Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Fixed tags showing by post_type and tag delete

givanzedd8da892781
diff --git a/admin/controller/content/autocomplete-trait.php b/admin/controller/content/autocomplete-trait.php
index 2624ac2..2da69ba 100644
--- a/admin/controller/content/autocomplete-trait.php
+++ b/admin/controller/content/autocomplete-trait.php
@@ -29,14 +29,13 @@ use function Vvveb\url;
trait AutocompleteTrait {
function categoriesAutocomplete() {
$categories = new CategorySQL();
+ $text = trim($this->request->get['text'] ?? '');
+ $post_type = $this->request->get['post_type'] ?? '';
$results = $categories->getCategories([
- 'start' => 0,
- 'limit' => 10,
- 'language_id' => 1,
- 'site_id' => 1,
- 'search' => '%' . trim($this->request->get['text']) . '%',
- ]);
+ 'post_type' => $post_type,
+ 'search' => '%' . $text . '%',
+ ] + $this->global);
$search = [];
@@ -57,11 +56,10 @@ trait AutocompleteTrait {
function manufacturersAutocomplete() {
$manufacturers = new \Vvveb\Sql\ManufacturerSQL();
+ $text = trim($this->request->get['text'] ?? '');
$options = [
- 'start' => 0,
- 'limit' => 10,
- 'search' => '%' . trim($this->request->get['text']) . '%',
+ 'search' => '%' . $text . '%',
] + $this->global;
$results = $manufacturers->getAll($options);
@@ -83,12 +81,11 @@ trait AutocompleteTrait {
}
function vendorsAutocomplete() {
- $vendors = new \Vvveb\Sql\VendorSQL();
+ $vendors = new \Vvveb\Sql\VendorSQL();
+ $text = trim($this->request->get['text'] ?? '');
$options = [
- 'start' => 0,
- 'limit' => 10,
- 'search' => '%' . trim($this->request->get['text']) . '%',
+ 'search' => '%' . $text . '%',
] + $this->global;
$results = $vendors->getAll($options);
@@ -110,12 +107,12 @@ trait AutocompleteTrait {
}
function urlAutocomplete() {
- $products = new \Vvveb\Sql\ProductSQL();
+ $products = new \Vvveb\Sql\ProductSQL();
+ $text = trim($this->request->get['text'] ?? '');
$options = [
- 'start' => 0,
'limit' => 5,
- 'like' => trim($this->request->get['text']),
+ 'like' => $text,
] + $this->global;
unset($options['admin_id']);
@@ -159,12 +156,11 @@ trait AutocompleteTrait {
}
function productsAutocomplete() {
- $products = new \Vvveb\Sql\ProductSQL();
+ $products = new \Vvveb\Sql\ProductSQL();
+ $text = trim($this->request->get['text'] ?? '');
$options = [
- 'start' => 0,
- 'limit' => 10,
- 'like' => trim($this->request->get['text']),
+ 'like' => $text,
] + $this->global;
unset($options['admin_id']);
@@ -187,13 +183,12 @@ trait AutocompleteTrait {
}
function adminsAutocomplete() {
- $admins = new \Vvveb\Sql\AdminSQL();
+ $admins = new \Vvveb\Sql\AdminSQL();
+ $text = trim($this->request->get['text'] ?? '');
$options = [
- 'start' => 0,
- 'limit' => 10,
- 'status' => 1,
- 'search' => trim($this->request->get['text']),
+ 'status' => 1,
+ 'search' => $text,
] + $this->global;
$results = $admins->getAll($options);
@@ -222,11 +217,10 @@ trait AutocompleteTrait {
function attributesAutocomplete() {
$attributes = new \Vvveb\Sql\AttributeSQL();
+ $text = trim($this->request->get['text'] ?? '');
$options = [
- 'start' => 0,
- 'limit' => 10,
- 'search' => trim($this->request->get['text']),
+ 'search' => $text,
] + $this->global;
$results = $attributes->getAll($options);
@@ -278,11 +272,10 @@ trait AutocompleteTrait {
function digitalAssetsAutocomplete() {
$digital_assets = new \Vvveb\Sql\Digital_assetSQL();
+ $text = trim($this->request->get['text'] ?? '');
$options = [
- 'start' => 0,
- 'limit' => 10,
- 'search' => trim($this->request->get['text']),
+ 'search' => $text,
] + $this->global;
$results = $digital_assets->getAll($options);
diff --git a/admin/controller/content/categories.php b/admin/controller/content/categories.php
index f7cd97c..1180b67 100755
--- a/admin/controller/content/categories.php
+++ b/admin/controller/content/categories.php
@@ -86,7 +86,7 @@ class Categories extends Base {
$categories = new categorySQL();
$page = $this->request->get['page'] ?? 1;
- $type = $this->request->get['type'] ?? 1;
+ $type = $this->request->get['type'] ?? '';
$taxonomy_id = $this->request->get['taxonomy_id'];
$limit = 1000;
diff --git a/admin/controller/content/menus.php b/admin/controller/content/menus.php
index fe2dd0a..2111a88 100755
--- a/admin/controller/content/menus.php
+++ b/admin/controller/content/menus.php
@@ -204,11 +204,9 @@ class Menus extends Categories {
$controllerPath = $admin_path . 'index.php?module=media/media';
$view->scanUrl = "$controllerPath&action=scan";
$view->uploadUrl = "$controllerPath&action=upload";
+ $view->linkUrl = $admin_path . 'index.php?module=content/post&action=urlAutocomplete';
$theme = Sites::getTheme() ?? 'default';
$view->themeCss = PUBLIC_PATH . "themes/$theme/css/admin-post-editor.css";
- //$view->themeCss = PUBLIC_PATH . "themes/$theme/css/style.css";
-
- //return 'content/menus/menu.html';
}
function index() {
diff --git a/admin/controller/content/tag.php b/admin/controller/content/tag.php
index 5b6b136..208a1a9 100755
--- a/admin/controller/content/tag.php
+++ b/admin/controller/content/tag.php
@@ -32,18 +32,37 @@ class Tag extends Base {
function save() {
$taxonomy_item_id = $this->request->get['taxonomy_item_id'] ?? false;
+ $taxonomy_id = $this->request->get['taxonomy_id'];
+ $post_type = $this->request->get['type'] ?? '';
$tag = $this->request->post['tag'] ?? false;
- if ($taxonomy_item_id && $tag) {
+ if ($tag) {
$tags = new categorySQL();
- $result = $tags->editCategory(
- ['taxonomy_item_content' => [$tag + $this->global],
- 'taxonomy_item_id' => $taxonomy_item_id,
- 'taxonomy_item' => ['taxonomy_item_id' => $taxonomy_item_id] + $tag,
+
+ if ($taxonomy_item_id) {
+ $result = $tags->editCategory(
+ ['taxonomy_item_content' => [$tag + $this->global],
+ 'taxonomy_item_id' => $taxonomy_item_id,
+ 'taxonomy_item' => ['taxonomy_item_id' => $taxonomy_item_id, 'taxonomy_id' => $taxonomy_id] + $tag,
+ ]);
+ } else {
+ var_dump(['taxonomy_item_content' => [$tag + $this->global],
+ 'taxonomy_item' => ['taxonomy_id' => $taxonomy_id] + $tag,
]);
+ $result = $tags->addCategory(
+ ['taxonomy_item_content' => $tag + $this->global,
+ 'taxonomy_item' => ['taxonomy_id' => $taxonomy_id] + $tag,
+ 'site_id' => $this->global['site_id'],
+ ]);
+ }
if ($result && isset($result['taxonomy_item_content'])) {
- $this->view->success[] = __('Tag saved!');
+ $message = __('Tag saved!');
+ $this->view->success[] = $message;
+
+ if (! $taxonomy_item_id) {
+ $this->redirect(['module'=> 'content/tag', 'taxonomy_item_id' => $result['taxonomy_item'], 'taxonomy_id' => $taxonomy_id, 'type' => $post_type, 'success' => $message], [], false);
+ }
} else {
$this->view->errors[] = __('Error saving!');
}
@@ -55,21 +74,31 @@ class Tag extends Base {
function index() {
$tags = new categorySQL();
$taxonomy_item_id = $this->request->get['taxonomy_item_id'] ?? false;
+ $taxonomy_id = $this->request->get['taxonomy_id'] ?? false;
+ $post_type = $this->request->get['type'] ?? '';
- $view = $this->view;
- $admin_path = \Vvveb\adminPath();
- $controllerPath = $admin_path . 'index.php?module=media/media';
- $view->scanUrl = "$controllerPath&action=scan";
- $view->uploadUrl = "$controllerPath&action=upload";
+ $view = $this->view;
+ $admin_path = \Vvveb\adminPath();
+ $controllerPath = $admin_path . 'index.php?module=media/media';
+ $view->scanUrl = "$controllerPath&action=scan";
+ $view->uploadUrl = "$controllerPath&action=upload";
$options = [
- 'type' => $this->type,
- 'taxonomy_item_id' => $taxonomy_item_id,
+ 'type' => $this->type,
+ 'taxonomy_item_id' => $taxonomy_item_id,
+ 'taxonomy_id' => $taxonomy_id,
] + $this->global;
unset($options['user_id']);
- $view->status = [0 => __('Disabled'), 1 => __('Enabled')];
- $view->tag = $tags->getCategoryBySlug($options);
- $view->tag['image_url'] = Images::image($view->tag['image'], 'tag', 'thumb');
+ $tag = $tags->getCategoryBySlug($options);
+
+ if ($tag) {
+ $tag['image_url'] = Images::image($tag['image'], 'tag', 'thumb');
+ }
+
+ $view->taxonomy_id = $taxonomy_id;
+ $view->type = $post_type;
+ $view->status = [1 => __('Enabled'), 0 => __('Disabled')];
+ $view->tag = $tag ?? [];
}
}
diff --git a/admin/controller/content/tags.php b/admin/controller/content/tags.php
index 35c766e..59dbb3b 100755
--- a/admin/controller/content/tags.php
+++ b/admin/controller/content/tags.php
@@ -22,21 +22,39 @@
namespace Vvveb\Controller\Content;
+use function Vvveb\__;
use Vvveb\Controller\Base;
use Vvveb\Sql\categorySQL;
+use Vvveb\System\Images;
class Tags extends Base {
+ function delete() {
+ $taxonomy_item_id = $this->request->get['taxonomy_item_id'] ?? false;
+ $categories = new categorySQL();
+
+ if ($taxonomy_item_id && $categories->deleteTaxonomyItem(['taxonomy_item_id' => $taxonomy_item_id])) {
+ $this->view->success[] = 'Item removed!';
+ } else {
+ $this->view->errors[] = __('Error saving!');
+ }
+
+ return $this->index();
+ }
+
function index() {
$view = $this->view;
$categories = new categorySQL();
- $page = $this->request->get['page'] ?? 1;
- $limit = 1000;
+ $page = $this->request->get['page'] ?? 1;
+ $type = $this->request->get['type'] ?? '';
+ $taxonomy_id = $this->request->get['taxonomy_id'] ?? false;
+ $limit = 1000;
$options = [
- 'start' => ($page - 1) * $limit,
- 'limit' => $limit,
- 'type' => 'tags',
+ 'start' => ($page - 1) * $limit,
+ 'limit' => $limit,
+ 'post_type' => $type,
+ 'type' => 'tags',
] + $this->global;
$results = $categories->getCategoriesAllLanguages($options);
@@ -47,6 +65,8 @@ class Tags extends Base {
$taxonomy_item['languages'] = json_decode($taxonomy_item['languages'], true);
$taxonomy_item['name'] = $taxonomy_item['languages'][0]['name'] ?? '';
*/
+ $taxonomy_item['image_url'] = Images::image($taxonomy_item['image'], 'tag', 'thumb');
+
if (isset($taxonomy_item['languages'])) {
$langs = json_decode($taxonomy_item['languages'], true);
$taxonomy_item['languages'] = [];
@@ -60,10 +80,13 @@ class Tags extends Base {
}
}
- $taxonomy_item['edit-url'] = \Vvveb\url(['module' => 'content/tag', 'taxonomy_item_id' => $taxonomy_item['taxonomy_item_id']]);
+ $url = ['module' => 'content/tag', 'taxonomy_item_id' => $taxonomy_item['taxonomy_item_id'], 'taxonomy_id' => $taxonomy_id, 'type' => $type];
+ $taxonomy_item['edit-url'] = \Vvveb\url($url);
+ $taxonomy_item['delete-url'] = \Vvveb\url(['module' => 'content/tags', 'action' => 'delete'] + $url);
}
}
+ $view->add_url = \Vvveb\url(['module' => 'content/tag', 'taxonomy_id' => $taxonomy_id, 'type' => $type]);
$view->set($results);
}
}
diff --git a/admin/sql/mysqli/category.sql b/admin/sql/mysqli/category.sql
index b399f07..26aebc7 100644
--- a/admin/sql/mysqli/category.sql
+++ b/admin/sql/mysqli/category.sql
@@ -82,7 +82,7 @@
tc.language_id = :language_id AND t2s.site_id = :site_id
- @IF isset(:search)
+ @IF isset(:search) && :search
THEN
AND tc.name LIKE :search
@@ -482,6 +482,8 @@
IN site_id INT,
IN taxonomy_id INT,
IN search CHAR,
+ IN type CHAR,
+ IN post_type CHAR,
-- pagination
IN start INT,
@@ -528,7 +530,7 @@
t2s.site_id = :site_id
- @IF isset(:search)
+ @IF isset(:search) && :search
THEN
AND tc.name LIKE :search
@@ -538,21 +540,21 @@
@IF isset(:taxonomy_id)
THEN
- AND categories.taxonomy_id LIKE :taxonomy_id
+ AND categories.taxonomy_id = :taxonomy_id
END @IF
- @IF isset(:type)
+ @IF isset(:type) && :type
THEN
- AND taxonomy.type LIKE :type
+ AND taxonomy.type = :type
END @IF
- @IF isset(:post_type)
+ @IF isset(:post_type) && :post_type
THEN
- AND taxonomy.post_type LIKE :post_type
+ AND taxonomy.post_type = :post_type
END @IF
diff --git a/admin/sql/pgsql/category.sql b/admin/sql/pgsql/category.sql
index f054b7e..6680f19 100755
--- a/admin/sql/pgsql/category.sql
+++ b/admin/sql/pgsql/category.sql
@@ -82,7 +82,7 @@
tc.language_id = :language_id AND t2s.site_id = :site_id
- @IF isset(:search)
+ @IF isset(:search) && :search
THEN
AND tc.name LIKE :search
@@ -481,6 +481,8 @@
IN site_id INT,
IN taxonomy_id INT,
IN search CHAR,
+ IN type CHAR,
+ IN post_type CHAR,
-- pagination
IN start INT,
@@ -519,7 +521,7 @@
t2s.site_id = :site_id
- @IF isset(:search)
+ @IF isset(:search) && :search
THEN
AND tc.name LIKE :search
@@ -529,21 +531,21 @@
@IF isset(:taxonomy_id)
THEN
- AND categories.taxonomy_id LIKE :taxonomy_id
+ AND categories.taxonomy_id = :taxonomy_id
END @IF
- @IF isset(:type)
+ @IF isset(:type) && :type
THEN
- AND taxonomy.type LIKE :type
+ AND taxonomy.type = :type
END @IF
- @IF isset(:post_type)
+ @IF isset(:post_type) && :post_type
THEN
- AND taxonomy.post_type LIKE :post_type
+ AND taxonomy.post_type = :post_type
END @IF
diff --git a/admin/sql/sqlite/category.sql b/admin/sql/sqlite/category.sql
index 19c762e..651e9b3 100755
--- a/admin/sql/sqlite/category.sql
+++ b/admin/sql/sqlite/category.sql
@@ -82,7 +82,7 @@
tc.language_id = :language_id AND t2s.site_id = :site_id
- @IF isset(:search)
+ @IF isset(:search) && :search
THEN
AND tc.name LIKE :search
@@ -481,6 +481,8 @@
IN site_id INT,
IN taxonomy_id INT,
IN search CHAR,
+ IN type CHAR,
+ IN post_type CHAR,
-- pagination
IN start INT,
@@ -528,7 +530,7 @@
t2s.site_id = :site_id
- @IF isset(:search)
+ @IF isset(:search) && :search
THEN
AND tc.name LIKE :search
@@ -538,21 +540,21 @@
@IF isset(:taxonomy_id)
THEN
- AND categories.taxonomy_id LIKE :taxonomy_id
+ AND categories.taxonomy_id = :taxonomy_id
END @IF
- @IF isset(:type)
+ @IF isset(:type) && :type
THEN
- AND taxonomy.type LIKE :type
+ AND taxonomy.type = :type
END @IF
- @IF isset(:post_type)
+ @IF isset(:post_type) && :post_type
THEN
- AND taxonomy.post_type LIKE :post_type
+ AND taxonomy.post_type = :post_type
END @IF
diff --git a/admin/template/content/tags.tpl b/admin/template/content/tags.tpl
index bcca0df..68c193f 100755
--- a/admin/template/content/tags.tpl
+++ b/admin/template/content/tags.tpl
@@ -14,7 +14,7 @@ if(isset($this->categories) && is_array($this->categories)) {
@tag input[data-v-*]|value = $tag['@@__data-v-(*)__@@']
@tag a[data-v-*]|href = $tag['@@__data-v-(*)__@@']
- @tag [data-v-img]|src = $tag['image']
+ @tag img[data-v-image_url]|src = $tag['image_url']
@tag [data-v-url]|href =<?php echo Vvveb\url(['module' => 'tag/tag', 'taxonomy_item_id' => $tag['taxonomy_item_id']]);?>
@tag [data-v-url]|title = $tag['title']
@@ -26,3 +26,5 @@ if(isset($this->categories) && is_array($this->categories)) {
@tag|after = <?php
}
}?>
+
+[data-v-add-url]|href = $this->add_url
\ No newline at end of file
diff --git a/public/admin/default b/public/admin/default
index d94b079..ba3d82f 160000
--- a/public/admin/default
+++ b/public/admin/default
@@ -1 +1 @@
-Subproject commit d94b07973ed4a4c7b930cd6d860bc8f682999944
+Subproject commit ba3d82fac66176cb403f13b50560d7fa672e5ccb