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 $myConfig = $this->getConfig();
00064
00065 $oArticleList = $this->getArticleList();
00066
00067
00068 if ( !$oArticleList || count( $oArticleList ) < 1 ) {
00069 error_404_handler();
00070 }
00071
00072
00073 $this->_processListArticles();
00074
00075 return $this->_sThisTemplate;
00076 }
00077
00083 protected function _getProductLinkType()
00084 {
00085 return OXARTICLE_LINKTYPE_TAG;
00086 }
00087
00093 public function getAddUrlParams()
00094 {
00095 $sAddParams = parent::getAddUrlParams();
00096 $sAddParams .= ($sAddParams?'&':'') . "listtype={$this->_sListType}";
00097 if ( $sParam = oxConfig::getParameter( 'searchtag', 1 ) ) {
00098 $sAddParams .= "&searchtag=" . rawurlencode( $sParam );
00099 }
00100 return $sAddParams;
00101 }
00102
00110 protected function _loadArticles( $oCategory )
00111 {
00112
00113 $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00114 $iNrofCatArticles = $iNrofCatArticles?$iNrofCatArticles:1;
00115 $oArtList = oxNew( 'oxarticlelist' );
00116 $oArtList->setSqlLimit( $iNrofCatArticles * $this->_getRequestPageNr(), $iNrofCatArticles );
00117 $oArtList->setCustomSorting( $this->getSortingSql( 'oxtags' ) );
00118
00119
00120 $this->_iAllArtCnt = $oArtList->loadTagArticles( $this->getTag(), oxLang::getInstance()->getBaseLanguage());
00121 $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00122
00123 return $oArtList;
00124 }
00125
00131 protected function _getCatPathString()
00132 {
00133 return $this->getTag();
00134 }
00135
00141 protected function _getSeoObjectId()
00142 {
00143 return md5("tag" . $this->getTag() );
00144 }
00145
00153 public function getSorting( $sCnid )
00154 {
00155 return parent::getSorting( "oxtags" );
00156 }
00157
00167 public function setItemSorting( $sCnid, $sSortBy, $sSortOrder = null )
00168 {
00169 parent::setItemSorting( "oxtags", $sSortBy, $sSortOrder );
00170 }
00171
00177 public function generatePageNavigationUrl()
00178 {
00179 if ( ( oxUtils::getInstance()->seoIsActive() && ( $sTag = $this->getTag() ) ) ) {
00180 $sLink = oxSeoEncoderTag::getInstance()->getTagUrl( $sTag, oxLang::getInstance()->getBaseLanguage() );
00181 }
00182 return $sLink ? $sLink : oxUBase::generatePageNavigationUrl();
00183 }
00184
00194 protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00195 {
00196 $sSeoUrl = $blSeo = oxUtils::getInstance()->seoIsActive();
00197 if ( $blSeo && ( $sTag = $this->getTag() ) ) {
00198 if ( $iPage && ( $sSeoUrl = oxSeoEncoderTag::getInstance()->getTagPageUrl( $sTag, $iPage, $iLang ) ) ) {
00199
00200 $sUrl = $sSeoUrl;
00201 }
00202 }
00203
00204 return ( !$blSeo || !$sSeoUrl ) ? oxUBase::_addPageNrParam( $sUrl, $iPage, $iLang ) : $sUrl;
00205 }
00206
00212 public function getArticleList()
00213 {
00214 if ( $this->_aArticleList === null ) {
00215 if ( ( $this->getTag() ) ) {
00216 $this->_aArticleList = $this->_loadArticles( null );
00217 }
00218 }
00219
00220 return $this->_aArticleList;
00221 }
00222
00228 public function getTag()
00229 {
00230 if ( $this->_sTag === null ) {
00231 $this->_sTag = oxConfig::getParameter("searchtag", 1);
00232 }
00233 return $this->_sTag;
00234 }
00235
00241 public function getTitle()
00242 {
00243 if ( $this->_sTagTitle === null ) {
00244 $this->_sTagTitle = false;
00245 if ( ( $sTag = $this->getTag() ) ) {
00246 $oStr = getStr();
00247 $sTitle = $oStr->ucfirst( $sTag );
00248 $this->_sTagTitle = $oStr->htmlspecialchars( $sTitle );
00249 }
00250 }
00251 return $this->_sTagTitle;
00252 }
00253
00259 public function getTreePath()
00260 {
00261 if ( ( $sTag = $this->getTag() ) ) {
00262 $oStr = getStr();
00263
00264 $aPath[0] = oxNew( "oxcategory" );
00265 $aPath[0]->setLink( false );
00266 $aPath[0]->oxcategories__oxtitle = new oxField( oxLang::getInstance()->translateString('TAGS') );
00267
00268 $aPath[1] = oxNew( "oxcategory" );
00269 $aPath[1]->setLink( false );
00270 $aPath[1]->oxcategories__oxtitle = new oxField( $oStr->ucfirst( $sTag ) );
00271 return $aPath;
00272 }
00273 }
00274
00280 public function getActiveCategory()
00281 {
00282 return $this->getActTag();
00283 }
00284
00294 protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00295 {
00296 return parent::_collectMetaKeyword( $sKeywords );
00297 }
00298
00309 protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
00310 {
00311 return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
00312 }
00313
00319 public function getCanonicalUrl()
00320 {
00321 if ( ( $iPage = $this->getActPage() ) ) {
00322 return $this->_addPageNrParam( $this->generatePageNavigationUrl(), $iPage );
00323 } elseif ( ( $sTag = $this->getTag() ) ) {
00324 return oxSeoEncoderTag::getInstance()->getTagUrl( $sTag );
00325 }
00326 }
00327
00333 public function getBreadCrumb()
00334 {
00335 $aPaths = array();
00336 $aCatPath = array();
00337
00338 $aCatPath['title'] = oxLang::getInstance()->translateString( 'TAGS', oxLang::getInstance()->getBaseLanguage(), false );
00339 $aPaths[] = $aCatPath;
00340
00341 $aCatPath['title'] = $this->getTitle();
00342 $aPaths[] = $aCatPath;
00343
00344 return $aPaths;
00345 }
00346
00347 }