- md5
- b6c8ce1b912f69839307922d72ee8fb2
- sha1
- bd9889afbfadd8b4703d787e3076be4aa0daae7b
- sha256
- 4e1476d2dc396da45ac6fb3d18ac06c2551ee3287795c5d552acee8a255383ae
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
<?php
/**
* @package Joomla.Plugin
* @subpackage Content.vote
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Content\Vote\Extension;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Vote plugin.
*
* @since 1.5
*/
final class Vote extends CMSPlugin
{
/**
* @var \Joomla\CMS\Application\CMSApplication
*
* @since 3.7.0
*
* @deprecated 4.4.0 will be removed in 6.0 as it is there only for layout overrides
* Use getApplication() instead
*/
protected $app;
/**
* 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->params->get('position', 'top') !== '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->params->get('position', 'top') !== '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 = PluginHelper::getLayoutPath('content', 'vote', 'rating');
// Render the layout
ob_start();
include $path;
$html = ob_get_clean();
if ($this->getApplication()->getInput()->getString('view', '') === 'article' && $row->state == 1) {
// Get the path for the voting form layout file
$path = PluginHelper::getLayoutPath('content', 'vote', 'vote');
// Render the layout
ob_start();
include $path;
$html .= ob_get_clean();
}
return $html;
}
}
The same content is in 41 releases, Joomla 4.4.0-alpha1 to 5.0.0-beta1. See them all, or every version of this file.