paristemi
[ class tree: paristemi ] [ index: paristemi ] [ all elements ]

Source for file db_multimedia.php

Documentation is available at db_multimedia.php

  1. <?php
  2. /**
  3. * <b>Database Class : Multimedia</b><br />
  4. * Provides all database access methods for the multimedia section
  5. * @author Kristen O'Brien <kristen_paristemi-com>
  6. * @copyright Copyright 2004, Kristen O'Brien
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. * @link http://www.paristemi.com Paristemi Main Site
  9. * @package paristemi
  10. * @subpackage paristemi_database_layer
  11. * @since Build 0.5
  12. * @version Build 0.7
  13. * @filesource
  14. */
  15. /**
  16. * <b>Database Class : Multimedia</b><br />
  17. * Provides all database access methods for the multimedia section
  18. * @author Kristen O'Brien <kristen_paristemi-com>
  19. * @copyright Copyright 2004, Kristen O'Brien
  20. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  21. * @link http://www.paristemi.com Paristemi Main Site
  22. * @package paristemi
  23. * @subpackage paristemi_database_layer
  24. * @since Build 0.5
  25. * @version Build 0.7
  26. * @filesource
  27. */
  28. class DB_Multimedia {
  29.  
  30. function DB_Multimedia() { }
  31.  
  32. //There must be an ID associated with all of the elements.
  33. function &GetMultimediaAudio() {
  34. $data = Array();
  35. $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
  36. A.LinkStream, A.Category,
  37. A.LinkDownload, A.PPTLink, A.PDFLink
  38. from Audio A
  39. where A.ShowMultimedia != 0
  40. order by A.Title");
  41.  
  42. //Process each row.
  43. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  44.  
  45. $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
  46. $row['Description'], $row['Transcript'],
  47. "", $row['LinkStream'],
  48. $row['LinkDownload'],
  49. $row['PPTLink'],$row['PDFLink']);
  50. }
  51.  
  52. return $data;
  53. }
  54. //There must be an ID associated with all of the elements.
  55. function &GetMultimediaAudioByLimit($limit,$blimit) {
  56. $data = Array();
  57. $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
  58. A.LinkStream, A.Category,
  59. A.LinkDownload, A.PPTLink, A.PDFLink
  60. from Audio A
  61. where A.ShowMultimedia != 0
  62. order by A.Title
  63. limit $blimit,$limit");
  64.  
  65. //Process each row.
  66. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  67.  
  68. $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
  69. $row['Description'], $row['Transcript'],
  70. "", $row['LinkStream'],
  71. $row['LinkDownload'],
  72. $row['PPTLink'],$row['PDFLink']);
  73. }
  74.  
  75. return $data;
  76. }
  77. //There must be an ID associated with all of the elements.
  78. function &GetMultimediaAudioCategories() {
  79. $data = Array();
  80. $result = mysql_query("select distinct Category
  81. from Audio
  82. where ShowMultimedia != 0
  83. order by Category");
  84.  
  85. //Process each row.
  86. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  87. $data[] = $row['Category'];
  88. }
  89.  
  90. return $data;
  91. }
  92. function &SearchAudioType(&$item,$atype,$limit,$blimit) {
  93. $data = Array();
  94. $query_string = "select DISTINCTROW A.ID, A.Title, A.Description, A.Transcript,
  95. A.LinkStream, A.Category,
  96. A.LinkDownload, A.PPTLink, A.PDFLink
  97. from Audio A
  98. where A.ShowMultimedia != 0 AND (";
  99.  
  100. foreach($atype as $type) {
  101. if($type == "category") {
  102. $query_string = $query_string . "A.Category LIKE '%$item%' OR ";
  103. }
  104. else if($type == "description") {
  105. $query_string = $query_string . "A.Description LIKE '%$item%' OR ";
  106. }
  107. else if($type == "title") {
  108. $query_string = $query_string . "A.Title LIKE '%$item%' OR ";
  109. }
  110. else if($type == "transcript") {
  111. $query_string = $query_string . "MATCH(A.Transcript) AGAINST('$item') OR ";
  112. }
  113. else { die("Invalid Parameters"); }
  114. }
  115. if(count($atype) == 0) { die("Invalid Parameters"); }
  116. $query_string = substr($query_string,0,strlen($query_string)-4);
  117. $query_string = $query_string . ") order by A.Title
  118. limit $blimit,$limit";
  119. $result = mysql_query($query_string);
  120. //Process each row.
  121. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  122. $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
  123. $row['Description'], $row['Transcript'],
  124. "", $row['LinkStream'],
  125. $row['LinkDownload'],
  126. $row['PPTLink'],$row['PDFLink']);
  127. }
  128.  
  129. return $data;
  130. }
  131.  
  132. function &SearchAudioCount(&$item,$atype) {
  133. $data = Array();
  134. $query_string = "SELECT DISTINCTROW COUNT(*)
  135. from Audio A
  136. where A.ShowMultimedia != 0 AND (";
  137.  
  138. foreach($atype as $type) {
  139. if($type == "category") {
  140. $query_string = $query_string . "A.Category LIKE '%$item%' OR ";
  141. }
  142. else if($type == "description") {
  143. $query_string = $query_string . "A.Description LIKE '%$item%' OR ";
  144. }
  145. else if($type == "title") {
  146. $query_string = $query_string . "A.Title LIKE '%$item%' OR ";
  147. }
  148. else if($type == "transcript") {
  149. $query_string = $query_string . "MATCH(A.Transcript) AGAINST('$item') OR ";
  150. }
  151. else { die("Invalid Parameters"); }
  152. }
  153. if(count($atype) == 0) { die("Invalid Parameters"); }
  154. $query_string = substr($query_string,0,strlen($query_string)-4);
  155. $query_string = $query_string . " )";
  156. $result = mysql_query($query_string);
  157. $row = mysql_fetch_array($result, MYSQL_ASSOC);
  158. foreach($row as $item) { $count = $item; }
  159. return $count;
  160. }
  161.  
  162.  
  163. //There must be an ID associated with all of the elements.
  164. function &GetMultimediaAudioRandom($lim) {
  165. $data = Array();
  166. $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
  167. A.LinkStream, A.Category,
  168. A.PPTLink, A.PDFLink, A.LinkDownload
  169. from Audio A
  170. where A.ShowMultimedia != 0
  171. order by rand()
  172. limit $lim");
  173.  
  174. //Process each row.
  175. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  176.  
  177. $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
  178. $row['Description'], $row['Transcript'],
  179. "", $row['LinkStream'],
  180. $row['LinkDownload'],
  181. $row['PPTLink'], $row['PDFLink']);
  182. }
  183.  
  184. return $data;
  185. }
  186. //There must be an ID associated with all of the elements.
  187. function &GetMultimediaAudioRecent($lim) {
  188. $data = Array();
  189. $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
  190. A.LinkStream, A.Category,
  191. A.PPTLink, A.PDFLink, A.LinkDownload
  192. from Audio A
  193. where A.ShowMultimedia != 0
  194. order by A.ID desc
  195. limit $lim");
  196.  
  197. //Process each row.
  198. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  199.  
  200. $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
  201. $row['Description'], $row['Transcript'],
  202. "", $row['LinkStream'],
  203. $row['LinkDownload'],
  204. $row['PPTLink'], $row['PDFLink']);
  205. }
  206.  
  207. return $data;
  208. }
  209. //There must be an ID associated with all of the elements.
  210. function &GetMultimediaAudioCategory(&$cat) {
  211. $data = Array();
  212. $cat = str_replace("_"," ",$cat);
  213. $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
  214. A.LinkStream, A.Category,
  215. A.PPTLink, A.PDFLink, A.LinkDownload
  216. from Audio A
  217. where A.ShowMultimedia != 0
  218. AND A.Category = '$cat'
  219. order by A.ID desc");
  220.  
  221. //Process each row.
  222. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  223. $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
  224. $row['Description'], $row['Transcript'],
  225. "", $row['LinkStream'],
  226. $row['LinkDownload'],
  227. $row['PPTLink'],$row['PDFLink']);
  228. }
  229.  
  230. return $data;
  231. }
  232. //There must be an ID associated with all of the elements.
  233. function &GetMultimediaAudioItem(&$id) {
  234. $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
  235. A.LinkStream, A.Category,
  236. A.PPTLink, A.PDFLink, A.LinkDownload,
  237. A.BookReference, A.StartVerse, A.StopVerse
  238. from Audio A
  239. where A.ID = $id
  240. order by A.Category
  241. limit 1");
  242.  
  243. $row = mysql_fetch_array($result, MYSQL_ASSOC);
  244.  
  245. $data = new AudioData($row['ID'], $row['Title'], $row['Category'],
  246. $row['Description'], $row['Transcript'],
  247. "", $row['LinkStream'],
  248. $row['LinkDownload'],
  249. $row['PPTLink'],$row['PDFLink'],
  250. $row['BookReference'],$row['StartVerse'],
  251. $row['StopVerse']);
  252.  
  253. return $data;
  254. }
  255. //There must be an ID associated with all of the elements.
  256. function &GetAllHardQuestions($lbegin=0,$lim=0) {
  257. $data = array();
  258. if($lim == 0) { $lim = $GLOBALS['LISTING_LIMIT']; }
  259. $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
  260. A.LinkStream, A.Category,
  261. A.PPTLink, A.PDFLink, A.LinkDownload
  262. from Audio A
  263. where A.Description LIKE '%Hard Questions%'
  264. order by A.Title
  265. limit $lbegin,$lim");
  266.  
  267. while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  268. $data[] = new AudioData($row['ID'], $row['Title'], $row['Category'],
  269. $row['Description'], $row['Transcript'],
  270. "", $row['LinkStream'],
  271. $row['LinkDownload'],
  272. $row['PPTLink'],$row['PDFLink']);
  273. }
  274. return $data;
  275. }
  276. //There must be an ID associated with all of the elements.
  277. function &GetHardQuestionsCount() {
  278. $data = array();
  279. $result = mysql_query("select COUNT(DISTINCT A.ID)
  280. from Audio A
  281. where A.Description LIKE '%Hard Questions%'");
  282. return mysql_result($result,0,0);
  283. }
  284. // There must be an ID associated with all of the elements.
  285. function &GetAllAudioCount() {
  286. $data = array();
  287. $result = mysql_query("select COUNT(DISTINCT A.ID)
  288. from Audio A
  289. where A.ShowMultimedia > 0");
  290. return mysql_result($result,0,0);
  291. }
  292. //There must be an ID associated with all of the elements.
  293. function &GetShowcaseHardQuestion() {
  294. $result = mysql_query("select A.ID, A.Title, A.Description, A.Transcript,
  295. A.LinkStream, A.Category,
  296. A.PPTLink, A.PDFLink, A.LinkDownload
  297. from Audio A
  298. where A.Description LIKE '%Hard Questions%'
  299. AND A.Description LIKE '%This Month%'
  300. limit 1");
  301.  
  302. $row = mysql_fetch_array($result, MYSQL_ASSOC);
  303. $data = new AudioData($row['ID'], $row['Title'], $row['Category'],
  304. $row['Description'], $row['Transcript'],
  305. "", $row['LinkStream'],
  306. $row['LinkDownload'],
  307. $row['PPTLink'],$row['PDFLink']);
  308. return $data;
  309. }
  310. //There must be an ID associated with all of the elements.
  311. function &GetMultimediaVideo() {
  312. $data = Array();
  313. $result = mysql_query("select V.ID, V.Title, V.Description, V.Links,
  314. V.Notes, V.Category
  315. from Video V
  316. where V.ShowMultimedia != 0
  317. order by V.Category");
  318.  
  319. //Process each row.
  320. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  321. $row['Links'] = eval("array(".$row['Links'].");");
  322. $data[] = new VideoData($row['ID'], $row['Title'], $row['Category'],
  323. $row['Description'], $row['Links'], $row['Notes']);
  324. }
  325.  
  326. return $data;
  327. }
  328. //There must be an ID associated with all of the elements.
  329. function &GetMultimediaVideoCategories() {
  330. $data = Array();
  331. $result = mysql_query("select distinct Category
  332. from Video
  333. where ShowMultimedia != 0
  334. order by Category");
  335.  
  336. //Process each row.
  337. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  338. $data[] = $row['Category'];
  339. }
  340.  
  341. return $data;
  342. }
  343. //There must be an ID associated with all of the elements.
  344. function &GetMultimediaVideoRandom($lim) {
  345. $data = Array();
  346. $result = mysql_query("select V.ID, V.Title, V.Description, V.Links,
  347. V.Notes, V.Category
  348. from Video V
  349. where V.ShowMultimedia != 0
  350. order by rand()
  351. limit $lim");
  352.  
  353. //Process each row.
  354. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  355. $row['Links'] = eval("array(".$row['Links'].");");
  356. $data[] = new VideoData($row['ID'], $row['Title'], $row['Category'],
  357. $row['Description'], $row['Links'], $row['Notes']);
  358. }
  359.  
  360. return $data;
  361. }
  362. //There must be an ID associated with all of the elements.
  363. function &GetMultimediaVideoRecent($lim) {
  364. $data = Array();
  365. $result = mysql_query("select V.ID, V.Title, V.Description, V.Links,
  366. V.Notes, V.Category
  367. from Video V
  368. where V.ShowMultimedia != 0
  369. order by V.ID desc
  370. limit $lim");
  371.  
  372. //Process each row.
  373. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  374. $row['Links'] = eval("array(".$row['Links'].");");
  375. $data[] = new VideoData($row['ID'], $row['Title'], $row['Category'],
  376. $row['Description'], $row['Links'], $row['Notes']);
  377. }
  378.  
  379. return $data;
  380. }
  381. //There must be an ID associated with all of the elements.
  382. function &GetMultimediaVideoCategory(&$cat) {
  383. $data = Array();
  384. $result = mysql_query("select V.ID, V.Title, V.Description, V.Links,
  385. V.Notes, V.Category
  386. from Video V
  387. where V.ShowMultimedia != 0
  388. order by V.Category");
  389.  
  390. //Process each row.
  391. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  392. if($cat == str_replace(" ", "", $row['Category'])) {
  393. $row['Links'] = eval("array(".$row['Links'].");");
  394. $data[] = new VideoData($row['ID'], $row['Title'], $row['Category'],
  395. $row['Description'], $row['Links'], $row['Notes']);
  396. }
  397. }
  398.  
  399. return $data;
  400. }
  401. //There must be an ID associated with all of the elements.
  402. function &GetMultimediaVideoItem(&$id) {
  403. $result = mysql_query("select V.ID, V.Title, V.Description, V.Links,
  404. V.Notes, V.Category
  405. from Video V
  406. where V.ID = $id
  407. order by V.Category
  408. limit 1");
  409.  
  410. $row = mysql_fetch_array($result, MYSQL_ASSOC);
  411. $links = array();
  412. $links = eval("return array(".$row['Links'].");");
  413.  
  414. $data = new VideoData($row['ID'], $row['Title'], $row['Category'],
  415. $row['Description'], $links, $row['Notes']);
  416.  
  417. return $data;
  418. }
  419. }
  420.  
  421. /**
  422. * <b>Database Container Class : Audio</b><br />
  423. * Contains all of the specific data for a audio file.
  424. * @author Kristen O'Brien <kristen_paristemi-com>
  425. * @copyright Copyright 2004, Kristen O'Brien
  426. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  427. * @link http://www.paristemi.com Paristemi Main Site
  428. * @package paristemi
  429. * @subpackage paristemi_database_layer
  430. * @since Build 0.5
  431. * @version Build 0.7
  432. * @filesource
  433. */
  434. class AudioData {
  435. var $ID;
  436. var $Title;
  437. var $Category;
  438. var $Description;
  439. var $Transcript;
  440. var $Topic;
  441. var $ALinkStream;
  442. var $ALinkDownload;
  443. var $PPTLink;
  444. var $PDFLink;
  445. var $BookReference;
  446. var $StartVerse;
  447. var $StopVerse;
  448. function AudioData($id, $title, $category, $desc, $transcript, $topic,
  449. $alink,$alinkdl,$pptlink,$pdflink,
  450. $bookref="",$startverse=0,$stopverse=0) {
  451. $this->ID = $id;
  452. $this->Title = $title;
  453. $this->Category = $category;
  454. $this->Description = $desc;
  455. $this->Transcript = $transcript;
  456. $this->Topic = $topic;
  457. $this->ALinkStream = $alink;
  458. $this->ALinkDownload = $alinkdl;
  459. $this->PPTLink = $pptlink;
  460. $this->PDFLink = $pdflink;
  461. $this->BookReference = $bookref;
  462. $this->StartVerse = $startverse;
  463. $this->StopVerse = $stopverse;
  464. }
  465. }
  466.  
  467. /**
  468. * <b>Database Container Class : Calendar Search</b><br />
  469. * Contains all of the specific data for video file(s).
  470. * @author Kristen O'Brien <kristen_paristemi-com>
  471. * @copyright Copyright 2004, Kristen O'Brien
  472. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  473. * @link http://www.paristemi.com Paristemi Main Site
  474. * @package paristemi
  475. * @subpackage paristemi_database_layer
  476. * @since Build 0.5
  477. * @version Build 0.7
  478. * @filesource
  479. */
  480. class VideoData {
  481. var $ID;
  482. var $Title;
  483. var $Category;
  484. var $Description;
  485. var $Size;
  486. var $Links;
  487. var $Notes;
  488. function VideoData($id, $title, $category, $desc, $links, $notes) {
  489. $this->ID = $id;
  490. $this->Title = $title;
  491. $this->Category = $category;
  492. $this->Description = $desc;
  493. $this->Links = $links;
  494. $this->Notes = $notes;
  495. }
  496. }
  497.  
  498. ?>

Documentation generated on Mon, 10 May 2004 12:09:14 -0700 by phpDocumentor 1.3.0RC3