예제 #1
0
 /**
  * Display a list of all categories
  *
  * @return  void
  */
 public function displayTask()
 {
     // Get filters
     $this->view->filters = array('state' => -1, 'access' => -1, 'object_type' => Request::getState($this->_option . '.' . $this->_controller . '.object_type', 'object_type', ''), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'state' => Request::getState($this->_option . '.' . $this->_controller . '.state', 'state', '-1'), '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'));
     $obj = new Archive();
     // Get record count
     $this->view->filters['count'] = true;
     $this->view->total = $obj->collections($this->view->filters);
     // Get records
     $this->view->filters['count'] = false;
     $this->view->rows = $obj->collections($this->view->filters);
     // Output the HTML
     $this->view->display();
 }
예제 #2
0
 /**
  * Display a list of collections
  *
  * @apiMethod GET
  * @apiUri    /collections/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":       "created",
  * 		"allowedValues": "created, ordering"
  * }
  * @apiParameter {
  * 		"name":          "sort_Dir",
  * 		"description":   "Direction to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       "desc",
  * 		"allowedValues": "asc, desc"
  * }
  * @return  void
  */
 public function listTask()
 {
     $model = new Archive();
     $filters = array('limit' => Request::getInt('limit', 25), 'start' => Request::getInt('limitstart', 0), 'search' => Request::getVar('search', ''), 'state' => 1, 'sort_Dir' => strtoupper(Request::getWord('sortDir', 'DESC')), 'is_default' => 0, 'access' => 0, 'count' => true);
     $response = new stdClass();
     $response->collections = array();
     $response->total = $model->collections($filters);
     if ($response->total) {
         $base = rtrim(Request::base(), '/');
         $filters['count'] = false;
         foreach ($model->collections($filters) as $i => $entry) {
             $collection = Collection::getInstance($entry->item()->get('object_id'));
             $obj = $collection->toObject();
             $obj->created_by = new stdClass();
             $obj->created_by->id = $collection->get('created_by');
             $obj->created_by->name = $collection->creator()->get('name');
             $obj->url = str_replace('/api', '', $base . '/' . ltrim(Route::url($collection->link()), '/'));
             $response->collections[] = $obj;
         }
     }
     $this->send($response);
 }