Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Fields support

givanz160fbbb1bc72
diff --git a/admin/controller/content/edit.php b/admin/controller/content/edit.php
index bfb76f5..23be38a 100644
--- a/admin/controller/content/edit.php
+++ b/admin/controller/content/edit.php
@@ -24,17 +24,22 @@ namespace Vvveb\Controller\Content;
use function Vvveb\__;
use Vvveb\Controller\Base;
+use function Vvveb\getSetting;
use function Vvveb\humanReadable;
use function Vvveb\model;
use function Vvveb\sanitizeHTML;
+use function Vvveb\setSetting;
use function Vvveb\slugify;
use Vvveb\Sql\CategorySQL;
+use Vvveb\Sql\Field_GroupSQL;
+use Vvveb\Sql\FieldSQL;
use Vvveb\System\Cache;
use Vvveb\System\CacheManager;
use Vvveb\System\Core\View;
use Vvveb\System\Event;
use Vvveb\System\Images;
use Vvveb\System\Sites;
+use Vvveb\System\Traits\FieldGroup;
use Vvveb\System\User\Admin;
use Vvveb\System\Validator;
@@ -45,10 +50,68 @@ class Edit extends Base {
protected $revisions = true;
- use TaxonomiesTrait, AutocompleteTrait, SitesTrait;
+ use TaxonomiesTrait, AutocompleteTrait, SitesTrait, FieldGroup;
function getThemeFolder() {
- return DIR_THEMES . Sites::getTheme() ?? 'default';
+ return DIR_THEMES . Sites::getTheme($this->global['site_id']) ?? 'default';
+ }
+
+ function fields() {
+ $field_group_id = 1;
+ $options = ['type' => $this->object, 'subtype' => $this->type, 'limit' => 1000];
+ $fieldGroup = new Field_GroupSQL();
+ $fieldGroups = $fieldGroup->getAll($options + $this->global)['field_group'] ?? [];
+
+ $langsFields = [];
+ $field_group_id = [];
+
+ foreach ($fieldGroups as $group) {
+ $field_group_id[$group['field_group_id']] = $group['field_group_id'];
+ }
+
+ if ($field_group_id) {
+ $post_id = $this->request->get[$this->object . '_id'] ?? false;
+
+ $field = new FieldSQL();
+ $fields = $field->getAll(['field_group_id' => $field_group_id, $this->object . '_id' => $post_id, 'limit' => 1000] + $this->global);
+ $langsFields = [];
+
+ if ($fields['count'] > 0) {
+ foreach ($fields['field'] as &$field) {
+ $input['settings'] = json_decode($field['settings'], true);
+ $input['validation'] = json_decode($field['validation'], true);
+ $input['presentation'] = json_decode($field['presentation'], true);
+
+ $field['class'] = 'row mb-3';
+ $field['label-class'] = 'form-label';
+ $field['label'] = $input['settings']['label'] ?? '';
+ $field['instructions'] = $input['presentation']['instructions'] ?? '';
+ $field['placeholder'] = $input['settings']['placeholder'] ?? '';
+
+ foreach (['value', 'default'] as $key) {
+ if (isset($field[$key]) && $field[$key]) {
+ if ($field[$key][0] == '{') {
+ $field[$key] = json_decode($field[$key], true);
+ }
+
+ $field['value'] = $field[$key];
+
+ break;
+ }
+ }
+
+ foreach ($this->view->languagesList as $code => $lang) {
+ $field['name'] = 'field[' . $lang['language_id'] . '][' . $field['field_id'] . ']';
+ $field['field'] = $this->renderFields2([$field]);
+
+ $groupName = $fieldGroups[$field['field_group_id']]['name'];
+ $langsFields[$lang['language_id']][$groupName][] = $field;
+ }
+ }
+ }
+ }
+ $this->view->fields = $langsFields;
+ $this->view->count = $fields['count'] ?? 0;
}
function index() {
@@ -63,7 +126,7 @@ class Edit extends Base {
$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';
+ $theme = Sites::getTheme($this->global['site_id']) ?? 'default';
$view->themeCss = '';
if (file_exists(DIR_THEMES . "$theme/css/admin-post-editor.css")) {
@@ -153,6 +216,9 @@ class Edit extends Base {
$route = "content/{$this->type}/index";
$altRoute = "content/{$this->object}/index";
$controller = 'content';
+ $stickyPosts = getSetting('posts', 'sticky') ?? [];
+ //$post['sticky'] = in_array($post['post_id'], $stickyPosts);
+ $post['sticky'] = isset($post['post_id']) && isset($stickyPosts[$post['post_id']]);
}
if ($this->revisions) {
@@ -223,7 +289,7 @@ class Edit extends Base {
$design_url = '';
if (isset($post['url'])) {
- $design_url = \Vvveb\url(['module' => 'editor/editor', 'name' => urlencode($name), 'url' => $post['relative-url'], 'template' => $template, 'host' => $this->global['host']], false);
+ $design_url = \Vvveb\url(['module' => 'editor/editor', 'name' => urlencode($name), 'url' => $post['relative-url'], 'template' => $template], false);
$post['design_url'] = $design_url;
}
@@ -255,7 +321,7 @@ class Edit extends Base {
$object = $this->object;
$view->$object = $post;
- $view->status = ['publish' => 'Publish', 'draft' => 'Draft', 'pending' => 'Pending', 'private' => 'Private', 'password' => 'Password', 'future' => 'Future'];
+ $view->status = ['publish' => 'Publish', 'draft' => 'Draft', 'pending' => 'Pending', 'private' => 'Private', 'scheduled' => 'Scheduled'];
$view->templates = Cache::getInstance()->cache(APP, 'template-list-' . $theme, function () use ($theme) {
return \Vvveb\getTemplateList($theme, ['email']);
@@ -276,6 +342,8 @@ class Edit extends Base {
return $names;
}, 604800);
+ $this->fields();
+
//$validator = new Validator([$this->object]);
//$view->validatorJson = $validator->getJSON();
$view->type = __($this->type);
@@ -377,19 +445,19 @@ class Edit extends Base {
$new = false;
if ($post_id) {
- /*
- $viewCapability = 'edit_other_posts';
+ $editCapability = 'edit_other_posts';
if ($this->object == 'product') {
- $viewCapability = 'edit_other_products';
+ $editCapability = 'edit_other_products';
}
- if (Admin::hasCapability($viewCapability)) {
- unset($postOptions['admin_id']);
+ if (Admin::hasCapability($editCapability)) {
+ //unset($data['admin_id']);
} else {
- $postOptions['admin_id'] = $this->global['admin_id'];
+ //$data['admin_id'] = $this->global['admin_id'];
+ $view->errors[] = __('Permission denied!');
+ return;
}
- */
$post[$this->object . '_id'] = (int)$post_id;
$data = [
@@ -406,6 +474,20 @@ class Edit extends Base {
if ($result >= 0) {
$this->view->success['get'] = ucfirst($this->type) . ' ' . __('saved') . '!';
+ $stickyPosts = getSetting('posts', 'sticky') ?? [];
+
+ if (isset($post['sticky']) && ! isset($stickyPosts[$post_id])) {
+ $stickyPosts[$post_id] = $post_id;
+ setSetting('posts', 'sticky', $stickyPosts);
+ }
+
+ if (isset($stickyPosts[$post_id]) && ! isset($post['sticky'])) {
+ unset($stickyPosts[$post_id]);
+ setSetting('posts', 'sticky', $stickyPosts);
+ }
+
+
+
if ($this->revisions) {
$revisions = model($this->object . '_content_revision');
@@ -452,6 +534,12 @@ class Edit extends Base {
$message = ucfirst($this->type) . ' ' . __('saved') . '!';
$view->success['get'] = $message;
+
+ if (isset($post['sticky'])) {
+ $stickyPosts = getSetting('posts', 'sticky');
+ $stickyPosts[$post_id] = $post_id;
+ setSetting('posts', 'sticky', $stickyPosts);
+ }
}
}
diff --git a/admin/controller/field/field-group.php b/admin/controller/field/field-group.php
old mode 100644
new mode 100755
index 74ece63..51e5ece
--- a/admin/controller/field/field-group.php
+++ b/admin/controller/field/field-group.php
@@ -24,17 +24,39 @@ namespace Vvveb\Controller\Field;
use function Vvveb\__;
use Vvveb\Controller\Crud;
-use Vvveb\Sql\CountrySQL;
+use function Vvveb\fieldTypeClass;
+use function Vvveb\getFieldTypes;
+use function Vvveb\importHtml;
+use function Vvveb\postTypes;
use Vvveb\Sql\Field_GroupSQL;
use Vvveb\Sql\FieldSQL;
+use Vvveb\System\Event;
+use Vvveb\System\Field as Fields;
+use Vvveb\System\Traits\FieldGroup as FieldGroupTrait;
class FieldGroup extends Crud {
+ use FieldGroupTrait;
+
protected $type = 'field_group';
protected $controller = 'field-group';
protected $module = 'field';
+ function setFieldDefault(&$field) {
+ $fieldClass = fieldTypeClass($field['type']);
+
+ if ($fieldClass && $fieldClass::valueType) {
+ $field['default'] = [];
+
+ foreach ($fieldClass::valueType as $key) {
+ $field['default'][$key] = $field['settings'][$key] ?? '';
+ }
+
+ $field['default'] = json_encode($field['default']);
+ }
+ }
+
function save() {/*
$field = $this->request->post['field'] ?? [];
$field_group_id = $this->request->get['field_group_id'] ?? false;
@@ -53,19 +75,98 @@ class FieldGroup extends Crud {
}*/
$this->request->post[$this->type]['status'] = 1;
-
+ $this->redirect = false;
parent::save();
+
+ $delete = $this->request->post['delete']['field_id'] ?? [];
+ $field = $this->request->post['field'] ?? [];
+ $field_group = $this->request->post['field_group'] ?? [];
+ $field_group_id = $this->request->get['field_group_id'] ?? false;
+ $edit = $this->request->get['field_group_id'] ?? false;
+ $field_group_id = $this->field_group_id;
+ $new = [];
+ unset($field_group['conditionals']);
+ //var_dump($field);
+ foreach ($field as $index => &$attr) {
+ $attr['field_group_id'] = $field_group_id;
+ $attr['sort_order'] = $attr['sort_order'] ?? 0;
+
+ if ($index === '#') {
+ unset($field[$index]);
+
+ continue;
+ }
+
+ $attr['name'] = $attr['name'] ?? $attr['settings']['name'] ?? '(none)';
+ $attr['label'] = $attr['label'] ?? $attr['settings']['label'] ?? '(none)';
+ $attr['default'] = $attr['label'] ?? $attr['settings']['default'] ?? '';
+ $attr['type'] = $attr['settings']['type'] ?? 'text';
+ $attr['field_id'] = $attr['settings']['field_id'] ?? $attr['field_id'] ?? null;
+ $attr['sort_order'] = $attr['settings']['sort_order'] ?? $attr['sort_order'] ?? 0;
+ $attr['row'] = $attr['settings']['row'] ?? $attr['row'] ?? 0;
+
+ if (! $attr['name']) {
+ unset($field[$index]);
+
+ continue;
+ }
+
+ $this->setFieldDefault($attr);
+
+ foreach (['settings', 'validation', 'presentation', 'conditionals'] as $section) {
+ $attr[$section] = $attr[$section] ?? [];
+ $attr[$section] = array_filter($attr[$section]);
+ $attr[$section] = json_encode($attr[$section]);
+ }
+
+ if (! ($attr['field_id'] ?? false) && $attr['name']) {
+ unset($attr['field_id']);
+ $new[] = $attr;
+ unset($field[$index]);
+ }
+ }
+
+ if ($field_group_id) {
+ $fieldGroup = new Field_GroupSQL();
+ $fieldSql = new FieldSQL();
+
+ if ($delete) {
+ $fieldSql->delete(['field_id' => $delete] + $this->global);
+ }
+
+ if ($field) {
+ foreach ($field as $index => &$attr) {
+ $fieldSql->edit(['field' => $attr, 'field_id' => $attr['field_id']] + $this->global);
+ }
+ }
+
+ if ($new) {
+ foreach ($new as $index => &$attr) {
+ $fieldSql->add(['field' => $attr] + $this->global);
+ }
+ }
+
+ $result = $fieldGroup->edit(['field_group_id' => $field_group_id, 'field_group' => $field_group]);
+
+ if ($result && isset($result['field_group_content'])) {
+ if (! $edit) {
+ $this->redirect(['module' => "{$this->module}/{$this->controller}", 'field_group_id' => $field_group_id]);
+ }
+ } else {
+ $this->view->errors[] = __('Error saving!');
+ }
+ }
+
+ $this->index();
}
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'] ?? [];
}
@@ -81,28 +182,43 @@ class FieldGroup extends Crud {
parent::index();
- return;
+ //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'] ?? [];
+ $field = new FieldSQL();
+ $fields = $field->getAll(['field_group_id' => [$field_group_id], 'limit' => 1000] + $this->global);
+
+ if ($fields['count'] > 0) {
+ foreach ($fields['field'] as &$field) {
+ $input['settings'] = json_decode($field['settings'], true);
+ $input['validation'] = json_decode($field['validation'], true);
+ $input['presentation'] = json_decode($field['presentation'], true);
+ $input['cols'] = $input['presentation']['cols'] ?? 'col';
+ $input['settings']['field_id'] = $field['field_id'];
+ $input['settings']['name'] = $input['settings']['name'] ?? '(none)';
+ $input['settings']['label'] = $input['settings']['label'] ?? '(none)';
+ $input['settings']['sort_order'] = $field['sort_order'];
+ $input['settings']['row'] = $field['row'];
+ $input['row'] = $input['settings']['row'] ?? 0;
+
+ $render = $this->renderField($field['type'], $field['field_id'], $input + $field);
+ $field['settings-tab'] = $render['settings'];
+ $field['validation-tab'] = $render['validation'];
+ $field['presentation-tab'] = $render['presentation'];
+ $field['field'] = $render['field'];
+ $field = $input + $field;
+ }
+ }
}
- $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'] ?? [];
+ $this->view->fieldTypes = getFieldTypes();
+ $this->view->postTypes = postTypes('post');
+ $this->view->productTypes = postTypes('product');
+ $this->view->fields = $fields['field'] ?? [];
- $admin_path = \Vvveb\adminPath();
- $controllerPath = $admin_path . 'index.php?module=localization/field-group';
- $this->view->fieldsUrl = "$controllerPath&action=fields";
+ $this->view->count = $fields['count'] ?? 0;
}
}
diff --git a/admin/sql/mysqli/category.sql b/admin/sql/mysqli/category.sql
old mode 100644
new mode 100755
index f448865..92e6003
--- a/admin/sql/mysqli/category.sql
+++ b/admin/sql/mysqli/category.sql
@@ -30,7 +30,7 @@
@IF isset(:count) AND :count
THEN
,count(post_id) as count
- END @IF
+ END @IF
@IF isset(:post_id)
THEN
@@ -168,6 +168,7 @@
IN parent_id INT,
IN search CHAR,
IN type CHAR,
+ IN post_type CHAR,
-- pagination
IN start INT,
@@ -198,7 +199,17 @@
FROM post_content pc
LEFT JOIN post p ON (pc.post_id = p.post_id)
LEFT JOIN post_to_taxonomy_item ptt ON (ptt.taxonomy_item_id = @taxonomy_item_id AND ptt.post_id = p.post_id)
- WHERE ptt.taxonomy_item_id = @taxonomy_item_id ORDER by p.sort_order
+ WHERE ptt.taxonomy_item_id = @taxonomy_item_id
+
+ @IF isset(:post_type)
+ THEN
+
+ AND p.type = :post_type
+
+ END @IF
+
+
+ ORDER by p.sort_order
@IF isset(:posts_limit) && !empty(:posts_limit)
THEN
@@ -371,6 +382,7 @@
IN taxonomy_item_id INT,
IN parent_id INT,
IN language_id INT,
+ IN site_id INT,
IN post_type CHAR,
IN slug CHAR,
OUT fetch_row
@@ -382,6 +394,12 @@
FROM taxonomy_item_content AS _
LEFT JOIN taxonomy_item as ti ON (_.taxonomy_item_id = ti.taxonomy_item_id)
LEFT JOIN taxonomy t ON (ti.taxonomy_id = t.taxonomy_id)
+
+ @IF isset(:site_id)
+ THEN
+ LEFT JOIN taxonomy_to_site tt ON (tt.taxonomy_item_id = ti.taxonomy_item_id)
+ END @IF
+
WHERE 1 = 1
@IF isset(:taxonomy_item_id)
@@ -403,7 +421,7 @@
AND parent_id = :parent_id
- END @IF
+ END @IF
@IF isset(:language_id)
THEN
@@ -417,6 +435,13 @@
AND t.post_type = :post_type
+ END @IF
+
+ @IF isset(:site_id)
+ THEN
+
+ AND tt.site_id = :site_id
+
END @IF
diff --git a/admin/sql/mysqli/field.sql b/admin/sql/mysqli/field.sql
index c90e913..9f47052 100755
--- a/admin/sql/mysqli/field.sql
+++ b/admin/sql/mysqli/field.sql
@@ -1,40 +1,36 @@
--- Taxonomy
+-- Fields
- -- get all taxonomies
+ -- get all fields
- CREATE PROCEDURE getAll(
- IN field_item_id INT,
-
- -- pagination
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN field_group_id ARRAY,
+ IN post_id INT,
IN start INT,
IN limit INT,
-
- -- filter
- IN post_type CHAR,
-
OUT fetch_all,
- OUT fetch_one
+ OUT fetch_one,
)
BEGIN
- -- field_item
- SELECT *, field_id as array_key
- FROM field
- -- LEFT JOIN field_to_site t2s ON (field_item.field_item_id = t2s.field_item_id)
+ -- field
+ SELECT *, field.field_id, field.field_id as array_key
+ FROM field
- WHERE 1 = 1
-
- @IF isset(:post_type)
+ @IF isset(:post_id)
THEN
+ LEFT JOIN post_field_value ON (field.field_id = post_field_value.field_id AND post_field_value.post_id = :post_id AND post_field_value.language_id = :language_id)
+ END @IF
+
+ WHERE 1 = 1
- AND post_type = :post_type
-
- END @IF
-
- @IF isset(:limit)
- THEN
- @SQL_LIMIT(:start, :limit)
- END @IF;
+ @IF !empty(:field_group_id) && is_array(:field_group_id)
+ THEN
+ AND field.field_group_id IN (:field_group_id)
+ END @IF
+ ORDER BY field.row, field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
SELECT count(*) FROM (
@@ -42,6 +38,100 @@
) as count;
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM field as _
+ INNER JOIN field_content ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND field_content.language_id = :language_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN field ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ INSERT INTO field
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ INSERT INTO field_content
+
+ ( @KEYS(:field_content_data), language_id, field_id )
+
+ VALUES ( :field_content_data, :language_id, @result.field);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN field ARRAY,
+ IN field_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ UPDATE field
+
+ SET @LIST(:field_data)
+
+ WHERE field_id = :field_id;
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ UPDATE field_content
+
+ SET @LIST(:field_content_data)
+
+ WHERE field_id = :field_id AND language_id = :language_id;
+
+
END
+ -- delete field
+ PROCEDURE delete(
+ IN field_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- field
+ DELETE FROM field_content WHERE field_id IN (:field_id);
+ -- field_content
+ DELETE FROM field WHERE field_id IN (:field_id);
+ END
diff --git a/admin/sql/mysqli/field_group.sql b/admin/sql/mysqli/field_group.sql
index 0ba2eed..c7e8cce 100755
--- a/admin/sql/mysqli/field_group.sql
+++ b/admin/sql/mysqli/field_group.sql
@@ -6,12 +6,14 @@
IN language_id INT,
IN start INT,
IN limit INT,
+ IN type CHAR,
+ IN subtype CHAR,
OUT fetch_all,
OUT fetch_one,
)
BEGIN
-- field_group
- SELECT *
+ SELECT *, field_group.field_group_id as array_key
FROM field_group
INNER JOIN field_group_content ON field_group_content.field_group_id = field_group.field_group_id
WHERE 1 = 1
@@ -20,6 +22,16 @@
THEN
AND field_group_content.language_id = :language_id
END @IF
+
+ @IF !empty(:type)
+ THEN
+ AND field_group.type = :type
+ END @IF
+
+ @IF !empty(:subtype)
+ THEN
+ AND field_group.subtype = :subtype OR field_group.subtype = ''
+ END @IF
@SQL_LIMIT(:start, :limit);
diff --git a/admin/sql/mysqli/field_value.sql b/admin/sql/mysqli/field_value.sql
new file mode 100644
index 0000000..2990cd9
--- /dev/null
+++ b/admin/sql/mysqli/field_value.sql
@@ -0,0 +1,137 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN field_group_id INT,
+ IN post_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT *, field.field_id as array_key
+ FROM field
+
+ @IF isset(:post_id)
+ THEN
+ LEFT JOIN post_field_value ON (field.field_id = post_field_value.field_id AND post_field_value.post_id = :post_id AND post_field_value.language_id = :language_id)
+ END @IF
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM field as _
+ INNER JOIN field_content ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND field_content.language_id = :language_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN field ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ INSERT INTO field
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ INSERT INTO field_content
+
+ ( @KEYS(:field_content_data), language_id, field_id )
+
+ VALUES ( :field_content_data, :language_id, @result.field);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN field ARRAY,
+ IN field_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ UPDATE field
+
+ SET @LIST(:field_data)
+
+ WHERE field_id = :field_id;
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ UPDATE field_content
+
+ SET @LIST(:field_content_data)
+
+ WHERE field_id = :field_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN field_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- field
+ DELETE FROM field_content WHERE field_id IN (:field_id);
+ -- field_content
+ DELETE FROM field WHERE field_id IN (:field_id);
+ END
diff --git a/admin/sql/mysqli/post.sql b/admin/sql/mysqli/post.sql
old mode 100755
new mode 100644
index cfe7a43..ae7d9a5
--- a/admin/sql/mysqli/post.sql
+++ b/admin/sql/mysqli/post.sql
@@ -38,7 +38,7 @@
)
BEGIN
- SELECT pd.*,post.*,ad.username,ad.display_name,ad.admin_id,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name
+ SELECT pd.*,post.*,ad.username,ad.display_name,ad.admin_id,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name, post.post_id as array_key
@IF isset(:comment_count)
THEN
,(SELECT COUNT(c.comment_id)
@@ -162,8 +162,6 @@
@IF isset(:status) && !empty(:status)
THEN
AND post.status = :status
- @ELSE
- AND post.status = 'publish'
END @IF
-- username/author
@@ -206,7 +204,7 @@
END @IF
- @IF isset(:site_id)
+ @IF isset(:site_id) && !empty(:site_id)
THEN
AND ps.site_id = :site_id
END @IF
@@ -366,6 +364,7 @@
IN post ARRAY,
IN post_content ARRAY,
IN taxonomy_item_id ARRAY,
+ IN post_field_value ARRAY,
IN site_id ARRAY,
OUT insert_id,
OUT insert_id,
@@ -390,17 +389,25 @@
@EACH(:post_content)
INSERT INTO post_content
- ( @KEYS(:each), post_id)
+ ( @KEYS(:each), post_id )
VALUES ( :each, @result.post);
@EACH(:taxonomy_item_id)
INSERT INTO post_to_taxonomy_item
- ( taxonomy_item_id, post_id)
+ ( taxonomy_item_id, post_id )
VALUES ( :each, @result.post)
ON DUPLICATE KEY UPDATE taxonomy_item_id = :each;
+
+ @EACH(:post_field_value)
+ INSERT INTO post_field_value
+
+ ( @KEYS(:each), post_id )
+
+ VALUES ( :each, @result.post)
+ ON DUPLICATE KEY UPDATE value = :each.value;
@EACH(:site_id)
INSERT INTO post_to_site
@@ -417,6 +424,7 @@
IN post ARRAY,
IN post_content ARRAY,
IN taxonomy_item_id ARRAY,
+ IN post_field_value ARRAY,
IN post_id INT,
IN site_id ARRAY,
OUT insert_id,
@@ -452,6 +460,14 @@
VALUES ( :each, :post_id)
ON DUPLICATE KEY UPDATE taxonomy_item_id = :each;
+ @EACH(:post_field_value)
+ INSERT INTO post_field_value
+
+ ( @KEYS(:each), post_id )
+
+ VALUES ( :each, :post_id)
+ ON DUPLICATE KEY UPDATE value = :each.value;
+
@IF isset(:site_id)
THEN
DELETE FROM post_to_site WHERE post_id = :post_id
@@ -593,7 +609,7 @@
AND type = :type
END @IF
- @IF isset(:site_id)
+ @IF isset(:site_id) && !empty(:site_id)
THEN
AND ps.site_id = :site_id
END @IF
diff --git a/admin/sql/mysqli/post_field_value.sql b/admin/sql/mysqli/post_field_value.sql
new file mode 100644
index 0000000..6d9d9eb
--- /dev/null
+++ b/admin/sql/mysqli/post_field_value.sql
@@ -0,0 +1,159 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN post_id INT,
+ IN subtype CHAR,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT post_field_value.*, field.settings, field.field_id as array_key
+ FROM post_field_value
+ LEFT JOIN field ON (field.field_id = post_field_value.field_id)
+ @IF !empty(:subtype)
+ THEN
+ -- INNER JOIN field_group ON (field.field_group_id = field_group.field_group_id AND field_group.subtype = :subtype)
+ END @IF
+
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND post_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND post_field_value.post_id = :post_id
+ END @IF
+
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN post_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM post_field_value as _
+ INNER JOIN field ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND post_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND post_field_value.field_id = :field_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND post_field_value.post_id = :post_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN post_field_value ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :post_field_value = @FILTER(:post_field_value, post_field_value)
+
+ INSERT INTO post_field_value
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN post_field_value ARRAY,
+ IN post_field_value_id INT,
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :post_field_value = @FILTER(:post_field_value, post_field_value)
+
+ UPDATE post_field_value
+
+ SET @LIST(:post_field_value)
+
+ WHERE field_id = :field_id AND post_id = :post_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- post_field_value_id
+ DELETE FROM post_field_value WHERE
+
+ @IF !empty(:language_id)
+ THEN
+ AND post_field_value.language_id IN (:language_id)
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND post_field_value.field_id IN (:field_id)
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND post_field_value.post_id IN (:post_id)
+ END @IF
+ END
diff --git a/admin/sql/mysqli/product.sql b/admin/sql/mysqli/product.sql
index b01bed6..d9eb0f0 100755
--- a/admin/sql/mysqli/product.sql
+++ b/admin/sql/mysqli/product.sql
@@ -764,6 +764,8 @@
IN manufacturer_id ARRAY,
IN vendor_id ARRAY,
IN option_value_id ARRAY,
+ IN attribute_id ARRAY,
+ IN field_id ARRAY,
IN related INT,
IN variant INT,
IN status INT,
@@ -1024,7 +1026,13 @@
LEFT JOIN admin ad ON (product.admin_id = ad.admin_id)
END @IF
- WHERE p2s.site_id = :site_id
+ WHERE 1 = 1
+
+ -- site_id
+ @IF isset(:site_id) && !empty(:site_id)
+ THEN
+ AND p2s.site_id = :site_id
+ END @IF
-- search
@IF isset(:search) && !empty(:search)
diff --git a/admin/sql/mysqli/product_field_value.sql b/admin/sql/mysqli/product_field_value.sql
new file mode 100644
index 0000000..5cca227
--- /dev/null
+++ b/admin/sql/mysqli/product_field_value.sql
@@ -0,0 +1,157 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN product_id INT,
+ IN subtype CHAR,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT product_field_value.*, field.settings, field.field_id as array_key
+ FROM product_field_value
+ LEFT JOIN field ON (field.field_id = product_field_value.field_id)
+ @IF !empty(:subtype)
+ THEN
+ -- INNER JOIN field_group ON (field.field_group_id = field_group.field_group_id AND field_group.subtype = :subtype)
+ END @IF
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND product_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:product_id)
+ THEN
+ AND product_field_value.product_id = :product_id
+ END @IF
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN product_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM product_field_value as _
+ INNER JOIN field ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND product_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND product_field_value.field_id = :field_id
+ END @IF
+
+ @IF !empty(:product_id)
+ THEN
+ AND product_field_value.product_id = :product_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN product_field_value ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :product_field_value = @FILTER(:product_field_value, product_field_value)
+
+ INSERT INTO product_field_value
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN product_field_value ARRAY,
+ IN product_field_value_id INT,
+ IN product_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :product_field_value = @FILTER(:product_field_value, product_field_value)
+
+ UPDATE product_field_value
+
+ SET @LIST(:product_field_value)
+
+ WHERE field_id = :field_id AND product_id = :product_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN product_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- product_field_value_id
+ DELETE FROM product_field_value WHERE
+
+ @IF !empty(:language_id)
+ THEN
+ AND product_field_value.language_id IN (:language_id)
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND product_field_value.field_id IN (:field_id)
+ END @IF
+
+ @IF !empty(:product_id)
+ THEN
+ AND product_field_value.post_id IN (:post_id)
+ END @IF
+ END
diff --git a/admin/sql/mysqli/product_option_value.sql b/admin/sql/mysqli/product_option_value.sql
old mode 100644
new mode 100755
index 457e7dc..a2a0bc5
--- a/admin/sql/mysqli/product_option_value.sql
+++ b/admin/sql/mysqli/product_option_value.sql
@@ -14,7 +14,7 @@
)
BEGIN
-- product_option_value
- SELECT product_option_value.*,
+ SELECT product_option_value.*, product_option_value.quantity as stock_quantity,
option_value.image, ovc.name, oc.name as `option`,
product_option_value.product_option_value_id as array_key
FROM product_option_value
diff --git a/admin/sql/mysqli/taxonomy_item_field_value.sql b/admin/sql/mysqli/taxonomy_item_field_value.sql
new file mode 100644
index 0000000..dc954cc
--- /dev/null
+++ b/admin/sql/mysqli/taxonomy_item_field_value.sql
@@ -0,0 +1,152 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN post_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT taxonomy_item_field_value.*, field.settings, field.field_id as array_key
+ FROM taxonomy_item_field_value
+ LEFT JOIN field ON (field.field_id = taxonomy_item_field_value.field_id)
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND taxonomy_item_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND taxonomy_item_field_value.post_id = :post_id
+ END @IF
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN post_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM taxonomy_item_field_value as _
+ INNER JOIN field ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND taxonomy_item_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND taxonomy_item_field_value.field_id = :field_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND taxonomy_item_field_value.post_id = :post_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN taxonomy_item_field_value ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :taxonomy_item_field_value = @FILTER(:taxonomy_item_field_value, taxonomy_item_field_value)
+
+ INSERT INTO taxonomy_item_field_value
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN taxonomy_item_field_value ARRAY,
+ IN taxonomy_item_field_value_id INT,
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :taxonomy_item_field_value = @FILTER(:taxonomy_item_field_value, taxonomy_item_field_value)
+
+ UPDATE taxonomy_item_field_value
+
+ SET @LIST(:taxonomy_item_field_value)
+
+ WHERE field_id = :field_id AND post_id = :post_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- taxonomy_item_field_value_id
+ DELETE FROM taxonomy_item_field_value WHERE
+
+ @IF !empty(:language_id)
+ THEN
+ AND taxonomy_item_field_value.language_id IN (:language_id)
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND taxonomy_item_field_value.field_id IN (:field_id)
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND taxonomy_item_field_value.post_id IN (:post_id)
+ END @IF
+ END
diff --git a/admin/sql/mysqli/weight_type.sql b/admin/sql/mysqli/weight_type.sql
index 127fb97..447eb40 100755
--- a/admin/sql/mysqli/weight_type.sql
+++ b/admin/sql/mysqli/weight_type.sql
@@ -1,4 +1,4 @@
--- Currencies
+-- Weight type
-- get all weight types
diff --git a/admin/sql/pgsql/digital_asset.sql b/admin/sql/pgsql/digital_asset.sql
old mode 100755
new mode 100644
index 6d822f0..6471686
--- a/admin/sql/pgsql/digital_asset.sql
+++ b/admin/sql/pgsql/digital_asset.sql
@@ -14,7 +14,7 @@
)
BEGIN
-- digital_asset
- SELECT UNIQUE digital_asset.digital_asset_id, digital_asset.*, digital_asset_content.name
+ SELECT DISTINCT digital_asset.digital_asset_id, digital_asset.*, digital_asset_content.name
-- user_id
@IF isset(:user_id)
THEN
diff --git a/admin/sql/pgsql/field.sql b/admin/sql/pgsql/field.sql
index c90e913..9f47052 100755
--- a/admin/sql/pgsql/field.sql
+++ b/admin/sql/pgsql/field.sql
@@ -1,40 +1,36 @@
--- Taxonomy
+-- Fields
- -- get all taxonomies
+ -- get all fields
- CREATE PROCEDURE getAll(
- IN field_item_id INT,
-
- -- pagination
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN field_group_id ARRAY,
+ IN post_id INT,
IN start INT,
IN limit INT,
-
- -- filter
- IN post_type CHAR,
-
OUT fetch_all,
- OUT fetch_one
+ OUT fetch_one,
)
BEGIN
- -- field_item
- SELECT *, field_id as array_key
- FROM field
- -- LEFT JOIN field_to_site t2s ON (field_item.field_item_id = t2s.field_item_id)
+ -- field
+ SELECT *, field.field_id, field.field_id as array_key
+ FROM field
- WHERE 1 = 1
-
- @IF isset(:post_type)
+ @IF isset(:post_id)
THEN
+ LEFT JOIN post_field_value ON (field.field_id = post_field_value.field_id AND post_field_value.post_id = :post_id AND post_field_value.language_id = :language_id)
+ END @IF
+
+ WHERE 1 = 1
- AND post_type = :post_type
-
- END @IF
-
- @IF isset(:limit)
- THEN
- @SQL_LIMIT(:start, :limit)
- END @IF;
+ @IF !empty(:field_group_id) && is_array(:field_group_id)
+ THEN
+ AND field.field_group_id IN (:field_group_id)
+ END @IF
+ ORDER BY field.row, field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
SELECT count(*) FROM (
@@ -42,6 +38,100 @@
) as count;
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM field as _
+ INNER JOIN field_content ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND field_content.language_id = :language_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN field ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ INSERT INTO field
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ INSERT INTO field_content
+
+ ( @KEYS(:field_content_data), language_id, field_id )
+
+ VALUES ( :field_content_data, :language_id, @result.field);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN field ARRAY,
+ IN field_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ UPDATE field
+
+ SET @LIST(:field_data)
+
+ WHERE field_id = :field_id;
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ UPDATE field_content
+
+ SET @LIST(:field_content_data)
+
+ WHERE field_id = :field_id AND language_id = :language_id;
+
+
END
+ -- delete field
+ PROCEDURE delete(
+ IN field_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- field
+ DELETE FROM field_content WHERE field_id IN (:field_id);
+ -- field_content
+ DELETE FROM field WHERE field_id IN (:field_id);
+ END
diff --git a/admin/sql/pgsql/field_group.sql b/admin/sql/pgsql/field_group.sql
index 502d068..ca6df9c 100755
--- a/admin/sql/pgsql/field_group.sql
+++ b/admin/sql/pgsql/field_group.sql
@@ -6,12 +6,14 @@
IN language_id INT,
IN start INT,
IN limit INT,
+ IN type CHAR,
+ IN subtype CHAR,
OUT fetch_all,
OUT fetch_one,
)
BEGIN
-- field_group
- SELECT *
+ SELECT *, field_group.field_group_id as array_key
FROM field_group
INNER JOIN field_group_content ON field_group_content.field_group_id = field_group.field_group_id
WHERE 1 = 1
@@ -20,6 +22,16 @@
THEN
AND field_group_content.language_id = :language_id
END @IF
+
+ @IF !empty(:type)
+ THEN
+ AND field_group.type = :type
+ END @IF
+
+ @IF !empty(:subtype)
+ THEN
+ AND field_group.subtype = :subtype OR field_group.subtype = ''
+ END @IF
@SQL_LIMIT(:start, :limit);
diff --git a/admin/sql/pgsql/field_value.sql b/admin/sql/pgsql/field_value.sql
new file mode 100644
index 0000000..2990cd9
--- /dev/null
+++ b/admin/sql/pgsql/field_value.sql
@@ -0,0 +1,137 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN field_group_id INT,
+ IN post_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT *, field.field_id as array_key
+ FROM field
+
+ @IF isset(:post_id)
+ THEN
+ LEFT JOIN post_field_value ON (field.field_id = post_field_value.field_id AND post_field_value.post_id = :post_id AND post_field_value.language_id = :language_id)
+ END @IF
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM field as _
+ INNER JOIN field_content ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND field_content.language_id = :language_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN field ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ INSERT INTO field
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ INSERT INTO field_content
+
+ ( @KEYS(:field_content_data), language_id, field_id )
+
+ VALUES ( :field_content_data, :language_id, @result.field);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN field ARRAY,
+ IN field_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ UPDATE field
+
+ SET @LIST(:field_data)
+
+ WHERE field_id = :field_id;
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ UPDATE field_content
+
+ SET @LIST(:field_content_data)
+
+ WHERE field_id = :field_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN field_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- field
+ DELETE FROM field_content WHERE field_id IN (:field_id);
+ -- field_content
+ DELETE FROM field WHERE field_id IN (:field_id);
+ END
diff --git a/admin/sql/pgsql/filter.sql b/admin/sql/pgsql/filter.sql
new file mode 100755
index 0000000..61eb83b
--- /dev/null
+++ b/admin/sql/pgsql/filter.sql
@@ -0,0 +1,329 @@
+-- Attributes
+
+ -- get all attributes
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN product_id ARRAY,
+ IN attribute_group_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- attribute
+ SELECT attribute_content.name, attribute_group_content.name as `group`, attribute.*
+ @IF isset(:product_id)
+ THEN
+ , pa.product_id
+ ,pa.value
+ END @IF
+
+ FROM attribute
+ INNER JOIN attribute_content
+ ON attribute_content.attribute_id = attribute.attribute_id AND attribute_content.language_id = :language_id
+ INNER JOIN attribute_group_content
+ ON attribute_group_content.attribute_group_id = attribute.attribute_group_id AND attribute_group_content.language_id = :language_id
+
+ @IF isset(:product_id)
+ THEN
+ LEFT JOIN product_attribute pa ON attribute.attribute_id = pa.attribute_id
+ END @IF
+
+ WHERE 1 = 1
+
+ @IF isset(:product_id)
+ THEN
+ AND pa.product_id IN (:product_id)
+ END @IF
+
+ @IF isset(:attribute_group_id)
+ THEN
+ AND attribute.attribute_group_id = :attribute_group_id
+ END @IF
+
+ -- search
+ @IF isset(:search) AND !empty(:search)
+ THEN
+ AND attribute_content.name LIKE CONCAT('%',:search,'%')
+ END @IF
+
+ -- limit
+ @IF isset(:limit)
+ THEN
+ @SQL_LIMIT(:start, :limit)
+ END @IF;
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(attribute.attribute_id, attribute) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get attribute
+
+ PROCEDURE get(
+ IN attribute_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- attribute
+ SELECT *
+ FROM attribute as _
+ INNER JOIN attribute_content ac
+ ON ac.attribute_id = _.attribute_id AND ac.language_id = :language_id
+
+ WHERE _.attribute_id = :attribute_id;
+ END
+
+ -- add attribute
+
+ PROCEDURE add(
+ IN attribute ARRAY,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :attribute_data = @FILTER(:attribute, attribute)
+
+
+ INSERT INTO attribute
+
+ ( @KEYS(:attribute_data) )
+
+ VALUES ( :attribute_data );
+
+
+ :attribute_content = @FILTER(:attribute, attribute_content)
+
+ INSERT INTO attribute_content
+
+ ( @KEYS(:attribute_content), language_id, attribute_id )
+
+ VALUES ( :attribute_content, :language_id, @result.attribute);
+
+
+ END
+
+ -- edit attribute
+ CREATE PROCEDURE edit(
+ IN attribute ARRAY,
+ IN attribute_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :attribute_data = @FILTER(:attribute, attribute)
+
+ UPDATE attribute
+
+ SET @LIST(:attribute_data)
+
+ WHERE attribute_id = :attribute_id;
+
+ -- allow only table fields and set defaults for missing values
+ :attribute_content = @FILTER(:attribute, attribute_content)
+
+ UPDATE attribute_content
+
+ SET @LIST(:attribute_content)
+
+ WHERE attribute_id = :attribute_id;
+
+ END
+
+ -- delete attribute
+
+ PROCEDURE delete(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- attribute
+ DELETE FROM attribute_content WHERE attribute_id IN (:attribute_id);
+ DELETE FROM attribute WHERE attribute_id IN (:attribute_id);
+ END
+
+
+
+ PROCEDURE price(
+ IN site_id INT,
+ IN category_id ARRAY,
+ IN taxonomy_item_id ARRAY,
+ IN option_value_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+
+ SELECT MAX(p.price) as price_max_limit, MIN(p.price) as price_min_limit -- , tax_type_id
+ FROM product p
+ LEFT JOIN product_to_site p2s ON (p.product_id = p2s.product_id)
+ LEFT JOIN product_to_taxonomy_item p2t ON (p.product_id = p2t.product_id)
+ LEFT JOIN product_option_value pov ON (p.product_id = pov.product_id)
+ LEFT JOIN product_attribute pa ON (p.product_id = pa.product_id)
+ WHERE
+ p2s.site_id = :site_id
+
+ -- filter sql
+ AND pov.product_id IN (
+ SELECT product_id FROM product_option_value pov2
+ WHERE pov2.option_value_id IN (:option_value_id)
+ -- GROUP by product_id HAVING count(product_id) >= 4
+ )
+
+ AND pa.value IN (:product_attribute)
+ AND p2t.taxonomy_item_id IN (:taxonomy_item_id)
+
+ -- limit
+ @IF isset(:limit)
+ THEN
+ @SQL_LIMIT(:start, :limit)
+ END @IF;
+
+ END
+
+
+
+ PROCEDURE manufacturers(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+
+ SELECT *,m.image as image FROM manufacturer m
+ LEFT JOIN manufacturer_to_site m2s ON (m.manufacturer_id = m2s.manufacturer_id)
+ INNER JOIN product p ON (m.manufacturer_id = p.manufacturer_id)
+ LEFT JOIN product_special ps ON (p.product_id = ps.product_id)
+ LEFT JOIN product_to_category p2c ON (p.product_id = p2c.product_id)
+ LEFT JOIN product_option_value pov ON (p.product_id = pov.product_id)
+ LEFT JOIN product_attribute pa ON (p.product_id = pa.product_id)
+ WHERE
+ m2s.site_id = :site_id
+ -- filter sql
+ GROUP BY(m.manufacturer_id)
+
+ -- limit
+ @IF isset(:limit)
+ THEN
+ @SQL_LIMIT(:start, :limit)
+ END @IF;
+
+ END
+
+
+
+ PROCEDURE categories(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+
+ SELECT *,c.category_id as category_id,count(p2c.product_id) as prod_count FROM category c
+ LEFT JOIN category_to_site c2s ON (c.category_id = c2s.category_id)
+ LEFT JOIN category_description cd ON (c.category_id = cd.category_id)
+ LEFT JOIN product_to_category p2c ON (c.category_id = p2c.category_id)
+ WHERE
+ c.parent_id = '" . (int)$parent_id . "'
+ AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "'
+ AND c2s.site_id = '" . (int)$this->config->get('config_site_id') . ' ' . "'
+ AND c.status = '1'
+
+ GROUP BY c.category_id ORDER BY c.sort_order, LCASE(cd.name)
+
+ -- limit
+ @IF isset(:limit)
+ THEN
+ @SQL_LIMIT(:start, :limit)
+ END @IF;
+ END
+
+
+
+
+ PROCEDURE filters(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- attribute
+ DELETE FROM attribute_content WHERE attribute_id IN (:attribute_id);
+ DELETE FROM attribute WHERE attribute_id IN (:attribute_id);
+ END
+
+
+
+
+ PROCEDURE availability(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- attribute
+ DELETE FROM attribute_content WHERE attribute_id IN (:attribute_id);
+ DELETE FROM attribute WHERE attribute_id IN (:attribute_id);
+ END
+
+
+
+
+ PROCEDURE options(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+
+ SELECT *,od.name as option_name, ovd.name as value_name, ov.image as value_image, count(p.product_id) as prod_count
+ FROM product_option_value pov
+ LEFT JOIN option_value ov ON (pov.option_value_id = ov.option_value_id)
+ LEFT JOIN option_value_description ovd ON (ov.option_value_id = ovd.option_value_id)
+ LEFT JOIN `option` po ON (pov.option_id = po.option_id)
+ LEFT JOIN option_description od ON (po.option_id = od.option_id)
+ INNER JOIN product_to_category p2c ON (pov.product_id = p2c.product_id $category_join)
+ LEFT JOIN product_attribute pa ON (pov.product_id = pa.product_id)
+ INNER JOIN product p ON (p.product_id = p2c.product_id)
+ LEFT JOIN product_special ps ON (p.product_id = ps.product_id)
+ WHERE ovd.language_id = :language_id
+ --. $filter_sql . "
+
+ GROUP BY ov.option_value_id
+
+ END
+
+
+ PROCEDURE attributes(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+
+ SELECT pa1.attribute_id, ad.name, pa1.text,count(pa1.product_id) as prod_count FROM product_attribute pa1
+
+ LEFT JOIN attribute_description ad ON (pa1.attribute_id = ad.attribute_id)
+ WHERE ad.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa1.language_id = '" . (int)$this->config->get('config_language_id') . "'
+ AND product_id IN (
+ SELECT p.product_id FROM
+ product p
+ INNER JOIN product_to_category p2c ON (p.product_id = p2c.product_id)
+
+ " . $sql_joins . "
+ -- ". $filter_sql .
+ )
+ GROUP BY pa1.attribute_id,text ORDER BY ad.name
+
+ END
diff --git a/admin/sql/pgsql/post.sql b/admin/sql/pgsql/post.sql
old mode 100755
new mode 100644
index c55b997..f40a31f
--- a/admin/sql/pgsql/post.sql
+++ b/admin/sql/pgsql/post.sql
@@ -38,7 +38,7 @@
)
BEGIN
- SELECT pd.*,post.*,ad.username,ad.display_name,ad.admin_id,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name
+ SELECT pd.*,post.*,ad.username,ad.display_name,ad.admin_id,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name, post.post_id as array_key
@IF isset(:comment_count)
THEN
,(SELECT COUNT(c.comment_id)
@@ -93,8 +93,6 @@
@IF isset(:status) && !empty(:status)
THEN
AND post.status = :status
- @ELSE
- AND post.status = 'publish'
END @IF
-- username/author
@@ -132,7 +130,7 @@
END @IF
- @IF isset(:site_id)
+ @IF isset(:site_id) && !empty(:site_id)
THEN
AND ps.site_id = :site_id
END @IF
@@ -252,7 +250,7 @@
@IF isset(:post_id) && :post_id > 0
THEN
AND _.post_id = :post_id
- END @IF
+ END @IF
@IF isset(:admin_id)
THEN
@@ -292,6 +290,7 @@
IN post ARRAY,
IN post_content ARRAY,
IN taxonomy_item_id ARRAY,
+ IN post_field_value ARRAY,
IN site_id ARRAY,
OUT fetch_one,
OUT fetch_one,
@@ -327,6 +326,14 @@
VALUES ( :each, @result.post)
ON CONFLICT ("taxonomy_item_id", "post_id") DO UPDATE SET "taxonomy_item_id" = :each;
+
+ @EACH(:post_field_value)
+ INSERT INTO post_field_value
+
+ ( @KEYS(:each), post_id )
+
+ VALUES ( :each, @result.post)
+ ON CONFLICT ("field_id", "post_id","language_id") DO UPDATE SET "value" = :each;
@EACH(:site_id)
INSERT INTO post_to_site
@@ -343,6 +350,7 @@
IN post ARRAY,
IN post_content ARRAY,
IN taxonomy_item_id ARRAY,
+ IN post_field_value ARRAY,
IN post_id INT,
IN site_id ARRAY,
OUT fetch_one,
@@ -378,6 +386,14 @@
VALUES ( :each, :post_id)
ON CONFLICT ("taxonomy_item_id", "post_id") DO UPDATE SET "taxonomy_item_id" = :each;
+ @EACH(:post_field_value)
+ INSERT INTO post_field_value
+
+ ( @KEYS(:each), post_id )
+
+ VALUES ( :each, @result.post)
+ ON CONFLICT ("field_id", "post_id","language_id") DO UPDATE SET "value" = :each;
+
@IF isset(:site_id)
THEN
DELETE FROM post_to_site WHERE post_id = :post_id
diff --git a/admin/sql/pgsql/post_field_value.sql b/admin/sql/pgsql/post_field_value.sql
new file mode 100644
index 0000000..6d9d9eb
--- /dev/null
+++ b/admin/sql/pgsql/post_field_value.sql
@@ -0,0 +1,159 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN post_id INT,
+ IN subtype CHAR,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT post_field_value.*, field.settings, field.field_id as array_key
+ FROM post_field_value
+ LEFT JOIN field ON (field.field_id = post_field_value.field_id)
+ @IF !empty(:subtype)
+ THEN
+ -- INNER JOIN field_group ON (field.field_group_id = field_group.field_group_id AND field_group.subtype = :subtype)
+ END @IF
+
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND post_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND post_field_value.post_id = :post_id
+ END @IF
+
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN post_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM post_field_value as _
+ INNER JOIN field ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND post_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND post_field_value.field_id = :field_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND post_field_value.post_id = :post_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN post_field_value ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :post_field_value = @FILTER(:post_field_value, post_field_value)
+
+ INSERT INTO post_field_value
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN post_field_value ARRAY,
+ IN post_field_value_id INT,
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :post_field_value = @FILTER(:post_field_value, post_field_value)
+
+ UPDATE post_field_value
+
+ SET @LIST(:post_field_value)
+
+ WHERE field_id = :field_id AND post_id = :post_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- post_field_value_id
+ DELETE FROM post_field_value WHERE
+
+ @IF !empty(:language_id)
+ THEN
+ AND post_field_value.language_id IN (:language_id)
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND post_field_value.field_id IN (:field_id)
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND post_field_value.post_id IN (:post_id)
+ END @IF
+ END
diff --git a/admin/sql/pgsql/product.sql b/admin/sql/pgsql/product.sql
index 485d5c1..513ab0a 100755
--- a/admin/sql/pgsql/product.sql
+++ b/admin/sql/pgsql/product.sql
@@ -1019,7 +1019,13 @@
LEFT JOIN admin ad ON (product.admin_id = ad.admin_id)
END @IF
- WHERE p2s.site_id = :site_id
+ WHERE 1 = 1
+
+ -- site_id
+ @IF isset(:site_id) && !empty(:site_id)
+ THEN
+ AND p2s.site_id = :site_id
+ END @IF
-- search
@IF isset(:search) && !empty(:search)
diff --git a/admin/sql/pgsql/product_field_value.sql b/admin/sql/pgsql/product_field_value.sql
new file mode 100644
index 0000000..5cca227
--- /dev/null
+++ b/admin/sql/pgsql/product_field_value.sql
@@ -0,0 +1,157 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN product_id INT,
+ IN subtype CHAR,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT product_field_value.*, field.settings, field.field_id as array_key
+ FROM product_field_value
+ LEFT JOIN field ON (field.field_id = product_field_value.field_id)
+ @IF !empty(:subtype)
+ THEN
+ -- INNER JOIN field_group ON (field.field_group_id = field_group.field_group_id AND field_group.subtype = :subtype)
+ END @IF
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND product_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:product_id)
+ THEN
+ AND product_field_value.product_id = :product_id
+ END @IF
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN product_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM product_field_value as _
+ INNER JOIN field ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND product_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND product_field_value.field_id = :field_id
+ END @IF
+
+ @IF !empty(:product_id)
+ THEN
+ AND product_field_value.product_id = :product_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN product_field_value ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :product_field_value = @FILTER(:product_field_value, product_field_value)
+
+ INSERT INTO product_field_value
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN product_field_value ARRAY,
+ IN product_field_value_id INT,
+ IN product_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :product_field_value = @FILTER(:product_field_value, product_field_value)
+
+ UPDATE product_field_value
+
+ SET @LIST(:product_field_value)
+
+ WHERE field_id = :field_id AND product_id = :product_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN product_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- product_field_value_id
+ DELETE FROM product_field_value WHERE
+
+ @IF !empty(:language_id)
+ THEN
+ AND product_field_value.language_id IN (:language_id)
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND product_field_value.field_id IN (:field_id)
+ END @IF
+
+ @IF !empty(:product_id)
+ THEN
+ AND product_field_value.post_id IN (:post_id)
+ END @IF
+ END
diff --git a/admin/sql/pgsql/product_option_value.sql b/admin/sql/pgsql/product_option_value.sql
old mode 100644
new mode 100755
index c84ab1b..8dcd2af
--- a/admin/sql/pgsql/product_option_value.sql
+++ b/admin/sql/pgsql/product_option_value.sql
@@ -14,7 +14,7 @@
)
BEGIN
-- product_option_value
- SELECT product_option_value.*,
+ SELECT product_option_value.*, product_option_value.quantity as stock_quantity,
option_value.image, ovc.name, oc.name as "option",
product_option_value.product_option_value_id as array_key
FROM product_option_value
diff --git a/admin/sql/pgsql/site.sql b/admin/sql/pgsql/site.sql
index 74333f9..fdc8d70 100755
--- a/admin/sql/pgsql/site.sql
+++ b/admin/sql/pgsql/site.sql
@@ -20,7 +20,7 @@
WHERE 1 = 1
-- site_id
- @IF isset(:site_id) && !empty(:site_id)
+ @IF isset(:site_id) && !empty(:site_id) && is_array(:site_id)
THEN
AND site.site_id IN (:site_id)
END @IF
diff --git a/admin/sql/pgsql/taxonomy_item_field_value.sql b/admin/sql/pgsql/taxonomy_item_field_value.sql
new file mode 100644
index 0000000..dc954cc
--- /dev/null
+++ b/admin/sql/pgsql/taxonomy_item_field_value.sql
@@ -0,0 +1,152 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN post_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT taxonomy_item_field_value.*, field.settings, field.field_id as array_key
+ FROM taxonomy_item_field_value
+ LEFT JOIN field ON (field.field_id = taxonomy_item_field_value.field_id)
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND taxonomy_item_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND taxonomy_item_field_value.post_id = :post_id
+ END @IF
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN post_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM taxonomy_item_field_value as _
+ INNER JOIN field ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND taxonomy_item_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND taxonomy_item_field_value.field_id = :field_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND taxonomy_item_field_value.post_id = :post_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN taxonomy_item_field_value ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :taxonomy_item_field_value = @FILTER(:taxonomy_item_field_value, taxonomy_item_field_value)
+
+ INSERT INTO taxonomy_item_field_value
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN taxonomy_item_field_value ARRAY,
+ IN taxonomy_item_field_value_id INT,
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :taxonomy_item_field_value = @FILTER(:taxonomy_item_field_value, taxonomy_item_field_value)
+
+ UPDATE taxonomy_item_field_value
+
+ SET @LIST(:taxonomy_item_field_value)
+
+ WHERE field_id = :field_id AND post_id = :post_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- taxonomy_item_field_value_id
+ DELETE FROM taxonomy_item_field_value WHERE
+
+ @IF !empty(:language_id)
+ THEN
+ AND taxonomy_item_field_value.language_id IN (:language_id)
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND taxonomy_item_field_value.field_id IN (:field_id)
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND taxonomy_item_field_value.post_id IN (:post_id)
+ END @IF
+ END
diff --git a/admin/sql/sqlite/category.sql b/admin/sql/sqlite/category.sql
index e230bce..f9521e4 100755
--- a/admin/sql/sqlite/category.sql
+++ b/admin/sql/sqlite/category.sql
@@ -65,12 +65,12 @@
@IF isset(:post_id) THEN
@IF :type == "tags"
- THEN
-
- INNER JOIN post_to_taxonomy_item pt ON (categories.taxonomy_item_id = pt.taxonomy_item_id AND pt.post_id = :post_id)
- @ELSE
-
- LEFT JOIN post_to_taxonomy_item pt ON (categories.taxonomy_item_id = pt.taxonomy_item_id AND pt.post_id = :post_id)
+ THEN
+
+ INNER JOIN post_to_taxonomy_item pt ON (categories.taxonomy_item_id = pt.taxonomy_item_id AND pt.post_id = :post_id)
+ @ELSE
+
+ LEFT JOIN post_to_taxonomy_item pt ON (categories.taxonomy_item_id = pt.taxonomy_item_id AND pt.post_id = :post_id)
END @IF
@@ -107,7 +107,7 @@
AND t.type = :type
END @IF
-
+
@IF isset(:post_type)
THEN
@@ -167,6 +167,7 @@
IN parent_id INT,
IN search CHAR,
IN type CHAR,
+ IN post_type CHAR,
-- pagination
IN start INT,
@@ -196,7 +197,23 @@
FROM post_content pc
LEFT JOIN post p ON (pc.post_id = p.post_id)
LEFT JOIN post_to_taxonomy_item ptt ON (ptt.taxonomy_item_id = categories.taxonomy_item_id AND ptt.post_id = p.post_id)
- WHERE ptt.taxonomy_item_id = categories.taxonomy_item_id ORDER by p.sort_order
+ WHERE ptt.taxonomy_item_id = categories.taxonomy_item_id
+
+ @IF isset(:post_type)
+ THEN
+
+ AND p.type = :post_type
+
+ END @IF
+
+
+ ORDER by p.sort_order
+
+ @IF isset(:posts_limit) && !empty(:posts_limit)
+ THEN
+ @SQL_LIMIT(:posts_start, :posts_limit)
+ END @IF
+
) AS post
FROM taxonomy_item AS categories
@@ -316,7 +333,7 @@
END @IF
- WHERE
+ WHERE
1 = 1
@IF isset(:taxonomy_item_id)
@@ -332,7 +349,7 @@
AND _.post_type = :post_type
END @IF
-
+
@IF isset(:post_id)
THEN
,pt.post_id as checked
@@ -363,6 +380,7 @@
IN taxonomy_item_id INT,
IN parent_id INT,
IN language_id INT,
+ IN site_id INT,
IN post_type CHAR,
IN slug CHAR,
OUT fetch_row
@@ -374,6 +392,12 @@
FROM taxonomy_item_content AS _
LEFT JOIN taxonomy_item as ti ON (_.taxonomy_item_id = ti.taxonomy_item_id)
LEFT JOIN taxonomy t ON (ti.taxonomy_id = t.taxonomy_id)
+
+ @IF isset(:site_id)
+ THEN
+ LEFT JOIN taxonomy_to_site tt ON (tt.taxonomy_item_id = ti.taxonomy_item_id)
+ END @IF
+
WHERE 1 = 1
@IF isset(:taxonomy_item_id)
@@ -409,9 +433,16 @@
AND t.post_type = :post_type
+ END @IF
+
+ @IF isset(:site_id)
+ THEN
+
+ AND tt.site_id = :site_id
+
END @IF
-
+
LIMIT 1;
-- images
diff --git a/admin/sql/sqlite/digital_asset.sql b/admin/sql/sqlite/digital_asset.sql
old mode 100755
new mode 100644
index f3eb588..46ab367
--- a/admin/sql/sqlite/digital_asset.sql
+++ b/admin/sql/sqlite/digital_asset.sql
@@ -14,7 +14,7 @@
)
BEGIN
-- digital_asset
- SELECT UNIQUE digital_asset.digital_asset_id, digital_asset.*, digital_asset_content.name
+ SELECT DISTINCT digital_asset.digital_asset_id, digital_asset.*, digital_asset_content.name
-- user_id
@IF isset(:user_id)
THEN
diff --git a/admin/sql/sqlite/field.sql b/admin/sql/sqlite/field.sql
index c90e913..9f47052 100755
--- a/admin/sql/sqlite/field.sql
+++ b/admin/sql/sqlite/field.sql
@@ -1,40 +1,36 @@
--- Taxonomy
+-- Fields
- -- get all taxonomies
+ -- get all fields
- CREATE PROCEDURE getAll(
- IN field_item_id INT,
-
- -- pagination
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN field_group_id ARRAY,
+ IN post_id INT,
IN start INT,
IN limit INT,
-
- -- filter
- IN post_type CHAR,
-
OUT fetch_all,
- OUT fetch_one
+ OUT fetch_one,
)
BEGIN
- -- field_item
- SELECT *, field_id as array_key
- FROM field
- -- LEFT JOIN field_to_site t2s ON (field_item.field_item_id = t2s.field_item_id)
+ -- field
+ SELECT *, field.field_id, field.field_id as array_key
+ FROM field
- WHERE 1 = 1
-
- @IF isset(:post_type)
+ @IF isset(:post_id)
THEN
+ LEFT JOIN post_field_value ON (field.field_id = post_field_value.field_id AND post_field_value.post_id = :post_id AND post_field_value.language_id = :language_id)
+ END @IF
+
+ WHERE 1 = 1
- AND post_type = :post_type
-
- END @IF
-
- @IF isset(:limit)
- THEN
- @SQL_LIMIT(:start, :limit)
- END @IF;
+ @IF !empty(:field_group_id) && is_array(:field_group_id)
+ THEN
+ AND field.field_group_id IN (:field_group_id)
+ END @IF
+ ORDER BY field.row, field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
SELECT count(*) FROM (
@@ -42,6 +38,100 @@
) as count;
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM field as _
+ INNER JOIN field_content ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND field_content.language_id = :language_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN field ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ INSERT INTO field
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ INSERT INTO field_content
+
+ ( @KEYS(:field_content_data), language_id, field_id )
+
+ VALUES ( :field_content_data, :language_id, @result.field);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN field ARRAY,
+ IN field_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ UPDATE field
+
+ SET @LIST(:field_data)
+
+ WHERE field_id = :field_id;
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ UPDATE field_content
+
+ SET @LIST(:field_content_data)
+
+ WHERE field_id = :field_id AND language_id = :language_id;
+
+
END
+ -- delete field
+ PROCEDURE delete(
+ IN field_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- field
+ DELETE FROM field_content WHERE field_id IN (:field_id);
+ -- field_content
+ DELETE FROM field WHERE field_id IN (:field_id);
+ END
diff --git a/admin/sql/sqlite/field_group.sql b/admin/sql/sqlite/field_group.sql
index 0ba2eed..c7e8cce 100755
--- a/admin/sql/sqlite/field_group.sql
+++ b/admin/sql/sqlite/field_group.sql
@@ -6,12 +6,14 @@
IN language_id INT,
IN start INT,
IN limit INT,
+ IN type CHAR,
+ IN subtype CHAR,
OUT fetch_all,
OUT fetch_one,
)
BEGIN
-- field_group
- SELECT *
+ SELECT *, field_group.field_group_id as array_key
FROM field_group
INNER JOIN field_group_content ON field_group_content.field_group_id = field_group.field_group_id
WHERE 1 = 1
@@ -20,6 +22,16 @@
THEN
AND field_group_content.language_id = :language_id
END @IF
+
+ @IF !empty(:type)
+ THEN
+ AND field_group.type = :type
+ END @IF
+
+ @IF !empty(:subtype)
+ THEN
+ AND field_group.subtype = :subtype OR field_group.subtype = ''
+ END @IF
@SQL_LIMIT(:start, :limit);
diff --git a/admin/sql/sqlite/field_value.sql b/admin/sql/sqlite/field_value.sql
new file mode 100644
index 0000000..2990cd9
--- /dev/null
+++ b/admin/sql/sqlite/field_value.sql
@@ -0,0 +1,137 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN field_group_id INT,
+ IN post_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT *, field.field_id as array_key
+ FROM field
+
+ @IF isset(:post_id)
+ THEN
+ LEFT JOIN post_field_value ON (field.field_id = post_field_value.field_id AND post_field_value.post_id = :post_id AND post_field_value.language_id = :language_id)
+ END @IF
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM field as _
+ INNER JOIN field_content ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND field_content.language_id = :language_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN field ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ INSERT INTO field
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ INSERT INTO field_content
+
+ ( @KEYS(:field_content_data), language_id, field_id )
+
+ VALUES ( :field_content_data, :language_id, @result.field);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN field ARRAY,
+ IN field_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :field_data = @FILTER(:field, field)
+
+ UPDATE field
+
+ SET @LIST(:field_data)
+
+ WHERE field_id = :field_id;
+
+ -- allow only table fields and set defaults for missing values
+ :field_content_data = @FILTER(:field, field_content)
+
+ UPDATE field_content
+
+ SET @LIST(:field_content_data)
+
+ WHERE field_id = :field_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN field_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- field
+ DELETE FROM field_content WHERE field_id IN (:field_id);
+ -- field_content
+ DELETE FROM field WHERE field_id IN (:field_id);
+ END
diff --git a/admin/sql/sqlite/filter.sql b/admin/sql/sqlite/filter.sql
new file mode 100755
index 0000000..61eb83b
--- /dev/null
+++ b/admin/sql/sqlite/filter.sql
@@ -0,0 +1,329 @@
+-- Attributes
+
+ -- get all attributes
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN product_id ARRAY,
+ IN attribute_group_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- attribute
+ SELECT attribute_content.name, attribute_group_content.name as `group`, attribute.*
+ @IF isset(:product_id)
+ THEN
+ , pa.product_id
+ ,pa.value
+ END @IF
+
+ FROM attribute
+ INNER JOIN attribute_content
+ ON attribute_content.attribute_id = attribute.attribute_id AND attribute_content.language_id = :language_id
+ INNER JOIN attribute_group_content
+ ON attribute_group_content.attribute_group_id = attribute.attribute_group_id AND attribute_group_content.language_id = :language_id
+
+ @IF isset(:product_id)
+ THEN
+ LEFT JOIN product_attribute pa ON attribute.attribute_id = pa.attribute_id
+ END @IF
+
+ WHERE 1 = 1
+
+ @IF isset(:product_id)
+ THEN
+ AND pa.product_id IN (:product_id)
+ END @IF
+
+ @IF isset(:attribute_group_id)
+ THEN
+ AND attribute.attribute_group_id = :attribute_group_id
+ END @IF
+
+ -- search
+ @IF isset(:search) AND !empty(:search)
+ THEN
+ AND attribute_content.name LIKE CONCAT('%',:search,'%')
+ END @IF
+
+ -- limit
+ @IF isset(:limit)
+ THEN
+ @SQL_LIMIT(:start, :limit)
+ END @IF;
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(attribute.attribute_id, attribute) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get attribute
+
+ PROCEDURE get(
+ IN attribute_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- attribute
+ SELECT *
+ FROM attribute as _
+ INNER JOIN attribute_content ac
+ ON ac.attribute_id = _.attribute_id AND ac.language_id = :language_id
+
+ WHERE _.attribute_id = :attribute_id;
+ END
+
+ -- add attribute
+
+ PROCEDURE add(
+ IN attribute ARRAY,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :attribute_data = @FILTER(:attribute, attribute)
+
+
+ INSERT INTO attribute
+
+ ( @KEYS(:attribute_data) )
+
+ VALUES ( :attribute_data );
+
+
+ :attribute_content = @FILTER(:attribute, attribute_content)
+
+ INSERT INTO attribute_content
+
+ ( @KEYS(:attribute_content), language_id, attribute_id )
+
+ VALUES ( :attribute_content, :language_id, @result.attribute);
+
+
+ END
+
+ -- edit attribute
+ CREATE PROCEDURE edit(
+ IN attribute ARRAY,
+ IN attribute_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :attribute_data = @FILTER(:attribute, attribute)
+
+ UPDATE attribute
+
+ SET @LIST(:attribute_data)
+
+ WHERE attribute_id = :attribute_id;
+
+ -- allow only table fields and set defaults for missing values
+ :attribute_content = @FILTER(:attribute, attribute_content)
+
+ UPDATE attribute_content
+
+ SET @LIST(:attribute_content)
+
+ WHERE attribute_id = :attribute_id;
+
+ END
+
+ -- delete attribute
+
+ PROCEDURE delete(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- attribute
+ DELETE FROM attribute_content WHERE attribute_id IN (:attribute_id);
+ DELETE FROM attribute WHERE attribute_id IN (:attribute_id);
+ END
+
+
+
+ PROCEDURE price(
+ IN site_id INT,
+ IN category_id ARRAY,
+ IN taxonomy_item_id ARRAY,
+ IN option_value_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+
+ SELECT MAX(p.price) as price_max_limit, MIN(p.price) as price_min_limit -- , tax_type_id
+ FROM product p
+ LEFT JOIN product_to_site p2s ON (p.product_id = p2s.product_id)
+ LEFT JOIN product_to_taxonomy_item p2t ON (p.product_id = p2t.product_id)
+ LEFT JOIN product_option_value pov ON (p.product_id = pov.product_id)
+ LEFT JOIN product_attribute pa ON (p.product_id = pa.product_id)
+ WHERE
+ p2s.site_id = :site_id
+
+ -- filter sql
+ AND pov.product_id IN (
+ SELECT product_id FROM product_option_value pov2
+ WHERE pov2.option_value_id IN (:option_value_id)
+ -- GROUP by product_id HAVING count(product_id) >= 4
+ )
+
+ AND pa.value IN (:product_attribute)
+ AND p2t.taxonomy_item_id IN (:taxonomy_item_id)
+
+ -- limit
+ @IF isset(:limit)
+ THEN
+ @SQL_LIMIT(:start, :limit)
+ END @IF;
+
+ END
+
+
+
+ PROCEDURE manufacturers(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+
+ SELECT *,m.image as image FROM manufacturer m
+ LEFT JOIN manufacturer_to_site m2s ON (m.manufacturer_id = m2s.manufacturer_id)
+ INNER JOIN product p ON (m.manufacturer_id = p.manufacturer_id)
+ LEFT JOIN product_special ps ON (p.product_id = ps.product_id)
+ LEFT JOIN product_to_category p2c ON (p.product_id = p2c.product_id)
+ LEFT JOIN product_option_value pov ON (p.product_id = pov.product_id)
+ LEFT JOIN product_attribute pa ON (p.product_id = pa.product_id)
+ WHERE
+ m2s.site_id = :site_id
+ -- filter sql
+ GROUP BY(m.manufacturer_id)
+
+ -- limit
+ @IF isset(:limit)
+ THEN
+ @SQL_LIMIT(:start, :limit)
+ END @IF;
+
+ END
+
+
+
+ PROCEDURE categories(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+
+ SELECT *,c.category_id as category_id,count(p2c.product_id) as prod_count FROM category c
+ LEFT JOIN category_to_site c2s ON (c.category_id = c2s.category_id)
+ LEFT JOIN category_description cd ON (c.category_id = cd.category_id)
+ LEFT JOIN product_to_category p2c ON (c.category_id = p2c.category_id)
+ WHERE
+ c.parent_id = '" . (int)$parent_id . "'
+ AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "'
+ AND c2s.site_id = '" . (int)$this->config->get('config_site_id') . ' ' . "'
+ AND c.status = '1'
+
+ GROUP BY c.category_id ORDER BY c.sort_order, LCASE(cd.name)
+
+ -- limit
+ @IF isset(:limit)
+ THEN
+ @SQL_LIMIT(:start, :limit)
+ END @IF;
+ END
+
+
+
+
+ PROCEDURE filters(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- attribute
+ DELETE FROM attribute_content WHERE attribute_id IN (:attribute_id);
+ DELETE FROM attribute WHERE attribute_id IN (:attribute_id);
+ END
+
+
+
+
+ PROCEDURE availability(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- attribute
+ DELETE FROM attribute_content WHERE attribute_id IN (:attribute_id);
+ DELETE FROM attribute WHERE attribute_id IN (:attribute_id);
+ END
+
+
+
+
+ PROCEDURE options(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+
+ SELECT *,od.name as option_name, ovd.name as value_name, ov.image as value_image, count(p.product_id) as prod_count
+ FROM product_option_value pov
+ LEFT JOIN option_value ov ON (pov.option_value_id = ov.option_value_id)
+ LEFT JOIN option_value_description ovd ON (ov.option_value_id = ovd.option_value_id)
+ LEFT JOIN `option` po ON (pov.option_id = po.option_id)
+ LEFT JOIN option_description od ON (po.option_id = od.option_id)
+ INNER JOIN product_to_category p2c ON (pov.product_id = p2c.product_id $category_join)
+ LEFT JOIN product_attribute pa ON (pov.product_id = pa.product_id)
+ INNER JOIN product p ON (p.product_id = p2c.product_id)
+ LEFT JOIN product_special ps ON (p.product_id = ps.product_id)
+ WHERE ovd.language_id = :language_id
+ --. $filter_sql . "
+
+ GROUP BY ov.option_value_id
+
+ END
+
+
+ PROCEDURE attributes(
+ IN attribute_id ARRAY,
+ OUT affected_rows,
+ OUT affected_rows,
+ )
+ BEGIN
+
+ SELECT pa1.attribute_id, ad.name, pa1.text,count(pa1.product_id) as prod_count FROM product_attribute pa1
+
+ LEFT JOIN attribute_description ad ON (pa1.attribute_id = ad.attribute_id)
+ WHERE ad.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa1.language_id = '" . (int)$this->config->get('config_language_id') . "'
+ AND product_id IN (
+ SELECT p.product_id FROM
+ product p
+ INNER JOIN product_to_category p2c ON (p.product_id = p2c.product_id)
+
+ " . $sql_joins . "
+ -- ". $filter_sql .
+ )
+ GROUP BY pa1.attribute_id,text ORDER BY ad.name
+
+ END
diff --git a/admin/sql/sqlite/post.sql b/admin/sql/sqlite/post.sql
old mode 100755
new mode 100644
index b299e57..c15107d
--- a/admin/sql/sqlite/post.sql
+++ b/admin/sql/sqlite/post.sql
@@ -38,7 +38,7 @@
)
BEGIN
- SELECT pd.*,post.*,ad.username,ad.display_name,ad.admin_id,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name
+ SELECT pd.*,post.*,ad.username,ad.display_name,ad.admin_id,ad.email, ad.avatar, ad.bio, ad.first_name, ad.last_name, post.post_id as array_key
@IF isset(:comment_count)
THEN
,(SELECT COUNT(c.comment_id)
@@ -88,8 +88,6 @@
@IF isset(:status) && !empty(:status)
THEN
AND post.status = :status
- @ELSE
- AND post.status = 'publish'
END @IF
-- username/author
@@ -127,7 +125,7 @@
END @IF
- @IF isset(:site_id)
+ @IF isset(:site_id) && !empty(:site_id)
THEN
AND ps.site_id = :site_id
END @IF
@@ -247,7 +245,7 @@
@IF isset(:post_id) && :post_id > 0
THEN
AND _.post_id = :post_id
- END @IF
+ END @IF
@IF isset(:admin_id)
THEN
@@ -287,6 +285,7 @@
IN post ARRAY,
IN post_content ARRAY,
IN taxonomy_item_id ARRAY,
+ IN post_field_value ARRAY,
IN site_id ARRAY,
OUT insert_id,
OUT insert_id,
@@ -323,6 +322,14 @@
VALUES ( :each, @result.post)
ON CONFLICT(`post_id`,`taxonomy_item_id`) DO UPDATE SET `taxonomy_item_id` = :each;
+ @EACH(:post_field_value)
+ INSERT INTO post_field_value
+
+ ( @KEYS(:each), post_id )
+
+ VALUES ( :each, @result.post)
+ ON CONFLICT(`field_id`,`post_id`,`language_id`) DO UPDATE SET `value` = :each;
+
@EACH(:site_id)
INSERT INTO post_to_site
@@ -338,6 +345,7 @@
IN post ARRAY,
IN post_content ARRAY,
IN taxonomy_item_id ARRAY,
+ IN post_field_value ARRAY,
IN post_id INT,
IN site_id ARRAY,
OUT insert_id,
@@ -367,13 +375,21 @@
END @IF;
@EACH(:taxonomy_item_id)
- INSERT INTO post_to_taxonomy_item
+ INSERT INTO post_to_taxonomy_item
(taxonomy_item_id, post_id)
VALUES ( :each, :post_id)
ON CONFLICT(`post_id`,`taxonomy_item_id`) DO UPDATE SET `taxonomy_item_id` = :each;
+ @EACH(:post_field_value)
+ INSERT INTO post_field_value
+
+ ( @KEYS(:each), post_id )
+
+ VALUES ( :each, @result.post)
+ ON CONFLICT(`field_id`,`post_id`,`language_id`) DO UPDATE SET `value` = :each;
+
@IF isset(:site_id)
THEN
DELETE FROM post_to_site WHERE post_id = :post_id
diff --git a/admin/sql/sqlite/post_content_meta.sql b/admin/sql/sqlite/post_content_meta.sql
old mode 100644
new mode 100755
index d7c84ee..e049bb4
--- a/admin/sql/sqlite/post_content_meta.sql
+++ b/admin/sql/sqlite/post_content_meta.sql
@@ -50,7 +50,7 @@
)
BEGIN
- INSERT INTO post_content_meta
+ INSERT INTO post_content_meta
(post_id, language_id, namespace, `key`, value )
VALUES (:post_id, :language_id, :namespace, :key , :value )
diff --git a/admin/sql/sqlite/post_field_value.sql b/admin/sql/sqlite/post_field_value.sql
new file mode 100644
index 0000000..6d9d9eb
--- /dev/null
+++ b/admin/sql/sqlite/post_field_value.sql
@@ -0,0 +1,159 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN post_id INT,
+ IN subtype CHAR,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT post_field_value.*, field.settings, field.field_id as array_key
+ FROM post_field_value
+ LEFT JOIN field ON (field.field_id = post_field_value.field_id)
+ @IF !empty(:subtype)
+ THEN
+ -- INNER JOIN field_group ON (field.field_group_id = field_group.field_group_id AND field_group.subtype = :subtype)
+ END @IF
+
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND post_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND post_field_value.post_id = :post_id
+ END @IF
+
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN post_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM post_field_value as _
+ INNER JOIN field ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND post_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND post_field_value.field_id = :field_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND post_field_value.post_id = :post_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN post_field_value ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :post_field_value = @FILTER(:post_field_value, post_field_value)
+
+ INSERT INTO post_field_value
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN post_field_value ARRAY,
+ IN post_field_value_id INT,
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :post_field_value = @FILTER(:post_field_value, post_field_value)
+
+ UPDATE post_field_value
+
+ SET @LIST(:post_field_value)
+
+ WHERE field_id = :field_id AND post_id = :post_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- post_field_value_id
+ DELETE FROM post_field_value WHERE
+
+ @IF !empty(:language_id)
+ THEN
+ AND post_field_value.language_id IN (:language_id)
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND post_field_value.field_id IN (:field_id)
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND post_field_value.post_id IN (:post_id)
+ END @IF
+ END
diff --git a/admin/sql/sqlite/product.sql b/admin/sql/sqlite/product.sql
index e00cbbb..65470d8 100755
--- a/admin/sql/sqlite/product.sql
+++ b/admin/sql/sqlite/product.sql
@@ -1019,7 +1019,13 @@
LEFT JOIN admin ad ON (product.admin_id = ad.admin_id)
END @IF
- WHERE p2s.site_id = :site_id
+ WHERE 1 = 1
+
+ -- site_id
+ @IF isset(:site_id) && !empty(:site_id)
+ THEN
+ AND p2s.site_id = :site_id
+ END @IF
-- search
@IF isset(:search) && !empty(:search)
diff --git a/admin/sql/sqlite/product_field_value.sql b/admin/sql/sqlite/product_field_value.sql
new file mode 100644
index 0000000..5cca227
--- /dev/null
+++ b/admin/sql/sqlite/product_field_value.sql
@@ -0,0 +1,157 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN product_id INT,
+ IN subtype CHAR,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT product_field_value.*, field.settings, field.field_id as array_key
+ FROM product_field_value
+ LEFT JOIN field ON (field.field_id = product_field_value.field_id)
+ @IF !empty(:subtype)
+ THEN
+ -- INNER JOIN field_group ON (field.field_group_id = field_group.field_group_id AND field_group.subtype = :subtype)
+ END @IF
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND product_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:product_id)
+ THEN
+ AND product_field_value.product_id = :product_id
+ END @IF
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN product_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM product_field_value as _
+ INNER JOIN field ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND product_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND product_field_value.field_id = :field_id
+ END @IF
+
+ @IF !empty(:product_id)
+ THEN
+ AND product_field_value.product_id = :product_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN product_field_value ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :product_field_value = @FILTER(:product_field_value, product_field_value)
+
+ INSERT INTO product_field_value
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN product_field_value ARRAY,
+ IN product_field_value_id INT,
+ IN product_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :product_field_value = @FILTER(:product_field_value, product_field_value)
+
+ UPDATE product_field_value
+
+ SET @LIST(:product_field_value)
+
+ WHERE field_id = :field_id AND product_id = :product_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN product_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- product_field_value_id
+ DELETE FROM product_field_value WHERE
+
+ @IF !empty(:language_id)
+ THEN
+ AND product_field_value.language_id IN (:language_id)
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND product_field_value.field_id IN (:field_id)
+ END @IF
+
+ @IF !empty(:product_id)
+ THEN
+ AND product_field_value.post_id IN (:post_id)
+ END @IF
+ END
diff --git a/admin/sql/sqlite/product_option_value.sql b/admin/sql/sqlite/product_option_value.sql
old mode 100644
new mode 100755
index 457e7dc..37defd0
--- a/admin/sql/sqlite/product_option_value.sql
+++ b/admin/sql/sqlite/product_option_value.sql
@@ -14,7 +14,7 @@
)
BEGIN
-- product_option_value
- SELECT product_option_value.*,
+ SELECT product_option_value.*, product_option_value.quantity as stock_quantity,
option_value.image, ovc.name, oc.name as `option`,
product_option_value.product_option_value_id as array_key
FROM product_option_value
diff --git a/admin/sql/sqlite/site.sql b/admin/sql/sqlite/site.sql
index 3b9375a..152fcf5 100755
--- a/admin/sql/sqlite/site.sql
+++ b/admin/sql/sqlite/site.sql
@@ -20,7 +20,7 @@
WHERE 1 = 1
-- site_id
- @IF isset(:site_id) && !empty(:site_id)
+ @IF isset(:site_id) && !empty(:site_id) && is_array(:site_id)
THEN
AND site.site_id IN (:site_id)
END @IF
diff --git a/admin/sql/sqlite/taxonomy_item_field_value.sql b/admin/sql/sqlite/taxonomy_item_field_value.sql
new file mode 100644
index 0000000..dc954cc
--- /dev/null
+++ b/admin/sql/sqlite/taxonomy_item_field_value.sql
@@ -0,0 +1,152 @@
+-- Fields
+
+ -- get all fields
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN post_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ -- field
+ SELECT taxonomy_item_field_value.*, field.settings, field.field_id as array_key
+ FROM taxonomy_item_field_value
+ LEFT JOIN field ON (field.field_id = taxonomy_item_field_value.field_id)
+
+ WHERE 1 = 1
+
+ @IF !empty(:field_group_id)
+ THEN
+ AND field.field_group_id = :field_group_id
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND taxonomy_item_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND taxonomy_item_field_value.post_id = :post_id
+ END @IF
+
+ ORDER BY field.sort_order
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(field.field_id, field) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get field
+
+ PROCEDURE get(
+ IN field_id INT,
+ IN post_id INT,
+ IN language_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- field
+ SELECT *
+ FROM taxonomy_item_field_value as _
+ INNER JOIN field ON field_content.field_id = _.field_id
+ WHERE _.field_id = :field_id
+
+ @IF !empty(:language_id)
+ THEN
+ AND taxonomy_item_field_value.language_id = :language_id
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND taxonomy_item_field_value.field_id = :field_id
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND taxonomy_item_field_value.post_id = :post_id
+ END @IF
+
+ ;
+ END
+
+ -- add field
+
+ PROCEDURE add(
+ IN taxonomy_item_field_value ARRAY,
+ IN language_id INT,
+ OUT insert_id,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :taxonomy_item_field_value = @FILTER(:taxonomy_item_field_value, taxonomy_item_field_value)
+
+ INSERT INTO taxonomy_item_field_value
+
+ ( @KEYS(:field_data) )
+
+ VALUES ( :field_data);
+
+ END
+
+ -- edit field
+ CREATE PROCEDURE edit(
+ IN taxonomy_item_field_value ARRAY,
+ IN taxonomy_item_field_value_id INT,
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :taxonomy_item_field_value = @FILTER(:taxonomy_item_field_value, taxonomy_item_field_value)
+
+ UPDATE taxonomy_item_field_value
+
+ SET @LIST(:taxonomy_item_field_value)
+
+ WHERE field_id = :field_id AND post_id = :post_id AND language_id = :language_id;
+
+
+ END
+
+ -- delete field
+
+ PROCEDURE delete(
+ IN post_id INT,
+ IN field_id INT,
+ IN language_id INT,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- taxonomy_item_field_value_id
+ DELETE FROM taxonomy_item_field_value WHERE
+
+ @IF !empty(:language_id)
+ THEN
+ AND taxonomy_item_field_value.language_id IN (:language_id)
+ END @IF
+
+ @IF !empty(:field_id)
+ THEN
+ AND taxonomy_item_field_value.field_id IN (:field_id)
+ END @IF
+
+ @IF !empty(:post_id)
+ THEN
+ AND taxonomy_item_field_value.post_id IN (:post_id)
+ END @IF
+ END
diff --git a/admin/template/content/edit.tpl b/admin/template/content/edit.tpl
old mode 100644
new mode 100755
index e4d6409..38fb16a
--- a/admin/template/content/edit.tpl
+++ b/admin/template/content/edit.tpl
@@ -163,4 +163,6 @@ foreach ($revisions as $revision) {
import(content/sites.tpl)
+import(content/fields.tpl)
+
import(content/post_taxonomy.tpl)
diff --git a/admin/template/field/field-group.tpl b/admin/template/field/field-group.tpl
old mode 100644
new mode 100755
index 5d17f2f..58251e2
--- a/admin/template/field/field-group.tpl
+++ b/admin/template/field/field-group.tpl
@@ -1,2 +1,138 @@
import(crud.tpl, {"type":"field_group"})
+@field = [data-v-fields] [data-v-row] [data-v-field]
+@row = [data-v-fields] [data-v-row]
+@row|deleteAllButFirstChild
+@field|deleteAllButFirstChild
+
+
+@row|before = <?php
+
+$close = false;
+$row = -1;
+$count = $this->count;
+$index = 1;
+$field = [];
+$newRow = true;
+$rowIndex = 0;
+$fields = $this->fields ?? [];
+if(isset($fields) && is_array($fields)) {
+ foreach ($fields as $field_index => $field) {
+
+ if ($row != $field['row']) {
+ if ($row > -1) echo '</div>';
+ ?>
+
+ @row|prepend = <?php
+ $row = $field['row'];
+ } ?>
+
+ @field|class = <?php echo 'col ' . ($field['cols'] ?? '');?>
+ @row|addNewAttribute = <?php echo "data-index=" . $rowIndex++;?>
+
+ @field .input = <?php echo $field['field'];?>
+ @field [data-v-field-settings] = <?php echo $field['settings-tab'];?>
+ @field [data-v-field-validation] = <?php echo $field['validation-tab'];?>
+ @field [data-v-field-presentation] = <?php echo $field['presentation-tab'];?>
+
+ @field [data-v-field-*]|innerText = $field['@@__data-v-field-(*)__@@']
+ @field input[data-v-field-*]|value = $field['@@__data-v-field-(*)__@@']
+ @field input[data-v-field-*]|value = $field['@@__data-v-field-(*)__@@']
+ @field a[data-v-field-*]|href = $field['@@__data-v-field-(*)__@@']
+ @field select option|addNewAttribute = <?php if (isset($field['value']) && $field['value'] == '@@__value__@@') echo 'selected';?>
+
+ @field [data-v-field-*]|name = <?php echo "field[$field_index][@@__data-v-field-(*)__@@]";?>
+ @field [data-v-field-*]|data-v-field-id = $field['field_id']
+ @field|data-id = $field['field_id']
+
+ // close row tag if last field or different row
+ @row|append = <?php
+ if ($index >= $count) {
+ ?>
+ @row|after = <?php
+ }
+ $index++;
+ }
+}?>
+
+
+/* add type dropdown list */
+
+@select = .field-types
+@group = .field-types ul
+@option = .field-types ul li.field
+@@group|deleteAllButFirstChild
+@option|deleteAllButFirstChild
+
+@group|before = <?php
+$groupType = $this->field_group['type'] ?? 'post';
+$groupSubtype = $this->field_group['subtype'] ?? '';
+if(isset($this->fieldTypes) && is_array($this->fieldTypes)) {
+ foreach ($this->fieldTypes as $group => $fields) { $group = ucfirst($group);?>
+
+ @group h6 = $group
+
+ @option|before = <?php
+ foreach ($fields as $type => $value) { ?>
+
+ @option span = $value['name']
+ @option a|data-type = $type
+ @option i|class = $value['icon']
+
+ @option|after = <?php
+ }
+ ?>
+
+ @group|after = <?php
+ $count++;
+ }
+}?>
+
+/* field type select */
+
+@optgroup = [data-v-field-type] optgroup
+@option = [data-v-field-type] option
+
+@optgroup|deleteAllButFirstChild
+@option|deleteAllButFirstChild
+
+@optgroup|before = <?php
+if(isset($this->fieldTypes) && is_array($this->fieldTypes)) {
+ foreach ($this->fieldTypes as $group => $fields) { $group = ucfirst($group);?>
+
+ @optgroup|label = $group
+
+ @option|before = <?php
+ foreach ($fields as $type => $value) { ?>
+
+ @option|value = $type
+ @option = $value['name']
+
+ @option|after = <?php
+ }
+ ?>
+
+@optgroup|after = <?php }
+ }
+?>
+
+
+/* post types */
+[data-v-field_group-type] option|addNewAttribute = <?php if('@@__value__@@' == $groupType) echo 'selected';?>
+
+[data-post-subtype]|before = <?php $subtype = '@@__data-post-subtype__@@';?>
+
+@select = [data-v-field_group-subtype]
+@option = [data-v-field_group-subtype] [data-option]
+@option|deleteAllButFirstChild
+
+@option|before = <?php
+ $postTypes = $subtype . 'Types';
+ $options = $this->$postTypes ?? [];
+ foreach ($options as $option) {?>
+
+ @option|value = $option['type']
+ @option = $option['name']
+ @option|addNewAttribute = <?php if($option['type'] == $groupSubtype) echo 'selected';?>
+
+@option|after = <?php } ?>
\ No newline at end of file
diff --git a/app/sql/mysqli/product.sql b/app/sql/mysqli/product.sql
old mode 100755
new mode 100644
index c160196..62ff9d3
--- a/app/sql/mysqli/product.sql
+++ b/app/sql/mysqli/product.sql
@@ -13,7 +13,7 @@
)
BEGIN
- SELECT product.*, _.product_id,_.slug,_.name,_.meta_keywords,_.meta_description,_.language_id,product.template,language.code,language.code as array_key
+ SELECT product.*, _.product_id,_.slug,_.name,_.content,_.meta_keywords,_.meta_description,_.language_id,product.template,language.code,language.slug,language.slug as array_key
FROM product_content AS _
LEFT JOIN language ON (language.language_id = _.language_id)
LEFT JOIN product ON (product.product_id = _.product_id)
diff --git a/app/sql/pgsql/product.sql b/app/sql/pgsql/product.sql
old mode 100755
new mode 100644
index c160196..62ff9d3
--- a/app/sql/pgsql/product.sql
+++ b/app/sql/pgsql/product.sql
@@ -13,7 +13,7 @@
)
BEGIN
- SELECT product.*, _.product_id,_.slug,_.name,_.meta_keywords,_.meta_description,_.language_id,product.template,language.code,language.code as array_key
+ SELECT product.*, _.product_id,_.slug,_.name,_.content,_.meta_keywords,_.meta_description,_.language_id,product.template,language.code,language.slug,language.slug as array_key
FROM product_content AS _
LEFT JOIN language ON (language.language_id = _.language_id)
LEFT JOIN product ON (product.product_id = _.product_id)
diff --git a/app/sql/sqlite/product.sql b/app/sql/sqlite/product.sql
old mode 100755
new mode 100644
index e539ed5..62ff9d3
--- a/app/sql/sqlite/product.sql
+++ b/app/sql/sqlite/product.sql
@@ -13,14 +13,14 @@
)
BEGIN
- SELECT product.*, _.product_id,_.slug,_.name,_.meta_keywords,_.meta_description,_.language_id,product.template,language.code,language.code as array_key
+ SELECT product.*, _.product_id,_.slug,_.name,_.content,_.meta_keywords,_.meta_description,_.language_id,product.template,language.code,language.slug,language.slug as array_key
FROM product_content AS _
LEFT JOIN language ON (language.language_id = _.language_id)
LEFT JOIN product ON (product.product_id = _.product_id)
WHERE 1 = 1
@IF isset(:status)
- THEN
+ THEN
AND product.status = :status
END @IF
diff --git a/app/template/components.tpl b/app/template/components.tpl
index c87b6f5..7029562 100755
--- a/app/template/components.tpl
+++ b/app/template/components.tpl
@@ -14,6 +14,7 @@ import(components/search.tpl, [data-v-component-search])
import(components/product_gallery.tpl, [data-v-component-product-gallery])
import(components/user.tpl, [data-v-component-user])
import(components/admin.tpl, [data-v-component-admin])
+import(components/admins.tpl, [data-v-component-admin])
import(components/checkout.tpl, [data-v-component-checkout])
import(components/manufacturers.tpl, [data-v-component-manufacturers])
import(components/breadcrumb.tpl, [data-v-component-breadcrumb])
@@ -36,3 +37,4 @@ import(components/checkout/shipping.tpl, [data-v-component-checkout-shipping])
import(components/digital_assets.tpl, [data-v-component-digital_assets])
import(components/user/wishlist.tpl, [data-v-component-user-wishlist])
import(components/site.tpl, [data-v-component-site])
+import(components/fields.tpl, [data-v-component-fields])
diff --git a/app/template/components/fields.tpl b/app/template/components/fields.tpl
new file mode 100644
index 0000000..9949552
--- /dev/null
+++ b/app/template/components/fields.tpl
@@ -0,0 +1,74 @@
+@fields = [data-v-component-fields]
+@field = [data-v-component-fields] [data-v-field]
+@subfields = [data-v-component-fields] [data-v-field] [data-v-subfields]
+@subfield = [data-v-component-fields] [data-v-field] [data-v-subfields] [data-v-subfields-field]
+
+@field|deleteAllButFirstChild
+
+@fields|prepend = <?php
+$vvveb_is_page_edit = Vvveb\isEditor();
+if (isset($_fields_idx)) $_fields_idx++; else $_fields_idx = 0;
+$previous_component = isset($current_component)?$current_component:null;
+$fields = $current_component = $this->_component['fields'][$_fields_idx] ?? [];
+
+$_pagination_count = $fields['count'] ?? 0;
+$_pagination_limit = isset($fields['limit']) ? $fields['limit'] : 5;
+?>
+
+
+@field|before = <?php
+$_default = (isset($vvveb_is_page_edit) && $vvveb_is_page_edit ) ? [0 => []] : false;
+$fields['field'] = empty($fields['field']) ? $_default : $fields['field'];
+
+if($fields && is_array($fields['field'])) {
+ foreach ($fields['field'] as $field_id => $field) {
+ if (!isset($field['value'])) continue;
+ $is_array = is_array($field['value']);
+ $hasType = false;
+ ?>
+
+ //@field|data-field_id = $field['field_id']
+ //@field|id = <?php echo 'field-' . $field['field_id'];?>
+
+ @field|addClass = <?php echo 'field-' . $field['field_id'];?>
+
+ @field img[data-v-field-*]|src = $field['@@__data-v-field-(*)__@@']
+
+ @field [data-v-field-*]|innerText = $field['@@__data-v-field-(*)__@@']
+
+ @field a[data-v-field-*]|href = $field['@@__data-v-field-(*)__@@']
+
+ @field input[data-v-field-field_id]|addNewAttribute = <?php
+ if (isset($field['active']) && $field['active']) {
+ echo 'checked';
+ }
+ ?>
+
+ @subfield|before = <?php
+ if (isset($vvveb_is_page_edit) && $vvveb_is_page_edit) { $is_array = true;$field['value'] = ['' => ''];}
+ if ($is_array) foreach ($field['value'] as $subfield => $value) {?>
+
+ @subfield [data-v-subfields-field-*] = $subfield['@@__data-v-subfields-field-(*)__@@']
+ @subfield [data-v-subfields-field-value] = $value
+ @subfield [data-v-subfields-field-name] = $subfield
+
+ @subfield|after = <?php
+ }
+ ?>
+
+
+ @field [data-v-type-*]|before = <?php
+ $type = '@@__data-v-type-(*)__@@';
+ if (($type == $field['type']) || ($type == 'default' && !$hasType)) {
+ $hasType = true;
+ ?>
+
+ @field [data-v-type-*]|after = <?php
+ }
+ ?>
+
+
+ @field|after = <?php
+ }
+}
+?>
diff --git a/install/sql/mysqli/schema/fields/field.sql b/install/sql/mysqli/schema/fields/field.sql
index 519fba7..195e656 100755
--- a/install/sql/mysqli/schema/fields/field.sql
+++ b/install/sql/mysqli/schema/fields/field.sql
@@ -4,8 +4,13 @@ CREATE TABLE `field` (
`field_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`field_group_id` int NOT NULL,
`type` varchar(32) NOT NULL,
- `value` text NOT NULL,
- `status` tinyint NOT NULL DEFAULT 0,
+ `default` varchar(192) NOT NULL DEFAULT '',
+ `settings` text NOT NULL,
+ `validation` text NOT NULL,
+ `presentation` text NOT NULL,
+ `conditionals` text NOT NULL,
+ `row` int NOT NULL DEFAULT 0,
+ `status` tinyint NOT NULL DEFAULT 1,
`sort_order` int NOT NULL DEFAULT 0,
PRIMARY KEY (`field_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/mysqli/schema/fields/field_content.sql b/install/sql/mysqli/schema/fields/field_content.sql
index cc8d6d0..66a62e2 100755
--- a/install/sql/mysqli/schema/fields/field_content.sql
+++ b/install/sql/mysqli/schema/fields/field_content.sql
@@ -4,5 +4,6 @@ CREATE TABLE `field_content` (
`field_id` int NOT NULL,
`language_id` int NOT NULL,
`name` varchar(128) NOT NULL,
+ `label` varchar(128) NOT NULL,
PRIMARY KEY (`field_id`,`language_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/mysqli/schema/fields/field_group.sql b/install/sql/mysqli/schema/fields/field_group.sql
index ea721a5..d9b04a6 100755
--- a/install/sql/mysqli/schema/fields/field_group.sql
+++ b/install/sql/mysqli/schema/fields/field_group.sql
@@ -2,7 +2,9 @@ DROP TABLE IF EXISTS `field_group`;
CREATE TABLE `field_group` (
`field_group_id` int NOT NULL AUTO_INCREMENT,
- `type` varchar(128) NOT NULL DEFAULT 'post', -- post, product, user, taxonomy item
+ `type` varchar(128) NOT NULL DEFAULT 'post',
+ `subtype` varchar(128) NOT NULL DEFAULT 'page',
+ `conditions` text,
`status` tinyint NOT NULL,
`sort_order` int NOT NULL NOT NULL DEFAULT 0,
PRIMARY KEY (`field_group_id`)
diff --git a/install/sql/mysqli/schema/fields/field_group_content.sql b/install/sql/mysqli/schema/fields/field_group_content.sql
index 4447760..b5a52f5 100755
--- a/install/sql/mysqli/schema/fields/field_group_content.sql
+++ b/install/sql/mysqli/schema/fields/field_group_content.sql
@@ -4,5 +4,7 @@ CREATE TABLE `field_group_content` (
`field_group_id` int NOT NULL,
`language_id` int NOT NULL,
`name` varchar(128) NOT NULL,
+ `slug` varchar(191) NOT NULL COMMENT 'The slug for post language',
+ `content` longtext NOT NULL COMMENT 'The content for post language',
PRIMARY KEY (`field_group_id`,`language_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/mysqli/schema/fields/field_value_content.sql b/install/sql/mysqli/schema/fields/field_value_content.sql
index 9312157..8119d85 100755
--- a/install/sql/mysqli/schema/fields/field_value_content.sql
+++ b/install/sql/mysqli/schema/fields/field_value_content.sql
@@ -5,5 +5,18 @@ CREATE TABLE `field_value_content` (
`language_id` int(10) UNSIGNED NOT NULL,
`field_id` int(10) UNSIGNED NOT NULL,
`name` varchar(128) NOT NULL,
+ `content` longtext NOT NULL,
PRIMARY KEY (`field_value_id`,`language_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
+
+
+DROP TABLE IF EXISTS `post_field_value_content`;
+
+CREATE TABLE `post_field_value_content` (
+ `post_field_value_id` int(10) UNSIGNED NOT NULL,
+ `language_id` int(10) UNSIGNED NOT NULL,
+ `field_id` int(10) UNSIGNED NOT NULL,
+ `name` varchar(128) NOT NULL,
+ `content` longtext NOT NULL,
+ PRIMARY KEY (`post_field_value_id`,`language_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/mysqli/schema/fields/order_field_value.sql b/install/sql/mysqli/schema/fields/order_field_value.sql
new file mode 100644
index 0000000..8ca1d38
--- /dev/null
+++ b/install/sql/mysqli/schema/fields/order_field_value.sql
@@ -0,0 +1,10 @@
+DROP TABLE IF EXISTS `order_field_value`;
+
+CREATE TABLE `order_field_value` (
+ `order_field_value_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `language_id` int(10) UNSIGNED NOT NULL,
+ `order_id` INT unsigned NOT NULL,
+ `field_id` int(10) UNSIGNED NOT NULL,
+ `sort_order` int(3) NOT NULL DEFAULT 0,
+ PRIMARY KEY (`order_field_value_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/mysqli/schema/fields/post_field_value.sql b/install/sql/mysqli/schema/fields/post_field_value.sql
new file mode 100644
index 0000000..e8a37c6
--- /dev/null
+++ b/install/sql/mysqli/schema/fields/post_field_value.sql
@@ -0,0 +1,9 @@
+DROP TABLE IF EXISTS `post_field_value`;
+
+CREATE TABLE `post_field_value` (
+ `post_id` INT unsigned NOT NULL,
+ `field_id` int(10) UNSIGNED NOT NULL,
+ `language_id` int(10) UNSIGNED NOT NULL,
+ `value` text NOT NULL,
+ PRIMARY KEY (`post_id`, `field_id`, `language_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/mysqli/schema/fields/product_field_value.sql b/install/sql/mysqli/schema/fields/product_field_value.sql
new file mode 100644
index 0000000..ac6d113
--- /dev/null
+++ b/install/sql/mysqli/schema/fields/product_field_value.sql
@@ -0,0 +1,10 @@
+DROP TABLE IF EXISTS `product_field_value`;
+
+CREATE TABLE `product_field_value` (
+ `product_field_value_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `field_id` int(10) UNSIGNED NOT NULL,
+ `product_id` INT unsigned NOT NULL,
+ `language_id` int(10) UNSIGNED NOT NULL,
+ `value` text NOT NULL,
+ PRIMARY KEY (`product_field_value_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/mysqli/schema/fields/taxonomy_item_field_value.sql b/install/sql/mysqli/schema/fields/taxonomy_item_field_value.sql
new file mode 100644
index 0000000..c739086
--- /dev/null
+++ b/install/sql/mysqli/schema/fields/taxonomy_item_field_value.sql
@@ -0,0 +1,10 @@
+DROP TABLE IF EXISTS `taxonomy_item_field_value`;
+
+CREATE TABLE `taxonomy_item_field_value` (
+ `taxonomy_item_field_value_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `language_id` int(10) UNSIGNED NOT NULL,
+ `taxonomy_item_id` INT unsigned NOT NULL,
+ `field_id` int(10) UNSIGNED NOT NULL,
+ `sort_order` int(3) NOT NULL DEFAULT 0,
+ PRIMARY KEY (`taxonomy_item_field_value_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/mysqli/schema/fields/user_field_value.sql b/install/sql/mysqli/schema/fields/user_field_value.sql
new file mode 100644
index 0000000..a2ec3de
--- /dev/null
+++ b/install/sql/mysqli/schema/fields/user_field_value.sql
@@ -0,0 +1,10 @@
+DROP TABLE IF EXISTS `user_field_value`;
+
+CREATE TABLE `user_field_value` (
+ `user_field_value_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `language_id` int(10) UNSIGNED NOT NULL,
+ `user_id` INT unsigned NOT NULL,
+ `field_id` int(10) UNSIGNED NOT NULL,
+ `sort_order` int(3) NOT NULL DEFAULT 0,
+ PRIMARY KEY (`user_field_value_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/pgsql/schema/fields/field.sql b/install/sql/pgsql/schema/fields/field.sql
index fed8360..3b2fadb 100755
--- a/install/sql/pgsql/schema/fields/field.sql
+++ b/install/sql/pgsql/schema/fields/field.sql
@@ -1,16 +1,22 @@
DROP TABLE IF EXISTS field;
-DROP SEQUENCE IF EXISTS field_seq;
-CREATE SEQUENCE field_seq;
--- SELECT setval('field_seq', 0, true); -- last inserted id by sample data
+-- DROP SEQUENCE IF EXISTS field_seq;
+-- CREATE SEQUENCE field_seq;
CREATE TABLE field (
- "field_id" int NOT NULL DEFAULT NEXTVAL ('field_seq'),
+ "field_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY,
"field_group_id" int NOT NULL,
"type" varchar(32) NOT NULL,
- "value" text NOT NULL,
- "status" smallint NOT NULL,
- "sort_order" int NOT NULL DEFAULT 0,
- PRIMARY KEY ("field_id")
+ "default" text NOT NULL,
+ "settings" text NOT NULL,
+ "validation" text NOT NULL,
+ "presentation" text NOT NULL,
+ "conditionals" text NOT NULL,
+ "row" int NOT NULL DEFAULT 0,
+ "status" smallint NOT NULL DEFAULT 1,
+ "sort_order" int NOT NULL DEFAULT 0
+ -- PRIMARY KEY("field_id")
);
+
+-- SELECT setval('field_field_id_seq', 0, true); -- last inserted id by sample data
diff --git a/install/sql/pgsql/schema/fields/field_content.sql b/install/sql/pgsql/schema/fields/field_content.sql
index 9c8030a..aa0b3b0 100755
--- a/install/sql/pgsql/schema/fields/field_content.sql
+++ b/install/sql/pgsql/schema/fields/field_content.sql
@@ -4,5 +4,5 @@ CREATE TABLE field_content (
"field_id" int NOT NULL,
"language_id" int NOT NULL,
"name" varchar(128) NOT NULL,
- PRIMARY KEY ("field_id","language_id")
+ PRIMARY KEY("field_id","language_id")
);
diff --git a/install/sql/pgsql/schema/fields/field_group.sql b/install/sql/pgsql/schema/fields/field_group.sql
index 94e72cc..3b19aaf 100755
--- a/install/sql/pgsql/schema/fields/field_group.sql
+++ b/install/sql/pgsql/schema/fields/field_group.sql
@@ -1,14 +1,16 @@
DROP TABLE IF EXISTS field_group;
-DROP SEQUENCE IF EXISTS field_group_seq;
-CREATE SEQUENCE field_group_seq;
--- SELECT setval('field_group_seq', 0, true); -- last inserted id by sample data
+-- DROP SEQUENCE IF EXISTS field_group_field_group_id_seq;
+-- CREATE SEQUENCE field_group_field_group_id_seq;
CREATE TABLE field_group (
- "field_group_id" int NOT NULL DEFAULT NEXTVAL ('field_group_seq'),
+ "field_group_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY,
"type" varchar(128) NOT NULL DEFAULT 'post', -- post, product, user, taxonomy item
+ "subtype" varchar(128) NOT NULL DEFAULT 'post', -- post, page, product
"status" smallint NOT NULL DEFAULT 1,
- "sort_order" int NOT NULL DEFAULT 0,
- PRIMARY KEY ("field_group_id")
+ "sort_order" int NOT NULL DEFAULT 0
+ -- PRIMARY KEY("field_group_id")
);
+
+-- SELECT setval('field_group_field_group_id_seq', 0, true); -- last inserted id by sample data
diff --git a/install/sql/pgsql/schema/fields/field_group_content.sql b/install/sql/pgsql/schema/fields/field_group_content.sql
index 84fb7b0..9bd5f54 100755
--- a/install/sql/pgsql/schema/fields/field_group_content.sql
+++ b/install/sql/pgsql/schema/fields/field_group_content.sql
@@ -4,5 +4,7 @@ CREATE TABLE field_group_content (
"field_group_id" int NOT NULL,
"language_id" int NOT NULL,
"name" varchar(128) NOT NULL,
- PRIMARY KEY ("field_group_id","language_id")
-);
+ "slug" varchar(191) NOT NULL,
+ "content" text NOT NULL,
+ PRIMARY KEY("field_group_id","language_id")
+);
\ No newline at end of file
diff --git a/install/sql/pgsql/schema/fields/field_value.sql b/install/sql/pgsql/schema/fields/field_value.sql
index 04b1d87..1bdf536 100755
--- a/install/sql/pgsql/schema/fields/field_value.sql
+++ b/install/sql/pgsql/schema/fields/field_value.sql
@@ -1,13 +1,14 @@
DROP TABLE IF EXISTS field_value;
-DROP SEQUENCE IF EXISTS field_value_seq;
-CREATE SEQUENCE field_value_seq;
--- SELECT setval('field_value_seq', 0, true); -- last inserted id by sample data
+-- DROP SEQUENCE IF EXISTS field_value_field_value_id_seq;
+-- CREATE SEQUENCE field_value_field_value_id_seq;
CREATE TABLE field_value (
- "field_value_id" int NOT NULL DEFAULT NEXTVAL ('field_value_seq'),
+ "field_value_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY,
"field_id" int NOT NULL,
- "sort_order" int NOT NULL DEFAULT 0,
- PRIMARY KEY ("field_value_id")
+ "sort_order" int NOT NULL DEFAULT 0
+ -- PRIMARY KEY("field_value_id")
);
+
+-- SELECT setval('field_value_field_value_id_seq', 0, true); -- last inserted id by sample data
diff --git a/install/sql/pgsql/schema/fields/field_value_content.sql b/install/sql/pgsql/schema/fields/field_value_content.sql
index 5f9e46d..c7e2f19 100755
--- a/install/sql/pgsql/schema/fields/field_value_content.sql
+++ b/install/sql/pgsql/schema/fields/field_value_content.sql
@@ -5,5 +5,6 @@ CREATE TABLE field_value_content (
"language_id" int NOT NULL,
"field_id" int NOT NULL,
"name" varchar(128) NOT NULL,
- PRIMARY KEY ("field_value_id","language_id")
+ "content" text NOT NULL,
+ PRIMARY KEY("field_value_id","language_id")
);
diff --git a/install/sql/pgsql/schema/fields/order_field_value.sql b/install/sql/pgsql/schema/fields/order_field_value.sql
new file mode 100644
index 0000000..4956362
--- /dev/null
+++ b/install/sql/pgsql/schema/fields/order_field_value.sql
@@ -0,0 +1,14 @@
+DROP TABLE IF EXISTS order_field_value;
+
+-- DROP SEQUENCE IF EXISTS order_field_value_field_value_id_seq;
+-- CREATE SEQUENCE order_field_value_field_value_id_seq;
+
+
+CREATE TABLE order_field_value (
+ "order_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY,
+ "field_id" int NOT NULL,
+ "sort_order" int NOT NULL DEFAULT 0
+ -- PRIMARY KEY("field_value_id")
+);
+
+-- SELECT setval('order_field_value_field_value_id_seq', 0, true); -- last inserted id by sample data
diff --git a/install/sql/pgsql/schema/fields/post_field_value.sql b/install/sql/pgsql/schema/fields/post_field_value.sql
new file mode 100644
index 0000000..1a98790
--- /dev/null
+++ b/install/sql/pgsql/schema/fields/post_field_value.sql
@@ -0,0 +1,15 @@
+DROP TABLE IF EXISTS post_field_value;
+
+-- DROP SEQUENCE IF EXISTS post_field_value_field_value_id_seq;
+-- CREATE SEQUENCE post_field_value_field_value_id_seq;
+
+
+CREATE TABLE post_field_value (
+ "post_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY,
+ "field_id" int NOT NULL,
+ "language_id" INT NOT NULL,
+ "value" TEXT NOT NULL
+ -- PRIMARY KEY("field_value_id")
+);
+
+-- SELECT setval('post_field_value_field_value_id_seq', 0, true); -- last inserted id by sample data
diff --git a/install/sql/pgsql/schema/fields/product_field_value.sql b/install/sql/pgsql/schema/fields/product_field_value.sql
new file mode 100644
index 0000000..084a6b6
--- /dev/null
+++ b/install/sql/pgsql/schema/fields/product_field_value.sql
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS product_field_value;
+
+-- DROP SEQUENCE IF EXISTS product_field_value_field_value_id_seq;
+-- CREATE SEQUENCE product_field_value_field_value_id_seq;
+
+
+CREATE TABLE product_field_value (
+ "product_field_value_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY,
+ "field_id" int NOT NULL,
+ "product_id" int NOT NULL,
+ "language_id" int NOT NULL,
+ "value" TEXT NOT NULL
+ -- PRIMARY KEY("field_value_id")
+);
+
+-- SELECT setval('product_field_value_field_value_id_seq', 0, true); -- last inserted id by sample data
diff --git a/install/sql/pgsql/schema/fields/taxonomy_item_field_value.sql b/install/sql/pgsql/schema/fields/taxonomy_item_field_value.sql
new file mode 100644
index 0000000..eccd220
--- /dev/null
+++ b/install/sql/pgsql/schema/fields/taxonomy_item_field_value.sql
@@ -0,0 +1,14 @@
+DROP TABLE IF EXISTS taxonomy_item_field_value;
+
+-- DROP SEQUENCE IF EXISTS taxonomy_item_field_value_field_value_id_seq;
+-- CREATE SEQUENCE taxonomy_item_field_value_field_value_id_seq;
+
+
+CREATE TABLE taxonomy_item_field_value (
+ "taxonomy_item_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY,
+ "field_id" int NOT NULL,
+ "sort_order" int NOT NULL DEFAULT 0
+ -- PRIMARY KEY("field_value_id")
+);
+
+-- SELECT setval('taxonomy_item_field_value_field_value_id_seq', 0, true); -- last inserted id by sample data
diff --git a/install/sql/pgsql/schema/fields/user_field_value.sql b/install/sql/pgsql/schema/fields/user_field_value.sql
new file mode 100644
index 0000000..a7073f3
--- /dev/null
+++ b/install/sql/pgsql/schema/fields/user_field_value.sql
@@ -0,0 +1,14 @@
+DROP TABLE IF EXISTS user_field_value;
+
+-- DROP SEQUENCE IF EXISTS user_field_value_field_value_id_seq;
+-- CREATE SEQUENCE user_field_value_field_value_id_seq;
+
+
+CREATE TABLE user_field_value (
+ "user_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY,
+ "field_id" int NOT NULL,
+ "sort_order" int NOT NULL DEFAULT 0
+ -- PRIMARY KEY("field_value_id")
+);
+
+-- SELECT setval('user_field_value_field_value_id_seq', 0, true); -- last inserted id by sample data
diff --git a/install/sql/sqlite/schema/fields/field.sql b/install/sql/sqlite/schema/fields/field.sql
index 3c6f205..f3dc15d 100755
--- a/install/sql/sqlite/schema/fields/field.sql
+++ b/install/sql/sqlite/schema/fields/field.sql
@@ -4,9 +4,14 @@ CREATE TABLE `field` (
`field_id` INTEGER PRIMARY KEY AUTOINCREMENT,
`field_group_id` INT NOT NULL,
`type` TEXT NOT NULL,
-`value` TEXT NOT NULL,
-`status` INT NOT NULL DEFAULT '0',
-`sort_order` INT NOT NULL DEFAULT '0'
+`default` TEXT NOT NULL,
+`settings` TEXT NOT NULL,
+`validation` TEXT NOT NULL,
+`presentation` TEXT NOT NULL,
+`conditionals` TEXT NOT NULL,
+`row` INT NOT NULL DEFAULT 0,
+`status` INT NOT NULL DEFAULT 1,
+`sort_order` INT NOT NULL DEFAULT 0
-- PRIMARY KEY (`field_id`)
);
diff --git a/install/sql/sqlite/schema/fields/field_group.sql b/install/sql/sqlite/schema/fields/field_group.sql
index 6c36444..db47db4 100755
--- a/install/sql/sqlite/schema/fields/field_group.sql
+++ b/install/sql/sqlite/schema/fields/field_group.sql
@@ -3,7 +3,8 @@ DROP TABLE IF EXISTS `field_group`;
CREATE TABLE `field_group` (
`field_group_id` INTEGER PRIMARY KEY AUTOINCREMENT,
`type` TEXT NOT NULL DEFAULT 'post',
+`subtype` TEXT NOT NULL DEFAULT 'post',
`status` INT NOT NULL DEFAULT 0,
`sort_order` INT NOT NULL NOT NULL DEFAULT 0
--PRIMARY KEY (`field_group_id`)
-);
\ No newline at end of file
+);
diff --git a/install/sql/sqlite/schema/fields/field_group_content.sql b/install/sql/sqlite/schema/fields/field_group_content.sql
index c16f697..97a0740 100755
--- a/install/sql/sqlite/schema/fields/field_group_content.sql
+++ b/install/sql/sqlite/schema/fields/field_group_content.sql
@@ -3,7 +3,9 @@ DROP TABLE IF EXISTS `field_group_content`;
CREATE TABLE `field_group_content` (
`field_group_id` INT NOT NULL,
`language_id` INT NOT NULL,
-`name` TEXT NOT NULL
+`name` TEXT NOT NULL,
+`slug` TEXT NOT NULL,
+`content` TEXT NOT NULL
--PRIMARY KEY (`field_group_id`,`language_id`)
);
diff --git a/install/sql/sqlite/schema/fields/field_value.sql b/install/sql/sqlite/schema/fields/field_value.sql
index a32b82c..38473f2 100755
--- a/install/sql/sqlite/schema/fields/field_value.sql
+++ b/install/sql/sqlite/schema/fields/field_value.sql
@@ -2,10 +2,9 @@ DROP TABLE IF EXISTS `field_value`;
CREATE TABLE `field_value` (
`field_id` INTEGER NOT NULL,
-`language_id` INT NOT NULL,
`value` TEXT NOT NULL,
`sort_order` INTEGER NOT NULL DEFAULT 0
-- PRIMARY KEY (`field_value_id`)
);
-CREATE INDEX `field_value_field_id_language_id` ON `field_value` (`field_id`,`language_id`);
\ No newline at end of file
+CREATE INDEX `field_value_field_id` ON `field_value` (`field_id`);
diff --git a/install/sql/sqlite/schema/fields/field_value_content.sql b/install/sql/sqlite/schema/fields/field_value_content.sql
index 857f965..8af51ab 100755
--- a/install/sql/sqlite/schema/fields/field_value_content.sql
+++ b/install/sql/sqlite/schema/fields/field_value_content.sql
@@ -1,10 +1,12 @@
DROP TABLE IF EXISTS `field_value_content`;
CREATE TABLE `field_value_content` (
+`field_value_id` INTEGER NOT NULL,
`field_id` INTEGER NOT NULL,
`language_id` INTEGER NOT NULL,
-`name` TEXT NOT NULL
+`name` TEXT NOT NULL,
+`content` longtext NOT NULL
-- PRIMARY KEY (`field_value_id`,`language_id`)
);
-CREATE INDEX `field_value_content_field_id_language_id` ON `field_value_content` (`field_id`,`language_id`);
\ No newline at end of file
+CREATE INDEX `field_value_content_field_id_language_id` ON `field_value_content` (`field_id`,`language_id`);
diff --git a/install/sql/sqlite/schema/fields/order_field_value.sql b/install/sql/sqlite/schema/fields/order_field_value.sql
new file mode 100644
index 0000000..b7d6339
--- /dev/null
+++ b/install/sql/sqlite/schema/fields/order_field_value.sql
@@ -0,0 +1,11 @@
+DROP TABLE IF EXISTS `order_field_value`;
+
+CREATE TABLE `order_field_value` (
+`order_id` INTEGER NOT NULL,
+`field_id` INTEGER NOT NULL,
+`language_id` INT NOT NULL,
+`value` TEXT NOT NULL
+-- PRIMARY KEY (`field_value_id`)
+);
+
+CREATE INDEX `order_field_valuefield_id_language_id` ON `order_field_value` (`order_id`,`field_id`,`language_id`);
diff --git a/install/sql/sqlite/schema/fields/post_field_value.sql b/install/sql/sqlite/schema/fields/post_field_value.sql
new file mode 100644
index 0000000..3f71747
--- /dev/null
+++ b/install/sql/sqlite/schema/fields/post_field_value.sql
@@ -0,0 +1,11 @@
+DROP TABLE IF EXISTS `post_field_value`;
+
+CREATE TABLE `post_field_value` (
+`post_id` INTEGER NOT NULL,
+`field_id` INTEGER NOT NULL,
+`language_id` INT NOT NULL,
+`value` TEXT NOT NULL
+-- PRIMARY KEY (`field_value_id`)
+);
+
+CREATE INDEX `post_field_valuefield_id_language_id` ON `post_field_value` (`post_id`,`field_id`,`language_id`);
diff --git a/install/sql/sqlite/schema/fields/product_field_value.sql b/install/sql/sqlite/schema/fields/product_field_value.sql
new file mode 100644
index 0000000..56d040e
--- /dev/null
+++ b/install/sql/sqlite/schema/fields/product_field_value.sql
@@ -0,0 +1,12 @@
+DROP TABLE IF EXISTS `product_field_value`;
+
+CREATE TABLE `product_field_value` (
+`product_field_value_id` INTEGER PRIMARY KEY AUTOINCREMENT,
+`field_id` INTEGER NOT NULL,
+`product_id` INTEGER NOT NULL,
+`language_id` INT NOT NULL,
+`value` TEXT NOT NULL
+-- PRIMARY KEY (`field_value_id`)
+);
+
+CREATE INDEX `product_field_valuefield_id_language_id` ON `product_field_value` (`product_id`,`field_id`,`language_id`);
diff --git a/install/sql/sqlite/schema/fields/taxonomy_item_field_value.sql b/install/sql/sqlite/schema/fields/taxonomy_item_field_value.sql
new file mode 100644
index 0000000..e77a03e
--- /dev/null
+++ b/install/sql/sqlite/schema/fields/taxonomy_item_field_value.sql
@@ -0,0 +1,11 @@
+DROP TABLE IF EXISTS `taxonomy_item_field_value`;
+
+CREATE TABLE `taxonomy_item_field_value` (
+`taxonomy_item_id` INTEGER NOT NULL,
+`field_id` INTEGER NOT NULL,
+`language_id` INT NOT NULL,
+`value` TEXT NOT NULL
+-- PRIMARY KEY (`field_value_id`)
+);
+
+CREATE INDEX `taxonomy_item_field_valuefield_id_language_id` ON `taxonomy_item_field_value` (`taxonomy_item_id`,`field_id`,`language_id`);
diff --git a/install/sql/sqlite/schema/fields/user_field_value.sql b/install/sql/sqlite/schema/fields/user_field_value.sql
new file mode 100644
index 0000000..c13a9e8
--- /dev/null
+++ b/install/sql/sqlite/schema/fields/user_field_value.sql
@@ -0,0 +1,11 @@
+DROP TABLE IF EXISTS `user_field_value`;
+
+CREATE TABLE `user_field_value` (
+`user_id` INTEGER NOT NULL,
+`field_id` INTEGER NOT NULL,
+`language_id` INT NOT NULL,
+`value` TEXT NOT NULL
+-- PRIMARY KEY (`field_value_id`)
+);
+
+CREATE INDEX `user_field_valuefield_id_language_id` ON `user_field_value` (`user_id`,`field_id`,`language_id`);
diff --git a/system/fields/accordion.php b/system/fields/accordion.php
new file mode 100755
index 0000000..b68160a
--- /dev/null
+++ b/system/fields/accordion.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Accordion extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/checkbox.php b/system/fields/checkbox.php
new file mode 100755
index 0000000..4fc9c36
--- /dev/null
+++ b/system/fields/checkbox.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Checkbox extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/color.php b/system/fields/color.php
new file mode 100755
index 0000000..5c1e181
--- /dev/null
+++ b/system/fields/color.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Color extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/date.php b/system/fields/date.php
new file mode 100755
index 0000000..3d168bc
--- /dev/null
+++ b/system/fields/date.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Date extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/date_time.php b/system/fields/date_time.php
new file mode 100755
index 0000000..47438a5
--- /dev/null
+++ b/system/fields/date_time.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Date_Time extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/email.php b/system/fields/email.php
new file mode 100755
index 0000000..0651b15
--- /dev/null
+++ b/system/fields/email.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Email extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/field.php b/system/fields/field.php
new file mode 100755
index 0000000..780fc42
--- /dev/null
+++ b/system/fields/field.php
@@ -0,0 +1,165 @@
+<?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\System\Fields;
+
+use function Vvveb\getFieldTypes;
+
+class Field {
+ const valueType = null; //single value, php array for complex json type
+
+ protected static $defaultSettings = [
+ 'field_id' => [
+ 'label' => 'Field id',
+ 'name' => 'field_id',
+ 'type' => 'hidden',
+ 'class' => 'field-label',
+ ],
+ 'row' => [
+ 'name' => 'row',
+ 'type' => 'hidden',
+ 'value' => 0,
+ ],
+ 'sort_order' => [
+ 'name' => 'sort_order',
+ 'type' => 'hidden',
+ 'value' => 0,
+ ],
+ 'parent_id' => [
+ 'name' => 'parent_id',
+ 'type' => 'hidden',
+ 'value' => 0,
+ ],
+ 'type' => [
+ 'label' => 'Type',
+ //'instructions' => '',
+ 'name' => 'type',
+ 'type' => 'optgroup', /*
+ 'options' => [
+ 'basic' => [
+ 'text' => 'Text',
+ 'textarea' => 'Text Area',
+ 'number' => 'Number',
+ 'range' => 'Range',
+ 'email' => 'Email',
+ 'url' => 'Url',
+ 'password' => 'Password',
+ ],
+ 'content' => [
+ 'image' => 'Image',
+ 'file' => 'File',
+ 'wysiwyg' => 'Wysiwyg Editor',
+ 'oembed' => 'oEmbed',
+ ],
+ ],*/
+ ],
+ 'label' => [
+ 'label' => 'Label',
+ 'instructions' => 'Name on edit page',
+ 'name' => 'label',
+ 'type' => 'text',
+ ],
+ 'name' => [
+ 'label' => 'Name',
+ 'instructions' => 'Input name',
+ 'name' => 'name',
+ 'type' => 'text',
+ ],
+ 'default' => [
+ 'label' => 'Default Value',
+ 'instructions' => 'Default value for new post',
+ 'type' => 'text',
+ 'name' => 'default',
+ ],
+ 'placeholder' => [
+ 'label' => 'Placeholder',
+ 'instructions' => '',
+ 'type' => 'text',
+ 'name' => 'placeholder',
+ ],
+ ];
+
+ protected static $defaultValidation = [
+ 'required' => [
+ 'label' => 'Required',
+ 'instructions' => '',
+ 'type' => 'checkbox',
+ 'name' => 'required',
+ 'class' => 'field-required',
+ 'value' => 'true',
+ ], /*
+ 'minimum' => 'number',
+ 'maximum' => 'number',*/
+ ];
+
+ protected static $defaultPresentation = [
+ 'cols' => [
+ 'label' => 'Columns',
+ 'type' => 'select',
+ 'name' => 'cols',
+ 'options' => ['' => 'auto', 'col-md-1' => '1', 'col-md-2' => '2', 'col-md-3' => '3', 'col-md-4' => '4', 'col-md-5' => '5', 'col-md-6' => '6', 'col-md-7' => '7', 'col-md-8' => '8', 'col-md-9' => '9', 'col-md-10' => '10', 'col-md-11' => '11', 'col-md-12' => '12'],
+ 'rows' => 5,
+ ],
+ 'instructions' => [
+ 'label' => 'Instructions',
+ 'instructions' => 'Instructions for content editors. Shown when submitting data.',
+ 'type' => 'textarea',
+ 'name' => 'instructions',
+ 'rows' => 5,
+ ],
+ ];
+
+ function getSettings() {
+ return $this->settings;
+ }
+
+ function getValidation() {
+ return $this->validation;
+ }
+
+ function getPresentation() {
+ return $this->presentation;
+ }
+
+ function extend() {
+ //set only once for all fields
+ if (! isset(self :: $defaultSettings['type']['options'])) {
+ $fieldTypes = getFieldTypes();
+
+ foreach ($fieldTypes as $group => &$fields) {
+ foreach ($fields as $field => &$settings) {
+ $fields[$field] = $settings['name'];
+ }
+ }
+
+ self :: $defaultSettings['type']['options'] = $fieldTypes;
+ }
+
+ $this->settings = array_merge(self :: $defaultSettings, $this->settings);
+ $this->validation = array_merge(self :: $defaultValidation, $this->validation);
+ $this->presentation = array_merge(self :: $defaultPresentation, $this->presentation);
+ }
+
+ function __construct() {
+ $this->extend();
+ }
+}
diff --git a/system/fields/file.php b/system/fields/file.php
new file mode 100755
index 0000000..f7a5152
--- /dev/null
+++ b/system/fields/file.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class File extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/gallery.php b/system/fields/gallery.php
new file mode 100755
index 0000000..7bec973
--- /dev/null
+++ b/system/fields/gallery.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Gallery extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/google_map.php b/system/fields/google_map.php
new file mode 100755
index 0000000..616b1ff
--- /dev/null
+++ b/system/fields/google_map.php
@@ -0,0 +1,59 @@
+<?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\System\Fields;
+
+class Google_map extends Field {
+ const valueType = ['address', 'lat', 'long', 'zoom'];
+
+ protected $settings = [
+ 'lat' => [
+ 'label' => 'Lat',
+ 'type' => 'number',
+ 'name' => 'lat',
+ ],
+ 'long' => [
+ 'label' => 'Long',
+ 'type' => 'number',
+ 'name' => 'long',
+ ],
+ 'zoom' => [
+ 'label' => 'Zoom',
+ 'type' => 'number',
+ 'name' => 'zoom',
+ 'value' => 1,
+ ],
+ 'address' => [
+ 'label' => 'Address',
+ 'instructions' => 'Default address for new post',
+ 'type' => 'text',
+ 'name' => 'address',
+ ],
+ 'default' => null,
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/image.php b/system/fields/image.php
new file mode 100755
index 0000000..bf2d77e
--- /dev/null
+++ b/system/fields/image.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Image extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/link.php b/system/fields/link.php
new file mode 100755
index 0000000..47dd79b
--- /dev/null
+++ b/system/fields/link.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Link extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/message.php b/system/fields/message.php
new file mode 100755
index 0000000..0b4160e
--- /dev/null
+++ b/system/fields/message.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Message extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/month.php b/system/fields/month.php
new file mode 100644
index 0000000..517a088
--- /dev/null
+++ b/system/fields/month.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Month extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/number.php b/system/fields/number.php
new file mode 100755
index 0000000..d6e7e31
--- /dev/null
+++ b/system/fields/number.php
@@ -0,0 +1,40 @@
+<?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\System\Fields;
+
+class Number extends Field {
+ protected $settings = [
+ 'default' => [
+ 'label' => 'Default Value',
+ 'instructions' => 'Default value for new post',
+ 'type' => 'number',
+ 'name' => 'default',
+ ],
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/oembed.php b/system/fields/oembed.php
new file mode 100755
index 0000000..688f343
--- /dev/null
+++ b/system/fields/oembed.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Oembed extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/password.php b/system/fields/password.php
new file mode 100755
index 0000000..864f8be
--- /dev/null
+++ b/system/fields/password.php
@@ -0,0 +1,40 @@
+<?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\System\Fields;
+
+class Password extends Field {
+ protected $settings = [
+ 'default' => [
+ 'label' => 'Default Value',
+ 'instructions' => 'Default value for new post',
+ 'type' => 'password',
+ 'name' => 'default',
+ ],
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/post.php b/system/fields/post.php
new file mode 100755
index 0000000..84f4f2c
--- /dev/null
+++ b/system/fields/post.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Post extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/product.php b/system/fields/product.php
new file mode 100755
index 0000000..84f4f2c
--- /dev/null
+++ b/system/fields/product.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Post extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/radio.php b/system/fields/radio.php
new file mode 100755
index 0000000..f92ebe7
--- /dev/null
+++ b/system/fields/radio.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Radio extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/range.php b/system/fields/range.php
new file mode 100755
index 0000000..8b6ed2f
--- /dev/null
+++ b/system/fields/range.php
@@ -0,0 +1,56 @@
+<?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\System\Fields;
+
+class Range extends Field {
+ protected $settings = [
+ 'min' => [
+ 'label' => 'Min',
+ 'type' => 'number',
+ 'name' => 'min',
+ ],
+ 'max' => [
+ 'label' => 'Max',
+ 'type' => 'number',
+ 'name' => 'max',
+ ],
+ 'step' => [
+ 'label' => 'Step',
+ 'type' => 'number',
+ 'name' => 'step',
+ 'value' => 1,
+ ],
+ 'default' => [
+ 'label' => 'Default Value',
+ 'instructions' => 'Default value for new post',
+ 'type' => 'number',
+ 'name' => 'default',
+ ],
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/select.php b/system/fields/select.php
new file mode 100755
index 0000000..d8364c6
--- /dev/null
+++ b/system/fields/select.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Select extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/tab.php b/system/fields/tab.php
new file mode 100755
index 0000000..8a279f1
--- /dev/null
+++ b/system/fields/tab.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Tab extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/taxonomy.php b/system/fields/taxonomy.php
new file mode 100755
index 0000000..c5f09f5
--- /dev/null
+++ b/system/fields/taxonomy.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Taxonomy extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/tel.php b/system/fields/tel.php
new file mode 100644
index 0000000..7288676
--- /dev/null
+++ b/system/fields/tel.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Tel extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/text.php b/system/fields/text.php
new file mode 100755
index 0000000..aeafd03
--- /dev/null
+++ b/system/fields/text.php
@@ -0,0 +1,42 @@
+<?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\System\Fields;
+
+class Text extends Field {
+ protected $category = 'basic';
+
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ 'max_length' => [
+ 'label' => 'Max length',
+ 'instructions' => '',
+ 'type' => 'text',
+ 'name' => 'number',
+ ],
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/textarea.php b/system/fields/textarea.php
new file mode 100755
index 0000000..5be7089
--- /dev/null
+++ b/system/fields/textarea.php
@@ -0,0 +1,54 @@
+<?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\System\Fields;
+
+class Textarea extends Field {
+ protected $category = 'basic';
+
+ protected $settings = [
+ 'default' => [
+ 'label' => 'Default Value',
+ 'instructions' => 'Default value for new post',
+ 'type' => 'textarea',
+ 'name' => 'default',
+ ],
+ ];
+
+ protected $validation = [
+ 'max_length' => [
+ 'label' => 'Max length',
+ 'instructions' => '',
+ 'type' => 'text',
+ 'name' => 'number',
+ ],
+ ];
+
+ protected $presentation = [
+ 'rows' => [
+ 'label' => 'Rows',
+ 'instructions' => '',
+ 'type' => 'number',
+ 'name' => 'rows',
+ ],
+ ];
+}
diff --git a/system/fields/time.php b/system/fields/time.php
new file mode 100755
index 0000000..b1bebcc
--- /dev/null
+++ b/system/fields/time.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Time extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/toggle.php b/system/fields/toggle.php
new file mode 100755
index 0000000..5ea785b
--- /dev/null
+++ b/system/fields/toggle.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Toggle extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/url.php b/system/fields/url.php
new file mode 100755
index 0000000..79e76d2
--- /dev/null
+++ b/system/fields/url.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Url extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/user.php b/system/fields/user.php
new file mode 100755
index 0000000..86610cb
--- /dev/null
+++ b/system/fields/user.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class User extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/week.php b/system/fields/week.php
new file mode 100644
index 0000000..8c71179
--- /dev/null
+++ b/system/fields/week.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Week extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/fields/wysiwyg.php b/system/fields/wysiwyg.php
new file mode 100755
index 0000000..3c48404
--- /dev/null
+++ b/system/fields/wysiwyg.php
@@ -0,0 +1,34 @@
+<?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\System\Fields;
+
+class Wysiwyg extends Field {
+ protected $settings = [
+ ];
+
+ protected $validation = [
+ ];
+
+ protected $presentation = [
+ ];
+}
diff --git a/system/traits/field-group.php b/system/traits/field-group.php
new file mode 100644
index 0000000..07996f3
--- /dev/null
+++ b/system/traits/field-group.php
@@ -0,0 +1,205 @@
+<?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\System\Traits;
+
+use function Vvveb\__;
+
+trait FieldGroup {
+ function renderFields2($fields) {
+ $htmlView = new \Vvveb\System\Core\View();
+ $htmlView->setTheme();
+ $htmlView->template('field/field-group/renderfields.html');
+
+ $htmlView->fields = $fields;
+ $html = $htmlView->render(true, false, true);
+
+ //return only content inside <body>
+ $html = preg_replace('@<!DOCTYPE[^>]+>|</?html>|</?body>@', '', $html);
+
+ return $html;
+ }
+
+ function field() {
+ $type = $this->request->post['type'] ?? 'text';
+ $field_id = $this->request->post['field_id'];
+
+ $json = $this->renderField($type, $field_id);
+ $this->response->setType('json');
+
+ return $json;
+ }
+
+ private function renderField($type, $field_id, $input = []) {
+ $fields = [];
+ $data = [];
+ $json = [];
+
+ foreach (['settings', 'validation', 'presentation', 'conditionals'] as $section) {
+ $input[$section] = $input[$section] ?? $this->request->post['field'][$field_id][$section] ?? [];
+ }
+
+ $field = ucfirst($type);
+ $fieldClass = "Vvveb\System\Fields\\$field";
+
+ if (! class_exists($fieldClass)) {
+ return;
+ }
+
+ $fieldObj = new $fieldClass();
+ $data['settings'] = $fieldObj->getSettings();
+ $data['validation'] = $fieldObj->getValidation();
+ $data['presentation'] = $fieldObj->getPresentation();
+
+ foreach ($data as $section => $field) {
+ foreach ($field as $name => $value) {
+ if (! $value) {
+ continue;
+ }
+ /*
+ if (isset($this->request->post['field'][$field_id][$section][$name])) {
+ $data[$section][$name]['value'] = $this->request->post['field'][$field_id][$section][$name];
+ }
+ */
+ if (isset($input[$section][$name])) {
+ $data[$section][$name]['value'] = $input[$section][$name];
+ }
+
+ $data[$section][$name]['id'] = $name;
+ $data[$section][$name]['name'] = "field[$field_id][$section][$name]";
+ $data[$section][$name]['class'] = ($value['type'] != 'hidden') ? 'row mb-3' : '';
+ $data[$section][$name]['label-class'] = 'col-sm-2 col-form-label py-0';
+ $data[$section][$name]['input-class'] = 'col-sm-10 col-xl-8 col-xxl-6';
+
+ if ($value['type'] == 'checkbox' && (isset($this->request->post['field'][$field_id][$section][$name]) || isset($input[$section][$name]))) {
+ $data[$section][$name]['checked'] = true;
+ }
+ }
+ }
+
+ //check if we have a complex value (json array) or a single value
+ if ($fieldClass::valueType) {
+ foreach ($fieldClass::valueType as $name) {
+ $value[$name] = $data['settings'][$name]['value'] ?? '';
+ }
+ } else {
+ $value = $data['settings']['default']['value'] ?? '';
+ }
+
+ $field = [
+ 'label' => $data['settings']['label']['value'] ?? __('Label'),
+ 'instructions' => $data['presentation']['instructions']['value'] ?? __('Instructions'),
+ 'name' => 'label',
+ //'id' => 'input-' . $field_id,
+ 'type' => $type,
+ 'label-class' => 'form-label',
+ 'placeholder' => $data['settings']['label']['value'] ?? __('Placeholder'),
+ 'readonly' => true,
+ 'value' => $value,
+ //'required' => $data['validation']['required']['checked'] ?? '',
+ ] + $input['presentation'] + $input['settings'];
+
+ foreach ($field as $name => $value) {
+ /*
+ if (isset($this->request->post['field'][$field_id]['settings'][$name])) {
+ $field[$name] = $this->request->post['field'][$field_id]['settings'][$name];
+ }*/
+
+ if (isset($input[$section][$name])) {
+ $field[$name] = $input[$section][$name];
+ }
+ }
+
+ $data['field']['input'] = $field;
+
+ $json['settings'] = $this->renderFields2($data['settings']);
+ $json['validation'] = $this->renderFields2($data['validation']);
+ $json['presentation'] = $this->renderFields2($data['presentation']);
+ $json['field'] = $this->renderFields2($data['field']);
+
+ return $json;
+ }
+
+ function renderFields() {
+ $type = $this->request->get['type'] ?? '';
+ $fields = [];
+
+ if ($type == 'field') {
+ $field = $this->request->get['field'] ?? 'text';
+ $section = $this->request->get['section'] ?? 'settings';
+
+ $field = ucfirst($field);
+ $fieldClass = "Vvveb\System\Fields\\$field";
+
+ if (! class_exists($fieldClass)) {
+ return;
+ }
+
+ $fieldObj = new $fieldClass();
+
+ switch ($section) {
+ case 'settings':
+ $fields = $fieldObj->getSettings();
+
+ break;
+
+ case 'validation':
+ $fields = $fieldObj->getValidation();
+
+ case 'presentation':
+ $fields = $fieldObj->getPresentation();
+
+ break;
+ }
+
+ foreach ($fields as $fieldName => $field) {
+ foreach ($field as $name => $value) {
+ if (isset($this->request->post[$fieldName][$name])) {
+ $fields[$fieldName][$name] = $this->request->post[$fieldName][$name];
+ }
+ }
+ }
+ }
+
+ if ($type == 'input') {
+ $field = [
+ 'label' => __('Label'),
+ 'instructions' => __('Instructions'),
+ 'name' => 'label',
+ 'type' => 'text',
+ 'class' => 'form-label',
+ 'placeholder' => 'placeholder',
+ //'value' => 'value',
+ ];
+
+ foreach ($field as $name => $value) {
+ if (isset($this->request->post[$name])) {
+ $field[$name] = $this->request->post[$name];
+ }
+ }
+
+ $fields['input'] = $field;
+ }
+
+ $this->view->fields = $fields;
+ }
+}