Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Added json array support in addtion to json objects for json values stored in settings

givanze834f210f3a9
diff --git a/system/meta/meta.php b/system/meta/meta.php
index ee82992..8e58c65 100644
--- a/system/meta/meta.php
+++ b/system/meta/meta.php
@@ -60,7 +60,7 @@ class Meta {
foreach ($result as &$value) {
$val = &$value['value'];
- if ($val && is_string($val) && $val[0] == '{') {
+ if ($val && is_string($val) && ($val[0] == '{' || $val[0] == '{')) {
$json = json_decode($val, true);
$val = $json ?: $val;
}
@@ -96,7 +96,7 @@ class Meta {
$result = $this->settingSql->get([$this->item_id => $item_id, 'namespace' => $namespace, 'key' => $key, 'language_id' => $language_id]) ?? $default;
- if ($result && is_string($result) && $result[0] == '{') {
+ if ($result && is_string($result) && ($result[0] == '{' || $result[0] == '[')) {
$json = json_decode($result, true);
$result = $json ?: $result;
}
@@ -107,7 +107,7 @@ class Meta {
public function set($item_id, $namespace, $key, $value, $language_id = false) {
if (! $namespace || ! $key) {
- return $default;
+ return;
}
$this->setting[$namespace][$key] = $value;
@@ -119,9 +119,9 @@ class Meta {
return $this->settingSql->set([$this->item_id => $item_id, 'namespace' => $namespace, 'key' => $key, 'value' => $value, 'language_id' => $language_id]);
}
- public function delete($item_id, $namespace, $key, $value, $language_id = false) {
+ public function delete($item_id, $namespace, $key, $language_id = false) {
if (! $namespace || ! $key) {
- return $default;
+ return;
}
unset($this->setting[$namespace][$key]);
diff --git a/system/setting.php b/system/setting.php
index 6eab9dd..147daf3 100755
--- a/system/setting.php
+++ b/system/setting.php
@@ -57,7 +57,7 @@ class Setting {
foreach ($result as $value) {
$val = $value['value'];
- if ($val && is_string($val) && $val[0] == '{') {
+ if ($val && is_string($val) && ($val[0] == '{' || $val[0] == '[')) {
$json = json_decode($val, true);
$val = $json ?: $val;
}
@@ -85,9 +85,9 @@ class Setting {
$result = $this->settingSql->get(['namespace' => $namespace, 'key' => $key, 'site_id' => $site_id]) ?? $default;
- if ($result && is_string($result) && $result[0] == '{') {
+ if ($result && is_string($result) && ($result[0] == '{' || $result[0] == '[')) {
$json = json_decode($result, true);
- $result = $json ?: $result;
+ $result = $json ?? $result;
}
return $result;
@@ -96,7 +96,7 @@ class Setting {
public function set($namespace, $key, $value, $site_id = SITE_ID) {
if (! $namespace || ! $key) {
- return $default;
+ return;
}
$this->setting[$namespace][$key] = $value;
@@ -108,9 +108,9 @@ class Setting {
return $this->settingSql->set(['namespace' => $namespace, 'key' => $key, 'value' => $value, 'site_id' => $site_id]);
}
- public function delete($namespace, $key, $value, $site_id = SITE_ID) {
+ public function delete($namespace, $key, $site_id = SITE_ID) {
if (! $namespace || ! $key) {
- return $default;
+ return;
}
unset($this->setting[$namespace][$key]);