/** * List all tags * * @return void */ public function displayTask() { // Incoming $this->view->filters = array('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'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'by' => Request::getState($this->_option . '.' . $this->_controller . '.by', 'filterby', 'all'), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'raw_tag'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC')); // 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; $t = new Cloud(); // Record count $this->view->total = $t->tags('count', $this->view->filters); $this->view->filters['limit'] = $this->view->filters['limit'] == 0 ? 'all' : $this->view->filters['limit']; // Get records $this->view->rows = $t->tags('list', $this->view->filters); // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } // Output the HTML $this->view->display(); }
/** * Get all the tags on an object * * @param integer $object_id Object ID * @param integer $offset Record offset * @param integer $limit Record limit * @param integer $tagger_id Tagger ID (set this if you want to restrict tags only added by a specific user) * @param integer $strength Tag strength (set this if you want to restrict tags by strength) * @param integer $admin Has admin access? * @return array */ public function get_tags_on_object($object_id, $offset = 0, $limit = 10, $tagger_id = NULL, $strength = 0, $admin = 0, $label = '') { $cloud = new Cloud($object_id, $this->_tbl); return $cloud->tags('list', ['objectid' => $object_id, 'tbl' => $this->_tbl]); }
/** * Displays a list of tags * * @apiMethod GET * @apiUri /tags/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": "raw_tag", * "allowedValues": "created, id, tag, raw_tag" * } * @apiParameter { * "name": "sort_Dir", * "description": "Direction to sort results by.", * "type": "string", * "required": false, * "default": "desc", * "allowedValues": "asc, desc" * } * @apiParameter { * "name": "scope", * "description": "Object scope (ex: group, resource, etc.)", * "type": "string", * "required": false, * "default": null * } * @apiParameter { * "name": "scope_id", * "description": "Object scope ID. Typically a Resource ID, Group ID, etc.", * "type": "integer", * "required": false, * "default": 0 * } * @apiParameter { * "name": "taggerid", * "description": "ID of user that tagged items.", * "type": "integer", * "required": false, * "default": 0 * } * @return void */ public function listTask() { $cloud = new Cloud(); $filters = array('limit' => Request::getInt('limit', 25), 'start' => Request::getInt('limitstart', 0), 'search' => Request::getVar('search', ''), 'scope' => Request::getWord('scope', ''), 'scope_id' => Request::getInt('scope_id', 0), 'taggerid' => Request::getVar('tagger', ''), 'sort' => Request::getWord('sort', 'raw_tag'), 'sort_Dir' => strtoupper(Request::getWord('sortDir', 'ASC'))); if ($filters['scope'] == 'members' || $filters['scope'] == 'member') { $filters['scope'] = 'xprofiles'; } $response = new stdClass(); $response->tags = array(); $response->total = $cloud->tags('count', $filters); //$response->showing = ($filters['start'] + 1) . ' - ' . ($filters['start'] + $filters['limit']); $response->start = $filters['start']; $response->limit = $filters['limit']; if ($response->total) { $base = rtrim(Request::base(), '/'); foreach ($cloud->tags('list', $filters) as $i => $tag) { $obj = new stdClass(); $obj->id = $tag->get('id'); $obj->raw_tag = $tag->get('raw_tag'); $obj->tag = $tag->get('tag'); $obj->uri = str_replace('/api', '', $base . '/' . ltrim(Route::url($tag->link()), '/')); $obj->substitutes_count = $tag->get('substitutes'); $obj->objects_count = $tag->get('total'); $response->tags[] = $obj; } } $response->success = true; $this->send($response); }
/** * Browse the list of tags * * @return void */ public function browseTask() { // Instantiate a new view if (Request::getVar('format', '') == 'xml') { $this->view->setLayout('browse_xml'); } // Incoming $this->view->filters = array('admin' => 0, 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''))); // Fallback support for deprecated sorting option if ($sortby = Request::getVar('sortby')) { Request::setVar('sort', $sortby); } $this->view->filters['sort'] = urldecode(Request::getState($this->_option . '.' . $this->_controller . '.sort', 'sort', 'raw_tag')); $this->view->filters['sort_Dir'] = strtolower(Request::getState($this->_option . '.' . $this->_controller . '.sort_Dir', 'sortdir', 'asc')); if (!in_array($this->view->filters['sort'], array('raw_tag', 'total'))) { $this->view->filters['sort'] = 'raw_tag'; } if (!in_array($this->view->filters['sort_Dir'], array('asc', 'desc'))) { $this->view->filters['sort_Dir'] = 'asc'; } $this->view->total = 0; $t = new Cloud(); $order = Request::getVar('order', ''); if ($order == 'usage') { $limit = Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'); $this->view->rows = $t->tags('list', array('limit' => $limit, 'admin' => 0, 'sort' => 'total', 'sort_Dir' => 'DESC', 'by' => 'user')); } else { // Record count $this->view->total = $t->tags('count', $this->view->filters); $this->view->filters['limit'] = Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'); // Get records $this->view->rows = $t->tags('list', $this->view->filters); } // Set the pathway $this->_buildPathway(); // Set the page title $this->_buildTitle(); $this->view->config = $this->config; // Output HTML foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->display(); }
/** * Browse the list of tags * * @return void */ public function browseTask() { // Instantiate a new view if (Request::getVar('format', '') == 'xml') { $this->view->setLayout('browse_xml'); } // Fallback support for deprecated sorting option if ($sortby = Request::getVar('sortby')) { Request::setVar('sort', $sortby); } // Incoming $filters = array('admin' => 0, 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'sort' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.sort', 'sort', 'raw_tag')), 'sort_Dir' => strtolower(Request::getState($this->_option . '.' . $this->_controller . '.sort_Dir', 'sortdir', 'asc'))); if (!in_array($filters['sort'], array('raw_tag', 'total'))) { $filters['sort'] = 'raw_tag'; } if (!in_array($filters['sort_Dir'], array('asc', 'desc'))) { $filters['sort_Dir'] = 'asc'; } $t = new Cloud(); // Record count $total = $t->tags('count', $filters); // Get records $rows = $t->tags('list', $filters); // Set the pathway $this->_buildPathway(); // Set the page title $this->_buildTitle(); $this->view->set('rows', $rows)->set('total', $total)->set('filters', $filters)->set('config', $this->config)->display(); }