Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Fixed edit content sites list

givanz57fa47c8425d
diff --git a/admin/controller/content/edit.php b/admin/controller/content/edit.php
index b01393c..bfb76f5 100644
--- a/admin/controller/content/edit.php
+++ b/admin/controller/content/edit.php
@@ -28,8 +28,7 @@ use function Vvveb\humanReadable;
use function Vvveb\model;
use function Vvveb\sanitizeHTML;
use function Vvveb\slugify;
-use Vvveb\Sql\categorySQL;
-use Vvveb\Sql\SiteSQL;
+use Vvveb\Sql\CategorySQL;
use Vvveb\System\Cache;
use Vvveb\System\CacheManager;
use Vvveb\System\Core\View;
@@ -46,34 +45,7 @@ class Edit extends Base {
protected $revisions = true;
- use TaxonomiesTrait, AutocompleteTrait;
-
- function sites($selectedSites = []) {
- $sites = new SiteSQL();
-
- $options = [];
-
- if (Admin::hasCapability('edit_other_sites')) {
- //unset($options['site_id']);
- } else {
- $options['site_id'] = Admin :: siteAccess();
- }
-
- $results = $sites->getAll(
- $options + [
- 'start' => 0,
- 'limit' => 100,
- ]
- )['site'] ?? [];
-
- if ($results && $selectedSites) {
- foreach ($results as &$site) {
- $site['selected'] = in_array($site['site_id'], $selectedSites);
- }
- }
-
- return $results;
- }
+ use TaxonomiesTrait, AutocompleteTrait, SitesTrait;
function getThemeFolder() {
return DIR_THEMES . Sites::getTheme() ?? 'default';
@@ -285,11 +257,11 @@ class Edit extends Base {
$view->$object = $post;
$view->status = ['publish' => 'Publish', 'draft' => 'Draft', 'pending' => 'Pending', 'private' => 'Private', 'password' => 'Password', 'future' => 'Future'];
- $view->templates = Cache::getInstance()->cache(APP,'template-list.' . $theme, function () use ($theme) {
+ $view->templates = Cache::getInstance()->cache(APP, 'template-list-' . $theme, function () use ($theme) {
return \Vvveb\getTemplateList($theme, ['email']);
}, 604800);
- $view->themeFonts = Cache::getInstance()->cache(APP,'fonts-list.' . $theme, function () use ($theme) {
+ $view->themeFonts = Cache::getInstance()->cache(APP, 'fonts-list-' . $theme, function () use ($theme) {
$fonts = \Vvveb\System\Media\Font::themeFonts($theme);
$names = [];
@@ -384,6 +356,21 @@ class Edit extends Base {
}
}
+ //process fields
+ $post_field_value = [];
+
+ if (isset($post['field'])) {
+ foreach ($post['field'] as $language_id => $fields) {
+ foreach ($fields as $field_id => $value) {
+ if (is_array($value)) {
+ $value = json_encode($value);
+ }
+
+ $post_field_value[] = ['field_id' => $field_id, 'language_id' => $language_id, 'value' => $value];
+ }
+ }
+ }
+
$site_id = $this->request->post['site'] ?? []; //[$this->global['site_id']];
$post = $post + $this->global;
@@ -410,6 +397,7 @@ class Edit extends Base {
$this->object . '_id' => $post_id,
$this->object . '_content' => $post[$this->object . '_content'],
'taxonomy_item_id' => $post['taxonomy_item_id'] ?? [],
+ 'post_field_value' => $post_field_value,
'site_id' => $site_id,
] + $this->global;
@@ -433,9 +421,6 @@ class Edit extends Base {
}
}
}
-
- //CacheManager::delete($this->object);
- CacheManager::delete();
} else {
$this->view->errors = [$posts->error];
}
@@ -450,6 +435,7 @@ class Edit extends Base {
$this->object => $post,
$this->object . '_content' => $post[$this->object . '_content'],
'taxonomy_item_id' => $post['taxonomy_item_id'] ?? [],
+ 'post_field_value' => $post_field_value,
'site_id' => $site_id,
] + $this->global;
@@ -459,7 +445,6 @@ class Edit extends Base {
if (! $id) {
$view->errors = [$posts->error];
} else {
- CacheManager::delete($this->object);
$this->request->get[$this->object . '_id'] = $id;
$post_id = $id;
@@ -482,6 +467,10 @@ class Edit extends Base {
list($post, $post_id, $this->type) = Event :: trigger(__CLASS__,__FUNCTION__, $post, $post_id, $this->type);
+ CacheManager::clearObjectCache('component', $this->object);
+ CacheManager::clearObjectCache('component', $this->object . 's');
+ CacheManager::clearPageCache();
+
if ($new) {
$this->redirect(['module'=>$this->module, $this->object . '_id' => $id, 'type' => $this->type, 'success' => $message], [], false);
}
diff --git a/admin/template/content/edit.tpl b/admin/template/content/edit.tpl
index 439c2c4..e4d6409 100644
--- a/admin/template/content/edit.tpl
+++ b/admin/template/content/edit.tpl
@@ -68,8 +68,8 @@ if ($optgroup != $option['folder']) {
foreach ($this->languagesList as $language) {
$content = $this->{{type}}['{{type}}_content'][$language['language_id']] ?? [];
?>
- [data-v-languages] [data-v-language-id]|id = <?php echo 'lang-' . $language['code'] . '-' . $_lang_instance;?>
- [data-v-languages] [data-v-language-id]|addClass = <?php if ($_i == 0) echo 'show active';?>
+ [data-v-languages] [data-v-language-id]|id = <?php echo 'lang-' . $language['code'] . '-' . $_lang_instance;?>
+ [data-v-languages] [data-v-language-id]|addClass = <?php if ($_i == 0) echo 'show active';?>
@language [data-v-language-name] = $language['name']
@language [data-v-language-img]|title = $language['name']
@@ -161,21 +161,6 @@ foreach ($revisions as $revision) {
[data-v-{{type}}] [data-v-revisions_url]|href = <?php echo $this->revisions_url . '&language_id=' . $language['language_id'];?>
-@site = [data-v-sites] [data-v-site]
-@site|deleteAllButFirstChild
-
-@site|before = <?php
-if(isset($this->sitesList) && is_array($this->sitesList)) {
- foreach ($this->sitesList as $index => $site) {?>
-
- @site [data-v-*]|innerText = $site['@@__data-v-(*)__@@']
- @site [data-v-*]|title = $site['@@__data-v-(*)__@@']
- @site input[data-v-*]|addNewAttribute = <?php if (isset($site['selected']) && $site['selected']) echo 'checked';?>
-
-
- @site|after = <?php
- }
-}?>
-
+import(content/sites.tpl)
import(content/post_taxonomy.tpl)