Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Code formatting

givanzfa79bcdf9e4a
diff --git a/admin/controller/content/revisions.php b/admin/controller/content/revisions.php
index aaeb93c..91201d3 100644
--- a/admin/controller/content/revisions.php
+++ b/admin/controller/content/revisions.php
@@ -24,9 +24,9 @@ namespace Vvveb\Controller\Content;
use function Vvveb\__;
use Vvveb\Controller\Base;
-use Vvveb\System\Images;
use function Vvveb\humanReadable;
use function Vvveb\model;
+use Vvveb\System\Images;
class Revisions extends Base {
protected $type = 'post';
@@ -44,14 +44,14 @@ class Revisions extends Base {
$this->revisions = model($this->type . '_content_revision');
$this->post = model($this->type);
-
+
$this->options = ['type' => $this->type];
-
+
foreach ([$this->type . '_id', 'language_id', 'created_at'] as $param) {
if (isset($this->request->get[$param])) {
$this->options[$param] = $this->request->get[$param];
}
- }
+ }
return parent::init();
}
@@ -66,26 +66,28 @@ class Revisions extends Base {
function save() {
$content = $this->request->post['content'] ?? false;
+
if ($content) {
$result = $this->post->editContent(
- [$this->type . '_content' => ['content' => $content]] +
- $this->options +
+ [$this->type . '_content' => ['content' => $content]] +
+ $this->options +
$this->global
);
-
+
if ($result) {
- $this->view->success[] = ucfirst($this->type) . ' ' . __('saved') . '!';;
+ $this->view->success[] = ucfirst($this->type) . ' ' . __('saved') . '!';
} else {
$view->errors = [$post->error];
}
}
-
+
return $this->index();
}
-
+
function revision() {
$view = $this->view;
- $results = $this->revisions->get($this->options);
+ $results = $this->revisions->get($this->options);
+
if ($results && isset($results['content'])) {
echo $results['content'];
}
@@ -96,25 +98,24 @@ class Revisions extends Base {
function index() {
$view = $this->view;
$revisions = model($this->type . '_content_revision');
- $this->options += $this->global;
+ $this->options += $this->global;
+
+ $revisions = $this->revisions->getAll($this->options); // all post/product revisions
+ $revision = $this->revisions->get($this->options); // latest or selected revision
+ $post = $this->post->get($this->options); // post/product content
-
- $revisions = $this->revisions->getAll($this->options);// all post/product revisions
- $revision = $this->revisions->get($this->options);// latest or selected revision
- $post = $this->post->get($this->options);// post/product content
-
if (isset($post['image'])) {
$post['image'] = $post['image'] = Images::image($post['image'], $this->type, 'thumb');
}
$results = [
'revisions' => $revisions['revision'] ?? [],
- 'revision' => $revision ?? [],
- 'post' => $post ?? [],
+ 'revision' => $revision ?? [],
+ 'post' => $post ?? [],
];
$view->set($results);
-
+
$view->limit = $this->options['limit'];
$view->type = $this->type;
$view->revisionUrl = \Vvveb\url(['module' => 'content/revisions', 'action' => 'revision', 'type' => $this->type]);
diff --git a/admin/controller/plugin/market.php b/admin/controller/plugin/market.php
index d72880c..570c282 100755
--- a/admin/controller/plugin/market.php
+++ b/admin/controller/plugin/market.php
@@ -99,6 +99,7 @@ class Market extends Base {
$plugins = [];
$request['limit'] = $this->view->limit = 8;
+
try {
$plugins = Plugins :: getMarketList($request);
$installed = Plugins :: getList($this->global['site_id']);
diff --git a/admin/controller/product/revisions.php b/admin/controller/product/revisions.php
index b793ae4..4eb4f1d 100644
--- a/admin/controller/product/revisions.php
+++ b/admin/controller/product/revisions.php
@@ -22,12 +22,10 @@
namespace Vvveb\Controller\Product;
-use function Vvveb\__;
-use Vvveb\Controller\Base;
use Vvveb\Controller\Content\Revisions as RevisionsBase;
class Revisions extends RevisionsBase {
protected $type = 'product';
-
+
protected $additionalPermissionCheck = ['product/revisions/save'];
}
diff --git a/admin/controller/theme/market.php b/admin/controller/theme/market.php
index 20e0283..cf35a12 100755
--- a/admin/controller/theme/market.php
+++ b/admin/controller/theme/market.php
@@ -92,6 +92,7 @@ class Market extends Base {
$themes = [];
$request['limit'] = $this->view->limit = 8;
+
try {
$themes = Themes :: getMarketList($request);
$installed = Themes :: getList($this->global['site_id']);
diff --git a/admin/template/crud.tpl b/admin/template/crud.tpl
index a25569a..8817c02 100755
--- a/admin/template/crud.tpl
+++ b/admin/template/crud.tpl
@@ -42,7 +42,7 @@ import(common.tpl)
[data-v-{{type}}] [data-v-{{type}}-*] [data-v-option]|value = $value
[data-v-{{type}}] [data-v-{{type}}-*] [data-v-option]|addNewAttribute = <?php if ($value == $selected) echo 'selected';?>
- [data-v-{{type}}] [data-v-{{type}}-*] [data-v-option] = <?php if (is_array($text)) { if (isset($text['name'])) echo $text['name'];} else echo $text;?>
+ [data-v-{{type}}] [data-v-{{type}}-*] [data-v-option] = <?php if (is_array($text)) { if (isset($text['name'])) echo Vvveb\humanReadable($text['name']);} else echo Vvveb\humanReadable($text);?>
[data-v-{{type}}] [data-v-{{type}}-*] [data-v-option]|after = <?php
} ?>
diff --git a/app/component/cart.php b/app/component/cart.php
index cea43b0..42e6d5b 100755
--- a/app/component/cart.php
+++ b/app/component/cart.php
@@ -29,7 +29,7 @@ use Vvveb\System\Event;
class Cart extends ComponentBase {
public static $defaultOptions = [
'language_id' => null,
- 'site_id' => null,
+ 'site_id' => null,
];
public $cacheExpire = 0; //seconds
diff --git a/app/component/checkout.php b/app/component/checkout.php
index c55dafb..112844a 100755
--- a/app/component/checkout.php
+++ b/app/component/checkout.php
@@ -27,7 +27,7 @@ use Vvveb\System\Component\ComponentBase;
class Checkout extends ComponentBase {
public static $defaultOptions = [
'language_id' => null,
- 'site_id' => null,
+ 'site_id' => null,
];
public $cacheExpire = 0; //seconds
diff --git a/app/component/comments.php b/app/component/comments.php
index e6615bc..48dc75c 100755
--- a/app/component/comments.php
+++ b/app/component/comments.php
@@ -37,21 +37,21 @@ class Comments extends ComponentBase {
protected $model = 'comment';
public static $defaultOptions = [
- 'post_id' => 'url',
- 'slug' => 'url',
- 'post_title' => NULL, //include post title (for recent comments etc)
- 'status' => 1, //approved comments
- 'language_id' => NULL,
- 'start' => 0,
- 'limit' => 10,
- 'order' => 'asc', //desc
+ 'post_id' => 'url',
+ 'slug' => 'url',
+ 'post_title' => NULL, //include post title (for recent comments etc)
+ 'status' => 1, //approved comments
+ 'language_id' => NULL,
+ 'start' => 0,
+ 'limit' => 10,
+ 'order' => 'asc', //desc
];
//called when fetching data, when cache expires
function results() {
$this->modelInstance = model($this->model); //new CommentSQL();
- $results = $this->modelInstance->getAll($this->options);
- $results[$this->type] = $results[$this->type] ?? [];
+ $results = $this->modelInstance->getAll($this->options);
+ $results[$this->type] = $results[$this->type] ?? [];
$order = $this->options['order'];
diff --git a/app/component/content/archives.php b/app/component/content/archives.php
index 7c71520..ef15862 100755
--- a/app/component/content/archives.php
+++ b/app/component/content/archives.php
@@ -28,17 +28,17 @@ use Vvveb\System\Event;
class Archives extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- 'language_id' => 1,
- 'site_id' => 1,
- 'count' => ['url', 4],
- 'id_manufacturer' => NULL,
- 'order' => ['url', 'price asc'],
- 'id_category' => NULL,
- 'limit' => 0,
- 'start' => 1,
- 'type' => 'post',
- 'interval' => 'month', //year, month, day
+ 'start' => 0,
+ 'language_id' => 1,
+ 'site_id' => 1,
+ 'count' => ['url', 4],
+ 'id_manufacturer' => NULL,
+ 'order' => ['url', 'price asc'],
+ 'id_category' => NULL,
+ 'limit' => 0,
+ 'start' => 1,
+ 'type' => 'post',
+ 'interval' => 'month', //year, month, day
];
function results() {
diff --git a/app/component/content/categories.php b/app/component/content/categories.php
index fd0164d..a5a2e9c 100755
--- a/app/component/content/categories.php
+++ b/app/component/content/categories.php
@@ -28,16 +28,16 @@ use Vvveb\System\Event;
class Categories extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- 'limit' => 7,
- 'site_id' => NULL,
- 'language_id' => NULL,
- 'taxonomy_id' => NULL,
- 'post_id' => 'url',
- 'parent_id' => NULL,
- 'search' => NULL,
- 'type' => 'categories',
- 'post_type' => 'post',
+ 'start' => 0,
+ 'limit' => 7,
+ 'site_id' => NULL,
+ 'language_id' => NULL,
+ 'taxonomy_id' => NULL,
+ 'post_id' => 'url',
+ 'parent_id' => NULL,
+ 'search' => NULL,
+ 'type' => 'categories',
+ 'post_type' => 'post',
];
function results() {
diff --git a/app/component/content/tags.php b/app/component/content/tags.php
old mode 100755
new mode 100644
index a917b93..197e16a
--- a/app/component/content/tags.php
+++ b/app/component/content/tags.php
@@ -27,12 +27,12 @@ use Vvveb\System\Event;
class Tags extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- //'language_id' => 1,
+ 'language_id' => NULL,
'count' => ['url', 4],
'id_manufacturer' => NULL,
'order' => ['url', 'price asc'],
'id_category' => NULL,
+ 'start' => 0,
'limit' => 7,
'page' => 1,
'type' => 'tags',
diff --git a/app/component/currency.php b/app/component/currency.php
index 8abad3c..e89d872 100755
--- a/app/component/currency.php
+++ b/app/component/currency.php
@@ -23,8 +23,6 @@
namespace Vvveb\Component;
use function Vvveb\availableCurrencies;
-use Vvveb\Sql\CurrencySQL;
-use Vvveb\System\Cache;
use Vvveb\System\Component\ComponentBase;
use Vvveb\System\Event;
use Vvveb\System\Session;
@@ -40,7 +38,7 @@ class Currency extends ComponentBase {
}
function results() {
- $results = [];
+ $results = [];
$results['currency'] = availableCurrencies();
if ($results) {
diff --git a/app/component/menu.php b/app/component/menu.php
index 4c3bcf2..793a8c3 100755
--- a/app/component/menu.php
+++ b/app/component/menu.php
@@ -28,10 +28,10 @@ use Vvveb\System\Event;
class Menu extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0, //defaut, override from html
- 'limit' => 10000,
- 'menu_id' => null, //unset, set from html
- 'slug' => null, //unset, set from html
+ 'start' => 0, //defaut, override from html
+ 'limit' => 10000,
+ 'menu_id' => null, //unset, set from html
+ 'slug' => null, //unset, set from html
];
function results() {
diff --git a/app/component/order.php b/app/component/order.php
index a447448..5ac7118 100755
--- a/app/component/order.php
+++ b/app/component/order.php
@@ -31,9 +31,9 @@ use Vvveb\System\Images;
class Order extends ComponentBase {
public static $defaultOptions = [
- 'user_id' => null,
- 'order_id' => null,
- 'limit' => ['url', 4],
+ 'user_id' => null,
+ 'order_id' => null,
+ 'limit' => ['url', 4],
];
public $options = [];
diff --git a/app/component/orders.php b/app/component/orders.php
index 567768b..629699f 100755
--- a/app/component/orders.php
+++ b/app/component/orders.php
@@ -29,10 +29,10 @@ use function Vvveb\url;
class Orders extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- 'order_id' => 'url',
- 'limit' => ['url', 4],
- 'order' => ['url', 'price asc'],
+ 'start' => 0,
+ 'order_id' => 'url',
+ 'limit' => ['url', 4],
+ 'order' => ['url', 'price asc'],
];
public $options = [];
diff --git a/app/component/post.php b/app/component/post.php
index 0dfc7b5..9582c4f 100755
--- a/app/component/post.php
+++ b/app/component/post.php
@@ -31,14 +31,14 @@ use function Vvveb\url;
class Post extends ComponentBase {
public static $defaultOptions = [
- 'post_id' => 'url',
- 'language_id' => null,
- 'site_id' => null,
- 'slug' => 'url',
- 'status' => 'publish',
- 'comment_count' => 1,
- 'comment_status' => 1,
- //'type' => 'post',
+ 'post_id' => 'url',
+ 'language_id' => null,
+ 'site_id' => null,
+ 'slug' => 'url',
+ 'status' => 'publish',
+ 'comment_count' => 1,
+ 'comment_status' => 1,
+ //'type' => 'post',
];
//called when fetching data, when cache expires
diff --git a/app/component/posts.php b/app/component/posts.php
index b587c4f..5d4dc6e 100755
--- a/app/component/posts.php
+++ b/app/component/posts.php
@@ -33,31 +33,31 @@ use function Vvveb\url;
class Posts extends ComponentBase {
public static $defaultOptions = [
- 'page' => ['url', 1],
- 'post_id' => 'url',
- 'language_id' => null,
- 'source' => 'autocomplete',
- 'type' => 'post',
- 'site_id' => null,
- 'start' => null,
- 'limit' => ['url', 8],
- 'order_by' => 'sort_order',
- 'direction' => ['desc', 'asc'],
- 'status' => 'publish',
- 'excerpt_limit' => 200,
- 'comment_count' => 1,
- 'comment_status' => 1,
- 'taxonomy_item_id' => NULL,
- 'taxonomy_item_slug' => NULL,
- 'search' => NULL,
- 'admin_id' => NULL,
+ 'page' => ['url', 1],
+ 'post_id' => 'url',
+ 'language_id' => null,
+ 'source' => 'autocomplete',
+ 'type' => 'post',
+ 'site_id' => null,
+ 'start' => null,
+ 'limit' => ['url', 8],
+ 'order_by' => 'sort_order',
+ 'direction' => ['desc', 'asc'],
+ 'status' => 'publish',
+ 'excerpt_limit' => 200,
+ 'comment_count' => 1,
+ 'comment_status' => 1,
+ 'taxonomy_item_id' => NULL,
+ 'taxonomy_item_slug' => NULL,
+ 'search' => NULL,
+ 'admin_id' => NULL,
//archive
- 'month' => NULL,
- 'year' => NULL,
- 'image_size' => 'medium',
- 'categories' => null,
- 'tags' => null,
- 'taxonomy' => null,
+ 'month' => NULL,
+ 'year' => NULL,
+ 'image_size' => 'medium',
+ 'categories' => null,
+ 'tags' => null,
+ 'taxonomy' => null,
];
public $options = [];
@@ -125,11 +125,14 @@ class Posts extends ComponentBase {
}
foreach (['categories' => 'category', 'tags' => 'tag', 'taxonomy' => $this->options['taxonomy'] ?? ''] as $taxonomy => $route) {
-
if (isset($post[$taxonomy])) {
$post[$taxonomy] = json_decode($post[$taxonomy], 1);
$count = $this->options[$taxonomy];
- if (!$post[$taxonomy]) continue;
+
+ if (! $post[$taxonomy]) {
+ continue;
+ }
+
if (is_numeric($count) && is_array($post[$taxonomy])) {
$post[$taxonomy] = array_slice($post[$taxonomy], 0, $count);
}
diff --git a/app/component/product.php b/app/component/product.php
index bc8372d..3aea5e1 100755
--- a/app/component/product.php
+++ b/app/component/product.php
@@ -34,14 +34,14 @@ class Product extends ComponentBase {
public static $defaultOptions = [
'product_id' => 'url',
'slug' => 'url',
- 'status' => 1,
+ 'status' => 1,
'language_id' => null,
'site_id' => null,
'user_id' => null,
'user_group_id' => null,
- 'reviews' => true,
- 'rating' => true,
- 'promotion' => true,
+ 'reviews' => true,
+ 'rating' => true,
+ 'promotion' => true,
];
function results() {
@@ -69,7 +69,7 @@ class Product extends ComponentBase {
$results['price_tax'] = $tax->addTaxes($results['price'], $results['tax_type_id']);
$results['price_tax_formatted'] = $currency->format($results['price_tax']);
$results['price_formatted'] = $currency->format($results['price']);
-
+
if ($results['promotion']) {
$results['promotion_tax'] = $tax->addTaxes($results['promotion'], $results['tax_type_id']);
$results['promotion_tax_formatted'] = $currency->format($results['promotion_tax']);
diff --git a/app/component/product/attributes.php b/app/component/product/attributes.php
index 417cc91..69f222e 100644
--- a/app/component/product/attributes.php
+++ b/app/component/product/attributes.php
@@ -28,18 +28,18 @@ use Vvveb\System\Event;
class Attributes extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- 'limit' => 7,
- 'site_id' => NULL,
- 'language_id' => NULL,
- 'product_id' => 'url',
- 'search' => NULL,
- 'image_size' => 'thumb',
+ 'start' => 0,
+ 'limit' => 7,
+ 'site_id' => NULL,
+ 'language_id' => NULL,
+ 'product_id' => 'url',
+ 'search' => NULL,
+ 'image_size' => 'thumb',
];
function results() {
- $category = new AttributeSQL();
- $results = $category->getAll($this->options);
+ $category = new AttributeSQL();
+ $results = $category->getAll($this->options);
$attributes = [];
$group = false;
diff --git a/app/component/product/categories.php b/app/component/product/categories.php
index 6e6533f..c00959c 100755
--- a/app/component/product/categories.php
+++ b/app/component/product/categories.php
@@ -27,16 +27,16 @@ use Vvveb\System\Event;
class Categories extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- 'limit' => 7,
- 'site_id' => NULL,
- 'language_id' => NULL,
- 'taxonomy_id' => NULL,
- 'product_id' => 'url',
- 'parent_id' => NULL,
- 'search' => NULL,
- 'type' => 'categories',
- 'post_type' => 'post',
+ 'start' => 0,
+ 'limit' => 7,
+ 'site_id' => NULL,
+ 'language_id' => NULL,
+ 'taxonomy_id' => NULL,
+ 'product_id' => 'url',
+ 'parent_id' => NULL,
+ 'search' => NULL,
+ 'type' => 'categories',
+ 'post_type' => 'post',
];
function results() {
diff --git a/app/component/product/manufacturers.php b/app/component/product/manufacturers.php
index 27b20ef..cf91202 100755
--- a/app/component/product/manufacturers.php
+++ b/app/component/product/manufacturers.php
@@ -24,11 +24,12 @@ namespace Vvveb\Component\Product;
use Vvveb\System\Component\ComponentBase;
use Vvveb\System\Event;
+use function Vvveb\url;
class Manufacturers extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- //'language_id' => 1,
+ 'start' => 0,
+ //'language_id' => 1,
'count' => ['url', 4],
'id_manufacturer' => NULL,
'order' => ['url', 'price asc'],
@@ -45,6 +46,10 @@ class Manufacturers extends ComponentBase {
$category = new \Vvveb\Sql\ManufacturerSQL();
$results = $category->getAll($this->options);
+ foreach ($results['manufacturer'] as &$manufacturer) {
+ $manufacturer['url'] = url('product/manufacturer/index', $manufacturer);
+ }
+
list($results) = Event :: trigger(__CLASS__,__FUNCTION__, $results);
return $results;
diff --git a/app/component/product/options.php b/app/component/product/options.php
index 5921ce1..f652a69 100644
--- a/app/component/product/options.php
+++ b/app/component/product/options.php
@@ -32,13 +32,13 @@ use Vvveb\System\Images;
class Options extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- 'limit' => NULL,
- 'site_id' => NULL,
- 'language_id' => NULL,
- 'product_id' => 'url',
- 'parent_id' => NULL,
- 'search' => NULL,
+ 'start' => 0,
+ 'limit' => NULL,
+ 'site_id' => NULL,
+ 'language_id' => NULL,
+ 'product_id' => 'url',
+ 'parent_id' => NULL,
+ 'search' => NULL,
];
function results() {
diff --git a/app/component/product/subscriptions.php b/app/component/product/subscriptions.php
index b6184e8..c500899 100644
--- a/app/component/product/subscriptions.php
+++ b/app/component/product/subscriptions.php
@@ -28,13 +28,13 @@ use Vvveb\System\Event;
class Subscriptions extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- 'limit' => 7,
- 'site_id' => NULL,
- 'language_id' => NULL,
- 'product_id' => 'url',
- 'parent_id' => NULL,
- 'search' => NULL,
+ 'start' => 0,
+ 'limit' => 7,
+ 'site_id' => NULL,
+ 'language_id' => NULL,
+ 'product_id' => 'url',
+ 'parent_id' => NULL,
+ 'search' => NULL,
];
function results() {
diff --git a/app/component/products.php b/app/component/products.php
index 6129064..bfcbb98 100755
--- a/app/component/products.php
+++ b/app/component/products.php
@@ -31,27 +31,27 @@ use function Vvveb\url;
class Products extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- 'page' => 1,
- 'limit' => 4,
- 'status' => 1,
- 'source' => 'autocomplete',
- 'language_id' => null,
- 'site_id' => null,
- 'type' => 'product',
- 'parent' => null,
- 'manufacturer_id' => NULL,
- 'vendor_id' => NULL,
- 'order_by' => NULL,
- 'direction' => ['url', 'asc', 'desc'],
- 'taxonomy_item_id'=> NULL,
- 'product_image' => true,
- 'product_id' => [],
- 'search' => null,
- 'slug' => null,
- 'related' => null,
- 'variant' => null,
- 'image_size' => 'medium',
+ 'start' => 0,
+ 'page' => 1,
+ 'limit' => 4,
+ 'status' => 1,
+ 'source' => 'autocomplete',
+ 'language_id' => null,
+ 'site_id' => null,
+ 'type' => 'product',
+ 'parent' => null,
+ 'manufacturer_id' => NULL,
+ 'vendor_id' => NULL,
+ 'order_by' => NULL,
+ 'direction' => ['url', 'asc', 'desc'],
+ 'taxonomy_item_id' => NULL,
+ 'product_image' => true,
+ 'product_id' => [],
+ 'search' => null,
+ 'slug' => null,
+ 'related' => null,
+ 'variant' => null,
+ 'image_size' => 'medium',
];
public $options = [];
@@ -121,7 +121,7 @@ class Products extends ComponentBase {
$product['pubDate'] = date('r', strtotime($product['created_at']));
$url = ['slug' => $product['slug'], 'product_id' => $product['product_id']] + $language;
- $product['url'] = url('product/product/index', $url);
+ $product['url'] = url('product/product/index', $url);
$product['add_cart_url'] = url('cart/cart/add', ['product_id' => $product['product_id']]);
$product['buy_url'] = url('checkout/checkout/index', ['product_id' => $product['product_id']]);
$product['add_wishlist_url'] = url('user/wishlist/add', ['product_id' => $product['product_id']]);
diff --git a/app/component/reviews.php b/app/component/reviews.php
index ed350c9..c41db11 100755
--- a/app/component/reviews.php
+++ b/app/component/reviews.php
@@ -21,6 +21,7 @@
*/
namespace Vvveb\Component;
+
use Vvveb\Sql\Product_Review_MediaSQL;
use Vvveb\System\Images;
@@ -33,7 +34,7 @@ class Reviews extends Comments {
public static $defaultOptions = [
'product_id' => 'url',
- 'slug' => 'url',
+ 'slug' => 'url',
'product_title' => NULL, //include product title (for recent reviews etc)
'user_id' => NULL,
'status' => 1, //approved reviews
@@ -56,12 +57,12 @@ class Reviews extends Comments {
$image['image'] = Images::image($image['image'], 'product');
}
}
- }
+ }
//all product reviews images
$media = new Product_Review_MediaSQL();
- $gallery = $media->getAll($this->options + ['status'=> 1])['product_review_media'] ?? [];
-
+ $gallery = $media->getAll($this->options + ['status' => 1])['product_review_media'] ?? [];
+
if ($gallery) {
//$gallery = Images::images($gallery, 'product', $this->options['image_size']);
foreach ($gallery as &$image) {
@@ -71,8 +72,9 @@ class Reviews extends Comments {
}
$results['images'] = $gallery;
-
+
$stats = $this->modelInstance->getProductStats($this->options);
+
if ($stats) {
$results += $stats;
}
@@ -80,17 +82,20 @@ class Reviews extends Comments {
$results['rating'] = number_format($results['rating'] ?? 0, 1);
//compute width and fill missing ratings
- foreach ([1,2,3,4,5] as $rating) {
+ foreach ([1, 2, 3, 4, 5] as $rating) {
if (isset($results['summary'][$rating])) {
- $summary = &$results['summary'][$rating];
+ $summary = &$results['summary'][$rating];
$summary['percent'] = ceil($summary['count'] * 100 / $results['count']);
} else {
+ $results['summary'][$rating]['rating'] = $rating;
$results['summary'][$rating]['percent'] = 0;
- $results['summary'][$rating]['rating'] = 1;
- $results['summary'][$rating]['count'] = 0;
+ $results['summary'][$rating]['count'] = 0;
}
}
-
+
+ //$results['buyers'] = 5;
+ //$results['recommendations'] = 100;
+
return $results;
}
}
diff --git a/app/controller/base.php b/app/controller/base.php
index 3c7f314..baffc30 100755
--- a/app/controller/base.php
+++ b/app/controller/base.php
@@ -152,11 +152,11 @@ class Base {
$site = siteSettings();
$user = User::current();
- $this->global['site_id'] = SITE_ID ?? 1;
- $this->global['user_id'] = $user['user_id'] ?? false;
+ $this->global['site_id'] = SITE_ID ?? 1;
+ $this->global['user_id'] = $user['user_id'] ?? false;
$this->global['user_group_id'] = $user['user_group_id'] ?? 1;
- $this->global['site'] = $site;
- $this->global['user'] = $user ?? [];
+ $this->global['site'] = $site;
+ $this->global['user'] = $user ?? [];
$this->language($site['language'] ?? 'en_US', $site['language_id'] ?? 1);
$this->currency($site['currency'] ?? 'USD', $site['currency_id'] ?? 1);
diff --git a/app/controller/content/post.php b/app/controller/content/post.php
index 00f4d52..92e0ce8 100755
--- a/app/controller/content/post.php
+++ b/app/controller/content/post.php
@@ -26,7 +26,6 @@ use \Vvveb\Sql\PostSQL;
use function Vvveb\__;
//use Vvveb\System\Component\Component;
use Vvveb\Controller\Base;
-use function Vvveb\sanitizeHTML;
class Post extends Base {
public $type = 'post';
diff --git a/app/controller/product/product.php b/app/controller/product/product.php
index ad07d3e..4b58bb2 100755
--- a/app/controller/product/product.php
+++ b/app/controller/product/product.php
@@ -40,7 +40,6 @@ class Product extends Base {
return $this->index();
}
-
function index() {
if (isset($this->request->post['content'])) {
if (isset($this->request->post['rating'])) {
@@ -80,7 +79,7 @@ class Product extends Base {
$this->request->get['product_id'] = $languageContent['product_id'];
$this->request->request['product_id'] = $languageContent['product_id'];
- $this->request->get['name'] = $languageContent['name'];
+ $this->request->get['name'] = $languageContent['name'];
$this->request->request['name'] = $languageContent['name'];
if (isset($languageContent['template']) && $languageContent['template']) {
@@ -100,4 +99,3 @@ class Product extends Base {
}
}
}
-
diff --git a/install/controller/index.php b/install/controller/index.php
index 38fdce1..cc1b21c 100755
--- a/install/controller/index.php
+++ b/install/controller/index.php
@@ -256,7 +256,7 @@ class Index extends Base {
$site = [
'host' => $_SERVER['HTTP_HOST'] ?? '*.*.*',
- 'id' => 1,
+ 'id' => 1,
'name' => 'Default',
'theme' => $theme,
'settings' => json_encode($settings),
diff --git a/system/extensions/extensions.php b/system/extensions/extensions.php
index fc93ade..4e8d91f 100755
--- a/system/extensions/extensions.php
+++ b/system/extensions/extensions.php
@@ -237,7 +237,7 @@ abstract class Extensions {
if ($content) {
$rss = new Rss($content);
- $result[static :: $extension . 's'] = $rss->get($params['start'] ?? 1, $params['limit'] ?? 10);
+ $result[static :: $extension . 's'] = $rss->get($params['start'] ?? 1, $params['limit'] ?? 10);
$result['count'] = $rss->value('count');
return $result;
diff --git a/system/user/admin.php b/system/user/admin.php
index 333e803..181705c 100755
--- a/system/user/admin.php
+++ b/system/user/admin.php
@@ -112,7 +112,7 @@ class Admin extends Auth {
$data['status'] = 1;
$adminInfo = self::get($data);
- if (! ($adminInfo && isset(adminInfo['password'])) ||
+ if (! ($adminInfo && isset($adminInfo['password'])) ||
! self::checkPassword($data['password'], $adminInfo['password'])) {
return false;
}