<?php
/**
* @version $Revision: 1.3$
* @package Joomla
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
define('VOTEEXT_PATH', dirname(__FILE__).DS.'voteext');
class plgContentVoteExt extends JPlugin
{
function plgContentVoteExt(&$subject, $params)
{
parent::__construct($subject, $params);
$this->loadLanguage();
}
function onAfterDisplayTitle(&$article, &$params, $limitstart)
{
if (3 == $this->params->get('display_at', 1)) {
return $this->render($article, $params, $limitstart);
}
return '';
}
function onBeforeDisplayContent(&$article, &$params, $limitstart)
{
if (1 == $this->params->get('display_at', 1)) {
return $this->render($article, $params, $limitstart);
}
return '';
}
function onAfterDisplayContent(&$article, &$params, $limitstart)
{
if (2 == $this->params->get('display_at', 1)) {
return $this->render($article, $params, $limitstart);
}
return '';
}
/**
* $html = current($mainframe->triggerEvent('onContentVote', array(&$this->article, &$this->params, 1)));
* echo $html;
*/
function onContentVote(&$article, &$params, $limitstart)
{
return $this->render($article, $params, $limitstart);
}
function render( &$row, &$params, $page=0 )
{
$uri = & JFactory::getURI();
$id = $row->id;
$html = '';
if ($params->get( 'show_vote' ) && !$params->get( 'popup' ))
{
global $mainframe;
$override = JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'plg_content_voteext'.DS.'default.php';
ob_start();
if (is_readable($override)) {
include($override);
}
else if (is_readable(VOTEEXT_PATH.DS.'tmpl'.DS.'default.php')) {
include(VOTEEXT_PATH.DS.'tmpl'.DS.'default.php');
}
else {
JError::raiseError(500, JText::_('Failed to load default.php'));
}
$html = ob_get_clean();
}
return $html;
}
}