Go to the documentation of this file.00001 <?php
00002
00006 class Tag extends aList
00007 {
00012 protected $_sListType = 'tag';
00013
00018 protected $_blShowSorting = true;
00019
00025 protected $_sTag;
00026
00032 protected $_sTagTitle;
00033
00038 protected $_oPageNavigation = null;
00039
00045 protected $_sTemplateLocation;
00046
00052 protected $_iViewIndexState = VIEW_INDEXSTATE_INDEX;
00053
00059 public function render()
00060 {
00061 oxUBase::render();
00062
00063 $oArticleList = $this->getArticleList();
00064
00065
00066 if ( !$this->showTags() || !$oArticleList || count( $oArticleList ) < 1 ) {
00067 error_404_handler();
00068 }
00069
00070
00071 $this->_processListArticles();
00072
00073 return $this->_sThisTemplate;
00074 }
00075
00081 protected function _getProductLinkType()
00082 {
00083 return OXARTICLE_LINKTYPE_TAG;
00084 }
00085
00091 public function getAddUrlParams()
00092 {
00093 $sAddParams = parent::getAddUrlParams();
00094 $sAddParams .= ($sAddParams?'&':'') . "listtype={$this->_sListType}";
00095 if ( $sParam = oxConfig::getParameter( 'searchtag', 1 ) ) {
00096 $sAddParams .= "&searchtag=" . rawurlencode( $sParam );
00097 }
00098 return $sAddParams;
00099 }
00100
00108 protected function _loadArticles( $oCategory )
00109 {
00110
00111 $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00112 $iNrofCatArticles = $iNrofCatArticles?$iNrofCatArticles:1;
00113 $oArtList = oxNew( 'oxarticlelist' );
00114 $oArtList->setSqlLimit( $iNrofCatArticles * $this->_getRequestPageNr(), $iNrofCatArticles );
00115 $oArtList->setCustomSorting( $this->getSortingSql( 'oxtags' ) );
00116 ;
00117
00118 $this->_iAllArtCnt = $oArtList->loadTagArticles( $this->getTag(), oxLang::getInstance()->getBaseLanguage());
00119 $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00120
00121 return $oArtList;
00122 }
00123
00129 protected function _getCatPathString()
00130 {
00131 return $this->getTag();
00132 }
00133
00139 protected function _getSeoObjectId()
00140 {
00141 return md5("tag" . $this->getTag() );
00142 }
00143
00151 public function getSorting( $sCnid )
00152 {
00153 return parent::getSorting( "oxtags" );
00154 }
00155
00165 public function setItemSorting( $sCnid, $sSortBy, $sSortOrder = null )
00166 {
00167 parent::setItemSorting( "oxtags", $sSortBy, $sSortOrder );
00168 }
00169
00175 public function generatePageNavigationUrl()
00176 {
00177 if ( ( oxUtils::getInstance()->seoIsActive() && ( $sTag = $this->getTag() ) ) ) {
00178 $sLink = oxSeoEncoderTag::getInstance()->getTagUrl( $sTag, oxLang::getInstance()->getBaseLanguage() );
00179 }
00180 return $sLink ? $sLink : oxUBase::generatePageNavigationUrl();
00181 }
00182
00192 protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00193 {
00194 $sSeoUrl = $blSeo = oxUtils::getInstance()->seoIsActive();
00195 if ( $blSeo && ( $sTag = $this->getTag() ) ) {
00196 if ( $iPage && ( $sSeoUrl = oxSeoEncoderTag::getInstance()->getTagPageUrl( $sTag, $iPage, $iLang ) ) ) {
00197
00198 $sUrl = $sSeoUrl;
00199 }
00200 }
00201
00202 return ( !$blSeo || !$sSeoUrl ) ? oxUBase::_addPageNrParam( $sUrl, $iPage, $iLang ) : $sUrl;
00203 }
00204
00210 public function getArticleList()
00211 {
00212 if ( $this->_aArticleList === null ) {
00213 if ( ( $this->getTag() ) ) {
00214 $this->_aArticleList = $this->_loadArticles( null );
00215 }
00216 }
00217
00218 return $this->_aArticleList;
00219 }
00220
00226 public function getTag()
00227 {
00228 if ( $this->_sTag === null ) {
00229 $this->_sTag = oxConfig::getParameter("searchtag", 1);
00230 }
00231 return $this->_sTag;
00232 }
00233
00239 public function getTitle()
00240 {
00241 if ( $this->_sTagTitle === null ) {
00242 $this->_sTagTitle = false;
00243 if ( ( $sTag = $this->getTag() ) ) {
00244 $oStr = getStr();
00245 $sTitle = $oStr->ucfirst( $sTag );
00246 $this->_sTagTitle = $oStr->htmlspecialchars( $sTitle );
00247 }
00248 }
00249 return $this->_sTagTitle;
00250 }
00251
00257 public function getTreePath()
00258 {
00259 if ( ( $sTag = $this->getTag() ) ) {
00260 $oStr = getStr();
00261
00262 $aPath[0] = oxNew( "oxcategory" );
00263 $aPath[0]->setLink( false );
00264 $aPath[0]->oxcategories__oxtitle = new oxField( oxLang::getInstance()->translateString('TAGS') );
00265
00266 $aPath[1] = oxNew( "oxcategory" );
00267 $aPath[1]->setLink( false );
00268 $aPath[1]->oxcategories__oxtitle = new oxField( $oStr->ucfirst( $sTag ) );
00269 return $aPath;
00270 }
00271 }
00272
00278 public function getActiveCategory()
00279 {
00280 return $this->getActTag();
00281 }
00282
00292 protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00293 {
00294 return parent::_collectMetaKeyword( $sKeywords );
00295 }
00296
00307 protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
00308 {
00309 return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
00310 }
00311
00317 public function getCanonicalUrl()
00318 {
00319 if ( ( $iPage = $this->getActPage() ) ) {
00320 return $this->_addPageNrParam( $this->generatePageNavigationUrl(), $iPage );
00321 } elseif ( ( $sTag = $this->getTag() ) ) {
00322 return oxSeoEncoderTag::getInstance()->getTagUrl( $sTag );
00323 }
00324 }
00325
00331 public function getBreadCrumb()
00332 {
00333 $aPaths = array();
00334 $aCatPath = array();
00335
00336 $aCatPath['title'] = oxLang::getInstance()->translateString( 'TAGS', oxLang::getInstance()->getBaseLanguage(), false );
00337 $aCatPath['link'] = oxSeoEncoder::getInstance()->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
00338 $aPaths[] = $aCatPath;
00339
00340 $aCatPath['title'] = $this->getTitle();
00341 $aCatPath['link'] = $this->getCanonicalUrl();
00342 $aPaths[] = $aCatPath;
00343
00344 return $aPaths;
00345 }
00346
00347 }