enhanced codepot_json_encode

This commit is contained in:
hyung-hwan 2016-01-13 13:13:13 +00:00
parent 4be7715d2b
commit 3bad9dc8c0
2 changed files with 8 additions and 8 deletions

View File

@ -76,9 +76,13 @@ if ( ! function_exists('codepot_dbdatetodispdate'))
if ( !function_exists ('codepot_json_encode')) if ( !function_exists ('codepot_json_encode'))
{ {
function codepot_json_encode( $data ) function codepot_json_encode($data)
{ {
if( is_array($data) || is_object($data) ) if (function_exists('json_encode'))
{
return json_encode($data);
}
else if( is_array($data) || is_object($data) )
{ {
$islist = is_array($data) && ( empty($data) || array_keys($data) === range(0,count($data)-1) ); $islist = is_array($data) && ( empty($data) || array_keys($data) === range(0,count($data)-1) );
@ -157,7 +161,7 @@ if ( !function_exists ('codepot_json_encode'))
if ( !function_exists ('codepot_delete_files')) if ( !function_exists ('codepot_delete_files'))
{ {
function codepot_delete_files($path, $del_dir = FALSE, $level = 0) function codepot_delete_files($path, $del_dir = FALSE, $level = 0)
{ {
// Trim the trailing slash // Trim the trailing slash
$path = rtrim($path, DIRECTORY_SEPARATOR); $path = rtrim($path, DIRECTORY_SEPARATOR);

View File

@ -196,11 +196,7 @@ var wiki_text_editor = null;
var work_in_progress = false; var work_in_progress = false;
var wiki_original_name = '<?php print addslashes($wiki->name); ?>'; var wiki_original_name = '<?php print addslashes($wiki->name); ?>';
var wiki_new_name = ''; var wiki_new_name = '';
<?php if (function_exists('json_encode')): ?> var wiki_original_text = <?php print codepot_json_encode($wiki->text); ?>;
var wiki_original_text = <?php print json_encode($wiki->text); ?>;
<?php else: ?>
var wiki_original_text = '<?php print addcslashes($wiki->text, "\0..\37'\"\\"); ?>';
<?php endif; ?>
function show_in_progress_message (outputMsg, titleMsg) function show_in_progress_message (outputMsg, titleMsg)
{ {