OXID eShop CE  4.9.11
 All Classes Files Functions Variables Pages
category_list.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
17  protected $_sListClass = 'oxcategory';
18 
24  protected $_sListType = 'oxcategorylist';
25 
31  public function getListSorting()
32  {
33  $sSortParameter = oxRegistry::getConfig()->getRequestParameter('sort');
34  if ($this->_aCurrSorting === null && !$sSortParameter && ($oBaseObject = $this->getItemListBaseObject())) {
35  $sCatView = $oBaseObject->getCoreTableName();
36 
37  $this->_aCurrSorting[$sCatView]["oxrootid"] = "desc";
38  $this->_aCurrSorting[$sCatView]["oxleft"] = "asc";
39 
40  return $this->_aCurrSorting;
41  } else {
42  return parent::getListSorting();
43  }
44  }
45 
52  public function render()
53  {
54  $myConfig = $this->getConfig();
55 
57 
58  $oLang = oxRegistry::getLang();
59  $iLang = $oLang->getTplLanguage();
60 
61  // parent category tree
62  $oCatTree = oxNew("oxCategoryList");
63  $oCatTree->loadList();
64 
65  // add Root as fake category
66  // rebuild list as we need the root entry at the first position
67  $aNewList = array();
68  $oRoot = new stdClass();
69  $oRoot->oxcategories__oxid = new oxField(null, oxField::T_RAW);
70  $oRoot->oxcategories__oxtitle = new oxField($oLang->translateString("viewAll", $iLang), oxField::T_RAW);
71  $aNewList[] = $oRoot;
72 
73  $oRoot = new stdClass();
74  $oRoot->oxcategories__oxid = new oxField("oxrootid", oxField::T_RAW);
75  $oRoot->oxcategories__oxtitle = new oxField("-- " . $oLang->translateString("mainCategory", $iLang) . " --", oxField::T_RAW);
76  $aNewList[] = $oRoot;
77 
78  foreach ($oCatTree as $oCategory) {
79  $aNewList[] = $oCategory;
80  }
81 
82  $oCatTree->assign($aNewList);
83  $aFilter = $this->getListFilter();
84  if (is_array($aFilter) && isset($aFilter["oxcategories"]["oxparentid"])) {
85  foreach ($oCatTree as $oCategory) {
86  if ($oCategory->oxcategories__oxid->value == $aFilter["oxcategories"]["oxparentid"]) {
87  $oCategory->selected = 1;
88  break;
89  }
90  }
91  }
92 
93  $this->_aViewData["cattree"] = $oCatTree;
94 
95  return "category_list.tpl";
96  }
97 }