diff --git a/.gitignore b/.gitignore
index a2a2940cb4d45b35dd699e79f56621dcd0c660b6..e2b0195b99a21653ab1ad03c1e361061da7c2c82 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
/nbproject/
/logs/
-/config.php
\ No newline at end of file
+/config.php
+/vendor
diff --git a/app/classes/BaseController.php b/app/classes/BaseController.php
index f095f6ae6e626ea7370b2882626b74490f48054e..57ef71644971b749edcf8dc1ce784f9611a6c3aa 100644
--- a/app/classes/BaseController.php
+++ b/app/classes/BaseController.php
@@ -245,11 +245,16 @@ class BaseController extends RExtController
}
if ($label) {
$id = addslashes(isset($var["_id"]) ? rock_id_string($var["_id"]) : "");
- $string = preg_replace_callback("/(['\"])rockfield\\.(.+)\\.rockfield(['\"])/U", create_function('$match', ' $fields = explode(".rockfield.", $match[2]);
- return "" . $match[1] . array_pop($fields) . $match[3] . "";'), $string);
- $string = preg_replace_callback("/__rockmore\\.(.+)\\.rockmore__/U", create_function('$match', '
- $field = str_replace("rockfield.", "", $match[1]);
- return "[...]";'), $string);
+
+ $string = preg_replace_callback("/(['\"])rockfield\\.(.+)\\.rockfield(['\"])/U", function($match) {
+ $fields = explode(".rockfield.", $match[2]);
+ return "" . $match[1] . array_pop($fields) . $match[3] . "";
+ }, $string);
+
+ $string = preg_replace_callback("/__rockmore\\.(.+)\\.rockmore__/U", function($match) use($id) {
+ $field = str_replace("rockfield.", "", $match[1]);
+ return "[...]";
+ }, $string);
}
return $string;
}
diff --git a/app/classes/Services_JSON.php b/app/classes/Services_JSON.php
index 84a9a33ebaf6e6bd2a622ea65d685715ca1de999..6422d07a5086f96dbcf05d53c2f22c1b377100ac 100644
--- a/app/classes/Services_JSON.php
+++ b/app/classes/Services_JSON.php
@@ -129,7 +129,7 @@ class Services_JSON
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
- function Services_JSON($use = 0)
+ function __construct($use = 0)
{
$this->use = $use;
}
@@ -152,7 +152,7 @@ class Services_JSON
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
- $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
+ $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
switch(true) {
case ((0x7F & $bytes) == $bytes):
@@ -205,17 +205,17 @@ class Services_JSON
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0x07 & (ord($utf8{0}) >> 2))
- . chr((0xC0 & (ord($utf8{0}) << 6))
- | (0x3F & ord($utf8{1})));
+ return chr(0x07 & (ord($utf8[0]) >> 2))
+ . chr((0xC0 & (ord($utf8[0]) << 6))
+ | (0x3F & ord($utf6[1])));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr((0xF0 & (ord($utf8{0}) << 4))
- | (0x0F & (ord($utf8{1}) >> 2)))
- . chr((0xC0 & (ord($utf8{1}) << 6))
- | (0x7F & ord($utf8{2})));
+ return chr((0xF0 & (ord($utf8[0]) << 4))
+ | (0x0F & (ord($utf6[1]) >> 2)))
+ . chr((0xC0 & (ord($utf6[1]) << 6))
+ | (0x7F & ord($utf8[2])));
}
// ignoring UTF-32 for now, sorry
@@ -298,7 +298,7 @@ class Services_JSON
*/
for ($c = 0; $c < $strlen_var; ++$c) {
- $ord_var_c = ord($var{$c});
+ $ord_var_c = ord($var[$c]);
switch (true) {
case $ord_var_c == 0x08:
@@ -321,12 +321,12 @@ class Services_JSON
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
- $ascii .= '\\'.$var{$c};
+ $ascii .= '\\'.$var;
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
- $ascii .= $var{$c};
+ $ascii .= $var;
break;
case (($ord_var_c & 0xE0) == 0xC0):
@@ -338,7 +338,7 @@ class Services_JSON
break;
}
- $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
+ $char = pack('C*', $ord_var_c, ord($var[$c+1]));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -353,8 +353,8 @@ class Services_JSON
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
- @ord($var{$c + 1}),
- @ord($var{$c + 2}));
+ @ord($var[$c+1]),
+ @ord($var[$c+2]));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -369,9 +369,9 @@ class Services_JSON
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}));
+ ord($var[$c+1]),
+ ord($var[$c+2]),
+ ord($var[$c + 3]));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -386,10 +386,10 @@ class Services_JSON
break;
}
$char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}));
+ ord($var[$c+1]),
+ ord($var[$c+2]),
+ ord($var[$c + 3]),
+ ord($var[$c + 4]));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -404,11 +404,11 @@ class Services_JSON
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}),
- ord($var{$c + 5}));
+ ord($var[$c+1]),
+ ord($var[$c+2]),
+ ord($var[$c + 3]),
+ ord($var[$c + 4]),
+ ord($var[$c + 5]));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -582,7 +582,7 @@ class Services_JSON
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
- $ord_chrs_c = ord($chrs{$c});
+ $ord_chrs_c = ord($chrs);
switch (true) {
case $substr_chrs_c_2 == '\b':
@@ -612,7 +612,7 @@ class Services_JSON
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
- $utf8 .= $chrs{++$c};
+ $utf8 .= $chrs[++$c];
}
break;
@@ -625,7 +625,7 @@ class Services_JSON
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
- $utf8 .= $chrs{$c};
+ $utf8 .= $chrs;
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
@@ -672,7 +672,7 @@ class Services_JSON
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
- if ($str{0} == '[') {
+ if ($str[0] == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
@@ -711,12 +711,12 @@ class Services_JSON
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
- if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
+ if (($c == $strlen_chrs) || (($chrs == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
- //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+ //print("Found split at : ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
@@ -753,48 +753,48 @@ class Services_JSON
}
- } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
+ } elseif ((($chrs == '"') || ($chrs == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
- array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
- //print("Found start of string at {$c}\n");
+ array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs));
+ //print("Found start of string at \n");
- } elseif (($chrs{$c} == $top['delim']) &&
+ } elseif (($chrs == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
// we know that it's not escaped becase there is _not_ an
// odd number of backslashes at the end of the string so far
array_pop($stk);
- //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
+ //print("Found end of string at : ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
- } elseif (($chrs{$c} == '[') &&
+ } elseif (($chrs == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
- //print("Found start of array at {$c}\n");
+ //print("Found start of array at \n");
- } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
+ } elseif (($chrs == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
- //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+ //print("Found end of array at : ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
- } elseif (($chrs{$c} == '{') &&
+ } elseif (($chrs == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
- //print("Found start of object at {$c}\n");
+ //print("Found start of object at \n");
- } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
+ } elseif (($chrs == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
- //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+ //print("Found end of object at : ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$c++;
- //print("Found start of comment at {$c}\n");
+ //print("Found start of comment at \n");
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
// found a comment end, and we're in one now
@@ -804,7 +804,7 @@ class Services_JSON
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
- //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+ //print("Found end of comment at : ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
}
@@ -842,7 +842,7 @@ if (class_exists('PEAR_Error')) {
class Services_JSON_Error extends PEAR_Error
{
- function Services_JSON_Error($message = 'unknown error', $code = null,
+ function __construct($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
@@ -856,7 +856,7 @@ if (class_exists('PEAR_Error')) {
*/
class Services_JSON_Error
{
- function Services_JSON_Error($message = 'unknown error', $code = null,
+ function __construct($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
diff --git a/app/funcs/functions.php b/app/funcs/functions.php
index 7a6c2691522b325e2f466231093deae5b990bebd..48139e14d0b14cce5566e7eece199075d4149777 100644
--- a/app/funcs/functions.php
+++ b/app/funcs/functions.php
@@ -7,22 +7,22 @@
* @return string utf-8 string
*/
function json_unicode_to_utf8($json){
- $json = preg_replace_callback("/\\\\u([0-9a-f]{4})/", create_function('$match', '
- $val = intval($match[1], 16);
- $c = "";
- if($val < 0x7F){ // 0000-007F
- $c .= chr($val);
- } elseif ($val < 0x800) { // 0080-0800
- $c .= chr(0xC0 | ($val / 64));
- $c .= chr(0x80 | ($val % 64));
- } else { // 0800-FFFF
- $c .= chr(0xE0 | (($val / 64) / 64));
- $c .= chr(0x80 | (($val / 64) % 64));
- $c .= chr(0x80 | ($val % 64));
- }
- return $c;
- '), $json);
- return $json;
+ $json = preg_replace_callback("/\\\\u([0-9a-f]{4})/", function($match){
+ $val = intval($match[1], 16);
+ $c = "";
+ if($val < 0x7F){ // 0000-007F
+ $c .= chr($val);
+ } elseif ($val < 0x800) { // 0080-0800
+ $c .= chr(0xC0 | ($val / 64));
+ $c .= chr(0x80 | ($val % 64));
+ } else { // 0800-FFFF
+ $c .= chr(0xE0 | (($val / 64) / 64));
+ $c .= chr(0x80 | (($val / 64) % 64));
+ $c .= chr(0x80 | ($val % 64));
+ }
+ return $c;
+ }, $json);
+ return $json;
}
/**
@@ -117,11 +117,12 @@ function json_format_html($json)
break;
}
}
- $new_json = preg_replace_callback("{(([\\da-zA-Z_\\.]+))+}", create_function('$match','
- $string = str_replace("", "", $match[0]);
- $string = str_replace("", "", $string);
- return "" . $string . "";
- '), $new_json);
+
+ $new_json = preg_replace_callback("{(([\\da-zA-Z_\\.]+))+}", function($match) {
+ $string = str_replace("", "", $match[0]);
+ $string = str_replace("", "", $string);
+ return "" . $string . "";
+ }, $new_json);
return $new_json;
}
diff --git a/app/funcs/rock.php b/app/funcs/rock.php
index 966a5a4781929e7576272360bf6ab682f35588f4..a483e2ed28990e3c45057296e7a9cf7aef4dd167 100644
--- a/app/funcs/rock.php
+++ b/app/funcs/rock.php
@@ -45,10 +45,35 @@ function rock_array_sort(array $array, $key = null, $asc = true) {
}
else {
$GLOBALS["ROCK_ARRAY_SORT_KEY_" . nil] = $key;
+
+ $fun1 = function($p1, $p2) {
+ $key=$GLOBALS["ROCK_ARRAY_SORT_KEY_" . nil];
+ $p1=rock_array_get($p1,$key);
+ $p2=rock_array_get($p2,$key);
+ if ($p1>$p2){
+ return 1;
+ }elseif($p1==$p2){
+ return 0;
+ }else{
+ return -1;
+ }
+ };
+
+ $fun2 = function($p1, $p2) {
+ $key=$GLOBALS["rock_ARRAY_SORT_KEY_" . nil];
+ $p1=rock_array_get($p1,$key);
+ $p2=rock_array_get($p2,$key);
+ if ($p1<$p2){
+ return 1;
+ }elseif($p1==$p2){
+ return 0;
+ }else{
+ return -1;
+ }
+ };
+
uasort($array,
- $asc ? create_function('$p1,$p2', '$key=$GLOBALS["ROCK_ARRAY_SORT_KEY_" . nil];$p1=rock_array_get($p1,$key);$p2=rock_array_get($p2,$key);if ($p1>$p2){return 1;}elseif($p1==$p2){return 0;}else{return -1;}')
- :
- create_function('$p1,$p2', '$key=$GLOBALS["rock_ARRAY_SORT_KEY_" . nil];$p1=rock_array_get($p1,$key);$p2=rock_array_get($p2,$key);if ($p1<$p2){return 1;}elseif($p1==$p2){return 0;}else{return -1;}')
+ $asc ? $fun1 : $fun2
);
unset($GLOBALS["ROCK_ARRAY_SORT_KEY_" . nil]);
}
diff --git a/rock.php b/rock.php
index ae2af9736153a4fea72fcb243f2fbd3915922e35..b460574d29d2c1a75417819a17d3513f28142940 100644
--- a/rock.php
+++ b/rock.php
@@ -477,8 +477,13 @@ function o($config)
*/
function rock_name_to_java($name)
{
- $name = preg_replace_callback("/_([a-zA-Z])/", create_function('$match', 'return strtoupper($match[1]);'), $name);
- return $name;
+
+ $arr = explode('_', $name);
+ $result = '';
+ foreach ($arr as $key => $val) {
+ $result .= ucfirst($val);
+ }
+ return $result;
}
/**
@@ -496,7 +501,9 @@ function rock_array_get(array $array, $keys)
}
if (!is_array($keys)) {
if (strstr($keys, "`")) {
- $keys = preg_replace_callback("/`(.+)`/U", create_function('$match', 'return str_replace(".", "\.", $match[1]);'), $keys);
+ $keys = preg_replace_callback("/`(.+)`/U", function($match){
+ return str_replace(".", "\.", $match[1]);
+ }, $keys);
}
$keys = preg_split("/(?