//$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":
break; case 'breeze': $liclass = ' class="swf"'; //$class = ' class="play"'; break; case 'hubpresenter': $liclass = ' class="presentation"'; $class = 'hubpresenter'; break; default: $liclass = ' class="' . strtolower($ftype) . '"'; break; } $title = $child->logicaltitle ? $child->logicaltitle : stripslashes($child->title); } $url = \Components\Resources\Helpers\Html::processPath($this->option, $child, $this->model->resource->id, $linkAction); //$child->title = str_replace('"', '"', $child->title); //$child->title = str_replace('&', '&', $child->title); //$child->title = str_replace('&', '&', $child->title); //$child->title = str_replace('&quot;', '"', $child->title); // width & height if (preg_match("/\\.(bmp|gif|jpg|jpe|jpeg|png)\$/i", $child->path)) { if (!preg_match("/(?:https?:|mailto:|ftp:|gopher:|news:|file:)/", $child->path)) { /*Component::params('com_tools'); $base_path = $config->get('uploadpath', '/site/resources'); if ($base_path) { $base_path = DS . trim($base_path, DS); }*/ $filename = $child->path; // Does the path start with a slash?
$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
/** * 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; }