(Any selected shop prpduct category). * @package main */ class alist extends oxUBase { /** * A list of articles (default null). * @var array */ var $aArticleList = null; /** * Number of current active (rendered) page (default 0). * @var integer */ var $iActPage = 0; /** * Count of all articles (default 0). * @var integer */ var $iAllArtCnt = 0; /** * List of most buyable products (default null). * @var array */ var $aTopAngeboteList = null; /** * Class constructor. */ function alist() { parent::oxUBase(); } /** * Generates and returns view ID (for Smarty caching). * @return string */ function GetViewID() { global $myConfig; if( isset( $this->sViewID)) return $this->sViewID; $iActPage = $myConfig->getParameter("pgNr"); if( !isset( $iActPage)) $iActPage = 0; $sActCat = $myConfig->getParameter("cnid"); // stock stuff $sAdd = ""; if( $myConfig->blTemplateCaching && $myConfig->blUseStock) { // PP Dodger 25.11.2003 ########################################### TUNING ################################################################ /* $sSelect = "select oxarticles.oxid from oxarticles left join oxobject2category on oxarticles.oxid=oxobject2category.oxobjectid "; $sSelect .= "where oxobject2category.oxcatnid = '$sActCat'"; $sSelect .= " and oxarticles.oxparentid is null and oxstockflag != '1' and oxstock <= 0 "; */ $sSelect = "select oxarticles.oxid from oxarticles, oxobject2category "; $sSelect .= "where oxobject2category.oxcatnid = '$sActCat' "; $sSelect .= "and oxarticles.oxid = oxobject2category.oxobjectid "; $sSelect .= " and oxarticles.oxparentid is null and oxstockflag != '1' and oxstock <= 0 "; ########################################### /TUNING ################################################################ $rs = $myConfig->oDB->Execute( $sSelect); if ($rs != false && $rs->RecordCount() > 0) { while (!$rs->EOF) { $sAdd .= $rs->fields[0]; $rs->MoveNext(); } } $sAdd = md5( $sAdd); } $this->sViewID = parent::GetViewID()."|".$myConfig->getParameter("cnid")."|".$iActPage."|".$sAdd; return $this->sViewID; } /** * Assigns template name ("list.tpl"), fetches a list of articles from DB. */ function init() { global $myConfig; parent::init(); // assign template name $sTemplate = "list_unsuscribe.tpl"; if( $this->oActCategory->oxcategories__oxtemplate->value) $sTemplate = $this->oActCategory->oxcategories__oxtemplate->value; $sTplName = basename ($myConfig->getParameter("tpl")); if( isset( $sTplName) && $sTplName) $sTemplate = $sTplName; $this->sThisTemplate = $sTemplate; $this->iActPage = $myConfig->getParameter("pgNr"); if( !isset( $this->iActPage)) $this->iActPage = 0; $sActCat = $myConfig->getParameter("cnid"); $oCategory = & oxNew( "oxcategory", "core"); $oCategory->Load( $sActCat); if( $oCategory->oxcategories__oxpricefrom->value || $oCategory->oxcategories__oxpriceto->value) { $dPriceFrom = $oCategory->oxcategories__oxpricefrom->value; $dPriceTo = $oCategory->oxcategories__oxpriceto->value; $oArtList = &oxNew( "oxarticlelist", "core"); // load only articles which we show on screen $oArtList->iSQLRecords = $myConfig->iNrofCatArticles; $oArtList->iSQLStart = $myConfig->iNrofCatArticles * $this->iActPage; // load the articles $this->iAllArtCnt = $oArtList->LoadPriceArticles( $dPriceFrom, $dPriceTo); $this->aArticleList = $oArtList->aList; // get it in base language $oCategoryInDefaultLanguage= &oxNew( "oxcategory", "core"); $oCategoryInDefaultLanguage->LoadInLang( 0, $oCategory->sOXID); $oArtList = &oxNew( "oxarticlelist", "core"); $oArtList->LoadAktionArticles( $oCategoryInDefaultLanguage->oxcategories__oxtitle->value); $this->aTopAngeboteList = $oArtList->aList; } else { $oArtList = &oxNew( "oxarticlelist", "core"); // load only articles which we show on screen $oArtList->iSQLRecords = $myConfig->iNrofCatArticles; $oArtList->iSQLStart = $myConfig->iNrofCatArticles * $this->iActPage; // load the articles $this->iAllArtCnt = $oArtList->LoadCategoryArticles( $sActCat); //echo $this->iAllArtCnt; $this->aArticleList = $oArtList->aList; // get it in base language $oCategoryInDefaultLanguage= &oxNew( "oxcategory", "core"); $oCategoryInDefaultLanguage->LoadInLang( 0, $this->oActCategory->sOXID); $oArtList = &oxNew( "oxarticlelist", "core"); $oArtList->LoadAktionArticles( $oCategoryInDefaultLanguage->oxcategories__oxtitle->value); $this->aTopAngeboteList = $oArtList->aList; } } /** * Generates navigation links, loads category tree, generates meta keywordds * and meta description. Returns name of template file. * @return string */ function render() { global $myConfig; global $mySession; parent::render(); $sPrice = ""; $dPriceFrom = $myConfig->getParameter("prf"); if( isset( $dPriceFrom) && $dPriceFrom) $sPrice = "&prf=$dPriceFrom"; $dPriceTo = $myConfig->getParameter("prt"); if( isset( $dPriceTo) && $dPriceTo) $sPrice .= "&prt=$dPriceTo"; $this->aViewData['articlelist'] = $this->aArticleList; $oTopOffer = null; $oBargainOffer = null; if( $this->aTopAngeboteList) { foreach( $this->aTopAngeboteList as $oOffer) { if( !$oTopOffer) $oTopOffer = $oOffer; elseif( !$oBargainOffer) $oBargainOffer = $oOffer; } } $this->aViewData['toparticle'] = $oTopOffer; $this->aViewData['articlebargain'] = $oBargainOffer; // generate the page navigation $pageNavigation->iArtCnt = $this->iAllArtCnt; $pageNavigation->NrOfPages = round( $this->iAllArtCnt/$myConfig->iNrofCatArticles + 0.49); $pageNavigation->actPage = $this->iActPage + 1; $sActCat = $myConfig->getParameter("cnid"); if( $this->iActPage > 0) $pageNavigation->previousPage = $myConfig->getShopHomeURL()."&cl=alist&pgNr=".($this->iActPage-1)."&cnid=$sActCat".$sPrice; else $pageNavigation->previousPage = null; if( $this->iActPage < $pageNavigation->NrOfPages-1) $pageNavigation->nextPage = $myConfig->getShopHomeURL()."&cl=alist&pgNr=".($this->iActPage+1)."&cnid=$sActCat".$sPrice; else $pageNavigation->nextPage = null; if( $pageNavigation->NrOfPages > 1) { for ($i=1; $i < $pageNavigation->NrOfPages + 1; $i++) { $page->url = $myConfig->getShopHomeURL()."&cl=alist&pgNr=".($i-1)."&cnid=$sActCat".$sPrice; $page->selected = 0; if( $i == $pageNavigation->actPage) $page->selected = 1; $pageNavigation->changePage[$i] = $page; } // first/last one $pageNavigation->firstpage = $myConfig->getShopHomeURL()."&cl=alist&pgNr=0&cnid=$sActCat".$sPrice; $iLast = $pageNavigation->NrOfPages - 1; $pageNavigation->lastpage = $myConfig->getShopHomeURL()."&cl=alist&pgNr=".$iLast."&cnid=$sActCat".$sPrice; } $this->aViewData['pageNavigation'] = $pageNavigation; // load category tree $sActCat = $myConfig->getParameter("cnid"); $oCategoryTree = &oxNew( "oxcategorylist", "core"); $oCategoryTree->SelectSimple( " where oxcategories.oxparentid = '$sActCat' and oxcategories.oxactiv".(($oCategoryTree->sLanguage)?"_$oCategoryTree->sLanguage":"")." = 1 order by oxcategories.oxorder "); ///print_r($oCategoryTree->aList); $oCategoryTree->SortList($oCategoryTree->aList); $this->aViewData['subcatlist'] = $oCategoryTree->aList; // generate searchengine tags $sText = ""; foreach (array_keys( $this->aArticleList) as $sKey) { $oProduct = & $this->aArticleList[$sKey]; $sDesc = strip_tags( $oProduct->oxarticles__oxlongdesc->value); $sDesc = trim(strtolower( $sDesc)); $sText .= $sDesc; if ( !in_array( $sDesc, $myConfig->aSkipTags) ) { $iMaxTextLenght = 60; $sSpace = " "; if ( strlen($sDesc) > $iMaxTextLenght ) { $text = substr( $sDesc, 0, $iMaxTextLenght); $sText .= substr( $text, 0, (strlen($text) - strpos(strrev($text),$sSpace))); } } } $sSource = "oxid esales " . $sText; $this->aViewData['meta_keywords'] = $this->ConvertForMetaTags( $sSource, "");//trim(htmlentities(substr( str_replace( " ", ", ", $sSource), 0, 1024))); $this->aViewData['meta_description'] = $this->ConvertForMetaTags( $sSource, "");//trim(htmlentities(substr( str_replace( " ", " ", $sSource), 0, 1024))); return $this->sThisTemplate; } } ?>