Beispiel #1
0
 /**
  * Constructor
  *
  * @param   string   $scope
  * @param   string   $group_cn
  * @param   integer  $project_id
  * @return  void
  */
 public function __construct($scope = 'project', $group_cn = '', $project_id = 0)
 {
     $this->_db = \App::get('db');
     $this->_scope = $scope;
     $this->_project_id = $project_id;
     parent::__construct($scope);
 }
Beispiel #2
0
 /**
  * Constructor
  *
  * @param   string $scope
  * @return  void
  */
 public function __construct($scope = '__site__', $group_cn = '', $project_id = 0)
 {
     $this->_db = \App::get('db');
     $this->_scope = $scope;
     $this->_tbl = new \Components\Wiki\Tables\Page($this->_db);
     $this->_group_cn = $group_cn;
     $this->_project_id = $project_id;
     parent::__construct($scope);
 }
Beispiel #3
0
 /**
  * Display all pages in the wiki(s)
  *
  * @return  void
  */
 public function displayTask()
 {
     $this->view->filters = array('authorized' => true, 'limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'id'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), 'search' => Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''), 'namespace' => Request::getState($this->_option . '.' . $this->_controller . '.namespace', 'namespace', ''), 'group' => Request::getState($this->_option . '.' . $this->_controller . '.group', 'group', ''), 'state' => array(0, 1, 2));
     $this->view->filters['sortby'] = $this->view->filters['sort'] . ' ' . $this->view->filters['sort_Dir'];
     // In case limit has been changed, adjust limitstart accordingly
     $this->view->filters['start'] = $this->view->filters['limit'] != 0 ? floor($this->view->filters['start'] / $this->view->filters['limit']) * $this->view->filters['limit'] : 0;
     $p = new Book();
     // Get record count
     $this->view->total = $p->pages('count', $this->view->filters);
     // Get records
     $this->view->rows = $p->pages('list', $this->view->filters);
     $this->view->groups = $p->groups();
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output the HTML
     $this->view->display();
 }
Beispiel #4
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;
 }
Beispiel #5
0
 /**
  * Display a list of pages
  *
  * @apiMethod GET
  * @apiUri    /wiki/list
  * @apiParameter {
  * 		"name":          "limit",
  * 		"description":   "Number of result to return.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       25
  * }
  * @apiParameter {
  * 		"name":          "start",
  * 		"description":   "Number of where to start returning results.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       0
  * }
  * @apiParameter {
  * 		"name":          "search",
  * 		"description":   "A word or phrase to search for.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       ""
  * }
  * @apiParameter {
  * 		"name":          "sort",
  * 		"description":   "Field to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  *      "default":       "title",
  * 		"allowedValues": "created, id, title"
  * }
  * @apiParameter {
  * 		"name":          "sort_Dir",
  * 		"description":   "Direction to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       "asc",
  * 		"allowedValues": "asc, desc"
  * }
  * @return  void
  */
 public function listTask()
 {
     $group = Request::getVar('group', '');
     $book = new Book($group ? $group : '__site__');
     $filters = array('limit' => Request::getInt('limit', 25), 'start' => Request::getInt('limitstart', 0), 'search' => Request::getVar('search', ''), 'sort' => Request::getWord('sort', 'title'), 'sort_Dir' => strtoupper(Request::getWord('sort_Dir', 'ASC')), 'state' => array(0, 1), 'group' => Request::getVar('group_cn', ''));
     $filters['sortby'] = $filters['sort'] . ' ' . $filters['sort_Dir'];
     $response = new stdClass();
     $response->pages = array();
     $response->total = $book->pages('count', $filters);
     if ($response->total) {
         $base = rtrim(Request::base(), '/');
         foreach ($book->pages('list', $filters) as $i => $entry) {
             $obj = new stdClass();
             $obj->id = $entry->get('id');
             $obj->title = $entry->get('title');
             $obj->name = $entry->get('name');
             $obj->scope = $entry->get('scope');
             $obj->created = $entry->get('created');
             $obj->created_by = $entry->get('created_by');
             $obj->uri = str_replace('/api', '', $base . '/' . ltrim(Route::url($entry->link()), '/'));
             $obj->revisions = $entry->revisions('count');
             $response->pages[] = $obj;
         }
     }
     $this->send($response);
 }
Beispiel #6
0
 /**
  * Display a list of pages
  *
  * @apiMethod GET
  * @apiUri    /wiki/list
  * @apiParameter {
  * 		"name":          "limit",
  * 		"description":   "Number of result to return.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       25
  * }
  * @apiParameter {
  * 		"name":          "start",
  * 		"description":   "Number of where to start returning results.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       0
  * }
  * @apiParameter {
  * 		"name":          "search",
  * 		"description":   "A word or phrase to search for.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       ""
  * }
  * @apiParameter {
  * 		"name":          "sort",
  * 		"description":   "Field to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  *      "default":       "title",
  * 		"allowedValues": "created, id, title"
  * }
  * @apiParameter {
  * 		"name":          "sort_Dir",
  * 		"description":   "Direction to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       "asc",
  * 		"allowedValues": "asc, desc"
  * }
  * @apiParameter {
  * 		"name":        "scope",
  * 		"description": "Page scope",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     "site"
  * }
  * @apiParameter {
  * 		"name":        "scope_id",
  * 		"description": "Page scope ID",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @return  void
  */
 public function listTask()
 {
     $filters = array('limit' => Request::getInt('limit', 25), 'start' => Request::getInt('limitstart', 0), 'search' => Request::getVar('search', ''), 'sort' => Request::getWord('sort', 'title'), 'sort_Dir' => strtoupper(Request::getWord('sort_Dir', 'ASC')), 'state' => array(Page::STATE_PUBLISHED), 'scope' => Request::getVar('scope', 'site'), 'scope_id' => Request::getInt('scope_id', 0));
     $book = new Book($filters['scope'], $filters['scope_id']);
     $response = new stdClass();
     $response->pages = array();
     $response->total = $book->pages($filters)->count();
     if ($response->total) {
         $base = rtrim(Request::base(), '/');
         $pages = $book->pages($filters)->order($filters['sort'], $filters['sort_Dir'])->rows();
         foreach ($pages as $i => $entry) {
             $obj = $entry->toObject();
             $obj->url = str_replace('/api', '', $base . '/' . ltrim(Route::url($entry->link()), '/'));
             $obj->revisions = $entry->versions()->whereEquals('approved', 1)->count();
             $response->pages[] = $obj;
         }
     }
     $this->send($response);
 }
Beispiel #7
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) {
         $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;
 }