Mage_Adminhtml_Model_System_Config_Source_Admin_Page Class Reference

List of all members.

Public Member Functions

 toOptionArray ()

Protected Member Functions

 _createOptions (&$optionArray, $menuNode)
 _getUrlModel ()
 _buildMenuArray (Varien_Simplexml_Element $parent=null, $path='', $level=0)
 _sortMenu ($a, $b)
 _checkDepends (Varien_Simplexml_Element $depends)
 _getHelperValue (Varien_Simplexml_Element $child)

Protected Attributes

 $_url


Detailed Description

Definition at line 35 of file Page.php.


Member Function Documentation

_buildMenuArray ( Varien_Simplexml_Element parent = null,
path = '',
level = 0 
) [protected]

Definition at line 83 of file Page.php.

00084     {
00085         if (is_null($parent)) {
00086             $parent = Mage::getConfig()->getNode('adminhtml/menu');
00087         }
00088 
00089         $parentArr = array();
00090         $sortOrder = 0;
00091         foreach ($parent->children() as $childName=>$child) {
00092 
00093             if ($child->depends && !$this->_checkDepends($child->depends)) {
00094                 continue;
00095             }
00096 
00097             $menuArr = array();
00098             $menuArr['label'] = $this->_getHelperValue($child);
00099 
00100             $menuArr['sort_order'] = $child->sort_order ? (int)$child->sort_order : $sortOrder;
00101 
00102             if ($child->action) {
00103                 $menuArr['url'] = (string)$child->action;
00104             } else {
00105                 $menuArr['url'] = '';
00106             }
00107 
00108             $menuArr['level'] = $level;
00109             $menuArr['path'] = $path . $childName;
00110 
00111             if ($child->children) {
00112                 $menuArr['children'] = $this->_buildMenuArray($child->children, $path.$childName.'/', $level+1);
00113             }
00114             $parentArr[$childName] = $menuArr;
00115 
00116             $sortOrder++;
00117         }
00118 
00119         uasort($parentArr, array($this, '_sortMenu'));
00120 
00121         while (list($key, $value) = each($parentArr)) {
00122             $last = $key;
00123         }
00124         if (isset($last)) {
00125             $parentArr[$last]['last'] = true;
00126         }
00127 
00128         return $parentArr;
00129     }

_checkDepends ( Varien_Simplexml_Element depends  )  [protected]

Definition at line 136 of file Page.php.

00137     {
00138         if ($depends->module) {
00139             $modulesConfig = Mage::getConfig()->getNode('modules');
00140             foreach ($depends->module as $module) {
00141                 if (!$modulesConfig->$module || !$modulesConfig->$module->is('active')) {
00142                     return false;
00143                 }
00144             }
00145         }
00146 
00147         return true;
00148     }

_createOptions ( &$  optionArray,
menuNode 
) [protected]

Definition at line 49 of file Page.php.

00050     {
00051         foreach ($menuNode as $menu) {
00052 
00053             if (!empty($menu['url'])) {
00054                 $optionArray[] = array(
00055                     'label' => str_repeat(' ', ($menu['level'] * 4)) . $menu['label'],
00056                     'value' => $menu['path'],
00057                 );
00058 
00059                 if (isset($menu['children'])) {
00060                     $this->_createOptions($optionArray, $menu['children']);
00061                 }
00062             }
00063             else {
00064                 $children = array();
00065                 $this->_createOptions($children, $menu['children']);
00066 
00067                 $optionArray[] = array(
00068                     'label' => str_repeat(' ', ($menu['level'] * 4)) . $menu['label'],
00069                     'value' => $children,
00070                 );
00071             }
00072         }
00073     }

_getHelperValue ( Varien_Simplexml_Element child  )  [protected]

Definition at line 150 of file Page.php.

00151     {
00152         $helperName         = 'adminhtml';
00153         $titleNodeName      = 'title';
00154         $childAttributes    = $child->attributes();
00155         if (isset($childAttributes['module'])) {
00156             $helperName     = (string)$childAttributes['module'];
00157         }
00158 
00159         $titleNodeName = 'title';
00160 
00161         return Mage::helper($helperName)->__((string)$child->$titleNodeName);
00162     }

_getUrlModel (  )  [protected]

Definition at line 75 of file Page.php.

00076     {
00077         if (is_null($this->_url)) {
00078             $this->_url = Mage::getModel('adminhtml/url');
00079         }
00080         return $this->_url;
00081     }

_sortMenu ( a,
b 
) [protected]

Definition at line 131 of file Page.php.

00132     {
00133         return $a['sort_order']<$b['sort_order'] ? -1 : ($a['sort_order']>$b['sort_order'] ? 1 : 0);
00134     }

toOptionArray (  ) 

Definition at line 39 of file Page.php.

00040     {
00041         $options = array();
00042         $menu    = $this->_buildMenuArray();
00043 
00044         $this->_createOptions($options, $menu);
00045 
00046         return $options;
00047     }


Member Data Documentation

$_url [protected]

Definition at line 37 of file Page.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:13 2009 for Magento by  doxygen 1.5.8