/** * Generate module contents * * @return void */ public function run() { include_once Component::path('com_resources') . DS . 'tables' . DS . 'resource.php'; $database = \App::get('db'); //Get the admin configured settings $filters = array('limit' => 1, 'start' => 0, 'type' => trim($this->params->get('type')), 'sortby' => 'random', 'minranking' => trim($this->params->get('minranking')), 'tag' => trim($this->params->get('tag')), 'access' => 'public', 'toolState' => 7); $row = null; // No - so we need to randomly choose one // Initiate a resource object $rr = new \Components\Resources\Tables\Resource($database); // Get records $rows = $rr->getRecords($filters, false); if (count($rows) > 0) { $row = $rows[0]; } $this->cls = trim($this->params->get('moduleclass_sfx')); $this->txt_length = trim($this->params->get('txt_length')); // Did we get any results? if ($row) { $config = Component::params('com_resources'); // Resource $id = $row->id; include_once Component::path('com_resources') . DS . 'helpers' . DS . 'html.php'; $path = DS . trim($config->get('uploadpath', '/site/resources'), DS); $path = \Components\Resources\Helpers\Html::build_path($row->created, $row->id, $path); if ($row->type == 7) { include_once Component::path('com_tools') . DS . 'tables' . DS . 'version.php'; $tv = new \Components\Tools\Tables\Version($database); $versionid = $tv->getVersionIdFromResource($id, 'current'); $picture = $this->getToolImage($path, $versionid); } else { $picture = $this->getImage($path); } $thumb = $path . DS . $picture; if (!is_file(PATH_APP . $thumb)) { $thumb = DS . trim($config->get('defaultpic')); } $row->typetitle = trim(stripslashes($row->typetitle)); if (substr($row->typetitle, -1, 1) == 's' && substr($row->typetitle, -3, 3) != 'ies') { $row->typetitle = substr($row->typetitle, 0, strlen($row->typetitle) - 1); } $this->id = $id; $this->thumb = $thumb; } $this->row = $row; require $this->getLayoutPath(); }
?> <tr> <td width="100%"> <span class="ftitle item:name id:<?php echo $child->id; ?> " data-id="<?php echo $child->id; ?> "> <?php echo $this->escape($child->title); ?> </span> <?php echo $isFile ? \Components\Resources\Helpers\Html::getFileAttribs($url, $base) : '<span class="caption">' . $url . '</span>'; ?> </td> <td> <?php $cs = $child->access == 1 ? 'registered' : 'public'; $st = $child->access == 1 ? 0 : 1; ?> <a class="access-<?php echo $cs; ?> access" href="index.php?option=<?php echo $this->option; ?> &controller=<?php echo $this->controller;
?> <?php } ?> </p> <?php } else { // get launch button $firstchild = $this->model->children(0); $html = $this->tab != 'play' && is_object($firstchild) ? \Components\Resources\Helpers\Html::primary_child($this->option, $this->model->resource, $firstchild, '') : ''; // Display some supporting documents $children = $this->model->children(); // Sort out supporting docs $html .= $children && count($children) > 1 ? \Components\Resources\Helpers\Html::sortSupportingDocs($this->model->resource, $this->option, $children) : ''; //$html .= $feeds ? $feeds : ''; $html .= $this->tab != 'play' ? \Components\Resources\Helpers\Html::license($this->model->params->get('license', '')) : ''; echo $html; } // --- end else (if group check passed) ?> </div><!-- / .aside launcharea --> </div> <?php // Display canonical $this->view('_canonical')->set('option', $this->option)->set('model', $this->model)->display(); ?> </div><!-- / .subject --> <aside class="aside rankarea"> <?php // Show metadata
} ?> </aside><!-- / .aside --> </section> </div> <?php if ($this->model->access('view-all')) { ?> <section class="main section"> <div class="subject tabbed"> <?php echo \Components\Resources\Helpers\Html::tabs($this->option, $this->model->resource->id, $this->cats, $this->tab, $this->model->resource->alias); ?> <?php echo \Components\Resources\Helpers\Html::sections($this->sections, $this->cats, $this->tab, 'hide', 'main'); ?> </div><!-- / .subject --> <aside class="aside extracontent"> <?php // Show related content $out = Event::trigger('resources.onResourcesSub', array($this->model->resource, $this->option, 1)); if (count($out) > 0) { foreach ($out as $ou) { if (isset($ou['html'])) { echo $ou['html']; } } } // Show what's popular if ($this->tab == 'about') {
$height = intval($attribs->get('height', 360)); if ($width > 0 && $height > 0) { $class .= ' ' . $width . 'x' . $height; } } // user guide if (strtolower($title) != preg_replace('/user guide/', '', strtolower($title))) { $liclass = ' class="guide"'; } ?> <li<?php echo $liclass; ?> > <?php echo \Components\Resources\Helpers\Html::getFileAttribs($child->path, $base, 0); ?> <a<?php echo $class ? ' class="' . $class . '"' : ''; ?> href="<?php echo $url; ?> " title="<?php echo $this->escape(stripslashes($child->title)); ?> " <?php echo $action ? ' ' . $action : ''; ?> > <?php
</option> <option value="4"<?php echo $this->filters['status'] == 4 ? ' selected="selected"' : ''; ?> ><?php echo Lang::txt('JTRASHED'); ?> </option> </select> <label for="type"><?php echo Lang::txt('COM_RESOURCES_FILTER_TYPE'); ?> :</label> <?php echo \Components\Resources\Helpers\Html::selectType($this->types, 'type', $this->filters['type'], Lang::txt('COM_RESOURCES_FILTER_TYPE_ALL'), '', ' onchange="this.form.submit();"', ''); ?> </div> </div> </fieldset> <table class="adminlist"> <thead> <tr> <th scope="col"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo $this->rows ? count($this->rows) : 0; ?> );" /></th> <th scope="col" class="priority-5"><?php echo Html::grid('sort', 'COM_RESOURCES_COL_ID', 'id', @$this->filters['sort_Dir'], @$this->filters['sort']); ?>
/** * Download a file * Runs through various permissions checks to ensure user has access * * @return void */ public function downloadTask() { // Incoming $id = Request::getInt('id', 0); $alias = Request::getVar('alias', ''); $d = Request::getVar('d', 'inline'); //make sure we have a proper disposition if ($d != "inline" && $d != "attachment") { $d = "inline"; } // Load the resource $resource = new Resource($this->database); if ($alias && !$resource->loadAlias($alias)) { App::abort(404, Lang::txt('COM_RESOURCES_RESOURCE_NOT_FOUND')); return; } elseif (substr($id, 0, 4) == '9999') { $resource->id = $id; $resource->standalone = 1; $resource->path = null; $resource->created = Date::of('now')->format('Y-m-d 00:00:00'); } elseif (!$resource->load($id)) { App::abort(404, Lang::txt('COM_RESOURCES_RESOURCE_NOT_FOUND')); return; } // Check if the resource is for logged-in users only and the user is logged-in if ($token = Request::getVar('token', '', 'get')) { $token = base64_decode($token); $key = App::hash(@$_SERVER['HTTP_USER_AGENT']); $crypter = new \Hubzero\Encryption\Encrypter(new \Hubzero\Encryption\Cipher\Simple(), new \Hubzero\Encryption\Key('simple', $key, $key)); $session_id = $crypter->decrypt($token); $session = \Hubzero\Session\Helper::getSession($session_id); $user = User::getInstance($session->userid); $user->guest = 0; $user->id = $session->userid; $user->usertype = $session->usertype; } else { $user = User::getRoot(); } if ($resource->access == 1 && $user->get('guest')) { App::abort(403, Lang::txt('COM_RESOURCES_ALERTNOTAUTH')); return; } // Check if the resource is "private" and the user is allowed to view it if ($resource->access == 4 || $resource->access == 3 || !$resource->standalone) { if ($this->checkGroupAccess($resource, $user)) { App::abort(403, Lang::txt('COM_RESOURCES_ALERTNOTAUTH')); return; } } if ($resource->standalone && !$resource->path) { $resource->path = DS . trim($this->config->get('uploadpath', '/site/resources'), DS) . Html::build_path($resource->created, $resource->id, '') . DS . 'media' . DS . Request::getVar('file'); } $resource->path = trim($resource->path); // Ensure we have a path // Ensure resource is published - stemedhub #472 if (empty($resource->path) && $resource->published != 1) { App::abort(404, Lang::txt('COM_RESOURCES_FILE_NOT_FOUND')); return; } // Get the configured upload path $base_path = $this->config->get('uploadpath', '/site/resources'); if ($base_path) { $base_path = DS . trim($base_path, DS); } // Does the path start with a slash? if (substr($resource->path, 0, 1) != DS) { $resource->path = DS . $resource->path; // Does the beginning of the $resource->path match the config path? if (substr($resource->path, 0, strlen($base_path)) == $base_path) { // Yes - this means the full path got saved at some point } else { // No - append it $resource->path = $base_path . $resource->path; } } // Add root path $filename = PATH_APP . $resource->path; // Ensure the file exist if (!file_exists($filename)) { App::abort(404, Lang::txt('COM_RESOURCES_FILE_NOT_FOUND') . ' ' . $filename); return; } $ext = strtolower(\Filesystem::extension($filename)); if (!in_array($ext, array('jpg', 'jpeg', 'jpe', 'gif', 'png', 'pdf', 'htm', 'html', 'txt', 'json', 'xml'))) { $d = 'attachment'; } // Initiate a new content server and serve up the file $xserver = new \Hubzero\Content\Server(); $xserver->filename($filename); $xserver->disposition($d); $xserver->acceptranges(false); // @TODO fix byte range support if (!$xserver->serve()) { // Should only get here on error throw new Exception(Lang::txt('COM_RESOURCES_SERVER_ERROR'), 500); } else { exit; } return; }
/** * Return a path to resource * * @param $createdDate Resource creation date * @param $resourceId Resource ID * @param $versionId Resource Version ID * * @return path */ public static function getResourcePath($createdDate, $resourceId, $versionId) { //include the resources html helper file include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'html.php'; //get resource upload path $resourceParams = Component::params('com_resources'); $path = DS . trim($resourceParams->get("uploadpath"), DS); //build path based on resource creation date and id $path .= \Components\Resources\Helpers\Html::build_path($createdDate, $resourceId, ''); //append version id if we have one if ($versionId) { $path .= DS . $versionId; } return $path; }
$doi = '10254/' . $tconfig->get('doi_prefix') . $this->model->resource->id . '.' . $this->model->resource->doi_label; } } if ($doi) { $cite->doi = $doi; } $revision = isset($this->model->resource->revision) ? $this->model->resource->revision : ''; } if ($this->model->params->get('show_citation') == 2) { $citations = ''; } } else { $cite = null; } $citeinstruct = \Components\Resources\Helpers\Html::citation($this->option, $cite, $this->model->resource->id, $citations, $this->model->resource->type, $revision); $citeinstruct .= \Components\Resources\Helpers\Html::citationCOins($cite, $this->model); ?> <?php if ($this->model->params->get('show_citation') == 3) { ?> <h4><?php echo isset($citations) && ($citations != NULL || $citations != '') ? Lang::txt('PLG_RESOURCES_ABOUT_CITE_THIS') : ''; ?> </h4> <div class="resource-content"> <?php echo isset($citations) && ($citations != NULL || $citations != '') ? $citeinstruct : ''; ?> </div>
} // Order images if (count($this->shots > 0)) { // sort by ordering array_multisort($ordering, $all); } else { // sort by name sort($all); } $images = $all; // Display screenshots $els = ''; $k = 0; $g = 0; for ($i = 0, $n = count($images); $i < $n; $i++) { $tn = \Components\Resources\Helpers\Html::thumbnail($images[$i]['img']); if (is_file($this->upath . DS . $tn)) { if (strtolower(end($images[$i]['type'])) == 'swf') { $g++; $title = isset($images[$i]['title']) && $images[$i]['title'] != '' ? $images[$i]['title'] : Lang::txt('COM_TOOLS_DEMO') . ' #' . $g; $els .= '<li>'; $els .= '<a class="popup" rel="external" href="' . $this->wpath . DS . $images[$i]['img'] . '" title="' . $title . '">'; $els .= '<img src="' . $this->wpath . DS . $tn . '" alt="' . $title . '" id="ss_' . $i . '" />'; $els .= '</a>'; $els .= '</li>' . "\n"; } else { $k++; $title = isset($images[$i]['title']) && $images[$i]['title'] != '' ? $images[$i]['title'] : Lang::txt('COM_TOOLS_SCREENSHOT') . ' #' . $k; $els .= '<li>'; $els .= '<span class="dev_ss">'; $els .= '<a href="' . $base . '/index.php?option=' . $this->option . '&controller=' . $this->controller . '&task=edit&pid=' . $this->rid . '&filename=' . $images[$i]['img'] . '&version=' . $this->version . '&tmpl=component" class="icon-edit edit popup" rel="external">' . Lang::txt('COM_TOOLS_EDIT') . '</a>';
/** * Process the compose step * * @return void */ public function step_compose_process() { // Initiate extended database class $fields = Request::getVar('fields', array(), 'post'); $row = Resource::oneOrNew($fields['id'])->set($fields); $isNew = $row->get('id') < 1 || substr($row->get('id'), 0, 4) == '9999'; //$row->created = ($row->created) ? $row->created : Date::toSql(); //$row->created_by = ($row->created_by) ? $row->created_by : User::get('id'); // Set status to "composing" if ($isNew) { $row->set('published', 2); } $row->set('published', (int) $row->get('published', 2)); $row->set('publish_up', $row->get('publish_up') && $row->get('publish_up') != '0000-00-00 00:00:00' ? $row->get('publish_up') : Date::toSql()); $row->set('publish_down', $row->get('publish_down') && $row->get('publish_down') != '0000-00-00 00:00:00' ? $row->get('publish_down') : '0000-00-00 00:00:00'); $row->set('modified', Date::toSql()); $row->set('modified_by', User::get('id')); $row->set('access', (int) $row->get('access', 0)); $row->set('fulltxt', trim(preg_replace('/\\\\/', "%5C", $row->get('fulltxt')))); $row->set('introtext', String::truncate(strip_tags($row->get('fulltxt')), 500)); // Get custom areas, add wrapper tags, and compile into fulltxt $type = Type::oneOrFail($row->get('type')); include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'models' . DS . 'elements.php'; $elements = new Elements(array(), $type->customFields); $schema = $elements->getSchema(); $fields = array(); if (is_object($schema)) { foreach ($schema->fields as $field) { $fields[$field->name] = $field; } } $fulltxt = $row->get('fulltxt'); $nbtag = Request::getVar('nbtag', array(), 'post'); $found = array(); foreach ($nbtag as $tagname => $tagcontent) { $f = ''; $fulltxt .= "\n" . '<nb:' . $tagname . '>'; if (is_array($tagcontent)) { $c = count($tagcontent); $num = 0; foreach ($tagcontent as $key => $val) { if (trim($val)) { $num++; } $fulltxt .= '<' . $key . '>' . trim($val) . '</' . $key . '>'; } if ($c == $num) { $f = 'found'; } } else { $f = trim($tagcontent); if ($f) { $fulltxt .= trim($tagcontent); } } $fulltxt .= '</nb:' . $tagname . '>' . "\n"; if (!$f && isset($fields[$tagname]) && $fields[$tagname]->required) { $this->setError(Lang::txt('COM_CONTRIBUTE_REQUIRED_FIELD_CHECK', $fields[$tagname]->label)); } $found[] = $tagname; } $row->set('fulltxt', $fulltxt); foreach ($fields as $field) { if (!in_array($field->name, $found) && $field->required) { $found[] = $field->name; $this->setError(Lang::txt('COM_CONTRIBUTE_REQUIRED_FIELD_CHECK', $field->label)); } } $row->set('title', preg_replace('/\\s+/', ' ', $row->get('title'))); $row->set('title', $this->_txtClean($row->get('title'))); // Strip any scripting there may be if (trim($row->get('fulltxt'))) { $row->set('fulltxt', \Components\Resources\Helpers\Html::stripStyles($row->get('fulltxt'))); $row->set('fulltxt', $this->_txtClean($row->get('fulltxt'))); $row->set('footertext', $this->_txtClean($row->get('footertext'))); } // Fall back to step if any errors found if ($this->getError()) { $this->step--; $this->view->step = $this->step; $this->view->setLayout('compose'); return $this->step_compose($row); } // reset id if ($isNew) { $row->set('id', 0); } // Store new content if (!$row->save()) { $this->setError(Lang::txt('Error: Failed to store changes.')); $this->step--; $this->view->step = $this->step; $this->view->setLayout('compose'); return $this->step_compose($row); } // build path to temp upload folder and future permanent folder $session = App::get('session'); $created = Date::format('Y-m-d 00:00:00'); $oldPath = $row->basepath() . Html::build_path($created, $session->get('resources_temp_id'), ''); $newPath = $row->filespace(); // if we have a temp dir, move it to permanent location if (is_dir($oldPath)) { \Filesystem::move($oldPath, $newPath); $old = DS . $session->get('resources_temp_id') . DS; $new = DS . $row->id . DS; // update all images in abstract $row->set('introtext', str_replace($old, $new, $row->get('introtext'))); $row->set('fulltxt', str_replace($old, $new, $row->get('fulltxt'))); $row->save(); // clear temp id $session->clear('resources_temp_id'); } // Is it a new resource? if ($isNew) { // Automatically attach this user as the first author Request::setVar('pid', $row->get('id')); Request::setVar('id', $row->get('id')); Request::setVar('authid', User::get('id')); include_once __DIR__ . DS . 'authors.php'; $authors = new Authors(); $authors->saveTask(0); } // Log activity $recipients = array(['resource', $row->get('id')], ['user', $row->get('created_by')]); foreach ($row->authors()->where('authorid', '>', 0)->rows() as $author) { $recipients[] = ['user', $author->get('authorid')]; } Event::trigger('system.logActivity', ['activity' => ['action' => $isNew ? 'updated' : 'created', 'scope' => 'resource', 'scope_id' => $row->get('id'), 'description' => Lang::txt('COM_RESOURCES_ACTIVITY_ENTRY_' . (!$isNew ? 'UPDATED' : 'CREATED'), '<a href="' . Route::url('index.php?option=com_resources&id=' . $row->get('id')) . '">' . $row->get('title') . '</a>'), 'details' => array('title' => $row->get('title'), 'url' => Route::url('index.php?option=com_resources&id=' . $row->get('id')))], 'recipients' => $recipients]); }
/** * Process the compose step * * @return void */ public function step_compose_process() { // Initiate extended database class $row = new Resource($this->database); $row->load(Request::getInt('id', 0)); if (!$row->bind($_POST)) { throw new Exception($row->getError(), 500); } $isNew = $row->id < 1 || substr($row->id, 0, 4) == '9999'; $row->created = $row->created ? $row->created : Date::toSql(); $row->created_by = $row->created_by ? $row->created_by : User::get('id'); // Set status to "composing" if ($isNew) { $row->published = 2; } else { $row->published = $row->published ?: 2; } $row->publish_up = $row->publish_up && $row->publish_up != '0000-00-00 00:00:00' ? $row->publish_up : Date::toSql(); $row->publish_down = $row->publish_down && $row->publish_down != '0000-00-00 00:00:00' ? $row->publish_down : '0000-00-00 00:00:00'; $row->modified = Date::toSql(); $row->modified_by = User::get('id'); $row->access = $row->access ?: 0; $row->fulltxt = trim(preg_replace('/\\\\/', "%5C", $row->fulltxt)); $row->introtext = String::truncate(strip_tags($row->fulltxt), 500); //$row->fulltxt = $this->_txtAutoP($row->fulltxt, 1); // Get custom areas, add wrapper tags, and compile into fulltxt $type = new Type($this->database); $type->load($row->type); include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'models' . DS . 'elements.php'; $elements = new Elements(array(), $type->customFields); $schema = $elements->getSchema(); $fields = array(); if (is_object($schema)) { foreach ($schema->fields as $field) { $fields[$field->name] = $field; } } $nbtag = isset($_POST['nbtag']) ? $_POST['nbtag'] : array(); $found = array(); foreach ($nbtag as $tagname => $tagcontent) { $f = ''; $row->fulltxt .= "\n" . '<nb:' . $tagname . '>'; if (is_array($tagcontent)) { $c = count($tagcontent); $num = 0; foreach ($tagcontent as $key => $val) { if (trim($val)) { $num++; } $row->fulltxt .= '<' . $key . '>' . trim($val) . '</' . $key . '>'; } if ($c == $num) { $f = 'found'; } } else { $f = trim($tagcontent); if ($f) { $row->fulltxt .= trim($tagcontent); //(isset($fields[$tagname]) && $fields[$tagname]->type == 'textarea') ? $this->_txtAutoP(trim($tagcontent), 1) : trim($tagcontent); } } $row->fulltxt .= '</nb:' . $tagname . '>' . "\n"; if (!$f && isset($fields[$tagname]) && $fields[$tagname]->required) { $this->setError(Lang::txt('COM_CONTRIBUTE_REQUIRED_FIELD_CHECK', $fields[$tagname]->label)); } $found[] = $tagname; } foreach ($fields as $field) { if (!in_array($field->name, $found) && $field->required) { $found[] = $field->name; $this->setError(Lang::txt('COM_CONTRIBUTE_REQUIRED_FIELD_CHECK', $field->label)); } } $row->title = preg_replace('/\\s+/', ' ', $row->title); $row->title = $this->_txtClean($row->title); // Strip any scripting there may be if (trim($row->fulltxt)) { $row->fulltxt = \Components\Resources\Helpers\Html::stripStyles($row->fulltxt); $row->fulltxt = $this->_txtClean($row->fulltxt); //$row->fulltxt = $this->_txtAutoP($row->fulltxt, 1); $row->footertext = $this->_txtClean($row->footertext); } // Check content if (!$row->check()) { $this->setError($row->getError()); } // Fall back to step if any errors found if ($this->getError()) { $this->step--; $this->view->step = $this->step; $this->view->setLayout('compose'); $this->step_compose($row); return; } // reset id if ($isNew) { $row->id = null; } // Store new content if (!$row->store()) { $this->setError(Lang::txt('Error: Failed to store changes.')); $this->step--; $this->view->step = $this->step; $this->view->setLayout('compose'); $this->step_compose($row); return; } // build path to temp upload folder and future permanent folder $session = App::get('session'); $created = Date::format('Y-m-d 00:00:00'); $oldPath = PATH_APP . DS . trim($this->config->get('uploadpath', '/site/resources'), DS) . Html::build_path($created, $session->get('resources_temp_id'), ''); $newPath = PATH_APP . DS . trim($this->config->get('uploadpath', '/site/resources'), DS) . Html::build_path($row->created, $row->id, ''); // if we have a temp dir, move it to permanent location if (is_dir($oldPath)) { \Filesystem::move($oldPath, $newPath); $old = DS . $session->get('resources_temp_id') . DS; $new = DS . $row->id . DS; // update all images in abstract $row->introtext = str_replace($old, $new, $row->introtext); $row->fulltxt = str_replace($old, $new, $row->fulltxt); $row->store(); // clear temp id $session->clear('resources_temp_id'); } // Checkin the resource $row->checkin(); // Is it a new resource? if ($isNew) { // Get the resource ID if (!$row->id) { $row->id = $row->insertid(); } // Automatically attach this user as the first author Request::setVar('pid', $row->id); Request::setVar('id', $row->id); Request::setVar('authid', User::get('id')); include_once __DIR__ . DS . 'authors.php'; $authors = new Authors(); $authors->saveTask(0); } }
$html .= '<p class="closedsource_license">' . Lang::txt('COM_RESOURCES_TOOL_IS_CLOSED_SOURCE') . '</p>' . "\n"; } // do we have a first-time user guide? $helper->getChildren($this->model->resource->id, 0, 'all'); $children = $helper->children; if (!$thistool) { $guide = 0; foreach ($children as $child) { $title = $child->logicaltitle ? $child->logicaltitle : stripslashes($child->title); if ($child->access == 0 || $child->access == 1 && !User::isGuest()) { if (strtolower($title) != preg_replace('/user guide/', '', strtolower($title))) { $guide = $child; } } } $url = $guide ? \Components\Resources\Helpers\Html::processPath($this->option, $guide, $this->model->resource->id) : ''; $html .= "\t\t" . '<p class="supdocs">' . "\n"; if ($url) { $html .= "\t\t\t" . '<span><span class="guide"><a href="' . $url . '">' . Lang::txt('COM_RESOURCES_TOOL_FIRT_TIME_USER_GUIDE') . '</a></span></span>' . "\n"; } $html .= "\t\t\t" . '<span class="viewalldocs"><a href="' . Route::url('index.php?option=' . $this->option . '&id=' . $this->model->resource->id . '&active=supportingdocs') . '">' . Lang::txt('COM_RESOURCES_TOOL_VIEW_ALL_SUPPORTING_DOCS') . '</a></span>' . "\n"; $html .= "\t\t" . '</p>' . "\n"; } echo $html; } // --- end else (if group check passed) ?> </div><!-- / .aside launcharea --> </div> <?php
<th><?php echo Lang::txt('COM_RESOURCES_RATING_USER'); ?> :</th> <td><?php echo $this->escape($user->get('name')); ?> </td> </tr> <tr> <th><?php echo Lang::txt('COM_RESOURCES_RATING_VALUE'); ?> :</th> <td><?php echo \Components\Resources\Helpers\Html::writeRating($row->rating); ?> </td> </tr> <tr> <th><?php echo Lang::txt('COM_RESOURCES_RATING_CREATED'); ?> :</th> <td><?php echo $thedate; ?> </td> </tr> <tr> <th><?php
/** * Lists all files and folders for a given directory * * @return void */ public function listTask() { // Incoming directory (this should be a path built from a resource ID and its creation year/month) $this->view->resource = Request::getInt('resource', 0); if (!$this->view->resource) { echo '<p class="error">' . Lang::txt('COM_TOOLS_CONTRIBUTE_NO_ID') . '</p>'; return; } /*$this->view->version = Request::getInt('version', 0); if (!$this->view->version) { echo '<p class="error">' . Lang::txt('No tool version ID provided.') . '</p>'; return; }*/ // Incoming sub-directory $this->view->subdir = Request::getVar('subdir', ''); // Build the path $row = new \Components\Resources\Tables\Resource($this->database); $row->load($this->view->resource); $path = \Components\Resources\Helpers\Html::dateToPath($row->created) . DS . \Components\Resources\Helpers\Html::niceidformat($this->view->resource); $path = \Components\Resources\Helpers\Utilities::buildUploadPath($path, $this->view->subdir) . DS . 'media'; $folders = array(); $docs = array(); if (is_dir($path)) { // Loop through all files and separate them into arrays of images, folders, and other $dirIterator = new \DirectoryIterator($path); foreach ($dirIterator as $file) { if ($file->isDot()) { continue; } if ($file->isDir()) { $name = $file->getFilename(); $folders[$path . DS . $name] = $name; continue; } if ($file->isFile()) { $name = $file->getFilename(); if ('cvs' == strtolower($name) || '.svn' == strtolower($name)) { continue; } $docs[$path . DS . $name] = $name; } } ksort($folders); ksort($docs); } $this->view->docs = $docs; $this->view->folders = $folders; $this->view->config = $this->config; foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->display(); }
/** * Display an upload form and file listing * * @return void */ public function displayTask() { $this->view->setLayout('display'); // Incoming directory (this should be a path built from a resource ID and its creation year/month) $this->view->resource = Request::getInt('resource', 0); if (!$this->view->resource) { echo '<p class="error">' . Lang::txt('No resource ID provided.') . '</p>'; return; } // Incoming sub-directory $this->view->subdir = Request::getVar('subdir', ''); // Build the path //$this->view->path = Utilities::buildUploadPath($this->view->listdir, $this->view->subdir); $row = new Resource($this->database); $row->load($this->view->resource); // allow for temp resource uploads if (!$row->created || $row->created == '0000-00-00 00:00:00') { $row->created = Date::format('Y-m-d 00:00:00'); } $this->view->path = PATH_APP . DS . trim($this->config->get('uploadpath', '/site/resources'), DS) . Html::build_path($row->created, $this->view->resource, '') . DS . 'media'; $folders = array(); $docs = array(); if (is_dir($this->view->path)) { // Loop through all files and separate them into arrays of images, folders, and other $dirIterator = new \DirectoryIterator($this->view->path); foreach ($dirIterator as $file) { if ($file->isDot()) { continue; } if ($file->isDir()) { $name = $file->getFilename(); $folders[$path . DS . $name] = $name; continue; } if ($file->isFile()) { $name = $file->getFilename(); if ('cvs' == strtolower($name) || '.svn' == strtolower($name)) { continue; } $docs[$this->view->path . DS . $name] = $name; } } ksort($folders); ksort($docs); } $this->view->row = $row; $this->view->docs = $docs; $this->view->folders = $folders; // Set any errors if ($this->getError()) { foreach ($this->getErrors() as $error) { $this->view->setError($error); } } // Output the HTML $this->view->display(); }
<input type="text" name="type[alias]" id="field-alias" maxlength="100" value="<?php echo $this->escape(stripslashes($this->row->alias)); ?> " /><br /> <span class="hint"><?php echo Lang::txt('COM_RESOURCES_FIELD_ALIAS_HINT'); ?> </span> </div> <div class="input-wrap"> <label><?php echo Lang::txt('COM_RESOURCES_FIELD_CATEGORY'); ?> :</label><br /> <?php echo \Components\Resources\Helpers\Html::selectType($this->categories, 'type[category]', $this->row->category, Lang::txt('COM_RESOURCES_SELECT'), '', '', ''); ?> </div> <div class="input-wrap"> <label for="field-contributable"><?php echo Lang::txt('COM_RESOURCES_FIELD_CONTRIBUTABLE'); ?> :</label><br /> <input type="checkbox" name="type[contributable]" id="field-contributable" value="1"<?php echo $this->row->contributable ? ' checked="checked"' : ''; ?> /> <?php echo Lang::txt('COM_RESOURCES_FIELD_CONTRIBUTABLE_EXPLANATION'); ?> </div> <?php
/** * Removes a resource * Redirects to main listing * * @return void */ public function removeTask() { // Check for request forgeries Request::checkToken(); // Incoming $ids = Request::getVar('id', array(0)); // Ensure we have some IDs to work with if (count($ids) < 1) { $this->setMessage(Lang::txt('COM_RESOURCES_NO_ITEM_SELECTED')); return $this->cancelTask(); } foreach ($ids as $id) { // Load resource info $row = new Resource($this->database); $row->load($id); // Get path and delete directories if ($row->path != '') { $listdir = $row->path; } else { // No stored path, derive from created date $listdir = Html::build_path($row->created, $id, ''); } // Build the path $path = Utilities::buildUploadPath($listdir, ''); $base = PATH_APP . '/' . trim($this->config->get('webpath', '/site/resources'), '/'); $baseY = $base . '/' . Date::of($row->created)->format("Y"); $baseM = $baseY . '/' . Date::of($row->created)->format("m"); // Check if the folder even exists if (!is_dir($path) or !$path) { $this->setError(Lang::txt('COM_RESOURCES_ERROR_DIRECTORY_NOT_FOUND')); } else { if ($path == $base || $path == $baseY || $path == $baseM) { $this->setError(Lang::txt('COM_RESOURCES_ERROR_DIRECTORY_NOT_FOUND')); } else { // Attempt to delete the folder if (!\Filesystem::deleteDirectory($path)) { $this->setError(Lang::txt('COM_RESOURCES_ERROR_UNABLE_TO_DELETE_DIRECTORY')); } } } // Delete associations to the resource $row->deleteExistence(); // Delete the resource $row->delete(); } $pid = Request::getInt('pid', 0); // Redirect App::redirect($this->buildRedirectURL($pid)); }
} if ($canDo->get('core.delete')) { Toolbar::deleteList(); } ?> <form action="<?php echo Route::url('index.php?option=' . $this->option . '&controller=' . $this->controller); ?> " method="post" name="adminForm" id="adminForm"> <fieldset id="filter-bar"> <label for="category"><?php echo Lang::txt('COM_RESOURCES_FILTER_CATEGORY'); ?> :</label> <?php echo \Components\Resources\Helpers\Html::selectType($this->cats, 'category', $this->filters['category'], Lang::txt('COM_RESOURCES_SELECT'), '', '', ''); ?> <input type="submit" name="filter_submit" id="filter_submit" value="<?php echo Lang::txt('COM_RESOURCES_GO'); ?> " /> </fieldset> <table class="adminlist"> <thead> <tr> <th scope="col"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->rows); ?> );" /></th>
<table class="related-resources"> <tbody> <?php foreach ($this->related as $line) { if ($line->section != 'Topic') { $class = \Components\Resources\Helpers\Html::getRatingClass($line->rating); $resourceEx = new \Components\Resources\Helpers\Helper($line->id, $database); $resourceEx->getContributors(); // If the user is logged in, get their rating for this resource if (!User::isGuest()) { $mr = new \Components\Resources\Tables\Review($database); $myrating = $mr->loadUserRating($line->id, User::get('id')); } else { $myrating = 0; } $myclass = \Components\Resources\Helpers\Html::getRatingClass($myrating); // Get the SEF for the resource if ($line->alias) { $sef = Route::url('index.php?option=' . $this->option . '&alias=' . $line->alias); } else { $sef = Route::url('index.php?option=' . $this->option . '&id=' . $line->id); } } else { if ($line->group_cn != '' && $line->scope != '') { $sef = Route::url('index.php?option=com_groups&scope=' . $line->scope . '&pagename=' . $line->alias); } else { $sef = Route::url('index.php?option=com_wiki&scope=' . $line->scope . '&pagename=' . $line->alias); } } // Make sure we have an SEF, otherwise it's a querystring $d = strstr($sef, 'option=') ? '&' : '?';
$data = array(); preg_match_all("#<nb:(.*?)>(.*?)</nb:(.*?)>#s", $this->row->fulltxt, $matches, PREG_SET_ORDER); if (count($matches) > 0) { foreach ($matches as $match) { $data[$match[1]] = stripslashes($match[2]); } } $this->row->fulltxt = preg_replace("#<nb:(.*?)>(.*?)</nb:(.*?)>#s", '', $this->row->fulltxt); $this->row->fulltxt = trim($this->row->fulltxt); $this->row->fulltxt = $this->row->fulltxt ? trim(stripslashes($this->row->fulltxt)) : trim(stripslashes($this->row->introtext)); include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'models' . DS . 'elements.php'; } // Build the path for uploading files $path = \Components\Resources\Helpers\Html::dateToPath($this->row->created); if ($this->row->id) { $dir_id = \Components\Resources\Helpers\Html::niceidformat($this->row->id); } else { $dir_id = time() . rand(0, 10000); } $time = $this->attribs->get('timeof', ''); $time = strtotime($time) === false ? NULL : $time; ?> <script type="text/javascript"> function submitbutton(pressbutton) { if (pressbutton == 'resethits') { if (confirm('<?php echo Lang::txt('COM_RESOURCES_CONFIRM_HITS_RESET'); ?> ')){
/** * Process a single record * * @param integer $id * @return object */ public function record($id) { if (strstr($id, ':')) { list($id, $revision) = explode(':', $id); } $id = intval($id); if (!isset($revision)) { $revision = 0; } $this->database->setQuery("SELECT r.id, r.id AS identifier, r.title, r.introtext AS description, r.fulltxt, r.created, r.publish_up, r.alias, rt.alias AS type\n\t\t\tFROM `#__resources` AS r\n\t\t\tINNER JOIN `#__resource_types` AS rt ON r.type = rt.id\n\t\t\tWHERE r.id = " . $this->database->quote($id)); $record = $this->database->loadObject(); $record->base = $this->name(); $record->type = $record->base . ':' . $record->type; if ($revision) { $this->database->setQuery("SELECT *\n\t\t\t\tFROM `#__tool_version`\n\t\t\t\tWHERE toolname=" . $this->database->quote($record->alias) . " AND revision=" . $this->database->quote($revision) . "\n\t\t\t\tLIMIT 1"); $tool = $this->database->loadObject(); if ($tool->id) { $record->title .= ' [version ' . $tool->version . ']'; $record->fulltxt = $tool->fulltxt; $record->publish_up = $tool->released; } } $record->date = $record->created; if ($record->publish_up && $record->publish_up != $this->database->getNullDate()) { $record->date = $record->publish_up; } if (!$record->description) { $record->description = $record->fulltxt; $record->description = preg_replace("#<nb:(.*?)>(.*?)</nb:(.*?)>#s", '', $record->description); } $record->description = strip_tags($record->description); $record->description = trim($record->description); unset($record->publish_up); unset($record->created); unset($record->fulltxt); $isTool = 0; if ($record->alias) { $this->database->setQuery("SELECT id\n\t\t\t\tFROM `#__tool`\n\t\t\t\tWHERE toolname=" . $this->database->quote($record->alias) . "\n\t\t\t\tLIMIT 1"); $isTool = $this->database->loadResult(); } if ($revision) { /*"SELECT a.`doi` FROM `#__doi_mapping` AS a LEFT JOIN `#__tool_version` AS v ON v.id=a.versionid WHERE a.rid=" . $this->database->quote($id) . " AND v.revision=" . $this->database->quote($revision) . " LIMIT 1"*/ $this->database->setQuery("SELECT a.`doi`\n\t\t\t\tFROM `#__doi_mapping` AS a\n\t\t\t\tWHERE a.rid=" . $this->database->quote($id) . " AND a.local_revision=" . $this->database->quote($revision) . "\n\t\t\t\tLIMIT 1"); } else { $this->database->setQuery("SELECT a.`doi`\n\t\t\t\tFROM `#__doi_mapping` AS a\n\t\t\t\tWHERE a.rid=" . $this->database->quote($id) . "\n\t\t\t\tORDER BY `versionid` DESC LIMIT 1"); } $record->identifier = $this->identifier($id, $this->database->loadResult(), $revision); $this->database->setQuery("SELECT DISTINCT t.raw_tag\n\t\t\tFROM `#__tags` t, `#__tags_object` tos\n\t\t\tWHERE t.id = tos.tagid AND tos.objectid=" . $this->database->quote($id) . " AND tos.tbl='resources' AND t.admin=0\n\t\t\tORDER BY t.raw_tag"); $record->subject = $this->database->loadColumn(); $record->relation = array(); $this->database->setQuery("SELECT r.id, r.title, r.type, r.logical_type AS logicaltype, r.created, r.created_by,\n\t\t\tr.published, r.publish_up, r.path, r.access, t.type AS logicaltitle, rt.type AS typetitle, r.standalone\n\t\t\tFROM `#__resources` AS r\n\t\t\tINNER JOIN `#__resource_types` AS rt ON r.type=rt.id\n\t\t\tINNER JOIN `#__resource_assoc` AS a ON r.id=a.child_id\n\t\t\tLEFT JOIN `#__resource_types` AS t ON r.logical_type=t.id\n\t\t\tWHERE r.published=1 AND a.parent_id=" . $this->database->quote($id) . "\n\t\t\tORDER BY a.ordering, a.grouping"); if ($children = $this->database->loadObjectList()) { require_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'html.php'; require_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php'; foreach ($children as $child) { $uri = \Components\Resources\Helpers\Html::processPath('com_resources', $child, $id, 3); if (substr($uri, 0, 4) != 'http') { $uri = self::$base . '/' . ltrim($uri, '/'); } $record->relation[] = array('type' => 'hasPart', 'value' => $uri); } } $this->database->setQuery("SELECT DISTINCT r.id\n\t\t\tFROM `#__resources` AS r\n\t\t\tINNER JOIN `#__resource_assoc` AS a ON r.id=a.parent_id\n\t\t\tWHERE r.published=1 AND a.child_id=" . $this->database->quote($id) . "\n\t\t\tORDER BY a.ordering, a.grouping"); if ($parents = $this->database->loadObjectList()) { foreach ($parents as $parent) { $record->relation[] = array('type' => 'isPartOf', 'value' => $this->identifier($parent->id, 0)); } } if ($isTool) { if ($revision) { $this->database->setQuery("SELECT n.uidNumber AS id,\n\t\t\t\t\t\tCASE WHEN t.name!='' AND t.name IS NOT NULL THEN t.name\n\t\t\t\t\t\tELSE n.name\n\t\t\t\t\t\tEND AS `name`\n\t\t\t\t\tFROM `#__tool_authors` AS t, `#__xprofiles` AS n, `#__tool_version` AS v\n\t\t\t\t\tWHERE n.uidNumber=t.uid AND t.toolname=" . $this->database->quote($record->alias) . " AND v.id=t.version_id and v.state<>3\n\t\t\t\t\tAND t.revision=" . $this->database->quote($revision) . "\n\t\t\t\t\tORDER BY t.ordering"); $record->creator = $this->database->loadColumn(); /*$record->relation[] = array( 'type' => 'isVersionOf', 'value' => $this->identifier($id, '', 0) );*/ } $this->database->setQuery("SELECT v.id, v.revision, d.*\n\t\t\t\tFROM `#__tool_version` as v\n\t\t\t\tLEFT JOIN `#__doi_mapping` as d\n\t\t\t\tON d.alias = v.toolname\n\t\t\t\tAND d.local_revision=v.revision\n\t\t\t\tWHERE v.toolname = " . $this->database->quote($record->alias) . "\n\t\t\t\tORDER BY v.state DESC, v.revision DESC"); $versions = $this->database->loadObjectList(); foreach ($versions as $i => $v) { if (!$v->revision || $v->revision == $revision) { continue; } $record->relation[] = array('type' => 'hasVersion', 'value' => $this->identifier($id, $v->doi, $v->revision)); } } if (!isset($record->creator)) { $this->database->setQuery("SELECT \n\t\t\t\t\tCASE WHEN a.name!='' AND a.name IS NOT NULL THEN a.name\n\t\t\t\t\tELSE n.name\n\t\t\t\t\tEND AS `name`\n\t\t\t\tFROM `#__author_assoc` AS a\n\t\t\t\tLEFT JOIN `#__xprofiles` AS n ON n.uidNumber=a.authorid\n\t\t\t\tWHERE a.subtable='resources' AND a.subid=" . $this->database->quote($id) . " AND a.role!='submitter'\n\t\t\t\tORDER BY a.ordering, a.name"); $record->creator = $this->database->loadColumn(); } $this->database->setQuery("SELECT *\n\t\t\tFROM `#__citations` AS a\n\t\t\tINNER JOIN `#__citations_assoc` AS n ON n.`cid`=a.`id`\n\t\t\tWHERE n.`tbl`='resource' AND n.`oid`=" . $this->database->quote($id) . " AND a.`published`=1\n\t\t\tORDER BY `year` DESC"); $references = $this->database->loadObjectList(); if (count($references) && file_exists(PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php')) { include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php'; $formatter = new \Components\Citations\Helpers\Format(); $formatter->setTemplate('apa'); foreach ($references as $reference) { //<dcterms:isReferencedBy>uytruytry</dcterms:isReferencedBy> //<dcterms:isVersionOf>jgkhfjf</dcterms:isVersionOf> $cite = strip_tags(html_entity_decode($reference->formatted ? $reference->formatted : \Components\Citations\Helpers\Format::formatReference($reference, ''))); $cite = str_replace('"', '"', $cite); $record->relation[] = array('type' => 'references', 'value' => trim($cite)); } } return $record; }
$html .= $lis; $html .= '</ul><input type="hidden" name="atg" id="atg" value="' . htmlentities($tg) . '" /><input type="hidden" name="d" id="d" value="' . $d . '" />'; break; case 2: $tools = $this->bits['tools']; $typetitle = $this->bits['typetitle']; $type = $this->bits['type']; $rt = $this->bits['rt']; $params = $this->bits['params']; $filters = $this->bits['filters']; $sortbys = array('date' => Lang::txt('COM_RESOURCES_SORT_BY') . ' ' . Lang::txt('COM_RESOURCES_DATE'), 'title' => Lang::txt('COM_RESOURCES_SORT_BY') . ' ' . Lang::txt('COM_RESOURCES_TITLE'), 'ranking' => Lang::txt('COM_RESOURCES_SORT_BY') . ' ' . Lang::txt('COM_RESOURCES_RANKING')); if ($type == 7) { $sortbys['users'] = Lang::txt('COM_RESOURCES_SORT_BY') . ' ' . Lang::txt('COM_RESOURCES_USERS'); $sortbys['jobs'] = Lang::txt('COM_RESOURCES_SORT_BY') . ' ' . Lang::txt('COM_RESOURCES_JOBS'); } $html .= '<h3>' . Lang::txt('COM_RESOURCES') . ' ' . \Components\Resources\Helpers\Html::formSelect('sortby', $sortbys, $this->bits['sortby'], '" onchange="javascript:HUB.TagBrowser.changeSort();"') . '</h3>'; $html .= '<ul id="ulitems">'; if ($tools && count($tools) > 0) { //$database = App::get('db'); foreach ($tools as $tool) { $tool->title = \Hubzero\Utility\String::truncate($tool->title, 40); $supported = null; if ($this->bits['supportedtag']) { if (in_array($tool->id, $this->bits['supportedtagusage'])) { $supported = true; } //$supported = $rt->checkTagUsage( $this->bits['supportedtag'], $tool->id ); } $html .= '<li '; if ($this->bits['supportedtag'] && ($this->bits['tag'] == $this->bits['supportedtag'] || $supported)) { $html .= 'class="supported" ';
/** * Delete a file * * @return void */ public function deleteTask() { // Incoming parent ID $pid = Request::getInt('pid', 0); if (!$pid) { $this->setError(Lang::txt('COM_TOOLS_CONTRIBUTE_NO_ID')); $this->displayTask($pid); return; } // get tool object $obj = new \Components\Tools\Tables\Tool($this->database); $this->_toolid = $obj->getToolIdFromResource($pid); // make sure user is authorized to go further if (!$this->_checkAccess($this->_toolid)) { App::abort(403, Lang::txt('COM_TOOLS_ALERTNOTAUTH')); return; } // Incoming child ID $id = Request::getInt('id', 0); if (!$id) { $this->setError(Lang::txt('COM_TOOLS_CONTRIBUTE_NO_CHILD_ID')); $this->displayTask($pid); return; } // Load resource info $row = new \Components\Resources\Tables\Resource($this->database); $row->load($id); // Check for stored file if ($row->path == '') { $this->setError(Lang::txt('COM_TOOLS_ERROR_MISSING_FILE_PATH')); $this->displayTask($pid); return; } // Get resource path include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'html.php'; $listdir = \Components\Resources\Helpers\Html::build_path($row->created, $id, ''); // Build the path $path = $this->_buildUploadPath($listdir, ''); // Check if the folder even exists if (!is_dir($path) or !$path) { $this->setError(Lang::txt('COM_TOOLS_DIRECTORY_NOT_FOUND')); } else { // Attempt to delete the file if (!Filesystem::deleteDirectory($path)) { $this->setError(Lang::txt('COM_TOOLS_UNABLE_TO_DELETE_DIRECTORY')); } // Delete associations to the resource $row->deleteExistence(); // Delete resource $row->delete(); } // Push through to the attachments view $this->displayTask($pid); }
<span class="hint"><?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_ACCESS_HINT'); ?> </span> </div> <div class="input-wrap" data-hint="<?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_GROUP_HINT'); ?> "> <label for="import-group"> <?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_GROUP'); ?> </label> <?php echo \Components\Resources\Helpers\Html::selectGroup($this->groups, $this->params->get('group', ''), 'params[group]', 'import-group'); ?> <span class="hint"><?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_GROUP_HINT'); ?> </span> </div> <div class="input-wrap" data-hint="<?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_MATCHTITLE_HINT'); ?> "> <label for="param-titlematch"> <?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_MATCHTITLE'); ?> </label>
// Initiate paging for children $pageNav = $this->pagination($ccount, $filters['start'], $filters['limit']); $pageNav->setAdditionalUrlParam('id', $this->model->resource->id); $pageNav->setAdditionalUrlParam('sortby', $filters['sortby']); echo $pageNav->render(); ?> </div><!-- / .subject --> <div class="aside"> <fieldset class="controls"> <label for="sortby"> <?php echo Lang::txt('COM_RESOURCES_SORT_BY'); ?> : <?php echo \Components\Resources\Helpers\Html::formSelect('sortby', $sortbys, $filters['sortby'], ''); ?> </label> <p class="submit"> <input type="submit" value="<?php echo Lang::txt('COM_RESOURCES_GO'); ?> " /> </p> </fieldset> </div><!-- / .aside --> </section><!-- / .main section --> </form> <?php } // if ($this->tab == 'about' && $ccount > 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(); }
//$html .= ($child->introtext) ? '<br />'.\Hubzero\Utility\String::truncate(stripslashes($child->introtext),200) : ''; } } $html .= '</td>' . "\n"; if ($this->helper->children && count($this->helper->children) > 0) { $videoi = ''; $breeze = ''; $hubpresenter = ''; $pdf = ''; $video = ''; $exercises = ''; $supp = ''; $grandchildren = $this->helper->children; foreach ($grandchildren as $grandchild) { $grandchild->title = $this->escape($grandchild->title); $grandchild->path = \Components\Resources\Helpers\Html::processPath($this->option, $grandchild, $child->id); $grandchild_rt = new \Components\Resources\Tables\Type($this->database); $grandchild_rt->load($grandchild->type); $alias = $grandchild_rt->alias; switch ($alias) { case "player": case "quicktime": $videoi .= !$videoi ? '<a href="' . $grandchild->path . '">' . Lang::txt('View') . '</a>' : ''; break; case "breeze": $breeze .= !$breeze ? '<a title="View Presentation - Flash Version" class="breeze flash" href="' . $grandchild->path . '&no_html=1" title="' . $this->escape(stripslashes($grandchild->title)) . '">' . Lang::txt('View Flash') . '</a>' : ''; break; case "hubpresenter": $hubpresenter .= !$hubpresenter ? '<a title="View Presentation - HTML5 Version" class="hubpresenter html5" href="' . $grandchild->path . '" title="' . $this->escape(stripslashes($grandchild->title)) . '">' . Lang::txt('View HTML') . '</a>' : ''; break; case "pdf":
/** * Generate macro output * * @return string */ public function render() { //get the args passed in $content = $this->args; // args will be null if the macro is called without parenthesis. if (!$content) { return; } //generate a unique id for the slider $id = uniqid(); // null base url for now $base_url = ''; // needed objects $db = \App::get('db'); $option = \Request::getCmd('option'); $config = \Component::params($option); // define a base url switch ($option) { case 'com_groups': $cn = \Request::getVar('cn'); $group = Group::getInstance($cn); $base_url = DS . trim($config->get('uploadpath', 'site/groups'), DS) . DS; $base_url .= $group->get('gidNumber') . DS . 'uploads'; break; case 'com_resources': $row = new \Components\Resources\Tables\Resource($db); $row->load($this->pageid); $base_url = DS . trim($config->get('uploadpath', 'site/resources'), DS) . DS; $base_url .= \Components\Resources\Helpers\Html::build_path($row->created, $this->pageid, '') . DS . 'media'; break; } //seperate image list into array of images $slides = array_map('trim', explode(',', $content)); //array for checked slides $final_slides = array(); //check each passed in slide foreach ($slides as $slide) { //check to see if image is external if (strpos($slide, 'http') === false) { $slide = trim($slide); //check if internal file actually exists if (is_file(PATH_APP . $base_url . DS . $slide)) { $final_slides[] = $base_url . DS . $slide; } } else { $headers = get_headers($slide); if (strpos($headers[0], "OK") !== false) { $final_slides[] = $slide; } } } $html = ''; $html .= '<div class="wiki_slider">'; $html .= '<div id="slider_' . $id . '">'; foreach ($final_slides as $fs) { $html .= '<img src="' . $fs . '" alt="" />'; } $html .= '</div>'; $html .= '<div class="wiki_slider_pager" id="slider_' . $id . '_pager"></div>'; $html .= '</div>'; \Document::addStyleSheet('plugins/content/formathtml/macros/macro-assets/slider/slider.css'); \Document::addScript('plugins/content/formathtml/macros/macro-assets/slider/slider.js'); \Document::addScriptDeclaration(' var $jQ = jQuery.noConflict(); $jQ(function() { $jQ("#slider_' . $id . '").cycle({ fx: \'scrollHorz\', speed: 450, pager: \'#slider_' . $id . '_pager\' }); }); '); return $html; }