本文整理匯總了PHP中IPSText::simpleJsonEncode方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSText::simpleJsonEncode方法的具體用法?PHP IPSText::simpleJsonEncode怎麽用?PHP IPSText::simpleJsonEncode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPSText
的用法示例。
在下文中一共展示了IPSText::simpleJsonEncode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: fetchBbcodeAsJson
/**
* Fetch bbcode as JSON for editors, etc
*
* @access public
* @return string JSON
*/
public static function fetchBbcodeAsJson()
{
$bbcodes = array();
$protectedBbcodes = array('right', 'left', 'center', 'b', 'i', 'u', 'url', 'img', 'quote', 'indent', 'list', 'strike', 'sub', 'sup', 'email', 'background', 'color', 'size', 'font', 'media');
foreach (ipsRegistry::cache()->getCache('bbcode') as $bbcode) {
if (in_array($bbcode['bbcode_tag'], $protectedBbcodes)) {
continue;
}
if ($bbcode['bbcode_groups'] != 'all') {
$pass = false;
$groups = array_diff(explode(',', $bbcode['bbcode_groups']), array(''));
$mygroups = array(ipsRegistry::member()->getProperty('member_group_id'));
$mygroups = array_diff(array_merge($mygroups, explode(',', IPSText::cleanPermString(ipsRegistry::member()->getProperty('mgroup_others')))), array(''));
foreach ($groups as $g_id) {
if (in_array($g_id, $mygroups)) {
$pass = true;
break;
}
}
if (!$pass) {
continue;
}
}
$bbcodes[$bbcode['bbcode_tag']] = array('id' => $bbcode['bbcode_id'], 'title' => $bbcode['bbcode_title'], 'desc' => $bbcode['bbcode_desc'], 'tag' => $bbcode['bbcode_tag'], 'useoption' => $bbcode['bbcode_useoption'], 'example' => $bbcode['bbcode_example'], 'switch_option' => $bbcode['bbcode_switch_option'], 'menu_option_text' => $bbcode['bbcode_menu_option_text'], 'menu_content_text' => $bbcode['bbcode_menu_content_text'], 'single_tag' => $bbcode['bbcode_single_tag'], 'optional_option' => $bbcode['bbcode_optional_option'], 'image' => $bbcode['bbcode_image']);
}
return IPSText::simpleJsonEncode($bbcodes);
}
示例2: _generatePollBox
/**
* Generates the poll box
*
* @param string Form type (new/edit/reply)
* @return string HTML
* @author MattMecham
* @access protected
*/
protected function _generatePollBox($formType)
{
if ($this->can_add_poll) {
//-----------------------------------------
// Did someone hit preview / do we have
// post info?
//-----------------------------------------
$poll_questions = array();
$poll_question = "";
$poll_view_voters = 0;
$poll_choices = array();
$show_open = 0;
$is_mod = 0;
$poll_votes = array();
$poll_only = array();
$poll_multi = array();
if (isset($_POST['question']) and is_array($_POST['question']) and count($_POST['question'])) {
foreach ($_POST['question'] as $id => $question) {
$poll_questions[$id] = $question;
}
$poll_question = ipsRegistry::$request['poll_question'];
$show_open = 1;
}
if (isset($_POST['multi']) and is_array($_POST['multi']) and count($_POST['multi'])) {
foreach ($_POST['multi'] as $id => $checked) {
$poll_multi[$id] = $checked;
}
}
if (isset($_POST['choice']) and is_array($_POST['choice']) and count($_POST['choice'])) {
foreach ($_POST['choice'] as $id => $choice) {
$poll_choices[$id] = $choice;
}
}
if ($formType == 'edit') {
if (isset($_POST['votes']) && is_array($_POST['votes']) and count($_POST['votes'])) {
foreach ($_POST['votes'] as $id => $vote) {
$poll_votes[$id] = $vote;
}
}
}
$poll_only = 0;
if ($this->settings['ipb_poll_only'] and ipsRegistry::$request['poll_only'] and ipsRegistry::$request['poll_only'] == 1) {
$poll_only = 1;
}
if ($formType == 'edit' and (!isset($_POST['question']) or !is_array($_POST['question']) or !count($_POST['question']))) {
//-----------------------------------------
// Load the poll from the DB
//-----------------------------------------
$this->poll_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'polls', 'where' => "tid=" . $this->getTopicID()));
$this->poll_answers = $this->poll_data['choices'] ? unserialize(stripslashes($this->poll_data['choices'])) : array();
//-----------------------------------------
// Lezz go
//-----------------------------------------
foreach ($this->poll_answers as $question_id => $data) {
if (!$data['question'] or !is_array($data['choice'])) {
continue;
}
$poll_questions[$question_id] = $data['question'];
$poll_multi[$question_id] = isset($data['multi']) ? intval($data['multi']) : 0;
foreach ($data['choice'] as $choice_id => $text) {
$poll_choices[$question_id . '_' . $choice_id] = $text;
$poll_votes[$question_id . '_' . $choice_id] = intval($data['votes'][$choice_id]);
}
}
$poll_only = 0;
if ($this->settings['ipb_poll_only'] and $this->poll_data['poll_only'] == 1) {
$poll_only = "checked='checked'";
}
$poll_view_voters = $this->poll_data['poll_view_voters'];
$poll_question = $this->poll_data['poll_question'];
$show_open = $this->poll_data['choices'] ? 1 : 0;
$is_mod = $this->can_add_poll_mod;
} else {
$poll_view_voters = $this->request['poll_view_voters'];
}
return $this->registry->getClass('output')->getTemplate('post')->pollBox($this->max_poll_questions, $this->max_poll_choices_per_question, IPSText::simpleJsonEncode($poll_questions), IPSText::simpleJsonEncode($poll_choices), IPSText::simpleJsonEncode($poll_votes), $show_open, $poll_question, $is_mod, json_encode($poll_multi), $poll_only, $poll_view_voters, intval($this->poll_data['votes']));
}
return '';
}
示例3: fetchBbcodeAsJson
/**
* Fetch bbcode as JSON for editors, etc
*
* @return string JSON
*/
public static function fetchBbcodeAsJson($filter = array())
{
$bbcodes = array();
$currentBbcodes = ipsRegistry::cache()->getCache('bbcode');
if ($filter['noParseOnly'] == 1) {
/* Find no parse codes */
$noParse = array();
foreach ($currentBbcodes as $bbcode) {
/* Allowed this BBCode? */
if ($bbcode['bbcode_no_parsing']) {
/* CODE is a special case */
if ($bbcode['bbcode_tag'] != 'code') {
$noParse[] = $bbcode['bbcode_tag'];
}
}
}
return json_encode($noParse);
}
/* Normal method */
$protectedBbcodes = array('right', 'left', 'center', 'b', 'i', 'u', 'url', 'img', 'quote', 'indent', 'snapback', 'list', 'strike', 'sub', 'sup', 'email', 'color', 'size', 'font');
/* Remove protected bbcodes */
foreach ($protectedBbcodes as $_key) {
unset($currentBbcodes[$_key]);
}
/* Get all others */
foreach ($currentBbcodes as $bbcode) {
if ($bbcode['bbcode_groups'] != 'all') {
$pass = false;
$groups = array_diff(explode(',', $bbcode['bbcode_groups']), array(''));
$mygroups = array(ipsRegistry::member()->getProperty('member_group_id'));
$mygroups = array_diff(array_merge($mygroups, explode(',', IPSText::cleanPermString(ipsRegistry::member()->getProperty('mgroup_others')))), array(''));
foreach ($groups as $g_id) {
if (in_array($g_id, $mygroups)) {
$pass = true;
break;
}
}
if (!$pass) {
continue;
}
}
if (!empty($filter['skip']) && is_array($filter['skip'])) {
if (in_array($bbcode['bbcode_tag'], $filter['skip'])) {
continue;
}
}
$bbcodes[$bbcode['bbcode_tag']] = array('id' => $bbcode['bbcode_id'], 'title' => $bbcode['bbcode_title'], 'desc' => $bbcode['bbcode_desc'], 'tag' => $bbcode['bbcode_tag'], 'useoption' => $bbcode['bbcode_useoption'], 'example' => $bbcode['bbcode_example'], 'switch_option' => $bbcode['bbcode_switch_option'], 'menu_option_text' => $bbcode['bbcode_menu_option_text'], 'menu_content_text' => $bbcode['bbcode_menu_content_text'], 'single_tag' => $bbcode['bbcode_single_tag'], 'optional_option' => $bbcode['bbcode_optional_option'], 'aliases' => explode(',', $bbcode['bbcode_aliases']), 'image' => $bbcode['bbcode_image']);
}
return IPSText::simpleJsonEncode($bbcodes);
}
示例4: _generatePollBox
/**
* Generates the poll box
*
* @param string Form type (new/edit/reply)
* @return string HTML
* @author MattMecham
*/
protected function _generatePollBox($formType)
{
if ($this->can_add_poll) {
//-----------------------------------------
// Did someone hit preview / do we have
// post info?
//-----------------------------------------
$poll_questions = array();
$poll_question = "";
$poll_view_voters = 0;
$poll_choices = array();
$show_open = 0;
$is_mod = 0;
$poll_votes = array();
$poll_only = 0;
$poll_multi = array();
if ($this->settings['ipb_poll_only'] and ipsRegistry::$request['poll_only'] and ipsRegistry::$request['poll_only'] == 1) {
$poll_only = 1;
}
if (isset($_POST['question']) and is_array($_POST['question']) and count($_POST['question'])) {
foreach ($_POST['question'] as $id => $question) {
$poll_questions[$id] = IPSText::parseCleanValue($question);
}
$poll_question = ipsRegistry::$request['poll_question'];
$show_open = 1;
}
if (isset($_POST['multi']) and is_array($_POST['multi']) and count($_POST['multi'])) {
foreach ($_POST['multi'] as $id => $checked) {
$poll_multi[$id] = $checked;
}
}
if (isset($_POST['choice']) and is_array($_POST['choice']) and count($_POST['choice'])) {
foreach ($_POST['choice'] as $id => $choice) {
$poll_choices[$id] = IPSText::parseCleanValue($choice);
}
}
if ($formType == 'edit') {
if (isset($_POST['votes']) && is_array($_POST['votes']) and count($_POST['votes'])) {
foreach ($_POST['votes'] as $id => $vote) {
$poll_votes[$id] = $vote;
}
}
}
if ($formType == 'edit' and (!isset($_POST['question']) or !is_array($_POST['question']) or !count($_POST['question']) or $this->getIsPreview())) {
//-----------------------------------------
// Load the poll from the DB
//-----------------------------------------
$this->poll_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'polls', 'where' => "tid=" . $this->getTopicID()));
$this->poll_answers = IPSLib::safeUnserialize(stripslashes($this->poll_data['choices']));
if (!is_array($this->poll_answers) or !count($this->poll_answers)) {
$this->poll_answers = IPSLib::safeUnserialize(preg_replace('!s:(\\d+):"(.*?)";!se', "'s:'.strlen('\$2').':\"\$2\";'", stripslashes($this->poll_data['choices'])));
}
if (!is_array($this->poll_answers) or !count($this->poll_answers)) {
$this->poll_answers = array();
}
//-----------------------------------------
// Lezz go
//-----------------------------------------
foreach ($this->poll_answers as $question_id => $data) {
if (!$data['question'] or !is_array($data['choice'])) {
continue;
}
$poll_questions[$question_id] = $data['question'];
$poll_multi[$question_id] = isset($data['multi']) ? intval($data['multi']) : 0;
foreach ($data['choice'] as $choice_id => $text) {
$poll_choices[$question_id . '_' . $choice_id] = stripslashes($text);
$poll_votes[$question_id . '_' . $choice_id] = intval($data['votes'][$choice_id]);
}
}
$poll_only = 0;
if ($this->settings['ipb_poll_only'] and $this->poll_data['poll_only'] == 1) {
$poll_only = 1;
}
$poll_view_voters = $this->poll_data['poll_view_voters'];
$poll_question = $this->poll_data['poll_question'];
$show_open = $this->poll_data['choices'] ? 1 : 0;
$is_mod = $this->can_add_poll_mod;
} else {
$poll_view_voters = $this->request['poll_view_voters'];
}
return $this->registry->getClass('output')->getTemplate('post')->pollBox(array('max_poll_questions' => $this->max_poll_questions, 'max_poll_choices' => $this->max_poll_choices_per_question, 'poll_questions' => IPSText::simpleJsonEncode($poll_questions), 'poll_choices' => IPSText::simpleJsonEncode($poll_choices), 'poll_votes' => IPSText::simpleJsonEncode($poll_votes), 'show_open' => $show_open, 'poll_question' => $poll_question, 'is_mod' => $is_mod, 'poll_multi' => json_encode($poll_multi), 'poll_only' => $poll_only, 'poll_view_voters' => $poll_view_voters, 'poll_total_votes' => intval($this->poll_data['votes']), 'poll_data' => $this->poll_data, 'poll_answers' => $this->poll_answers));
}
return '';
}