Update requirements for json_encode()
| Project: | Image Browser |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Algebraist |
| Status: | needs work |
Jump to:
I've installed and configured Imagebrowser to use the WYSIWYG-API with FCK-Editor 2.6.5 on drupal 6.14. Everything works fine, except the final step. I created a new input format that uses only the Image Browser Filter. Than I configured the FCKEditor Profile to show only the button for the image browser.
So I can create a new page and choose my new input format. The FCK comes up with the imagebrowser button. I hit the button and the imagebrowser shows up with my images. I can choose an image and set all options. But finally when I hit 'Insert', nothing happens, the image browser stays open and no image is inserted. 'Cancel', 'Close' and 'Delete' do what they are supposed to do, but 'Insert' does not work.

#1
Getting any javascript errors?
#2
Hi
See this thread:
http://drupal.org/node/564822
#3
That is a good hint! Currently I'm using PHP5.1, so this might be the cause. I will update my PHP and report if it fixes this issue.
#4
Yes, that solves it. I updated my php to 5.2.6 and now it works like a charme.
So I think the requirements in README.txt should claim that only PHP >= 5.2 is supoorted (json_encode() is available).
#5
Thanks for flagging this. I might write a custom json_encode() to do the job.
#6
This is from the php.net documentation page of json_encode, a substitute:
<?php
if (!function_exists('json_encode'))
{
function json_encode($a=false)
{
if (is_null($a)) return 'null';
if ($a === false) return 'false';
if ($a === true) return 'true';
if (is_scalar($a))
{
if (is_float($a))
{
// Always use "." for floats.
return floatval(str_replace(",", ".", strval($a)));
}
if (is_string($a))
{
static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
}
else
return $a;
}
$isList = true;
for ($i = 0, reset($a); $i < count($a); $i++, next($a))
{
if (key($a) !== $i)
{
$isList = false;
break;
}
}
$result = array();
if ($isList)
{
foreach ($a as $v) $result[] = json_encode($v);
return '[' . join(',', $result) . ']';
}
else
{
foreach ($a as $k => $v) $result[] = json_encode($k).':'.json_encode($v);
return '{' . join(',', $result) . '}';
}
}
}
?>