Beispiel #1
0
 /**
  * TODO
  */
 public static function load($data, $parentKey = 'parent_id', $childKey = 'children')
 {
     self::$_data = $data;
     self::$_parentKey = $parentKey;
     self::$_childKey = $childKey;
 }
Beispiel #2
0
 /**
  * Displays an edit page form.
  *
  * Route: admin/pages/edit/:num
  *
  * @param int $id The id of the page to edit
  */
 public static function edit($id)
 {
     if (isset($_POST['update_page']) && Html::form()->validate()) {
         $status = Page::page()->where('id', '=', $id)->update(array('page_id' => $_POST['page_id'], 'title' => $_POST['title'], 'slug' => $_POST['slug'], 'body' => $_POST['body']));
         if ($status) {
             Message::ok('Page updated successfully.');
         } else {
             Message::error('Error updating page. Please try again.');
         }
     }
     $page = Page::page()->find($id);
     // Either get all pages or only current users pages based on permission
     if (!User::current()->hasPermission('page.manage')) {
         $pages = Page::page()->where('user_id', '=', User::current())->andWhere('id', '!=', $id)->all();
     } else {
         $pages = Page::page()->where('id', '!=', $id)->all();
     }
     MultiArray::load($pages, 'page_id');
     $indentedPages = MultiArray::indent();
     $arrPages = array(0 => '-');
     foreach ($indentedPages as $p) {
         $arrPages[$p->id] = $p->indent . $p->title;
     }
     $fields[] = array('fields' => array('page_id' => array('title' => 'Parent', 'type' => 'select', 'options' => $arrPages, 'selected' => $page->page_id), 'title' => array('title' => 'Title', 'type' => 'text', 'default_value' => $page->title, 'validate' => array('required')), 'slug' => array('title' => 'Slug', 'type' => 'text', 'default_value' => $page->slug, 'validate' => array('required')), 'body' => array('title' => 'Body', 'type' => 'textarea', 'default_value' => $page->body, 'attributes' => array('class' => 'tinymce')), 'update_page' => array('value' => 'Update Page', 'type' => 'submit')));
     return array(array('title' => 'Edit Page', 'content' => Html::form()->build($fields)));
 }