category_list.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Category_List extends oxAdminList
00010 {
00011 
00017     protected $_sListClass = 'oxcategory';
00018 
00024     protected $_sListType = 'oxcategorylist';
00025 
00031     public function getListSorting()
00032     {
00033         $sSortParameter = oxRegistry::getConfig()->getRequestParameter('sort');
00034         if ($this->_aCurrSorting === null && !$sSortParameter && ($oBaseObject = $this->getItemListBaseObject())) {
00035             $sCatView = $oBaseObject->getCoreTableName();
00036 
00037             $this->_aCurrSorting[$sCatView]["oxrootid"] = "desc";
00038             $this->_aCurrSorting[$sCatView]["oxleft"] = "asc";
00039 
00040             return $this->_aCurrSorting;
00041         } else {
00042             return parent::getListSorting();
00043         }
00044     }
00045 
00052     public function render()
00053     {
00054         $myConfig = $this->getConfig();
00055 
00056         parent::render();
00057 
00058         $oLang = oxRegistry::getLang();
00059         $iLang = $oLang->getTplLanguage();
00060 
00061         // parent category tree
00062         $oCatTree = oxNew("oxCategoryList");
00063         $oCatTree->loadList();
00064 
00065         // add Root as fake category
00066         // rebuild list as we need the root entry at the first position
00067         $aNewList = array();
00068         $oRoot = new stdClass();
00069         $oRoot->oxcategories__oxid = new oxField(null, oxField::T_RAW);
00070         $oRoot->oxcategories__oxtitle = new oxField($oLang->translateString("viewAll", $iLang), oxField::T_RAW);
00071         $aNewList[] = $oRoot;
00072 
00073         $oRoot = new stdClass();
00074         $oRoot->oxcategories__oxid = new oxField("oxrootid", oxField::T_RAW);
00075         $oRoot->oxcategories__oxtitle = new oxField("-- " . $oLang->translateString("mainCategory", $iLang) . " --", oxField::T_RAW);
00076         $aNewList[] = $oRoot;
00077 
00078         foreach ($oCatTree as $oCategory) {
00079             $aNewList[] = $oCategory;
00080         }
00081 
00082         $oCatTree->assign($aNewList);
00083         $aFilter = $this->getListFilter();
00084         if (is_array($aFilter) && isset($aFilter["oxcategories"]["oxparentid"])) {
00085             foreach ($oCatTree as $oCategory) {
00086                 if ($oCategory->oxcategories__oxid->value == $aFilter["oxcategories"]["oxparentid"]) {
00087                     $oCategory->selected = 1;
00088                     break;
00089                 }
00090             }
00091         }
00092 
00093         $this->_aViewData["cattree"] = $oCatTree;
00094 
00095         return "category_list.tpl";
00096     }
00097 }