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 init()
00060 {
00061 $this->_sTag = oxConfig::getParameter("searchtag", 1);
00062 return parent::init();
00063 }
00064
00074 public function render()
00075 {
00076 oxUBase::render();
00077
00078 $myConfig = $this->getConfig();
00079
00080
00081 $this->_aViewData['articlelist'] = $this->getArticleList();
00082 $this->_aViewData['title'] = $this->getTitle();
00083 $this->_aViewData['template_location'] = $this->getTemplateLocation();
00084 $this->_aViewData['searchtag'] = $this->getTag();
00085
00086 $this->_aViewData['pageNavigation'] = $this->getPageNavigation();
00087 $this->_aViewData['actCategory'] = $this->getActiveCategory();
00088
00089
00090 $this->_processListArticles();
00091
00092 return $this->_sThisTemplate;
00093 }
00094
00100 protected function _getProductLinkType()
00101 {
00102 return OXARTICLE_LINKTYPE_TAG;
00103 }
00104
00110 public function getAddUrlParams()
00111 {
00112 $sAddParams = parent::getAddUrlParams();
00113 $sAddParams .= ($sAddParams?'&':'') . "listtype={$this->_sListType}";
00114
00115 if ( $sParam = rawurlencode( oxConfig::getParameter( 'searchtag', 1 ) ) ) {
00116 $sAddParams .= "&searchtag={$sParam}";
00117 }
00118
00119 return $sAddParams;
00120 }
00121
00129 protected function _loadArticles( $oVendor )
00130 {
00131
00132 $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00133 $iNrofCatArticles = $iNrofCatArticles?$iNrofCatArticles:1;
00134
00135 $oArtList = oxNew( 'oxarticlelist' );
00136 $oArtList->setSqlLimit( $iNrofCatArticles * $this->getActPage(), $iNrofCatArticles );
00137 $oArtList->setCustomSorting( $this->getSortingSql( 'oxtags' ) );
00138
00139
00140 $this->_iAllArtCnt = $oArtList->loadTagArticles( $this->_sTag, oxLang::getInstance()->getBaseLanguage());
00141 $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00142
00143 return $oArtList;
00144 }
00145
00151 protected function _getCatPathString()
00152 {
00153 return $this->_sTag;
00154 }
00155
00161 protected function _getSeoObjectId()
00162 {
00163 return md5("tag" . $this->_sTag);
00164 }
00165
00173 public function getSorting( $sCnid )
00174 {
00175 return parent::getSorting( "oxtags" );
00176 }
00177
00187 public function setItemSorting( $sCnid, $sSortBy, $sSortOrder = null )
00188 {
00189 parent::setItemSorting( "oxtags", $sSortBy, $sSortOrder );
00190 }
00191
00197 public function generatePageNavigationUrl()
00198 {
00199 if ( ( oxUtils::getInstance()->seoIsActive() && ( $sTag = $this->getTag() ) ) ) {
00200 return oxSeoEncoderTag::getInstance()->getTagUrl( $sTag, oxLang::getInstance()->getBaseLanguage() );
00201 } else {
00202 return oxUBase::generatePageNavigationUrl();
00203 }
00204 }
00205
00215 protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00216 {
00217 if ( oxUtils::getInstance()->seoIsActive() && ( $sTag = $this->getTag() ) ) {
00218 if ( $iPage ) {
00219 $sUrl = oxSeoEncoderTag::getInstance()->getTagPageUrl( $sTag, $iPage, $iLang );
00220 }
00221 } else {
00222 $sUrl = oxUBase::_addPageNrParam( $sUrl, $iPage, $iLang );
00223 }
00224 return $sUrl;
00225 }
00226
00232 public function getArticleList()
00233 {
00234 if ( $this->_aArticleList === null ) {
00235 if ( ( $this->getTag() ) ) {
00236 $this->_aArticleList = $this->_loadArticles( null );
00237 }
00238 }
00239 return $this->_aArticleList;
00240 }
00241
00247 public function getTag()
00248 {
00249 return $this->_sTag;
00250 }
00251
00257 public function getTitle()
00258 {
00259 if ( $this->_sTagTitle === null ) {
00260 $this->_sTagTitle = false;
00261 if ( ( $sTag = $this->getTag() ) ) {
00262 $oStr = getStr();
00263 $sTitle = $oStr->ucfirst( $sTag );
00264 $this->_sTagTitle = $oStr->htmlspecialchars( $sTitle );
00265 }
00266 }
00267 return $this->_sTagTitle;
00268 }
00269
00277 public function getTemplateLocation()
00278 {
00279 if ( $this->_sTemplateLocation === null ) {
00280 $this->_sTemplateLocation = false;
00281 if ( ( $sTag = $this->getTag() ) ) {
00282 $oStr = getStr();
00283 $sTitle = $oStr->ucfirst( $sTag );
00284 $this->_sTemplateLocation = oxLang::getInstance()->translateString('TAGS')." / ".$oStr->htmlspecialchars( $sTitle );
00285 }
00286 }
00287 return $this->_sTemplateLocation;
00288 }
00289
00295 public function getTreePath()
00296 {
00297 if ( ( $sTag = $this->getTag() ) ) {
00298 $oStr = getStr();
00299
00300 $aPath[0] = oxNew( "oxcategory" );
00301 $aPath[0]->setLink( false );
00302 $aPath[0]->oxcategories__oxtitle = new oxField( oxLang::getInstance()->translateString('TAGS') );
00303
00304 $aPath[1] = oxNew( "oxcategory" );
00305 $aPath[1]->setLink( false );
00306 $aPath[1]->oxcategories__oxtitle = new oxField( $oStr->htmlspecialchars( $oStr->ucfirst( $sTag ) ) );
00307 return $aPath;
00308 }
00309 }
00310
00316 public function getActiveCategory()
00317 {
00318 return $this->getActTag();
00319 }
00320
00330 protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00331 {
00332 return parent::_collectMetaKeyword( $sKeywords );
00333 }
00334
00345 protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
00346 {
00347 return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
00348 }
00349
00355 public function getCanonicalUrl()
00356 {
00357 if ( ( $iPage = $this->getActPage() ) ) {
00358 return $this->_addPageNrParam( $this->generatePageNavigationUrl(), $iPage );
00359 } elseif ( ( $sTag = $this->getTag() ) ) {
00360 return oxSeoEncoderTag::getInstance()->getTagUrl( $sTag );
00361 }
00362 }
00363 }