Go to the documentation of this file.00001 <?php
00002
00006 class Tag extends aList
00007 {
00008
00014 protected $_sListType = 'tag';
00015
00021 protected $_blShowSorting = true;
00022
00028 protected $_sTag;
00029
00035 protected $_sTagTitle;
00036
00042 protected $_oPageNavigation = null;
00043
00049 protected $_sTemplateLocation;
00050
00056 protected $_iViewIndexState = VIEW_INDEXSTATE_INDEX;
00057
00063 public function render()
00064 {
00065 oxUBase::render();
00066
00067 $oArticleList = $this->getArticleList();
00068
00069
00070 if (!$this->showTags() || !$oArticleList) {
00071 error_404_handler();
00072 }
00073
00074
00075 $this->_processListArticles();
00076
00077 return $this->_sThisTemplate;
00078 }
00079
00085 protected function _getProductLinkType()
00086 {
00087 return OXARTICLE_LINKTYPE_TAG;
00088 }
00089
00095 public function getAddUrlParams()
00096 {
00097 $sAddParams = parent::getAddUrlParams();
00098 $sAddParams .= ($sAddParams ? '&' : '') . "listtype={$this->_sListType}";
00099 if ($sParam = oxRegistry::getConfig()->getRequestParameter('searchtag', true)) {
00100 $sAddParams .= "&searchtag=" . rawurlencode($sParam);
00101 }
00102
00103 return $sAddParams;
00104 }
00105
00113 protected function _loadArticles($oCategory)
00114 {
00115
00116 $iNrofCatArticles = (int) $this->getConfig()->getConfigParam('iNrofCatArticles');
00117 $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 1;
00118 $oArtList = oxNew('oxarticlelist');
00119 $oArtList->setSqlLimit($iNrofCatArticles * $this->_getRequestPageNr(), $iNrofCatArticles);
00120 $oArtList->setCustomSorting($this->getSortingSql($this->getSortIdent()));
00121
00122 $this->_iAllArtCnt = $oArtList->loadTagArticles($this->getTag(), oxRegistry::getLang()->getBaseLanguage());
00123 $this->_iCntPages = round($this->_iAllArtCnt / $iNrofCatArticles + 0.49);
00124
00125 return $oArtList;
00126 }
00127
00133 protected function _getCatPathString()
00134 {
00135 return $this->getTag();
00136 }
00137
00143 protected function _getSeoObjectId()
00144 {
00145 return md5("tag" . $this->getTag());
00146 }
00147
00153 public function generatePageNavigationUrl()
00154 {
00155 if ((oxRegistry::getUtils()->seoIsActive() && ($sTag = $this->getTag()))) {
00156 $sLink = oxRegistry::get("oxSeoEncoderTag")->getTagUrl($sTag, oxRegistry::getLang()->getBaseLanguage());
00157 }
00158
00159 return $sLink ? $sLink : oxUBase::generatePageNavigationUrl();
00160 }
00161
00171 protected function _addPageNrParam($sUrl, $iPage, $iLang = null)
00172 {
00173 $sSeoUrl = $blSeo = oxRegistry::getUtils()->seoIsActive();
00174 if ($blSeo && ($sTag = $this->getTag())) {
00175 if ($iPage && ($sSeoUrl = oxRegistry::get("oxSeoEncoderTag")->getTagPageUrl($sTag, $iPage, $iLang))) {
00176
00177 $sUrl = $sSeoUrl;
00178 }
00179 }
00180
00181 return (!$blSeo || !$sSeoUrl) ? oxUBase::_addPageNrParam($sUrl, $iPage, $iLang) : $sUrl;
00182 }
00183
00189 public function getArticleList()
00190 {
00191 if ($this->_aArticleList === null) {
00192 if (($this->getTag())) {
00193 $this->_aArticleList = $this->_loadArticles(null);
00194 }
00195 }
00196
00197 return $this->_aArticleList;
00198 }
00199
00205 public function getTag()
00206 {
00207 if ($this->_sTag === null) {
00208 $this->_sTag = oxRegistry::getConfig()->getRequestParameter("searchtag", false);
00209 }
00210
00211 return $this->_sTag;
00212 }
00213
00219 public function getTitle()
00220 {
00221 if ($this->_sTagTitle === null) {
00222 $this->_sTagTitle = false;
00223 if (($sTag = $this->getTag())) {
00224 $oStr = getStr();
00225 $sTitle = $oStr->ucfirst($sTag);
00226 $this->_sTagTitle = $oStr->htmlspecialchars($sTitle);
00227 }
00228 }
00229
00230 return $this->_sTagTitle;
00231 }
00232
00238 public function getTreePath()
00239 {
00240 if (($sTag = $this->getTag())) {
00241 $oStr = getStr();
00242
00243 $aPath[0] = oxNew("oxcategory");
00244 $aPath[0]->setLink(false);
00245 $aPath[0]->oxcategories__oxtitle = new oxField(oxRegistry::getLang()->translateString('TAGS'));
00246
00247 $aPath[1] = oxNew("oxcategory");
00248 $aPath[1]->setLink(false);
00249 $aPath[1]->oxcategories__oxtitle = new oxField($oStr->ucfirst($sTag));
00250
00251 return $aPath;
00252 }
00253 }
00254
00264 protected function _prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords = true)
00265 {
00266 return parent::_collectMetaKeyword($sKeywords);
00267 }
00268
00279 protected function _prepareMetaDescription($sMeta, $iLength = 1024, $blDescTag = false)
00280 {
00281 return parent::_collectMetaDescription($sMeta, $iLength, $blDescTag);
00282 }
00283
00289 public function getCanonicalUrl()
00290 {
00291 if (($iPage = $this->getActPage())) {
00292 return $this->_addPageNrParam($this->generatePageNavigationUrl(), $iPage);
00293 } elseif (($sTag = $this->getTag())) {
00294 return oxRegistry::get("oxSeoEncoderTag")->getTagUrl($sTag);
00295 }
00296 }
00297
00303 public function getBreadCrumb()
00304 {
00305 $aPaths = array();
00306 $aCatPath = array();
00307
00308 $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
00309 $sSelfLink = $this->getViewConfig()->getSelfLink();
00310
00311 $aCatPath['title'] = oxRegistry::getLang()->translateString('TAGS', $iBaseLanguage, false);
00312 $aCatPath['link'] = oxRegistry::get("oxSeoEncoder")->getStaticUrl($sSelfLink . 'cl=tags');
00313 $aPaths[] = $aCatPath;
00314
00315 $aCatPath['title'] = $this->getTitle();
00316 $aCatPath['link'] = $this->getCanonicalUrl();
00317 $aPaths[] = $aCatPath;
00318
00319 return $aPaths;
00320 }
00321 }