topical media & game development
[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

talk show tell print

portal-classes-core.content.php



  <?PHP

  error_reporting(E_ALL);

  

  class Content {

  

          var core;

  

          function Content (&core) {

                  this->core = &core;

          }

          

          

          function setTopItems () {

                                  

                  if (isset(_GET['TopItemsNumber'])) {

                          topItemNumber = _GET['TopItemsNumber'];

                  } else {

                          topItemNumber = 1;

                  }                        

                  

                  if (topItemNumber < 0 || topItemNumber > 5 || empty(topItemNumber)) {

                          topItemNumber = 1;

                  }

                  

                  topItemNumber--; // -1 omdat limit bij 0 begint.

                  

                  sql = "SELECT content_id

                                  FROM user_content_rating

                                  WHERE content_id IN (        SELECT content_id

                                                                                  FROM content

                                                                                  WHERE content_type = 'video')

                                  ORDER BY user_content_rating_qualityvalue DESC

                                  LIMIT ".topItemNumber.",1"; 

                  

                  if (this->core->Db->getQueryNumRows(sql) == 0) {

                          // Er staat niets in de tabel , duhhhhhh , nu een random content_id

                          sql = "SELECT content_id

                                          FROM content

                                          WHERE content_type = 'video'

                                          ORDER BY rand()

                                          LIMIT 1";

                          queryResult = this->core->Db->getQueryResult(sql);

                          contentId = queryResult['content_id'];

                  } else {

                          queryResult = this->core->Db->getQueryResult(sql);

                          contentId = queryResult['content_id'];

                  }

                  

                  sql = "SELECT *

                                  FROM content

                                  WHERE content_id = ".contentId." ";

                  queryResult = this->core->Db->getQueryResult(sql);

                  

                  /* Oud toen het nog over alle type content ging

                  // Wat voor plaatje moet er komen?

                  switch (queryResult['content_type']) {

                          case 'audio':

                                  firstWord = 'AUDIO';

                                  imageUrl = '<img src="img/audio.jpg" width="475" height="150" />';

                                  break;

                          case 'video':

                                  firstWord = 'VIDEO';

                                  imageUrl = '<img src="img/video.jpg" width="475" height="150" />';

                                  break;

                          case 'picture':

                                  firstWord = 'PICTURE';

                                  imageUrl = '<img src="img/picture.jpg" width="475" height="150" />';

                                  break;

                          case 'article':

                                  firstWord = 'ARTICLE';

                                  imageUrl = '<img src="img/article.jpg" width="475" height="150" />';

                                  break;

                          default:

                                  imageUrl = '<img src="img/article.jpg" width="475" height="150" />';

                                  firstWord = 'FOUT';

                  }

                  

                  text = firstWord.' - '.this->core->Common->cutText(queryResult['content_binary'], 280);

  		*/

                  

                  if (queryResult['content_source_name'] == 'Youtube') {

                          videoCode = queryResult['content_binary'];

                  } else {

                          videoCode = '        <OBJECT id="mediaPlayer" width="400" height="300" 

                                                        classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" 

                                                        codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"

                                                        standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">

                                                        <param name="fileName" value="http://www.few.vu.nl/~casus07/cms/'.queryResult['content_binary'].'">

                                                        <param name="animationatStart" value="true">

                                                        <param name="transparentatStart" value="true">

                                                        <param name="autoStart" value="true">

                                                        <param name="showControls" value="true">

                                                        <param name="loop" value="true">

                                                        <EMBED type="application/x-mplayer2"

                                                                  pluginspage="http://microsoft.com/windows/mediaplayer/en/download/"

                                                                  id="mediaPlayer" name="mediaPlayer" displaysize="4" autosize="-1" 

                                                                  bgcolor="darkblue" showcontrols="true" showtracker="-1" 

                                                                  showdisplay="0" showstatusbar="-1" videoborder3d="-1" width="400" height="300"

                                                                  src="http://www.few.vu.nl/~casus07/cms/'.queryResult['content_binary'].'" autostart="true" designtimesp="5311" loop="true">

                                                          </EMBED>

                                                          </OBJECT>';

                  }                

                  

                  link = 'index.php?Page=VideoView&ContentId='.queryResult['content_id'];

                  

                  this->core->PageComm->setPageCommVar('top_items_text', queryResult['content_description']);

                  this->core->PageComm->setPageCommVar('top_items_video_code', videoCode);

                  this->core->PageComm->setPageCommVar('top_items_link', link);

                  

          }

          

          function getLatestPictures () {

                  

                  result = array();

  

                  sql = "SELECT content_id

                                  FROM content_type_picture

                                  ORDER BY content_type_picture_id DESC

                                  LIMIT 5";

                                  // Eventueel: WHERE rss_article = 0 om de rss feeds eruit te halen

                  articleQueryResults = this->core->Db->getQueryResults(sql);

                  

                  for (i = 0 ; i < count(articleQueryResults) ; i++) {

                  

                          sql = "SELECT *

                                          FROM content

                                          WHERE content_id = ".articleQueryResults[i]['content_id']." ";

                          contentQueryResult = this->core->Db->getQueryResult(sql);

                          

                          result[] = array(        "title"                        => contentQueryResult['content_title'],

                                                                  "content_id"        => articleQueryResults[i]['content_id'] ,

                                                                  "image_url"                => 'www.few.vu.nl/~casus07/cms/'.$contentQueryResult['content_binary'] );

                  }

                  

                  return result;

                  

                  

          }

          

          function getLatestArticles () {

                  

                  

                  result = array();

                  

                  sql = "SELECT content_id

                                  FROM content_type_article

                                  ORDER BY content_type_article_id DESC

                                  LIMIT 5";

                                  // Eventueel: WHERE rss_article = 0 om de rss feeds eruit te halen

                  articleQueryResults = this->core->Db->getQueryResults(sql);

                  

                  for (i = 0 ; i < count(articleQueryResults) ; i++) {

                  

                          sql = "SELECT *

                                          FROM content

                                          WHERE content_id = ".articleQueryResults[i]['content_id']." ";

                          contentQueryResult = this->core->Db->getQueryResult(sql);

                          

                          result[] = array(        "title"                        => contentQueryResult['content_title'],

                                                                  "text"                        => this->core->Common->cutText(contentQueryResult['content_binary'], 150),

                                                                  "content_id"        => articleQueryResults[i]['content_id'] );

                  }

                  

                  return result;                

                  

          }

          

          function getLatestAudio () {

                  

                  result = array();

                  

                  sql = "SELECT content_id

                                  FROM content_type_audio

                                  ORDER BY content_type_audio_id DESC

                                  LIMIT 5";

                                  // Eventueel: WHERE rss_article = 0 om de rss feeds eruit te halen

                  articleQueryResults = this->core->Db->getQueryResults(sql);

                  

                  for (i = 0 ; i < count(articleQueryResults) ; i++) {

                  

                          sql = "SELECT *

                                          FROM content

                                          WHERE content_id = ".articleQueryResults[i]['content_id']." ";

                          contentQueryResult = this->core->Db->getQueryResult(sql);

                          

                          result[] = array(        "title"                        => contentQueryResult['content_title'],

                                                                  "description"        => this->core->Common->cutText(contentQueryResult['content_binary'], 150),

                                                                  "content_id"        => articleQueryResults[i]['content_id'] );

                  }

                  

                  return result;                                

                  

          }        

                  

          function setViewCategoryVars () {

          

                  result = array();

                  

                  arrSelections = array();

                  whereStatement = '';

                  

                  category = _GET['Cat'];

                  

                  /*

                  healthSelected = 0;

                  politicsSelected = 0;

                  wildlifeSelected = 0;

                  energySelected = 0;

                  businessSelected = 0;

                  climateSelected = 0;

                  pollutionSelected = 0;

                  technologySelected = 0;

                  lifestyleSelected = 0;

                  environmentSelected = 0;

  		*/

                  

                  // de switch is niet perse nodig, maar de default is wel handig voor als niet is opgegeven

                  // Ook kan deze functie gebruikt worden om van meerdere categorien de content te krijgen

                  switch (category) {

                          case 'Health':

                                  arrSelections[] = 'health';

                                  break;

                          case 'Politics':

                                  arrSelections[] = 'politics';

                                  break;

                          case 'Wildlife':

                                  arrSelections[] = 'wildlife';

                                  break;

                          case 'Energy':

                                  arrSelections[] = 'energy';

                                  break;

                          case 'Business':

                                  arrSelections[] = 'business';

                                  break;

                          case 'Climate':

                                  arrSelections[] = 'climate';

                                  break;

                          case 'Pollution':

                                  arrSelections[] = 'pollution';

                                  break;

                          case 'Technology':

                                  arrSelections[] = 'technology';

                                  break;

                          case 'Lifestyle':

                                  arrSelections[] = 'lifestyle';

                                  break;

                          case 'Environment':

                                  arrSelections[] = 'environment';

                                  break;

                          default:

                                  arrSelections[] = 'health';

                  }        

                  

                  for (i = 0 ; i < count(arrSelections) ; i++) {                

                          if (i == 0) {

                                  whereStatement = 'WHERE '.arrSelections[i].' = 1';

                          } else {

                                  whereStatement .= 'AND '.arrSelections[i].' = 1';

                          }

                  }                                                                                                                                                                                                                                                                                                                

                          

                  sql = "SELECT content_id

                                  FROM content_matrix

                                  ".whereStatement."

                                  ORDER BY content_id DESC

                                  LIMIT 50";

                  catContentQueryResults = this->core->Db->getQueryResults(sql);

                                  

                  for (i = 0 ; i < count(catContentQueryResults) ; i++) { 

                  

                          sql = "SELECT *

                                          FROM content

                                          WHERE content_id = ".catContentQueryResults[i]['content_id']." ";

                          contentQueryResult = this->core->Db->getQueryResult(sql);

                                                  

                          switch (contentQueryResult['content_type']) {

                                  case 'picture':

                                  

                                          result[] = array(        "title"                                => contentQueryResult['content_title'],

                                                                                  "image_url"                        => 'www.few.vu.nl/~casus07/images/thumb_empty_image.jpg',

                                                                                  "link_url"                        => 'index.php?Page=PictureView&ContentId='.catContentQueryResults[i]['content_id'],

                                                                                  "text"                                => 'PICTURE - '.this->core->Common->cutText(contentQueryResult['content_description'], 150),

                                                                                  "content_id"                => catContentQueryResults[i]['content_id'] );

                                          break;

                                          

                                  case 'article':

                                                                  

                                          result[] = array(        "title"                                => contentQueryResult['content_title'],

                                                                                  "image_url"                        => 'www.few.vu.nl/~casus07/images/thumb_empty_article.jpg',

                                                                                  "link_url"                        => 'index.php?Page=ArticleView&ContentId='.catContentQueryResults[i]['content_id'],

                                                                                  "text"                                => 'ARTICLE - '.this->core->Common->cutText(contentQueryResult['content_binary'], 150),

                                                                                  "content_id"                => catContentQueryResults[i]['content_id'] );

                                          break;

                                          

                                  case 'video':

                                  

                                          result[] = array(        "title"                                => contentQueryResult['content_title'],

                                                                                  "image_url"                        => 'www.few.vu.nl/~casus07/images/thumb_empty_video.jpg',

                                                                                  "link_url"                        => 'index.php?Page=VideoView&ContentId='.catContentQueryResults[i]['content_id'],

                                                                                  "text"                                => 'VIDEO - '.this->core->Common->cutText(contentQueryResult['content_description'], 150),

                                                                                  "content_id"                => catContentQueryResults[i]['content_id'] );

                                          break;

                                          

                                  case 'audio':

                                  

                                          result[] = array(        "title"                                => contentQueryResult['content_title'],

                                                                                  "image_url"                        => 'www.few.vu.nl/~casus07/images/thumb_empty_audio.jpg',

                                                                                  "link_url"                        => 'index.php?Page=AudioView&ContentId='.catContentQueryResults[i]['content_id'],

                                                                                  "text"                                => 'VIDEO - '.this->core->Common->cutText(contentQueryResult['content_description'], 150),

                                                                                  "content_id"                => catContentQueryResults[i]['content_id'] );

                                          break;

                                          

                          }                                                                

                  }

                  

                  this->core->PageComm->setPageCommVar('cat_items', result);

                  this->core->PageComm->setPageCommVar('cat_title', category);

                                  

          }

          

          function setArticleView () {

                  

                  contentId = _GET['ContentId'];

                  

                  sql = "SELECT *

                                  FROM content

                                  WHERE content_id = ".contentId." ";

                  contentQueryResult = this->core->Db->getQueryResult(sql);

                                  

                  this->core->PageComm->setPageCommVar('article_title', contentQueryResult['content_title']);

                  this->core->PageComm->setPageCommVar('article_text', contentQueryResult['content_binary']);

                  this->core->PageComm->setPageCommVar('article_sourceurl', contentQueryResult['content_sourceurl']);

                  

          }

          

          function setVideoView () {

                  

                  contentId = _GET['ContentId'];

                  

                  sql = "SELECT *

                                  FROM content

                                  WHERE content_id = ".contentId." ";

                  contentQueryResult = this->core->Db->getQueryResult(sql);

                  

                  

                  if (contentQueryResult['content_source_name'] == 'Youtube') {

                          videoCode = contentQueryResult['content_binary'];

                  } else {

                          videoCode = '        <OBJECT id="mediaPlayer" width="400" height="300" 

                                                        classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" 

                                                        codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"

                                                        standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">

                                                        <param name="fileName" value="http://www.few.vu.nl/~casus07/cms/'.contentQueryResult['content_binary'].'">

                                                        <param name="animationatStart" value="true">

                                                        <param name="transparentatStart" value="true">

                                                        <param name="autoStart" value="true">

                                                        <param name="showControls" value="true">

                                                        <param name="loop" value="true">

                                                        <EMBED type="application/x-mplayer2"

                                                                  pluginspage="http://microsoft.com/windows/mediaplayer/en/download/"

                                                                  id="mediaPlayer" name="mediaPlayer" displaysize="4" autosize="-1" 

                                                                  bgcolor="darkblue" showcontrols="true" showtracker="-1" 

                                                                  showdisplay="0" showstatusbar="-1" videoborder3d="-1" width="400" height="300"

                                                                  src="http://www.few.vu.nl/~casus07/cms/'.contentQueryResult['content_binary'].'" autostart="true" designtimesp="5311" loop="true">

                                                          </EMBED>

                                                          </OBJECT>';

                  }

                  

                  

                  this->core->PageComm->setPageCommVar('video_title', contentQueryResult['content_title']);

                  this->core->PageComm->setPageCommVar('video_description', contentQueryResult['content_description']);

                  this->core->PageComm->setPageCommVar('audio_sourceurl', contentQueryResult['content_sourceurl']);

                  this->core->PageComm->setPageCommVar('video_code', videoCode);                

                  

          }

          

          function setAudioView () {

                  

                  contentId = _GET['ContentId'];

                  

                  sql = "SELECT *

                                  FROM content

                                  WHERE content_id = ".contentId." ";

                  contentQueryResult = this->core->Db->getQueryResult(sql);

                                  

                  this->core->PageComm->setPageCommVar('audio_file_url', 'www.few.vu.nl/~casus07/cms/'.$contentQueryResult['content_binary']);

                  this->core->PageComm->setPageCommVar('audio_title', contentQueryResult['content_title']);

                  this->core->PageComm->setPageCommVar('audio_sourceurl', contentQueryResult['content_sourceurl']);

                  this->core->PageComm->setPageCommVar('audio_description', contentQueryResult['content_description']);                

                  

          }

          

          function setPictureView () {

                  

                  contentId = _GET['ContentId'];

                  

                  sql = "SELECT *

                                  FROM content

                                  WHERE content_id = ".contentId." ";

                  contentQueryResult = this->core->Db->getQueryResult(sql);

                                  

                  this->core->PageComm->setPageCommVar('picture_file_url', 'www.few.vu.nl/~casus07/cms/'.$contentQueryResult['content_binary']);

                  this->core->PageComm->setPageCommVar('picture_title', contentQueryResult['content_title']);

                  this->core->PageComm->setPageCommVar('picture_sourceurl', contentQueryResult['content_sourceurl']);

                  this->core->PageComm->setPageCommVar('picture_description', contentQueryResult['content_description']);        

                  

          }

          

      

      

  }

  

  ?>


(C) A. Eliëns 2/9/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.