oxtaglist.php

Go to the documentation of this file.
00001 <?php
00002 
00003 if (!defined('OXTAGCLOUD_MINFONT')) {
00004     define('OXTAGCLOUD_MINTAGLENGTH', 4);
00005     define('OXTAGCLOUD_STARTPAGECOUNT', 20);
00006     define('OXTAGCLOUD_EXTENDEDCOUNT', 200);
00007 }
00013 class oxTagList extends oxI18n implements oxITagList
00014 {
00015 
00021     protected $_oTagSet = null;
00022 
00028     protected $_blExtended = false;
00029 
00033     public function __construct()
00034     {
00035         parent::__construct();
00036         $this->_oTagSet = oxNew('oxtagset');
00037     }
00038 
00044     public function getCacheId()
00045     {
00046         return 'tag_list_' . $this->getLanguage();
00047     }
00048 
00054     public function loadList()
00055     {
00056         $oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
00057 
00058         $iLang = $this->getLanguage();
00059 
00060         $sArtView = getViewName('oxarticles', $iLang);
00061         $sViewName = getViewName('oxartextends', $iLang);
00062 
00063         // check if article is still active
00064         $oArticle = oxNew('oxarticle');
00065         $oArticle->setLanguage($iLang);
00066         $sArtActive = $oArticle->getActiveCheckQuery(true);
00067 
00068         $sQ = "SELECT {$sViewName}.`oxtags` AS `oxtags`
00069             FROM {$sArtView} AS `oxarticles`
00070                 LEFT JOIN {$sViewName} ON `oxarticles`.`oxid` = {$sViewName}.`oxid`
00071             WHERE `oxarticles`.`oxactive` = 1 AND $sArtActive";
00072 
00073         $oDb->setFetchMode(oxDb::FETCH_MODE_ASSOC);
00074         $oRs = $oDb->select($sQ);
00075 
00076         $this->get()->clear();
00077         while ($oRs && $oRs->recordCount() && !$oRs->EOF) {
00078             $this->_addTagsFromDb($oRs->fields['oxtags']);
00079             $oRs->moveNext();
00080         }
00081 
00082         return $this->_isLoaded = true;
00083     }
00084 
00090     public function get()
00091     {
00092         return $this->_oTagSet;
00093     }
00094 
00100     public function addTag($mTag)
00101     {
00102         $this->_oTagSet->addTag($mTag);
00103     }
00104 
00112     protected function _addTagsFromDb($sTags)
00113     {
00114         if (empty($sTags)) {
00115             return;
00116         }
00117         $sSeparator = $this->get()->getSeparator();
00118         $aTags = explode($sSeparator, $sTags);
00119         foreach ($aTags as $sTag) {
00120             $oTag = oxNew("oxtag");
00121             $oTag->set($sTag, false);
00122             $oTag->removeUnderscores();
00123             $this->addTag($oTag);
00124         }
00125     }
00126 }