public function add() { if (Page::already($_POST['baseUrl'], $_POST['uri'], $_POST['language'])) { throw new Exception('PAGE ALREADY EXISTS', 409); } $page = new Page(); $page->setBaseUrl($_POST['baseUrl']); $page->setUri($_POST['uri']); $page->setLanguage($_POST['language']); if (array_key_exists('content', $_POST) && !empty($_POST['content'])) { $page->setContent($_POST['content']); } $page->setModele($_POST['modele']); $page->setTitle($_POST['title']); if (array_key_exists('languageParentId', $_POST)) { $page->setLanguageParentId($_POST['languageParentId']); } if (array_key_exists('ajax', $_POST)) { $page->setAjax($_POST['ajax']); } if (array_key_exists('published', $_POST)) { $page->setPublished($_POST['published']); } if (array_key_exists('metas', $_POST)) { $page->setMetas($_POST['metas']); } if (array_key_exists('css', $_POST)) { $page->setCss($_POST['css']); } if (array_key_exists('js', $_POST)) { $page->setJs($_POST['js']); } if (array_key_exists('action', $_POST)) { $page->setAction($_POST['action']); } if (array_key_exists('method', $_POST)) { $page->setMethod($_POST['method']); } if (array_key_exists('priority', $_POST)) { $page->setPriority($_POST['priority']); } if (array_key_exists('datas', $_POST)) { $page->setDatas($_POST['datas']); } if (!array_key_exists('blockIds', $_POST)) { $blkIds = array(); foreach ($_POST['blockIds'] as $blk) { if (array_key_exists('id', $blk) && MongoId::isValid($blk['id'])) { $blkIds[] = $blk['id']; } } $this->page->setBlockIds($blkIds); } $page->save(); return array('pageId' => $page->getId()); }
$content = isset($_POST["content"]) ? $_POST["content"] : null; if (empty($content)) { Message::register(new Message(Message::DANGER, i18n(array("en" => "content is required.", "zh" => "请填写content")))); $error_flag = true; } // validation for $published $published = isset($_POST["published"]) ? 1 : 0; /// proceed submission // proceed for $uri $object->setUri($uri); // proceed for $title $object->setTitle($title); // proceed for $content $object->setContent($content); // proceed for $published $object->setPublished($published); if ($error_flag == false) { if ($object->save()) { Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Record saved", "zh" => "记录保存成功")))); HTML::forwardBackToReferer(); } else { Message::register(new Message(Message::DANGER, i18n(array("en" => "Record failed to save", "zh" => "记录保存失败")))); } } } $html = new HTML(); $html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Create Page', 'zh' => 'Create 基本页面')))); $html->output('<div id="wrapper">'); $html->renderOut('core/backend/header'); $html->renderOut('page/backend/page_create', array('object' => $object)); $html->output('</div>');