oxcontentlist.php

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