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