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 
00031     public function init()
00032     {
00033         $sCatView = getViewName('oxcategories');
00034         $this->_sDefSort = "$sCatView.oxrootid desc, $sCatView.oxleft";
00035         parent::Init();
00036     }
00037 
00044     public function render()
00045     {
00046         $myConfig = $this->getConfig();
00047 
00048         parent::render();
00049 
00050         $oLang = oxLang::getInstance();
00051         $iLang = $oLang->getTplLanguage();
00052 
00053         // parent categorie tree
00054         $oCatTree = oxNew( "oxCategoryList" );
00055         $oCatTree->buildList( $myConfig->getConfigParam( 'bl_perfLoadCatTree' ) );
00056 
00057         // add Root as fake category
00058         // rebuild list as we need the root entry at the first position
00059         $aNewList = array();
00060         $oRoot = new oxStdClass();
00061         $oRoot->oxcategories__oxid    = new oxField( null, oxField::T_RAW );
00062         $oRoot->oxcategories__oxtitle = new oxField( $oLang->translateString("viewAll", $iLang ), oxField::T_RAW );
00063         $aNewList[] = $oRoot;
00064 
00065         $oRoot = new oxStdClass();
00066         $oRoot->oxcategories__oxid    = new oxField( "oxrootid", oxField::T_RAW );
00067         $oRoot->oxcategories__oxtitle = new oxField( "-- ".$oLang->translateString("mainCategory", $iLang )." --", oxField::T_RAW );
00068         $aNewList[] = $oRoot;
00069 
00070         foreach( $oCatTree as $oCategory ) {
00071             $aNewList[] = $oCategory;
00072         }
00073 
00074         $oCatTree->assign( $aNewList );
00075 
00076         $sCatView = getViewName( 'oxcategories' );
00077 
00078         $aWhere  = oxConfig::getParameter( "where" );
00079         if ( is_array( $aWhere ) && isset( $aWhere["{$sCatView}.oxparentid"] ) ) {
00080             foreach( $oCatTree as $oCategory ) {
00081                 if ( $oCategory->oxcategories__oxid->value == $aWhere["{$sCatView}.oxparentid"]) {
00082                     $oCategory->selected = 1;
00083                     break;
00084                 }
00085             }
00086         }
00087 
00088         $this->_aViewData["cattree"] = $oCatTree;
00089 
00090         return "category_list.tpl";
00091     }
00092 }

Generated on Wed Apr 22 12:26:29 2009 for OXID eShop CE by  doxygen 1.5.5