tag.php

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 
00063     public function render()
00064     {
00065         oxUBase::render();
00066 
00067         $myConfig = $this->getConfig();
00068 
00069         // load vendor
00070         $this->_aViewData['articlelist']       = $this->getArticleList();
00071         $this->_aViewData['title']             = $this->getTitle();
00072         $this->_aViewData['template_location'] = $this->getTemplateLocation();
00073         $this->_aViewData['searchtag']         = $this->getTag();
00074 
00075         $this->_aViewData['pageNavigation']    = $this->getPageNavigation();
00076         $this->_aViewData['actCategory']    = $this->getActiveCategory();
00077 
00078         // processing list articles
00079         $this->_processListArticles();
00080 
00081         return $this->_sThisTemplate;
00082     }
00083 
00089     protected function _getProductLinkType()
00090     {
00091         return OXARTICLE_LINKTYPE_TAG;
00092     }
00093 
00099     public function getAddUrlParams()
00100     {
00101         $sAddParams  = parent::getAddUrlParams();
00102         $sAddParams .= ($sAddParams?'&amp;':'') . "listtype={$this->_sListType}";
00103         if ( $sParam = oxConfig::getParameter( 'searchtag', 1 ) ) {
00104             $sAddParams .= "&amp;searchtag=" . rawurlencode( $sParam );
00105         }
00106         return $sAddParams;
00107     }
00108 
00116     protected function _loadArticles( $oVendor )
00117     {
00118         // load only articles which we show on screen
00119         $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00120         $iNrofCatArticles = $iNrofCatArticles?$iNrofCatArticles:1;
00121 
00122         $oArtList = oxNew( 'oxarticlelist' );
00123         $oArtList->setSqlLimit( $iNrofCatArticles * $this->getActPage(), $iNrofCatArticles );
00124         $oArtList->setCustomSorting( $this->getSortingSql( 'oxtags' ) );
00125 
00126         // load the articles
00127         $this->_iAllArtCnt = $oArtList->loadTagArticles( $this->getTag(), oxLang::getInstance()->getBaseLanguage());
00128         $this->_iCntPages  = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00129 
00130         return $oArtList;
00131     }
00132 
00138     protected function _getCatPathString()
00139     {
00140         return $this->getTag();
00141     }
00142 
00148     protected function _getSeoObjectId()
00149     {
00150         return md5("tag" . $this->getTag() );
00151     }
00152 
00160     public function getSorting( $sCnid )
00161     {
00162         return parent::getSorting( "oxtags" );
00163     }
00164 
00174     public function setItemSorting( $sCnid, $sSortBy, $sSortOrder  = null )
00175     {
00176         parent::setItemSorting( "oxtags", $sSortBy, $sSortOrder );
00177     }
00178 
00184     public function generatePageNavigationUrl()
00185     {
00186         if ( ( oxUtils::getInstance()->seoIsActive() && ( $sTag = $this->getTag() ) ) ) {
00187             return oxSeoEncoderTag::getInstance()->getTagUrl( $sTag, oxLang::getInstance()->getBaseLanguage() );
00188         }
00189         return oxUBase::generatePageNavigationUrl();
00190     }
00191 
00201     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00202     {
00203         if ( oxUtils::getInstance()->seoIsActive() && ( $sTag = $this->getTag() ) ) {
00204             if ( $iPage ) {
00205                 // only if page number > 0
00206                 $sUrl = oxSeoEncoderTag::getInstance()->getTagPageUrl( $sTag, $iPage, $iLang );
00207             }
00208         } else {
00209             $sUrl = oxUBase::_addPageNrParam( $sUrl, $iPage, $iLang );
00210         }
00211         return $sUrl;
00212     }
00213 
00219     public function getArticleList()
00220     {
00221         if ( $this->_aArticleList === null ) {
00222             if ( ( $this->getTag() ) ) {
00223                 $this->_aArticleList = $this->_loadArticles( null );
00224             }
00225         }
00226         return $this->_aArticleList;
00227     }
00228 
00234     public function getTag()
00235     {
00236         if ( $this->_sTag === null ) {
00237             $this->_sTag = oxConfig::getParameter("searchtag", 1);
00238         }
00239         return $this->_sTag;
00240     }
00241 
00247     public function getTitle()
00248     {
00249         if ( $this->_sTagTitle === null ) {
00250             $this->_sTagTitle = false;
00251             if ( ( $sTag = $this->getTag() ) ) {
00252                 $oStr = getStr();
00253                 $sTitle = $oStr->ucfirst( $sTag );
00254                 $this->_sTagTitle = $oStr->htmlspecialchars( $sTitle );
00255             }
00256         }
00257         return $this->_sTagTitle;
00258     }
00259 
00267     public function getTemplateLocation()
00268     {
00269         if ( $this->_sTemplateLocation === null ) {
00270             $this->_sTemplateLocation = false;
00271             if ( ( $sTag = $this->getTag() ) ) {
00272                 $oStr = getStr();
00273                 $sTitle = $oStr->ucfirst( $sTag );
00274                 $this->_sTemplateLocation = oxLang::getInstance()->translateString('TAGS')." / ".$oStr->htmlspecialchars( $sTitle );
00275             }
00276         }
00277         return $this->_sTemplateLocation;
00278     }
00279 
00285     public function getTreePath()
00286     {
00287         if ( ( $sTag = $this->getTag() ) ) {
00288             $oStr = getStr();
00289 
00290             $aPath[0] = oxNew( "oxcategory" );
00291             $aPath[0]->setLink( false );
00292             $aPath[0]->oxcategories__oxtitle = new oxField( oxLang::getInstance()->translateString('TAGS') );
00293 
00294             $aPath[1] = oxNew( "oxcategory" );
00295             $aPath[1]->setLink( false );
00296             $aPath[1]->oxcategories__oxtitle = new oxField( $oStr->htmlspecialchars( $oStr->ucfirst( $sTag ) ) );
00297             return $aPath;
00298         }
00299     }
00300 
00306     public function getActiveCategory()
00307     {
00308         return $this->getActTag();
00309     }
00310 
00320     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00321     {
00322         return parent::_collectMetaKeyword( $sKeywords );
00323     }
00324 
00335     protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
00336     {
00337         return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
00338     }
00339 
00345     public function getCanonicalUrl()
00346     {
00347         if ( ( $iPage = $this->getActPage() ) ) {
00348             return $this->_addPageNrParam( $this->generatePageNavigationUrl(), $iPage );
00349         } elseif ( ( $sTag = $this->getTag() ) ) {
00350             return oxSeoEncoderTag::getInstance()->getTagUrl( $sTag );
00351         }
00352     }
00353 }

Generated by  doxygen 1.6.2