Exemple #1
0
 /**
  * Create an item entry for a wiki page
  *
  * @param   integer  $id  Optional ID to use
  * @return  boolean
  */
 public function make($id = null)
 {
     if ($this->exists()) {
         return true;
     }
     include_once PATH_CORE . DS . 'components' . DS . 'com_wiki' . DS . 'models' . DS . 'book.php';
     $page = null;
     if (!$id) {
         $group = Request::getVar('cn', '');
         $book = new Book($group ? $group : '__site__');
         $page = $book->page();
         $id = $page->get('id');
     }
     $this->_tbl->loadType($id, $this->_type);
     if ($this->exists()) {
         return true;
     }
     if (!$page) {
         $page = new Page($id);
     }
     if (!$page->exists()) {
         $this->setError(Lang::txt('Wiki page not found.'));
         return false;
     }
     $this->set('type', $this->_type)->set('object_id', $page->get('id'))->set('created', $page->get('created'))->set('created_by', $page->get('created_by'))->set('title', $page->get('title'))->set('description', $page->revision()->content('clean', 300))->set('url', Route::url($page->link()));
     if (!$this->store()) {
         return false;
     }
     return true;
 }
 /**
  * Delete a page
  *
  * @apiParameter {
  * 		"name":          "id",
  * 		"description":   "Page identifier",
  * 		"type":          "integer",
  * 		"required":      true,
  * 		"default":       0
  * }
  * @return  void
  */
 public function deleteTask()
 {
     $this->requiresAuthentication();
     $id = Request::getInt('id', 0);
     $record = new Page($id);
     if (!$record->exists()) {
         throw new Exception(Lang::txt('Specified page does not exist.'), 404);
     }
     if (!$record->delete()) {
         throw new Exception(Lang::txt('Failed to delete page.'), 500);
     }
     $this->send(null, 202);
 }