/** * Special formatting for results * * @param object $row Database row * @param string $period Time period * @return string */ public static function out($row, $period) { $database = App::get('db'); $helper = new \Components\Resources\Helpers\Helper($row->id, $database); // Instantiate a helper object if (!isset($row->authors)) { $helper->getContributors(); $row->authors = $helper->contributors; } // Get the component params and merge with resource params $config = Component::params('com_resources'); $rparams = new \Hubzero\Config\Registry($row->params); // Set the display date switch ($rparams->get('show_date', $config->get('show_date'))) { case 0: $thedate = ''; break; case 1: $thedate = Date::of($row->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; case 2: $thedate = Date::of($row->modified)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; case 3: $thedate = Date::of($row->publish_up)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; } // Start building HTML $html = "\t" . '<li class="resource">' . "\n"; $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a></p>' . "\n"; if ($rparams->get('show_ranking', $config->get('show_ranking'))) { $helper->getCitationsCount(); $helper->getLastCitationDate(); if ($row->area == 'Tools') { $stats = new \Components\Resources\Helpers\Usage\Stats($database, $row->id, $row->category, $row->rating, $helper->citationsCount, $helper->lastCitationDate); } else { $stats = new \Components\Resources\Helpers\Usage\Andmore($database, $row->id, $row->category, $row->rating, $helper->citationsCount, $helper->lastCitationDate); } $statshtml = $stats->display(); $row->ranking = round($row->ranking, 1); $html .= "\t\t" . '<div class="metadata">' . "\n"; $r = 10 * $row->ranking; if (intval($r) < 10) { $r = '0' . $r; } $html .= "\t\t\t" . '<dl class="rankinfo">' . "\n"; $html .= "\t\t\t\t" . '<dt class="ranking"><span class="rank-' . $r . '">' . Lang::txt('PLG_WHATSNEW_RESOURCES_THIS_HAS') . '</span> ' . number_format($row->ranking, 1) . ' ' . Lang::txt('PLG_WHATSNEW_RESOURCES_RANKING') . '</dt>' . "\n"; $html .= "\t\t\t\t" . '<dd>' . "\n"; $html .= "\t\t\t\t\t" . '<p>' . Lang::txt('PLG_WHATSNEW_RESOURCES_RANKING_EXPLANATION') . '</p>' . "\n"; $html .= "\t\t\t\t\t" . '<div>' . "\n"; $html .= $statshtml; $html .= "\t\t\t\t\t" . '</div>' . "\n"; $html .= "\t\t\t\t" . '</dd>' . "\n"; $html .= "\t\t\t" . '</dl>' . "\n"; $html .= "\t\t" . '</div>' . "\n"; } elseif ($rparams->get('show_rating', $config->get('show_rating'))) { switch ($row->rating) { case 0.5: $class = ' half-stars'; break; case 1: $class = ' one-stars'; break; case 1.5: $class = ' onehalf-stars'; break; case 2: $class = ' two-stars'; break; case 2.5: $class = ' twohalf-stars'; break; case 3: $class = ' three-stars'; break; case 3.5: $class = ' threehalf-stars'; break; case 4: $class = ' four-stars'; break; case 4.5: $class = ' fourhalf-stars'; break; case 5: $class = ' five-stars'; break; case 0: default: $class = ' no-stars'; break; } $html .= "\t\t" . '<div class="metadata">' . "\n"; $html .= "\t\t\t" . '<p class="rating"><span class="avgrating' . $class . '"><span>' . Lang::txt('PLG_WHATSNEW_RESOURCES_OUT_OF_5_STARS', $row->rating) . '</span> </span></p>' . "\n"; $html .= "\t\t" . '</div>' . "\n"; } $html .= "\t\t" . '<p class="details">' . $thedate . ' <span>|</span> ' . $row->area; if ($row->authors) { $html .= ' <span>|</span> ' . Lang::txt('PLG_WHATSNEW_RESOURCES_CONTRIBUTORS') . ' ' . $row->authors; } $html .= '</p>' . "\n"; if ($row->itext) { $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(strip_tags(stripslashes($row->itext)), 200) . '</p>' . "\n"; } else { if ($row->ftext) { $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(strip_tags(stripslashes($row->ftext)), 200) . '</p>' . "\n"; } } $html .= "\t\t" . '<p class="href">' . Request::base() . trim($row->href, '/') . '</p>' . "\n"; $html .= "\t" . '</li>' . "\n"; // Return output return $html; }
/** * Generate an RSS feed * * @return string RSS */ public function feedTask() { // Incoming $tagstring = trim(Request::getVar('tag', '', 'request', 'none', 2)); // Ensure we were passed a tag if (!$tagstring) { throw new Exception(Lang::txt('COM_TAGS_NO_TAG'), 404); } // Break the string into individual tags $tgs = explode(',', $tagstring); // Sanitize the tag $tags = array(); $added = array(); foreach ($tgs as $tag) { // Load the tag $tagobj = Tag::getInstance($tag); if (in_array($tagobj->get('tag'), $added)) { continue; } $added[] = $tagobj->get('tag'); // Ensure we loaded the tag's info from the database if ($tagobj->exists()) { $tags[] = $tagobj; } } // Paging variables $limitstart = Request::getInt('limitstart', 0); $limit = Request::getInt('limit', Config::get('list_limit')); $areas = array(); $searchareas = Event::trigger('tags.onTagAreas'); foreach ($searchareas as $area) { $areas = array_merge($areas, $area); } // Get the active category $area = Request::getVar('area', ''); $sort = Request::getVar('sort', ''); if ($area) { $activeareas = array($area); } else { $activeareas = $areas; } // Get the search results if (count($activeareas) > 1) { $sqls = Event::trigger('tags.onTagView', array($tags, $limit, $limitstart, $sort, $activeareas)); if ($sqls) { $s = array(); foreach ($sqls as $sql) { if (!is_string($sql)) { continue; } if (trim($sql) != '') { $s[] = $sql; } } $query = "("; $query .= implode(") UNION (", $s); $query .= ") ORDER BY "; switch ($sort) { case 'title': $query .= 'title ASC, publish_up'; break; case 'id': $query .= "id DESC"; break; case 'date': default: $query .= 'publish_up DESC, title'; break; } $query .= $limit != 'all' && $limit > 0 ? " LIMIT {$limitstart}, {$limit}" : ""; } $this->database->setQuery($query); $results = array($this->database->loadObjectList()); } else { $results = Event::trigger('tags.onTagView', array($tags, $limit, $limitstart, $sort, $activeareas)); } // Run through the array of arrays returned from plugins and find the one that returned results $rows = array(); if ($results) { foreach ($results as $result) { if (is_array($result) && !empty($result)) { $rows = $result; break; } } } // Build some basic RSS document information $title = Lang::txt(strtoupper($this->_option)) . ': '; for ($i = 0, $n = count($tags); $i < $n; $i++) { if ($i > 0) { $title .= '+ '; } $title .= $tags[$i]->get('raw_tag') . ' '; } $title = trim($title); $title .= ': ' . $area; // Set the mime encoding for the document Document::setType('feed'); // Start a new feed object $doc = Document::instance(); $doc->link = Route::url('index.php?option=' . $this->_option); $doc->title = Config::get('sitename') . ' - ' . $title; $doc->description = Lang::txt('COM_TAGS_RSS_DESCRIPTION', Config::get('sitename'), $title); $doc->copyright = Lang::txt('COM_TAGS_RSS_COPYRIGHT', gmdate("Y"), Config::get('sitename')); $doc->category = Lang::txt('COM_TAGS_RSS_CATEGORY'); // Start outputing results if any found if (count($rows) > 0) { include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'helper.php'; foreach ($rows as $row) { // Prepare the title $title = strip_tags($row->title); $title = html_entity_decode($title); // Strip html from feed item description text $description = html_entity_decode(String::truncate(Sanitize::stripAll(stripslashes($row->ftext)), 300)); $author = ''; @($date = $row->publish_up ? date('r', strtotime($row->publish_up)) : ''); if (isset($row->data3) || isset($row->rcount)) { $resourceEx = new \Components\Resources\Helpers\Helper($row->id, $this->database); $resourceEx->getCitationsCount(); $resourceEx->getLastCitationDate(); $resourceEx->getContributors(); $author = strip_tags($resourceEx->contributors); } // Load individual item creator class $item = new \Hubzero\Document\Type\Feed\Item(); $item->title = $title; $item->link = $row->href; $item->description = $description; $item->date = $date; $item->category = isset($row->data1) ? $row->data1 : ''; $item->author = $author; // Loads item info into rss array $doc->addItem($item); } } }
$html .= ' <a class="edit button" href="'. $link .'" title="'. Lang::txt('COM_RESOURCES_EDIT') .'">'. Lang::txt('COM_RESOURCES_EDIT') .'</a>'; } }*/ ?> </p> <?php if ($params->get('show_ranking')) { ?> <div class="metadata"> <dl class="rankinfo"> <dt class="ranking"> <?php //$database = App::get('db'); // Get statistics info $helper->getCitationsCount(); $helper->getLastCitationDate(); $this->line->ranking = round($this->line->ranking, 1); $r = 10 * $this->line->ranking; ?> <span class="rank"> <span class="rank-<?php echo $r; ?> " style="width: <?php echo $r; ?> %;"><?php echo Lang::txt('COM_RESOURCES_THIS_HAS'); ?> </span>
/** * Static method for formatting results * * @param object $row Database row * @return string HTML */ public static function out($row) { $authorized = false; if (User::authorise('core.manage', 'com_resources')) { $authorized = true; } $database = App::get('db'); // Instantiate a helper object $helper = new \Components\Resources\Helpers\Helper($row->id, $database); $helper->getContributors(); // Get the component params and merge with resource params $config = Component::params('com_resources'); $rparams = new \Hubzero\Config\Registry($row->params); //$params = $config; //$params->merge($rparams); // Set the display date switch ($rparams->get('show_date', $config->get('show_date'))) { case 0: $thedate = ''; break; case 1: $thedate = Date::of($row->created)->toLocal('d M Y'); break; case 2: $thedate = Date::of($row->modified)->toLocal('d M Y'); break; case 3: $thedate = Date::of($row->publish_up)->toLocal('d M Y'); break; } $html = "\t" . '<li class="'; switch ($row->access) { case 1: $html .= 'registered'; break; case 2: $html .= 'special'; break; case 3: $html .= 'protected'; break; case 4: $html .= 'private'; break; case 0: default: $html .= 'public'; break; } $html .= ' resource">' . "\n"; $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a>'; if ($authorized || $row->created_by == User::get('id')) { switch ($row->state) { case 5: $html .= ' <span class="resource-status internal">' . Lang::txt('PLG_MEMBERS_RESOURCES_STATUS_PENDING_INTERNAL') . '</span>'; break; case 4: $html .= ' <span class="resource-status deleted">' . Lang::txt('PLG_MEMBERS_RESOURCES_STATUS_DELETED') . '</span>'; break; case 3: $html .= ' <span class="resource-status pending">' . Lang::txt('PLG_MEMBERS_RESOURCES_STATUS_PENDING') . '</span>'; break; case 2: $html .= ' <span class="resource-status draft">' . Lang::txt('PLG_MEMBERS_RESOURCES_STATUS_DRAFT') . '</span>'; break; case 1: $html .= ' <span class="resource-status published">' . Lang::txt('PLG_MEMBERS_RESOURCES_STATUS_PUBLISHED') . '</span>'; break; case 0: default: $html .= ' <span class="resource-status unpublished">' . Lang::txt('PLG_MEMBERS_RESOURCES_STATUS_UNPUBLISHED') . '</span>'; break; } } $html .= '</p>' . "\n"; if ($rparams->get('show_ranking')) { $helper->getCitationsCount(); $helper->getLastCitationDate(); if ($row->category == 7) { $stats = new \Components\Resources\Helpers\Usage\Tools($database, $row->id, $row->category, $row->rating, $helper->citationsCount, $helper->lastCitationDate); } else { $stats = new \Components\Resources\Helpers\Usage\Andmore($database, $row->id, $row->category, $row->rating, $helper->citationsCount, $helper->lastCitationDate); } $statshtml = $stats->display(); $row->ranking = round($row->ranking, 1); $html .= "\t\t" . '<div class="metadata">' . "\n"; $r = 10 * $row->ranking; if (intval($r) < 10) { $r = '0' . $r; } $html .= "\t\t\t" . '<dl class="rankinfo">' . "\n"; $html .= "\t\t\t\t" . '<dt class="ranking"><span class="rank-' . $r . '">' . Lang::txt('PLG_MEMBERS_RESOURCES_THIS_HAS') . '</span> ' . number_format($row->ranking, 1) . ' ' . Lang::txt('PLG_MEMBERS_RESOURCES_RANKING') . '</dt>' . "\n"; $html .= "\t\t\t\t" . '<dd>' . "\n"; $html .= "\t\t\t\t\t" . '<p>' . Lang::txt('PLG_MEMBERS_RESOURCES_RANKING_EXPLANATION') . '</p>' . "\n"; $html .= "\t\t\t\t\t" . '<div>' . "\n"; $html .= $statshtml; $html .= "\t\t\t\t\t" . '</div>' . "\n"; $html .= "\t\t\t\t" . '</dd>' . "\n"; $html .= "\t\t\t" . '</dl>' . "\n"; $html .= "\t\t" . '</div>' . "\n"; } elseif ($rparams->get('show_rating')) { switch ($row->rating) { case 0.5: $class = ' half-stars'; break; case 1: $class = ' one-stars'; break; case 1.5: $class = ' onehalf-stars'; break; case 2: $class = ' two-stars'; break; case 2.5: $class = ' twohalf-stars'; break; case 3: $class = ' three-stars'; break; case 3.5: $class = ' threehalf-stars'; break; case 4: $class = ' four-stars'; break; case 4.5: $class = ' fourhalf-stars'; break; case 5: $class = ' five-stars'; break; case 0: default: $class = ' no-stars'; break; } $html .= "\t\t" . '<div class="metadata">' . "\n"; $html .= "\t\t\t" . '<p class="rating"><span class="avgrating' . $class . '"><span>' . Lang::txt('PLG_MEMBERS_RESOURCES_OUT_OF_5_STARS', $row->rating) . '</span> </span></p>' . "\n"; $html .= "\t\t" . '</div>' . "\n"; } $html .= "\t\t" . '<p class="details">' . $thedate . ' <span>|</span> ' . stripslashes($row->area); if ($helper->contributors) { $html .= ' <span>|</span> ' . Lang::txt('PLG_MEMBERS_RESOURCES_CONTRIBUTORS') . ': ' . $helper->contributors; } $html .= '</p>' . "\n"; if ($row->itext) { $html .= \Hubzero\Utility\String::truncate(stripslashes($row->itext), array('html' => true)) . "\n"; } else { if ($row->ftext) { $html .= \Hubzero\Utility\String::truncate(stripslashes($row->ftext), array('html' => true)) . "\n"; } } $html .= "\t" . '</li>' . "\n"; return $html; }
?> "><?php echo Lang::txt('PLG_GROUPS_RESOURCES_THIS_HAS'); ?> </span> <?php echo number_format($this->row->ranking, 1) . ' ' . Lang::txt('PLG_GROUPS_RESOURCES_RANKING'); ?> </dt> <dd> <p><?php echo Lang::txt('PLG_GROUPS_RESOURCES_RANKING_EXPLANATION'); ?> </p> <div> <?php $RE->getCitationsCount(); $RE->getLastCitationDate(); if ($this->row->category == 7) { $stats = new \Components\Resources\Helpers\Usage\Tools($database, $this->row->id, $this->row->category, $this->row->rating, $RE->citationsCount, $RE->lastCitationDate); } else { $stats = new \Components\Resources\Helpers\Usage\Andmore($database, $this->row->id, $this->row->category, $this->row->rating, $RE->citationsCount, $RE->lastCitationDate); } echo $stats->display(); ?> </div> </dd> </dl> </div> <?php } elseif ($params->get('show_rating')) { ?>