示例#1
0
 protected static function mapper(array $row, $alias = 'page')
 {
     $model = new \Rebond\Cms\Page\Model(false);
     if (isset($row[$alias . 'Id'])) {
         $model->setId($row[$alias . 'Id']);
     }
     if (isset($row[$alias . 'ParentId'])) {
         $model->setParentId($row[$alias . 'ParentId']);
         $model->setParent(\Rebond\Cms\Page\Data::join($row, $alias . '_parent'));
     }
     if (isset($row[$alias . 'TemplateId'])) {
         $model->setTemplateId($row[$alias . 'TemplateId']);
         $model->setTemplate(\Rebond\Cms\Template\Data::join($row, $alias . '_template'));
     }
     if (isset($row[$alias . 'LayoutId'])) {
         $model->setLayoutId($row[$alias . 'LayoutId']);
         $model->setLayout(\Rebond\Cms\Layout\Data::join($row, $alias . '_layout'));
     }
     if (isset($row[$alias . 'Title'])) {
         $model->setTitle($row[$alias . 'Title']);
     }
     if (isset($row[$alias . 'Css'])) {
         $model->setCss($row[$alias . 'Css']);
     }
     if (isset($row[$alias . 'Js'])) {
         $model->setJs($row[$alias . 'Js']);
     }
     if (isset($row[$alias . 'InNavHeader'])) {
         $model->setInNavHeader($row[$alias . 'InNavHeader']);
     }
     if (isset($row[$alias . 'InNavSide'])) {
         $model->setInNavSide($row[$alias . 'InNavSide']);
     }
     if (isset($row[$alias . 'InSitemap'])) {
         $model->setInSitemap($row[$alias . 'InSitemap']);
     }
     if (isset($row[$alias . 'InBreadcrumb'])) {
         $model->setInBreadcrumb($row[$alias . 'InBreadcrumb']);
     }
     if (isset($row[$alias . 'InNavFooter'])) {
         $model->setInNavFooter($row[$alias . 'InNavFooter']);
     }
     if (isset($row[$alias . 'FriendlyUrlPath'])) {
         $model->setFriendlyUrlPath($row[$alias . 'FriendlyUrlPath']);
     }
     if (isset($row[$alias . 'FriendlyUrl'])) {
         $model->setFriendlyUrl($row[$alias . 'FriendlyUrl']);
     }
     if (isset($row[$alias . 'Redirect'])) {
         $model->setRedirect($row[$alias . 'Redirect']);
     }
     if (isset($row[$alias . 'Class'])) {
         $model->setClass($row[$alias . 'Class']);
     }
     if (isset($row[$alias . 'Permission'])) {
         $model->setPermission($row[$alias . 'Permission']);
     }
     if (isset($row[$alias . 'DisplayOrder'])) {
         $model->setDisplayOrder($row[$alias . 'DisplayOrder']);
     }
     if (isset($row[$alias . 'Status'])) {
         $model->setStatus($row[$alias . 'Status']);
     }
     if (isset($row[$alias . 'CreatedDate'])) {
         $model->setCreatedDate($row[$alias . 'CreatedDate']);
     }
     if (isset($row[$alias . 'ModifiedDate'])) {
         $model->setModifiedDate($row[$alias . 'ModifiedDate']);
     }
     return $model;
 }
示例#2
0
 public function edit()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.page', true, '/page');
     // check
     $id = Converter::int('id');
     $pid = Converter::int('pid', 'get', 1);
     $page = \Rebond\Cms\Page\Data::loadById($id);
     if (!isset($page)) {
         $page = new \Rebond\Cms\Page\Model();
         $title = Lang::lang('newPage');
     } else {
         $title = Lang::lang('edit') . ' ' . $page->getTitle();
     }
     if ($page->getId() != 1 && $page->getParentId() == 1) {
         $page->setParentId($pid);
     }
     $form = new \Rebond\Cms\Page\Form($page);
     // action
     $save = Converter::string('save', 'post');
     if (isset($save)) {
         Auth::isAdminAuthorized($this->signedUser, 'admin.page.edit', true, '/page');
         if ($form->setFromPost()->validate()->isValid()) {
             // set new friendly url hidden
             $page->setFriendlyUrl(strtolower($page->getFriendlyUrl()));
             $fuh = \Rebond\Cms\Page\Data::fullFriendlyUrl($page->getParentId());
             $page->setFriendlyUrlPath($fuh);
             $page->save();
             // update children pages
             \Rebond\Cms\Page\Data::updateChildrenFriendlyUrl($page->getId(), $page->getFriendlyUrlPath(), $page->getFriendlyUrl());
             Session::adminSuccess('saved', '/page');
         } else {
             Session::set('adminError', $form->getValidation()->getMessage());
         }
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Template(Template::MODULE, ['cms', 'page']);
     $tplMain->set('title', $title);
     $tplMain->set('siteUrl', 'http://' . \Rebond\Config::getPath('siteUrl'));
     $tplMain->set('item', $form);
     // layout
     if (Auth::isAdminAuthorized($this->signedUser, 'admin.page.edit', false)) {
         $this->tplLayout->set('column1', $tplMain->render('editor'));
     } else {
         $this->tplLayout->set('column1', $tplMain->render('view'));
     }
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     $this->tplMaster->set('jsLauncher', 'page');
     return $this->tplMaster->render('tpl-default');
 }