Mage_Adminhtml_Block_System_Config_Tabs Class Reference

Inheritance diagram for Mage_Adminhtml_Block_System_Config_Tabs:

Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 initTabs ()
 addTab ($code, $config)
 getTab ($code)
 addSection ($code, $tabCode, $config)
 getTabs ()
 getStoreSelectOptions ()
 getStoreButtonsHtml ()
 checkSectionPermissions ($code=null)

Protected Member Functions

 _construct ()
 _sort ($a, $b)

Protected Attributes

 $_tabs


Detailed Description

Definition at line 35 of file Tabs.php.


Member Function Documentation

_construct (  )  [protected]

Enter description here...

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 49 of file Tabs.php.

00050     {
00051         $this->setId('system_config_tabs');
00052         $this->setTitle(Mage::helper('adminhtml')->__('Configuration'));
00053         $this->setTemplate('system/config/tabs.phtml');
00054     }

_sort ( a,
b 
) [protected]

Enter description here...

Parameters:
unknown_type $a
unknown_type $b
Returns:
int

Definition at line 63 of file Tabs.php.

00064     {
00065         return (int)$a->sort_order < (int)$b->sort_order ? -1 : ((int)$a->sort_order > (int)$b->sort_order ? 1 : 0);
00066     }

addSection ( code,
tabCode,
config 
)

Definition at line 178 of file Tabs.php.

00179     {
00180         if($tab = $this->getTab($tabCode)) {
00181             if(!$tab->getSections()) {
00182                 $tab->setSections(new Varien_Data_Collection());
00183             }
00184             $section = new Varien_Object($config);
00185             $section->setId($code);
00186             $tab->getSections()->addItem($section);
00187         }
00188         return $this;
00189     }

addTab ( code,
config 
)

Definition at line 155 of file Tabs.php.

00156     {
00157         $tab = new Varien_Object($config);
00158         $tab->setId($code);
00159         $this->_tabs[$code] = $tab;
00160         return $this;
00161     }

checkSectionPermissions ( code = null  ) 

Enter description here...

Parameters:
string $code
Returns:
boolean

Definition at line 323 of file Tabs.php.

00324     {
00325         static $permissions;
00326 
00327         if (!$code or trim($code) == "") {
00328             return false;
00329         }
00330 
00331         if (!$permissions) {
00332             $permissions = Mage::getSingleton('admin/session');
00333         }
00334 
00335         $showTab = false;
00336         if ( $permissions->isAllowed('system/config/'.$code) ) {
00337             $showTab = true;
00338         }
00339         return $showTab;
00340     }

getStoreButtonsHtml (  ) 

Enter description here...

Returns:
string

Definition at line 274 of file Tabs.php.

00275     {
00276         $curWebsite = $this->getRequest()->getParam('website');
00277         $curStore = $this->getRequest()->getParam('store');
00278 
00279         $html = '';
00280 
00281         if (!$curWebsite && !$curStore) {
00282             $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00283                 'label'     => Mage::helper('adminhtml')->__('New Website'),
00284                 'onclick'   => "location.href='".$this->getUrl('*/system_website/new')."'",
00285                 'class'     => 'add',
00286             ))->toHtml();
00287         } elseif (!$curStore) {
00288             $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00289                 'label'     => Mage::helper('adminhtml')->__('Edit Website'),
00290                 'onclick'   => "location.href='".$this->getUrl('*/system_website/edit', array('website'=>$curWebsite))."'",
00291             ))->toHtml();
00292             $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00293                 'label'     => Mage::helper('adminhtml')->__('New Store View'),
00294                 'onclick'   => "location.href='".$this->getUrl('*/system_store/new', array('website'=>$curWebsite))."'",
00295                 'class'     => 'add',
00296             ))->toHtml();
00297             $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00298                 'label'     => Mage::helper('adminhtml')->__('Delete Website'),
00299                 'onclick'   => "location.href='".$this->getUrl('*/system_website/delete', array('website'=>$curWebsite))."'",
00300                 'class'     => 'delete',
00301             ))->toHtml();
00302         } else {
00303             $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00304                 'label'     => Mage::helper('adminhtml')->__('Edit Store View'),
00305                 'onclick'   => "location.href='".$this->getUrl('*/system_store/edit', array('store'=>$curStore))."'",
00306             ))->toHtml();
00307             $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00308                 'label'     => Mage::helper('adminhtml')->__('Delete Store View'),
00309                 'onclick'   => "location.href='".$this->getUrl('*/system_store/delete', array('store'=>$curStore))."'",
00310                 'class'     => 'delete',
00311             ))->toHtml();
00312         }
00313 
00314         return $html;
00315     }

getStoreSelectOptions (  ) 

Enter description here...

Returns:
array

Definition at line 201 of file Tabs.php.

00202     {
00203         $section = $this->getRequest()->getParam('section');
00204 
00205         $curWebsite = $this->getRequest()->getParam('website');
00206         $curStore   = $this->getRequest()->getParam('store');
00207 
00208         $storeModel = Mage::getSingleton('adminhtml/system_store');
00209         /* @var $storeModel Mage_Adminhtml_Model_System_Store */
00210 
00211         $url = Mage::getModel('adminhtml/url');
00212 
00213         $options = array();
00214         $options['default'] = array(
00215             'label'    => Mage::helper('adminhtml')->__('Default Config'),
00216             'url'      => $url->getUrl('*/*/*', array('section'=>$section)),
00217             'selected' => !$curWebsite && !$curStore,
00218             'style'    => 'background:#ccc; font-weight:bold;',
00219         );
00220 
00221         foreach ($storeModel->getWebsiteCollection() as $website) {
00222             $websiteShow = false;
00223             foreach ($storeModel->getGroupCollection() as $group) {
00224                 if ($group->getWebsiteId() != $website->getId()) {
00225                     continue;
00226                 }
00227                 $groupShow = false;
00228                 foreach ($storeModel->getStoreCollection() as $store) {
00229                     if ($store->getGroupId() != $group->getId()) {
00230                         continue;
00231                     }
00232                     if (!$websiteShow) {
00233                         $websiteShow = true;
00234                         $options['website_' . $website->getCode()] = array(
00235                             'label'    => $website->getName(),
00236                             'url'      => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode())),
00237                             'selected' => !$curStore && $curWebsite == $website->getCode(),
00238                             'style'    => 'padding-left:16px; background:#DDD; font-weight:bold;',
00239                         );
00240                     }
00241                     if (!$groupShow) {
00242                         $groupShow = true;
00243                         $options['group_' . $group->getId() . '_open'] = array(
00244                             'is_group'  => true,
00245                             'is_close'  => false,
00246                             'label'     => $group->getName(),
00247                             'style'     => 'padding-left:32px;'
00248                         );
00249                     }
00250                     $options['store_' . $store->getCode()] = array(
00251                         'label'    => $store->getName(),
00252                         'url'      => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode(), 'store'=>$store->getCode())),
00253                         'selected' => $curStore == $store->getCode(),
00254                         'style'    => '',
00255                     );
00256                 }
00257                 if ($groupShow) {
00258                     $options['group_' . $group->getId() . '_close'] = array(
00259                         'is_group'  => true,
00260                         'is_close'  => true,
00261                     );
00262                 }
00263             }
00264         }
00265 
00266         return $options;
00267     }

getTab ( code  ) 

Retrive tab

Parameters:
string $code
Returns:
Varien_Object

Definition at line 169 of file Tabs.php.

00170     {
00171         if(isset($this->_tabs[$code])) {
00172             return $this->_tabs[$code];
00173         }
00174 
00175         return null;
00176     }

getTabs (  ) 

Definition at line 191 of file Tabs.php.

00192     {
00193         return $this->_tabs;
00194     }

initTabs (  ) 

Enter description here...

Definition at line 72 of file Tabs.php.

00073     {
00074         $current = $this->getRequest()->getParam('section');
00075         $websiteCode = $this->getRequest()->getParam('website');
00076         $storeCode = $this->getRequest()->getParam('store');
00077 
00078         $url = Mage::getModel('adminhtml/url');
00079 
00080         $configFields = Mage::getSingleton('adminhtml/config');
00081         $sections = $configFields->getSections($current);
00082         $tabs     = (array)$configFields->getTabs()->children();
00083        
00084 
00085         $sections = (array)$sections;
00086 
00087         usort($sections, array($this, '_sort'));
00088         usort($tabs, array($this, '_sort'));
00089 
00090         foreach ($tabs as $tab) {
00091             $helperName = $configFields->getAttributeModule($tab);
00092             $label = Mage::helper($helperName)->__((string)$tab->label);
00093 
00094             $this->addTab($tab->getName(), array(
00095                 'label' => $label,
00096                 'class' => (string) $tab->class
00097             ));
00098         }
00099 
00100 
00101         foreach ($sections as $section) {
00102 
00103             $hasChildren = $configFields->hasChildren($section, $websiteCode, $storeCode);
00104 
00105             //$code = $section->getPath();
00106             $code = $section->getName();
00107 
00108             $sectionAllowed = $this->checkSectionPermissions($code);
00109             if ((empty($current) && $sectionAllowed)) {
00110 
00111                 $current = $code;
00112                 $this->getRequest()->setParam('section', $current);
00113             }
00114 
00115             $helperName = $configFields->getAttributeModule($section);
00116 
00117             $label = Mage::helper($helperName)->__((string)$section->label);
00118 
00119             if ($code == $current) {
00120                 if (!$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store')) {
00121                     $this->_addBreadcrumb($label);
00122                 } else {
00123                     $this->_addBreadcrumb($label, '', $url->getUrl('*/*/*', array('section'=>$code)));
00124                 }
00125             }
00126             if ( $sectionAllowed && $hasChildren) {
00127                 $this->addSection($code, (string)$section->tab, array(
00128                     'class'     => (string)$section->class,
00129                     'label'     => $label,
00130                     'url'       => $url->getUrl('*/*/*', array('_current'=>true, 'section'=>$code)),
00131                 ));
00132             }
00133 
00134             if ($code == $current) {
00135                 $this->setActiveTab($section->tab);
00136                 $this->setActiveSection($code);
00137             }
00138         }
00139 
00140         /*
00141          * Set last sections
00142          */
00143         foreach ($this->getTabs() as $tab) {
00144             $sections = $tab->getSections();
00145             if ($sections) {
00146                 $sections->getLastItem()->setIsLast(true);
00147             }
00148         }
00149 
00150         Mage::helper('adminhtml')->addPageHelpUrl($current.'/');
00151 
00152         return $this;
00153     }


Member Data Documentation

$_tabs [protected]

Definition at line 43 of file Tabs.php.


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

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