function js_cdeq($str) { return js_quote(cdata_escape($str)); }
function js_quote($html) { return "'" . str_replace("\n", "\\n", str_replace("'", "\\'", $html)) . "'"; } switch ($format) { case 'js': header("Content-Type: application/x-javascript"); echo "document.write(" . js_quote($html) . ");"; break; case 'jscb': header("Content-Type: application/x-javascript"); $cb = @$url_params['cb']; if (!$cb) { echo 'alert("Missing cb parameter to PA JS call! Check that your PeopleAggregator badge script is correct.");'; } else { echo "{$cb}(" . js_quote($html) . ");"; } break; case 'jsdiv': header("Content-Type: application/x-javascript"); $div = @$url_params['div']; if (!$div) { echo 'alert("Missing div parameter to PA JS call! Check that your PeopleAggregator badge script is correct.");'; } else { echo "document.getElementById('{$div}').innerHTML = " . js_quote($html) . ";"; } break; case 'html': echo $html; break; }
} } break; } else { $flag = 0; } } } //$total_vote = count($total_vote); $per_option = array(); if (!empty($vote)) { for ($i = 0; $i < count($vote); $i++) { $per_option[] = round($vote[$i][2]->counter / count($total_vote) * 100, 1); } } $template_file = 'web/Widgets/' . $widget_name . '/widget.tpl'; $template = new Template($template_file); $template->set('url_param', $url_param); $template->set('login_uid', PA::$login_uid); $template->set('flag', $flag); $template->set('percentage', $per_option); $template->set('total_vote', $total_vote); $template->set('options', $options); $template->set('topic', $poll_data); $html .= $template->fetch(); } else { $html .= 'No such poll'; } header("Content-Type: application/x-javascript"); echo "document.getElementById('pa_widget_poll').innerHTML = " . js_quote($html) . ";";
/** ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * [filename] is a part of PeopleAggregator. * [description including history] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @author [creator, or "Original Author"] * @license http://bit.ly/aVWqRV PayAsYouGo License * @copyright Copyright (c) 2010 Broadband Mechanics * @package PeopleAggregator */ include_once "../config.inc"; include_once "web/Widgets/ViewTracker/ViewTracker.php"; //spliting the path_info to get type. $param = preg_split("|/|", $path_info); for ($i = 2; $i < count($param); $i++) { list($k, $v) = explode('=', $param[$i]); $url_param[$k] = $v; } if (!empty($url_param['type'])) { $template_file = 'web/Widgets/' . $widget_name . '/widget.tpl'; $template = new Template($template_file); $template->set('url_param', $url_param); $template->set('login_uid', PA::$login_uid); $html .= $template->fetch(); } else { $html .= 'Type does not exist'; } header("Content-Type: application/x-javascript"); echo "document.write(" . js_quote($html) . ");";