Пример #1
0
 /**
  *
  * @return <type>
  */
 public function pages($pModule)
 {
     $pages = array();
     $req = Zend_Controller_front::getInstance()->getRequest();
     $active_module = $req->getModuleName();
     $active_controller = $req->getControllerName();
     $sql = array('(required = 1) OR (active = 1)', 'sort_by');
     $modules = Administer_Model_Modules::getInstance()->find_from_sql($sql, TRUE, FALSE);
     foreach ($modules as $module) {
         $module->menu();
         $module_names[] = '"' . $module->folder . '"';
     }
     $module_is_active = sprintf(' (module = "%s") ', $active_module);
     $mm = Model_Menu::getInstance();
     $sql = sprintf('(module in (%s)) AND (parent = 0)', join(',', $module_names));
     //// at this point have selected all the menus of this module
     $sql .= sprintf(' AND ((if_module = 0) OR (%s)) ', $module_is_active);
     // if the menu only viewable in the context of the current menu,
     // require the module to be current
     error_log(__METHOD__ . ': menu sql = ' . $sql);
     foreach ($mm->find_from_sql(array($sql, array('sort_by', 'label'))) as $menu) {
         $new_pages = $menu->pages();
         $pages = array_merge($pages, $new_pages);
     }
     return new Zend_Navigation($pages);
 }
Пример #2
0
 /**
  *
  * @return void
  */
 public function _parent_menu($panel, $parent = NULL, $pDepth = 0)
 {
     $out = array();
     if ($parent) {
         $mt = new Model_Menu($parent);
         $found = $mt->children();
     } else {
         $mt = Model_Menu::getInstance();
         $params = array('parent' => 0, 'panel' => $panel);
         $found = $mt->find($params, 'sort_by');
     }
     foreach ($found as $m) {
         $out[$m->identity() . '_' . $panel] = $this->_pm_prefix($pDepth) . $m->label;
         foreach ($this->_parent_menu($panel, $m->identity(), $pDepth + 1) as $k => $v) {
             $out[$k] = $v;
         }
     }
     return $out;
 }
 public function menuexportexecuteAction()
 {
     $root_module = $this->_getParam("root_module", NULL);
     $params = array('parent' => 0);
     if (strcasecmp($root_module, 'all')) {
         $params['created_by_module'] = $root_module;
     }
     $menus = Model_Menu::getInstance()->find($params, array('panel', 'sort_by'));
     $out = array();
     foreach ($menus as $i => $menu) {
         $md = $menu->toArray();
         $data = $this->_menu_ini($menu);
         $data['sort_by'] = $i + 1;
         $out[$menu->name] = $data;
     }
     $config = new Zend_Config(array('menu' => $out));
     error_log(__METHOD__ . ': data = ' . print_r($config, 1));
     $ini = new Zupal_Config_Writer_Ini(array('config' => $config));
     $this->view->data = $ini->__toString();
 }
Пример #4
0
 /**
  *
  * @return void
  */
 public function load_menus($pReload = FALSE)
 {
     if ($pReload || !$this->menu_loaded) {
         if ($config = $this->menu_data()) {
             $mm = Model_Menu::getInstance();
             $crit = $mm->table()->getAdapter()->quoteInto('created_by_module = ?', $this->folder);
             $mm->table()->delete($crit);
             $data = $config->toArray();
             $mm->add_menus($data, $this->folder);
         }
         $this->menu_loaded = TRUE;
         $this->save();
     }
 }
Пример #5
0
 /**
  *
  * @return Zend_Navigation
  */
 public function pages($pPanel = 'main')
 {
     return Model_Menu::getInstance()->pages($pPanel);
 }