function render() { //得到属性的值 $name = $this->_extract('name'); $catch_id = 'Dy_menu' . $name; //读取缓存 $rowSet = Q::cache($catch_id); //读取失败 if (!$rowSet) { $rowSet = Sysmenu::find()->order('parent_id ASC, order_pos ASC')->asArray()->getAll(); //写缓存 Q::writeCache($catch_id, $rowSet); } /** * 验证不能访问的菜单 */ $app = MyApp::instance(); foreach ($rowSet as $offset => $row) { if ($row['controller'] == '') { continue; } $udi = "{$row['controller']}/{$row['action']}"; //权限判断 if (!$app->authorizedUDI($app->currentUserRoles(), $udi)) { //删除没有权限访问的菜单 unset($rowSet[$offset]); } else { $args = array(); parse_str($row['args'], $args); $rowSet[$offset]['url'] = url($udi, $args); } } //数组转换成树 $menu = Helper_Array::toTree($rowSet, 'menu_id', 'parent_id', 'submenu'); // $mainMenu = & new Helper_Menu($menu) ; $mainMenu = new Helper_Menu($menu); $output = "var {$name} = "; $output .= $mainMenu->returnJsArray(true); $output .= ";\n"; echo <<<EOT <div id="mainMenuBar"></div> <link href="js/ThemeOffice/theme.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript" src="js/JSCookMenu.js"></script> <script language="javascript" type="text/javascript" src="js/ThemeOffice/theme.js"></script> <script language="javascript" type="text/javascript"> {{$output}} cmDraw ('mainMenuBar', myMenu, 'hbr', cmThemeOffice); </script> EOT; }
public function render() { $page = 'home'; $app = Config::get('app'); $policy = new Policy_LoggedIn($this->app); $logged_in = $policy->check(); $app->menu_items = Helper_Menu::processMenuItems($app->menu_items, $page, $logged_in); $user = null; $formatted_weights = array(); $settingsVals = array(); $viewOptions = array(); if ($logged_in) { $userid = $policy->getData(); $user_mapper = new Mapper_User(); $user = $user_mapper->getUserById($userid); $settings_mapper = new Mapper_Settings(); $settingsVals = $settings_mapper->getFilteredSettingsByUserid($userid); $defaultView = 30.5; if (isset($settingsVals['default_view'])) { $defaultView = $settingsVals['default_view']; } $viewOptions = array(0 => array('value' => 7, 'name' => '1 week'), 1 => array('value' => 30.5, 'name' => '1 month'), 2 => array('value' => 61, 'name' => '2 months'), 3 => array('value' => 91.5, 'name' => '3 months'), 4 => array('value' => 182.5, 'name' => '6 months'), 5 => array('value' => 365, 'name' => '1 year'), 6 => array('value' => 'ytd', 'name' => 'Year to date'), 7 => array('value' => 'all', 'name' => 'All data')); foreach ($viewOptions as &$option) { if ($option['value'] == $defaultView) { $option['selected'] = true; } } } return array('app' => $app, 'breadcrumb' => 'Home', 'error' => Helper_Message::getError(), 'logged_in' => $logged_in, 'user' => $user, 'user_settings' => $settingsVals, 'view_options' => $viewOptions); }
public function render() { $page = 'about'; $app = Config::get('app'); $policy = new Policy_LoggedIn($this->app); $userid = $policy->getData(); $app->menu_items = Helper_Menu::processMenuItems($app->menu_items, $page, $userid); return array('app' => $app, 'breadcrumb' => 'About'); }
public function render() { $page = 'login'; $app = Config::get('app'); $policy = new Policy_LoggedOut($this->app); $logged_in = $policy->getData(); $app->menu_items = Helper_Menu::processMenuItems($app->menu_items, $page, $logged_in); return array('app' => $app, 'breadcrumb' => 'Log in', 'error' => Helper_Message::getError(), 'username' => Helper_Message::getField('username')); }
public function render() { $page = 'tools'; $app = Config::get('app'); $policy = new Policy_LoggedIn($this->app); $userid = $policy->getData(); $app->menu_items = Helper_Menu::processMenuItems($app->menu_items, $page, $userid); return array('app' => $app, 'breadcrumb' => 'Tools', 'error' => Helper_Message::getError(), 'success' => Helper_Message::getSuccess()); }
public function render() { $page = 'settings'; $app = Config::get('app'); $policy = new Policy_LoggedIn($this->app); $userid = $policy->getData(); $app->menu_items = Helper_Menu::processMenuItems($app->menu_items, $page, $userid); $mapper = new Mapper_User(); $user = $mapper->getUserById($userid); return array('app' => $app, 'breadcrumb' => 'Account', 'user' => $user, 'error' => Helper_Message::getError(), 'success' => Helper_Message::getSuccess()); }
public function render() { $page = 'settings'; $app = Config::get('app'); $policy = new Policy_LoggedIn($this->app); $userid = $policy->getData(); $app->menu_items = Helper_Menu::processMenuItems($app->menu_items, $page, $userid); $userSettings = $app->user_settings; usort($userSettings, array('self', 'sortSettings')); $settings_mapper = new Mapper_Settings(); $settingsVals = $settings_mapper->getFilteredSettingsByUserid($userid); foreach ($userSettings as &$setting) { $setting['value'] = $settingsVals[$setting['name']]; } return array('app' => $app, 'breadcrumb' => 'Settings', 'user_settings' => $userSettings, 'error' => Helper_Message::getError(), 'success' => Helper_Message::getSuccess()); }
public function render() { $page = 'records'; $recordsPerPage = 10; $app = Config::get('app'); $policy = new Policy_LoggedIn($this->app); $userid = $policy->getData(); $app->menu_items = Helper_Menu::processMenuItems($app->menu_items, $page, $userid); $request = $this->app->request(); $page = trim($request->get('page')); if (!ctype_digit($page)) { $page = 1; } $weight_mapper = new Mapper_Weight(); $totalWeights = $weight_mapper->getWeightsCountForUser($userid); $weights = $weight_mapper->getPaginatedWeightsForUser($userid, $page, $recordsPerPage); $numPages = ceil($totalWeights / $recordsPerPage); if ($page > $numPages) { $page = 1; } $hasPrev = false; $hasNext = false; if ($numPages > 1) { if ($page > 1) { $hasPrev = true; } if ($page < $numPages) { $hasNext = true; } } $pagesArray = array(); for ($i = 1; $i <= $numPages; $i++) { $data = array('page' => $i, 'selected' => $i == $page ? true : false); $pagesArray[] = $data; } foreach ($weights as &$weight) { $weight['time'] = date('D F j, Y, g:i a', $weight['create_time']); $wVal = $weight['weight']; if (round($wVal) == $wVal) { $weight['weight'] = round($wVal); } } return array('app' => $app, 'breadcrumb' => 'Records', 'has_weights' => count($weights) > 0, 'weights' => $weights, 'pages' => $pagesArray, 'has_previous' => $hasPrev, 'has_next' => $hasNext, 'previous_val' => $page - 1, 'next_val' => $page + 1, 'total_pages' => $numPages, 'current_page' => $page); }