[go: up one dir, main page]

Menu

[r11]: / trunk / voteext.php  Maximize  Restore  History

Download this file

86 lines (75 with data), 2.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?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;
}
}