article_list.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Article_List extends oxAdminList
00010 {
00016     protected $_sListClass = 'oxarticle';
00017 
00023     protected $_sListType = 'oxarticlelist';
00024 
00031     public function render()
00032     {
00033         $myConfig = $this->getConfig();
00034         $sPwrSearchFld = oxConfig::getParameter( "pwrsearchfld" );
00035         if ( !isset( $sPwrSearchFld ) ) {
00036             $sPwrSearchFld  = "oxtitle";
00037         }
00038 
00039         $oArticle = null;
00040         $oList = $this->getItemList();
00041         if ( $oList) {
00042             foreach ( $oList as $key => $oArticle ) {
00043                 $sFieldName = "oxarticles__".strtolower( $sPwrSearchFld );
00044 
00045                 // formatting view
00046                 if ( !$myConfig->getConfigParam( 'blSkipFormatConversion' ) ) {
00047                     if ( $oArticle->$sFieldName->fldtype == "datetime" )
00048                         oxDb::getInstance()->convertDBDateTime( $oArticle->$sFieldName );
00049                     elseif ( $oArticle->$sFieldName->fldtype == "timestamp" )
00050                         oxDb::getInstance()->convertDBTimestamp( $oArticle->$sFieldName );
00051                     elseif ( $oArticle->$sFieldName->fldtype == "date" )
00052                         oxDb::getInstance()->convertDBDate( $oArticle->$sFieldName );
00053                 }
00054 
00055                 $oArticle->pwrsearchval = $oArticle->$sFieldName->value;
00056                 $oList[$key] = $oArticle;
00057             }
00058         }
00059 
00060         parent::render();
00061 
00062         // load fields
00063         if ( !$oArticle && $oList ) {
00064             $oArticle = $oList->getBaseObject();
00065         }
00066         $this->_aViewData["pwrsearchfields"] = $oArticle ? $oArticle->getSearchableFields() : null;
00067         $this->_aViewData["pwrsearchfld"]    = strtoupper( $sPwrSearchFld );
00068 
00069         if ( isset( $this->_aViewData["where"] ) ) {
00070             $sFieldName = "oxarticles__".strtoupper( $sPwrSearchFld );
00071             if ( isset( $this->_aViewData["where"]->$sFieldName ) ) {
00072                 $this->_aViewData["pwrsearchinput"] = $this->_aViewData["where"]->$sFieldName;
00073             }
00074         }
00075 
00076         $sType  = '';
00077         $sValue = '';
00078 
00079         $sArtCat= oxConfig::getParameter( "art_category" );
00080         if ( $sArtCat && strstr( $sArtCat, "@@" ) !== false ) {
00081             list( $sType, $sValue ) = explode( "@@", $sArtCat );
00082         }
00083 
00084         // parent categorie tree
00085         $this->_aViewData["cattree"] = $this->getCategoryList($sType, $sValue);
00086 
00087         // manufacturer list
00088         $this->_aViewData["mnftree"] = $this->getManufacturerlist($sType, $sValue);
00089 
00090         // vendor list
00091         $this->_aViewData["vndtree"] = $this->getVendorList($sType, $sValue);
00092 
00093         return "article_list.tpl";
00094     }
00095 
00104     public function getCategoryList($sType, $sValue)
00105     {
00106         $myConfig = $this->getConfig();
00107 
00108         // parent categorie tree
00109         $oCatTree = oxNew( "oxCategoryList");
00110         $oCatTree->buildList( $myConfig->getConfigParam( 'bl_perfLoadCatTree' ) );
00111         if ( $sType === 'cat' ) {
00112             foreach ($oCatTree as $oCategory ) {
00113                 if ( $oCategory->oxcategories__oxid->value == $sValue ) {
00114                     $oCategory->selected = 1;
00115                     break;
00116                 }
00117             }
00118         }
00119 
00120         return $oCatTree;
00121     }
00122 
00131     public function getManufacturerList($sType, $sValue)
00132     {
00133         $oMnfTree = oxNew( "oxManufacturerList");
00134         $oMnfTree->loadManufacturerList();
00135         if ( $sType === 'mnf' ) {
00136             foreach ($oMnfTree as $oManufacturer ) {
00137                 if ( $oManufacturer->oxmanufacturers__oxid->value == $sValue ) {
00138                     $oManufacturer->selected = 1;
00139                     break;
00140                 }
00141             }
00142         }
00143 
00144         return $oMnfTree;
00145     }
00146 
00155     public function getVendorList($sType, $sValue)
00156     {
00157         $oVndTree = oxNew( "oxVendorList");
00158         $oVndTree->loadVendorList();
00159         if ( $sType === 'vnd' ) {
00160             foreach ($oVndTree as $oVendor ) {
00161                 if ( $oVendor->oxvendor__oxid->value == $sValue ) {
00162                     $oVendor->selected = 1;
00163                     break;
00164                 }
00165             }
00166         }
00167 
00168         return $oVndTree;
00169     }
00170 
00178     protected function _changeselect( $sSql )
00179     {
00180         $sArtCat= oxConfig::getParameter("art_category");
00181         if ( $sArtCat && strstr($sArtCat, "@@") !== false ) {
00182             list($sType, $sValue) = explode("@@", $sArtCat);
00183         }
00184 
00185         $sTable   = getViewName( "oxarticles" );
00186         switch ($sType) {
00187             // add category
00188             case 'cat':
00189                 $oStr = getStr();
00190                 $sO2CView = getViewName( "oxobject2category" );
00191                 $sInsert  = "from $sTable left join $sO2CView on $sTable.oxid = $sO2CView.oxobjectid where $sO2CView.oxcatnid = ".oxDb::getDb()->quote($sValue)." and ";
00192                 $sSql = $oStr->preg_replace( "/from\s+$sTable\s+where/i", $sInsert, $sSql);
00193                 break;
00194             // add category
00195             case 'mnf':
00196                 $sSql.= " and $sTable.oxmanufacturerid = ".oxDb::getDb()->quote($sValue);
00197                 break;
00198             // add vendor
00199             case 'vnd':
00200                 $sSql.= " and $sTable.oxvendorid = ".oxDb::getDb()->quote($sValue);
00201                 break;
00202         }
00203         return $sSql;
00204     }
00205 
00211     public function buildWhere()
00212     {
00213         // we override this to select only parent articles
00214         $this->_aWhere = ( array ) parent::buildWhere();
00215 
00216         // adding folder check
00217         $sFolder = oxConfig::getParameter( 'folder' );
00218         if ( $sFolder && $sFolder != '-1' ) {
00219             $sViewName = getViewName( 'oxarticles' );
00220             $this->_aWhere["$sViewName.oxfolder"] = $sFolder;
00221         }
00222 
00223         return $this->_aWhere;
00224     }
00225 
00234     protected function _prepareWhereQuery( $aWhere, $sQ )
00235     {
00236         $sQ = parent::_prepareWhereQuery( $aWhere, $sQ );
00237 
00238         return $sQ . " and ".getViewName( 'oxarticles' ).".oxparentid = '' ";
00239     }
00240 
00246     public function deleteEntry()
00247     {
00248         $sOxId = oxConfig::getParameter( "oxid" );
00249         $oArticle = oxNew( "oxarticle");
00250         if ( $sOxId && $oArticle->load( $sOxId ) ) {
00251             parent::deleteEntry();
00252         }
00253     }
00254 
00255 }

Generated by  doxygen 1.6.2