- <?php
- /**
- * <b>Database Class : Multimedia</b><br />
- * Provides all database access methods for the multimedia section
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_database_layer
- * @since Build 0.5
- * @version Build 0.7
- * @filesource
- */
- /**
- * <b>Database Class : Multimedia</b><br />
- * Provides all database access methods for the multimedia section
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_database_layer
- * @since Build 0.5
- * @version Build 0.7
- * @filesource
- */
- class DB_Multimedia {
-
- function DB_Multimedia() { }
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaAudio() {
- $data = Array();
- $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
- A.LinkStream, A.Category,
- A.LinkDownload, A.PPTLink, A.PDFLink
- from Audio A
- where A.ShowMultimedia != 0
- order by A.Title");
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
-
- $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Transcript'],
- "", $row['LinkStream'],
- $row['LinkDownload'],
- $row['PPTLink'],$row['PDFLink']);
- }
-
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaAudioByLimit($limit,$blimit) {
- $data = Array();
- $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
- A.LinkStream, A.Category,
- A.LinkDownload, A.PPTLink, A.PDFLink
- from Audio A
- where A.ShowMultimedia != 0
- order by A.Title
- limit $blimit,$limit");
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
-
- $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Transcript'],
- "", $row['LinkStream'],
- $row['LinkDownload'],
- $row['PPTLink'],$row['PDFLink']);
- }
-
- return $data;
- }
-
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaAudioCategories() {
- $data = Array();
- $result = mysql_query("select distinct Category
- from Audio
- where ShowMultimedia != 0
- order by Category");
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
- $data[] = $row['Category'];
- }
-
- return $data;
- }
-
- function &SearchAudioType(&$item,$atype,$limit,$blimit) {
- $data = Array();
- $query_string = "select DISTINCTROW A.ID, A.Title, A.Description, A.Transcript,
- A.LinkStream, A.Category,
- A.LinkDownload, A.PPTLink, A.PDFLink
- from Audio A
- where A.ShowMultimedia != 0 AND (";
-
- foreach($atype as $type) {
- if($type == "category") {
- $query_string = $query_string . "A.Category LIKE '%$item%' OR ";
- }
- else if($type == "description") {
- $query_string = $query_string . "A.Description LIKE '%$item%' OR ";
- }
- else if($type == "title") {
- $query_string = $query_string . "A.Title LIKE '%$item%' OR ";
- }
- else if($type == "transcript") {
- $query_string = $query_string . "MATCH(A.Transcript) AGAINST('$item') OR ";
- }
- else { die("Invalid Parameters"); }
- }
- if(count($atype) == 0) { die("Invalid Parameters"); }
-
- $query_string = substr($query_string,0,strlen($query_string)-4);
- $query_string = $query_string . ") order by A.Title
- limit $blimit,$limit";
- $result = mysql_query($query_string);
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
- $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Transcript'],
- "", $row['LinkStream'],
- $row['LinkDownload'],
- $row['PPTLink'],$row['PDFLink']);
- }
-
- return $data;
- }
-
- function &SearchAudioCount(&$item,$atype) {
- $data = Array();
- $query_string = "SELECT DISTINCTROW COUNT(*)
- from Audio A
- where A.ShowMultimedia != 0 AND (";
-
- foreach($atype as $type) {
- if($type == "category") {
- $query_string = $query_string . "A.Category LIKE '%$item%' OR ";
- }
- else if($type == "description") {
- $query_string = $query_string . "A.Description LIKE '%$item%' OR ";
- }
- else if($type == "title") {
- $query_string = $query_string . "A.Title LIKE '%$item%' OR ";
- }
- else if($type == "transcript") {
- $query_string = $query_string . "MATCH(A.Transcript) AGAINST('$item') OR ";
- }
- else { die("Invalid Parameters"); }
- }
- if(count($atype) == 0) { die("Invalid Parameters"); }
-
- $query_string = substr($query_string,0,strlen($query_string)-4);
- $query_string = $query_string . " )";
- $result = mysql_query($query_string);
- $row = mysql_fetch_array($result, MYSQL_ASSOC);
- foreach($row as $item) { $count = $item; }
- return $count;
- }
-
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaAudioRandom($lim) {
- $data = Array();
- $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
- A.LinkStream, A.Category,
- A.PPTLink, A.PDFLink, A.LinkDownload
- from Audio A
- where A.ShowMultimedia != 0
- order by rand()
- limit $lim");
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
-
- $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Transcript'],
- "", $row['LinkStream'],
- $row['LinkDownload'],
- $row['PPTLink'], $row['PDFLink']);
- }
-
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaAudioRecent($lim) {
- $data = Array();
- $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
- A.LinkStream, A.Category,
- A.PPTLink, A.PDFLink, A.LinkDownload
- from Audio A
- where A.ShowMultimedia != 0
- order by A.ID desc
- limit $lim");
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
-
- $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Transcript'],
- "", $row['LinkStream'],
- $row['LinkDownload'],
- $row['PPTLink'], $row['PDFLink']);
- }
-
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaAudioCategory(&$cat) {
- $data = Array();
- $cat = str_replace("_"," ",$cat);
- $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
- A.LinkStream, A.Category,
- A.PPTLink, A.PDFLink, A.LinkDownload
- from Audio A
- where A.ShowMultimedia != 0
- AND A.Category = '$cat'
- order by A.ID desc");
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
- $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Transcript'],
- "", $row['LinkStream'],
- $row['LinkDownload'],
- $row['PPTLink'],$row['PDFLink']);
- }
-
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaAudioItem(&$id) {
- $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
- A.LinkStream, A.Category,
- A.PPTLink, A.PDFLink, A.LinkDownload,
- A.BookReference, A.StartVerse, A.StopVerse
- from Audio A
- where A.ID = $id
- order by A.Category
- limit 1");
-
- $row = mysql_fetch_array($result, MYSQL_ASSOC);
-
- $data = new AudioData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Transcript'],
- "", $row['LinkStream'],
- $row['LinkDownload'],
- $row['PPTLink'],$row['PDFLink'],
- $row['BookReference'],$row['StartVerse'],
- $row['StopVerse']);
-
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetAllHardQuestions($lbegin=0,$lim=0) {
- $data = array();
- if($lim == 0) { $lim = $GLOBALS['LISTING_LIMIT']; }
- $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
- A.LinkStream, A.Category,
- A.PPTLink, A.PDFLink, A.LinkDownload
- from Audio A
- where A.Description LIKE '%Hard Questions%'
- order by A.Title
- limit $lbegin,$lim");
-
- while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
- $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Transcript'],
- "", $row['LinkStream'],
- $row['LinkDownload'],
- $row['PPTLink'],$row['PDFLink']);
- }
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetHardQuestionsCount() {
- $data = array();
- $result = mysql_query("select COUNT(DISTINCT A.ID)
- from Audio A
- where A.Description LIKE '%Hard Questions%'");
- return mysql_result($result,0,0);
- }
- // There must be an ID associated with all of the elements.
-
- function &GetAllAudioCount() {
- $data = array();
- $result = mysql_query("select COUNT(DISTINCT A.ID)
- from Audio A
- where A.ShowMultimedia > 0");
- return mysql_result($result,0,0);
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetShowcaseHardQuestion() {
- $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
- A.LinkStream, A.Category,
- A.PPTLink, A.PDFLink, A.LinkDownload
- from Audio A
- where A.Description LIKE '%Hard Questions%'
- AND A.Description LIKE '%This Month%'
- limit 1");
-
- $row = mysql_fetch_array($result, MYSQL_ASSOC);
- $data = new AudioData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Transcript'],
- "", $row['LinkStream'],
- $row['LinkDownload'],
- $row['PPTLink'],$row['PDFLink']);
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaVideo() {
- $data = Array();
- $result = mysql_query("select V.ID, V.Title, V.Description, V.Links,
- V.Notes, V.Category
- from Video V
- where V.ShowMultimedia != 0
- order by V.Category");
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
- $row['Links'] = eval("array(".$row['Links'].");");
- $data[] = new VideoData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Links'], $row['Notes']);
- }
-
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaVideoCategories() {
- $data = Array();
- $result = mysql_query("select distinct Category
- from Video
- where ShowMultimedia != 0
- order by Category");
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
- $data[] = $row['Category'];
- }
-
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaVideoRandom($lim) {
- $data = Array();
- $result = mysql_query("select V.ID, V.Title, V.Description, V.Links,
- V.Notes, V.Category
- from Video V
- where V.ShowMultimedia != 0
- order by rand()
- limit $lim");
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
- $row['Links'] = eval("array(".$row['Links'].");");
- $data[] = new VideoData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Links'], $row['Notes']);
- }
-
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaVideoRecent($lim) {
- $data = Array();
- $result = mysql_query("select V.ID, V.Title, V.Description, V.Links,
- V.Notes, V.Category
- from Video V
- where V.ShowMultimedia != 0
- order by V.ID desc
- limit $lim");
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
- $row['Links'] = eval("array(".$row['Links'].");");
- $data[] = new VideoData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Links'], $row['Notes']);
- }
-
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaVideoCategory(&$cat) {
- $data = Array();
- $result = mysql_query("select V.ID, V.Title, V.Description, V.Links,
- V.Notes, V.Category
- from Video V
- where V.ShowMultimedia != 0
- order by V.Category");
-
- //Process each row.
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
- if($cat == str_replace(" ", "", $row['Category'])) {
- $row['Links'] = eval("array(".$row['Links'].");");
- $data[] = new VideoData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $row['Links'], $row['Notes']);
- }
- }
-
- return $data;
- }
-
- //There must be an ID associated with all of the elements.
-
- function &GetMultimediaVideoItem(&$id) {
- $result = mysql_query("select V.ID, V.Title, V.Description, V.Links,
- V.Notes, V.Category
- from Video V
- where V.ID = $id
- order by V.Category
- limit 1");
-
- $row = mysql_fetch_array($result, MYSQL_ASSOC);
- $links = array();
- $links = eval("return array(".$row['Links'].");");
-
- $data = new VideoData($row['ID'], $row['Title'], $row['Category'],
- $row['Description'], $links, $row['Notes']);
-
- return $data;
- }
- }
-
- /**
- * <b>Database Container Class : Audio</b><br />
- * Contains all of the specific data for a audio file.
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_database_layer
- * @since Build 0.5
- * @version Build 0.7
- * @filesource
- */
- class AudioData {
- var $ID;
- var $Title;
- var $Category;
- var $Description;
- var $Transcript;
- var $Topic;
- var $ALinkStream;
- var $ALinkDownload;
- var $PPTLink;
- var $PDFLink;
- var $BookReference;
- var $StartVerse;
- var $StopVerse;
-
- function AudioData($id, $title, $category, $desc, $transcript, $topic,
- $alink,$alinkdl,$pptlink,$pdflink,
- $bookref="",$startverse=0,$stopverse=0) {
- $this->ID = $id;
- $this->Title = $title;
- $this->Category = $category;
- $this->Description = $desc;
- $this->Transcript = $transcript;
- $this->Topic = $topic;
- $this->ALinkStream = $alink;
- $this->ALinkDownload = $alinkdl;
- $this->PPTLink = $pptlink;
- $this->PDFLink = $pdflink;
- $this->BookReference = $bookref;
- $this->StartVerse = $startverse;
- $this->StopVerse = $stopverse;
- }
- }
-
- /**
- * <b>Database Container Class : Calendar Search</b><br />
- * Contains all of the specific data for video file(s).
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_database_layer
- * @since Build 0.5
- * @version Build 0.7
- * @filesource
- */
- class VideoData {
- var $ID;
- var $Title;
- var $Category;
- var $Description;
- var $Size;
- var $Links;
- var $Notes;
-
- function VideoData($id, $title, $category, $desc, $links, $notes) {
- $this->ID = $id;
- $this->Title = $title;
- $this->Category = $category;
- $this->Description = $desc;
- $this->Links = $links;
- $this->Notes = $notes;
- }
- }
-
- ?>