当前位置: 首页>>代码示例>>PHP>>正文


PHP Moxiecode_JSON类代码示例

本文整理汇总了PHP中Moxiecode_JSON的典型用法代码示例。如果您正苦于以下问题:PHP Moxiecode_JSON类的具体用法?PHP Moxiecode_JSON怎么用?PHP Moxiecode_JSON使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Moxiecode_JSON类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: iVolunteer_buildSidebar

function iVolunteer_buildSidebar(&$buf)
{
    $rc = 1;
    // Reset to 0 on success
    // Get the iVolunteer local events list -- returned as XML
    if (($response = iVolunteer_cURL()) == FALSE) {
        // This can happen when the site is found, but the API is down
        // -- just exit
        printf("No opportunities found -- please try later.<br />");
    } elseif (strpos($response, "Not Found")) {
        // This can happen when the site is NOT found -- just exit
        printf("No opportunities found - please try later.<br />");
    } else {
        // Instantiate JSON object
        $json_iVolunteer = new Moxiecode_JSON();
        // Decode the returned JSON
        if (($consolidated = $json_iVolunteer->decode($response)) == 0) {
            // No data came back
            printf("No opportunities found, please try later.<br />");
        } else {
            // Parse JSON and load sidebar buf
            parse_json($consolidated, $buf);
            $rc = 0;
        }
        // NULL the object
        $json_iVolunteer = 0;
    }
    return $rc;
}
开发者ID:ryanschneider,项目名称:ivolunteer,代码行数:29,代码来源:ivolunteer.php

示例2: 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);
}
开发者ID:sudar,项目名称:rolopress-core,代码行数:17,代码来源:note-functions.php

示例3: header

<?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;
开发者ID:TNTCccc,项目名称:jqswfupload,代码行数:9,代码来源:upload.php

示例4: json_decode

 /**
  * 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_decode($obj)
 {
     // Try to use native PHP 5.2+ json_encode
     // Switch back to JSON library included with Tiny MCE
     if (function_exists('json_decode')) {
         return @json_decode($obj);
     } else {
         require_once ABSPATH . "/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php";
         $json_obj = new Moxiecode_JSON();
         $json = $json_obj->decode($obj);
         return $json;
     }
 }
开发者ID:henare,项目名称:salsa-australian-politicians,代码行数:23,代码来源:salsa-core.php

示例5: load_json_file

            function load_json_file($json_file, $theme_name, $context = '')
            {
                $json_error = false;
                // check that config.json exists
                if (file_exists($json_file)) {
                    // attempt to read config.json
                    if (!($read_file = fopen($json_file, 'r'))) {
                        $this->log(wp_kses(__('Read json error', 'tvr-microthemer'), array()), '<p>' . sprintf(wp_kses(__('WordPress was not able to read %s. ', 'tvr-microthemer'), array()), $this->root_rel($json_file)) . '. ' . $this->permissionshelp . '</p>');
                    } else {
                        // get the data
                        $data = fread($read_file, filesize($json_file));
                        fclose($read_file);
                    }
                    // tap into WordPress native JSON functions
                    if (!class_exists('Moxiecode_JSON')) {
                        require_once $this->thisplugindir . 'includes/class-json.php';
                    }
                    $json_object = new Moxiecode_JSON();
                    // convert to array
                    if (!($json_array = $json_object->decode($data))) {
                        $this->log('', '', 'error', 'json-decode', array('json_file', $json_file));
                        $json_error = true;
                    }
                    // Unitless css values may need to be auto-adjusted
                    $filtered_json = $this->filter_json_css_units($json_array);
                    // do for each MQ too
                    if (!empty($filtered_json['non_section']['m_query']) and is_array($filtered_json['non_section']['m_query'])) {
                        foreach ($filtered_json['non_section']['m_query'] as $m_key => $array) {
                            $filtered_json['non_section']['m_query'][$m_key] = $this->filter_json_css_units($array);
                        }
                    }
                    // check what import method the user specified
                    if ($context == 'Overwrite' or empty($context)) {
                        // attempt to decode json into an array
                        if (!($this->options = $filtered_json)) {
                            $this->log('', '', 'error', 'json-decode', array('json_file', $json_file));
                            $json_error = true;
                        }
                    } elseif ($context == 'Merge') {
                        // attempt to decode json into an array
                        if (!($this->to_be_merged = $filtered_json)) {
                            $this->log('', '', 'error', 'json-decode', array('json_file', $json_file));
                            $json_error = true;
                        } else {
                            $this->options = $this->merge($this->options, $this->to_be_merged);
                        }
                    }
                    // json decode was successful
                    if (!$json_error) {
                        $this->log(wp_kses(__('Settings were imported', 'tvr-microthemer'), array()), '<p>' . wp_kses(__('The design pack settings were successfully imported.', 'tvr-microthemer'), array()) . '</p>', 'notice');
                        // check for new mqs
                        $pref_array['m_queries'] = $this->preferences['m_queries'];
                        // check for new media queries in the import
                        $mq_analysis = $this->analyse_mqs($this->options['non_section']['active_queries'], $pref_array['m_queries']);
                        if ($mq_analysis['new']) {
                            // merge the new queries
                            $pref_array['m_queries'] = array_merge($pref_array['m_queries'], $mq_analysis['new']);
                            $this->log(wp_kses(__('Media queries added', 'tvr-microthemer'), array()), '<p>' . wp_kses(__('The design pack you imported contained media queries that are different from the ones used in your current setup. In order for the design pack settings to function correctly, these additional media queries have been imported into your workspace.', 'tvr-microthemer'), array()) . '</p>
								<p>' . sprintf(wp_kses(__('Please <span %s>review (and possibly rename) the imported media queries</span>. Note: imported queries are marked with "(imp)", which you can remove from the label name once you\'ve reviewed them.', 'tvr-microthemer'), array('span' => array())), 'class="link show-dialog" rel="edit-media-queries"') . ' </p>', 'warning');
                        }
                        if ($this->debug_merge) {
                            $debug_file = $this->micro_root_dir . $this->preferences['theme_in_focus'] . '/debug-merge-post.txt';
                            $write_file = fopen($debug_file, 'w');
                            $data = '';
                            $data .= "\n\nThe merged and MQ replaced options\n\n";
                            $data .= print_r($this->options, true);
                            fwrite($write_file, $data);
                            fclose($write_file);
                        }
                        // save settings in db
                        $this->saveUiOptions($this->options);
                        // update active-styles.css
                        $this->update_active_styles($theme_name, $context);
                        // pass the context so the function doesn't update theme_in_focus
                        // Only update theme_in_focus if it's not a merge
                        if ($context != 'Merge') {
                            $pref_array['theme_in_focus'] = $theme_name;
                        }
                        // update the preferences if not merge or media queries need importing
                        if ($context != 'Merge' or $mq_analysis['new']) {
                            $this->savePreferences($pref_array);
                        }
                    }
                } else {
                    $this->log(wp_kses(__('Config file missing', 'tvr-microthemer'), array()), '<p>' . sprintf(wp_kses(__('%1$s settings file could not be loaded because it doesn\'t exist in %2$s', 'tvr-microthemer'), array()), $this->root_rel($json_file), '<i>' . $this->readable_name($theme_name) . '</i>.') . '</p>');
                }
            }
开发者ID:noikiy,项目名称:microthemer,代码行数:87,代码来源:tvr-microthemer.php

示例6: _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);
}
开发者ID:nunomorgadinho,项目名称:SimplePhone,代码行数:13,代码来源:contact-functions.php

示例7: return_json

 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 ")";
     }
 }
开发者ID:hscale,项目名称:webento,代码行数:17,代码来源:autoblogadmin.php

示例8: fsockopen

    $socket = fsockopen($url['host'], intval($url['port']), $errno, $errstr, 30);
    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);
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:31,代码来源:rpc.php

示例9: array

    require_once "../" . $path;
}
// Dispatch onAuthenticate event
if ($man->isAuthenticated()) {
    if ($_SERVER["REQUEST_METHOD"] == "GET") {
        $args = $_GET;
        // Dispatch event before starting to stream
        $man->dispatchEvent("onBeforeStream", array($cmd, &$args));
        // 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>';
开发者ID:pombredanne,项目名称:mondo-license-grinder,代码行数:31,代码来源:stream.php

示例10: while

        if ($fp) {
            $raw = "";
            while (!feof($fp)) {
                $raw = fread($fp, 1024);
            }
            fclose($fp);
        }
    } else {
        $raw = "" . file_get_contents("php://input");
    }
}
if ($raw == "") {
    die('{"result":null,"id":null,"error":{"errstr":"Could not get raw post data.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
}
// Get JSON data
$json = new Moxiecode_JSON();
$input = $json->decode($raw);
// Parse prefix and method
$chunks = explode('.', $input['method']);
$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));
开发者ID:manis6062,项目名称:sagarmathaonline,代码行数:31,代码来源:rpc.php

示例11: array

    require_once "../" . $path;
}
// Dispatch onAuthenticate event
if ($man->isAuthenticated()) {
    if ($_SERVER["REQUEST_METHOD"] == "GET") {
        $args = $_GET;
        // Dispatch event before starting to stream
        $man->dispatchEvent("onBeforeStream", array($cmd, &$args));
        // 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));
            // Flash can't get our nice JSON output, so we need to return something... weird.
            if (isset($_GET["format"]) && $_GET["format"] == "flash") {
                if ($result->getRowCount() > 0) {
                    $row = $result->getRow(0);
                    switch ($row["status"]) {
                        case "OK":
                            // No header needed, 200 OK!
                            break;
                        case "DEMO_ERROR":
                        case "ACCESS_ERROR":
                        case "MCACCESS_ERROR":
开发者ID:oaki,项目名称:demoshop,代码行数:31,代码来源:stream.php

示例12: 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);
        }
    }
}
开发者ID:rajankz,项目名称:webspace,代码行数:16,代码来源:common.php

示例13: doApiRequest

 function doApiRequest($action, $params, $method = 'POST')
 {
     $this->success = false;
     $url = "{$this->protocol}://{$this->base_url}/{$action}";
     if ($method == 'GET' && count($params) > 0) {
         $url .= "?" . http_build_query($params);
     }
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_REFERER, "");
     curl_setopt($ch, CURLOPT_USERPWD, "{$this->user}:{$this->key}");
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     switch (strtoupper($method)) {
         case 'POST':
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
             break;
         case 'DELETE':
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
             break;
         case 'PUT':
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
             curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
             //curl_setopt ($ch, CURLOPT_HTTPHEADER, array ("Content-Type: application/x-www-form-urlencoded\n"));
             break;
     }
     //curl_setopt($ch, CURLOPT_CAINFO, "cacert.pem");
     $raw = curl_exec($ch);
     if ($raw === false) {
         return false;
     }
     //throw new Exception(curl_error($ch), null);
     $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     curl_close($ch);
     if (function_exists('json_decode')) {
         $response = json_decode($raw, true);
     } else {
         if (class_exists("Moxiecode_JSON")) {
             $json = new Moxiecode_JSON();
             $response = $json->decode($raw);
         } else {
             die("DPD Cart API error: No JSON parser is available");
         }
     }
     if ($http_code != '200') {
         return false;
     }
     $this->success = true;
     return $response;
 }
开发者ID:jcoby,项目名称:dpd-api,代码行数:51,代码来源:DPDCartApi.class.php

示例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;
}
开发者ID:alexanmtz,项目名称:M-dulo-de-pagamento-para-wordpress,代码行数:11,代码来源:modulo_pagseguro.php

示例15: json_encode

 /**
  * 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 '';
     }
 }
开发者ID:OutThisLife,项目名称:HTW,代码行数:22,代码来源:shadow_plugin_framework.php


注:本文中的Moxiecode_JSON类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。