Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Fixed broken page edit url when running on localhost (docker) https://github.com/givanz/Vvveb/discussions/113

givanza7ed5bbb3f99
diff --git a/admin/controller/content/edit.php b/admin/controller/content/edit.php
index 59a272e..c0b31a2 100644
--- a/admin/controller/content/edit.php
+++ b/admin/controller/content/edit.php
@@ -30,6 +30,7 @@ use function Vvveb\sanitizeHTML;
use function Vvveb\slugify;
use Vvveb\Sql\categorySQL;
use Vvveb\Sql\SiteSQL;
+use Vvveb\System\Cache;
use Vvveb\System\CacheManager;
use Vvveb\System\Core\View;
use Vvveb\System\Event;
@@ -171,7 +172,7 @@ class Edit extends Base {
}
//get site host for current selected site to use for absolute url
- $url = ['host' => $this->global['host']];
+ $url = ['host' => $this->global['site_url']];
$revisionsUrl = \Vvveb\url(['module' => "$controller/revisions", 'object' => $this->object, 'type' => $this->type, $this->object . '_id' => $post_id]);
@@ -225,7 +226,7 @@ class Edit extends Base {
$themeFolder = $this->getThemeFolder();
if (isset($post['url'])) {
- $design_url = \Vvveb\url(['module' => 'editor/editor', 'url' => $post['url'], 'template' => $template, 'host' => $this->global['host'] . $admin_path], false, false);
+ $design_url = \Vvveb\url(['module' => 'editor/editor', 'url' => $post['url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
$post['design_url'] = $design_url;
}
@@ -258,7 +259,11 @@ class Edit extends Base {
$object = $this->object;
$view->$object = $post;
$view->status = ['publish' => 'Publish', 'draft' => 'Draft', 'pending' => 'Pending', 'private' => 'Private', 'password' => 'Password'];
- $view->templates = \Vvveb\getTemplateList(false, ['email']);
+
+ $view->templates = Cache::getInstance()->cache(APP,'template-list.' . $this->global['site_id'],function () {
+ return \Vvveb\getTemplateList(false, ['email']);
+ }, 604800);
+
//$validator = new Validator([$this->object]);
//$view->validatorJson = $validator->getJSON();
$view->type = __($this->type);
diff --git a/admin/controller/content/posts.php b/admin/controller/content/posts.php
index 4a492bb..205d616 100755
--- a/admin/controller/content/posts.php
+++ b/admin/controller/content/posts.php
@@ -185,8 +185,8 @@ class Posts extends Base {
$post['admin-url'] = \Vvveb\url(['module' => 'content/posts']) . '&filter[admin_id_text]=' . $post['username'] . ' &filter[admin_id]=' . $post['admin_id'];
$post['delete-url'] = \Vvveb\url(['module' => 'content/posts', 'action' => 'delete'] + $url + ['post_id[]' => $post['post_id']]);
- $post['view-url'] = \Vvveb\url("content/{$this->type}/index", $post + $url + ['host' => $this->global['host']]);
- $post['design-url'] = \Vvveb\url(['module' => 'editor/editor', 'url' => $post['view-url'], 'template' => $template, 'host' => $this->global['host'] . $admin_path], false, false);
+ $post['view-url'] = \Vvveb\url("content/{$this->type}/index", $post + $url + ['host' => $this->global['site_url']]);
+ $post['design-url'] = \Vvveb\url(['module' => 'editor/editor', 'url' => $post['view-url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
}
}
@@ -198,7 +198,7 @@ class Posts extends Base {
}, 259200);
$view->set($results);
- $view->status = ['publish' => 'publish', 'pending' => 'pending'];
+ $view->status = ['publish' => 'Publish', 'pending' => 'Pending', 'draft' => 'Draft', 'private' => 'Private', 'password' => 'Password'];
$view->archives = $archives;
$view->filter = $this->filter;
$view->limit = $options['limit'];
diff --git a/admin/controller/product/product.php b/admin/controller/product/product.php
index 19f9d39..1a632cc 100755
--- a/admin/controller/product/product.php
+++ b/admin/controller/product/product.php
@@ -175,7 +175,7 @@ class Product extends Edit {
$view->product['manufacturer_id'] = (($view->product['manufacturer_id'] ?? 0) ? $view->product['manufacturer_id'] : '');
$view->product['vendor_id'] = (($view->product['vendor_id'] ?? 0) ? $view->product['vendor_id'] : '');
$view->product['status'] = $view->product['status'] ?? 1;
- $data['subtract'] = [1 => __('Yes'), 0 => __('No')]; //Subtract stock options
+ $data['subtract_stock'] = [1 => __('Yes'), 0 => __('No')]; //Subtract stock options
$data['status'] = [0 => __('Disabled'), 1 => __('Enabled')];
$view->set($data);
}
diff --git a/admin/controller/product/products.php b/admin/controller/product/products.php
index 21a0cfe..ce97ee6 100755
--- a/admin/controller/product/products.php
+++ b/admin/controller/product/products.php
@@ -107,9 +107,9 @@ class Products extends Base {
$product['url'] = url(['module' => 'product/product', 'product_id' => $product['product_id'], 'type' => $product['type']]);
$product['edit-url'] = url(['module' => 'product/product', 'product_id' => $product['product_id'], 'type' => $product['type']]);
$product['delete-url'] = url(['module' => 'product/products', 'action' => 'delete', 'product_id[]' => $product['product_id'], 'type' => $product['type']]);
- $product['view-url'] = url('product/product/index', $product + ['host' => $this->global['host']]);
+ $product['view-url'] = url('product/product/index', $product + ['host' => $this->global['site_url']]);
$admin_path = \Vvveb\config('admin.path', 'admin') . '/';
- $product['design-url'] = url(['module' => 'editor/editor', 'url' => $product['view-url'], 'template' => $template, 'host' => $this->global['host'] . $admin_path], false, false);
+ $product['design-url'] = url(['module' => 'editor/editor', 'url' => $product['view-url'], 'template' => $template, 'host' => $this->global['site_url'] . $admin_path], false, false);
}
}
diff --git a/admin/template/components/sites.tpl b/admin/template/components/sites.tpl
index dc7f049..2faba5b 100755
--- a/admin/template/components/sites.tpl
+++ b/admin/template/components/sites.tpl
@@ -21,7 +21,7 @@ if(isset($this->_component['sites']) && $this->_component['sites'][$_sites_idx])
@site [data-v-site-name] = $site['name']
@site [data-v-site-icon]|addClass = <?php echo $sites['states'][$state]['icon'];?>
- @site a[data-v-site-href]|href = <?php echo '//' . $site['href'];?>
+ @site a[data-v-site-url]|href = <?php echo '//' . $site['url'];?>
@site button[data-v-site-site_id]|value = $site['id']
diff --git a/system/sites.php b/system/sites.php
index 253d490..ec06132 100755
--- a/system/sites.php
+++ b/system/sites.php
@@ -62,7 +62,7 @@ class Sites {
self :: $sites = \Vvveb\config('sites');
foreach (self::$sites as &$site) {
- $site['href'] = self :: url($site['host']);
+ $site['url'] = self :: url($site['host']);
}
return self :: $sites;
@@ -177,7 +177,7 @@ class Sites {
$matches['subdomain'] = $matches['tld'] = $matches['prefix'] = '';
}
- return ($matches['prefix'] ? $matches['prefix'] : '') .
+ $url = ($matches['prefix'] ? $matches['prefix'] : '') .
(! empty($matches['subdomain']) ? $matches['subdomain'] . '.' : '') .
($matches['domain'] ?? '') .
(! empty($matches['tld']) ? '.' . $matches['tld'] : '') .