Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Model entity name renamed to singular

givanz3c0efd8f4cfa
diff --git a/admin/controller/base.php b/admin/controller/base.php
index e572719..f2261be 100755
--- a/admin/controller/base.php
+++ b/admin/controller/base.php
@@ -560,7 +560,7 @@ class Base {
FrontController::closeConnections();
PageCache::getInstance()->cleanUp();
- die();
+ die(0);
}
}
diff --git a/admin/controller/content/autocomplete-trait.php b/admin/controller/content/autocomplete-trait.php
index 6c4a4bd..de76875 100644
--- a/admin/controller/content/autocomplete-trait.php
+++ b/admin/controller/content/autocomplete-trait.php
@@ -109,8 +109,8 @@ trait AutocompleteTrait {
$search = [];
- if (isset($results['products'])) {
- foreach ($results['products'] as $product) {
+ if (isset($results['product'])) {
+ foreach ($results['product'] as $product) {
$product['image'] = Images::image($product['image'], 'product', 'thumb');
$search[] = [
'type' => 'cardimage',
@@ -125,8 +125,8 @@ trait AutocompleteTrait {
$posts = new \Vvveb\Sql\PostSQL();
$results = $posts->getAll($options);
- if (isset($results['posts'])) {
- foreach ($results['posts'] as $post) {
+ if (isset($results['post'])) {
+ foreach ($results['post'] as $post) {
$post['image'] = Images::image($post['image'], 'post', 'thumb');
$search[] = [
'type' => 'cardimage',
@@ -155,8 +155,8 @@ trait AutocompleteTrait {
$search = [];
- if (isset($results['products'])) {
- foreach ($results['products'] as $product) {
+ if (isset($results['product'])) {
+ foreach ($results['product'] as $product) {
$product['image'] = Images::image($product['image'], $this->object);
$search[$product[$this->object . '_id']] = '<img width="32" height="32" src="' . $product['image'] . '"> ' . $product['name'];
}
diff --git a/admin/controller/content/categories.php b/admin/controller/content/categories.php
index 1180b67..9533024 100755
--- a/admin/controller/content/categories.php
+++ b/admin/controller/content/categories.php
@@ -36,7 +36,7 @@ class Categories extends Base {
echo __('Item removed!');
}
- die();
+ die(0);
}
function reorder() {
@@ -48,7 +48,7 @@ class Categories extends Base {
echo __('Items reordered!');
}
- die();
+ die(0);
}
function add() {
@@ -76,7 +76,7 @@ class Categories extends Base {
}
}
- die();
+ die(0);
return;
}
diff --git a/admin/controller/content/comments.php b/admin/controller/content/comments.php
index b708693..09bed57 100755
--- a/admin/controller/content/comments.php
+++ b/admin/controller/content/comments.php
@@ -34,7 +34,7 @@ use Vvveb\System\Images;
class Comments extends Listing {
protected $type = 'comment';
- protected $list = 'comments';
+ protected $list = 'comment';
protected $module = 'content';
@@ -59,12 +59,12 @@ class Comments extends Listing {
}
function index() {
- $view = View :: getInstance();
- $type = $this->type;
+ $view = View :: getInstance();
+ $type = $this->type;
$controller = $this->controller ?? $type;
$listController = $this->listController ?? $controller;
- $module = $this->module;
- $list = $this->list ?? $type . 's';
+ $module = $this->module;
+ $list = $this->list ?? $type . 's';
$status = $this->request->get['status'] ?? '';
$comment_status = [
diff --git a/admin/controller/content/edit.php b/admin/controller/content/edit.php
index 4aedf9b..1592a31 100644
--- a/admin/controller/content/edit.php
+++ b/admin/controller/content/edit.php
@@ -64,7 +64,7 @@ class Edit extends Base {
'start' => 0,
'limit' => 100,
]
- )['sites'] ?? [];
+ )['site'] ?? [];
if ($results && $selectedSites) {
foreach ($results as &$site) {
@@ -177,6 +177,7 @@ class Edit extends Base {
$url = ['host' => $this->global['site_url']];
$revisionsUrl = \Vvveb\url(['module' => "$controller/revisions", 'object' => $this->object, 'type' => $this->type, $this->object . '_id' => $post_id]);
+ $name = '';
if (isset($post[$this->object . '_content'])) {
foreach ($post[$this->object . '_content'] as &$content) {
@@ -196,6 +197,8 @@ class Edit extends Base {
}
}
$language = ['language' => $code];
+ } else {
+ $name = $content['name'];
}
$content['url'] = \Vvveb\url($route, $content + $language + $url);
@@ -209,13 +212,13 @@ class Edit extends Base {
$revision = $revisions->getAll([$this->object . '_id' => $post_id, 'language_id' => $content['language_id']]);
if ($revision) {
- foreach ($revision['revision'] as &$rev) {
+ foreach ($revision[$this->object . '_content_revision'] as &$rev) {
$rev['preview-url'] = $content['url'] . '?revision=preview&created_at=' . $rev['created_at'];
$rev['compare-url'] = $revisionsUrl . '&created_at=' . $rev['created_at'];
}
$content['revision_count'] = $revision['count'];
- $content['revision'] = $revision['revision'];
+ $content['revision'] = $revision[$this->object . '_content_revision'];
}
}
}
@@ -230,7 +233,7 @@ class Edit extends Base {
$design_url = '';
if (isset($post['url'])) {
- $design_url = \Vvveb\url(['module' => 'editor/editor', 'url' => $post['url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
+ $design_url = \Vvveb\url(['module' => 'editor/editor', 'name' => urlencode($name), 'url' => $content['url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
$post['design_url'] = $design_url;
}
diff --git a/admin/controller/content/menus.php b/admin/controller/content/menus.php
index 9b7e071..7df51da 100755
--- a/admin/controller/content/menus.php
+++ b/admin/controller/content/menus.php
@@ -81,7 +81,7 @@ class Menus extends Categories {
echo $menus->error;
}
- die();
+ die(0);
return $this->index();
}
@@ -95,7 +95,7 @@ class Menus extends Categories {
echo __('Items reordered!');
}
- die();
+ die(0);
}
function add() {
@@ -118,13 +118,14 @@ class Menus extends Categories {
}
}
- $response = [];
- $success = true;
+ $response = [];
+ $success = true;
$menu_item_id = false;
-
+
if (isset($data['menu_item_id']) && $data['menu_item_id']) {
- $results = $menus->editMenuItem(['menu_item' => $data, 'menu_item_id' => $data['menu_item_id']]);
+ $results = $menus->editMenuItem(['menu_item' => $data, 'menu_item_id' => $data['menu_item_id']]);
$menu_item_id = $data['menu_item_id'];
+
if ($results) {
$message = __('Item saved!');
} else {
@@ -136,13 +137,13 @@ class Menus extends Categories {
if ($results) {
$menu_item_id = $results['menu_item'];
- $message = __('Item added!');
+ $message = __('Item added!');
} else {
$message = __('Error!');
$success = false;
}
}
-
+
$response += ['success' => $success, 'message' => $message, 'menu_item_id' => $menu_item_id];
$this->response->setType('json');
@@ -229,7 +230,7 @@ class Menus extends Categories {
'limit' => 10000,
] + $this->global;
- $results = $menus->getMenusList($options);
+ $results = $menus->getAll($options);
if (isset($results['menu'])) {
foreach ($results['menu'] as &$menu) {
diff --git a/admin/controller/content/posts.php b/admin/controller/content/posts.php
index dc56181..b2637d1 100755
--- a/admin/controller/content/posts.php
+++ b/admin/controller/content/posts.php
@@ -225,8 +225,8 @@ class Posts extends Base {
$defaultTemplate = "content/{$this->type}.html";
- if ($results && isset($results['posts'])) {
- foreach ($results['posts'] as $id => &$post) {
+ if ($results && isset($results['post'])) {
+ foreach ($results['post'] as $id => &$post) {
if (isset($post['image'])) {
$post['image'] = Images::image($post['image'], 'post');
}
@@ -240,7 +240,7 @@ class Posts extends Base {
$post['delete-url'] = url(['module' => 'content/posts', 'action' => 'delete'] + $url + ['post_id[]' => $post['post_id']]);
$post['duplicate-url'] = url(['module' => 'content/posts', 'action' => 'duplicate'] + $url + ['post_id' => $post['post_id']]);
$post['view-url'] = url("content/{$this->type}/index", $post + $url + ['host' => $this->global['site_url']]);
- $post['design-url'] = url(['module' => 'editor/editor', 'url' => $post['view-url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
+ $post['design-url'] = url(['module' => 'editor/editor', 'name' => urlencode($post['name'] ?? ''), 'url' => $post['view-url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
}
}
diff --git a/admin/controller/editor/autocomplete.php b/admin/controller/editor/autocomplete.php
index 4567ec2..71ad524 100755
--- a/admin/controller/editor/autocomplete.php
+++ b/admin/controller/editor/autocomplete.php
@@ -34,7 +34,7 @@ class Autocomplete extends Base {
$options = [
'start' => 0,
'limit' => 10,
- 'like' => $text,
+ 'like' => $text,
] + $this->global;
unset($options['admin_id']);
@@ -43,7 +43,7 @@ class Autocomplete extends Base {
$search = [];
- foreach ($results['products'] as $product) {
+ foreach ($results['product'] as $product) {
$search[$product['product_id']] = $product['name'];
}
@@ -105,7 +105,7 @@ class Autocomplete extends Base {
'start' => 0,
'limit' => 10,
'type' => $type,
- 'like' => $text,
+ 'like' => $text,
//'like' => '%' . $text . '%',
] + $this->global;
@@ -115,8 +115,8 @@ class Autocomplete extends Base {
$search = [];
- if (isset($results['posts'])) {
- foreach ($results['posts'] as $post) {
+ if (isset($results['post'])) {
+ foreach ($results['post'] as $post) {
$search[$post['post_id']] = substr($post['name'],0, 50);
}
}
diff --git a/admin/controller/field/field-group.php b/admin/controller/field/field-group.php
new file mode 100644
index 0000000..74ece63
--- /dev/null
+++ b/admin/controller/field/field-group.php
@@ -0,0 +1,108 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller\Field;
+
+use function Vvveb\__;
+use Vvveb\Controller\Crud;
+use Vvveb\Sql\CountrySQL;
+use Vvveb\Sql\Field_GroupSQL;
+use Vvveb\Sql\FieldSQL;
+
+class FieldGroup extends Crud {
+ protected $type = 'field_group';
+
+ protected $controller = 'field-group';
+
+ protected $module = 'field';
+
+ function save() {/*
+ $field = $this->request->post['field'] ?? [];
+ $field_group_id = $this->request->get['field_group_id'] ?? false;
+
+ if ($field_group_id) {
+ $fieldGroup = new Field_GroupSQL();
+ $result = $fieldGroup->addFields(['field_group_id' => $field_group_id, 'field_to_field_group' => $field]);
+
+ if ($result && isset($result['field_to_field_group'])) {
+ $successMessage = __('Field saved!');
+ $this->view->success[] = $successMessage;
+ $this->view->errors = [];
+ } else {
+ $this->view->errors[] = __('Error saving!');
+ }
+ }*/
+
+ $this->request->post[$this->type]['status'] = 1;
+
+ parent::save();
+ }
+
+ function fields() {
+ $country_id = $this->request->get['country_id'] ?? false;
+ $fields = [];
+
+ if ($country_id) {
+ $field = new FieldSQL();
+ $options = $this->global;
+ $options['status'] = 1;
+ $options['country_id'] = $country_id;
+ unset($options['limit']);
+ $fields = $field->getAll($options)['field'] ?? [];
+ }
+
+ $this->response->setType('json');
+ $this->response->output($fields);
+ //return [];
+ }
+
+ function index() {
+ $field_group_id = $this->request->get['field_group_id'] ?? false;
+ $this->view->field_group_id = $field_group_id;
+
+ parent::index();
+
+ return;
+ $field_group_id = $this->request->get['field_group_id'] ?? false;
+
+ $fields = [];
+
+ if ($field_group_id) {
+ $fieldGroup = new Field_GroupSQL();
+ $fields = $fieldGroup->getFields(['field_group_id' => $field_group_id])['fields'] ?? [];
+ }
+ $this->view->fields = $fields;
+ $this->view->field_group_id = $field_group_id;
+
+ $countryModel = new CountrySQL();
+ $options = $this->global;
+ $options['status'] = 1;
+ unset($options['limit']);
+ $country = $countryModel->getAll($options);
+
+ $this->view->countries = $country['country'] ?? [];
+
+ $admin_path = \Vvveb\adminPath();
+ $controllerPath = $admin_path . 'index.php?module=localization/field-group';
+ $this->view->fieldsUrl = "$controllerPath&action=fields";
+ }
+}
diff --git a/app/controller/rest.php b/admin/controller/field/field-groups.php
old mode 100755
new mode 100644
similarity index 65%
rename from app/controller/rest.php
rename to admin/controller/field/field-groups.php
index 96e8f61..f3bc8cf
--- a/app/controller/rest.php
+++ b/admin/controller/field/field-groups.php
@@ -20,35 +20,18 @@
*
*/
-namespace Vvveb\Controller;
+namespace Vvveb\Controller\Field;
-#[\AllowDynamicProperties]
-class Rest {
- private $method = 'GET';
+use Vvveb\Controller\Listing;
- function _construct() {
- $this->method = $this->request->method;
+class FieldGroups extends Listing {
+ protected $type = 'field_group';
- switch ($this->method) {
- case 'GET':
- break;
+ protected $controller = 'field-group';
- case 'POST':
- break;
+ protected $listController = 'field-group';
- case 'PUT':
- break;
+ protected $list = 'field_group';
- case 'DELETE':
- $this->action = 'delete';
-
- break;
- }
- }
-
- function index() {
- var_dump($this->request->get);
-
- die();
- }
+ protected $module = 'field';
}
diff --git a/admin/controller/localization/currencies.php b/admin/controller/localization/currencies.php
index 1eb606c..2ed15b1 100755
--- a/admin/controller/localization/currencies.php
+++ b/admin/controller/localization/currencies.php
@@ -27,7 +27,7 @@ use Vvveb\Controller\Listing;
class Currencies extends Listing {
protected $type = 'currency';
- protected $list = 'currencies';
+ protected $list = 'currency';
protected $listController = 'currencies';
diff --git a/admin/controller/localization/languages.php b/admin/controller/localization/languages.php
index bb4cc71..5ae787f 100755
--- a/admin/controller/localization/languages.php
+++ b/admin/controller/localization/languages.php
@@ -27,7 +27,7 @@ use Vvveb\Controller\Listing;
class Languages extends Listing {
protected $type = 'language';
- protected $list = 'languages';
+ protected $list = 'language';
protected $module = 'localization';
}
diff --git a/admin/controller/localization/translations.php b/admin/controller/localization/translations.php
index af709e8..21247f1 100755
--- a/admin/controller/localization/translations.php
+++ b/admin/controller/localization/translations.php
@@ -106,7 +106,6 @@ class Translations extends Base {
if ($lang && $domain) {
$poFile = DIR_ROOT . 'locale' . DS . $lang . DS . 'LC_MESSAGES' . DS . $domain . '.po';
$view->poFile = $poFile;
- //$poFile = '/home/www/vvveb/vvveb/locale/ro_RO/LC_MESSAGES/vvveb.po';
if (file_exists($poFile)) {
$view->translations = phpmo_parse_po_file($poFile);
diff --git a/admin/controller/media/media.php b/admin/controller/media/media.php
index 6615f93..e59e15d 100755
--- a/admin/controller/media/media.php
+++ b/admin/controller/media/media.php
@@ -24,9 +24,9 @@ namespace Vvveb\Controller\Media;
use function Vvveb\__;
use Vvveb\Controller\Base;
-use Vvveb\Sql\media_ContentSQL;
use function Vvveb\fileUploadErrMessage;
use function Vvveb\sanitizeFileName;
+use Vvveb\Sql\media_ContentSQL;
class Media extends Base {
protected $uploadDenyExtensions = ['php', 'svg', 'js'];
@@ -146,7 +146,7 @@ class Media extends Base {
$file = sanitizeFileName($this->request->post['file']);
$newfile = sanitizeFileName($this->request->post['newfile']);
$duplicate = $this->request->post['duplicate'] ?? false;
- $dirMedia = DIR_MEDIA;
+ $dirMedia = DIR_MEDIA;
$currentFile = $dirMedia . DS . $file;
$targetFile = $dirMedia . DS . $newfile;
@@ -170,11 +170,12 @@ class Media extends Base {
}
function newFolder() {
- $folder = sanitizeFileName($this->request->post['folder']);
- $path = sanitizeFileName($this->request->post['path']);
+ $folder = sanitizeFileName($this->request->post['folder']);
+ $path = sanitizeFileName($this->request->post['path']);
$success = false;
-
+
$dirMedia = DIR_MEDIA;
+
if (is_dir($dirMedia . $path)) {
if (@mkdir($dirMedia . $path . DS . $folder)) {
$message = __('Folder created!');
@@ -185,43 +186,42 @@ class Media extends Base {
} else {
$message = __('Path does not exist!');
}
-
+
$message = ['success' => $success, 'message' => $message];
$this->response->setType('json');
$this->response->output($message);
}
-
+
function mediaContentSave() {
$file = sanitizeFileName($this->request->post['file']);
$content = ($this->request->post['media_content']);
$mediaContent = new media_ContentSQL();
- $media = $mediaContent->get(['file' => $file] + $this->global);
+ $media = $mediaContent->get(['file' => $file] + $this->global);
+
if ($media) {
- //var_dump(['media_id' => $media['media_id'], 'media_content' => $content]);
- $result = $mediaContent->edit(['media_id' => $media['media_id'], 'media_content' => $content, 'media' => []]);
+ $result = $mediaContent->edit(['media_id' => $media['media_id'], 'media_content' => $content, 'media' => []]);
} else {
- //var_dump(['media' => ['file' => $file], 'media_content' => $content]);
$result = $mediaContent->add(['media' => ['file' => $file], 'media_content' => $content]);
}
-
+
if ($result) {
$message = ['success' => true, 'message' => __('Saved!')];
} else {
$message = ['success' => false, 'message' => __('Error saving!')];
- }
+ }
$this->response->setType('json');
$this->response->output($message);
}
-
+
function mediaContent() {
$file = sanitizeFileName($this->request->get['file']);
$themeFolder = DIR_MEDIA;
$mediaContent = new media_ContentSQL();
- $result = $mediaContent->getContent(['file' => $file] + $this->global);
+ $result = $mediaContent->getContent(['file' => $file] + $this->global);
$this->response->setType('json');
$this->response->output($result ?? []);
diff --git a/admin/controller/plugin/plugins.php b/admin/controller/plugin/plugins.php
index 8a9e3e9..306b5f7 100755
--- a/admin/controller/plugin/plugins.php
+++ b/admin/controller/plugin/plugins.php
@@ -51,10 +51,10 @@ class Plugins extends Base {
return $this->index();
}
- function activate() {
+ function checkPluginAndActivate() {
$global = $this->request->get['plugin'] ?? false;
$this->category = $this->request->get['category'] ?? false;
- $this->pluginCheckUrl = \Vvveb\url(['module' => 'plugin/plugins', 'action'=> 'checkPluginAndActivate', 'plugin' => $this->plugin, 'category' => $this->category]);
+ $this->pluginCheckUrl = \Vvveb\url(['module' => 'plugin/plugins', 'action'=> 'activate', 'plugin' => $this->plugin, 'category' => $this->category]);
$this->view->checkPluginUrl = $this->pluginCheckUrl;
$this->view->info[] = sprintf(__('Activating %s plugin ...'), '<b>' . \Vvveb\humanReadable($this->plugin) . '</b> <span class="spinner-border spinner-border-sm align-middle" role="status" aria-hidden="true"></span>');
@@ -118,7 +118,7 @@ class Plugins extends Base {
if ($this->pluginSlug) {
$this->pluginName = \Vvveb\humanReadable($this->pluginSlug);
$this->pluginName = "<b>$this->pluginName</b>";
- $this->pluginActivateUrl = \Vvveb\url(['module' => 'plugin/plugins', 'action'=> 'activate', 'plugin' => $this->pluginSlug]);
+ $this->pluginActivateUrl = \Vvveb\url(['module' => 'plugin/plugins', 'action'=> 'checkPluginAndActivate', 'plugin' => $this->pluginSlug]);
$successMessage = sprintf(__('Plugin %s was successfully installed!'), $this->pluginName, $this->pluginActivateUrl);
$successMessage .= "<p><a class='btn btn-primary btn-sm m-2' href='{$this->pluginActivateUrl}'>" . __('Activate plugin') . '</a></p>';
$this->view->success[] = $successMessage;
@@ -132,7 +132,7 @@ class Plugins extends Base {
return $this->index();
}
- function checkPluginAndActivate() {
+ function activate() {
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
@@ -158,7 +158,7 @@ class Plugins extends Base {
$error['title'] = sprintf(__('Error activating plugin `%s`!'), $this->plugin);
FrontController::notFound(false, $error, 500);
- die();
+ die(0);
}
if ($active) {
diff --git a/admin/controller/product/manufacturers.php b/admin/controller/product/manufacturers.php
index f128cac..6908da7 100755
--- a/admin/controller/product/manufacturers.php
+++ b/admin/controller/product/manufacturers.php
@@ -27,7 +27,7 @@ use Vvveb\Controller\Listing;
class Manufacturers extends Listing {
protected $type = 'manufacturer';
- protected $list = 'manufacturers';
+ protected $list = 'manufacturer';
protected $module = 'product';
}
diff --git a/admin/controller/product/product-question.php b/admin/controller/product/product-question.php
index ed39813..14ea8af 100755
--- a/admin/controller/product/product-question.php
+++ b/admin/controller/product/product-question.php
@@ -27,7 +27,7 @@ use Vvveb\Controller\Content\Comment;
class Productquestion extends Comment {
protected $type = 'product_question';
- protected $list = 'product_questions';
+ protected $list = 'product_question';
protected $module = 'product';
diff --git a/admin/controller/product/product-questions.php b/admin/controller/product/product-questions.php
index 8d1fc62..b15d4d3 100755
--- a/admin/controller/product/product-questions.php
+++ b/admin/controller/product/product-questions.php
@@ -27,7 +27,7 @@ use Vvveb\Controller\Content\Comments;
class ProductQuestions extends Comments {
protected $type = 'product_question';
- protected $list = 'product_questions';
+ protected $list = 'product_question';
protected $listController = 'product-questions';
diff --git a/admin/controller/product/product-review.php b/admin/controller/product/product-review.php
index b094c4b..f3d57a1 100755
--- a/admin/controller/product/product-review.php
+++ b/admin/controller/product/product-review.php
@@ -27,7 +27,7 @@ use Vvveb\Controller\Content\Comment;
class ProductReview extends Comment {
protected $type = 'product_review';
- protected $list = 'product_reviews';
+ protected $list = 'product_review';
protected $module = 'product';
diff --git a/admin/controller/product/product-reviews.php b/admin/controller/product/product-reviews.php
index dc6e23c..5c7acbf 100755
--- a/admin/controller/product/product-reviews.php
+++ b/admin/controller/product/product-reviews.php
@@ -27,7 +27,7 @@ use Vvveb\Controller\Content\Comments;
class ProductReviews extends Comments {
protected $type = 'product_review';
- protected $list = 'product_reviews';
+ protected $list = 'product_review';
protected $module = 'product';
diff --git a/admin/controller/product/product.php b/admin/controller/product/product.php
index 1ae03fe..e7bfbb3 100755
--- a/admin/controller/product/product.php
+++ b/admin/controller/product/product.php
@@ -117,19 +117,21 @@ class Product extends Edit {
$this->product_id = $this->request->get[$this->object . '_id'] ?? $post[$this->object . '_id'] ?? false;
- $this->saveOptions();
+ if ($this->product_id) {
+ $this->saveOptions();
- $product = new ProductSQL();
- $features = ['related', 'variant', 'subscription', 'discount', 'promotion', 'points', 'attribute', 'digital_asset'];
+ $product = new ProductSQL();
+ $features = ['related', 'variant', 'subscription', 'discount', 'promotion', 'points', 'attribute', 'digital_asset'];
- foreach ($features as $feature) {
- $feature = $this->object . '_' . $feature; //eg: product_related
- $data = $this->request->post[$feature] ?? [];
+ foreach ($features as $feature) {
+ $feature = $this->object . '_' . $feature; //eg: product_related
+ $data = $this->request->post[$feature] ?? [];
- if ($data) {
- $fn = lcfirst(dashesToCamelCase($feature, '_')); //eg: $product->productRelated()
- unset($data['#']);
- $product->$fn([$this->object . '_id' => $this->product_id, $feature => array_unique($data, SORT_REGULAR)]);
+ if ($data) {
+ $fn = lcfirst(dashesToCamelCase($feature, '_')); //eg: $product->productRelated()
+ unset($data['#']);
+ $product->$fn([$this->object . '_id' => $this->product_id, $feature => array_unique($data, SORT_REGULAR)]);
+ }
}
}
diff --git a/admin/controller/product/products.php b/admin/controller/product/products.php
index e07ea58..004b753 100755
--- a/admin/controller/product/products.php
+++ b/admin/controller/product/products.php
@@ -160,8 +160,8 @@ class Products extends Base {
$defaultTemplate = "product/{$this->type}.html";
- if ($results && isset($results['products'])) {
- foreach ($results['products'] as $id => &$product) {
+ if ($results && isset($results['product'])) {
+ foreach ($results['product'] as $id => &$product) {
if (isset($product['images'])) {
$product['images'] = json_decode($product['images'], 1);
@@ -181,7 +181,7 @@ class Products extends Base {
$product['duplicate-url'] = url(['module' => 'product/products', 'action' => 'duplicate', 'product_id' => $product['product_id'], 'type' => $product['type']]);
$product['view-url'] = url('product/product/index', $product + ['host' => $this->global['site_url']]);
$admin_path = \Vvveb\adminPath();
- $product['design-url'] = url(['module' => 'editor/editor', 'url' => $product['view-url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
+ $product['design-url'] = url(['module' => 'editor/editor', 'name' => urlencode($product['name'] ?? ''), 'url' => $product['view-url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
}
}
diff --git a/admin/controller/product/vendors.php b/admin/controller/product/vendors.php
index db71c04..6e66b4c 100755
--- a/admin/controller/product/vendors.php
+++ b/admin/controller/product/vendors.php
@@ -27,7 +27,7 @@ use Vvveb\Controller\Listing;
class Vendors extends Listing {
protected $type = 'vendor';
- protected $list = 'vendors';
+ protected $list = 'vendor';
protected $module = 'product';
}
diff --git a/admin/controller/settings/post-types.php b/admin/controller/settings/post-types.php
index a8f65d1..f76d858 100644
--- a/admin/controller/settings/post-types.php
+++ b/admin/controller/settings/post-types.php
@@ -91,7 +91,7 @@ class PostTypes extends Listing {
$types = $this->defaultTypes + $pluginTypes + $userTypes;
- $this->view->types = $types;
+ $this->view->type = $types;
$this->view->count = count($types);
}
}
diff --git a/admin/controller/settings/sites.php b/admin/controller/settings/sites.php
index 01eb497..f3e3ee2 100755
--- a/admin/controller/settings/sites.php
+++ b/admin/controller/settings/sites.php
@@ -42,7 +42,6 @@ class Sites extends Base {
$active_deleted = false;
$active_site_id = $this->session->get('site_id');
-
if (is_numeric($site_id)) {
$site_id = [$site_id];
}
@@ -91,7 +90,7 @@ class Sites extends Base {
} else {
$options['site_id'] = Admin :: siteAccess();
}
-
+
$page = $this->request->get['page'] ?? 1;
$limit = $this->request->get['limit'] ?? 10;
@@ -102,14 +101,14 @@ class Sites extends Base {
]
);
- if (isset($results['sites'])) {
- foreach ($results['sites'] as &$site) {
+ if (isset($results['site'])) {
+ foreach ($results['site'] as &$site) {
$site['url'] = SitesList::url($site['host']);
$site['delete-url'] = \Vvveb\url(['module' => 'settings/sites', 'action' => 'delete', 'site_id[]' => $site['site_id']]);
}
}
- $view->sitesList = $results['sites'] ?? [];
+ $view->sitesList = $results['site'] ?? [];
$view->count = $results['count'] ?? 0;
}
}
diff --git a/admin/template/field/field-group.tpl b/admin/template/field/field-group.tpl
new file mode 100644
index 0000000..5d17f2f
--- /dev/null
+++ b/admin/template/field/field-group.tpl
@@ -0,0 +1,2 @@
+import(crud.tpl, {"type":"field_group"})
+
diff --git a/admin/template/field/field-groups.tpl b/admin/template/field/field-groups.tpl
new file mode 100644
index 0000000..5f806c6
--- /dev/null
+++ b/admin/template/field/field-groups.tpl
@@ -0,0 +1 @@
+import(listing.tpl, {"type":"field_group", "list": "field_group"})
diff --git a/admin/template/listing.tpl b/admin/template/listing.tpl
index 15add12..1e09b89 100755
--- a/admin/template/listing.tpl
+++ b/admin/template/listing.tpl
@@ -6,8 +6,8 @@ import(pagination.tpl)
@{{type}}|before = <?php
$count = 0;
-if(isset($this->{{list}}) && is_array($this->{{list}})) {
- foreach ($this->{{list}} as $index => ${{type}}) { ?>
+if(isset($this->{{type}}) && is_array($this->{{type}})) {
+ foreach ($this->{{type}} as $index => ${{type}}) { ?>
@{{type}} [data-v-{{type}}-*]|innerText = ${{type}}['@@__data-v-{{type}}-(*)__@@']
@{{type}} input[data-v-{{type}}-*]|value = ${{type}}['@@__data-v-{{type}}-(*)__@@']
diff --git a/admin/template/plugin/plugins_list.tpl b/admin/template/plugin/plugins_list.tpl
index 8a756fa..0db2c78 100755
--- a/admin/template/plugin/plugins_list.tpl
+++ b/admin/template/plugin/plugins_list.tpl
@@ -9,6 +9,7 @@ if(isset($this->plugins) && is_array($this->plugins)) {
$category = $this->category ?? '';
foreach ($this->plugins as $index => $plugin) { ?>
+ @plugin|id = <?php echo 'plugin-' . $plugin['slug'];?>
@plugin img[data-v-plugin-screenshot]|src = $plugin['screenshot']
@plugin input[data-v-vvveb-action]|value = $plugin['slug']
@@ -17,10 +18,10 @@ if(isset($this->plugins) && is_array($this->plugins)) {
@plugin [data-v-plugin-author-url]|href = <?php echo $plugin['author-url'] ?? '';?>
- @plugin [data-v-plugin-activate-url]|href = <?php echo Vvveb\url(['module' => 'plugin/plugins', 'action'=> 'activate', 'plugin' => $plugin['slug'], 'category' => $category]);?>
+ @plugin [data-v-plugin-activate-url]|href = <?php echo Vvveb\url(['module' => 'plugin/plugins', 'action'=> 'checkPluginAndActivate', 'plugin' => $plugin['slug'], 'category' => $category]);?>
@plugin [data-v-plugin-deactivate-url]|href = <?php echo Vvveb\url(['module' => 'plugin/plugins', 'action'=> 'deactivate', 'plugin' => $plugin['slug'], 'category' => $category]);?>
- @plugin [data-v-plugin-global-activate-url]|href = <?php echo Vvveb\url(['module' => 'plugin/plugins', 'action'=> 'activate', 'global'=> 'true', 'plugin' => $plugin['slug'], 'category' => $category]);?>
+ @plugin [data-v-plugin-global-activate-url]|href = <?php echo Vvveb\url(['module' => 'plugin/plugins', 'action'=> 'checkPluginAndActivate', 'global'=> 'true', 'plugin' => $plugin['slug'], 'category' => $category]);?>
@plugin [data-v-plugin-global-deactivate-url]|href = <?php echo Vvveb\url(['module' => 'plugin/plugins', 'action'=> 'deactivate', 'global'=> 'true', 'plugin' => $plugin['slug'], 'category' => $category]);?>
@plugin [data-v-plugin-delete-url]|href = <?php echo Vvveb\url(['module' => 'plugin/plugins', 'action'=> 'delete', 'plugin' => $plugin['slug'], 'category' => $category]);?>
diff --git a/admin/template/settings/post-types.tpl b/admin/template/settings/post-types.tpl
index e31c433..4c81f9d 100755
--- a/admin/template/settings/post-types.tpl
+++ b/admin/template/settings/post-types.tpl
@@ -1 +1 @@
-import(listing.tpl, {"type":"type", "list": "types"})
+import(listing.tpl, {"type":"type", "list": "type"})
diff --git a/admin/template/settings/product-types.tpl b/admin/template/settings/product-types.tpl
index e31c433..4c81f9d 100755
--- a/admin/template/settings/product-types.tpl
+++ b/admin/template/settings/product-types.tpl
@@ -1 +1 @@
-import(listing.tpl, {"type":"type", "list": "types"})
+import(listing.tpl, {"type":"type", "list": "type"})
diff --git a/app/controller/cart/compare.php b/app/controller/cart/compare.php
index a7f3513..2c5190e 100644
--- a/app/controller/cart/compare.php
+++ b/app/controller/cart/compare.php
@@ -54,11 +54,11 @@ class Compare extends Base {
}
}
- if ($results && isset($results['products'])) {
+ if ($results && isset($results['product'])) {
$tax = Tax::getInstance($this->global);
$currency = Currency::getInstance($this->global);
- foreach ($results['products'] as $id => &$product) {
+ foreach ($results['product'] as $id => &$product) {
if (isset($product['image']) && $product['image']) {
$product['image'] = Images::image($product['image'], 'product', 'thumb');
}
@@ -77,7 +77,7 @@ class Compare extends Base {
$specs = [];
foreach ($names as $attribute_id => $name) {
- foreach ($results['products'] as $prod) {
+ foreach ($results['product'] as $prod) {
$id = $prod['product_id'];
$specs[$attribute_id][$id] = $attrs[$id][$attribute_id] ?? '-';
}
diff --git a/app/controller/content/post.php b/app/controller/content/post.php
index ab20cfa..3ae0ae5 100755
--- a/app/controller/content/post.php
+++ b/app/controller/content/post.php
@@ -84,6 +84,7 @@ class Post extends Base {
$this->request->get['post_id'] = $languageContent['post_id'];
$this->request->get['admin_id'] = $languageContent['admin_id'];
$this->request->request['post_id'] = $languageContent['post_id'];
+ $this->request->get['name'] = $languageContent['name'];
$this->request->request['name'] = $languageContent['name'];
$this->request->request['code'] = $languageContent['code'];
$this->request->request['language_id'] = $languageContent['language_id'];
diff --git a/app/controller/cron.php b/app/controller/cron.php
index 5829e46..8b535bb 100755
--- a/app/controller/cron.php
+++ b/app/controller/cron.php
@@ -50,10 +50,10 @@ class Cron {
}
if (! empty($this->request->post) || defined('CLI')) {
- die();
+ die(0);
}
- die();
+ die(0);
}
function call() {
diff --git a/app/controller/user/base.php b/app/controller/user/base.php
index 065c442..7d18cf4 100755
--- a/app/controller/user/base.php
+++ b/app/controller/user/base.php
@@ -32,7 +32,7 @@ class Base extends \Vvveb\Controller\Base {
if (! $user) {
$this->redirect('/user/login');
- die();
+ die(0);
}
if (isset($this->request->post['logout'])) {
diff --git a/app/controller/user/downloads.php b/app/controller/user/downloads.php
index 874bf23..ccc2e0b 100755
--- a/app/controller/user/downloads.php
+++ b/app/controller/user/downloads.php
@@ -80,6 +80,6 @@ class Downloads extends Base {
die(__('Invalid download!'));
}
- die();
+ die(0);
}
}
diff --git a/app/template/pagination.tpl b/app/template/pagination.tpl
index 183d905..c8b86c4 100755
--- a/app/template/pagination.tpl
+++ b/app/template/pagination.tpl
@@ -75,7 +75,7 @@ if ($pagecount > $maxpages)
@page [data-page-no] = $page
@page [data-page-url]|href = <?php echo htmlentities(Vvveb\url($url, ['page' => $page] + $parameters)) . $query_string;?>
- @page|addClass = <?php if ($current_page == $page) echo 'active'?>
+ @page|addClass = <?php if (($current_page == $page) && !$vvveb_is_page_edit) echo 'active'?>
@page|after = <?php
}
diff --git a/system/cart/cart.php b/system/cart/cart.php
index 9e433c2..1efa775 100755
--- a/system/cart/cart.php
+++ b/system/cart/cart.php
@@ -156,7 +156,7 @@ class Cart {
}
}
- $products = $results['products'] ?? [];
+ $products = $results['product'] ?? [];
if ($products) {
foreach ($this->products as $key => &$prod) {
diff --git a/system/cart/order-cart.php b/system/cart/order-cart.php
index c0b2c85..bcd9958 100644
--- a/system/cart/order-cart.php
+++ b/system/cart/order-cart.php
@@ -138,7 +138,7 @@ class OrderCart extends Cart {
}
}
- $products = $results['products'] ?? [];
+ $products = $results['product'] ?? [];
if ($products) {
foreach ($this->products as $key => &$prod) {
@@ -278,9 +278,9 @@ class OrderCart extends Cart {
$this->addTotal($total['key'], $total['title'], $total['value'], '', $total['order_total_id']);
}
}
- //$this->products = $results['products'];
- if (isset($results['products']) && $results['products']) {
- foreach ($results['products'] as $product) {
+ //$this->products = $results['product'];
+ if (isset($results['product']) && $results['product']) {
+ foreach ($results['product'] as $product) {
$option_value = $product['option_value'] ? json_decode($product['option_value'], true) : [];
$this->add($product['product_id'], $product['order_product_id'], $product['quantity'], $option_value);
}
diff --git a/system/meta/meta.php b/system/meta/meta.php
index 8e58c65..e4f886c 100644
--- a/system/meta/meta.php
+++ b/system/meta/meta.php
@@ -31,7 +31,7 @@ class Meta {
private static $instance;
- protected $model;
+ protected $modelName;
protected $item_id;
@@ -44,7 +44,7 @@ class Meta {
}
function __construct() {
- $this->settingSql = model($this->model);
+ $this->settingSql = model($this->modelName);
}
public function getMulti($item_id, $namespace, $key = null, $default = null, $language_id = false) {
diff --git a/system/meta/post-content-meta.php b/system/meta/post-content-meta.php
index bcfbf9e..8a5cc98 100644
--- a/system/meta/post-content-meta.php
+++ b/system/meta/post-content-meta.php
@@ -23,7 +23,7 @@
namespace Vvveb\System\Meta;
class PostContentMeta extends Meta {
- protected $model = 'post_content_meta';
+ protected $modelName = 'post_content_meta';
protected $item_id = 'post_id';
}
diff --git a/system/meta/post-meta.php b/system/meta/post-meta.php
index b85030c..696b3e1 100644
--- a/system/meta/post-meta.php
+++ b/system/meta/post-meta.php
@@ -23,7 +23,7 @@
namespace Vvveb\System\Meta;
class PostMeta extends Meta {
- protected $model = 'post_meta';
+ protected $modelName = 'post_meta';
protected $item_id = 'post_id';
}
diff --git a/system/meta/setting-content.php b/system/meta/setting-content.php
index 7a76fd1..ffe4505 100644
--- a/system/meta/setting-content.php
+++ b/system/meta/setting-content.php
@@ -23,7 +23,7 @@
namespace Vvveb\System\Meta;
class SettingContent extends Meta {
- protected $model = 'setting_content';
+ protected $modelName = 'setting_content';
protected $item_id = 'site_id';
}