diff --git a/administrator/language/en-GB/en-GB.plg_content_vote.ini b/administrator/language/en-GB/en-GB.plg_content_vote.ini index 434f00780e871..542ea9bcc5011 100644 --- a/administrator/language/en-GB/en-GB.plg_content_vote.ini +++ b/administrator/language/en-GB/en-GB.plg_content_vote.ini @@ -4,10 +4,14 @@ ; Note : All ini files need to be saved as UTF-8 PLG_CONTENT_VOTE="Content - Vote" +PLG_VOTE_BOTTOM="Bottom" PLG_VOTE_LABEL="Please Rate" +PLG_VOTE_POSITION_DESC="Set where the voting is displayed." +PLG_VOTE_POSITION_LABEL="Position" PLG_VOTE_RATE="Rate" PLG_VOTE_STAR_ACTIVE="Star Active" PLG_VOTE_STAR_INACTIVE="Star Inactive" +PLG_VOTE_TOP="Top" PLG_VOTE_USER_RATING="User Rating: %1$s / %2$s" PLG_VOTE_VOTE="Vote %s" PLG_VOTE_XML_DESCRIPTION="Add Voting functionality to Articles." diff --git a/plugins/content/vote/vote.php b/plugins/content/vote/vote.php index e11e29d6a9128..413fe41334c63 100644 --- a/plugins/content/vote/vote.php +++ b/plugins/content/vote/vote.php @@ -33,7 +33,30 @@ class PlgContentVote extends JPlugin protected $autoloadLanguage = true; /** - * Displays the voting area if in an article + * The position the voting data is displayed in relative to the article. + * + * @var string + * @since __DEPLOY_VERSION__ + */ + protected $votingPosition; + + /** + * Constructor. + * + * @param object &$subject The object to observe + * @param array $config An optional associative array of configuration settings. + * + * @since __DEPLOY_VERSION__ + */ + 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 @@ -44,7 +67,51 @@ class PlgContentVote extends JPlugin * * @since 1.6 */ - public function onContentBeforeDisplay($context, &$row, &$params, $page=0) + 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 __DEPLOY_VERSION__ + */ + 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 __DEPLOY_VERSION__ + */ + private function displayVotingData($context, &$row, &$params, $page) { $parts = explode(".", $context); diff --git a/plugins/content/vote/vote.xml b/plugins/content/vote/vote.xml index d2f99ab760788..87c37c26693c3 100644 --- a/plugins/content/vote/vote.xml +++ b/plugins/content/vote/vote.xml @@ -19,6 +19,18 @@ +
+ + + + +