本文整理汇总了PHP中Moxiecode_JSON::encode方法的典型用法代码示例。如果您正苦于以下问题:PHP Moxiecode_JSON::encode方法的具体用法?PHP Moxiecode_JSON::encode怎么用?PHP Moxiecode_JSON::encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Moxiecode_JSON
的用法示例。
在下文中一共展示了Moxiecode_JSON::encode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rolo_edit_note_callback
/**
* callback function for inline note edits
*/
function rolo_edit_note_callback()
{
$new_value = $_POST['new_value'];
$note_id = $_POST['note_id'];
$note_id = substr($note_id, strripos($note_id, "-") + 1);
$current_comment = get_comment($note_id, ARRAY_A);
$current_comment['comment_content'] = $new_value;
wp_update_comment($current_comment);
$results = array('is_error' => false, 'error_text' => '', 'html' => $new_value);
include_once ABSPATH . 'wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php';
$json = new Moxiecode_JSON();
$results = $json->encode($results);
die($results);
}
示例2: StreamErrorHandler
/**
* Calls the MCError class, returns true.
*
* @param Int $errno Number of the error.
* @param String $errstr Error message.
* @param String $errfile The file the error occured in.
* @param String $errline The line in the file where error occured.
* @param Array $errcontext Error context array, contains all variables.
* @return Bool Just return true for now.
*/
function StreamErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
{
global $MCErrorHandler;
// Ignore these
if ($errno == E_STRICT) {
return true;
}
// Just pass it through to the class.
$data = $MCErrorHandler->handleError($errno, $errstr, $errfile, $errline, $errcontext);
if ($data['break']) {
if ($_SERVER["REQUEST_METHOD"] == "GET") {
header("HTTP/1.1 500 Internal server error");
die($errstr);
} else {
unset($data['break']);
unset($data['title']);
$data['level'] = "FATAL";
$json = new Moxiecode_JSON();
$result = new stdClass();
$result->result = null;
$result->id = 'err';
$result->error = $data;
echo '<html><body><script type="text/javascript">parent.handleJSON(' . $json->encode($result) . ');</script></body></html>';
die;
}
}
}
示例3: array
// Check command, do command, stream file.
$man->dispatchEvent("onStream", array($cmd, &$args));
// Dispatch event after stream
$man->dispatchEvent("onAfterStream", array($cmd, &$args));
} else {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$args = array_merge($_POST, $_GET);
$json = new Moxiecode_JSON();
// Dispatch event before starting to stream
$man->dispatchEvent("onBeforeUpload", array($cmd, &$args));
// Check command, do command, stream file.
$result = $man->executeEvent("onUpload", array($cmd, &$args));
$data = $result->toArray();
if (isset($args["chunk"])) {
// Output JSON response to multiuploader
die('{method:\'' . $method . '\',result:' . $json->encode($data) . ',error:null,id:\'m0\'}');
} else {
// Output JSON function
echo '<html><body><script type="text/javascript">';
if (isset($args["domain"]) && $args["domain"]) {
echo 'document.domain="' . $args["domain"] . '";';
}
echo 'parent.handleJSON({method:\'' . $method . '\',result:' . $json->encode($data) . ',error:null,id:\'m0\'});</script></body></html>';
}
// Dispatch event after stream
$man->dispatchEvent("onAfterUpload", array($cmd, &$args));
}
}
} else {
if (isset($_GET["format"]) && $_GET["format"] == "flash") {
header("HTTP/1.1 405 Method Not Allowed");
示例4: header
function return_json($results)
{
// Check for callback
if (isset($_GET['callback'])) {
// Add the relevant header
header('Content-type: text/javascript');
echo addslashes($_GET['callback']) . " (";
} else {
if (isset($_GET['pretty'])) {
// Will output pretty version
header('Content-type: text/html');
} else {
//header('Content-type: application/json');
//header('Content-type: text/javascript');
}
}
if (function_exists('json_encode')) {
echo json_encode($results);
} else {
// PHP4 version
require_once ABSPATH . "wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php";
$json_obj = new Moxiecode_JSON();
echo $json_obj->encode($results);
}
if (isset($_GET['callback'])) {
echo ")";
}
}
示例5: elseif
/**
* Backwards compatible json_encode.
*
* @param mixed $data
* @return string
*/
function json_encode($data)
{
if (function_exists('json_encode')) {
return json_encode($data);
}
if (class_exists('Services_JSON')) {
$json = new Services_JSON();
return $json->encodeUnsafe($data);
} elseif (class_exists('Moxiecode_JSON')) {
$json = new Moxiecode_JSON();
return $json->encode($data);
} else {
trigger_error('No JSON parser available', E_USER_ERROR);
return '';
}
}
示例6:
<?php
include 'JSON.php';
header('Content-type: application/json');
$files = $_FILES['Filedata'];
$json_obj = new Moxiecode_JSON();
/* encode */
$json = $json_obj->encode($files);
echo $json;
示例7: json_encode
/**
* Encode JSON objects
*
* A wrapper for JSON encode methods. Pass in the PHP array and get a string
* in return that is formatted as JSON.
*
* @param $obj - the array to be encoded
*
* @return string that is formatted as JSON
*/
public function json_encode($obj)
{
// Try to use native PHP 5.2+ json_encode
// Switch back to JSON library included with Tiny MCE
if (function_exists('json_encode')) {
return json_encode($obj);
} else {
require_once ABSPATH . "/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php";
$json_obj = new Moxiecode_JSON();
$json = $json_obj->encode($obj);
return $json;
}
}
示例8: addslashes
function return_json($results)
{
if (isset($_GET['callback'])) {
echo addslashes($_GET['callback']) . " (";
}
if (function_exists('json_encode')) {
echo json_encode($results);
} else {
// PHP4 version
require_once ABSPATH . "wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php";
$json_obj = new Moxiecode_JSON();
echo $json_obj->encode($results);
}
if (isset($_GET['callback'])) {
echo ")";
}
}
示例9: _rolo_edit_callback_success
/**
* helper function for callback function
* @param <type> $new_value
* @since 0.1
*/
function _rolo_edit_callback_success($new_value)
{
$results = array('is_error' => false, 'error_text' => '', 'html' => $new_value);
include_once ABSPATH . 'wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php';
$json = new Moxiecode_JSON();
$results = $json->encode($results);
die($results);
}
示例10:
function json_encode($str)
{
$json = new Moxiecode_JSON();
return $json->encode($str);
}
示例11: die
$type = $chunks[0];
$input['method'] = $chunks[1];
// Clean up type, only a-z stuff.
$type = preg_replace("/[^a-z]/i", "", $type);
if ($type == "") {
die('{"result":null,"id":null,"error":{"errstr":"No type set.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
}
// Include Base and Core and Config.
$man = new Moxiecode_ManagerEngine($type);
require_once $basepath . "CorePlugin.php";
require_once "../config.php";
$man->dispatchEvent("onPreInit", array($type));
$config =& $man->getConfig();
// Include all plugins
$pluginPaths = $man->getPluginPaths();
foreach ($pluginPaths as $path) {
require_once "../" . $path;
}
// Dispatch onInit event
if ($man->isAuthenticated()) {
$man->dispatchEvent("onBeforeRPC", array($input['method'], $input['params'][0]));
$result = new stdClass();
$result->result = $man->executeEvent("onRPC", array($input['method'], $input['params'][0]));
$result->id = $input['id'];
$result->error = null;
$data = $json->encode($result);
//header('Content-Length: ' . strlen($data));
die($data);
} else {
die('{"result":{"login_url":"' . addslashes($config["authenticator.login_page"]) . '"},"id":null,"error":{"errstr":"Access denied by authenicator.","errfile":"","errline":null,"errcontext":"","level":"AUTH"}}');
}
示例12: header
header("HTTP/1.1 409 Conflict");
die('status=' . $row["status"]);
break;
case "RW_ERROR":
header("HTTP/1.1 412 Precondition Failed");
die('status=' . $row["status"]);
break;
case "SIZE_ERROR":
header("HTTP/1.1 414 Request-URI Too Long");
die('status=' . $row["status"]);
break;
default:
header("HTTP/1.1 501 Not Implemented");
die('status=' . $row["status"]);
}
}
} else {
// Output JSON function
$data = $result->toArray();
echo '<html><body><script type="text/javascript">parent.handleJSON({method:\'' . $method . '\',result:' . $json->encode($data) . ',error:null,id:\'m0\'});</script></body></html>';
}
// Dispatch event after stream
$man->dispatchEvent("onAfterUpload", array($cmd, &$args));
}
}
} else {
if (isset($_GET["format"]) && $_GET["format"] == "flash") {
header("HTTP/1.1 405 Method Not Allowed");
}
die('{"result":{login_url:"' . addslashes($config["authenticator.login_page"]) . '"},"id":null,"error":{"errstr":"Access denied by authenicator.","errfile":"","errline":null,"errcontext":"","level":"AUTH"}}');
}
示例13: FA_lite_json
/**
* Creates a JSON string from an array
* @param array $array
*/
function FA_lite_json($array)
{
if (function_exists('json_encode')) {
return json_encode($array);
} else {
if (file_exists(ABSPATH . '/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php')) {
require_once ABSPATH . '/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php';
$json_obj = new Moxiecode_JSON();
return $json_obj->encode($array);
}
}
}
示例14: modulo_venda_obter_info
function modulo_venda_obter_info()
{
$envio = $_POST['envio'];
$pagamento = $_POST['pagamento'];
$modulo = array('opcoes-de-envio' => array('PAC' => array('titulo' => 'Encomenda Normal', 'conteudo' => 'o PAC é mais barato que o sedex.<br /> Prazo de entrega: 6 dias úteis. Envio totalmente rastreado.', 'link' => 'http://www.correios.com.br/encomendas/servicos/Pac/default.cfm'), 'Sedex' => array('titulo' => 'Sedex', 'conteudo' => 'Com o Sedex, o tempo médio de entrega é de 48 horas e a encomenda é totalmente rastreável', 'link' => 'http://www.correios.com.br/encomendas/servicos/Sedex/sedex.cfm'), 'Grátis' => array('titulo' => 'Grátis', 'conteudo' => 'O frete está incluído no preço do guia. <br />Prazo de entrega: 6 dias úteis. Envio totalmente rastreado.')), 'opcoes-de-pagamento' => array('Cartão de crédito ou boleto bancário (via pagseguro)' => array('titulo' => 'Pagseguro', 'conteudo' => 'O Pagseguro é um serviço prático e seguro de efetuar pagamentos online. Não é necessário se cadastrar, não tem custo adicional para o comprador e possui as maiorias de formas de pagamento disponíveis no mercado, além de ter o cálculo de frete próprio.', 'link' => 'https://pagseguro.uol.com.br/para_voce/como_funciona.jhtml'), 'Transferência bancária' => array('titulo' => 'Transferência bancária', 'conteudo' => 'Através do Blog você poderá efetuar a compra e o vendedor entrará em contato fornecendo o número da conta. Após o pagamento ser efetuado, a mercadoria é enviada no modo de entrega escolhido. O valor do frete é enviado pelo vendedor')));
$json_obj = new Moxiecode_JSON();
/* encode */
$json = $json_obj->encode($modulo[$pagamento][$envio]);
echo $json;
die;
}
示例15: fputs
if ($socket) {
// Send request headers
fputs($socket, $req);
// Read response headers and data
$resp = "";
while (!feof($socket)) {
$resp .= fgets($socket, 4096);
}
fclose($socket);
// Split response header/data
$resp = explode("\r\n\r\n", $resp);
echo $resp[1];
// Output body
}
die;
}
// Get JSON data
$json = new Moxiecode_JSON();
$input = $json->decode($raw);
// Execute RPC
if (isset($config['general.engine'])) {
$spellchecker = new $config['general.engine']($config);
$result = call_user_func_array(array($spellchecker, $input['method']), $input['params']);
} else {
die('{"result":null,"id":null,"error":{"errstr":"You must choose an spellchecker engine in the config.php file.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
}
// Request and response id should always be the same
$output = array("id" => $input->id, "result" => $result, "error" => null);
// Return JSON encoded string
echo $json->encode($output);