diff --git a/application/controllers/Collection.php b/application/controllers/Collection.php index f0d5a91..19dafb3 100755 --- a/application/controllers/Collection.php +++ b/application/controllers/Collection.php @@ -204,7 +204,7 @@ public function Record() { $cursor = $this->getModel()->find($this->db, $this->collection, $query, $fields, $limit, $skip, $type); $ordeBy = $this->getSort($this->request->getParam('order_by', false), $this->request->getParam('orders', false)); - if ($ordeBy) + if ($ordeBy && is_object($cursor)) $cursor->sort($ordeBy); $record = $cryptography->decode($cursor, $type); diff --git a/application/views/Collection/_list.php b/application/views/Collection/_list.php index c4417c9..d6108f8 100755 --- a/application/views/Collection/_list.php +++ b/application/views/Collection/_list.php @@ -37,7 +37,11 @@ echo ' ' . I18n::t('') . ''; } echo "
";
- print_r($cursor);
+ if ($format == 'document') {
+ echo htmlspecialchars(print_r($cursor, true));
+ } else {
+ print_r($cursor);
+ }
echo "";
}
?>
diff --git a/system/Cryptography.php b/system/Cryptography.php
index 93176c8..50dc56a 100755
--- a/system/Cryptography.php
+++ b/system/Cryptography.php
@@ -56,8 +56,10 @@ public function arrayToString($array, $tab = "") {
$string.="\"$key\"" . '=>' . $this->objectToString($value);
} else if (is_numeric($value)) {
$string.="\"$key\"" . '=>' . $value;
+ } else if (is_bool($value)) {
+ $string.="\"$key\"" . '=>' . ($value ? 'true' : 'false');
} else {
- $string.="\"$key\"" . '=>' . "\"$value\"";
+ $string.="\"$key\"" . '=>' . "'".str_replace(array('\\', '\''), array('\\\\', '\\\''), $value)."'";
}
$string.=',';
}
@@ -122,6 +124,8 @@ function arrayToJSON($array, $tab = "") {
$value = $this->objectToJSON($value);
} else if (is_double($value)) {
$value = "NumberLong(" . addslashes($value) . ")";
+ } else if (is_bool($value)) {
+ $value = $value ? 'true' : 'false';
} else if (!is_numeric($value) || is_string($value)) {
$value = "'" . addslashes($value) . "'";
}
@@ -139,6 +143,8 @@ function arrayToJSON($array, $tab = "") {
$value = $this->arrayToJSON($value, "$tab\t");
} else if (is_object($value)) {
$value = $this->objectToJSON($value);
+ } else if (is_bool($value)) {
+ $value = $value ? 'true' : 'false';
} else if (!is_numeric($value) || is_string($value)) {
$value = "'" . addslashes($value) . "'";
}