category_list.php

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