Example #1
0
 /**
  * Prepare options for Manage select
  *
  * @param boolean $all
  * @param string $excludeScopes
  * @return array
  */
 protected function _prepareOptions($all = false, $excludeScopes)
 {
     $storeStructure = Mage::getSingleton('adminhtml/system_store')->getStoresStructure($all);
     $nonEscapableNbspChar = html_entity_decode(' ', ENT_NOQUOTES, 'UTF-8');
     $options = array();
     $cmsHierarchyScopes = new Varien_Object();
     $cmsHierarchyScopes->setStoreStructure($storeStructure);
     $cmsHierarchyScopes->setExclude($excludeScopes);
     Mage::dispatchEvent('cms_hierarchy_manage_prepare_form', array('scopes' => $cmsHierarchyScopes));
     $excludeScopes = $cmsHierarchyScopes->getExclude();
     foreach ($storeStructure as $website) {
         $value = Enterprise_Cms_Helper_Hierarchy::SCOPE_PREFIX_WEBSITE . $website['value'];
         if (isset($website['children'])) {
             $website['value'] = in_array($value, $excludeScopes) ? array() : $value;
             $options[] = array('label' => $website['label'], 'value' => $website['value'], 'style' => 'border-bottom: none; font-weight: bold;');
             foreach ($website['children'] as $store) {
                 if (isset($store['children']) && !in_array($store['value'], $excludeScopes)) {
                     $storeViewOptions = array();
                     foreach ($store['children'] as $storeView) {
                         $storeView['value'] = Enterprise_Cms_Helper_Hierarchy::SCOPE_PREFIX_STORE . $storeView['value'];
                         if (!in_array($storeView['value'], $excludeScopes)) {
                             $storeView['label'] = str_repeat($nonEscapableNbspChar, 4) . $storeView['label'];
                             $storeViewOptions[] = $storeView;
                         }
                     }
                     if ($storeViewOptions) {
                         $options[] = array('label' => str_repeat($nonEscapableNbspChar, 4) . $store['label'], 'value' => $storeViewOptions);
                     }
                 }
             }
         } elseif ($website['value'] == Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID) {
             $website['value'] = in_array($website['value'], $excludeScopes) ? array() : Enterprise_Cms_Helper_Hierarchy::SCOPE_PREFIX_STORE . Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID;
             $options[] = array('label' => $website['label'], 'value' => $website['value']);
         }
     }
     return $options;
 }