OXID eShop CE  4.10.4
 All Classes Namespaces Files Functions Variables Pages
oxcontentlist.php
Go to the documentation of this file.
1 <?php
2 
8 class oxContentList extends oxList
9 {
10 
17 
24 
30  const TYPE_CATEGORY_MENU = 2;
31 
37  const TYPE_SERVICE_LIST = 3;
38 
44  protected $_aServiceKeys = array('oximpressum', 'oxagb', 'oxsecurityinfo', 'oxdeliveryinfo', 'oxrightofwithdrawal', 'oxorderinfo', 'oxcredits');
45 
51  public function setServiceKeys($aServiceKeys)
52  {
53  $this->_aServiceKeys = $aServiceKeys;
54  }
55 
61  public function getServiceKeys()
62  {
63  return $this->_aServiceKeys;
64  }
65 
71  public function __construct()
72  {
73  parent::__construct('oxcontent');
74  }
75 
79  public function loadMainMenulist()
80  {
81  $this->_load(self::TYPE_MAIN_MENU_LIST);
82  }
83 
87  public function loadCatMenues()
88  {
89  $this->_load(self::TYPE_CATEGORY_MENU);
90  $aArray = array();
91 
92  if ($this->count()) {
93  foreach ($this as $oContent) {
94  // add into category tree
95  if (!isset($aArray[$oContent->getCategoryId()])) {
96  $aArray[$oContent->getCategoryId()] = array();
97  }
98 
99  $aArray[$oContent->oxcontents__oxcatid->value][] = $oContent;
100  }
101  }
102 
103  $this->_aArray = $aArray;
104  }
105 
106 
114  protected function _loadFromDb($iType)
115  {
116  $sSql = $this->_getSQLByType($iType);
117  $aData = oxDb::getDb(oxDb::FETCH_MODE_ASSOC)->getAll($sSql);
118 
119  return $aData;
120  }
121 
127  protected function _load($iType)
128  {
129 
130  $aData = $this->_loadFromDb($iType);
131 
132  $this->assignArray($aData);
133  }
134 
135 
139  public function loadServices()
140  {
141  $this->_load(self::TYPE_SERVICE_LIST);
142  $this->_extractListToArray();
143  }
144 
148  protected function _extractListToArray()
149  {
150  $aExtractedContents = array();
151  foreach ($this as $oContent) {
152  $aExtractedContents[$oContent->getLoadId()] = $oContent;
153  }
154 
155  $this->_aArray = $aExtractedContents;
156  }
157 
165  protected function _getSQLByType($iType)
166  {
167  $sSQLAdd = '';
168  $oDb = oxDb::getDb();
169  $sSQLType = " AND `oxtype` = " . $oDb->quote($iType);
170 
171  if ($iType == self::TYPE_CATEGORY_MENU) {
172  $sSQLAdd = " AND `oxcatid` IS NOT NULL AND `oxsnippet` = '0'";
173  }
174 
175  if ($iType == self::TYPE_SERVICE_LIST) {
176  $sIdents = implode(", ", oxDb::getInstance()->quoteArray($this->getServiceKeys()));
177  $sSQLAdd = " AND OXLOADID IN (" . $sIdents . ")";
178  $sSQLType = '';
179  }
180  $sViewName = $this->getBaseObject()->getViewName();
181  $sSql = "SELECT * FROM {$sViewName} WHERE `oxactive` = '1' $sSQLType AND `oxshopid` = " . $oDb->quote($this->_sShopID) . " $sSQLAdd ORDER BY `oxloadid`";
182 
183  return $sSql;
184  }
185 }