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


PHP common::JsonEncode方法代码示例

本文整理汇总了PHP中common::JsonEncode方法的典型用法代码示例。如果您正苦于以下问题:PHP common::JsonEncode方法的具体用法?PHP common::JsonEncode怎么用?PHP common::JsonEncode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common的用法示例。


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

示例1: MenuData

 function MenuData($data)
 {
     $data = common::JsonEncode($data);
     echo '<span style="display:none">' . htmlspecialchars($data, ENT_NOQUOTES) . '</span>';
 }
开发者ID:rizub4u,项目名称:gpEasy-CMS,代码行数:5,代码来源:admin_menu_new.php

示例2: MenuLink

 /**
  * Output Sortable Menu Link and data about the title or external link
  *
  */
 function MenuLink($data, $external = false)
 {
     $class = 'gp_label sort';
     if ($external) {
         $class .= ' external';
     }
     $json = common::JsonEncode($data);
     echo '<a class="' . $class . '" data-cmd="menu_info" data-arg="' . str_replace('&', '&amp;', $data['key']) . '" data-json=\'' . htmlspecialchars($json, ENT_QUOTES & ~ENT_COMPAT) . '\'>';
 }
开发者ID:GedionChang,项目名称:gpEasy-CMS,代码行数:13,代码来源:admin_menu_new.php

示例3: InlineEdit

 static function InlineEdit($section_data)
 {
     $section_data += array('type' => '', 'content' => '');
     $scripts = array();
     $scripts[] = '/include/js/inline_edit/inline_editing.js';
     $type = 'text';
     if (!empty($section_data['type'])) {
         $type = $section_data['type'];
     }
     switch ($type) {
         case 'gallery':
             $scripts = gpAjax::InlineEdit_Gallery($scripts);
             break;
         case 'include':
             $scripts = gpAjax::InlineEdit_Include($scripts);
             break;
         case 'text':
             $scripts = gpAjax::InlineEdit_Text($scripts);
             break;
         case 'image':
             echo 'var gp_blank_img = ' . gpAjax::quote(common::GetDir('/include/imgs/blank.gif')) . ';';
             $scripts[] = '/include/js/jquery.auto_upload.js';
             $scripts[] = '/include/js/inline_edit/image_common.js';
             $scripts[] = '/include/js/inline_edit/image_edit.js';
             break;
     }
     $scripts = gpPlugin::Filter('InlineEdit_Scripts', array($scripts, $type));
     self::SendScripts($scripts);
     //replace resized images with their originals
     if (isset($section_data['resized_imgs']) && is_array($section_data['resized_imgs']) && count($section_data['resized_imgs'])) {
         includeFile('tool/editing.php');
         $section_data['content'] = gp_edit::RestoreImages($section_data['content'], $section_data['resized_imgs']);
     }
     //create the section object that will be passed to gp_init_inline_edit
     $section_object = common::JsonEncode($section_data);
     //send call to gp_init_inline_edit()
     echo ';if( typeof(gp_init_inline_edit) == "function" ){';
     echo 'gp_init_inline_edit(';
     echo gpAjax::quote($_GET['area_id']);
     echo ',' . $section_object;
     echo ');';
     echo '}else{alert("gp_init_inline_edit() is not defined");}';
 }
开发者ID:GedionChang,项目名称:gpEasy-CMS,代码行数:43,代码来源:ajax.php

示例4: JsonEncode

 /**
  * A more functional JSON Encode function for gpEasy than php's json_encode
  * @param mixed $data
  *
  */
 static function JsonEncode($data)
 {
     static $search = array('\\', '"', "\n", "\r", "\t", '<script', '</script>');
     static $repl = array('\\\\', '\\"', '\\n', '\\r', '\\t', '<"+"script', '<"+"/script>');
     $type = gettype($data);
     switch ($type) {
         case 'NULL':
             return 'null';
         case 'boolean':
             return $data ? 'true' : 'false';
         case 'integer':
         case 'double':
         case 'float':
             return $data;
         case 'string':
             return '"' . str_replace($search, $repl, $data) . '"';
         case 'object':
             $data = get_object_vars($data);
         case 'array':
             $output_index_count = 0;
             $output_indexed = array();
             $output_associative = array();
             foreach ($data as $key => $value) {
                 $output_indexed[] = common::JsonEncode($value);
                 $output_associative[] = common::JsonEncode($key) . ':' . common::JsonEncode($value);
                 if ($output_index_count !== NULL && $output_index_count++ !== $key) {
                     $output_index_count = NULL;
                 }
             }
             if ($output_index_count !== NULL) {
                 return '[' . implode(',', $output_indexed) . ']';
             } else {
                 return '{' . implode(',', $output_associative) . '}';
             }
         default:
             return '';
             // Not supported
     }
 }
开发者ID:Knuzen,项目名称:gpEasy-CMS,代码行数:44,代码来源:common.php

示例5: InlineEdit

 function InlineEdit($section_data)
 {
     global $dataDir, $dirPrefix;
     $section_data += array('type' => '', 'content' => '');
     header('Content-type: application/x-javascript');
     $type = $section_data['type'];
     $scripts = array();
     $scripts[] = '/include/js/inline_edit/inline_editing.js';
     //$scripts[] = '/include/thirdparty/jquery_ui/jquery-ui.custom.min.js';
     $type = 'text';
     if (!empty($section_data['type'])) {
         $type = $section_data['type'];
     }
     switch ($section_data['type']) {
         case 'gallery':
             $scripts = gpAjax::InlineEdit_Gallery($scripts);
             break;
         case 'include':
             $scripts = gpAjax::InlineEdit_Include($scripts);
             break;
         case 'text':
             $scripts = gpAjax::InlineEdit_Text($scripts);
             break;
     }
     $scripts = gpPlugin::Filter('InlineEdit_Scripts', array($scripts, $type));
     $scripts = array_unique($scripts);
     //send all scripts
     foreach ($scripts as $script) {
         //absolute paths don't need $dataDir
         $full_path = $script;
         if (strpos($script, $dataDir) !== 0) {
             //fix addon paths that use $addonRelativeCode
             if (!empty($dirPrefix) && strpos($script, $dirPrefix) === 0) {
                 $script = substr($script, strlen($dirPrefix));
             }
             $full_path = $dataDir . $script;
         }
         if (!file_exists($full_path)) {
             echo 'if(isadmin){alert("Admin Notice: The following file could not be found: \\n\\n' . addslashes($full_path) . '");}';
             continue;
         }
         echo ';';
         //echo "\n/**\n* $script\n*\n*/\n";
         readfile($full_path);
     }
     //replace resized images with their originals
     if (is_array($section_data['resized_imgs']) && count($section_data['resized_imgs'])) {
         includeFile('tool/editing.php');
         $section_data['content'] = gp_edit::RestoreImages($section_data['content'], $section_data['resized_imgs']);
     }
     //create the section object that will be passed to gp_init_inline_edit
     $section_object = common::JsonEncode($section_data);
     //send call to gp_init_inline_edit()
     echo ';if( typeof(gp_init_inline_edit) == "function" ){';
     echo 'gp_init_inline_edit(';
     echo gpAjax::quote($_GET['area_id']);
     echo ',' . $section_object;
     echo ');';
     echo '}else{alert("gp_init_inline_edit() is not defined");}';
 }
开发者ID:rizub4u,项目名称:gpEasy-CMS,代码行数:60,代码来源:ajax.php


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