Skip to content

Commit 3c0efd8

Browse files
committed
Model entity name renamed to singular
1 parent 1883707 commit 3c0efd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+233
-133
lines changed

admin/controller/base.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ protected function redirect($url = '/', $parameters = [], $stop = true) {
560560
FrontController::closeConnections();
561561
PageCache::getInstance()->cleanUp();
562562

563-
die();
563+
die(0);
564564
}
565565
}
566566

admin/controller/content/autocomplete-trait.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ function urlAutocomplete() {
109109

110110
$search = [];
111111

112-
if (isset($results['products'])) {
113-
foreach ($results['products'] as $product) {
112+
if (isset($results['product'])) {
113+
foreach ($results['product'] as $product) {
114114
$product['image'] = Images::image($product['image'], 'product', 'thumb');
115115
$search[] = [
116116
'type' => 'cardimage',
@@ -125,8 +125,8 @@ function urlAutocomplete() {
125125
$posts = new \Vvveb\Sql\PostSQL();
126126
$results = $posts->getAll($options);
127127

128-
if (isset($results['posts'])) {
129-
foreach ($results['posts'] as $post) {
128+
if (isset($results['post'])) {
129+
foreach ($results['post'] as $post) {
130130
$post['image'] = Images::image($post['image'], 'post', 'thumb');
131131
$search[] = [
132132
'type' => 'cardimage',
@@ -155,8 +155,8 @@ function productsAutocomplete() {
155155

156156
$search = [];
157157

158-
if (isset($results['products'])) {
159-
foreach ($results['products'] as $product) {
158+
if (isset($results['product'])) {
159+
foreach ($results['product'] as $product) {
160160
$product['image'] = Images::image($product['image'], $this->object);
161161
$search[$product[$this->object . '_id']] = '<img width="32" height="32" src="' . $product['image'] . '"> ' . $product['name'];
162162
}

admin/controller/content/categories.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function delete() {
3636
echo __('Item removed!');
3737
}
3838

39-
die();
39+
die(0);
4040
}
4141

4242
function reorder() {
@@ -48,7 +48,7 @@ function reorder() {
4848
echo __('Items reordered!');
4949
}
5050

51-
die();
51+
die(0);
5252
}
5353

5454
function add() {
@@ -76,7 +76,7 @@ function add() {
7676
}
7777
}
7878

79-
die();
79+
die(0);
8080

8181
return;
8282
}

admin/controller/content/comments.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
class Comments extends Listing {
3535
protected $type = 'comment';
3636

37-
protected $list = 'comments';
37+
protected $list = 'comment';
3838

3939
protected $module = 'content';
4040

@@ -59,12 +59,12 @@ function save() {
5959
}
6060

6161
function index() {
62-
$view = View :: getInstance();
63-
$type = $this->type;
62+
$view = View :: getInstance();
63+
$type = $this->type;
6464
$controller = $this->controller ?? $type;
6565
$listController = $this->listController ?? $controller;
66-
$module = $this->module;
67-
$list = $this->list ?? $type . 's';
66+
$module = $this->module;
67+
$list = $this->list ?? $type . 's';
6868
$status = $this->request->get['status'] ?? '';
6969

7070
$comment_status = [

admin/controller/content/edit.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function sites($selectedSites = []) {
6464
'start' => 0,
6565
'limit' => 100,
6666
]
67-
)['sites'] ?? [];
67+
)['site'] ?? [];
6868

6969
if ($results && $selectedSites) {
7070
foreach ($results as &$site) {
@@ -177,6 +177,7 @@ function index() {
177177
$url = ['host' => $this->global['site_url']];
178178

179179
$revisionsUrl = \Vvveb\url(['module' => "$controller/revisions", 'object' => $this->object, 'type' => $this->type, $this->object . '_id' => $post_id]);
180+
$name = '';
180181

181182
if (isset($post[$this->object . '_content'])) {
182183
foreach ($post[$this->object . '_content'] as &$content) {
@@ -196,6 +197,8 @@ function index() {
196197
}
197198
}
198199
$language = ['language' => $code];
200+
} else {
201+
$name = $content['name'];
199202
}
200203

201204
$content['url'] = \Vvveb\url($route, $content + $language + $url);
@@ -209,13 +212,13 @@ function index() {
209212
$revision = $revisions->getAll([$this->object . '_id' => $post_id, 'language_id' => $content['language_id']]);
210213

211214
if ($revision) {
212-
foreach ($revision['revision'] as &$rev) {
215+
foreach ($revision[$this->object . '_content_revision'] as &$rev) {
213216
$rev['preview-url'] = $content['url'] . '?revision=preview&created_at=' . $rev['created_at'];
214217
$rev['compare-url'] = $revisionsUrl . '&created_at=' . $rev['created_at'];
215218
}
216219

217220
$content['revision_count'] = $revision['count'];
218-
$content['revision'] = $revision['revision'];
221+
$content['revision'] = $revision[$this->object . '_content_revision'];
219222
}
220223
}
221224
}
@@ -230,7 +233,7 @@ function index() {
230233
$design_url = '';
231234

232235
if (isset($post['url'])) {
233-
$design_url = \Vvveb\url(['module' => 'editor/editor', 'url' => $post['url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
236+
$design_url = \Vvveb\url(['module' => 'editor/editor', 'name' => urlencode($name), 'url' => $content['url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
234237
$post['design_url'] = $design_url;
235238
}
236239

admin/controller/content/menus.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function delete() {
8181
echo $menus->error;
8282
}
8383

84-
die();
84+
die(0);
8585

8686
return $this->index();
8787
}
@@ -95,7 +95,7 @@ function reorder() {
9595
echo __('Items reordered!');
9696
}
9797

98-
die();
98+
die(0);
9999
}
100100

101101
function add() {
@@ -118,13 +118,14 @@ function add() {
118118
}
119119
}
120120

121-
$response = [];
122-
$success = true;
121+
$response = [];
122+
$success = true;
123123
$menu_item_id = false;
124-
124+
125125
if (isset($data['menu_item_id']) && $data['menu_item_id']) {
126-
$results = $menus->editMenuItem(['menu_item' => $data, 'menu_item_id' => $data['menu_item_id']]);
126+
$results = $menus->editMenuItem(['menu_item' => $data, 'menu_item_id' => $data['menu_item_id']]);
127127
$menu_item_id = $data['menu_item_id'];
128+
128129
if ($results) {
129130
$message = __('Item saved!');
130131
} else {
@@ -136,13 +137,13 @@ function add() {
136137

137138
if ($results) {
138139
$menu_item_id = $results['menu_item'];
139-
$message = __('Item added!');
140+
$message = __('Item added!');
140141
} else {
141142
$message = __('Error!');
142143
$success = false;
143144
}
144145
}
145-
146+
146147
$response += ['success' => $success, 'message' => $message, 'menu_item_id' => $menu_item_id];
147148

148149
$this->response->setType('json');
@@ -229,7 +230,7 @@ function index() {
229230
'limit' => 10000,
230231
] + $this->global;
231232

232-
$results = $menus->getMenusList($options);
233+
$results = $menus->getAll($options);
233234

234235
if (isset($results['menu'])) {
235236
foreach ($results['menu'] as &$menu) {

admin/controller/content/posts.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ function index() {
225225

226226
$defaultTemplate = "content/{$this->type}.html";
227227

228-
if ($results && isset($results['posts'])) {
229-
foreach ($results['posts'] as $id => &$post) {
228+
if ($results && isset($results['post'])) {
229+
foreach ($results['post'] as $id => &$post) {
230230
if (isset($post['image'])) {
231231
$post['image'] = Images::image($post['image'], 'post');
232232
}
@@ -240,7 +240,7 @@ function index() {
240240
$post['delete-url'] = url(['module' => 'content/posts', 'action' => 'delete'] + $url + ['post_id[]' => $post['post_id']]);
241241
$post['duplicate-url'] = url(['module' => 'content/posts', 'action' => 'duplicate'] + $url + ['post_id' => $post['post_id']]);
242242
$post['view-url'] = url("content/{$this->type}/index", $post + $url + ['host' => $this->global['site_url']]);
243-
$post['design-url'] = url(['module' => 'editor/editor', 'url' => $post['view-url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
243+
$post['design-url'] = url(['module' => 'editor/editor', 'name' => urlencode($post['name'] ?? ''), 'url' => $post['view-url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
244244
}
245245
}
246246

admin/controller/editor/autocomplete.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function products() {
3434
$options = [
3535
'start' => 0,
3636
'limit' => 10,
37-
'like' => $text,
37+
'like' => $text,
3838
] + $this->global;
3939

4040
unset($options['admin_id']);
@@ -43,7 +43,7 @@ function products() {
4343

4444
$search = [];
4545

46-
foreach ($results['products'] as $product) {
46+
foreach ($results['product'] as $product) {
4747
$search[$product['product_id']] = $product['name'];
4848
}
4949

@@ -105,7 +105,7 @@ function posts() {
105105
'start' => 0,
106106
'limit' => 10,
107107
'type' => $type,
108-
'like' => $text,
108+
'like' => $text,
109109
//'like' => '%' . $text . '%',
110110
] + $this->global;
111111

@@ -115,8 +115,8 @@ function posts() {
115115

116116
$search = [];
117117

118-
if (isset($results['posts'])) {
119-
foreach ($results['posts'] as $post) {
118+
if (isset($results['post'])) {
119+
foreach ($results['post'] as $post) {
120120
$search[$post['post_id']] = substr($post['name'],0, 50);
121121
}
122122
}
+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
3+
/**
4+
* Vvveb
5+
*
6+
* Copyright (C) 2022 Ziadin Givan
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
namespace Vvveb\Controller\Field;
24+
25+
use function Vvveb\__;
26+
use Vvveb\Controller\Crud;
27+
use Vvveb\Sql\CountrySQL;
28+
use Vvveb\Sql\Field_GroupSQL;
29+
use Vvveb\Sql\FieldSQL;
30+
31+
class FieldGroup extends Crud {
32+
protected $type = 'field_group';
33+
34+
protected $controller = 'field-group';
35+
36+
protected $module = 'field';
37+
38+
function save() {/*
39+
$field = $this->request->post['field'] ?? [];
40+
$field_group_id = $this->request->get['field_group_id'] ?? false;
41+
42+
if ($field_group_id) {
43+
$fieldGroup = new Field_GroupSQL();
44+
$result = $fieldGroup->addFields(['field_group_id' => $field_group_id, 'field_to_field_group' => $field]);
45+
46+
if ($result && isset($result['field_to_field_group'])) {
47+
$successMessage = __('Field saved!');
48+
$this->view->success[] = $successMessage;
49+
$this->view->errors = [];
50+
} else {
51+
$this->view->errors[] = __('Error saving!');
52+
}
53+
}*/
54+
55+
$this->request->post[$this->type]['status'] = 1;
56+
57+
parent::save();
58+
}
59+
60+
function fields() {
61+
$country_id = $this->request->get['country_id'] ?? false;
62+
$fields = [];
63+
64+
if ($country_id) {
65+
$field = new FieldSQL();
66+
$options = $this->global;
67+
$options['status'] = 1;
68+
$options['country_id'] = $country_id;
69+
unset($options['limit']);
70+
$fields = $field->getAll($options)['field'] ?? [];
71+
}
72+
73+
$this->response->setType('json');
74+
$this->response->output($fields);
75+
//return [];
76+
}
77+
78+
function index() {
79+
$field_group_id = $this->request->get['field_group_id'] ?? false;
80+
$this->view->field_group_id = $field_group_id;
81+
82+
parent::index();
83+
84+
return;
85+
$field_group_id = $this->request->get['field_group_id'] ?? false;
86+
87+
$fields = [];
88+
89+
if ($field_group_id) {
90+
$fieldGroup = new Field_GroupSQL();
91+
$fields = $fieldGroup->getFields(['field_group_id' => $field_group_id])['fields'] ?? [];
92+
}
93+
$this->view->fields = $fields;
94+
$this->view->field_group_id = $field_group_id;
95+
96+
$countryModel = new CountrySQL();
97+
$options = $this->global;
98+
$options['status'] = 1;
99+
unset($options['limit']);
100+
$country = $countryModel->getAll($options);
101+
102+
$this->view->countries = $country['country'] ?? [];
103+
104+
$admin_path = \Vvveb\adminPath();
105+
$controllerPath = $admin_path . 'index.php?module=localization/field-group';
106+
$this->view->fieldsUrl = "$controllerPath&action=fields";
107+
}
108+
}

0 commit comments

Comments
 (0)