/** * * @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); }
/** * Возвращает данные для заполнения пользователя */ public function generateUserData() { // Получаем необходимые парметры из запроса $langs = Zend_Controller_front::getInstance()->getRequest()->getHeader('Accept-Language'); $languageCode = substr($langs, 0, 2); $data = array('password' => $this->generatePassword(Users_Service_Adapter_OpenId::PASSWORD_LENGTH), 'email' => $this->generateEmail(), 'role' => User::ROLE_REGISTERED, 'balance' => 0, 'sex_id' => 14, 'currency_id' => 1, 'language_code' => $languageCode, 'created_at' => date('Y-m-d H:i:s', time()), 'username' => $this->generateUsername(), 'name' => $this->generateUsername(), 'openid_identity' => $this->_broker->getIdentityUrl()); return $data; }
/** * * @param string $pPanel = 'main' * @return Zend_Navigation */ public function pages($pPanel = 'main') { $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) { if (!$module->active) { continue; } $module->load_menus(); $module_names[] = '"' . $module->folder . '"'; } foreach ($this->find(array('panel' => $pPanel, 'parent' => 0), 'sort_by') as $menu) { if ($new_page = $menu->page($active_module, $active_controller)) { $pages[] = $new_page; } } $router = Zend_Controller_Front::getInstance()->getRouter(); $fake_route = new Zend_Controller_Request_Http(); $fake_route->setRequestUri('/'); $router->route($fake_route); return new Zend_Navigation($pages); }