Changeset 13130
- Timestamp:
- 10/27/07 20:15:03 (1 year ago)
- Files:
-
- trunk/midcom/midgard.admin.asgard/navigation.php (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midgard.admin.asgard/navigation.php
r12816 r13130 5 5 /** 6 6 * Root types 7 * 7 * 8 8 * @access public 9 9 * @var string 10 */ 10 */ 11 11 var $root_types = array(); 12 12 … … 21 21 /** 22 22 * Object path to the current object. 23 * 23 * 24 24 * @access private 25 25 * @var Array 26 26 */ 27 27 var $_object_path = array(); 28 28 29 29 var $_reflectors = array(); 30 30 var $_request_data = array(); 31 31 var $expanded_root_types = array(); 32 32 var $shown_objects = array(); 33 33 34 34 function midgard_admin_asgard_navigation($object, &$request_data) 35 35 { 36 36 $this->_component = 'midgard.admin.asgard'; 37 37 parent::midcom_baseclasses_components_purecode(); 38 38 39 39 $this->_object = $object; 40 40 $this->_object_path = $this->get_object_path(); 41 41 $this->_request_data =& $request_data; 42 42 43 43 $this->root_types = midgard_admin_asgard_reflector_tree::get_root_classes(); 44 44 45 45 if (array_key_exists('current_type', $this->_request_data)) 46 46 { … … 48 48 } 49 49 } 50 50 51 51 /* 52 52 function handle_session() … … 66 66 $session->set('midgard_admin_asgard_navigation_roots', $this->expanded_root_types); 67 67 } 68 68 69 69 if (isset($_GET['midgard_admin_asgard_navigation_close'])) 70 70 { … … 73 73 $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, "MgdSchema type '{$_GET['midgard_admin_asgard_navigation_close']}' was not found."); 74 74 } 75 75 76 76 $new_root_types = array(); 77 77 foreach ($this->expanded_root_types as $type) … … 87 87 } 88 88 */ 89 89 90 90 function &_get_reflector(&$object) 91 91 { … … 104 104 return $this->_reflectors[$classname]; 105 105 } 106 106 107 107 function get_object_path() 108 108 { … … 112 112 return $object_path; 113 113 } 114 114 115 115 $object_path[] = $this->_object->guid; 116 116 … … 122 122 $parent = $parent->get_parent(); 123 123 } 124 124 125 125 return array_reverse($object_path); 126 126 } 127 127 128 128 function _list_child_elements($object, $prefix = ' ', $level = 0) 129 129 { … … 148 148 continue; 149 149 } 150 150 151 151 $ref =& $this->_get_reflector(&$child); 152 152 … … 158 158 $css_class .= ' selected'; 159 159 } 160 160 161 161 if ($child->guid == $this->_object->guid) 162 162 { 163 163 $css_class .= ' current'; 164 164 } 165 165 166 166 $this->shown_objects[$child->guid] = true; 167 167 168 168 echo "{$prefix} <li class=\"{$css_class}\">"; 169 169 … … 174 174 $label = "#{$child->id}"; 175 175 } 176 176 177 177 echo "<a href=\"{$_MIDGARD['self']}__mfa/asgard/object/view/{$child->guid}/\" title=\"GUID: {$child->guid}, ID: {$child->id}\">{$icon}{$label}</a>\n"; 178 178 179 179 180 180 if ($selected) … … 182 182 $this->_list_child_elements($child, "{$prefix} ", $level+1); 183 183 } 184 184 185 185 echo "{$prefix} </li>\n"; 186 186 } … … 189 189 } 190 190 } 191 191 192 192 function _draw_plugins() 193 193 { … … 213 213 } 214 214 } 215 215 216 216 function draw() 217 217 { … … 219 219 $this->_draw_plugins(); 220 220 $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'); 222 222 if (!empty($this->_object_path)) 223 223 { 224 224 $root_object = $_MIDCOM->dbfactory->get_object_by_guid($this->_object_path[0]); 225 225 } 226 227 $label_mapping = Array(); 226 228 foreach ($this->root_types as $root_type) 227 229 { 228 230 $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 230 239 if (in_array($root_type, $this->expanded_root_types)) 231 240 { … … 236 245 $this->_request_data['section_url'] = "{$_MIDGARD['self']}__mfa/asgard/{$root_type}"; 237 246 } 238 239 $this->_request_data['section_name'] = $ ref->get_class_label();247 248 $this->_request_data['section_name'] = $label; 240 249 midcom_show_style('midgard_admin_asgard_navigation_section_header'); 241 250 if ( isset($root_object) 242 && (is_a($root_object, $root_type) 251 && (is_a($root_object, $root_type) 243 252 || midgard_admin_asgard_reflector::is_same_class($root_type,$root_object->__midcom_class_name__)) 244 253 || in_array($root_type, $this->expanded_root_types)) … … 248 257 { 249 258 echo "<ul class=\"midgard_admin_asgard_navigation\">\n"; 250 259 251 260 foreach ($root_objects as $object) 252 261 { … … 258 267 $css_class .= ' selected'; 259 268 } 260 269 261 270 if ( is_object($this->_object) 262 271 && $object->guid == $this->_object->guid) … … 265 274 } 266 275 $this->shown_objects[$object->guid] = true; 267 276 268 277 echo " <li class=\"{$css_class}\">"; 269 278 … … 274 283 $label = "#{$object->id}"; 275 284 } 276 285 277 286 echo "<a href=\"{$_MIDGARD['self']}__mfa/asgard/object/view/{$object->guid}/\" title=\"GUID: {$object->guid}, ID: {$object->id}\">{$icon}{$label}</a>\n"; 278 287 … … 281 290 $this->_list_child_elements($root_object); 282 291 } 283 292 284 293 echo " </li>\n"; 285 294 } 286 295 287 296 echo "</ul>\n"; 288 297 }
