コード例 #1
0
ファイル: wiki.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * 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;
 }
コード例 #2
0
ファイル: wiki.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * 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) {
         $scope = 'site';
         $scope_id = 0;
         if ($group = Request::getVar('cn', '')) {
             $group = Group::getInstance($group);
             $scope = 'group';
             $scope_id = $group->get('gidNumber');
         }
         $book = new Book($scope, $scope_id);
         $page = $book->page();
         $id = $page->get('id');
     }
     $this->_tbl->loadType($id, $this->_type);
     if ($this->exists()) {
         return true;
     }
     if (!$page) {
         $page = Page::oneOrFail($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->title)->set('description', strip_tags($page->version->content($page)))->set('url', Route::url($page->link()));
     if (!$this->store()) {
         return false;
     }
     return true;
 }