OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxtaglist.php
Go to the documentation of this file.
1 <?php
2 
3 if (!defined('OXTAGCLOUD_MINFONT')) {
4  define('OXTAGCLOUD_MINTAGLENGTH', 4);
5  define('OXTAGCLOUD_STARTPAGECOUNT', 20);
6  define('OXTAGCLOUD_EXTENDEDCOUNT', 200);
7 }
13 class oxTagList extends oxI18n implements oxITagList
14 {
15 
21  protected $_oTagSet = null;
22 
28  protected $_blExtended = false;
29 
33  public function __construct()
34  {
36  $this->_oTagSet = oxNew( 'oxtagset' );
37  }
38 
44  public function getCacheId()
45  {
46  return 'tag_list_'.$this->getLanguage();
47  }
48 
54  public function loadList()
55  {
57 
58  $iLang = $this->getLanguage();
59 
60  $sArtView = getViewName( 'oxarticles', $iLang );
61  $sViewName = getViewName( 'oxartextends', $iLang );
62 
63  // check if article is still active
64  $oArticle = oxNew( 'oxarticle' );
65  $oArticle->setLanguage( $iLang );
66  $sArtActive = $oArticle->getActiveCheckQuery( true );
67 
68  $sQ = "SELECT {$sViewName}.`oxtags` AS `oxtags`
69  FROM {$sArtView} AS `oxarticles`
70  LEFT JOIN {$sViewName} ON `oxarticles`.`oxid` = {$sViewName}.`oxid`
71  WHERE `oxarticles`.`oxactive` = 1 AND $sArtActive";
72 
73  $oDb->setFetchMode( oxDb::FETCH_MODE_ASSOC );
74  $oRs = $oDb->select( $sQ );
75 
76  $this->get()->clear();
77  while ( $oRs && $oRs->recordCount() && !$oRs->EOF ) {
78  $this->_addTagsFromDb( $oRs->fields['oxtags'] );
79  $oRs->moveNext();
80  }
81 
82  return $this->_isLoaded = true;
83  }
84 
90  public function get()
91  {
92  return $this->_oTagSet;
93  }
94 
102  public function addTag( $mTag )
103  {
104  $this->_oTagSet->addTag( $mTag );
105  }
106 
114  protected function _addTagsFromDb( $sTags )
115  {
116  if ( empty( $sTags ) ) {
117  return;
118  }
119  $sSeparator = $this->get()->getSeparator();
120  $aTags = explode( $sSeparator, $sTags );
121  foreach ( $aTags as $sTag ) {
122  $oTag = oxNew( "oxtag" );
123  $oTag->set( $sTag, false );
124  $oTag->removeUnderscores();
125  $this->addTag( $oTag );
126  }
127  }
128 }