Changeset 13130

Show
Ignore:
Timestamp:
10/27/07 20:15:03 (1 year ago)
Author:
flack
Message:

sort navigation alphabetically, this makes it a bit easier to find a specific class

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midgard.admin.asgard/navigation.php

    r12816 r13130  
    55    /** 
    66     * Root types 
    7      *  
     7     * 
    88     * @access public 
    99     * @var string 
    10      */  
     10     */ 
    1111    var $root_types = array(); 
    1212 
     
    2121    /** 
    2222     * Object path to the current object. 
    23      *  
     23     * 
    2424     * @access private 
    2525     * @var Array 
    2626     */ 
    2727    var $_object_path = array(); 
    28      
     28 
    2929    var $_reflectors = array(); 
    3030    var $_request_data = array(); 
    3131    var $expanded_root_types = array(); 
    3232    var $shown_objects = array(); 
    33      
     33 
    3434    function midgard_admin_asgard_navigation($object, &$request_data) 
    3535    { 
    3636        $this->_component = 'midgard.admin.asgard'; 
    3737        parent::midcom_baseclasses_components_purecode(); 
    38          
     38 
    3939        $this->_object = $object; 
    4040        $this->_object_path = $this->get_object_path(); 
    4141        $this->_request_data =& $request_data; 
    42          
     42 
    4343        $this->root_types = midgard_admin_asgard_reflector_tree::get_root_classes(); 
    44       
     44 
    4545        if (array_key_exists('current_type', $this->_request_data)) 
    4646        { 
     
    4848        } 
    4949    } 
    50      
     50 
    5151    /* 
    5252    function handle_session() 
     
    6666            $session->set('midgard_admin_asgard_navigation_roots', $this->expanded_root_types); 
    6767        } 
    68          
     68 
    6969        if (isset($_GET['midgard_admin_asgard_navigation_close'])) 
    7070        { 
     
    7373                $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, "MgdSchema type '{$_GET['midgard_admin_asgard_navigation_close']}' was not found."); 
    7474            } 
    75              
     75 
    7676            $new_root_types = array(); 
    7777            foreach ($this->expanded_root_types as $type) 
     
    8787    } 
    8888    */ 
    89      
     89 
    9090    function &_get_reflector(&$object) 
    9191    { 
     
    104104        return $this->_reflectors[$classname]; 
    105105    } 
    106      
     106 
    107107    function get_object_path() 
    108108    { 
     
    112112            return $object_path; 
    113113        } 
    114          
     114 
    115115        $object_path[] = $this->_object->guid; 
    116116 
     
    122122            $parent = $parent->get_parent(); 
    123123        } 
    124          
     124 
    125125        return array_reverse($object_path); 
    126126    } 
    127      
     127 
    128128    function _list_child_elements($object, $prefix = '    ', $level = 0) 
    129129    { 
     
    148148                        continue; 
    149149                    } 
    150                      
     150 
    151151                    $ref =& $this->_get_reflector(&$child); 
    152152 
     
    158158                        $css_class .= ' selected'; 
    159159                    } 
    160                      
     160 
    161161                    if ($child->guid == $this->_object->guid) 
    162162                    { 
    163163                        $css_class .= ' current'; 
    164164                    } 
    165                      
     165 
    166166                    $this->shown_objects[$child->guid] = true; 
    167                      
     167 
    168168                    echo "{$prefix}    <li class=\"{$css_class}\">"; 
    169169 
     
    174174                        $label = "#{$child->id}"; 
    175175                    } 
    176                      
     176 
    177177                    echo "<a href=\"{$_MIDGARD['self']}__mfa/asgard/object/view/{$child->guid}/\" title=\"GUID: {$child->guid}, ID: {$child->id}\">{$icon}{$label}</a>\n"; 
    178                      
     178 
    179179 
    180180                    if ($selected) 
     
    182182                        $this->_list_child_elements($child, "{$prefix}        ", $level+1); 
    183183                    } 
    184                      
     184 
    185185                    echo "{$prefix}    </li>\n"; 
    186186                } 
     
    189189        } 
    190190    } 
    191      
     191 
    192192    function _draw_plugins() 
    193193    { 
     
    213213        } 
    214214    } 
    215      
     215 
    216216    function draw() 
    217217    { 
     
    219219        $this->_draw_plugins(); 
    220220        $this->_request_data['chapter_name'] = $_MIDCOM->i18n->get_string('midgard objects', 'midgard.admin.asgard'); 
    221         midcom_show_style('midgard_admin_asgard_navigation_chapter');     
     221        midcom_show_style('midgard_admin_asgard_navigation_chapter'); 
    222222        if (!empty($this->_object_path)) 
    223223        { 
    224224            $root_object = $_MIDCOM->dbfactory->get_object_by_guid($this->_object_path[0]); 
    225225        } 
     226 
     227        $label_mapping = Array(); 
    226228        foreach ($this->root_types as $root_type) 
    227229        { 
    228230            $ref = $this->_get_reflector($root_type); 
    229              
     231            $label_mapping[$root_type] = $ref->get_class_label(); 
     232        } 
     233        sort($label_mapping); 
     234 
     235        foreach ($label_mapping as $root_type => $label) 
     236        { 
     237            $ref = $this->_get_reflector($root_type); 
     238 
    230239            if (in_array($root_type, $this->expanded_root_types)) 
    231240            { 
     
    236245                $this->_request_data['section_url'] = "{$_MIDGARD['self']}__mfa/asgard/{$root_type}"; 
    237246            } 
    238              
    239             $this->_request_data['section_name'] = $ref->get_class_label()
     247 
     248            $this->_request_data['section_name'] = $label
    240249            midcom_show_style('midgard_admin_asgard_navigation_section_header'); 
    241250            if (   isset($root_object) 
    242                 && (is_a($root_object, $root_type)  
     251                && (is_a($root_object, $root_type) 
    243252                        || midgard_admin_asgard_reflector::is_same_class($root_type,$root_object->__midcom_class_name__)) 
    244253                || in_array($root_type, $this->expanded_root_types)) 
     
    248257                { 
    249258                    echo "<ul class=\"midgard_admin_asgard_navigation\">\n"; 
    250               
     259 
    251260                    foreach ($root_objects as $object) 
    252261                    { 
     
    258267                            $css_class .= ' selected'; 
    259268                        } 
    260                          
     269 
    261270                        if (   is_object($this->_object) 
    262271                            && $object->guid == $this->_object->guid) 
     
    265274                        } 
    266275                        $this->shown_objects[$object->guid] = true; 
    267                          
     276 
    268277                        echo "    <li class=\"{$css_class}\">"; 
    269278 
     
    274283                            $label = "#{$object->id}"; 
    275284                        } 
    276                          
     285 
    277286                        echo "<a href=\"{$_MIDGARD['self']}__mfa/asgard/object/view/{$object->guid}/\" title=\"GUID: {$object->guid}, ID: {$object->id}\">{$icon}{$label}</a>\n"; 
    278287 
     
    281290                            $this->_list_child_elements($root_object); 
    282291                        } 
    283                          
     292 
    284293                        echo "    </li>\n"; 
    285294                    } 
    286                      
     295 
    287296                    echo "</ul>\n"; 
    288297                }