OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
article_list.php
Go to the documentation of this file.
1 <?php
2 
9 class Article_List extends oxAdminList
10 {
16  protected $_sListClass = 'oxarticle';
17 
23  protected $_sListType = 'oxarticlelist';
24 
31  public function render()
32  {
33  $myConfig = $this->getConfig();
34  $sPwrSearchFld = oxConfig::getParameter( "pwrsearchfld" );
35  $sPwrSearchFld = $sPwrSearchFld ? strtolower( $sPwrSearchFld ) : "oxtitle";
36 
37  $oArticle = null;
38  $oList = $this->getItemList();
39  if ( $oList) {
40  foreach ( $oList as $key => $oArticle ) {
41  $sFieldName = "oxarticles__{$sPwrSearchFld}";
42 
43  // formatting view
44  if ( !$myConfig->getConfigParam( 'blSkipFormatConversion' ) ) {
45  if ( $oArticle->$sFieldName->fldtype == "datetime" )
46  oxRegistry::get("oxUtilsDate")->convertDBDateTime( $oArticle->$sFieldName );
47  elseif ( $oArticle->$sFieldName->fldtype == "timestamp" )
48  oxRegistry::get("oxUtilsDate")->convertDBTimestamp( $oArticle->$sFieldName );
49  elseif ( $oArticle->$sFieldName->fldtype == "date" )
50  oxRegistry::get("oxUtilsDate")->convertDBDate( $oArticle->$sFieldName );
51  }
52 
53  $oArticle->pwrsearchval = $oArticle->$sFieldName->value;
54  $oList[$key] = $oArticle;
55  }
56  }
57 
59 
60  // load fields
61  if ( !$oArticle && $oList ) {
62  $oArticle = $oList->getBaseObject();
63  }
64  $this->_aViewData["pwrsearchfields"] = $oArticle ? $this->getSearchFields() : null;
65  $this->_aViewData["pwrsearchfld"] = strtoupper( $sPwrSearchFld );
66 
67  $aFilter = $this->getListFilter();
68  if ( isset( $aFilter["oxarticles"][$sPwrSearchFld] ) ) {
69  $this->_aViewData["pwrsearchinput"] = $aFilter["oxarticles"][$sPwrSearchFld];
70  }
71 
72  $sType = '';
73  $sValue = '';
74 
75  $sArtCat= oxConfig::getParameter( "art_category" );
76  if ( $sArtCat && strstr( $sArtCat, "@@" ) !== false ) {
77  list( $sType, $sValue ) = explode( "@@", $sArtCat );
78  }
79  $this->_aViewData["art_category"] = $sArtCat;
80 
81  // parent categorie tree
82  $this->_aViewData["cattree"] = $this->getCategoryList($sType, $sValue);
83 
84  // manufacturer list
85  $this->_aViewData["mnftree"] = $this->getManufacturerlist($sType, $sValue);
86 
87  // vendor list
88  $this->_aViewData["vndtree"] = $this->getVendorList($sType, $sValue);
89 
90  return "article_list.tpl";
91  }
92 
98  public function getSearchFields()
99  {
100  $aSkipFields = array("oxblfixedprice", "oxvarselect", "oxamitemid", "oxamtaskid", "oxpixiexport", "oxpixiexported") ;
101  $oArticle = oxNew( "oxarticle" );
102  return array_diff( $oArticle->getFieldNames(), $aSkipFields );
103  }
104 
113  public function getCategoryList($sType, $sValue)
114  {
115  $myConfig = $this->getConfig();
116 
117  // parent categorie tree
118  $oCatTree = oxNew( "oxCategoryList" );
119  $oCatTree->loadList();
120  if ( $sType === 'cat' ) {
121  foreach ($oCatTree as $oCategory ) {
122  if ( $oCategory->oxcategories__oxid->value == $sValue ) {
123  $oCategory->selected = 1;
124  break;
125  }
126  }
127  }
128 
129  return $oCatTree;
130  }
131 
140  public function getManufacturerList($sType, $sValue)
141  {
142  $oMnfTree = oxNew( "oxManufacturerList");
143  $oMnfTree->loadManufacturerList();
144  if ( $sType === 'mnf' ) {
145  foreach ($oMnfTree as $oManufacturer ) {
146  if ( $oManufacturer->oxmanufacturers__oxid->value == $sValue ) {
147  $oManufacturer->selected = 1;
148  break;
149  }
150  }
151  }
152 
153  return $oMnfTree;
154  }
155 
164  public function getVendorList($sType, $sValue)
165  {
166  $oVndTree = oxNew( "oxVendorList");
167  $oVndTree->loadVendorList();
168  if ( $sType === 'vnd' ) {
169  foreach ($oVndTree as $oVendor ) {
170  if ( $oVendor->oxvendor__oxid->value == $sValue ) {
171  $oVendor->selected = 1;
172  break;
173  }
174  }
175  }
176 
177  return $oVndTree;
178  }
179 
187  protected function _buildSelectString( $oListObject = null )
188  {
189  $sQ = parent::_buildSelectString( $oListObject );
190  if ( $sQ ) {
191  $sTable = getViewName( "oxarticles" );
192  $sQ .= " and $sTable.oxparentid = '' ";
193 
194  $sType = false;
195  $sArtCat = oxConfig::getParameter( "art_category" );
196  if ( $sArtCat && strstr( $sArtCat, "@@" ) !== false ) {
197  list( $sType, $sValue ) = explode("@@", $sArtCat );
198  }
199 
200  switch ( $sType ) {
201  // add category
202  case 'cat':
203  $oStr = getStr();
204  $sO2CView = getViewName( "oxobject2category" );
205  $sInsert = "from $sTable left join $sO2CView on $sTable.oxid = $sO2CView.oxobjectid where $sO2CView.oxcatnid = ".oxDb::getDb()->quote($sValue)." and ";
206  $sQ = $oStr->preg_replace( "/from\s+$sTable\s+where/i", $sInsert, $sQ);
207  break;
208  // add category
209  case 'mnf':
210  $sQ.= " and $sTable.oxmanufacturerid = ".oxDb::getDb()->quote($sValue);
211  break;
212  // add vendor
213  case 'vnd':
214  $sQ.= " and $sTable.oxvendorid = ".oxDb::getDb()->quote($sValue);
215  break;
216  }
217  }
218 
219  return $sQ;
220  }
221 
227  public function buildWhere()
228  {
229  // we override this to select only parent articles
230  $this->_aWhere = parent::buildWhere();
231 
232  // adding folder check
233  $sFolder = oxConfig::getParameter( 'folder' );
234  if ( $sFolder && $sFolder != '-1' ) {
235  $this->_aWhere[getViewName( "oxarticles" ).".oxfolder"] = $sFolder;
236  }
237 
238  return $this->_aWhere;
239  }
240 
246  public function deleteEntry()
247  {
248  $sOxId = $this->getEditObjectId();
249  $oArticle = oxNew( "oxarticle");
250  if ( $sOxId && $oArticle->load( $sOxId ) ) {
252  }
253  }
254 
255 }