public function testProperties() { $action = new MenuAction('Test', 'snippet:Test', 'some-icon'); $this->assertEquals('snippet:Test', $action->getRoute()); $this->assertNotNull($action->label); $this->assertNotNull($action->icon); }
function insertMenu(&$menus, $id, $menu) { $pos = strpos($id, '.'); if ($pos != false) { MenuAction::insertMenu($menus[substr($id, 0, $pos)]["children"], substr($id, $pos + 1), $menu); } else { $menus[$id] = $menu; } }
public function editAction() { $id = $this->request->getPost('id'); $this->view->setVar('Edit', Menus::findFirst(array('id=' . $id))); $this->view->setVar('MLang', $this->inc->getLang('menus')); $this->view->setVar('Action', MenuAction::find()); $this->view->setVar('Lang', $this->inc->getLang('system/sys_menu')); $this->view->pick("system/menus/edit"); }
public function permAction() { $Lang = $this->inc->getLang('menus'); $html = ''; $permArr = $this->splitPerm($this->request->getPost('perm')); $actionM = MenuAction::find(); $menu1 = Menus::find('fid=0'); foreach ($menu1 as $m1) { $ck = isset($permArr[$m1->id]) ? 'checked' : ''; $title1 = $Lang->_($m1->title); $html .= '<div id="oneMenuPerm" class="perm">'; $html .= ' <span class="text1"><input type="checkbox" value="' . $m1->id . '" ' . $ck . ' /></span>'; $html .= ' <span>[<a href="#">-</a>] ' . $title1 . '</span>'; $html .= '</div>'; $menu2 = Menus::find('fid=' . $m1->id); foreach ($menu2 as $m2) { $ck = isset($permArr[$m2->id]) ? 'checked' : ''; $title2 = $Lang->_($m2->title); $html .= '<div id="twoMenuPerm" class="perm">'; $html .= ' <span class="text2"><input type="checkbox" value="' . $m2->id . '" ' . $ck . ' /></span>'; $html .= ' <span>[<a href="#">-</a>] ' . $title2 . '</span>'; $html .= '</div>'; $menu3 = Menus::find('fid=' . $m2->id); foreach ($menu3 as $m3) { $ck = isset($permArr[$m3->id]) ? 'checked' : ''; $title3 = $Lang->_($m3->title); $html .= '<div id="threeMenuPerm" class="perm perm_action">'; $html .= ' <span class="text3"><input type="checkbox" name="threeMenuPerm" value="' . $m3->id . '" ' . $ck . ' /></span>'; $html .= ' <span>[<a href="#">-</a>] ' . $title3 . '</span>'; $html .= ' <span id="actionPerm_' . $m3->id . '"> ( '; foreach ($actionM as $val) { if (intval($m3->perm) & intval($val->perm)) { $ck = @$permArr[$m3->id] & intval($val->perm) ? 'checked' : ''; $name = $Lang->_($val->name); $html .= '<span><input type="checkbox" value="' . $val->perm . '" ' . $ck . ' /></span><span class="text">' . $name . '</span>'; } } $html .= ')</span>'; $html .= '</div>'; } } } $this->view->setVar('menusHtml', $html); $this->view->pick("system/admin/perm"); }
private function actionMenus($perm = '', $Cname = '', $Lang = '') { $Action = MenuAction::find(array('order' => 'id')); $data = ''; foreach ($Action as $val) { if (intval($perm) & intval($val->perm)) { $data[] = array('name' => $Lang->_($val->name), 'ico' => $val->ico); } } return $data; }
public function menu_removeSub() { if ($this->inGroup(63, true)) { require dirname(__FILE__) . '/resources/menu.action.php'; $menu = new MenuAction($this->parent); return $menu->remove(); } else { return new ActionResult($this, '/admin/core/menu_view', 0, 'You are not allowed to do that', B_T_FAIL); } }
public function DataAction($type = 'save') { if ($this->request->isPost()) { // Add if ($type == 'add') { $post = $this->request->getPost(); $data = new MenuAction(); if ($data->save($post)) { $this->response->redirect('Result/suc/SysMenusAction'); } else { $this->response->redirect('Result/err'); } // Edit } elseif ($type == 'edit') { $id = $this->request->getPost('id'); $data = MenuAction::findFirst(array('id=:id:', 'bind' => array('id' => $id))); if ($data->save($this->request->getPost(), array('name', 'perm', 'ico'))) { $this->response->redirect('Result/suc/SysMenusAction'); } else { $this->response->redirect('Result/err'); } // Delete } elseif ($type == 'delete') { $id = $this->request->getPost('id'); $arr = json_decode($id); foreach ($arr as $val) { $data = MenuAction::findFirst('id=' . $val); if ($data->delete() == FALSE) { $this->response->redirect('Result/err'); } } $this->response->redirect('Result/suc/SysMenusAction'); } } else { return FALSE; } }