/** * Method to get list of tools * * @apiMethod GET * @apiUri /tools/list * @apiParameter { * "name": "user_id", * "description": "Member identifier", * "type": "integer", * "required": true, * "default": 0 * } * @return void */ public function listTask() { //get the userid and attempt to load user profile $userid = Request::getInt('user_id', 0); $result = User::getInstance($userid); //make sure we have a user //if ($result === false) return $this->not_found(); //instantiate database object $database = \App::get('db'); //get list of tools $tools = \Components\Tools\Models\Tool::getMyTools(); //get the supported tag $rconfig = Component::params('com_resources'); $supportedtag = $rconfig->get('supportedtag', ''); //get supportedtag usage include_once Component::path('com_resources') . DS . 'helpers' . DS . 'tags.php'; $resource_tags = new \Components\Resources\Helpers\Tags(0); $supportedtagusage = $resource_tags->getTagUsage($supportedtag, 'alias'); //create list of tools $t = array(); foreach ($tools as $k => $tool) { if (isset($t[$tool->alias])) { $t[$tool->alias]['versions'][] = $tool->revision; continue; } $t[$tool->alias]['alias'] = $tool->alias; $t[$tool->alias]['title'] = $tool->title; $t[$tool->alias]['description'] = $tool->description; $t[$tool->alias]['versions'] = array($tool->revision); $t[$tool->alias]['supported'] = in_array($tool->alias, $supportedtagusage) ? 1 : 0; } //encode and return result $object = new stdClass(); $object->tools = array_values($t); $this->send($object); }
</section> <section class="below section"> <?php if ($this->results) { ?> <div class="subject"> <h3><?php echo Lang::txt('COM_RESOURCES_TOP_RATED'); ?> </h3> <?php $supported = array(); if ($this->supportedtag) { include_once Component::path('com_resources') . DS . 'helpers' . DS . 'tags.php'; $rt = new \Components\Resources\Helpers\Tags(0); $supported = $rt->getTagUsage($this->supportedtag, 'id'); } $this->view('_list', 'browse')->set('lines', $this->results)->set('show_edit', $this->authorized)->set('supported', $supported)->display(); ?> </div><!-- / .subject --> <?php } ?> <aside class="aside"> <p><?php echo Lang::txt('COM_RESOURCES_TOP_RATED_EXPLANATION'); ?> </p> </aside><!-- / .aside --> </div><!-- / .main section --> </form>
<?php } ?> </nav> <div class="container-block"> <?php if ($this->results) { ?> <?php $config = Component::params('com_resources'); $supported = array(); if ($tag = $config->get('supportedtag')) { include_once Component::path('com_resources') . DS . 'helpers' . DS . 'tags.php'; $rt = new \Components\Resources\Helpers\Tags(0); $supported = $rt->getTagUsage($tag, 'id'); } $this->view('_list', 'browse')->set('lines', $this->results)->set('show_edit', $this->authorized)->set('supported', $supported)->display(); ?> <div class="clear"></div> <?php } else { ?> <p class="warning"><?php echo Lang::txt('COM_RESOURCES_NO_RESULTS'); ?> </p> <?php } ?> </div>