芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/plugins.8/content/vote/tmpl/rating.php
* @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Uri\Uri; /** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ $wa = $this->app->getDocument()->getWebAssetManager(); $wa->registerAndUseStyle('plg_content_vote', 'plg_content_vote/rating.css'); /** * Layout variables * ----------------- * @var string $context The context of the content being passed to the plugin * @var object &$row The article object * @var object &$params The article params * @var integer $page The 'page' number * @var array $parts The context segments * @var string $path Path to this file */ if ($context === 'com_content.categories') { return; } // Get the icons $iconStar = HTMLHelper::_('image', 'plg_content_vote/vote-star.svg', '', '', true, true); $iconHalfstar = HTMLHelper::_('image', 'plg_content_vote/vote-star-half.svg', '', '', true, true); // If you can't find the icons then skip it if ($iconStar === null || $iconHalfstar === null) { return; } // Get paths to icons $pathStar = JPATH_ROOT . substr($iconStar, strlen(Uri::root(true))); $pathHalfstar = JPATH_ROOT . substr($iconHalfstar, strlen(Uri::root(true))); // Write inline '
' elements $star = file_exists($pathStar) ? file_get_contents($pathStar) : ''; $halfstar = file_exists($pathHalfstar) ? file_get_contents($pathHalfstar) : ''; // Get rating $rating = (float) $row->rating; $rcount = (int) $row->rating_count; // Round to 0.5 $rating = round($rating / 0.5) * 0.5; // Determine number of stars $stars = $rating; $img = ''; for ($i = 0; $i < floor($stars); $i++) { $img .= '
' . $star . '
'; } if (($stars - floor($stars)) >= 0.5) { $img .= '
' . $star . '
'; $img .= '
' . $halfstar . '
'; ++$stars; } for ($i = $stars; $i < 5; $i++) { $img .= '
' . $star . '
'; } ?>
' . $rating . '', '
5
'); ?>
params->get('show_total_votes', 0)): ?>