Example #1
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();
 }
Example #2
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);
 }
Example #3
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);
 }