Example #1
0
 /**
  * Method to get tool information
  *
  * @apiMethod GET
  * @apiUri    /tools/{tool}
  * @apiParameter {
  * 		"name":          "tool",
  * 		"description":   "Tool identifier",
  * 		"type":          "string",
  * 		"required":      true,
  * 		"default":       ""
  * }
  * @apiParameter {
  * 		"name":          "version",
  * 		"description":   "Tool version",
  * 		"type":          "string",
  * 		"required":      true,
  * 		"default":       "current"
  * }
  * @return     void
  */
 public function infoTask()
 {
     $database = \App::get('db');
     $tool = Request::getVar('tool', '');
     $version = Request::getVar('version', 'current');
     //we need a tool to continue
     if ($tool == '') {
         throw new Exception(Lang::txt('Tool Alias Required.'), 400);
     }
     //poll database for tool matching alias
     $sql = "SELECT r.id, r.alias, tv.toolname, tv.title, tv.description, tv.toolaccess as access, tv.mw, tv.instance, tv.revision, r.fulltxt as abstract, r.created\n\t\t\t\tFROM #__resources as r, #__tool_version as tv\n\t\t\t\tWHERE r.published=1\n\t\t\t\tAND r.type=7\n\t\t\t\tAND r.standalone=1\n\t\t\t\tAND r.access!=4\n\t\t\t\tAND r.alias=tv.toolname\n\t\t\t\tAND tv.state=1\n\t\t\t\tAND r.alias='{$tool}'\n\t\t\t\tORDER BY revision DESC";
     $database->setQuery($sql);
     $tool_info = $database->loadObject();
     //veryify we have result
     if ($tool_info == null) {
         throw new Exception(Lang::txt('No Tool Found Matching the Alias: "%s"', $tool), 404);
     }
     //add tool alias to tool info from db
     $tool_info->alias = $tool;
     //remove tags and slashes from abastract
     $tool_info->abstract = stripslashes(strip_tags($tool_info->abstract));
     //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';
     $this->rt = new \Components\Resources\Helpers\Tags(0);
     $supportedtagusage = $this->rt->getTagUsage($supportedtag, 'alias');
     $tool_info->supported = in_array($tool_info->alias, $supportedtagusage) ? 1 : 0;
     //get screenshots
     include_once Component::path('com_resources') . DS . 'tables' . DS . 'screenshot.php';
     include_once dirname(dirname(__DIR__)) . DS . 'tables' . DS . 'version.php';
     $ts = new \Components\Resources\Tables\Screenshot($database);
     $tv = new \Components\Tools\Tables\Version($database);
     $vid = $tv->getVersionIdFromResource($tool_info->id, $version);
     $shots = $ts->getScreenshots($tool_info->id, $vid);
     //get base path
     $path = \Components\Tools\Helpers\Utils::getResourcePath($tool_info->created, $tool_info->id, $vid);
     //add full path to screenshot
     $s = array();
     foreach ($shots as $shot) {
         $s[] = $path . DS . $shot->filename;
     }
     $tool_info->screenshots = $s;
     $object = new stdClass();
     $object->tool = $tool_info;
     $this->send($object);
 }
Example #2
0
 /**
  * Display a list of screenshots for this entry
  *
  * @param      integer $rid     Resource ID
  * @param      string  $version Tool version
  * @return     void
  */
 public function displayTask($rid = NULL, $version = NULL)
 {
     $this->view->setLayout('display');
     // Incoming
     if (!$rid) {
         $rid = Request::getInt('rid', 0);
     }
     if (!$version) {
         $version = Request::getVar('version', 'dev');
     }
     // Ensure we have an ID to work with
     if (!$rid) {
         App::abort(500, Lang::txt('COM_TOOLS_CONTRIBUTE_NO_ID'));
         return;
     }
     // Get resource information
     $resource = new \Components\Resources\Tables\Resource($this->database);
     $resource->load($rid);
     // Get version id
     $objV = new \Components\Tools\Tables\Version($this->database);
     $vid = $objV->getVersionIdFromResource($rid, $version);
     // Do we have a published tool?
     $this->view->published = $objV->getCurrentVersionProperty($resource->alias, 'id');
     // Get screenshot information for this resource
     $ss = new \Components\Resources\Tables\Screenshot($this->database);
     $this->view->shots = $ss->getScreenshots($rid, $vid);
     // Build paths
     include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'html.php';
     $path = \Components\Resources\Helpers\Html::build_path($resource->created, $rid, '');
     $this->view->upath = PATH_APP . DS . trim($this->rconfig->get('uploadpath'), DS) . $path;
     $this->view->wpath = DS . trim($this->rconfig->get('uploadpath'), DS) . $path;
     if ($vid) {
         $this->view->upath .= DS . $vid;
         $this->view->wpath .= DS . $vid;
     }
     // Make sure wpath is preceded by app
     if (substr($this->view->wpath, 0, 4) != DS . 'app') {
         $this->view->wpath = DS . 'app' . $this->view->wpath;
     }
     // get config
     $this->view->cparams = Component::params('com_resources');
     $this->view->version = $version;
     $this->view->rid = $rid;
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output HTML
     $this->view->display();
 }
Example #3
0
    Document::setDescription(strip_tags($this->model->resource->introtext));
}
// Check if there's anything left in the fulltxt after removing custom fields
// If not, set it to the introtext
$maintext = $this->model->description('parsed');
?>
<div class="subject abouttab">
	<?php 
if ($this->model->isTool()) {
    ?>
		<?php 
    if ($this->model->resource->revision == 'dev' or !$this->model->resource->toolpublished) {
        //$shots = null;
    } else {
        // Screenshots
        $ss = new \Components\Resources\Tables\Screenshot($this->database);
        $this->view('_screenshots')->set('id', $this->model->resource->id)->set('created', $this->model->resource->created)->set('upath', $this->model->params->get('uploadpath'))->set('wpath', $this->model->params->get('uploadpath'))->set('versionid', $this->model->resource->versionid)->set('sinfo', $ss->getScreenshots($this->model->resource->id, $this->model->resource->versionid))->set('slidebar', 1)->display();
        ?>
		<?php 
    }
    ?>
	<?php 
}
?>

	<div class="resource">
		<?php 
if ($thedate) {
    ?>
			<div class="grid">
				<div class="col span-half">