/**
  * Display a poll
  *
  * @access	public
  * @return	string		HTML content to replace tag with
  */
 public function poll_show_poll()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $extra = "";
     $sql = "";
     $check = 0;
     //-----------------------------------------
     // Got a poll?
     //-----------------------------------------
     if (!$this->settings['poll_poll_url']) {
         return;
     }
     //-----------------------------------------
     // Get the topic ID of the entered URL
     //-----------------------------------------
     /* Friendly URL */
     if ($this->settings['use_friendly_urls']) {
         preg_match("#/topic/(\\d+)(.*?)/#", $this->settings['poll_poll_url'], $match);
         $tid = intval(trim($match[1]));
     } else {
         preg_match("/(\\?|&)(t|showtopic)=(\\d+)(\$|&)/", $this->settings['poll_poll_url'], $match);
         $tid = intval(trim($match[3]));
     }
     if (!$tid) {
         return;
     }
     //-----------------------------------------
     // Get topic...
     //-----------------------------------------
     $this->registry->class_localization->loadLanguageFile(array('public_boards', 'public_topic'), 'forums');
     $this->registry->class_localization->loadLanguageFile(array('public_editors'), 'core');
     require_once IPSLib::getAppDir('forums') . "/sources/classes/forums/class_forums.php";
     $this->registry->setClass('class_forums', new class_forums($this->registry));
     $this->registry->getClass('class_forums')->strip_invisible = 1;
     $this->registry->getClass('class_forums')->forumsInit();
     require_once IPSLib::getAppDir('forums', 'forums') . '/topics.php';
     $topic = new public_forums_forums_topics();
     $topic->makeRegistryShortcuts($this->registry);
     $topic->topic = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'topics', 'where' => "tid=" . $tid));
     $topic->forum = ipsRegistry::getClass('class_forums')->forum_by_id[$topic->topic['forum_id']];
     $this->request['f'] = $topic->forum['id'];
     $this->request['t'] = $tid;
     if ($topic->topic['poll_state']) {
         return $this->registry->getClass('output')->getTemplate('portal')->pollWrapper($topic->_generatePollOutput(), $tid);
     } else {
         return;
     }
 }
 /**
  * Execute the plugin and return the HTML to show on the page.  
  * Can be called from ACP or front end, so the plugin needs to setup any appropriate lang files, skin files, etc.
  *
  * @access	public
  * @param	array 				Block data
  * @return	string				Block HTML to display or cache
  */
 public function executePlugin($block)
 {
     $config = unserialize($block['block_config']);
     if (!$config['custom']['poll']) {
         return '';
     }
     /* Friendly URL */
     if ($this->settings['use_friendly_urls']) {
         preg_match("#/topic/(\\d+)(.*?)/#", $config['custom']['poll'], $match);
         $tid = intval(trim($match[1]));
     } else {
         preg_match("/(\\?|&)(t|showtopic)=(\\d+)(\$|&)/", $config['custom']['poll'], $match);
         $tid = intval(trim($match[3]));
     }
     if (!$tid) {
         return '';
     }
     $poll = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'polls', 'where' => 'tid=' . $tid));
     if (!$poll['pid']) {
         return '';
     }
     $this->lang->loadLanguageFile(array('public_boards', 'public_topic'), 'forums');
     $this->lang->loadLanguageFile(array('public_editors'), 'core');
     require_once IPSLib::getAppDir('forums') . "/sources/classes/forums/class_forums.php";
     $this->registry->setClass('class_forums', new class_forums($this->registry));
     require_once IPSLib::getAppDir('forums') . '/modules_public/forums/topics.php';
     $topic = new public_forums_forums_topics();
     $topic->makeRegistryShortcuts($this->registry);
     $topic->topic = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'topics', 'where' => "tid=" . $poll['tid']));
     $topic->forum = ipsRegistry::getClass('class_forums')->forum_by_id[$topic->topic['forum_id']];
     $this->request['f'] = $topic->forum['id'];
     $this->request['t'] = $poll['tid'];
     if ($topic->topic['poll_state']) {
         $pluginConfig = $this->returnPluginInfo();
         $templateBit = $pluginConfig['templateBit'] . '_' . $block['block_id'];
         return $this->registry->output->getTemplate('ccs')->{$templateBit}($block['block_name'], $topic->_generatePollOutput(), $tid);
     } else {
         return;
     }
 }