public function save($menuID, $language, $title, $entryID, $data) { $menu = Menu::get($menuID); if ($menu == null) { $this->error(t('Menu not found')); $this->redirect('admin', 'menu', $language); return; } $entry = new MenuEntry; $entry->menuID = $menuID; $entry->title = $title; $entry->data = $data; $entry->entryID = $entryID; $entry->language = $language; try { $entry->save(); $this->notice(t('Menu entry added')); if ($language == I18n::getLanguage()) { $this->redirect('admin', 'menu', 'edit', $menuID); } else { $this->redirect('admin', 'menu', 'edit', $menuID, $language); } } catch (ValidationException $e) { $this->menu = $menu; $this->adminlanguage = $language; $this->providerActionCombos = Menu::providerActionCombos($language); $this->newEntry = $entry; $this->error(t('Entry was not saved')); $this->render('edit'); } }
public function display() { SessionCache::clear(); $template = new Template(); $template->load("menu_edit"); if (isset($_POST['add'])) { if (trim($_POST['newtitle']) != "") { if (trim($_POST['newurl']) != "") { $entry = new MenuEntry(); $entry->menu = $_GET['menu']; $entry->title = $_POST['newtitle']; $entry->type = $_POST['type']; if ($entry->type == 0) { $entry->href = $_POST['newPage']; } else { if ($entry->type == 1) { $entry->href = $_POST['newurl']; } else { $entry->href = $_POST['newMenu']; } } $res = $entry->save(); if ($res) { $template->assign_var("MESSAGE", Language::DirectTranslate("ENTRY_ADDED")); } else { $template->assign_var("MESSAGE", Language::DirectTranslate("ENTRY_NOT_ADDED")); } Cache::clear("menu"); } else { $template->assign_var("MESSAGE", Language::DirectTranslate("ENTER_LINK_TARGET")); } } else { $template->assign_var("MESSAGE", Language::DirectTranslate("ENTER_LINK_TITLE")); } } else { if (isset($_POST['save'])) { foreach ($_POST as $param => $value) { if (strlen($param) >= 6) { if (substr($param, -5, 5) == "_href") { $entries[substr($param, 0, -5)]['href'] = $value; } else { if (strlen($param) >= 7 && substr($param, -6, 6) == "_title") { $entries[substr($param, 0, -6)]['title'] = $value; } else { if (substr($param, -5, 5) == "_type") { $entries[substr($param, 0, -5)]['type'] = $value; } } } } } foreach ($entries as $id => $params) { $entry = new MenuEntry(); $entry->id = $id; $entry->menu = $_GET['menu']; $entry->title = $params['title']; $entry->href = $params['href']; $entry->type = $params['type']; $entry->save(); } } else { if (isset($_GET['delete'])) { Menu::deleteEntry(DataBase::Current()->EscapeString($_GET['menu']), DataBase::Current()->EscapeString($_GET['delete'])); } else { if (isset($_GET['moveup'])) { Menu::changePositions($_GET['menu'], $_GET['moveup'], $_GET['moveup'] - 1); } else { if (isset($_GET['movedown'])) { Menu::changePositions($_GET['menu'], $_GET['movedown'], $_GET['movedown'] + 1); } } } } } if (isset($_GET['menu'])) { $template->assign_var("URL", $this->page->getUrl("menu=" . urlencode($_GET['menu']))); $template->assign_var("EDITABLEMENU", Menu::getEditableCode(DataBase::Current()->EscapeString($_GET['menu']))); } else { $template->assign_var("URL", ""); $template->assign_var("EDITABLEMENU", ""); } $selector = new MenueSelector(); $selector->name = 'newMenu'; $selector->value = -1; $selector->style = 'width:200px;position:relative;left:-210px;visibility:hidden'; $template->assign_var("MENUSELECTOR", $selector->getCode()); $selector = new PageSelector(); $selector->name = 'newPage'; $selector->value = -1; $selector->style = 'width:200px;position:relative;left:-415px;'; $template->assign_var("PAGESELECTOR", $selector->getCode()); $template->assign_var("MESSAGE", ""); $template->output(); }
public function testCreateProviderDoesNotExist() { $entry = new MenuEntry; $entry->menuID = 'main'; $entry->language = 'en'; $entry->title = 'metitle'; $entry->entryID = 'NoProvider/action'; try { $entry->save(); $this->fail('Exception expected'); } catch (ValidationException $e) { $this->assertEquals('Provider not found', $entry->entryID_error); } }
<?php /* * ChangePassword - Installationsscript * Copyright Justin Künzel * * Package changepassword */ Language::ClearCache(); //Seiten-Typ anlegen DataBase::Current()->Execute("INSERT INTO `{'dbprefix'}pagetypes` (\n `id`, `class`, `name`\n ) VALUES (\n NULL, 'Plugin_ChangePassword_Page', '{LANG:PLUGIN_CHANGEPASSWORD_CHANGEPASSWORD}'\n ); "); $id = Page::create("admin/changepassword", "Plugin_ChangePassword_Page", "{LANG:PLUGIN_CHANGEPASSWORD_CHANGEPASSWORD}"); $menuEntry = new MenuEntry(); $menuEntry->menu = 4; $menuEntry->title = "{LANG:PLUGIN_CHANGEPASSWORD_CHANGEPASSWORD}"; $menuEntry->href = $id; $menuEntry->type = 0; $menuEntry->save();