Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Show 404 not found for disabled products, status = 0 Defaults for components to keep elements when displaying in page builder to avoid losing elements on page save

givanz78f4bd1884fb
diff --git a/app/component/product.php b/app/component/product.php
index 3aea5e1..94ce8b2 100755
--- a/app/component/product.php
+++ b/app/component/product.php
@@ -42,6 +42,7 @@ class Product extends ComponentBase {
'reviews' => true,
'rating' => true,
'promotion' => true,
+ 'image_size' => '',
];
function results() {
@@ -49,12 +50,12 @@ class Product extends ComponentBase {
$results = $product->get($this->options);
if (isset($results['product_image'])) {
- $results['images'] = Images::images($results['product_image'], 'product');
+ $results['images'] = Images::images($results['product_image'], 'product', $this->options['image_size']);
}
if (isset($results['image'])) {
//$results['images'][] = ['image' => Images::image('product', $results['image'])];
- $results['image']= Images::image($results['image'], 'product');
+ $results['image']= Images::image($results['image'], 'product', $this->options['image_size']);
}
$results['add_cart_url'] = url('cart/cart/add', ['product_id' => $results['product_id']]);
diff --git a/app/controller/checkout/confirm.php b/app/controller/checkout/confirm.php
index 4d0759b..1bbd673 100755
--- a/app/controller/checkout/confirm.php
+++ b/app/controller/checkout/confirm.php
@@ -27,7 +27,7 @@ use Vvveb\Controller\Base;
class Confirm extends Base {
function index() {
$order = $this->session->get('order');
- $this->view->order_id = $order['order'];
+ $this->view->order_id = $order['order'] ?? false;
if (! $order) {
$this->notFound();
diff --git a/app/controller/content/post.php b/app/controller/content/post.php
index 92e0ce8..9bc0aef 100755
--- a/app/controller/content/post.php
+++ b/app/controller/content/post.php
@@ -26,6 +26,7 @@ use \Vvveb\Sql\PostSQL;
use function Vvveb\__;
//use Vvveb\System\Component\Component;
use Vvveb\Controller\Base;
+use Vvveb\System\Event;
class Post extends Base {
public $type = 'post';
@@ -41,15 +42,16 @@ class Post extends Base {
$result = $this->insertComment();
}
- $language = $this->request->get['language'] ?? '';
+ $language = $this->request->get['language'] ?? $this->global['language'] ?? $this->global['default_language'];
$slug = $this->request->get['slug'] ?? '';
if ($slug) {
$contentSql = new PostSQL();
$options = $this->global + ['slug' => $slug, 'type' => $this->type];
- $content = $contentSql->getContent($options);
+ $content = $contentSql->getContent($options) ?? [];
- $error = __('Post not found!');
+ $error = __('Post not found!');
+ list($content, $language, $slug) = Event :: trigger(__CLASS__,__FUNCTION__, $content, $language, $slug);
if ($content) {
if (isset($content[$language])) {
diff --git a/app/controller/product/product.php b/app/controller/product/product.php
index 4b58bb2..dc8555f 100755
--- a/app/controller/product/product.php
+++ b/app/controller/product/product.php
@@ -26,10 +26,11 @@ use \Vvveb\Sql\ProductSQL;
use function Vvveb\__;
use Vvveb\Controller\Base;
use Vvveb\Controller\Content\CommentTrait;
+use Vvveb\System\Event;
class Product extends Base {
public $type = 'product';
-
+
use CommentTrait;
function addReview() {
@@ -49,14 +50,16 @@ class Product extends Base {
}
}
- $language = $this->request->get['language'] ?? '';
+ $language = $this->request->get['language'] ?? $this->global['language'] ?? $this->global['default_language'];
$slug = $this->request->get['slug'] ?? '';
if ($slug) {
$contentSql = new ProductSQL();
- $options = $this->global + ['slug' => $slug, 'type' => $this->type];
+ $options = $this->global + ['slug' => $slug, 'type' => $this->type, 'status' => 1];
$content = $contentSql->getContent($options);
+ list($content, $language, $slug) = Event :: trigger(__CLASS__,__FUNCTION__, $content, $language, $slug);
+
$error = __('Product not found!');
if ($content) {
diff --git a/app/sql/mysqli/post.sql b/app/sql/mysqli/post.sql
index b9b37da..8b266e7 100755
--- a/app/sql/mysqli/post.sql
+++ b/app/sql/mysqli/post.sql
@@ -74,7 +74,7 @@
)
BEGIN
- SELECT _.post_id,_.slug,_.name,_.meta_keywords,_.meta_description,_.language_id,post.template,language.code,language.code as array_key
+ SELECT post.*,_.post_id,_.slug,_.name,_.meta_keywords,_.meta_description,_.language_id,post.template,language.code,language.code as array_key
FROM post_content AS _
LEFT JOIN language ON (language.language_id = _.language_id)
LEFT JOIN post ON (post.post_id = _.post_id)
diff --git a/app/sql/mysqli/product.sql b/app/sql/mysqli/product.sql
index 4750a0d..34953dd 100755
--- a/app/sql/mysqli/product.sql
+++ b/app/sql/mysqli/product.sql
@@ -2,10 +2,12 @@
import(/admin/product.sql);
+
-- get all languages content
CREATE PROCEDURE getContent(
IN product_id INT,
+ IN status INT,
IN slug CHAR,
OUT fetch_all,
)
@@ -17,7 +19,12 @@
LEFT JOIN product ON (product.product_id = _.product_id)
WHERE 1 = 1
- @IF isset(:slug)
+ @IF isset(:status)
+ THEN
+ AND product.status = :status
+ END @IF
+
+ @IF isset(:slug)
THEN
AND _.product_id = (SELECT product_id FROM product_content WHERE slug = :slug LIMIT 1)
END @IF
diff --git a/app/sql/pgsql/post.sql b/app/sql/pgsql/post.sql
index 920474a..7ec6df4 100755
--- a/app/sql/pgsql/post.sql
+++ b/app/sql/pgsql/post.sql
@@ -37,7 +37,7 @@
END @IF
FROM post AS _
- LEFT JOIN post_content pd ON (_.post_id = pd.post_id)
+ LEFT JOIN post_content pd ON (_.post_id = pd.post_id AND pd.language_id = :language_id)
LEFT JOIN admin ad ON (_.admin_id = ad.admin_id)
WHERE 1 = 1
@@ -49,11 +49,6 @@
@IF isset(:post_id)
THEN
AND _.post_id = :post_id
- END @IF
-
- @IF isset(:language_id)
- THEN
- AND pd.language_id = :language_id
END @IF
@IF isset(:type)
@@ -79,7 +74,7 @@
)
BEGIN
- SELECT _.post_id,_.slug,_.name,_.meta_keywords,_.meta_description,_.language_id,post.template,language.code,language.code as array_key
+ SELECT post.*,_.post_id,_.slug,_.name,_.meta_keywords,_.meta_description,_.language_id,post.template,language.code,language.code as array_key
FROM post_content AS _
LEFT JOIN language ON (language.language_id = _.language_id)
LEFT JOIN post ON (post.post_id = _.post_id)
diff --git a/app/sql/pgsql/product.sql b/app/sql/pgsql/product.sql
index 623d2fe..1934025 100755
--- a/app/sql/pgsql/product.sql
+++ b/app/sql/pgsql/product.sql
@@ -7,6 +7,7 @@
CREATE PROCEDURE getContent(
IN product_id INT,
+ IN status INT,
IN slug CHAR,
OUT fetch_all,
)
@@ -18,6 +19,11 @@
LEFT JOIN product ON (product.product_id = _.product_id)
WHERE 1 = 1
+ @IF isset(:status)
+ THEN
+ AND product.status = :status
+ END @IF
+
@IF isset(:slug)
THEN
AND _.product_id = (SELECT product_id FROM product_content WHERE slug = :slug LIMIT 1)
diff --git a/app/sql/sqlite/post.sql b/app/sql/sqlite/post.sql
index c5d0664..3c91738 100755
--- a/app/sql/sqlite/post.sql
+++ b/app/sql/sqlite/post.sql
@@ -74,7 +74,7 @@
)
BEGIN
- SELECT _.post_id,_.slug,_.name,_.meta_keywords,_.meta_description,_.language_id,post.template,language.code,language.code as array_key
+ SELECT post.*,_.post_id,_.slug,_.name,_.meta_keywords,_.meta_description,_.language_id,post.template,language.code,language.code as array_key
FROM post_content AS _
LEFT JOIN language ON (language.language_id = _.language_id)
LEFT JOIN post ON (post.post_id = _.post_id)
diff --git a/app/sql/sqlite/product.sql b/app/sql/sqlite/product.sql
index 623d2fe..1934025 100755
--- a/app/sql/sqlite/product.sql
+++ b/app/sql/sqlite/product.sql
@@ -7,6 +7,7 @@
CREATE PROCEDURE getContent(
IN product_id INT,
+ IN status INT,
IN slug CHAR,
OUT fetch_all,
)
@@ -18,6 +19,11 @@
LEFT JOIN product ON (product.product_id = _.product_id)
WHERE 1 = 1
+ @IF isset(:status)
+ THEN
+ AND product.status = :status
+ END @IF
+
@IF isset(:slug)
THEN
AND _.product_id = (SELECT product_id FROM product_content WHERE slug = :slug LIMIT 1)
diff --git a/app/template/cart/cart.tpl b/app/template/cart/cart.tpl
index d1d5daf..2cbeb3e 100755
--- a/app/template/cart/cart.tpl
+++ b/app/template/cart/cart.tpl
@@ -37,7 +37,7 @@ if(is_array($products)) foreach ($products as $key => $product) {
@cart-option|before = <?php
-$_default = (isset($vvveb_is_page_edit) && $vvveb_is_page_edit ) ? [0 => ['product_option_value_id' => 1]] : false;
+$_default = (isset($vvveb_is_page_edit) && $vvveb_is_page_edit ) ? [0 => 'product_option_value_id'] : false;
$option_value = empty($product['option_value']) ? $_default : $product['option_value'];
if($option_value) {
diff --git a/app/template/components/cart.tpl b/app/template/components/cart.tpl
index 9bbddbd..e07953e 100755
--- a/app/template/components/cart.tpl
+++ b/app/template/components/cart.tpl
@@ -53,7 +53,7 @@ if($products) {
@cart-option|before = <?php
-$_default = (isset($vvveb_is_page_edit) && $vvveb_is_page_edit ) ? [0 => ['product_option_value_id' => 1]] : false;
+$_default = (isset($vvveb_is_page_edit) && $vvveb_is_page_edit ) ? [0 => 'product_option_value_id'] : false;
$option_value = empty($product['option_value']) ? $_default : $product['option_value'];
if($option_value) {
diff --git a/app/template/components/questions.tpl b/app/template/components/questions.tpl
index df10512..9f50da5 100644
--- a/app/template/components/questions.tpl
+++ b/app/template/components/questions.tpl
@@ -14,7 +14,7 @@ $_pagination_limit = isset($questions['limit']) ? $questions['limit'] : 5;
?>
@question|before = <?php
-$_default = (isset($vvveb_is_page_edit) && $vvveb_is_page_edit ) ? [0 => []] : false;
+$_default = (isset($vvveb_is_page_edit) && $vvveb_is_page_edit ) ? [0 => ['product_question_id' => 0, 'content' => '']] : false;
$questions = empty($questions) ? $_default : $questions;
if($questions && is_array($questions)) {
diff --git a/app/template/components/reviews.tpl b/app/template/components/reviews.tpl
index 0fa1ac5..4667188 100755
--- a/app/template/components/reviews.tpl
+++ b/app/template/components/reviews.tpl
@@ -17,7 +17,7 @@ $_pagination_limit = isset($reviews['limit']) ? $reviews['limit'] : 5;
@review|before = <?php
-$_default = (isset($vvveb_is_page_edit) && $vvveb_is_page_edit ) ? [0 => ['product_review_id']] : false;
+$_default = (isset($vvveb_is_page_edit) && $vvveb_is_page_edit ) ? [0 => ['product_review_id' => 0, 'content' => '']] : false;
$reviews = empty($reviews) ? $_default : $reviews;
if($reviews && is_array($reviews)) {