oxcontentlist.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxContentList extends oxList
00009 {
00015     const TYPE_INFORMATION_CONTENTS = 0;
00016 
00022     const TYPE_MAIN_MENU_LIST = 1;
00023 
00029     const TYPE_CATEGORY_MENU = 2;
00030 
00036     const TYPE_SERVICE_LIST = 3;
00037 
00043     protected $_aServiceKeys = array( 'oximpressum', 'oxagb', 'oxsecurityinfo', 'oxdeliveryinfo', 'oxrightofwithdrawal', 'oxorderinfo', 'oxcredits' );
00044 
00050     public function setServiceKeys( $aServiceKeys )
00051     {
00052         $this->_aServiceKeys = $aServiceKeys;
00053     }
00054 
00060     public function getServiceKeys()
00061     {
00062         return $this->_aServiceKeys;
00063     }
00064 
00070     public function __construct( $sObjectsInListName = 'oxcontent' )
00071     {
00072         parent::__construct( 'oxcontent' );
00073     }
00074 
00078     public function loadMainMenulist()
00079     {
00080         $this->_load( self::TYPE_MAIN_MENU_LIST );
00081     }
00082 
00086     public function loadCatMenues()
00087     {
00088         $this->_load( self::TYPE_CATEGORY_MENU );
00089         $aArray = array();
00090 
00091         if ( $this->count() ) {
00092             foreach ( $this as $oContent ) {
00093                 // add into category tree
00094                 if ( !isset( $aArray[$oContent->getCategoryId()] ) ) {
00095                     $aArray[$oContent->getCategoryId()] = array();
00096                 }
00097 
00098                 $aArray[$oContent->oxcontents__oxcatid->value][] = $oContent;
00099             }
00100         }
00101 
00102         $this->_aArray = $aArray;
00103     }
00104 
00105 
00113     protected function _loadFromDb( $iType )
00114     {
00115         $sSql = $this->_getSQLByType( $iType );
00116         $aData = oxDb::getDb( oxDb::FETCH_MODE_ASSOC )->getAll( $sSql );
00117 
00118         return $aData;
00119     }
00120 
00128     protected function _load( $iType )
00129     {
00130 
00131             $aData = $this->_loadFromDb( $iType );
00132 
00133         $this->assignArray( $aData );
00134     }
00135 
00136 
00142     public function loadServices()
00143     {
00144         $this->_load( self::TYPE_SERVICE_LIST );
00145         $this->_extractListToArray();
00146     }
00147 
00151     protected function _extractListToArray()
00152     {
00153         $aExtractedContents = array();
00154         foreach ( $this as $oContent ) {
00155             $aExtractedContents[$oContent->getLoadId()] = $oContent;
00156         }
00157 
00158         $this->_aArray = $aExtractedContents;
00159     }
00160 
00168     protected function _getSQLByType( $iType )
00169     {
00170         $sSQLAdd = '';
00171         $oDb = oxDb::getDb();
00172         $sSQLType = " AND `oxtype` = " . $oDb->quote( $iType );
00173 
00174         if ( $iType == self::TYPE_CATEGORY_MENU ) {
00175             $sSQLAdd = " AND `oxcatid` IS NOT NULL AND `oxsnippet` = '0'";
00176         }
00177 
00178         if ( $iType == self::TYPE_SERVICE_LIST ) {
00179             $sIdents = implode( ", ", oxDb::getInstance()->quoteArray( $this->getServiceKeys() ) );
00180             $sSQLAdd = " AND OXLOADID IN (" . $sIdents . ")";
00181             $sSQLType = '';
00182         }
00183         $sViewName = $this->getBaseObject()->getViewName();
00184         $sSql = "SELECT * FROM {$sViewName} WHERE `oxactive` = '1' $sSQLType AND `oxshopid` = " . $oDb->quote( $this->_sShopID ) . " $sSQLAdd ORDER BY `oxloadid`";
00185 
00186         return $sSql;
00187     }
00188 }