diff --git a/app/controllers/collection.php b/app/controllers/collection.php index 7196f5d..ac54dc4 100644 --- a/app/controllers/collection.php +++ b/app/controllers/collection.php @@ -104,7 +104,7 @@ public function doIndex() { $params = xn(); if ($this->_logQuery && count($params) > 3) {//not only "action", "db" and "collection" $logDir = dirname(__ROOT__) . DS . "logs"; - if (!empty($params["criteria"]) && strlen(trim($params["criteria"], "{} \t\n\r")) > 0) { + if (!empty($params["criteria"]) && mb_strlen(trim($params["criteria"], "{} \t\n\r")) > 0) { if (is_writable($logDir)) { $logFile = $this->_logFile($this->db, $this->collection); $fp = null; diff --git a/app/funcs/functions.php b/app/funcs/functions.php index 7a6c269..0bb0953 100644 --- a/app/funcs/functions.php +++ b/app/funcs/functions.php @@ -39,11 +39,12 @@ function json_format_html($json) $indent_level = 0; $in_string = false; - $len = strlen($json); + $len = mb_strlen($json); + $chars = preg_split('//u',$json, -1, PREG_SPLIT_NO_EMPTY); for($c = 0; $c < $len; $c++) { - $char = $json[$c]; + $char = $chars[$c]; switch($char) { case '{': @@ -89,7 +90,7 @@ function json_format_html($json) } break; case '"': - if($c > 0 && $json[$c-1] != '\\') { + if($c > 0 && $chars[$c-1] != '\\') { $in_string = !$in_string; if ($in_string) { $new_json .= "" . $char; @@ -171,7 +172,7 @@ function json_format($json) $json = json_encode($json_obj); */ - $len = strlen($json); + $len = mb_strlen($json); for($c = 0; $c < $len; $c++) { diff --git a/app/lib/mongo/RQuery.php b/app/lib/mongo/RQuery.php index cac2510..e8def2c 100644 --- a/app/lib/mongo/RQuery.php +++ b/app/lib/mongo/RQuery.php @@ -59,7 +59,7 @@ function attr($nameOrAttrs, $value = null) { $nameOrAttrs = array( $nameOrAttrs => $value ); } foreach ($nameOrAttrs as $attr => $value) { - if ($attr == "_id" && (!is_object($value) || !($value instanceof MongoId)) && strlen($attr) == 24) { + if ($attr == "_id" && (!is_object($value) || !($value instanceof MongoId)) && mb_strlen($attr) == 24) { $value = new MongoId($value); } if (!isset($this->_attrs[$attr])) { diff --git a/app/lib/page/RPage.php b/app/lib/page/RPage.php index caeae86..2b167e6 100644 --- a/app/lib/page/RPage.php +++ b/app/lib/page/RPage.php @@ -318,7 +318,7 @@ function setAutoQuery($bool = true, $except = "", $only = "") { if (!is_array($except)) { $except = preg_split("/\\s+,\\s+/", $except); } - if (!is_array($only) && strlen($only) > 0) { + if (!is_array($only) && mb_strlen($only) > 0) { $only = preg_split("/\\s+,\\s+/", $only); } if ($bool) { diff --git a/themes/default/views/header.php b/themes/default/views/header.php index e480fac..0ee2e80 100644 --- a/themes/default/views/header.php +++ b/themes/default/views/header.php @@ -12,6 +12,31 @@ $(document).click(window.parent.hideMenus); if ($("textarea").length > 0) { $("textarea").tabby(); + + + // Search with ID field + var elTextField = $("").attr({type: 'text', size: 30}).keypress(function(e) { + if (e.keyCode == '13') { + e.preventDefault(); + $(this).parent().find('input:last').click(); + } + }); + var elButton = $("").attr({type: 'button', value: 'Select by ID'}) + .bind('click', function (e) { + var v = $(this).parent().find('input:first').val(); + // заветная строка! + $('#query_form textarea').val('{\n\"_id\": ObjectId(\"'+v+'\")\n}'); + $('#query_form').submit(); + }); + $("
") + .html('_id: ') + .css({paddingLeft: 5, paddingTop: 4}) + .append(elTextField) + .append(' ') + .append(elButton) + .prependTo('#query_form'); + + } });