public function onContentPrepare($context, &$article, &$params, $page = 0) { if (strpos($article->text, "{custompolls_vote}") === false) { return false; } $path = $this->livepath . '/plugins/content/' . $this->_name . '/assets'; $document = JFactory::getDocument(); $document->addScript($path . '/js/libs/jquery/jquery-1.8.2.min.js'); $document->addScript($path . '/js/libs/underscore-min.js'); $document->addScript($path . '/js/libs/moment.min.js'); $document->addScript($path . '/js/script.js'); $document->addStyleSheet($path . '/css/styles.css'); $mPolls = new CustompollsModelPolls(); $user =& JFactory::getUser(); if (!$user->guest) { $name = $user->name; $region = $mPolls->getUserRegion($user->id); } else { $name = ""; $region = ""; } $num = $mPolls->getCountVotes($article->id); list($vote, $status) = $mPolls->getVote($article->id); $result = file_get_contents(dirname(__FILE__) . "/assets/templates/polls.html"); $result = str_replace("{articleId}", $article->id, $result); $result = str_replace("{countVotes}", $num, $result); $result = str_replace("{region}", htmlspecialchars($region), $result); $result = str_replace("{name}", htmlspecialchars($name), $result); $result = str_replace("{vote}", $vote ? 1 : 0, $result); $article->text = str_replace("{custompolls_vote}", $result, $article->text); }
public function comments() { $articleId = JRequest::getVar("article_id", 0); $mPolls = new CustompollsModelPolls(); $result = $mPolls->getComments($articleId); print json_encode($result); jexit(); }