Changeset 6593 for CKEditor/trunk
- Timestamp:
- 03/22/11 10:23:18 (2 years ago)
- Location:
- CKEditor/trunk
- Files:
-
- 3 edited
-
CHANGES.html (modified) (1 diff)
-
ckeditor_php4.php (modified) (2 diffs)
-
ckeditor_php5.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/trunk/CHANGES.html
r6591 r6593 89 89 <li><a href="http://dev.ckeditor.com/ticket/7180">#7180</a> : [IE9] Using Kama skin and RTL layout, dialog buttons were not being displayed correctly.</li> 90 90 <li><a href="http://dev.ckeditor.com/ticket/7182">#7182</a> : [IE9] Using Office2003/v2 skin and RTL layout, dialog shadows were corrupted.</li> 91 <li><a href="http://dev.ckeditor.com/ticket/6913">#6913</a> : Invalid escape sequence (\b) used in PHP integration.</li> 91 92 <li>Updated the following language files:<ul> 92 93 <li><a href="http://dev.ckeditor.com/ticket/7124">#7124</a> : Czech;</li> -
CKEditor/trunk/ckeditor_php4.php
r6352 r6593 532 532 /** 533 533 * This little function provides a basic JSON support. 534 * http://php.net/manual/en/function.json-encode.php535 534 * \private 536 535 * … … 543 542 return 'null'; 544 543 } 545 if ($val === false) { 546 return 'false'; 547 } 548 if ($val === true) { 549 return 'true'; 550 } 551 if (is_scalar($val)) 552 { 553 if (is_float($val)) 554 { 555 // Always use "." for floats. 556 $val = str_replace(",", ".", strval($val)); 557 } 558 559 // Use @@ to not use quotes when outputting string value 560 if (strpos($val, '@@') === 0) { 561 return substr($val, 2); 562 } 563 else { 564 // All scalars are converted to strings to avoid indeterminism. 565 // PHP's "1" and 1 are equal for all PHP operators, but 566 // JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend, 567 // we should get the same result in the JS frontend (string). 568 // Character replacements for JSON. 569 static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), 570 array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"')); 571 572 $val = str_replace($jsonReplaces[0], $jsonReplaces[1], $val); 573 if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') { 574 return $val; 575 } 576 577 return '"' . $val . '"'; 578 } 579 } 580 $isList = true; 581 for ($i = 0, reset($val); $i < count($val); $i++, next($val)) 582 { 583 if (key($val) !== $i) 584 { 585 $isList = false; 586 break; 587 } 588 } 589 $result = array(); 590 if ($isList) 591 { 592 foreach ($val as $v) $result[] = $this->jsEncode($v); 593 return '[ ' . join(', ', $result) . ' ]'; 594 } 595 else 596 { 597 foreach ($val as $k => $v) $result[] = $this->jsEncode($k).': '.$this->jsEncode($v); 598 return '{ ' . join(', ', $result) . ' }'; 599 } 544 if (is_bool($val)) { 545 return $val ? 'true' : 'false'; 546 } 547 if (is_int($val)) { 548 return $val; 549 } 550 if (is_float($val)) { 551 return str_replace(',', '.', $val); 552 } 553 if (is_array($val) || is_object($val)) { 554 if (is_array($val) && (array_keys($val) === range(0,count($val)-1))) { 555 return '[' . implode(',', array_map(array($this, 'jsEncode'), $val)) . ']'; 556 } 557 $temp = array(); 558 foreach ($val as $k => $v){ 559 $temp[] = $this->jsEncode("{$k}") . ':' . $this->jsEncode($v); 560 } 561 return '{' . implode(',', $temp) . '}'; 562 } 563 // String otherwise 564 if (strpos($val, '@@') === 0) 565 return substr($val, 2); 566 if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') 567 return $val; 568 569 return '"' . str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val) . '"'; 600 570 } 601 571 } -
CKEditor/trunk/ckeditor_php5.php
r6352 r6593 523 523 /** 524 524 * This little function provides a basic JSON support. 525 * http://php.net/manual/en/function.json-encode.php526 525 * 527 526 * @param mixed $val … … 533 532 return 'null'; 534 533 } 535 if ($val === false) { 536 return 'false'; 537 } 538 if ($val === true) { 539 return 'true'; 540 } 541 if (is_scalar($val)) 542 { 543 if (is_float($val)) 544 { 545 // Always use "." for floats. 546 $val = str_replace(",", ".", strval($val)); 547 } 548 549 // Use @@ to not use quotes when outputting string value 550 if (strpos($val, '@@') === 0) { 551 return substr($val, 2); 552 } 553 else { 554 // All scalars are converted to strings to avoid indeterminism. 555 // PHP's "1" and 1 are equal for all PHP operators, but 556 // JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend, 557 // we should get the same result in the JS frontend (string). 558 // Character replacements for JSON. 559 static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), 560 array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"')); 561 562 $val = str_replace($jsonReplaces[0], $jsonReplaces[1], $val); 563 if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') { 564 return $val; 565 } 566 567 return '"' . $val . '"'; 568 } 569 } 570 $isList = true; 571 for ($i = 0, reset($val); $i < count($val); $i++, next($val)) 572 { 573 if (key($val) !== $i) 574 { 575 $isList = false; 576 break; 577 } 578 } 579 $result = array(); 580 if ($isList) 581 { 582 foreach ($val as $v) $result[] = $this->jsEncode($v); 583 return '[ ' . join(', ', $result) . ' ]'; 584 } 585 else 586 { 587 foreach ($val as $k => $v) $result[] = $this->jsEncode($k).': '.$this->jsEncode($v); 588 return '{ ' . join(', ', $result) . ' }'; 589 } 534 if (is_bool($val)) { 535 return $val ? 'true' : 'false'; 536 } 537 if (is_int($val)) { 538 return $val; 539 } 540 if (is_float($val)) { 541 return str_replace(',', '.', $val); 542 } 543 if (is_array($val) || is_object($val)) { 544 if (is_array($val) && (array_keys($val) === range(0,count($val)-1))) { 545 return '[' . implode(',', array_map(array($this, 'jsEncode'), $val)) . ']'; 546 } 547 $temp = array(); 548 foreach ($val as $k => $v){ 549 $temp[] = $this->jsEncode("{$k}") . ':' . $this->jsEncode($v); 550 } 551 return '{' . implode(',', $temp) . '}'; 552 } 553 // String otherwise 554 if (strpos($val, '@@') === 0) 555 return substr($val, 2); 556 if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') 557 return $val; 558 559 return '"' . str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val) . '"'; 590 560 } 591 561 }
Note: See TracChangeset
for help on using the changeset viewer.
