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_NOINDEXFOLLOW;
00053
00059 public function init()
00060 {
00061 if ( oxUtils::getInstance()->seoIsActive() ) {
00062
00063 $this->setSessionCategoryId( null );
00064 }
00065
00066 $this->_sTag = oxConfig::getParameter("searchtag", 1);
00067 return parent::init();
00068 }
00069
00079 public function render()
00080 {
00081 oxUBase::render();
00082
00083 $myConfig = $this->getConfig();
00084
00085
00086 $this->_aViewData['articlelist'] = $this->getArticleList();
00087 $this->_aViewData['title'] = $this->getTitle();
00088 $this->_aViewData['template_location'] = $this->getTemplateLocation();
00089 $this->_aViewData['searchtag'] = $this->getTag();
00090
00091 $this->_aViewData['pageNavigation'] = $this->getPageNavigation();
00092 $this->_aViewData['actCategory'] = $this->getActiveCategory();
00093
00094
00095 $this->_processListArticles();
00096
00097 return $this->_sThisTemplate;
00098 }
00099
00105 protected function _getProductLinkType()
00106 {
00107 return OXARTICLE_LINKTYPE_TAG;
00108 }
00109
00115 public function getAddUrlParams()
00116 {
00117 $sAddParams = parent::getAddUrlParams();
00118 $sAddParams .= ($sAddParams?'&':'') . "listtype={$this->_sListType}";
00119
00120 if ( $sParam = rawurlencode( oxConfig::getParameter( 'searchtag', 1 ) ) ) {
00121 $sAddParams .= "&searchtag={$sParam}";
00122 }
00123
00124 return $sAddParams;
00125 }
00126
00134 protected function _loadArticles( $oVendor )
00135 {
00136
00137 $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00138 $iNrofCatArticles = $iNrofCatArticles?$iNrofCatArticles:1;
00139
00140 $oArtList = oxNew( 'oxarticlelist' );
00141 $oArtList->setSqlLimit( $iNrofCatArticles * $this->getActPage(), $iNrofCatArticles );
00142 $oArtList->setCustomSorting( $this->getSortingSql( 'oxtags' ) );
00143
00144
00145 $this->_iAllArtCnt = $oArtList->loadTagArticles( $this->_sTag, oxLang::getInstance()->getBaseLanguage());
00146 $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00147
00148 return $oArtList;
00149 }
00150
00156 protected function _getCatPathString()
00157 {
00158 return $this->_sTag;
00159 }
00160
00166 protected function _getSeoObjectId()
00167 {
00168 return md5("tag" . $this->_sTag);
00169 }
00170
00178 public function getSorting( $sCnid )
00179 {
00180 return parent::getSorting( "oxtags" );
00181 }
00182
00192 public function setItemSorting( $sCnid, $sSortBy, $sSortOrder = null )
00193 {
00194 parent::setItemSorting( "oxtags", $sSortBy, $sSortOrder );
00195 }
00196
00202 public function generatePageNavigationUrl()
00203 {
00204 if ( ( oxUtils::getInstance()->seoIsActive() && ( $sTag = $this->getTag() ) ) ) {
00205 return oxSeoEncoderTag::getInstance()->getTagUrl( $sTag, oxLang::getInstance()->getBaseLanguage() );
00206 } else {
00207 return oxUBase::generatePageNavigationUrl();
00208 }
00209 }
00210
00220 protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00221 {
00222 if ( oxUtils::getInstance()->seoIsActive() && ( $sTag = $this->getTag() ) ) {
00223 if ( $iPage ) {
00224 $sUrl = oxSeoEncoderTag::getInstance()->getTagPageUrl( $sTag, $iPage, $iLang );
00225 }
00226 } else {
00227 $sUrl = oxUBase::_addPageNrParam( $sUrl, $iPage, $iLang );
00228 }
00229 return $sUrl;
00230 }
00231
00237 public function getArticleList()
00238 {
00239 if ( $this->_aArticleList === null ) {
00240 if ( ( $this->getTag() ) ) {
00241 $this->_aArticleList = $this->_loadArticles( null );
00242 }
00243 }
00244 return $this->_aArticleList;
00245 }
00246
00252 public function getTag()
00253 {
00254 return $this->_sTag;
00255 }
00256
00262 public function getTitle()
00263 {
00264 if ( $this->_sTagTitle === null ) {
00265 $this->_sTagTitle = false;
00266 if ( ( $sTag = $this->getTag() ) ) {
00267 $oStr = getStr();
00268 $sTitle = $oStr->ucfirst( $sTag );
00269 $this->_sTagTitle = $oStr->htmlspecialchars( $sTitle );
00270 }
00271 }
00272 return $this->_sTagTitle;
00273 }
00274
00280 public function getTemplateLocation()
00281 {
00282 if ( $this->_sTemplateLocation === null ) {
00283 $this->_sTemplateLocation = false;
00284 if ( ( $sTag = $this->getTag() ) ) {
00285 $oStr = getStr();
00286 $sTitle = $oStr->ucfirst( $sTag );
00287 $this->_sTemplateLocation = oxLang::getInstance()->translateString('TAGS')." / ".$oStr->htmlspecialchars( $sTitle );
00288 }
00289 }
00290 return $this->_sTemplateLocation;
00291 }
00292
00298 public function getActiveCategory()
00299 {
00300 return $this->getActTag();
00301 }
00302
00312 protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00313 {
00314 return parent::_collectMetaKeyword( $sKeywords );
00315 }
00316
00327 protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
00328 {
00329 return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
00330 }
00331 }