Spade
Mini Shell
PKX��[�����tmpl/rating.phpnu�[���<?php
/**
* @package Joomla.Plugin
* @subpackage Content.vote
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* 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;
}
$rating = (int) $row->rating;
$rcount = (int) $row->rating_count;
// Look for images in template if available
$starImageOn = JHtml::_('image',
'system/rating_star.png',
JText::_('PLG_VOTE_STAR_ACTIVE'), null, true);
$starImageOff = JHtml::_('image',
'system/rating_star_blank.png',
JText::_('PLG_VOTE_STAR_INACTIVE'), null, true);
$img = '';
for ($i = 0; $i < $rating; $i++)
{
$img .= $starImageOn;
}
for ($i = $rating; $i < 5; $i++)
{
$img .= $starImageOff;
}
?>
<div class="content_rating">
<?php if ($rcount) : ?>
<p class="unseen element-invisible"
itemprop="aggregateRating" itemscope
itemtype="https://schema.org/AggregateRating">
<?php echo JText::sprintf('PLG_VOTE_USER_RATING',
'<span itemprop="ratingValue">' . $rating .
'</span>', '<span
itemprop="bestRating">5</span>'); ?>
<meta itemprop="ratingCount" content="<?php echo
$rcount; ?>" />
<meta itemprop="worstRating" content="1" />
</p>
<?php endif; ?>
<?php echo $img; ?>
</div>
PKX��[�0ɼ�
tmpl/vote.phpnu�[���<?php
/**
* @package Joomla.Plugin
* @subpackage Content.vote
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* 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
*/
$uri = clone JUri::getInstance();
$uri->setVar('hitcount', '0');
// Create option list for voting select box
$options = array();
for ($i = 1; $i < 6; $i++)
{
$options[] = JHtml::_('select.option', $i,
JText::sprintf('PLG_VOTE_VOTE', $i));
}
?>
<form method="post" action="<?php echo
htmlspecialchars($uri->toString(), ENT_COMPAT, 'UTF-8');
?>" class="form-inline">
<span class="content_vote">
<label class="unseen element-invisible"
for="content_vote_<?php echo (int) $row->id;
?>"><?php echo JText::_('PLG_VOTE_LABEL');
?></label>
<?php echo JHtml::_('select.genericlist', $options,
'user_rating', null, 'value', 'text',
'5', 'content_vote_' . (int) $row->id); ?>
 <input class="btn btn-mini"
type="submit" name="submit_vote" value="<?php
echo JText::_('PLG_VOTE_RATE'); ?>" />
<input type="hidden" name="task"
value="article.vote" />
<input type="hidden" name="hitcount"
value="0" />
<input type="hidden" name="url"
value="<?php echo htmlspecialchars($uri->toString(), ENT_COMPAT,
'UTF-8'); ?>" />
<?php echo JHtml::_('form.token'); ?>
</span>
</form>
PKX��[V��wwvote.phpnu�[���<?php
/**
* @package Joomla.Plugin
* @subpackage Content.vote
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Vote plugin.
*
* @since 1.5
*/
class PlgContentVote extends JPlugin
{
/**
* Application object
*
* @var JApplicationCms
* @since 3.7.0
*/
protected $app;
/**
* The position the voting data is displayed in relative to the article.
*
* @var string
* @since 3.7.0
*/
protected $votingPosition;
/**
* Constructor.
*
* @param object &$subject The object to observe
* @param array $config An optional associative array of
configuration settings.
*
* @since 3.7.0
*/
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
$this->votingPosition = $this->params->get('position',
'top');
}
/**
* Displays the voting area when viewing an article and the voting section
is displayed before the article
*
* @param string $context The context of the content being passed to
the plugin
* @param object &$row The article object
* @param object &$params The article params
* @param integer $page The 'page' number
*
* @return string|boolean HTML string containing code for the votes if
in com_content else boolean false
*
* @since 1.6
*/
public function onContentBeforeDisplay($context, &$row, &$params,
$page = 0)
{
if ($this->votingPosition !== 'top')
{
return '';
}
return $this->displayVotingData($context, $row, $params, $page);
}
/**
* Displays the voting area when viewing an article and the voting section
is displayed after the article
*
* @param string $context The context of the content being passed to
the plugin
* @param object &$row The article object
* @param object &$params The article params
* @param integer $page The 'page' number
*
* @return string|boolean HTML string containing code for the votes if
in com_content else boolean false
*
* @since 3.7.0
*/
public function onContentAfterDisplay($context, &$row, &$params,
$page = 0)
{
if ($this->votingPosition !== 'bottom')
{
return '';
}
return $this->displayVotingData($context, $row, $params, $page);
}
/**
* Displays the voting area
*
* @param string $context The context of the content being passed to
the plugin
* @param object &$row The article object
* @param object &$params The article params
* @param integer $page The 'page' number
*
* @return string|boolean HTML string containing code for the votes if
in com_content else boolean false
*
* @since 3.7.0
*/
private function displayVotingData($context, &$row, &$params,
$page)
{
$parts = explode('.', $context);
if ($parts[0] !== 'com_content')
{
return false;
}
if (empty($params) || !$params->get('show_vote', null))
{
return '';
}
// Load plugin language files only when needed (ex: they are not needed
if show_vote is not active).
$this->loadLanguage();
// Get the path for the rating summary layout file
$path = JPluginHelper::getLayoutPath('content',
'vote', 'rating');
// Render the layout
ob_start();
include $path;
$html = ob_get_clean();
if ($this->app->input->getString('view', '')
=== 'article' && $row->state == 1)
{
// Get the path for the voting form layout file
$path = JPluginHelper::getLayoutPath('content',
'vote', 'vote');
// Render the layout
ob_start();
include $path;
$html .= ob_get_clean();
}
return $html;
}
}
PKX��[����vote.xmlnu�[���<?xml
version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin"
group="content" method="upgrade">
<name>plg_content_vote</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2020 Open Source Matters. All rights
reserved.</copyright>
<license>GNU General Public License version 2 or later; see
LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_VOTE_XML_DESCRIPTION</description>
<files>
<filename plugin="vote">vote.php</filename>
<folder>tmpl</folder>
</files>
<languages>
<language
tag="en-GB">en-GB.plg_content_vote.ini</language>
<language
tag="en-GB">en-GB.plg_content_vote.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="position"
type="list"
label="PLG_VOTE_POSITION_LABEL"
description="PLG_VOTE_POSITION_DESC"
default="top"
>
<option value="top">PLG_VOTE_TOP</option>
<option value="bottom">PLG_VOTE_BOTTOM</option>
</field>
</fieldset>
</fields>
</config>
</extension>
PKX��[�����tmpl/rating.phpnu�[���PKX��[�0ɼ�
�tmpl/vote.phpnu�[���PKX��[V��ww�
vote.phpnu�[���PKX��[����kvote.xmlnu�[���PK,B!