public function render() { $url = $this->view->url(array('controller' => 'x', 'action' => 'suggest')); $opt = array_merge(array('typeahead' => array('source' => new Zend\Json\Expr('adapter.ttAdapter()'))), $this->opt->to_array()); $this->view->messify->append('js', '/' . DIR_KERNEL . '/js/jquery/typeahead.bundle.js')->append('js', '/' . DIR_KERNEL . '/ctl/bootstrap/tokenfield/bootstrap-tokenfield.js')->append_inline('js', 'var adapter = new Bloodhound(' . Zend\Json\Json::encode(array('datumTokenizer' => new Zend\Json\Expr('Bloodhound.tokenizers.obj.whitespace("value")'), 'queryTokenizer' => new Zend\Json\Expr('Bloodhound.tokenizers.whitespace'), 'prefetch' => array('url' => $url, 'ajax' => array('type' => 'post', 'data' => array('term' => 1, 'model' => $this->model, 'method' => $this->method)))), false, array('enableJsonExprFinder' => true)) . ');adapter.initialize();var o = $("input[name=\'' . $this->name . '\']");o.tokenfield(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');')->append('css', '/' . DIR_KERNEL . '/ctl/bootstrap/tokenfield/bootstrap-tokenfield.css')->append('css', '/' . DIR_KERNEL . '/ctl/bootstrap/tokenfield/tokenfield-typeahead.css'); return parent::render(); }
/** * Convert a collection to json ready * @param collection $collection * @return array */ public static function toJson($collection) { \Zend\Json\Json::$useBuiltinEncoderDecoder = true; $newCollection = array(); foreach ($collection as $model) { $newCollection[] = $model->toArray(); } return json_encode($newCollection); }
public function render() { if ($this->uniform) { $opt = array(); $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/uniform/jquery.uniform.js')->append_inline('js', '$("input[type=radio][name=\'' . $this->name . '\']").uniform(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');'); if ($this->uniform->css) { $this->view->messify->append('css', '/' . DIR_KERNEL . '/ctl/uniform/themes/default/css/uniform.default.css'); } } return parent::render(); }
public function render() { if ($this->ui) { $opt = array(); if ($this->ui->opt) { $opt = array_merge($opt, $this->ui->opt->to_array()); } $opt['source'] = new Zend\Json\Expr('function(request, response) { $.ajax({ url: "/x/autocomplete/model/' . $this->fetch->model . ($this->fetch->method ? '/method/' . $this->fetch->method : '') . ($this->fetch->param ? '/param/' . $this->fetch->param : '') . '/term/" + encodeURIComponent(request.term), dataType: "json", success: function(data) { response(data); } }); }'); $opt['select'] = new Zend\Json\Expr('function(event, ui) { $("input[name=\'' . $this->name . '_fake\']").val(ui.item.label); $("input[name=\'' . $this->name . '\']").val(ui.item.value); $("input[name=\'' . $this->name . '\']").data("was_selected", true); return false; }'); $opt['change'] = new Zend\Json\Expr('function(event, ui) { if (!$("input[name=\'' . $this->name . '\']").data("was_selected")) { $("input[name=\'' . $this->name . '_fake\']").val(""); $("input[name=\'' . $this->name . '\']").val(""); } return false; }'); $opt['create'] = new Zend\Json\Expr('function(event, ui) { var val = $("input[name=\'' . $this->name . '\']").val(); if (val && String(val).length) $.ajax({ url: "/x/autocomplete/action/card/model/' . $this->fetch->model . ($this->fetch->method ? '/method/' . $this->fetch->method : '') . ($this->fetch->param ? '/param/' . $this->fetch->param : '') . '/value/" + encodeURIComponent(val), dataType: "json", success: function(data) { if (data && String(data.label).length) { $("input[name=\'' . $this->name . '_fake\']").val(data.label); } else { $("input[name=\'' . $this->name . '_fake\']").val(""); $("input[name=\'' . $this->name . '\']").val(""); } } }); return false; }'); $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.core.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.widget.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.position.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.menu.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.autocomplete.js')->append_inline('js', '$("input[name=\'' . $this->name . '_fake\']").autocomplete(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');$("input[name=\'' . $this->name . '_fake\']").focus(function() { $("input[name=\'' . $this->name . '\']").data("was_selected", false); });')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.core.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.theme.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.menu.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.autocomplete.css'); } return parent::render(); }
public function render() { if ($this->ui) { $opt = array(); if ($this->ui->opt) { $opt = array_merge($opt, $this->ui->opt->to_array()); } $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.core.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.datepicker.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/i18n/jquery.ui.datepicker-' . $this->ui->lang . '.js')->append_inline('js', '$("input[name=\'' . $this->name . '\']").' . ($this->time ? 'datetimepicker' : 'datepicker') . '(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');'); if ($this->time) { $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/timepicker/jquery-ui-timepicker-addon.js'); } $this->view->messify->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.core.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.theme.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.datepicker.css'); if ($this->time) { $this->view->messify->append('css', '/' . DIR_KERNEL . '/ctl/timepicker/jquery-ui-timepicker-addon.css'); } } return parent::render(); }
public function render() { if ($this->chosen) { $opt = array('no_results_text' => $this->view->translate('form_element_select_no_results_text'), 'placeholder_text' => $this->view->translate('form_element_select_placeholder_text'), 'placeholder_text_multiple' => $this->view->translate('form_element_select_placeholder_text_multiple')); $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/chosen/chosen.jquery.js')->append_inline('js', '$("select[name=\'' . $this->name . ($this->multiple ? '\\[\\]' : '') . '\']").chosen(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');'); if ($this->chosen->css) { $this->view->messify->append('css', '/' . DIR_KERNEL . '/ctl/chosen/chosen.css'); } } if ($this->uniform) { $opt = array(); $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/uniform/jquery.uniform.js')->append_inline('js', '$("select[name=\'' . $this->name . '\']").uniform(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');'); if ($this->chosen->css) { $this->view->messify->append('css', '/' . DIR_KERNEL . '/ctl/uniform/themes/default/css/uniform.default.css'); } } return parent::render(); }
public function render() { $url = $this->view->url(array('controller' => 'x', 'action' => 'suggest')); $opt = array_merge(array('width' => '100%', 'height' => '49px', 'unique' => new Zend\Json\Expr(true), 'autocomplete_url' => $url, 'autocomplete' => array('source' => new Zend\Json\Expr('function(request, response) { request["model"] = "' . $this->model . '"; request["method"] = "' . $this->method . '"; $.ajax({ url: "' . $url . '", type: "post", dataType: "json", data: request, success: function(data) { if (data.length == 0) o.val(""); response(data); } }); }'))), $this->ui->opt->to_array()); $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.core.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.widget.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.position.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.menu.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.autocomplete.js')->append('js', '/' . DIR_KERNEL . '/ctl/tagsinput/jquery.tagsinput.js')->append_inline('js', 'var o = $("input[name=\'' . $this->name . '\']");o.tagsInput(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.core.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.theme.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.menu.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.autocomplete.css')->append('css', '/' . DIR_KERNEL . '/ctl/tagsinput/jquery.tagsinput.css'); return parent::render(); }
public function render() { if (!function_exists('to_array')) { function to_array(&$obj) { if ($obj instanceof data) { $obj = $obj->to_array(); } if (is_array($obj)) { foreach ($obj as &$el) { to_array($el); } } } } $opt = array('target' => $this->target, 'jcrop' => $this->jcrop); to_array($opt); $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/crop/crop.js')->append('js', '/' . DIR_KERNEL . '/ctl/fancybox2/jquery.fancybox.js')->append('js', '/' . DIR_KERNEL . '/ctl/jcrop/js/jquery.Jcrop.js')->append_inline('js', '$("input[name=\'' . $this->name . '\']").crop(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');')->append('css', '/' . DIR_KERNEL . '/ctl/fancybox2/jquery.fancybox.css')->append('css', '/' . DIR_KERNEL . '/ctl/jcrop/css/jquery.Jcrop.css'); return parent::render(); }
public function render() { $opt = array(); if ($this->map_type) { $opt['map_type'] = $this->map_type; } if ($this->center) { $opt['center'] = $this->center->to_array(); } if ($this->zoom) { $opt['zoom'] = $this->zoom; } $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/coord/coord.js'); if ($this->map_type == 'yandex') { $this->view->messify->append('js', 'http://api-maps.yandex.ru/2.1/?load=package.standard&lang=ru', array('remote' => true)); } else { if ($this->map_type == 'google') { $this->view->messify->append('js', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&language=ru', array('remote' => true)); } } $this->view->messify->append_inline('js', '$("input[name=\'' . $this->name . '\']").coord(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');'); return parent::render(); }
function get_upload_progress() { global $vars; $key = ini_get('session.upload_progress.prefix') . PKWK_WIKI_NAMESPACE; header('Content-Type: application/json; charset=' . CONTENT_CHARSET); echo Zend\Json\Json::encode(isset($_SESSION[$key]) ? $_SESSION[$key] : null); exit; }
public function returnParserContentType($contentType) { if ($contentType === 'application/x-www-form-urlencoded') { return function ($input) { parse_str($input, $data); return $data; }; } elseif ($contentType === 'application/json') { return function ($input) { $jsonDecoder = new \Zend\Json\Json(); try { return $jsonDecoder->decode($input, \Zend\Json\Json::TYPE_ARRAY); } catch (\Exception $e) { return new ApiProblem(400, 'Data Parsing Error.'); } }; } elseif ($contentType === 'multipart/form-data') { return function ($input) { return $input; }; } return function ($input) { return $input; }; }
public function render() { if ($this->uploadifive) { session::set('uploadifive_' . $this->name, array('path' => $this->path, 'validator' => $this->validator, 'name_filer_length' => $this->name_filer_length)); $opt1 = $this->uploadifive->opt ? $this->uploadifive->opt->to_array() : array(); $opt = array('multi' => new Zend\Json\Expr($this->multiple ? 1 : 0), 'width' => '160px', 'fileObjName' => $this->name, 'dnd' => new Zend\Json\Expr(0), 'buttonText' => $this->view->translate('form_element_file_uploadifive_button_text' . ($this->multiple ? '_multiple' : '')), 'uploadScript' => $this->view->url(array('controller' => 'x', 'action' => 'upload')), 'onUploadComplete' => new Zend\Json\Expr('function(file, text) { var t = $(this); if (typeof text != "string") text = ""; if (text.slice(0, 3) == "ok|") { var v = text.slice(3); var file_data = window.uploadifive_data(v, file.queueItem); file_data.queueItem.find(".filename").html(v); file_data.queueItem.find(".image img").attr("src", "' . $this->url . '/" + v + "?" + Math.random() * 10000); file_data.queueItem.data("file", file_data); } else if (text.length && file.queueItem) { var info = text.replace("|", ", "); file.queueItem.find(".fileinfo").html(" - " + info); file.queueItem.find(".image").remove(); var file_1 = file.queueItem.data("file"); delete file_1["name"]; file_1.name = ""; window.setTimeout(function() { file.queueItem.find(".close").click(); }, 800); } else { file.queueItem.find(".image img").attr("src", "' . $this->url . '/" + file.name + "?" + Math.random() * 10000); } var filename = file.queueItem.find(".filename").html(); if (file.queueItem.find(".fileinfo").html().indexOf("Completed") !== -1) file.queueItem.find(".fileinfo").html(filename.length ? " / <a target=\\"_blank\\" href=\\"' . $this->url . '/" + filename + "\\">' . $this->view->translate('control_download') . '</a>" : ""); window.uploadifive_update(t.parent().parent()); ' . @$opt1['customUpload'] . ' }'), 'onSelect' => $this->multiple ? null : new Zend\Json\Expr('function(file) { var data = this.data("uploadifive"); $(this).parent().parent().find("#' . $this->view->escape($this->name) . '_delete").remove(); if (data.queue.count > 1) { var first = data.queueEl.find(".uploadifive-queue-item:first"); if (first.length) { var file = first.data("file"); if (file) data.removeQueueItem(file, true); } } ' . @$opt1['customSelect'] . ' }'), 'onCancel' => new Zend\Json\Expr('function() { var parent = $(this).parent().parent(); window.setTimeout(function() { ' . ($this->multiple ? '' : 'parent.append("<input type=\\"hidden\\" value=\\"' . $this->view->escape($this->value) . '\\" name=\\"' . $this->view->escape($this->name) . '_delete\\" id=\\"' . $this->view->escape($this->name) . '_delete\\" />");') . ' window.uploadifive_update(parent); }, 800); ' . @$opt1['customCancel'] . ' }'), 'onInit' => new Zend\Json\Expr('function() { var t = $(this); var parent = t.parent().parent(); var old = parent.find("input[type=hidden]:first").val(); parent.find(".e-form-element-file-value").remove(); if (old) { var files = old.split(","); for (k in files) { if (files[k].length) { var data = this.data("uploadifive"); var file = window.uploadifive_data(files[k]); data.addQueueItem(file); file.queueItem.find(".progress").hide(); data.uploadComplete(null, file, false); } } } if (parent.find("input[type=hidden]:first").length == 0) t.after("<input type=\\"hidden\\" name=\\"" + t.attr("name") + "\\" value=\\"\\" />"); window.uploadifive_update(parent); ' . @$opt1['customInit'] . ' }')); if ($this->uploadifive->opt) { unset($opt1['customSelect']); unset($opt1['customUpload']); unset($opt1['customInit']); unset($opt1['customCancel']); $opt = array_merge($opt, $opt1); } $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/uploadifive/jquery.uploadifive.js')->append_inline('js', 'if (typeof window.uploadifive_update == "undefined") window.uploadifive_update = function(o) { var val = []; o.find(".uploadifive-queue-item").each(function() { var file = $(this).data("file"); if (file && (typeof file.skip == "undefined" || !file.skip)) val.push(file.name); }); o.find("input[type=hidden]:first").val(val.join(",")); }; if (typeof window.uploadifive_data == "undefined") window.uploadifive_data = function(name, item) { return { name: name, xhr: { responseText: "" }, queueItem: item, complete: true }; }; $("input[type=file][name=\'' . $this->name . ($this->multiple && !$this->uploadifive ? '[]' : '') . '\']").uploadifive(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');'); if ($this->uploadifive->css) { $this->view->messify->append('css', '/' . DIR_KERNEL . '/ctl/uploadifive/uploadifive.css'); } } return parent::render(); }
<?php if (!defined('IN_AJAX')) { die(basename(__FILE__)); } global $bf, $lang; $user_id = (int) $this->request['user_id']; $new_opt = Zend\Json\Json::decode($this->request['user_opt'], Zend\Json\Json::TYPE_ARRAY); if (!$user_id or !($u_data = get_userdata($user_id))) { $this->ajax_die('invalid user_id'); } if (!is_array($new_opt)) { $this->ajax_die('invalid new_opt'); } foreach ($bf['user_opt'] as $opt_name => $opt_bit) { if (isset($new_opt[$opt_name])) { setbit($u_data['user_opt'], $opt_bit, !empty($new_opt[$opt_name])); } } DB()->query("UPDATE " . BB_USERS . " SET user_opt = {$u_data['user_opt']} WHERE user_id = {$user_id} LIMIT 1"); // Удаляем данные из кеша cache_rm_user_sessions($user_id); $this->response['resp_html'] = $lang['SAVED'];
<?php $val = explode(',', $this->control()->config->param->{'search_' . $this->name}); if ($this->range_type == 'date') { $this->messify->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.core.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.datepicker.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/i18n/jquery.ui.datepicker-' . $this->control()->config->ui->lang . '.js')->append_inline('js', '$(function() { $("#c-table-filter-' . $this->name . '-1").datepicker(' . Zend\Json\Json::encode($this->range_ui_param->to_array(), false, array('enableJsonExprFinder' => true)) . ');$("#c-table-filter-' . $this->name . '-2").datepicker(' . Zend\Json\Json::encode($this->range_ui_param->to_array(), false, array('enableJsonExprFinder' => true)) . '); });')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->control()->config->ui->theme . '/jquery.ui.core.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->control()->config->ui->theme . '/jquery.ui.theme.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->control()->config->ui->theme . '/jquery.ui.datepicker.css'); } ?> <div class="c-table-filter-range"><input id="c-table-filter-<?php echo $this->name; ?> -1" data-field="<?php echo $this->escape($this->name); ?> " data-default="<?php echo @$this->default[0]; ?> " onkeydown="c.filter_change(this, event);" class="span5" type="text" value="<?php echo $this->escape(@$val[0] ? $val[0] : @$this->default[0]); ?> " /><span class="span2">-</span><input id="c-table-filter-<?php echo $this->name; ?> -2" data-field="<?php echo $this->escape($this->name); ?> " data-default="<?php echo @$this->default[1]; ?> " onkeydown="c.filter_change(this, event);" class="span5" type="text" value="<?php echo $this->escape(@$val[1] ? $val[1] : @$this->default[1]); ?>
public function render() { $opt = array('type' => $this->point, 'url' => $this->url); $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/point/point.js')->append_inline('js', '$("input[name=\'' . $this->name . '\']").point(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');'); return parent::render(); }
if (IS_MOD) { $template->assign_vars(array('SHOW_GROUP_MEMBERSHIP' => $profiledata['user_level'] != USER)); } } // Show users torrent-profile if (IS_AM || $profile_user_id || !bf($profiledata['user_opt'], 'user_opt', 'user_dls')) { require UCP_DIR . 'viewtorrent.php'; } // Ajax bt_userdata if (IS_AM || $profile_user_id) { show_bt_userdata($profiledata['user_id']); } else { $template->assign_vars(array('DOWN_TOTAL_BYTES' => false, 'MIN_DL_BYTES' => false)); } if (IS_ADMIN) { $ajax_user_opt = Zend\Json\Json::encode(array('dis_avatar' => bf($profiledata['user_opt'], 'user_opt', 'dis_avatar'), 'dis_sig' => bf($profiledata['user_opt'], 'user_opt', 'dis_sig'), 'dis_passkey' => bf($profiledata['user_opt'], 'user_opt', 'dis_passkey'), 'dis_pm' => bf($profiledata['user_opt'], 'user_opt', 'dis_pm'), 'dis_post' => bf($profiledata['user_opt'], 'user_opt', 'dis_post'), 'dis_post_edit' => bf($profiledata['user_opt'], 'user_opt', 'dis_post_edit'), 'dis_topic' => bf($profiledata['user_opt'], 'user_opt', 'dis_topic'))); $template->assign_vars(array('EDITABLE_TPLS' => true, 'AJAX_USER_OPT' => $ajax_user_opt, 'U_MANAGE' => "profile.php?mode=editprofile&u={$profiledata['user_id']}", 'U_PERMISSIONS' => "admin/admin_ug_auth.php?mode=user&u={$profiledata['user_id']}")); } $user_restrictions = array(); if (bf($profiledata['user_opt'], 'user_opt', 'dis_avatar')) { $user_restrictions[] = $lang['HIDE_AVATARS']; } if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) { $user_restrictions[] = $lang['SHOW_CAPTION']; } if (bf($profiledata['user_opt'], 'user_opt', 'dis_passkey')) { $user_restrictions[] = $lang['DOWNLOAD_TORRENT']; } if (bf($profiledata['user_opt'], 'user_opt', 'dis_pm')) { $user_restrictions[] = $lang['SEND_PM']; }
/** * OB Handler */ function ob_handler($contents) { if (DBG_USER) { if ($contents) { $this->response['raw_output'] = $contents; } } $response_js = Zend\Json\Json::encode($this->response); if (GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) { if (UA_GZIP_SUPPORTED && strlen($response_js) > 2000) { header('Content-Encoding: gzip'); $response_js = gzencode($response_js, 1); } } return $response_js; }
function get_poll_data_items_js($topic_id) { if (!($topic_id_csv = get_id_csv($topic_id))) { return is_array($topic_id) ? array() : false; } $items = array(); if (!($poll_data = CACHE('bb_poll_data')->get("poll_{$topic_id}"))) { $poll_data = DB()->fetch_rowset("\n\t\t\tSELECT topic_id, vote_id, vote_text, vote_result\n\t\t\tFROM " . BB_POLL_VOTES . "\n\t\t\tWHERE topic_id IN({$topic_id_csv})\n\t\t\tORDER BY topic_id, vote_id\n\t\t"); CACHE('bb_poll_data')->set("poll_{$topic_id}", $poll_data); } foreach ($poll_data as $row) { $opt_text_for_js = htmlCHR($row['vote_text']); $opt_result_for_js = (int) $row['vote_result']; $items[$row['topic_id']][$row['vote_id']] = array($opt_text_for_js, $opt_result_for_js); } foreach ($items as $k => $v) { $items[$k] = Zend\Json\Json::encode($v); } return is_array($topic_id) ? $items : $items[$topic_id]; }
public function render() { $res = parent::render(); if (!function_exists('to_array')) { function to_array(&$obj) { if ($obj instanceof data) { $obj = $obj->to_array(); } if (is_array($obj)) { foreach ($obj as &$el) { to_array($el); } } } } if (@$this->markitup) { $opt = clone $this->markitup->opt; to_array($opt); $this->view->messify->append('css', '/' . DIR_KERNEL . '/ctl/markitup/skins/' . $this->markitup->skin . '/style.css')->append('css', $this->markitup->set_style)->append('js', '/' . DIR_KERNEL . '/ctl/markitup/jquery.markitup.js')->append_inline('js', '$("textarea[name=\'' . $this->name . '\']").markItUp(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');'); if ($this->markitup->class) { $res = '<div class="' . $this->markitup->class . '">' . $res . '</div>'; } } if (@$this->ckeditor) { $opt = clone $this->ckeditor->opt; to_array($opt); $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/ckeditor/ckeditor.js')->append('js', '/' . DIR_KERNEL . '/ctl/ckfinder/ckfinder.js')->append_inline('js', 'var editor_' . $this->name . ' = CKEDITOR.replace("' . $this->name . '", ' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');CKFinder.setupCKEditor(editor_' . $this->name . ', "/' . DIR_KERNEL . '/ctl/ckfinder/");'); if ($this->ckeditor->class) { $res = '<div class="' . $this->ckeditor->class . '">' . $res . '</div>'; } } return $res; }
/** * Load misc options */ function load_opt_js() { if (IS_GUEST) { $this->opt_js = array_merge($this->opt_js, $this->opt_js_guest); } else { if (!empty($_COOKIE['opt_js'])) { $opt_js = Zend\Json\Json::decode($_COOKIE['opt_js'], Zend\Json\Json::TYPE_ARRAY); if (is_array($opt_js)) { $this->opt_js = array_merge($this->opt_js, $opt_js); } } } }
// synch unread pm count if (defined('IN_PM')) { $row = DB()->fetch_row("\n\t\t\t\tSELECT COUNT(*) AS pm_count\n\t\t\t\tFROM " . BB_PRIVMSGS . "\n\t\t\t\tWHERE privmsgs_to_userid = " . $userdata['user_id'] . "\n\t\t\t\t\tAND privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . "\n\t\t\t\tGROUP BY privmsgs_to_userid\n\t\t\t"); $real_unread_pm_count = (int) $row['pm_count']; if ($userdata['user_unread_privmsg'] != $real_unread_pm_count) { $userdata['user_unread_privmsg'] = $real_unread_pm_count; db_update_userdata($userdata, array('user_unread_privmsg' => $real_unread_pm_count)); } } $pm_info = declension($userdata['user_unread_privmsg'], $lang['UNREAD_PMS_DECLENSION'], $lang['UNREAD_PMS_FORMAT']); $have_unread_pm = true; } } $template->assign_vars(array('HAVE_NEW_PM' => $have_new_pm, 'HAVE_UNREAD_PM' => $have_unread_pm)); // The following assigns all _common_ variables that may be used at any point in a template $template->assign_vars(array('SIMPLE_HEADER' => !empty($gen_simple_header), 'CONTENT_ENCODING' => $bb_cfg['lang'][$userdata['user_lang']]['encoding'], 'IN_ADMIN' => defined('IN_ADMIN'), 'SHOW_ADS' => !$logged_in || isset($bb_cfg['show_ads_users'][$user->id]) || !IS_AM && $user->show_ads, 'USER_HIDE_CAT' => BB_SCRIPT == 'index', 'USER_LANG' => $userdata['user_lang'], 'INCLUDE_BBCODE_JS' => !empty($page_cfg['include_bbcode_js']), 'USER_OPTIONS_JS' => IS_GUEST ? '{}' : Zend\Json\Json::encode($user->opt_js), 'USE_TABLESORTER' => !empty($page_cfg['use_tablesorter']), 'SITENAME' => $bb_cfg['sitename'], 'U_INDEX' => BB_ROOT . "index.php", 'T_INDEX' => sprintf($lang['FORUM_INDEX'], $bb_cfg['sitename']), 'IS_GUEST' => IS_GUEST, 'IS_USER' => IS_USER, 'IS_ADMIN' => IS_ADMIN, 'IS_MOD' => IS_MOD, 'IS_AM' => IS_AM, 'FORUM_PATH' => FORUM_PATH, 'FULL_URL' => FULL_URL, 'CURRENT_TIME' => sprintf($lang['CURRENT_TIME'], bb_date(TIMENOW, $bb_cfg['last_visit_date_format'], false)), 'S_TIMEZONE' => preg_replace('/\\(.*?\\)/', '', sprintf($lang['ALL_TIMES'], $lang['TZ'][str_replace(',', '.', floatval($bb_cfg['board_timezone']))])), 'BOARD_TIMEZONE' => $bb_cfg['board_timezone'], 'PM_INFO' => $pm_info, 'PRIVMSG_IMG' => $icon_pm, 'LOGGED_IN' => $logged_in, 'SESSION_USER_ID' => $userdata['user_id'], 'POINTS' => $userdata['user_points'], 'THIS_USER' => profile_url($userdata), 'THIS_AVATAR' => get_avatar($userdata['user_id'], $userdata['avatar_ext_id'], !bf($userdata['user_opt'], 'user_opt', 'dis_avatar')), 'SHOW_LOGIN_LINK' => !defined('IN_LOGIN'), 'AUTOLOGIN_DISABLED' => !$bb_cfg['allow_autologin'], 'S_LOGIN_ACTION' => LOGIN_URL, 'U_CUR_DOWNLOADS' => PROFILE_URL . $userdata['user_id'], 'U_FORUM' => "viewforum.php", 'U_GROUPS' => "group.php", 'U_LOGIN_LOGOUT' => $u_login_logout, 'U_MEMBERLIST' => "memberlist.php", 'U_MODCP' => "modcp.php", 'U_OPTIONS' => "profile.php?mode=editprofile", 'U_PRIVATEMSGS' => PM_URL . "?folder=inbox", 'U_PROFILE' => PROFILE_URL . $userdata['user_id'], 'U_READ_PM' => PM_URL . "?folder=inbox" . ($userdata['user_newest_pm_id'] && $userdata['user_new_privmsg'] == 1 ? "&mode=read&p={$userdata['user_newest_pm_id']}" : ''), 'U_REGISTER' => "profile.php?mode=register", 'U_SEARCH' => "search.php", 'U_SEND_PASSWORD' => "profile.php?mode=sendpassword", 'U_TERMS' => $bb_cfg['terms_and_conditions_url'], 'U_TRACKER' => "tracker.php", 'SHOW_SIDEBAR1' => !empty($page_cfg['show_sidebar1'][BB_SCRIPT]) || $bb_cfg['show_sidebar1_on_every_page'], 'SHOW_SIDEBAR2' => !empty($page_cfg['show_sidebar2'][BB_SCRIPT]) || $bb_cfg['show_sidebar2_on_every_page'], 'HTML_AGREEMENT' => LANG_DIR . 'html/user_agreement.html', 'HTML_COPYRIGHT' => LANG_DIR . 'html/copyright_holders.html', 'HTML_ADVERT' => LANG_DIR . 'html/advert.html', 'HTML_SIDEBAR_1' => LANG_DIR . 'html/sidebar1.html', 'HTML_SIDEBAR_2' => LANG_DIR . 'html/sidebar2.html', 'AVATARS_URL' => 'data/avatars', 'CAT_URL' => BB_ROOT . CAT_URL, 'DOWNLOAD_URL' => BB_ROOT . DOWNLOAD_URL, 'FORUM_URL' => BB_ROOT . FORUM_URL, 'GROUP_URL' => BB_ROOT . GROUP_URL, 'LOGIN_URL' => $bb_cfg['login_url'], 'NEWEST_URL' => '&view=newest#newest', 'PM_URL' => $bb_cfg['pm_url'], 'POST_URL' => BB_ROOT . POST_URL, 'POSTING_URL' => $bb_cfg['posting_url'], 'PROFILE_URL' => BB_ROOT . PROFILE_URL, 'TOPIC_URL' => BB_ROOT . TOPIC_URL, 'AJAX_HTML_DIR' => AJAX_HTML_DIR, 'ONLY_NEW_POSTS' => ONLY_NEW_POSTS, 'ONLY_NEW_TOPICS' => ONLY_NEW_TOPICS, 'BOT_UID' => BOT_UID, 'COOKIE_MARK' => COOKIE_MARK, 'SID' => $userdata['session_id'], 'SID_HIDDEN' => '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />', 'CHECKED' => HTML_CHECKED, 'DISABLED' => HTML_DISABLED, 'READONLY' => HTML_READONLY, 'SELECTED' => HTML_SELECTED, 'U_SEARCH_SELF_BY_LAST' => "search.php?uid={$userdata['user_id']}&o=5", 'U_WATCHED_TOPICS' => "profile.php?mode=watch")); if (!empty($page_cfg['show_torhelp'][BB_SCRIPT]) && !empty($userdata['torhelp'])) { $ignore_time = !empty($_COOKIE['torhelp']) ? (int) $_COOKIE['torhelp'] : 0; if (TIMENOW > $ignore_time) { if ($ignore_time) { bb_setcookie('torhelp', '', COOKIE_EXPIRED); } $sql = "\n\t\t\tSELECT topic_id, topic_title\n\t\t\tFROM " . BB_TOPICS . "\n\t\t\tWHERE topic_id IN(" . $userdata['torhelp'] . ")\n\t\t\tLIMIT 8\n\t\t"; $torhelp_topics = array(); foreach (DB()->fetch_rowset($sql) as $row) { $torhelp_topics[] = '<a href="viewtopic.php?t=' . $row['topic_id'] . '">' . $row['topic_title'] . '</a>'; } $template->assign_vars(array('TORHELP_TOPICS' => join("</li>\n<li>", $torhelp_topics))); } } // Ads