/** * 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; }
$sections = $this->bits['sections']; $primary_child = isset($this->bits['primary_child']) ? $this->bits['primary_child'] : ''; $params = $this->bits['params']; $rt = $this->bits['rt']; $config = $this->bits['config']; $authorized = $this->bits['authorized']; $database = App::get('db'); $statshtml = ''; if ($params->get('show_ranking')) { $helper->getLastCitationDate(); if ($resource->type == 7) { $stats = new \Components\Resources\Helpers\Usage\Tools($database, $resource->id, $resource->type, $resource->rating, $helper->citationsCount, $helper->lastCitationDate); } else { $stats = new \Components\Resources\Helpers\Usage\Andmore($database, $resource->id, $resource->type, $resource->rating, $helper->citationsCount, $helper->lastCitationDate); } $statshtml = $stats->display(); } $html .= '<h3>' . Lang::txt('COM_RESOURCES_INFO') . '</h3>'; $html .= '<ul id="ulinfo">'; $html .= '<li>'; $html .= '<h4'; switch ($resource->access) { case 1: $html .= ' class="registered"'; break; case 2: $html .= ' class="special"'; break; case 3: $html .= ' class="protected"'; break;
/** * 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; }
?> %;">This resource has a</span></span> <?php echo number_format($rank, 1); ?> Ranking </dt> <dd> <p> Ranking is calculated from a formula comprised of <a href="<?php echo Route::url('index.php?option=' . $this->option . '&id=' . $this->model->resource->id . '&active=reviews'); ?> ">user reviews</a> and usage statistics. <a href="about/ranking/">Learn more ›</a> </p> <div> <?php echo $stats->display(); ?> </div> </dd> </dl> <?php } if ($this->model->params->get('show_audience')) { include_once PATH_CORE . DS . 'components' . DS . $this->option . DS . 'tables' . DS . 'audience.php'; include_once PATH_CORE . DS . 'components' . DS . $this->option . DS . 'tables' . DS . 'audiencelevel.php'; $ra = new \Components\Resources\Tables\Audience($database); $audience = $ra->getAudience($this->model->resource->id, $versionid = 0, $getlabels = 1, $numlevels = 4); $this->view('_audience', 'view')->set('audience', $audience)->set('showtips', 1)->set('numlevels', 4)->set('audiencelink', $this->model->params->get('audiencelink'))->display(); } if ($this->model->params->get('supportedtag')) { $rt = new \Components\Resources\Helpers\Tags($this->model->resource->id);