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