function parse_wysiwyg_html($html, $ishtml = 0, $forumid = 0, $allowsmilie = 1) { global $vbulletin; if ($ishtml) { // parse HTML into vbcode // I DON'T THINK THIS IS EVER USED NOW - KIER $html = convert_wysiwyg_html_to_bbcode($html); } else { $html = unhtmlspecialchars($html, 0); } // parse the message back into WYSIWYG-friendly HTML require_once DIR . '/includes/class_bbcode_alt.php'; $wysiwyg_parser = new vB_BbCodeParser_Wysiwyg($vbulletin, fetch_tag_list()); $wysiwyg_parser->set_parse_userinfo($vbulletin->userinfo); return $wysiwyg_parser->parse($html, $forumid, $allowsmilie); }
/** * Parses out specific white space before or after cetain tags, rematches * tags where necessary, and processes line breaks. * * @param string Text to process * @param bool Whether to translate newlines to HTML breaks (unused) * * @return string Processed text */ function parse_whitespace_newlines($text, $do_nl2br = true) { $text = parent::parse_whitespace_newlines($text, $do_nl2br); if ($this->is_wysiwyg('ie')) { // heading tags that span multiple lines shouldn't have p tags within // and they can't be split into multiple tags $text = preg_replace_callback(array('#\\[((h)=.*)\\](.*)\\[/\\2\\]#siU', '#\\[((page))\\](.*)\\[/\\2\\]#siU'), array($this, 'rematchIELinebreaks'), $text); // close any open p tags that come up to heading tags $text = preg_replace(array('#(\\[h=[1-6]\\].*\\[/h\\])#siU', '#(\\[page\\].*\\[/page\\])#siU'), '</p>\\1<p>', $text); $text = str_replace('<p></p>', '', $text); } return $text; }
/** * This does the actual work of creating the navigation elements. T * We use the existing search functionality. It's already all there, we just need * to * * @return string; */ private function makeResults($config) { include_once DIR . '/includes/functions_misc.php'; $search_core = vB_Search_Core::get_instance(); $hashkey = $this->getHash($this->widget->getId()); $data = vB_Cache::instance()->read($hashkey, true, true); if (!$data) { $criteria = $search_core->create_criteria($search_core->get_search_type('vBForum', 'Post')); $contenttypeid = $search_core->get_contenttypeid('vBForum', 'Post'); $criteria->add_contenttype_filter($contenttypeid); $criteria->set_advanced_typeid($contenttypeid); if ($config['ids']) { $criteria->add_group_filter( explode(",", $config['ids'])); $criteria->set_grouped(vB_Search_Core::GROUP_YES); } else { if ($config['forumchoice']) { $criteria->add_forumid_filter($config['forumchoice'], $config['childforums']); } if ($config['days']) { $timelimit = TIMENOW - (86400 * $config['days']); $criteria->add_date_filter(vB_Search_Core::OP_GT, $timelimit); } $criteria->add_filter('pollid', vB_Search_Core::OP_GT, 1, true); $search_type = vB_Search_Core::get_instance()->get_search_type_from_id($contenttypeid); $search_type->add_advanced_search_filters($criteria, vB::$vbulletin); $criteria->set_grouped(vB_Search_Core::GROUP_YES); } //Set the configuration parameters if (! intval($config['count'])) { $config['count'] = 5; } if (intval($config['count']) > 12) { $config['count'] = 5; } if (!isset($config['template_name']) OR ($config['template_name'] == '')) { $config['template_name'] = 'vbcms_widget_poll_page'; } if (!isset($config['detail_template']) OR ($config['detail_template'] == '')) { $config['detail_template'] = 'vbcms_widget_poll_resultdetail'; } $criteria->set_sort('dateline', 'desc'); $current_user = new vB_Legacy_CurrentUser(); $results = vB_Search_Results::create_from_cache($current_user, $criteria); if (!$results) { $results = vB_Search_Results::create_from_criteria($current_user, $criteria); } $page = $results->get_page(1, $config['count'], 0); if (count($page)) { $threads = array(); foreach ($page as $result) { $threads[] = $result->get_thread()->get_field('threadid'); } $where = implode(', ', $threads); $sql = "SELECT p.question, p.options, p.votes, t.threadid FROM " . TABLE_PREFIX . "poll p INNER JOIN " . TABLE_PREFIX . "thread t ON t.pollid = p.pollid WHERE t.threadid IN ( " . $where . ");"; if ($rst = vB::$vbulletin->db->query_read($sql)) { $data = array(); require_once(DIR . '/includes/class_bbcode_alt.php'); while ($row = vB::$vbulletin->db->fetch_array($rst)) { $this_item = array(); $options = explode('|||', $row['options'] ); $votes = explode('|||', $row['votes'] ); $this_item['totalvotes'] = 0; for($i = 0; $i < count($votes); $i++) { $this_item['totalvotes'] += $votes[$i]; } $detail = array(); $parser = new vB_BbCodeParser_Wysiwyg(vB::$vbulletin, fetch_tag_list('', true), true); for ($i = 0; $i < count($options); $i++) { $this_option = $parser->do_parse($options[$i]); $percent = ($this_item['totalvotes'] != 0) ? $votes[$i] / $this_item['totalvotes'] * 100 : 0; $detail[] = array( 'option' => $this_option, 'votes' => $votes[$i], 'percent' => vb_number_format($percent, 2), 'percentraw' => $percent, 'number' => $i + 1, 'graphicnumber' => (($i + 1) % 6) + 1, ); } $detailview = new vBCms_View_Widget($config['detail_template']); $detailview->resultdetail = $detail; $this_item['resultdetail'] = $detailview->render(); $this_item['threadid'] = $row['threadid']; $this_item['question'] = $row['question']; $data[$row['threadid']] = $this_item; } if (!isset($config['template_name']) OR ($config['template_name'] == '')) { $config['template_name'] = 'vbcms_widget_poll_page'; } } } vB_Cache::instance()->write($hashkey, $data, $this->cache_ttl); } // Create view $view = new vBCms_View_Widget($config['template_name']); $view->poll_data = $data; $view->class = $this->widget->getClass(); $view->title = $this->widget->getTitle(); $view->description = $this->widget->getDescription(); if (empty($view->poll_data)) { $view->setDisplayView(false); } return $view; }