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         $oCatTree = oxNew( "oxCategoryList");
00086         $oCatTree->buildList( $myConfig->getConfigParam( 'bl_perfLoadCatTree' ) );
00087         if ( $sType === 'cat' ) {
00088             foreach ($oCatTree as $oCategory ) {
00089                 if ( $oCategory->oxcategories__oxid->value == $sValue ) {
00090                     $oCategory->selected = 1;
00091                     break;
00092                 }
00093             }
00094         }
00095         $this->_aViewData["cattree"] = $oCatTree;
00096 
00097        // manufacturer list
00098         $oMnfTree = oxNew( "oxManufacturerList");
00099         $oMnfTree->loadManufacturerList();
00100         if ( $sType === 'mnf' ) {
00101             foreach ($oMnfTree as $oManufacturer ) {
00102                 if ( $oManufacturer->oxmanufacturers__oxid->value == $sValue ) {
00103                     $oManufacturer->selected = 1;
00104                     break;
00105                 }
00106             }
00107         }
00108         $this->_aViewData["mnftree"] = $oMnfTree;
00109 
00110         // vendor list
00111         $oVndTree = oxNew( "oxVendorList");
00112         $oVndTree->loadVendorList();
00113         if ( $sType === 'vnd' ) {
00114             foreach ($oVndTree as $oVendor ) {
00115                 if ( $oVendor->oxvendor__oxid->value == $sValue ) {
00116                     $oVendor->selected = 1;
00117                     break;
00118                 }
00119             }
00120         }
00121         $this->_aViewData["vndtree"] = $oVndTree;
00122 
00123         return "article_list.tpl";
00124     }
00125 
00133     protected function _changeselect( $sSql )
00134     {
00135         $sArtCat= oxConfig::getParameter("art_category");
00136         if ( $sArtCat && strstr($sArtCat, "@@") !== false ) {
00137             list($sType, $sValue) = explode("@@", $sArtCat);
00138         }
00139 
00140         $sTable   = getViewName( "oxarticles" );
00141         switch ($sType) {
00142             // add category
00143             case 'cat':
00144                 $sO2CView = getViewName( "oxobject2category" );
00145                 $sInsert  = "from $sTable left join $sO2CView on $sTable.oxid = $sO2CView.oxobjectid where $sO2CView.oxcatnid = ".oxDb::getDb()->quote($sValue)." and ";
00146                 $sSql = preg_replace( "/from\s+$sTable\s+where/i", $sInsert, $sSql);
00147                 break;
00148             // add category
00149             case 'mnf':
00150                 $sSql.= " and $sTable.oxmanufacturerid = ".oxDb::getDb()->quote($sValue);
00151                 break;
00152             // add vendor
00153             case 'vnd':
00154                 $sSql.= " and $sTable.oxvendorid = ".oxDb::getDb()->quote($sValue);
00155                 break;
00156         }
00157         return $sSql;
00158     }
00159 
00165     public function buildWhere()
00166     {
00167         // we override this to select only parent articles
00168         $this->_aWhere = ( array ) parent::buildWhere();
00169 
00170         // adding folder check
00171         $sFolder = oxConfig::getParameter( 'folder' );
00172         if ( $sFolder && $sFolder != '-1' ) {
00173             $sViewName = getViewName( 'oxarticles' );
00174             $this->_aWhere["$sViewName.oxfolder"] = $sFolder;
00175         }
00176 
00177         return $this->_aWhere;
00178     }
00179 
00188     protected function _prepareWhereQuery( $aWhere, $sQ )
00189     {
00190         $sQ = parent::_prepareWhereQuery( $aWhere, $sQ );
00191 
00192         return $sQ . " and ".getViewName( 'oxarticles' ).".oxparentid = '' ";
00193     }
00194 
00200     public function deleteEntry()
00201     {
00202         $sOxId = oxConfig::getParameter( "oxid" );
00203         $oArticle = oxNew( "oxarticle");
00204         if ( $sOxId && $oArticle->load( $sOxId ) ) {
00205             parent::deleteEntry();
00206         }
00207     }
00208 
00209 }

Generated by  doxygen 1.6.2