Skip to content

Commit

Permalink
Fixed broken page edit url when running on localhost (docker) #113
Browse files Browse the repository at this point in the history
  • Loading branch information
givanz committed Apr 13, 2024
1 parent f589b8f commit a7ed5bb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
11 changes: 8 additions & 3 deletions admin/controller/content/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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;
Expand Down Expand Up @@ -171,7 +172,7 @@ function index() {
}

//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]);

Expand Down Expand Up @@ -225,7 +226,7 @@ function index() {
$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;
}

Expand Down Expand Up @@ -258,7 +259,11 @@ function index() {
$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);
Expand Down
6 changes: 3 additions & 3 deletions admin/controller/content/posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ function index() {

$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);
}
}

Expand All @@ -198,7 +198,7 @@ function () use (&$options) {
}, 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'];
Expand Down
2 changes: 1 addition & 1 deletion admin/controller/product/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function index() {
$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);
}
Expand Down
4 changes: 2 additions & 2 deletions admin/controller/product/products.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ function index() {
$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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion admin/template/components/sites.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
4 changes: 2 additions & 2 deletions system/sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function getSites() {
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;
Expand Down Expand Up @@ -177,7 +177,7 @@ public static function url($url, $host = null) {
$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'] : '') .
Expand Down

0 comments on commit a7ed5bb

Please sign in to comment.