Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Rename editor module to page-builder, admin UI refactor (fields, field groups), type hint pass

Givan193f6947eaab
diff --git a/admin/component/admin.php b/admin/component/admin.php
old mode 100755
new mode 100644
index 448d03f..2dfed12
--- a/admin/component/admin.php
+++ b/admin/component/admin.php
@@ -28,30 +28,43 @@ use Vvveb\System\Images;
use Vvveb\System\User\Admin as AdminUser;
class Admin extends ComponentBase {
- public static $defaultOptions = [
+ /** @var array{limit: int, page: int} Default options for admin user listing. */
+ public static array $defaultOptions = [
'limit' => 1000,
'page' => 1,
];
- protected $options = [];
+ /** @var array<string, mixed> Resolved options for this component. */
+ protected array $options = [];
- public $cacheExpire = 0; //seconds
+ /** @var int Cache expiry time in seconds (0 = disabled). */
+ public int $cacheExpire = 0;
- function cacheKey() {
+ /**
+ * Disable caching for this component.
+ *
+ * @return string|null Always returns false to disable caching.
+ */
+ public function cacheKey(): ?string {
// disable caching
- return false;
+ return null;
}
- function results() {
+ /**
+ * Get current admin user data with resolved avatar and cover images.
+ *
+ * @return array<string, mixed> Current admin user data with resolved images.
+ */
+ public function results(): array {
$results = AdminUser::current();
foreach (['avatar', 'cover'] as $image) {
if (isset($results[$image])) {
- $results[$image]= Images::image($results[$image], 'admin');
+ $results[$image] = Images::image($results[$image], 'admin');
}
}
- list($results) = Event::trigger(__CLASS__, __FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
diff --git a/admin/component/comments.php b/admin/component/comments.php
index c996065..e563bbb 100755
--- a/admin/component/comments.php
+++ b/admin/component/comments.php
@@ -28,17 +28,24 @@ use Vvveb\System\Event;
use Vvveb\System\Images;
class Comments extends ComponentBase {
- public static $defaultOptions = [
- 'start' => 0,
- 'limit' => 10,
- 'language_id' => null,
- 'site_id' => null,
- 'status' => 1,
+ /** @var array<string, mixed> Default options for comment listing. */
+ public static array $defaultOptions = [
+ 'start' => 0,
+ 'limit' => 10,
+ 'language_id' => null,
+ 'site_id' => null,
+ 'status' => 1,
];
- public $options = [];
+ /** @var array<string, mixed> Resolved options for this component. */
+ public array $options = [];
- function results() {
+ /**
+ * Get comments with resolved images.
+ *
+ * @return array<string, mixed> Comments with resolved images.
+ */
+ public function results(): array {
$comments = new CommentSQL();
$results = $comments->getAll($this->options) ?? [];
@@ -46,7 +53,7 @@ class Comments extends ComponentBase {
if (isset($results['comment'])) {
foreach ($results['comment'] as $id => &$comment) {
if (isset($comment['images'])) {
- $comment['images'] = json_decode($comment['images'], 1);
+ $comment['images'] = json_decode($comment['images'], true);
foreach ($comment['images'] as &$image) {
$image = Images::image('comment', $image);
@@ -59,7 +66,7 @@ class Comments extends ComponentBase {
}
}
- list($results) = Event::trigger(__CLASS__, __FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
diff --git a/admin/component/languages.php b/admin/component/languages.php
index d7ceb91..ea87e85 100644
--- a/admin/component/languages.php
+++ b/admin/component/languages.php
@@ -27,29 +27,42 @@ use Vvveb\System\Event;
use Vvveb\System\Locale;
class Languages extends ComponentBase {
- public static $defaultOptions = [
+ /** @var array{start: int, limit: int, status: int} Default options for language listing. */
+ public static array $defaultOptions = [
'start' => 1,
'limit' => 1000,
'status' => 1,
];
- protected $options = [];
+ /** @var array<string, mixed> Resolved options for this component. */
+ protected array $options = [];
- public $cacheExpire = 0; //seconds
+ /** @var int Cache expiry time in seconds (0 = disabled). */
+ public int $cacheExpire = 0;
- function cacheKey() {
+ /**
+ * Disable caching for this component.
+ *
+ * @return string|null Always returns false to disable caching.
+ */
+ public function cacheKey(): ?string {
// disable caching
- return false;
+ return null;
}
- function results() {
+ /**
+ * Get available languages and the currently active language.
+ *
+ * @return array{language: array<string, mixed>, current?: string, active?: array{name: string, code: string, slug: string, id: mixed}}
+ */
+ public function results(): array {
$results = [];
$results['language'] = Locale::availableLanguages();
if ($results['language']) {
$results['current'] = $code = self :: $global['language'];
- if (! isset($results['language'][$code])) {
+ if (!isset($results['language'][$code])) {
$results['current'] = $code = key($results['language']);
}
@@ -64,11 +77,10 @@ class Languages extends ComponentBase {
'slug' => $language['slug'],
'id' => $language['language_id'],
];
- } else {
}
}
- list($results) = Event::trigger(__CLASS__, __FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
diff --git a/admin/component/news.php b/admin/component/news.php
old mode 100755
new mode 100644
index 4e3093b..c5e9705
--- a/admin/component/news.php
+++ b/admin/component/news.php
@@ -29,39 +29,49 @@ use Vvveb\System\Event;
use Vvveb\System\Import\Rss;
class News extends ComponentBase {
- protected $domain = 'https://blog.vvveb.com';
+ /** @var string Domain URL for the news feed. */
+ protected string $domain = 'https://blog.vvveb.com';
- protected $url = '/feed/news';
+ /** @var string Path to the news feed endpoint. */
+ protected string $url = '/feed/news';
- public static $defaultOptions = [
+ /** @var array{page: int, limit: int} Default options for pagination. */
+ public static array $defaultOptions = [
'page' => 0,
'limit' => 10,
];
- public $options = [];
+ /** @var array<string, mixed> Resolved options for this component. */
+ public array $options = [];
- function getNews() {
+ /**
+ * Fetch news items from the RSS feed.
+ *
+ * @return array<int, mixed> Parsed news items, or empty array on failure.
+ */
+ public function getNews(): array {
$feed = getUrl($this->domain . $this->url, true, 604800, 3, false);
if ($feed) {
$rss = new Rss($feed);
- $result = $rss->get($this->options['page'], $this->options['limit']);
-
- return $result;
+ return $rss->get($this->options['page'], $this->options['limit']);
}
return [];
}
- function results() {
- list($this->domain, $this->url) = Event::trigger(__CLASS__, 'url', $this->domain, $this->url);
+ /**
+ * Get news component results including domain, URL, and news items.
+ *
+ * @return array{domain: string, url: string, news: array<int, mixed>, count: int}
+ */
+ public function results(): array {
+ [$this->domain, $this->url] = Event::trigger(__CLASS__, 'url', $this->domain, $this->url);
$cache = Cache::getInstance();
// check for news ~twice a week
- $news = $cache->cache('vvveb', 'news', function () {
- return $this->getNews();
- }, 259200);
+ $news = $cache->cache('vvveb', 'news', fn (): array => $this->getNews(), 259200);
$results = [
'domain' => $this->domain,
@@ -70,7 +80,7 @@ class News extends ComponentBase {
'count' => count($news),
];
- list($results) = Event::trigger(__CLASS__, __FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
diff --git a/admin/component/notifications.php b/admin/component/notifications.php
old mode 100644
new mode 100755
index ce24a2e..9930a55
--- a/admin/component/notifications.php
+++ b/admin/component/notifications.php
@@ -25,7 +25,6 @@ namespace Vvveb\Component;
use function Vvveb\commentStatusBadgeClass;
use function Vvveb\orderStatusBadgeClass;
use Vvveb\Sql\StatSQL;
-use Vvveb\System\Cache;
use Vvveb\System\Component\ComponentBase;
use Vvveb\System\Core\View;
use Vvveb\System\Event;
@@ -33,24 +32,35 @@ use Vvveb\System\Update;
use function Vvveb\url;
class Notifications extends ComponentBase {
- public static $defaultOptions = [
+ /** @var array<string, mixed> Default options (empty for notifications). */
+ public static array $defaultOptions = [
];
- public $options = [];
+ /** @var array<string, mixed> Resolved options for this component. */
+ public array $options = [];
- private $stats;
+ /** @var StatSQL|null Statistics query instance. */
+ private ?StatSQL $stats = null;
- private $count = 0;
+ /** @var int Total notification count. */
+ private int $count = 0;
- private $notifications = [];
+ /** @var array<string, mixed> Aggregated notification data. */
+ private array $notifications = [];
- private $menu = [];
+ /** @var array<string, mixed> Menu badge data for sidebar notifications. */
+ private array $menu = [];
- protected function orders() {
- $orderCount = $this->stats->getOrdersCount($this->options)['orders'] ?? [];
+ /**
+ * Gather order notification counts and update menu badges.
+ *
+ * @return void
+ */
+ protected function orders(): void {
+ $orderCount = $this->stats->getOrdersCount($this->options)['orders'] ?? [];
- $orderStatsusNew = 1; //get from site config
- $newOrders = ($orderCount[$orderStatsusNew]['count'] ?? 0);
+ $orderStatusNew = 1; //get from site config
+ $newOrders = ($orderCount[$orderStatusNew]['count'] ?? 0);
if ($newOrders > 0) {
$this->count += $newOrders;
@@ -59,12 +69,13 @@ class Notifications extends ComponentBase {
$this->menu['sales']['badge-class'] = 'badge bg-success-subtle text-body mx-2';
}
- $url = ['module' => 'product/products'];
- //set order name as array keys
+ //link order status notifications to the orders list filtered by status
+ $url = ['module' => 'order/orders'];
+ //re-key by human readable status name
foreach ($orderCount as $type => $orders) {
if (isset($orders['name'])) {
$orders['badge'] = orderStatusBadgeClass($orders['order_status_id']);
- $orders['icon'] = 'icon-bag-handle-outline';
+ $orders['icon'] = 'shopping-bag';
$orders['url'] = url($url + ['filter[order_status_id]' => $orders['order_status_id']]);
$orderCount[$orders['name']] = $orders;
unset($orderCount[$type]);
@@ -74,21 +85,30 @@ class Notifications extends ComponentBase {
$this->notifications['orders'] = $orderCount + $this->notifications['orders'];
}
- protected function users() {
+ /**
+ * Gather user registration counts for current month and year.
+ *
+ * @return void
+ */
+ protected function users(): void {
$userCount = $this->stats->getUsersCount($this->options)['users'] ?? [];
- $currentYear = intval(date('Y'));
- $currentMonth = intval(date('n'));
+ $currentYear = (int)(date('Y'));
+ $currentMonth = (int)(date('n'));
$monthCount = 0;
$yearCount = 0;
foreach ($userCount as $m) {
- if ($m['year'] == $currentYear) {
+ //db drivers return year/month as strings, compare as integers
+ $year = (int)($m['year'] ?? 0);
+ $month = (int)($m['month'] ?? 0);
+
+ if ($year === $currentYear) {
$yearCount += $m['count'];
}
- if ($m['year'] == $currentYear && $m['month'] == $currentMonth) {
+ if ($year === $currentYear && $month === $currentMonth) {
$monthCount += $m['count'];
}
}
@@ -101,12 +121,17 @@ class Notifications extends ComponentBase {
$this->notifications['users']['month']['url'] = $url;
}
- protected function products() {
+ /**
+ * Gather product stock notification counts.
+ *
+ * @return void
+ */
+ protected function products(): void {
$productCount = $this->stats->getProductStockCount($this->options)['products'] ?? [];
$url = ['module' => 'product/products'];
foreach ($productCount as $type => &$products) {
- $products['icon'] = 'icon-cube-outline';
+ $products['icon'] = 'box';
$products['badge'] = commentStatusBadgeClass($products['stock_status_id']);
$products['url'] = url($url + ['filter[stock_status_id]' => $products['stock_status_id']]);
}
@@ -114,118 +139,101 @@ class Notifications extends ComponentBase {
$this->notifications['products'] = $productCount + $this->notifications['products'];
}
- protected function comments() {
- $commentCount = $this->stats->getCommentsCount($this->options)['comments'] ?? [];
- $comment_status = [
- 0 => 'pending',
- 1 => 'approved',
- 2 => 'spam',
- 3 => 'trash',
+ /**
+ * Aggregate status notifications for comments-like content types.
+ *
+ * Shared by comments(), reviews() and questions(): counts new items into
+ * the total and menu badges, then re-keys counts by status name with
+ * icon, badge and URL for each status.
+ *
+ * @param string $key Result key in notifications.
+ * @param array<int, mixed> $counts Status rows keyed by status id.
+ * @param string $module Module for status filter URLs.
+ * @param string $icon Icon class for all statuses.
+ * @param string $menu Menu key for the badge.
+ * @param string|null $menuItem Submenu item key for the badge, or null for none.
+ *
+ * @return void
+ */
+ protected function statusNotifications(string $key, array $counts, string $module, string $icon, string $menu, ?string $menuItem = null): void {
+ $statusNames = [
+ 0 => 'pending',
+ 1 => 'approved',
+ 2 => 'spam',
+ 3 => 'trash',
];
- $commentStatsusNew = 0; //get from site config
- $newComments = ($commentCount[$commentStatsusNew]['count'] ?? 0);
+ $newItems = ($counts[0]['count'] ?? 0); //get from site config
- if ($newComments > 0) {
- $this->count += $newComments;
- $this->menu['post'] = [];
- $this->menu['post']['badge'] = $newComments;
- $this->menu['post']['badge-class'] = 'badge bg-primary-subtle text-body mx-2';
+ if ($newItems > 0) {
+ $this->count += $newItems;
+ $this->menu[$menu]['badge'] = ($this->menu[$menu]['badge'] ?? 0) + $newItems;
+ $this->menu[$menu]['badge-class'] = 'badge bg-primary-subtle text-body mx-2';
- $this->menu['post']['items']['comments'] = [];
- $this->menu['post']['items']['comments']['badge'] = $newComments;
- $this->menu['post']['items']['comments']['badge-class'] = 'badge bg-primary-subtle text-body mx-2';
+ if ($menuItem) {
+ $this->menu[$menu]['items'][$menuItem]['badge'] = $newItems;
+ $this->menu[$menu]['items'][$menuItem]['badge-class'] = 'badge bg-primary-subtle text-body mx-2';
+ }
}
- $url = ['module' => 'content/comments'];
+ $url = ['module' => $module];
- foreach ($commentCount as $type => $comments) {
- $comments['icon'] = 'la la-comment';
- $comments['badge'] = commentStatusBadgeClass($comments['status']);
- $comments['url'] = url($url + ['status' => $comments['status']]);
- $commentCount[$comment_status[$type]] = $comments;
- unset($commentCount[$type]);
+ foreach ($counts as $type => $items) {
+ $items['icon'] = $icon;
+ $items['badge'] = commentStatusBadgeClass($items['status']);
+ $items['url'] = url($url + ['status' => $items['status']]);
+ $counts[$statusNames[$type] ?? $type] = $items;
+ unset($counts[$type]);
}
- $this->notifications['comments'] = $commentCount + $this->notifications['comments'];
+ $this->notifications[$key] = $counts + $this->notifications[$key];
}
- protected function reviews() {
- $reviewCount = $this->stats->getReviewsCount($this->options)['reviews'] ?? [];
- $comment_status = [
- 0 => 'pending',
- 1 => 'approved',
- 2 => 'spam',
- 3 => 'trash',
- ];
-
- $reviewStatsusNew = 0; //get from site config
- $newReviews = ($reviewCount[$reviewStatsusNew]['count'] ?? 0);
-
- if ($newReviews > 0) {
- $this->count += $newReviews;
- //$this->menu['product'] = [];
- $this->menu['product']['badge'] = $newReviews;
- $this->menu['product']['badge-class'] = 'badge bg-primary-subtle text-body mx-2';
-
- //$this->menu['product']['items']['reviews'] = [];
- $this->menu['product']['items']['reviews']['badge'] = $newReviews;
- $this->menu['product']['items']['reviews']['badge-class'] = 'badge bg-primary-subtle text-body mx-2';
- }
-
- $url = ['module' => 'product/product-reviews'];
-
- foreach ($reviewCount as $type => $reviews) {
- $reviews['icon'] = ' la la-comments';
- $reviews['badge'] = commentStatusBadgeClass($reviews['status']);
- $reviews['url'] = url($url + ['status' => $reviews['status']]);
- $reviewCount[$comment_status[$type]] = $reviews;
- unset($reviewCount[$type]);
- }
+ /**
+ * Gather comment notification counts and update menu badges.
+ *
+ * @return void
+ */
+ protected function comments(): void {
+ $commentCount = $this->stats->getCommentsCount($this->options)['comments'] ?? [];
- $this->notifications['reviews'] = $reviewCount + $this->notifications['reviews'];
+ $this->statusNotifications('comments', $commentCount, 'content/comments', 'message', 'post', 'comments');
}
- protected function questions() {
- $questionCount = $this->stats->getQuestionsCount($this->options)['questions'] ?? [];
- $comment_status = [
- 0 => 'pending',
- 1 => 'approved',
- 2 => 'spam',
- 3 => 'trash',
- ];
-
- $questionStatsusNew = 0; //get from site config
- $newQuestions = ($questionCount[$questionStatsusNew]['count'] ?? 0);
+ /**
+ * Gather review notification counts and update menu badges.
+ *
+ * @return void
+ */
+ protected function reviews(): void {
+ $reviewCount = $this->stats->getReviewsCount($this->options)['reviews'] ?? [];
- if ($newQuestions > 0) {
- $this->count += $newQuestions;
- //$this->menu['product'] = [];
- $this->menu['product']['badge'] = ($this->menu['product']['badge'] ?? 0) + $newQuestions;
- $this->menu['product']['badge-class'] = 'badge bg-primary-subtle text-body mx-2';
-
- //$this->menu['product']['items']['questions'] = [];
- $this->menu['product']['items']['questions']['badge'] = $newQuestions;
- $this->menu['product']['items']['questions']['badge-class'] = 'badge bg-primary-subtle text-body mx-2';
- }
-
- $url = ['module' => 'product/product-questions'];
+ $this->statusNotifications('reviews', $reviewCount, 'product/product-reviews', 'messages', 'product', 'reviews');
+ }
- foreach ($questionCount as $type => $questions) {
- $questions['icon'] = 'la la-question-circle';
- $questions['badge'] = commentStatusBadgeClass($questions['status']);
- $questions['url'] = url($url + ['status' => $questions['status']]);
- $questionCount[$comment_status[$type]] = $questions;
- unset($questionCount[$type]);
- }
+ /**
+ * Gather question notification counts and update menu badges.
+ *
+ * @return void
+ */
+ protected function questions(): void {
+ $questionCount = $this->stats->getQuestionsCount($this->options)['questions'] ?? [];
- $this->notifications['questions'] = $questionCount + $this->notifications['questions'];
+ $this->statusNotifications('questions', $questionCount, 'product/product-questions', 'help-circle', 'product', 'questions');
}
- function request(&$results, $index) {
+ /**
+ * Apply notification menu badges to the view menu on first request.
+ *
+ * @param array<string, mixed> $results Component results.
+ * @param int $index Request index.
+ *
+ * @return void
+ */
+ public function request(array &$results, int $index = 0): void {
//add menu notification count
- if ($results['menu'] && $index == 0) {
+ if ($results['menu'] && $index === 0) {
$view = View::getInstance();
if (isset($view->menu) && $view->menu) {
@@ -234,42 +242,46 @@ class Notifications extends ComponentBase {
}
}
- function results() {
+ /**
+ * Get aggregated notification results for orders, users, products, comments,
+ * reviews, questions, and system updates.
+ *
+ * @return array{notifications: array<string, mixed>, count: int, menu: array<string, mixed>}
+ */
+ public function results(): array {
// return [];
- $cache = Cache::getInstance();
-
$this->notifications = [
'updates' => [
- 'core' => ['hasUpdate' => 1, 'version' => '1.0'],
+ 'core' => ['hasUpdate' => 0, 'version' => V_VERSION],
],
'orders' => [
- 'processing' => ['count' => 0, 'icon' => 'icon-bag-handle-outline', 'badge' => 'bg-primary-subtle text-body'],
- 'complete' => ['count' => 0, 'icon' => 'icon-bag-handle-outline', 'badge' => 'bg-success-subtle text-body'],
- 'processed' => ['count' => 0, 'icon' => 'icon-bag-handle-outline', 'badge' => 'bg-secondary-subtle text-body'],
+ 'processing' => ['count' => 0, 'icon' => 'shopping-bag', 'badge' => 'bg-primary-subtle text-body'],
+ 'complete' => ['count' => 0, 'icon' => 'shopping-bag', 'badge' => 'bg-success-subtle text-body'],
+ 'processed' => ['count' => 0, 'icon' => 'shopping-bag', 'badge' => 'bg-secondary-subtle text-body'],
],
'users' => [
- 'month' => ['count' => 0, 'icon' => 'icon-person-outline', 'badge' => 'bg-secondary-subtle text-body'],
- 'year' => ['count' => 0, 'icon' => 'icon-person-outline', 'badge' => 'bg-secondary-subtle text-body'],
+ 'month' => ['count' => 0, 'icon' => 'user', 'badge' => 'bg-secondary-subtle text-body'],
+ 'year' => ['count' => 0, 'icon' => 'user', 'badge' => 'bg-secondary-subtle text-body'],
],
'products' => [
],
'comments' => [
- 'pending' => ['count' => 0, 'icon' => 'la la-comment', 'badge' => 'bg-primary-subtle text-body'],
- 'approved' => ['count' => 0, 'icon' => 'la la-comment', 'badge' => 'bg-secondary-subtle text-body'],
- 'spam' => ['count' => 0, 'icon' => 'la la-comment', 'badge' => 'bg-secondary-subtle text-body'],
- 'trash' => ['count' => 0, 'icon' => 'la la-comment', 'badge' => 'bg-secondary-subtle text-body'],
+ 'pending' => ['count' => 0, 'icon' => 'message', 'badge' => 'bg-primary-subtle text-body'],
+ 'approved' => ['count' => 0, 'icon' => 'message', 'badge' => 'bg-secondary-subtle text-body'],
+ 'spam' => ['count' => 0, 'icon' => 'message', 'badge' => 'bg-secondary-subtle text-body'],
+ 'trash' => ['count' => 0, 'icon' => 'message', 'badge' => 'bg-secondary-subtle text-body'],
],
'reviews' => [
- 'pending' => ['count' => 0, 'icon' => 'la la-comment', 'badge' => 'bg-primary-subtle text-body'],
- 'approved' => ['count' => 0, 'icon' => 'la la-comment', 'badge' => 'bg-secondary-subtle text-body'],
- 'spam' => ['count' => 0, 'icon' => 'la la-comment', 'badge' => 'bg-secondary-subtle text-body'],
- 'trash' => ['count' => 0, 'icon' => 'la la-comment', 'badge' => 'bg-secondary-subtle text-body'],
+ 'pending' => ['count' => 0, 'icon' => 'message', 'badge' => 'bg-primary-subtle text-body'],
+ 'approved' => ['count' => 0, 'icon' => 'message', 'badge' => 'bg-secondary-subtle text-body'],
+ 'spam' => ['count' => 0, 'icon' => 'message', 'badge' => 'bg-secondary-subtle text-body'],
+ 'trash' => ['count' => 0, 'icon' => 'message', 'badge' => 'bg-secondary-subtle text-body'],
],
'questions' => [
- 'pending' => ['count' => 0, 'icon' => 'la la-question-circle', 'badge' => 'bg-primary-subtle text-body'],
- 'approved' => ['count' => 0, 'icon' => 'la la-question-circle', 'badge' => 'bg-secondary-subtle text-body'],
- 'spam' => ['count' => 0, 'icon' => 'la la-question-circle', 'badge' => 'bg-secondary-subtle text-body'],
- 'trash' => ['count' => 0, 'icon' => 'la la-question-circle', 'badge' => 'bg-secondary-subtle text-body'],
+ 'pending' => ['count' => 0, 'icon' => 'help-circle', 'badge' => 'bg-primary-subtle text-body'],
+ 'approved' => ['count' => 0, 'icon' => 'help-circle', 'badge' => 'bg-secondary-subtle text-body'],
+ 'spam' => ['count' => 0, 'icon' => 'help-circle', 'badge' => 'bg-secondary-subtle text-body'],
+ 'trash' => ['count' => 0, 'icon' => 'help-circle', 'badge' => 'bg-secondary-subtle text-body'],
],
];
@@ -282,10 +294,10 @@ class Notifications extends ComponentBase {
$this->questions();
$update = new Update();
- $updates = $update->checkUpdates('core') ?? [];
+ //$updates = $update->checkUpdates('core') ?? [];
- $this->notifications['updates']['core'] = $updates;
- $this->count += max($updates['hasUpdate'] ?? 0, 0);
+ //$this->notifications['updates']['core'] = $updates;
+ //$this->count += max($updates['hasUpdate'] ?? 0, 0);
$results = [
'notifications' => $this->notifications,
@@ -293,7 +305,7 @@ class Notifications extends ComponentBase {
'menu' => $this->menu,
];
- list($results) = Event::trigger(__CLASS__, __FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
diff --git a/admin/component/order.php b/admin/component/order.php
old mode 100644
new mode 100755
diff --git a/admin/component/orders.php b/admin/component/orders.php
index a4d5b83..f3496b4 100755
--- a/admin/component/orders.php
+++ b/admin/component/orders.php
@@ -28,45 +28,52 @@ use Vvveb\System\Event;
use Vvveb\System\Images;
class Orders extends ComponentBase {
- public static $defaultOptions = [
+ /** @var array<string, mixed> Default options for order listing. */
+ public static array $defaultOptions = [
'start' => 0,
'limit' => 10,
- 'language_id' => NULL,
- 'site_id' => NULL,
- 'user_id' => NULL,
- 'email' => NULL,
- 'phone_number' => NULL,
- 'search' => NULL,
- 'id_manufacturer' => NULL,
- 'order_status' => NULL,
- 'order_status_id' => NULL,
- 'order_by' => NULL,
+ 'language_id' => null,
+ 'site_id' => null,
+ 'user_id' => null,
+ 'email' => null,
+ 'phone_number' => null,
+ 'search' => null,
+ 'id_manufacturer' => null,
+ 'order_status' => null,
+ 'order_status_id' => null,
+ 'order_by' => null,
'direction' => ['url', 'asc', 'desc'],
];
- public $options = [];
-
- function results() {
- $orders = new \Vvveb\Sql\OrderSQL();
-
- $results = $orders->getAll($this->options);
+ /** @var array<string, mixed> Resolved options for this component. */
+ public array $options = [];
+ /**
+ * Get orders with validated sort parameters, resolved images, and formatted totals.
+ *
+ * @return array<string, mixed> Orders with formatted prices and resolved images.
+ */
+ public function results(): array {
if (isset($this->options['order_by']) &&
- ! in_array($this->options['order_by'], ['order_id', 'customer_order_id', 'order_status_id', 'created_at'])) {
+ !in_array($this->options['order_by'], ['order_id', 'customer_order_id', 'order_status_id', 'created_at'])) {
unset($this->options['order_by']);
}
if (isset($this->options['direction']) &&
- ! in_array($this->options['direction'], ['asc', 'desc'])) {
+ !in_array($this->options['direction'], ['asc', 'desc'])) {
unset($this->options['direction']);
}
- if ($results['order']) {
+ $orders = new \Vvveb\Sql\OrderSQL();
+
+ $results = $orders->getAll($this->options) ?? [];
+
+ if (!empty($results['order'])) {
$currency = Currency::getInstance();
foreach ($results['order'] as $id => &$order) {
if (isset($order['images'])) {
- $order['images'] = json_decode($order['images'], 1);
+ $order['images'] = json_decode($order['images'], true);
foreach ($order['images'] as &$image) {
$image = Images::image('order', $image);
@@ -81,7 +88,7 @@ class Orders extends ComponentBase {
}
}
- list($results) = Event::trigger(__CLASS__, __FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
diff --git a/admin/component/posts.php b/admin/component/posts.php
index e25bae4..a66526a 100755
--- a/admin/component/posts.php
+++ b/admin/component/posts.php
@@ -28,25 +28,32 @@ use Vvveb\System\Event;
use Vvveb\System\Images;
class Posts extends ComponentBase {
- public static $defaultOptions = [
+ /** @var array<string, mixed> Default options for post listing. */
+ public static array $defaultOptions = [
'start' => 0,
'language_id' => 1,
'site_id' => 1,
'post_id' => 'url',
'limit' => ['url', 4],
- 'id_manufacturer' => NULL,
+ 'id_manufacturer' => null,
'order' => ['url', 'price asc'],
'id_category' => 'url',
];
- public $options = [];
+ /** @var array<string, mixed> Resolved options for this component. */
+ public array $options = [];
- function results() {
+ /**
+ * Get posts with image data resolved.
+ *
+ * @return array<string, mixed> Posts with resolved images.
+ */
+ public function results(): array {
$posts = new PostSQL();
- $results = $posts->getAll($this->options);
+ $results = $posts->getAll($this->options) ?? [];
- foreach ($results['post'] as $id => &$post) {
+ foreach ($results['post'] ?? [] as $id => &$post) {
if (isset($post['images'])) {
$post['images'] = json_decode($post['images'], true);
@@ -60,7 +67,7 @@ class Posts extends ComponentBase {
}
}
- list($results) = Event::trigger(__CLASS__, __FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
diff --git a/admin/component/product.php b/admin/component/product.php
old mode 100644
new mode 100755
diff --git a/admin/component/products.php b/admin/component/products.php
index 2acfefd..743ecf1 100755
--- a/admin/component/products.php
+++ b/admin/component/products.php
@@ -29,34 +29,36 @@ use Vvveb\System\Event;
use Vvveb\System\Images;
class Products extends ComponentBase {
- public static $defaultOptions = [
- 'start' => 0,
- 'limit' => 4,
- 'language_id' => 1,
- 'site_id' => 1,
- 'manufacturer_id'=> NULL,
- 'vendor_id' => NULL,
- 'related' => NULL,
- 'order' => ['url', 'price asc'],
- //'taxonomy_item_id'=> null,
- 'product_image' => true,
+ /** @var array<string, mixed> Default options for product listing. */
+ public static array $defaultOptions = [
+ 'start' => 0,
+ 'limit' => 4,
+ 'language_id' => 1,
+ 'site_id' => 1,
+ 'manufacturer_id' => null,
+ 'vendor_id' => null,
+ 'related' => null,
+ 'order' => ['url', 'price asc'],
+ 'product_image' => true,
];
- public $options = [];
+ /** @var array<string, mixed> Resolved options for this component. */
+ public array $options = [];
- function __construct($class = __CLASS__) {
- parent::__construct($class);
- }
-
- function results() {
+ /**
+ * Get products with pricing, tax, and image data.
+ *
+ * @return array<string, mixed> Products with formatted prices and images.
+ */
+ public function results(): array {
$products = new \Vvveb\Sql\ProductSQL();
- $results = $products->getAll($this->options);
+ $results = $products->getAll($this->options) ?? [];
- $results['product'] = $results['product'] ?? [];
+ $results['product'] ??= [];
if ($results['product']) {
- $tax = Tax::getInstance($this->options);
+ $tax = Tax::getInstance();
$currency = Currency::getInstance($this->options);
foreach ($results['product'] as $id => &$product) {
@@ -69,7 +71,7 @@ class Products extends ComponentBase {
}
if (isset($product['image']) && $product['image']) {
- $product['image'] =Images::image($product['image'], 'product');
+ $product['image'] = Images::image($product['image'], 'product');
}
$product['price_tax'] = $tax->addTaxes($product['price'], $product['tax_type_id']);
@@ -78,7 +80,7 @@ class Products extends ComponentBase {
}
}
- list($results) = Event :: trigger(__CLASS__,__FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
diff --git a/admin/component/site.php b/admin/component/site.php
old mode 100644
new mode 100755
diff --git a/admin/component/sites.php b/admin/component/sites.php
old mode 100755
new mode 100644
index 9548515..43dc858
--- a/admin/component/sites.php
+++ b/admin/component/sites.php
@@ -28,22 +28,35 @@ use Vvveb\System\Sites as SitesList;
use Vvveb\System\User\Admin;
class Sites extends ComponentBase {
- public static $defaultOptions = [
+ /** @var array{limit: int, page: int, site_access: int} Default options for site listing. */
+ public static array $defaultOptions = [
'limit' => 1000,
'page' => 1,
'site_access' => 1,
];
- protected $options = [];
+ /** @var array<string, mixed> Resolved options for this component. */
+ protected array $options = [];
- public $cacheExpire = 0; //seconds
+ /** @var int Cache expiry time in seconds (0 = disabled). */
+ public int $cacheExpire = 0;
- function cacheKey() {
+ /**
+ * Disable caching for this component.
+ *
+ * @return string|null Always returns false to disable caching.
+ */
+ public function cacheKey(): ?string {
//disable caching
- return false;
+ return null;
}
- function results() {
+ /**
+ * Get all sites filtered by admin site access, with active site and states.
+ *
+ * @return array{sites: array<int, mixed>, states: array<string, mixed>, site_id: mixed, active: array<string, mixed>, count: int}
+ */
+ public function results(): array {
$results = [];
$results['sites'] = SitesList::getSites();
@@ -57,14 +70,14 @@ class Sites extends ComponentBase {
if ($site_access) {
foreach ($results['sites'] as $key => $site) {
- if (! in_array($site['site_id'], $site_access)) {
+ if (!in_array($site['site_id'], $site_access)) {
unset($results['sites'][$key]);
}
}
}
}
- list($results) = Event :: trigger(__CLASS__,__FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
diff --git a/admin/component/states.php b/admin/component/states.php
old mode 100755
new mode 100644
index 43aa819..c83f697
--- a/admin/component/states.php
+++ b/admin/component/states.php
@@ -28,19 +28,32 @@ use Vvveb\System\Event;
use Vvveb\System\Sites;
class States extends ComponentBase {
- public static $defaultOptions = [
+ /** @var array<string, mixed> Default options (empty for states). */
+ public static array $defaultOptions = [
];
- protected $options = [];
+ /** @var array<string, mixed> Resolved options for this component. */
+ protected array $options = [];
- public $cacheExpire = 0; //seconds
+ /** @var int Cache expiry time in seconds (0 = disabled). */
+ public int $cacheExpire = 0;
- function cacheKey() {
+ /**
+ * Disable caching for this component.
+ *
+ * @return string|null Always returns false to disable caching.
+ */
+ public function cacheKey(): ?string {
//disable caching
- return false;
+ return null;
}
- function results() {
+ /**
+ * Get application states (e.g. live, maintenance) with active state info.
+ *
+ * @return array{active_name: string, active_icon: string, states: array<string, mixed>, active: string}
+ */
+ public function results(): array {
$states = Sites::getStates();
$active = sess('state') ?? 'live';
$results['active_name'] = $states[$active]['name'];
@@ -49,7 +62,7 @@ class States extends ComponentBase {
$results['states'] = $states;
$results['active'] = $active;
- list($results) = Event :: trigger(__CLASS__,__FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
diff --git a/admin/component/stats.php b/admin/component/stats.php
index 6ed7ecc..de64c7f 100755
--- a/admin/component/stats.php
+++ b/admin/component/stats.php
@@ -27,7 +27,8 @@ use Vvveb\System\Component\ComponentBase;
use Vvveb\System\Event;
class Stats extends ComponentBase {
- public static $defaultOptions = [
+ /** @var array<string, mixed> Default options for statistics query. */
+ public static array $defaultOptions = [
'start' => 0,
'limit' => 10,
'language_id' => null,
@@ -38,27 +39,33 @@ class Stats extends ComponentBase {
'range' => 'day', //day, week, month, year
];
- public $options = [];
+ /** @var array<string, mixed> Resolved options for this component. */
+ public array $options = [];
- function results() {
+ /**
+ * Get chart data with labels, user counts, and order counts.
+ *
+ * @return array{labels: array<int, string>, users: array<int, int>, orders: array<int, int>}
+ */
+ public function results(): array {
$stats = new StatSQL();
- if ($this->options['end_date'] == 'NOW()') {
+ if (($this->options['end_date'] ?? '') === 'NOW()') {
$this->options['end_date'] = date('Y-m-d');
}
- if ($this->options['start_date'] == 'NOW()') {
+ if (($this->options['start_date'] ?? '') === 'NOW()') {
$this->options['start_date'] = date('Y-m-d');
}
- $results = $stats->getStats($this->options);
+ $results = $stats->getStats($this->options) ?? [];
$data = [];
- foreach ($results['orders'] as $order) {
+ foreach ($results['orders'] ?? [] as $order) {
$data[$order['date']]['orders'] = $order['orders'];
}
- foreach ($results['users'] as $order) {
+ foreach ($results['users'] ?? [] as $order) {
$data[$order['date']]['users'] = $order['users'];
}
@@ -73,10 +80,8 @@ class Stats extends ComponentBase {
$orders[] = $stat['orders'] ?? 0;
}
- list($labels, $users, $orders) = Event :: trigger(__CLASS__,__FUNCTION__, $labels, $users, $orders);
+ [$labels, $users, $orders] = Event::trigger(__CLASS__, __FUNCTION__, $labels, $users, $orders);
return ['labels' => $labels, 'users' => $users, 'orders' => $orders];
-
- return $results;
}
}
diff --git a/admin/component/user/wishlist.php b/admin/component/user/wishlist.php
old mode 100644
new mode 100755
index 133f00c..f5ec13c
--- a/admin/component/user/wishlist.php
+++ b/admin/component/user/wishlist.php
@@ -22,28 +22,39 @@
namespace Vvveb\Component\User;
-use Vvveb\Sql\User_WishlistSQL;
+use Vvveb\Sql\User_wishlistSQL;
use Vvveb\System\Component\ComponentBase;
use Vvveb\System\Event;
use function Vvveb\url;
class Wishlist extends ComponentBase {
- public static $defaultOptions = [
- 'start' => 0,
- 'limit' => 10,
+ /** @var array{start: int, limit: int} Default options for wishlist listing. */
+ public static array $defaultOptions = [
+ 'start' => 0,
+ 'limit' => 10,
];
- //don't cache
- function cacheKey() {
- return false;
+ /**
+ * Disable caching for this component.
+ *
+ * @return string|null Always returns false to disable caching.
+ */
+ public function cacheKey(): ?string {
+ //don't cache
+ return null;
}
- function results() {
+ /**
+ * Get wishlist items for the current user with edit/delete URLs.
+ *
+ * @return array<string, mixed> Wishlist data with item URLs.
+ */
+ public function results(): array {
$results = [];
if ($this->options['user_id']) {
- $wishlist = new User_WishlistSQL();
- $results = $wishlist->getAll($this->options);
+ $wishlist = new User_wishlistSQL();
+ $results = $wishlist->getAll($this->options) ?? [];
if ($results && isset($results['wishlist'])) {
foreach ($results['wishlist'] as $id => &$wishlist) {
@@ -53,12 +64,8 @@ class Wishlist extends ComponentBase {
}
}
- list($results) = Event :: trigger(__CLASS__,__FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
-
- //called on each request
- function request($results, $index = 0) {
- }
}
diff --git a/admin/component/users.php b/admin/component/users.php
index 33f52d2..4bda569 100755
--- a/admin/component/users.php
+++ b/admin/component/users.php
@@ -28,37 +28,44 @@ use Vvveb\System\Event;
use Vvveb\System\Images;
class Users extends ComponentBase {
- public static $defaultOptions = [
- 'start' => 0,
- 'limit' => 10,
- 'site_id' => null,
- 'user_id' => 'url',
- 'user' => ['url', 'price asc'],
- 'order_by' => NULL,
- 'direction' => ['url', 'asc', 'desc'],
+ /** @var array<string, mixed> Default options for user listing. */
+ public static array $defaultOptions = [
+ 'start' => 0,
+ 'limit' => 10,
+ 'site_id' => null,
+ 'user_id' => 'url',
+ 'user' => ['url', 'price asc'],
+ 'order_by' => null,
+ 'direction' => ['url', 'asc', 'desc'],
];
- public $options = [];
-
- function results() {
- $users = new UserSQL();
-
- $results = $users->getAll($this->options);
+ /** @var array<string, mixed> Resolved options for this component. */
+ public array $options = [];
+ /**
+ * Get users with validated sort parameters and resolved images.
+ *
+ * @return array<string, mixed> Users with resolved images.
+ */
+ public function results(): array {
if (isset($this->options['order_by']) &&
- ! in_array($this->options['order_by'], ['user_id', 'created_at', 'email', 'username'])) {
+ !in_array($this->options['order_by'], ['user_id', 'created_at', 'email', 'username'])) {
unset($this->options['order_by']);
}
if (isset($this->options['direction']) &&
- ! in_array($this->options['direction'], ['asc', 'desc'])) {
+ !in_array($this->options['direction'], ['asc', 'desc'])) {
unset($this->options['direction']);
}
+ $users = new UserSQL();
+
+ $results = $users->getAll($this->options) ?? [];
+
if (isset($results['user'])) {
foreach ($results['user'] as $id => &$user) {
if (isset($user['images'])) {
- $user['images'] = json_decode($user['images'], 1);
+ $user['images'] = json_decode($user['images'], true);
foreach ($user['images'] as &$image) {
$image = Images::image('user', $image);
@@ -71,7 +78,7 @@ class Users extends ComponentBase {
}
}
- list($results) = Event :: trigger(__CLASS__,__FUNCTION__, $results);
+ [$results] = Event::trigger(__CLASS__, __FUNCTION__, $results);
return $results;
}
diff --git a/admin/controller/editor/autocomplete.php b/admin/controller/editor/autocomplete.php
index 2076cfe..fbe2005 100755
--- a/admin/controller/editor/autocomplete.php
+++ b/admin/controller/editor/autocomplete.php
@@ -23,18 +23,21 @@
namespace Vvveb\Controller\Editor;
use Vvveb\Controller\Base;
-use Vvveb\Sql\categorySQL;
+use Vvveb\Sql\CategorySQL;
class Autocomplete extends Base {
- private $themeConfig = [];
-
- function products() {
+ /**
+ * Returns product autocomplete suggestions as JSON.
+ *
+ * @return void
+ */
+ public function products(): void {
$text = $this->request->get['text'];
$options = [
- 'start' => 0,
- 'limit' => 10,
- 'like' => $text,
+ 'start' => 0,
+ 'limit' => 10,
+ 'like' => $text,
] + $this->global;
unset($options['admin_id']);
@@ -51,7 +54,12 @@ class Autocomplete extends Base {
$this->response->output($search);
}
- function categories() {
+ /**
+ * Returns category autocomplete suggestions as JSON.
+ *
+ * @return void
+ */
+ public function categories(): void {
$text = $this->request->get['text'];
$options = [
@@ -74,7 +82,12 @@ class Autocomplete extends Base {
$this->response->output($search);
}
- function manufacturers() {
+ /**
+ * Returns manufacturer autocomplete suggestions as JSON.
+ *
+ * @return void
+ */
+ public function manufacturers(): void {
$text = $this->request->get['text'];
$options = [
@@ -97,15 +110,20 @@ class Autocomplete extends Base {
$this->response->output($search);
}
- function posts() {
+ /**
+ * Returns post autocomplete suggestions as JSON.
+ *
+ * @return void
+ */
+ public function posts(): void {
$text = $this->request->get['text'];
$type = $this->request->get['type'] ?? 'post';
$options = [
- 'start' => 0,
- 'limit' => 10,
- 'type' => $type,
- 'like' => $text,
+ 'start' => 0,
+ 'limit' => 10,
+ 'type' => $type,
+ 'like' => $text,
//'like' => '%' . $text . '%',
] + $this->global;
@@ -117,7 +135,7 @@ class Autocomplete extends Base {
if (isset($results['post'])) {
foreach ($results['post'] as $post) {
- $search[$post['post_id']] = substr($post['name'],0, 50);
+ $search[$post['post_id']] = substr($post['name'], 0, 50);
}
}
@@ -125,12 +143,18 @@ class Autocomplete extends Base {
$this->response->output($search);
}
- function tags() {
+ /**
+ * Returns tag autocomplete suggestions as JSON.
+ *
+ * @return void
+ */
+ public function tags(): void {
+ $post_id = $this->request->get['post_id'] ?? false;
$taxonomy_id = $this->request->get['taxonomy_id'];
$taxonomy = $this->request->get['taxonomy'];
$text = $this->request->get['text'];
- $taxonomy_itemSql = new categorySQL();
+ $taxonomy_itemSQL = new CategorySQL();
$options = [
'post_id' => $post_id,
@@ -142,11 +166,11 @@ class Autocomplete extends Base {
'search' => '%' . $text . '%',
] + $this->global;
- $results = $taxonomy_itemSql->getCategories($options + ['taxonomy_id' => $taxonomy_id]);
+ $results = $taxonomy_itemSQL->getCategories($options + ['taxonomy_id' => $taxonomy_id]);
$search = [];
- foreach ($results['categories'] as $id => &$taxonomy_item) {
+ foreach ($results['categories'] as $taxonomy_item) {
$search[$taxonomy_item['taxonomy_item_id']] = $taxonomy_item['name'];
}
diff --git a/admin/controller/editor/global-trait.php b/admin/controller/editor/global-trait.php
old mode 100644
new mode 100755
index 58ccdc0..448835e
--- a/admin/controller/editor/global-trait.php
+++ b/admin/controller/editor/global-trait.php
@@ -25,8 +25,16 @@ namespace Vvveb\Controller\Editor;
use function Vvveb\sanitizeFileName;
trait GlobalTrait {
- private function saveGlobalElements($content, $options = []) {
- $document = new \DomDocument();
+ /**
+ * Saves global elements (header/footer) from the editor page to their source files.
+ *
+ * @param string $content The HTML content to process.
+ * @param array<string, mixed> $options Options such as 'inline-css'.
+ *
+ * @return string The processed HTML content.
+ */
+ private function saveGlobalElements(string $content, array $options = []): string {
+ $document = new \DOMDocument();
$document->preserveWhiteSpace = true;
$document->recover = true;
$document->strictErrorChecking = false;
@@ -40,11 +48,11 @@ trait GlobalTrait {
@$document->loadHTML($content);
- $xpath = new \DOMXpath($document);
+ $xpath = new \DOMXPath($document);
$themeFolder = $this->getThemeFolder();
- if (! isset($options['inline-css']) || $options['inline-css'] == false) {
+ if (!isset($options['inline-css']) || $options['inline-css'] == false) {
//save vvvebjs css to custom.css
$style = $xpath->query('//style[ @id="vvvebjs-styles" ]');
$cssFile = $themeFolder . DS . 'css' . DS . 'custom.css';
@@ -68,7 +76,7 @@ trait GlobalTrait {
$elements = $xpath->query('//*[ @data-v-save-global ]');
if ($elements && $elements->length) {
- $toDocument = new \DomDocument();
+ $toDocument = new \DOMDocument();
$toDocument->preserveWhiteSpace = false;
$toDocument->recover = true;
$toDocument->strictErrorChecking = false;
@@ -78,14 +86,14 @@ trait GlobalTrait {
$toDocument->xmlStandalone = true;
foreach ($elements as $element) {
- if (! $element->hasChildNodes()) {
+ if (!$element->hasChildNodes()) {
continue;
}//skip empty elements
$attribute = $element->getAttribute('data-v-save-global');
- if (strpos($attribute, ',') !== false) {
- list($file, $selector) = explode(',', $attribute);
+ if (str_contains($attribute, ',')) {
+ [$file, $selector] = explode(',', $attribute);
$file = sanitizeFileName(html_entity_decode($file));
$selector = html_entity_decode($selector);
@@ -93,13 +101,13 @@ trait GlobalTrait {
$toDocument->loadHTMLFile($file);
- $toXpath = new \DOMXpath($toDocument);
- $xpath = \Vvveb\cssToXpath($selector);
- $toElements = $toXpath->query($xpath);
+ $toXpath = new \DOMXPath($toDocument);
+ $cssQuery = \Vvveb\cssToXpath($selector);
+ $toElements = $toXpath->query($cssQuery);
$count = 0;
- if ($elements && $elements->length) {
+ if ($toElements && $toElements->length) {
foreach ($toElements as $externalNode) {
$parent = $externalNode->parentNode;
@@ -112,7 +120,7 @@ trait GlobalTrait {
} else {
$parent->replaceChild($importedNode, $externalNode);
}*/
- if (! $parent->replaceChild($importedNode, $externalNode)) {
+ if (!$parent->replaceChild($importedNode, $externalNode)) {
$externalNode->replaceWith($importedNode);
}
@@ -133,8 +141,6 @@ trait GlobalTrait {
}
}
- $content= $document->saveHTML();
-
- return $content;
+ return $document->saveHTML();
}
}
diff --git a/admin/controller/editor/editor.php b/admin/controller/editor/page-builder.php
old mode 100755
new mode 100644
similarity index 52%
rename from admin/controller/editor/editor.php
rename to admin/controller/editor/page-builder.php
index 51621b4..81d920f
--- a/admin/controller/editor/editor.php
+++ b/admin/controller/editor/page-builder.php
@@ -22,13 +22,14 @@
namespace Vvveb\Controller\Editor;
-use \Vvveb\Sql\menuSQL;
use function Vvveb\__;
use Vvveb\Controller\Base;
use function Vvveb\getUrl;
use function Vvveb\model;
+use function Vvveb\removeJsonComments;
use function Vvveb\sanitizeFileName;
use function Vvveb\slugify;
+use Vvveb\Sql\MenuSQL;
use Vvveb\Sql\PostSQL;
use Vvveb\Sql\ProductSQL;
use Vvveb\System\Cache;
@@ -39,116 +40,176 @@ use Vvveb\System\PageCache;
use Vvveb\System\Sites;
use function Vvveb\url;
-class Editor extends Base {
+class PageBuilder extends Base {
use GlobalTrait;
- protected $revisionDateFormat = 'Y-m-d_H:i:s';
+ /**
+ * @var string Date format for page revisions.
+ */
+ protected string $revisionDateFormat = 'Y-m-d_H:i:s';
- private $themeConfig = [];
+ /**
+ * @var array<string, mixed> Theme configuration.
+ */
+ private array $themeConfig = [];
- private $skipFolders = ['src', 'source', 'backup', 'import'];
+ /**
+ * @var array<int, string> Folders to skip during file operations.
+ */
+ private array $skipFolders = ['src', 'source', 'backup', 'import'];
- private $skipFiles = [];
+ /**
+ * @var array<int, string> Files to skip.
+ */
+ private array $skipFiles = [];
- function init() {
+ /**
+ * Initializes the controller and loads theme configuration.
+ *
+ * @return string|null
+ */
+ public function init(): ?string {
$return = parent::init();
$this->loadThemeConfig();
return $return;
}
- function oEmbedProxy() {
- $url = $this->request->get['url'];
+ /**
+ * Proxy for oEmbed requests.
+ *
+ * @return void
+ */
+ public function oEmbedProxy(): void {
+ $url = $this->request->get['url'] ?? '';
- if (! $url) {
+ if (!$url) {
return;
}
- $result = getUrl($url, false);
+ $result = getUrl($url);
$this->response->setType('json');
$this->response->output($result);
}
- private function getTheme() {
- return $theme = sanitizeFileName($this->request->get['theme'] ?? Sites::getTheme($this->global['site_id']) ?? 'default');
+ /**
+ * Gets the current active theme name.
+ *
+ * @return string Active theme name.
+ */
+ private function getTheme(): string {
+ return sanitizeFileName($this->request->get['theme'] ?? Sites::getTheme($this->global['site_id']));
}
- private function getThemeFolder() {
+ /**
+ * Gets the theme directory folder path.
+ *
+ * @return string Theme folder path.
+ */
+ private function getThemeFolder(): string {
return DIR_THEMES . $this->getTheme();
}
- private function loadThemeConfig() {
- $config = $this->getThemeFolder() . DS . 'theme.php';
-
- if (file_exists($config)) {
- $this->themeConfig = include $config;
+ /**
+ * Loads the theme configuration.
+ *
+ * @return void
+ */
+ private function loadThemeConfig(): void {
+ $configFile = $this->getThemeFolder() . DS . 'theme.json';
+ $this->themeConfig = [];
+
+ if (file_exists($configFile) &&
+ ($json = file_get_contents($configFile)) &&
+ $config = json_decode(removeJsonComments($json), true)) {
+ $this->themeConfig = $config;
} else {
//default config
- $this->themeConfig = [];
+ $this->themeConfig = [
+ 'cssFramework' => 'bootstrap5', //vanilla or empty, bootstrap, tailwind, bulma etc
+ 'jsFramework' => 'vanilla', //vanilla or empty, react, vue etc
+ ];
}
}
- private function loadTemplateList($theme = null) {
+ /**
+ * Loads the template list for the specified theme.
+ *
+ * @param string|null $theme Theme name.
+ *
+ * @return array<string, mixed> Template list.
+ */
+ private function loadTemplateList(?string $theme = null): array {
$list = $this->themeConfig['pages'] ?? [];
- $pages = $list + Cache::getInstance()->cache(APP, 'template-list-' . $theme,
- function () use ($theme) {
+ $pages = $list + Cache::getInstance()->cache(
+ APP,
+ 'template-list-' . $theme,
+ function() use ($theme) {
$templates = \Vvveb\getTemplateList($theme);
//add a prefix for templates like 404 to avoid showing them first
foreach ($templates as $key => $template) {
- if (is_numeric($key) || is_numeric($key[0])) {
+ if (is_numeric($key) || ($key !== '' && is_numeric($key[0]))) {
unset($templates[$key]);
$templates["t-$key"] = $template;
}
}
return $templates;
- }, 604800);
+ },
+ 604800
+ );
- list($pages) = Event::trigger(__CLASS__, __FUNCTION__, $pages);
+ [$pages] = Event::trigger(__CLASS__, __FUNCTION__, $pages);
return $pages;
}
- private function clearTemplateListCache($theme = null) {
+ /**
+ * Clears the template list cache for the specified theme.
+ *
+ * @param ?string $theme Theme name.
+ *
+ * @return bool True on success, false on failure.
+ */
+ private function clearTemplateListCache(?string $theme = null): bool {
return Cache::getInstance()->delete(APP, 'template-list-' . sanitizeFileName($theme));
}
- private function loadEditorData() {
+ /**
+ * Loads editor data, such as menus.
+ *
+ * @return array<string, mixed> Loaded editor data.
+ */
+ private function loadEditorData(): array {
$data = [];
//menu list
- $menuSql = new \Vvveb\Sql\menuSQL();
- $results = $menuSql->getAll($this->global);
+ $menuSQL = new MenuSQL();
+ $results = $menuSQL->getAll($this->global);
$data += $results;
- list($data) = Event::trigger(__CLASS__, __FUNCTION__, $data);
+ [$data] = Event::trigger(__CLASS__, __FUNCTION__, $data);
return $data;
}
- /*
- Load theme sections, components and inputs
- */
- private function loadEditorAssets() {
- }
-
- /*
- Load theme sections, components and inputs
+ /**
+ * Loads theme sections, components, inputs, and styles.
+ *
+ * @return void
*/
- private function loadThemeAssets() {
+ private function loadThemeAssets(): void {
$themeFolder = $this->getThemeFolder();
$view = &$this->view;
- $themeJs = [];
$assets = [];
foreach (['inputs', 'components', 'blocks', 'sections', 'styles'] as $type) {
- $$type = [];
- $glob = glob("$themeFolder/$type/*.js");
+ $glob = glob("$themeFolder/$type/*.js") ?: [];
foreach ($glob as &$file) {
- $base = str_replace('.js', '', basename($file));
+ $base = str_replace('.js', '', basename($file));
$assets[$type][$base] = str_replace($themeFolder, $view->themeBaseUrl, $file);
}
}
@@ -159,21 +220,33 @@ class Editor extends Base {
$assets['js']['vvvebjs'] = $view->themeBaseUrl . $vvvebJs;
}
- list($assets) =
+ [$assets] =
Event::trigger(__CLASS__, __FUNCTION__, $assets);
foreach ($assets as $type => $files) {
- $name = 'theme' . ucfirst($type); //themeSections
+ $name = 'theme' . ucfirst($type); //themeSections
$view->$name = $files;
}
}
- function proxy() {
- }
-
- protected function pages($theme = false, $urlParams = '') {
+ /**
+ * Proxy handler (currently empty stub).
+ *
+ * @return void
+ */
+ public function proxy(): void {}
+
+ /**
+ * Loads list of pages and updates the view pages configuration.
+ *
+ * @param string|false $theme Theme name or false.
+ * @param string $urlParams URL parameter string.
+ *
+ * @return void
+ */
+ protected function pages(string|false $theme = false, string $urlParams = ''): void {
$view = View::getInstance();
- $view->pages = $view->pages ?? $this->loadTemplateList($theme);
+ $view->pages ??= $this->loadTemplateList($theme);
$this->posts = new PostSQL();
$options = [
@@ -187,11 +260,11 @@ class Editor extends Base {
if ($results && isset($results['post'])) {
foreach ($results['post'] as $post) {
//skip posts without translations
- if (! isset($post['slug']) || ! isset($post['name'])) {
+ if (!isset($post['slug']) || !isset($post['name'])) {
continue;
}
- $slug = htmlspecialchars($post['slug']);
+ $slug = htmlspecialchars($post['slug']);
$params = ['slug' => $slug, 'post_id' => $post['post_id']];
if ($this->global['path']) {
$params['path'] = '/' . $this->global['path'];
@@ -199,10 +272,11 @@ class Editor extends Base {
$url = url('content/page/index', $params);
+ $templateFile = $post['template'] ?: 'content/page.html';
$posts["$slug-page"] = [
'name' => "$slug-page",
- 'file' => $post['template'] ? $post['template'] : 'content/page.html',
- 'filename' => $post['template'] ? $post['template'] : 'content/page.html',
+ 'file' => $templateFile,
+ 'filename' => $templateFile,
'url' => $url . ($theme ? '?theme=' . $theme : '') . $urlParams,
'title' => htmlspecialchars($post['name']),
'post_id' => $post['post_id'],
@@ -217,14 +291,20 @@ class Editor extends Base {
}
}
- function index() {
+ /**
+ * Main index action for the editor.
+ * Sets up template lists, endpoint URLs, and loads requested templates.
+ *
+ * @return void
+ */
+ public function index(): void {
$theme = $this->getTheme();
$themeParam = (isset($this->request->get['theme']) ? '&theme=' . $theme : '');
$view = View::getInstance();
$view->themeBaseUrl = PUBLIC_PATH . 'themes/' . $theme . '/';
$view->themeName = $theme;
- $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 = [];
@@ -250,145 +330,77 @@ class Editor extends Base {
$this->pages(isset($this->request->get['theme']) ? $theme : false, $urlParams);
- $homeUrl = (V_SUBDIR_INSTALL ?: '') . '/' . ($this->global['path'] ? $this->global['path'] : '');
+ $homeUrl = V_SUBDIR_INSTALL . '/' . ($this->global['path'] ?: '');
$url = sanitizeFileName($this->request->get['url'] ?? $homeUrl, false);
$name = $this->request->get['name'] ?? '';
- $template = $this->request->get['template'] ?? ''; //\Vvveb\getUrlTemplate($url) ?? 'index.html';
+ $template = $this->request->get['template'] ?? '';
$folder = $this->request->get['folder'] ?? false;
$route = \Vvveb\getUrlRoute($url);
$className = 'url';
$current_page = [];
$site_name = '';
- if ($url == $homeUrl && ! $template) {
- $site = Sites :: getSiteData($this->global['site_id']);
- $template = ($site['template'][$this->global['language_id']] ?? $site['template'][0] ?? '') ?: 'index.html';
- $site_name = $site['name'];
+ if ($url === $homeUrl && !$template) {
+ $site = Sites::getSiteData($this->global['site_id']);
+
+ if ($site) {
+ $template = ($site['template'][$this->global['language_id']] ?? $site['template'][0] ?? '') ?: 'index.html';
+ $site_name = $site['name'] ?? '';
+ } else {
+ $template = 'index.html';
+ }
}
$file = $template;
//check if url and template is relative
- if (strpos($url, '//') !== false && strpos($template, '..') !== false) {
+ if (str_contains($url, '//') || str_contains($template, '..')) {
$this->notFound();
-
- exit();
}
//check if the url has extension and is a html file and exists in the theme folder
- if (strpos($url, '.') !== false) {
- if (substr_compare($url, '.html', -5 ,5) === 0) {
- //check if plugin template exists
- if (substr_compare($url, '/plugins/', 0 ,9) === 0) {
- $pluginFile = substr($url, 9);
- $pluginFile = preg_replace('@^(.+/)@', '$1/public/',$pluginFile);
- if (! file_exists(DIR_PLUGINS . $pluginFile)) {
- $this->notFound(sprintf(__('%s does not exist!'), $pluginFile));
- exit();
- }
- } else {
- //check if theme template exists
- $relative = preg_replace('@.+themes/[^\/]+/@', '', $url);
-
- if (! file_exists(DIR_THEMES . $theme . DS . $relative)) {
- $this->notFound(sprintf(__('%s does not exist!'), $relative));
- exit();
- }
- }
+ if (str_contains($url, '.')) {
+ if (str_ends_with($url, '.html')) {
+ $this->validateTemplateExists($url, $theme);
} else {
$this->notFound(sprintf(__('%s does not exist!'), $url));
- exit();
}
}
//check if template belongs to theme and is a html file
- if (substr_compare($template, '.html', -5 ,5) === 0) {
- //check if plugin template exists
- if (substr_compare($template, '/plugins/', 0 ,9) === 0) {
- $pluginFile = substr($template, 9);
- $pluginFile = preg_replace('@^(.+/)@', '$1/public/', $pluginFile);
- if (! file_exists(DIR_PLUGINS . $pluginFile)) {
- $this->notFound(sprintf(__('%s does not exist!'), $pluginFile));
- exit();
- }
- } else {
- //check if theme template exists
- if (! file_exists(DIR_THEMES . $theme . DS . $template)) {
- $this->notFound(sprintf(__('%s does not exist!'), $template));
- exit();
- }
- }
+ if (str_ends_with($template, '.html')) {
+ $this->validateTemplateExists($template, $theme);
} else {
$this->notFound(sprintf(__('%s does not exist!'), __('template')));
- exit();
}
if ($route && isset($route['module'])) {
- switch ($route['module']) {
- case 'product/product/index':
- $className = 'product';
-
- if (isset($route['product_id'])) {
- $current_page['product_id'] = $route['product_id'];
- } else {
- if (isset($this->request->get['product_id'])) {
- $current_page['product_id'] = $this->request->get['product_id'];
- } else {
- if (isset($route['slug'])) {
- $current_page['slug'] = htmlspecialchars($route['slug']);
- }
- }
- }
-
- break;
-
- case 'content/post/index':
- case 'content/page/index':
- $className = 'page';
-
- if (isset($route['post_id'])) {
- $current_page['post_id'] = $route['post_id'];
- } else {
- if (isset($this->request->get['post_id'])) {
- $current_page['post_id'] = $this->request->get['post_id'];
- } else {
- if (isset($route['slug'])) {
- $current_page['slug'] = htmlspecialchars($route['slug']);
- }
- }
- }
-
- break;
- }
+ $className = $this->routeToClassName($route, $current_page);
}
$key = slugify($url);
$slug = slugify(str_replace('.html', '', $template));
- if (! $name) {
+ if (!$name) {
//if in page list get pretty name
if (isset($view->pages[$slug])) {
$name = $view->pages[$slug]['title'];
} else {
$name = \Vvveb\humanReadable($url);
- if (! $name) {
+ if (!$name) {
$name = $slug;
}
}
}
- if ($url == $homeUrl) {
+ if ($url === $homeUrl) {
$key = $slug = 'index';
if ($site_name) {
$name .= ' - ' . $site_name;
}
}
- $global = false;
-
- if ($file == 'index.html') {
- $global = true;
- }
+ $global = ($file === 'index.html');
$current_page += [
'name' => $key,
@@ -403,17 +415,33 @@ class Editor extends Base {
$view->pages = [$key => $current_page] + $view->pages;
+ $this->setEditorUrls($themeParam);
//encrypted key for component render requests
- $key = \Vvveb\getConfig('app.key');
- $keyData = $this->global['admin_id'] . '-' . $this->global['site_id'];
- $view->userKey = \Vvveb\encrypt($key, $keyData);
- $view->adminId = $this->global['admin_id'];
+ $key = \Vvveb\getConfig('app.key');
+ $keyData = $this->global['admin_id'] . '-' . $this->global['site_id'];
+ $view->userKey = \Vvveb\encrypt($key, $keyData);
+ $view->adminId = $this->global['admin_id'];
+
+ $view->cssFramework = $this->themeConfig['cssFramework'] ?? 'bootstrap5';
+ $view->jsFramework = $this->themeConfig['jsFramework'] ?? 'vanilla';
+ $view->templates = \Vvveb\getTemplateList($theme);
+ $view->folders = \Vvveb\getThemeFolderList($theme);
+ $view->data = $this->loadEditorData();
+ }
- $admin_path = \Vvveb\adminPath();
- $mediaControllerPath = $admin_path . 'index.php?module=media/media';
- $controllerPath = $admin_path . 'index.php?module=editor/editor' . $themeParam;
- $revisionsPath = $admin_path . 'index.php?module=editor/revisions' . $themeParam;
- $reusablePath = $admin_path . 'index.php?module=editor/reusable' . $themeParam;
+ /**
+ * Set all editor/media/revisions endpoint URLs on the view.
+ *
+ * @param string $themeParam The theme query-string parameter (e.g. '&theme=default').
+ *
+ * @return void
+ */
+ private function setEditorUrls(string $themeParam): void {
+ $admin_path = \Vvveb\adminPath();
+ $mediaControllerPath = $admin_path . 'index.php?module=media/media';
+ $controllerPath = $admin_path . 'index.php?module=editor/page-builder' . $themeParam;
+ $revisionsPath = $admin_path . 'index.php?module=editor/revisions' . $themeParam;
+ $reusablePath = $admin_path . 'index.php?module=editor/reusable' . $themeParam;
//media endpoints
$this->view->scanUrl = "$mediaControllerPath&action=scan";
@@ -434,23 +462,103 @@ class Editor extends Base {
$this->view->revisionLoadUrl = "$revisionsPath&action=load";
$this->view->revisionDeleteUrl = "$revisionsPath&action=delete";
$this->view->linkUrl = $admin_path . 'index.php?module=content/post&action=urlAutocomplete&type=key-value';
- $view->templates = \Vvveb\getTemplateList($theme);
- $view->folders = \Vvveb\getThemeFolderList($theme);
- $view->data = $this->loadEditorData();
}
- private function backup($page) {
+ /**
+ * Compute the relative base path (../) for a file based on its folder depth.
+ *
+ * @param string $fileBase The file path including folder prefix.
+ *
+ * @return string The relative base (e.g. '../../' for 2 levels deep).
+ */
+ private function computeRelativeBase(string $fileBase): string {
+ $relativeBase = '';
+ $pos = 0;
+
+ if ($fileBase) {
+ while (($pos = strpos($fileBase, '/', $pos + 1)) !== false) {
+ $relativeBase .= '../';
+ }
+ }
+
+ return $relativeBase;
+ }
+
+ /**
+ * Check that a template file (plugin or theme) exists, or call notFound + exit.
+ *
+ * @param string $path The template path to check (URL or template name).
+ * @param string $theme The active theme name.
+ *
+ * @return void
+ */
+ private function validateTemplateExists(string $path, string $theme): void {
+ if (str_starts_with($path, '/plugins/')) {
+ $pluginFile = substr($path, 9);
+ $pluginFile = preg_replace('@^(.+/)@', '$1/public/', $pluginFile);
+
+ if (!file_exists(DIR_PLUGINS . $pluginFile)) {
+ $this->notFound(sprintf(__('%s does not exist!'), $pluginFile));
+ }
+ } else {
+ //strip theme prefix from URL paths; bare template names pass through unchanged
+ $relative = preg_replace('@.+themes/[^\/]+/@', '', $path);
+
+ if (!file_exists(DIR_THEMES . $theme . DS . $relative)) {
+ $this->notFound(sprintf(__('%s does not exist!'), $relative));
+ }
+ }
+ }
+
+ /**
+ * Map a resolved route to a CSS className and populate current_page identifiers.
+ *
+ * @param array<string, mixed> $route The resolved route array.
+ * @param array<string, mixed> $current_page Current-page array (modified in-place).
+ *
+ * @return string The className ('product', 'page', or 'url').
+ */
+ private function routeToClassName(array $route, array &$current_page): string {
+ $idKey = 'post_id';
+ $className = 'page';
+
+ if ($route['module'] === 'product/product/index') {
+ $className = 'product';
+ $idKey = 'product_id';
+ } elseif ($route['module'] !== 'content/post/index' && $route['module'] !== 'content/page/index') {
+ return 'url';
+ }
+
+ if (isset($route[$idKey])) {
+ $current_page[$idKey] = $route[$idKey];
+ } elseif (isset($this->request->get[$idKey])) {
+ $current_page[$idKey] = $this->request->get[$idKey];
+ } elseif (isset($route['slug'])) {
+ $current_page['slug'] = htmlspecialchars($route['slug']);
+ }
+
+ return $className;
+ }
+
+ /**
+ * Creates a backup copy of a page.
+ *
+ * @param string $page Page name/file.
+ *
+ * @return int|false Bytes written or false on failure.
+ */
+ private function backup(string $page): int|false {
$themeFolder = $this->getThemeFolder() . DS;
$backupFolder = $themeFolder . 'backup' . DS;
$page = str_replace('.html', '', sanitizeFileName($page));
- $backupName = str_replace(DS, '-', $page) . '@' . str_replace(':',';', date($this->revisionDateFormat)) . '.html';
+ $backupName = str_replace(DS, '-', $page) . '@' . str_replace(':', ';', date($this->revisionDateFormat)) . '.html';
$file = $themeFolder . $page . '.html';
if (is_dir($backupFolder)) {
if (file_exists($file)) {
- $content = file_get_contents($themeFolder . $page . '.html');
+ $content = file_get_contents($file);
- if (strpos($content, '<base') !== false) {
+ if (str_contains($content, '<base')) {
$content = preg_replace('/<base(.*)href=["\'](.*?)["\'](.*?)>/', '<base$1href="../"$3>', $content);
} else {
$content = str_replace('<head>', "<head>\n<base href=\"../\">\n", $content);
@@ -463,9 +571,14 @@ class Editor extends Base {
return false;
}
- private function saveElements($elements) {
- $products = new ProductSQL();
- $posts = new PostSQL();
+ /**
+ * Saves modified components/elements from the editor page.
+ *
+ * @param array<int, array<string, mixed>> $elements Components list with their fields.
+ *
+ * @return bool True on success.
+ */
+ private function saveElements(array $elements): bool {
$components = [];
foreach ($elements as $element) {
@@ -474,70 +587,32 @@ class Editor extends Base {
$id = $element['id'];
$fields = $element['fields'];
- //todo: check and load components from plugins
+ if (!preg_match('/^[a-zA-Z][a-zA-Z0-9_\-]*$/', $component)) {
+ continue;
+ }
- $componentName = "\Vvveb\Component\\$component";
+ $componentName = "\Vvveb\Component\\$component";
- if (! class_exists($componentName)) {
+ if (!class_exists($componentName, false)) {
include_once DIR_ROOT . "app/component/$component.php";
}
- if (! isset($components[$component])) {
+ if (!isset($components[$component])) {
$components[$component] = new $componentName();
}
$components[$component]->editorSave($id, $fields, $type);
}
- /*
- switch ($type) {
- case 'product':
- $product_content = [];
-
- foreach ($fields as $field) {
- $name = $field['name'];
- $value = $field['value'];
-
- if ($name == 'name' || $name == 'content') {
- $product_content[$name] = $value;
- } else {
- $product[$name] = $value;
- }
- }
-
- //$product_content['product_id'] = $id;
- $product_content['language_id'] = 1;
-
- $product['product_content'][] = $product_content;
- $result = $products->edit(['product' => $product, 'product_id' => $id]);
-
- break;
-
- case 'post':
- $post_content = [];
-
- foreach ($fields as $field) {
- $name = $field['name'];
- $value = $field['value'];
-
- if ($name == 'name' || $name == 'content') {
- $post_content[$name] = $value;
- } else {
- $post[$name] = $value;
- }
- }
- //$post['post_content']['post_id'] = $id;
- $post_content['language_id'] = 1;
- $post['post_content'][] = $post_content;
-
- $result = $posts->edit(['post' => $post, 'post_id' => $id]);
-
- break;
- } */
return true;
}
- function delete() {
+ /**
+ * Deletes a template file or database post/page.
+ *
+ * @return void
+ */
+ public function delete(): void {
$post_id = $this->request->post['post_id'] ?? false;
$file = sanitizeFileName($this->request->post['file'] ?? '');
$themeFolder = $this->getThemeFolder();
@@ -545,23 +620,21 @@ class Editor extends Base {
if ($post_id) {
$type = 'page';
- if ($post_id) {
- if (is_numeric($post_id)) {
- $post_id = [$post_id];
- }
+ if (is_numeric($post_id)) {
+ $post_id = [$post_id];
+ }
- $this->posts = new PostSQL();
- $options = [
- 'post_id' => $post_id, 'type' => $type,
- ] + $this->global;
+ $this->posts = new PostSQL();
+ $options = [
+ 'post_id' => $post_id, 'type' => $type,
+ ] + $this->global;
- $result = $this->posts->delete($options);
+ $result = $this->posts->delete($options);
- if ($result && isset($result['post'])) {
- $message = ['success' => true, 'message' => ucfirst($type) . __(' deleted!')];
- } else {
- $message = ['success' => false, 'message' => sprintf(__('Error deleting %s!'), $type)];
- }
+ if ($result && isset($result['post'])) {
+ $message = ['success' => true, 'message' => ucfirst($type) . __(' deleted!')];
+ } else {
+ $message = ['success' => false, 'message' => sprintf(__('Error deleting %s!'), $type)];
}
} else {
if ($file && file_exists($themeFolder . DS . $file)) {
@@ -579,12 +652,17 @@ class Editor extends Base {
$this->response->output($message);
}
- function rename() {
+ /**
+ * Renames or duplicates a template file or database page/product.
+ *
+ * @return void
+ */
+ public function rename(): void {
$post_id = $this->request->post['post_id'] ?? false;
$product_id = $this->request->post['product_id'] ?? false;
- $file = sanitizeFileName($this->request->post['file']);
- $newfile = sanitizeFileName($this->request->post['newfile']);
- $duplicate = $this->request->post['duplicate'] ?? 'false';
+ $file = sanitizeFileName($this->request->post['file'] ?? '');
+ $newfile = sanitizeFileName($this->request->post['newfile'] ?? '');
+ $duplicate = ($this->request->post['duplicate'] ?? 'false') === 'true';
$themeFolder = $this->getThemeFolder();
$name = $this->request->post['name'] ?? $newfile;
$theme = $this->getTheme();
@@ -614,17 +692,17 @@ class Editor extends Base {
}
if ($newfile) {
- $name = sanitizeFileName($this->request->post['name']);
+ $name = sanitizeFileName($this->request->post['name'] ?? $name);
$slug = slugify($name);
$this->posts = model($model);
- if ($duplicate === 'true') {
+ if ($duplicate) {
$data = $this->posts->get([$model . '_id' => $model_id]);
if ($data) {
unset($data[$model . '_id']);
- $id = rand(1, 1000);
+ $id = random_int(1, 1000);
foreach ($data[$model . '_content'] as &$content) {
unset($content[$model . '_id']);
@@ -638,12 +716,14 @@ class Editor extends Base {
}
}
+ $taxonomy_item = [];
if (isset($data[$model . '_to_taxonomy_item'])) {
foreach ($data[$model . '_to_taxonomy_item'] as &$item) {
$taxonomy_item[] = $item['taxonomy_item_id'];
}
}
+ $site_id = [];
if (isset($data[$model . '_to_site'])) {
foreach ($data[$model . '_to_site'] as &$item) {
$site_id[] = $item['site_id'];
@@ -653,17 +733,17 @@ class Editor extends Base {
$startTemplateUrl = $data['template'] ?? "$namespace/$type.html";
$template = "$namespace/$slug.html";
- if (! @copy($themeFolder . DS . $startTemplateUrl, $themeFolder . DS . $template)) {
+ if (!@copy($themeFolder . DS . $startTemplateUrl, $themeFolder . DS . $template)) {
$template = $data['template'] ?? '';
}
$new = [
$model => [
- 'taxonomy_item' => $taxonomy_item ?? [],
- 'template' => $template,
+ 'taxonomy_item' => $taxonomy_item,
+ 'template' => $template,
] + $data,
- $model . '_content' => $data[$model . '_content'],
- 'site_id' => $site_id,
+ $model . '_content' => $data[$model . '_content'],
+ 'site_id' => $site_id,
] + $data + $this->global;
$result = $this->posts->add($new);
@@ -674,14 +754,14 @@ class Editor extends Base {
$model_id = $result[$model];
$message = ['success' => true, 'name' => $name, 'slug' => $slug, $model . '_id' => $model_id, 'newfile' => $newfile, 'url' => url("$namespace/$type/index", ['slug' => $slug, $model . '_id' => $model_id]), 'message' => ucfirst($type) . ' ' . __('duplicated') . '!'];
} else {
- $message = ['success' => false, 'message' => sprintf(__('Error duplicating %s!'), $type)];
+ $message = ['success' => false, 'message' => sprintf(__('Error duplicating %s!'), $type)];
}
}
} else {
$data = [
- $model . '_content' => ['name' => $name, 'slug' => $slug],
- $model . '_id' => $model_id,
- 'language_id' => $this->global['language_id'],
+ $model . '_content' => ['name' => $name, 'slug' => $slug],
+ $model . '_id' => $model_id,
+ 'language_id' => $this->global['language_id'],
];
$result = $this->posts->editContent($data);
@@ -690,24 +770,28 @@ class Editor extends Base {
if ($result && isset($result[$model . '_content'])) {
$message = ['success' => true, 'name' => $name, 'slug' => $slug, $model . '_id' => $model_id, 'newfile' => $newfile, 'url' => url("$namespace/$type/index", ['slug' => $slug, $model . '_id' => $model_id]), 'message' => ucfirst($type) . ' ' . __('renamed') . '!'];
} else {
- $message = ['success' => false, 'message' => sprintf(__('Error renaming %s!'), $type)];
+ $message = ['success' => false, 'message' => sprintf(__('Error renaming %s!'), $type)];
}
}
}
} else {
- $newfile = PUBLIC_PATH . "themes/$theme/" . ($dir ? $dir . '/' : '') . $newfile;
-
- if ($duplicate === 'true') {
- if (@copy($currentFile, $targetFile)) {
- $message = ['success' => true, 'newfile' => $newfile, 'name' => $name, 'message' => __('File copied!'), 'url' => $newfile];
- } else {
- $message = ['success' => false, 'message' => __('Error copying file!')];
- }
+ if (!$file || !$newfile) {
+ $message = ['success' => false, 'message' => __('File and new file name are required!')];
} else {
- if (rename($currentFile, $targetFile)) {
- $message = ['success' => true, 'newfile' => $newfile, 'name' => $name, 'message' => __('File renamed!')];
+ $newfile = PUBLIC_PATH . "themes/$theme/" . ($dir ? $dir . '/' : '') . $newfile;
+
+ if ($duplicate) {
+ if (@copy($currentFile, $targetFile)) {
+ $message = ['success' => true, 'newfile' => $newfile, 'name' => $name, 'message' => __('File copied!'), 'url' => $newfile];
+ } else {
+ $message = ['success' => false, 'message' => __('Error copying file!')];
+ }
} else {
- $message = ['success' => false, 'message' => __('Error renaming file!')];
+ if (rename($currentFile, $targetFile)) {
+ $message = ['success' => true, 'newfile' => $newfile, 'name' => $name, 'message' => __('File renamed!')];
+ } else {
+ $message = ['success' => false, 'message' => __('Error renaming file!')];
+ }
}
}
}
@@ -717,12 +801,103 @@ class Editor extends Base {
$this->response->output($message);
}
- function save() {
+ /**
+ * Create a new page/post or product record from the editor save action.
+ *
+ * @param string $type Content type ('page', 'post', or 'product').
+ * @param string $name Display name.
+ * @param string $slug URL slug.
+ * @param string $content HTML content.
+ * @param string $image Image path.
+ * @param string $templateType 'global' or 'custom'.
+ * @param string $startTemplateUrl Starter template URL.
+ *
+ * @return array{0:string,1:string,2:bool} [file, url, success]
+ */
+ private function createContent(string $type, string $name, string $slug, string $content, string $image, string $templateType, string $startTemplateUrl): array {
+ $file = '';
+ $url = '';
+ $success = false;
+
+ switch ($type) {
+ case 'page':
+ case 'post':
+ $default = sanitizeFileName(($templateType === 'global') ? "content/$type.html" : "content/$slug.html");
+ $template = ($templateType === 'global' && $startTemplateUrl) ? $startTemplateUrl : $default;
+ $file = $template;
+
+ $post = new PostSQL();
+ $result = $post->add([
+ 'post' => [
+ 'template' => $template,
+ 'type' => $type,
+ 'image' => $image,
+ ] + $this->global,
+ 'post_content' => [[
+ 'slug' => $slug,
+ 'name' => $name,
+ 'content' => $content,
+ 'language_id' => $this->global['language_id'],
+ ]],
+ 'site_id' => [$this->global['site_id']],
+ ] + $this->global);
+
+ if ($result['post'] ?? false) {
+ $post_id = $result['post'];
+ $success = true;
+ $url = \Vvveb\url("content/{$type}/index", ['slug' => $slug, 'post_id' => $post_id]);
+ }
+
+ break;
+
+ case 'product':
+ $default = sanitizeFileName(($templateType === 'global') ? "product/$type.html" : "product/$slug.html");
+ $template = ($templateType === 'global' && $startTemplateUrl) ? $startTemplateUrl : $default;
+ $price = $this->request->post['price'] ?? 0;
+ $file = $template;
+
+ $product = new ProductSQL();
+ $result = $product->add([
+ 'product' => [
+ 'model' => '',
+ 'image' => $image,
+ 'status' => 1, //active
+ 'template' => $template,
+ 'price' => $price,
+ ] + $this->global,
+ 'product_content' => [[
+ 'slug' => $slug,
+ 'name' => $name,
+ 'content' => $content,
+ 'language_id' => $this->global['language_id'],
+ ]],
+ 'site_id' => [$this->global['site_id']],
+ ] + $this->global);
+
+ if ($result['product'] ?? false) {
+ $product_id = $result['product'];
+ $success = true;
+ $url = \Vvveb\url("product/{$type}/index", ['slug' => $slug, 'product_id' => $product_id]);
+ }
+
+ break;
+ }
+
+ return [$file, $url, $success];
+ }
+
+ /**
+ * Saves templates, pages, or database posts/products, processes backups,
+ * updates menus, and purges compiled caches.
+ *
+ * @return void
+ */
+ public function save(): void {
$file = $this->request->post['filename'] ?? '';
$folder = $this->request->post['folder'] ?? '';
- $startTemplateUrl = $this->request->post['startTemplateUrl'] ?? null;
+ $startTemplateUrl = $this->request->post['startTemplateUrl'] ?? '';
$name = $this->request->post['name'] ?? '';
- $content = $this->request->post['content'] ?? 'Lorem ipsum';
+ $content = $this->request->post['content'] ?? '<div>Lorem ipsum</div>';
$image = $this->request->post['image'] ?? '';
$type = $this->request->post['type'] ?? false;
$templateType = $this->request->post['template-type'] ?? 'global';
@@ -739,125 +914,49 @@ class Editor extends Base {
$file = sanitizeFileName(str_replace('.html', '', $file)) . '.html';
}
- if ($type && $name) {
- $slug = slugify($name);
- $success = false;
-
- switch ($type) {
- case 'page':
- case 'post':
- $default = $templateType == 'global' ? "content/$type.html" : "content/$slug.html";
- $default = sanitizeFileName($default);
- $template = ($templateType == 'global' && isset($startTemplateUrl) && $startTemplateUrl) ? $startTemplateUrl : $default;
- $file = $template;
-
- $post = new PostSQL();
- $result = $post->add([
- 'post' => [
- 'template' => $template,
- 'type' => $type,
- 'image' => $image,
- ] + $this->global,
- 'post_content' => [[
- 'slug' => $slug,
- 'name' => $name,
- 'content' => $content,
- 'language_id' => $this->global['language_id'],
- ]],
- 'site_id' => [$this->global['site_id']],
- ] + $this->global);
-
- if ($result['post']) {
- $post_id = $result['post'];
- $success = true;
- $route = "content/{$type}/index";
- $url = \Vvveb\url($route, ['slug'=> $slug, 'post_id'=> $post_id]);
- }
-
- break;
-
- case 'product':
- $default = $templateType == 'global' ? "product/$type.html" : "product/$slug.html";
- $default = sanitizeFileName($default);
- $template = $templateType == 'global' && isset($startTemplateUrl) ? $startTemplateUrl : $default;
- $price = $this->request->post['price'] ?? 0;
- $file = $template;
-
- $product = new ProductSQL();
- $result = $product->add([
- 'product' => [
- 'model' => '',
- 'image' => $image,
- 'status' => 1, //active
- 'template' => $template,
- 'price' => $price,
- ] + $this->global,
- 'product_content' => [[
- 'slug' => $slug,
- 'name' => $name,
- 'name' => $name,
- 'content' => $content,
- 'language_id' => $this->global['language_id'],
- ]],
- 'site_id' => [$this->global['site_id']], ] + $this->global);
-
- if ($result['product']) {
- $product_id = $result['product'];
- $success = true;
- $route = "product/{$type}/index";
- $url = \Vvveb\url($route, ['slug' => $slug, 'product_id'=> $product_id]);
- }
+ $slug = $name ? slugify($name) : '';
- break;
- }
+ if ($type && $name) {
+ [$file, $url, $success] = $this->createContent($type, $name, $slug, $content, $image, $templateType, $startTemplateUrl);
}
$html = $this->request->post['html'] ?? false;
$elements = $this->request->post['elements'] ?? false;
- $setTemplate = $this->request->post['setTemplate'] ?? false;
$view = View::getInstance();
$view->noJson = true;
- $text = '';
- $messages = [];
+ $messages = [];
$baseUrl = PUBLIC_PATH . 'themes/' . $theme . '/' . ($folder ? $folder . '/' : '');
$themeFolder = $this->getThemeFolder();
- $relativeBase = '';
- $pos = 0;
-
- //if more than one level deep add one level up for each level
- $fileBase = ($folder ? $folder . '/' : '') . $file;
- if ($fileBase) {
- while (($pos = strpos($fileBase, '/', $pos + 1)) !== false) {
- $relativeBase .= '../';
- }
- }
+ $fileBase = ($folder ? $folder . '/' : '') . $file;
+ $relativeBase = $this->computeRelativeBase($fileBase);
if ($startTemplateUrl) {
$startTemplate = $themeFolder . DS . $startTemplateUrl;
if (file_exists($startTemplate)) {
- if (! ($html = @file_get_contents($startTemplate))) {
+ if (!($html = @file_get_contents($startTemplate))) {
$messages[] = ['success' => false, 'message' => sprintf(__('%s is not readable!'), $startTemplate)];
}
} else {
$messages[] = ['success' => false, 'message' => sprintf(__('%s does not exist!'), $startTemplate)];
}
- $html = preg_replace('@<base\s+href[^>]+>@', '<base href="' . $relativeBase . '">', $html);
+ if ($html) {
+ $html = preg_replace('@<base\s+href[^>]+>@', '<base href="' . $relativeBase . '">', $html);
+ }
}
- if (! $url) {
+ if (!$url) {
$url = "$baseUrl$file";
}
-
if ($elements) {
if ($this->saveElements($elements)) {
- $success = true;
+ $success = true;
$messages[] = ['success' => true, 'message' => __('Elements saved!')];
} else {
- $success = false;
+ $success = false;
$messages[] = ['success' => false, 'message' => __('Error saving elements!')];
}
}
@@ -865,26 +964,25 @@ class Editor extends Base {
//if plugins template use public path
$isPlugin = false;
- if (strncmp($file, '/plugins/', 9) === 0) {
+ if (str_starts_with($file, '/plugins/')) {
$pluginFile = substr($file, 9);
$pluginFile = preg_replace('@^(.+/)@', '$1/public/', $pluginFile);
- $fileName = DIR_PLUGINS . /*($folder ? $folder . DS : '') .*/ $pluginFile;
- $isPlugin = true;
+ $fileName = DIR_PLUGINS . $pluginFile;
+ $isPlugin = true;
} else {
$fileName = $themeFolder . DS . ($folder ? $folder . DS : '') . $file;
}
- if (! $startTemplateUrl && ! $isPlugin && $file) {
+ if (!$startTemplateUrl && !$isPlugin && $file) {
$backupFolder = $themeFolder . DS . 'backup' . DS;
if (is_writable($backupFolder)) {
- if ($this->backup(($folder ? $folder . DS : '') . $file)) {
- } else {
- $success = false;
- $messages[] = ['success' => false, 'message' => __('Error saving revision!')];
+ if (!$this->backup(($folder ? $folder . DS : '') . $file)) {
+ $success = false;
+ $messages[] = ['success' => false, 'message' => __('Error saving revision!')];
}
} else {
- $success = false;
+ $success = false;
$messages[] = ['success' => false, 'message' => sprintf(__('%s folder not writable!'), $theme . DS . 'backup')];
}
}
@@ -894,14 +992,14 @@ class Editor extends Base {
'menu_id' => $menu_id,
'url' => $url,
'menu_item_content' => [[
- 'name' => $name,
- 'slug' => $slug,
- 'language_id' => $this->global['language_id'],
- 'content' => '',
+ 'name' => $name,
+ 'slug' => $slug,
+ 'language_id' => $this->global['language_id'],
+ 'content' => '',
]],
]] + $this->global;
- $menus = new menuSQL();
+ $menus = new MenuSQL();
$results = $menus->addMenuItem($menuData);
if ($results) {
@@ -917,39 +1015,39 @@ class Editor extends Base {
//$html = preg_replace('@<base href[^>]+>@', '', $html);
$html = preg_replace('@<base href[^>]+>@', '<base href="' . $relativeBase . '">', $html);
//remove empty value for data attributes
- $html = preg_replace('/(data-[\w\-]+)="\s*"/','$1', $html);
+ $html = preg_replace('/(data-[\w\-]+)="\s*"/', '$1', $html);
if (@file_put_contents($fileName, $html)) {
$globalOptions = [];
//keep css inline for email templates
- if (strpos($fileName, '/email/') !== false) {
+ if (str_contains($fileName, '/email/')) {
$globalOptions['inline-css'] = true;
}
$html = $this->saveGlobalElements($html, $globalOptions);
- $success = true;
- $messages[] = ['success' => true, 'message' => __('File saved!')];
+ $success = true;
+ $messages[] = ['success' => true, 'message' => __('File saved!')];
} else {
$success = false;
- if (! is_writable($fileName)) {
+ if (!is_writable($fileName)) {
$messages[] = ['success' => false, 'message' => sprintf(__('%s is not writable!'), $file)];
} else {
$messages[] = ['success' => false, 'message' => sprintf(__('Error saving %s!'), $file)];
}
}
} else {
- $messages[] = ['success' => false, 'message' => __('Page html empty!')];
+ $messages[] = ['success' => false, 'message' => __('Page html empty!')];
}
}
$cssFile = DS . 'css' . DS . 'custom.css';
//try to create custom.css if it doesn't exist
- if (! file_exists($themeFolder . $cssFile) && ! touch($themeFolder . $cssFile)) {
+ if (!file_exists($themeFolder . $cssFile) && !@touch($themeFolder . $cssFile)) {
$messages[] = ['success' => false, 'message' => sprintf(__('Can not create file %s!'), $theme . $cssFile)];
} else {
- if (! is_writable($themeFolder . $cssFile)) {
+ if (!is_writable($themeFolder . $cssFile)) {
$messages[] = ['success' => false, 'message' => sprintf(__('%s is not writable!'), $theme . $cssFile)];
}
}
diff --git a/admin/controller/editor/reusable.php b/admin/controller/editor/reusable.php
index 18a87fa..724e508 100644
--- a/admin/controller/editor/reusable.php
+++ b/admin/controller/editor/reusable.php
@@ -30,35 +30,53 @@ use function Vvveb\slugify;
use Vvveb\System\Sites;
class Reusable extends Base {
- private $sectionTemplate = <<<TPL
-
-Vvveb.Sections.add("reusable/{name}", {
- name: "{title}",
- //image: Vvveb.themeBaseUrl + "/../../media/img/logo-small.png",
- image: "img/logo-small.png",
- html: `{content}`
-});
-Vvveb.SectionsGroup['Reusable'].push("reusable/{name}");
-
-TPL;
-
- private $blockTemplate = <<<TPL
-
-Vvveb.Blocks.add("reusable/{name}", {
- name: "{title}",
- //image: Vvveb.themeBaseUrl + "/../../media/img/logo-small.png",
- image: "img/logo-small.png",
- html: `{content}`
-});
-Vvveb.BlocksGroup['Reusable'].push("reusable/{name}");
-
-TPL;
-
- private function getThemeFolder() {
- return DIR_THEMES . ($this->request->get['theme'] ?? Sites::getTheme($this->global['site_id']) ?? 'default');
+ /**
+ * @var string Heredoc template for reusable sections.
+ */
+ private string $sectionTemplate = <<<'TPL'
+
+ Vvveb.Sections.add("reusable/{name}", {
+ name: "{title}",
+ //image: Vvveb.themeBaseUrl + "/../../media/img/logo-small.png",
+ image: "img/logo-small.png",
+ html: `{content}`
+ });
+ Vvveb.SectionsGroup['Reusable'].push("reusable/{name}");
+
+ TPL;
+
+ /**
+ * @var string Heredoc template for reusable blocks.
+ */
+ private string $blockTemplate = <<<'TPL'
+
+ Vvveb.Blocks.add("reusable/{name}", {
+ name: "{title}",
+ //image: Vvveb.themeBaseUrl + "/../../media/img/logo-small.png",
+ image: "img/logo-small.png",
+ html: `{content}`
+ });
+ Vvveb.BlocksGroup['Reusable'].push("reusable/{name}");
+
+ TPL;
+
+ /**
+ * Returns the theme folder path for the current site.
+ *
+ * @return string Theme folder path.
+ */
+ private function getThemeFolder(): string {
+ return DIR_THEMES . ($this->request->get['theme'] ?? Sites::getTheme($this->global['site_id']));
}
- private function regenerate($type) {
+ /**
+ * Regenerates the JS file for reusable sections or blocks.
+ *
+ * @param string $type Either 'section' or 'block'.
+ *
+ * @return int|false Bytes written or false on failure.
+ */
+ private function regenerate(string $type): int|false {
$themeFolder = $this->getThemeFolder();
$folder = $themeFolder . DS . $type . 's' . DS;
@@ -68,10 +86,10 @@ TPL;
$js = '';
foreach (scandir($htmlFolder) as $file) {
- if (strpos($file, '.html') === false) {
+ if (!str_contains($file, '.html')) {
continue;
}
- $name = str_replace('.html','', $file);
+ $name = str_replace('.html', '', $file);
$title = humanReadable($name);
$content = file_get_contents($htmlFolder . DS . $file);
@@ -106,7 +124,12 @@ TPL;
return file_put_contents($jsFile, $jsContent);
}
- function save() {
+ /**
+ * Saves a reusable section or block to disk and regenerates the JS file.
+ *
+ * @return void
+ */
+ public function save(): void {
$name = slugify(sanitizeFileName($this->request->post['name']));
$type = $this->request->post['type'];
$html = $this->request->post['html'];
diff --git a/admin/controller/editor/revisions.php b/admin/controller/editor/revisions.php
index 0380bd6..bf9d1da 100644
--- a/admin/controller/editor/revisions.php
+++ b/admin/controller/editor/revisions.php
@@ -29,23 +29,45 @@ use function Vvveb\sanitizeFileName;
use Vvveb\System\Sites;
class Revisions extends Base {
- function getThemeFolder() {
- $theme = $this->request->get['theme'] ?? Sites::getTheme($this->global['site_id']) ?? 'default';
+ /**
+ * Returns the sanitized theme folder name.
+ *
+ * @return string Theme name.
+ */
+ public function getThemeFolder(): string {
+ $theme = $this->request->get['theme'] ?? Sites::getTheme($this->global['site_id']);
return sanitizeFileName($theme);
}
- private function sanitizeBackupFileName($fileName) {
+ /**
+ * Sanitizes a backup file name by removing dots and slashes.
+ *
+ * @param string $fileName The raw file name.
+ *
+ * @return string The sanitized file name.
+ */
+ private function sanitizeBackupFileName(string $fileName): string {
return str_replace(['.', '/', '\\'], '', $fileName);
}
- private function backupFolder() {
+ /**
+ * Returns the full backup folder path for the current theme.
+ *
+ * @return string Backup folder path.
+ */
+ private function backupFolder(): string {
$theme = $this->getThemeFolder();
- return DIR_THEMES . $theme . DS . 'backup' . DS;
+ return DIR_THEMES . $theme . DS . 'backup' . DS;
}
- function delete() {
+ /**
+ * Deletes a backup revision file.
+ *
+ * @return void
+ */
+ public function delete(): void {
$file = $this->request->post['file'] ?? false;
if ($file) {
@@ -69,7 +91,12 @@ class Revisions extends Base {
}
}
- function load() {
+ /**
+ * Loads a backup revision file and outputs its content.
+ *
+ * @return void
+ */
+ public function load(): void {
$file = $this->request->post['file'] ?? false;
$theme = $this->getThemeFolder();
@@ -81,7 +108,7 @@ class Revisions extends Base {
$html = file_get_contents($file);
$base = "/themes/$theme/";
- if (strpos($html, '<base') !== false) {
+ if (str_contains($html, '<base')) {
$html = preg_replace('/<base(.*)href=["\'](.*?)["\'](.*?)>/', '<base$1href="' . $base . '"$3>', $html);
} else {
$html = str_replace('<head>', "<head>\n<base href=\"$base\">\n", $html);
@@ -90,11 +117,16 @@ class Revisions extends Base {
$this->response->output($html);
}
} else {
- die(__('Invalid request!'));
+ exit(__('Invalid request!'));
}
}
- function revisions() {
+ /**
+ * Lists all backup revisions for a given template.
+ *
+ * @return void
+ */
+ public function revisions(): void {
$theme = $this->getThemeFolder();
$template = $this->request->get['template'] ?? false;
$backupFolder = $this->backupFolder();
@@ -108,8 +140,8 @@ class Revisions extends Base {
foreach ($glob as &$file) {
$file = basename($file, '.html');
- $url = $path . "backup/$file.html";
- list($name, $date) = explode('@', $file);
+ $url = $path . "backup/$file.html";
+ [$name, $date] = explode('@', $file);
$date = str_replace(['_', ';'], [' ', ':'], $date);
$date_friendly = friendlyDate($date);
/*
@@ -127,7 +159,4 @@ class Revisions extends Base {
$this->response->setType('json');
$this->response->output($revisions);
}
-
- function index() {
- }
}
diff --git a/admin/controller/editor/translate.php b/admin/controller/editor/translate.php
index 4572dca..9b29656 100644
--- a/admin/controller/editor/translate.php
+++ b/admin/controller/editor/translate.php
@@ -27,7 +27,12 @@ use Vvveb\Controller\Base;
use Vvveb\System\Locale;
class Translate extends Base {
- function get() {
+ /**
+ * Returns translations of a text string in all available languages as JSON.
+ *
+ * @return void
+ */
+ public function get(): void {
$text = $this->request->post['text'];
$languages = Locale::availableLanguages();
$translations = [];
@@ -48,7 +53,12 @@ class Translate extends Base {
$this->response->output($translations);
}
- function save() {
+ /**
+ * Saves translations to PO/MO files for each language.
+ *
+ * @return void
+ */
+ public function save(): void {
$translations = $this->request->post ?? [];
$success = true;
$message = __('Translations saved!');
@@ -58,6 +68,7 @@ class Translate extends Base {
unset($translations['csrf']);
$defaultLang = key($translations); //'en_US';
+ $langCode = is_string($defaultLang) ? $defaultLang : '';
$domain = 'vvveb';
$text = $translations[$defaultLang];
@@ -71,7 +82,7 @@ class Translate extends Base {
$moFile = $folder . $domain . '.mo';
foreach ([$poFile, $moFile] as $file) {
- if (! is_writable($file)) {
+ if (!is_writable($file)) {
$message = sprintf(__('File %s not writable!'), $file);
$success = false;
@@ -109,8 +120,6 @@ class Translate extends Base {
}
}
-
-
$this->response->setType('json');
$this->response->output(['success' => $success, 'message' => $message]);
}
diff --git a/admin/template/admin.tpl b/admin/template/admin.tpl
index cd84ed8..47157ec 100755
--- a/admin/template/admin.tpl
+++ b/admin/template/admin.tpl
@@ -9,8 +9,4 @@ form[data-v-url][data-v-url-params]|action = <?php echo Vvveb\url('@@__data-v-ur
//csrf
[data-v-csrf]|value = <?php echo \Vvveb\session('csrf');?>
-
-/*body|prepend = <?php var_dump($this);?>*/
-
-// head base|href = <?php echo Vvveb\themeUrlPath()?>
diff --git a/admin/template/common.tpl b/admin/template/common.tpl
index fd9662e..32334d8 100755
--- a/admin/template/common.tpl
+++ b/admin/template/common.tpl
@@ -28,6 +28,11 @@ if (isset($this->global['rtl']) && $this->global['rtl'] && !$vvveb_is_page_edit)
html|lang = $this->global['locale']
-#container|addClass = <?php if (isset($_COOKIE['sidebar-size']) && ($_COOKIE['sidebar-size'] == 'small-nav')) {
- echo 'small-nav';
-} ?>
+#container|addClass = <?php
+ if (isset($_COOKIE['sidebar-size']) && ($_COOKIE['sidebar-size'] == 'small-nav')) {
+ echo 'small-nav';
+ }
+ if (isset($_COOKIE['ai-assistant']) && ($_COOKIE['ai-assistant'] == 'true')) {
+ echo ' ai-assistant';
+ }
+?>
diff --git a/admin/template/components.tpl b/admin/template/components.tpl
old mode 100644
new mode 100755
index 55366f4..47ddec2
--- a/admin/template/components.tpl
+++ b/admin/template/components.tpl
@@ -7,12 +7,10 @@ import(components/languages.tpl)
import(components/admin.tpl)
import(components/comments.tpl)
import(components/news.tpl)
-import(components/product/reviews.tpl)
import(components/stats.tpl)
import(components/states.tpl)
import(components/sites.tpl)
import(components/site.tpl)
import(components/order.tpl)
import(components/user/address.tpl)
-import(components/pagination.tpl)
-import(components/notifications.tpl, [data-v-component-notifications])
+import(components/notifications.tpl)
diff --git a/admin/template/components/admin.tpl b/admin/template/components/admin.tpl
index 2cf0f3a..ecf601d 100755
--- a/admin/template/components/admin.tpl
+++ b/admin/template/components/admin.tpl
@@ -2,7 +2,7 @@
if (isset($_admin_idx)) $_admin_idx++; else $_admin_idx = 0;
$previous_component = isset($component)?$component:null;
$admin = $component = $this->_component['admin'][$_admin_idx] ?? [];
- $admin['edit-url'] = Vvveb\url(['module' => 'admin/user', 'admin_id' => $admin['admin_id'] ?? 1]);
+ $admin['edit-url'] = Vvveb\url(['module' => 'admin/user', 'admin_id' => $admin['admin_id'] ?? null]);
//$admin = \Vvveb\session('admin');
?>
@@ -12,4 +12,4 @@
[data-v-component-admin]|append = <?php
$component = $previous_component;
-?>
\ No newline at end of file
+?>
diff --git a/admin/template/components/categories.tpl b/admin/template/components/categories.tpl
index 5a11c0f..2230883 100755
--- a/admin/template/components/categories.tpl
+++ b/admin/template/components/categories.tpl
@@ -3,19 +3,16 @@
[data-v-component-categories]|prepend = <?php
if (isset($_categories_idx)) $_categories_idx++; else $_categories_idx = 0;
-
-$_pagination_count = $this->categories[$_categories_idx]['count'];
-$_pagination_limit = $this->categories[$_categories_idx]['limit'];
+$categories = $this->_component['categories'][$_categories_idx] ?? [];
+$_pagination_count = $categories['count'] ?? 0;
+$_pagination_limit = $categories['limit'] ?? 5;
?>
[data-v-component-categories] [data-v-category]|before = <?php
-if(isset($this->_component['categories']) && is_array($this->_component['categories'][$_categories_idx]['categories']))
-{
- //$pagination = $this->categories[$_categories_idx]['pagination'];
- foreach ($this->categories[$_categories_idx]['categories'] as $index => $category)
- {
- ?>
+if(is_array($categories['categories'])) {
+ //$pagination = $categories['pagination'];
+ foreach ($categories['categories'] as $index => $category) {?>
@category [data-v-category-name] = $category['name']
@category [data-v-category-url]|href = <?php echo '/admin?module=category&category_id=' . $category['category_id'];?>
@@ -24,7 +21,6 @@ if(isset($this->_component['categories']) && is_array($this->_component['categor
@category [data-v-img]|src =
<?php
echo '/image/' .$category['image'];
- //echo htmlspecialchars(str_replace('large', '@@__class:image_([a-zA-Z_]+)__@@', $category['images'][$category['main_image']]['url']));
?>
diff --git a/admin/template/components/languages.tpl b/admin/template/components/languages.tpl
old mode 100644
new mode 100755
diff --git a/admin/template/components/notifications.tpl b/admin/template/components/notifications.tpl
index ff471cc..134d271 100644
--- a/admin/template/components/notifications.tpl
+++ b/admin/template/components/notifications.tpl
@@ -35,7 +35,8 @@ $count = $notificationComponent['count'] ?? 0;
@notifications [data-v-group-notification-count]|addClass = <?php if (isset($notification['badge'])) echo $notification['badge'];?>
- @notifications [data-v-group-icon]|class = $notification['icon']
+ @notifications [data-v-group-icon]|if_exists = $notification['icon']
+ @notifications [data-v-group-icon-use]|href = <?php echo '/admin/default/img/icons.svg#' . htmlspecialchars($notification['icon']); ?>
@notifications [data-v-group-notification]|after = <?php
diff --git a/admin/template/components/order.tpl b/admin/template/components/order.tpl
old mode 100644
new mode 100755
diff --git a/admin/template/components/posts.tpl b/admin/template/components/posts.tpl
index 218603c..bf25145 100755
--- a/admin/template/components/posts.tpl
+++ b/admin/template/components/posts.tpl
@@ -4,18 +4,15 @@
[data-v-component-posts]|prepend = <?php
if (isset($_posts_idx)) $_posts_idx++; else $_posts_idx = 0;
-$_pagination_count = $this->_component['posts'][$_posts_idx]['count'];
-$_pagination_limit = isset($this->_component['posts'][$_posts_idx]['limit'])? $this->_component['posts'][$_posts_idx]['limit'] : 5;
+$_component_data = $this->_component['posts'][$_posts_idx] ?? [];
+$_pagination_count = $_component_data['count'] ?? 0;
+$_pagination_limit = $_component_data['limit'] ?? 5;
?>
-[data-v-component-posts] [data-v-category] = <?php $_category = current($this->_component['posts'][$_posts_idx]['posts']);echo htmlspecialchars($_category['category']);?>
-[data-v-component-posts] [data-v-manufacturer] = <?php $_manufacturer = current($this->_component['posts'][$_posts_idx]['posts']);echo htmlspecialchars($_manufacturer['manufacturer']);?>
-
-
//$post = [data-v-component-posts] [data-v-post]
[data-v-component-posts] [data-v-post]|before = <?php
-if(isset($this->_component['posts']) && is_array($this->_component['posts'][$_posts_idx]['post']))
+if(isset($this->_component['posts']) && is_array($this->_component['posts'][$_posts_idx] ?? null) && is_array($this->_component['posts'][$_posts_idx]['post'] ?? null))
{
//$pagination = $this->posts[$_posts_idx]['pagination'];
foreach ($this->_component['posts'][$_posts_idx]['post'] as $index => $post) {?>
diff --git a/admin/template/components/product.tpl b/admin/template/components/product.tpl
old mode 100644
new mode 100755
diff --git a/admin/template/components/products.tpl b/admin/template/components/products.tpl
index eb21e4d..2b80e98 100755
--- a/admin/template/components/products.tpl
+++ b/admin/template/components/products.tpl
@@ -15,12 +15,12 @@ $_pagination_count = $count;
$_pagination_limit = $products['limit'] ?? 5;
?>
-[data-v-component-products] [data-v-category] = <?php $_category = current($products['products']); echo htmlspecialchars($_category['category']);?>
-[data-v-component-products] [data-v-manufacturer] = <?php $_manufacturer = current($products['products']); echo htmlspecialchars($_manufacturer['manufacturer']);?>
+[data-v-component-products] [data-v-category] = <?php $_product_list = $products['products'] ?? []; if ($_product_list) { $_category = current($_product_list); echo htmlspecialchars($_category['category'] ?? ''); } ?>
+[data-v-component-products] [data-v-manufacturer] = <?php if ($_product_list) { $_manufacturer = current($_product_list); echo htmlspecialchars($_manufacturer['manufacturer'] ?? ''); } ?>
[data-v-component-products] [data-v-product]|before = <?php
-if(is_array($products['product'])) {
+if(isset($products['product']) && is_array($products['product'])) {
$index = 0;
foreach ($products['product'] as $index => $product) { ?>
diff --git a/admin/template/components/site.tpl b/admin/template/components/site.tpl
old mode 100644
new mode 100755
diff --git a/admin/template/components/sites.tpl b/admin/template/components/sites.tpl
old mode 100755
new mode 100644
index 036493e..5527084
--- a/admin/template/components/sites.tpl
+++ b/admin/template/components/sites.tpl
@@ -20,7 +20,8 @@ if(isset($this->_component['sites']) && $this->_component['sites'][$_sites_idx])
@site .dropdown-item|addClass = <?php if (isset($site['site_id']) && ($site['site_id'] == $sites['site_id'])) echo 'active'?>
@site [data-v-site-name] = $site['name']
- @site [data-v-site-icon]|addClass = <?php echo $sites['states'][$state]['icon'];?>
+ @site [data-v-site-icon]|if_exists = $sites['states'][$state]['icon']
+ @site [data-v-site-icon-use]|href = <?php echo '/admin/default/img/icons.svg#' . htmlspecialchars($sites['states'][$state]['icon']); ?>
@site a[data-v-site-url]|href = <?php echo '//' . $site['url'];?>
@site button[data-v-site-site_id]|value = $site['site_id']
diff --git a/admin/template/components/states.tpl b/admin/template/components/states.tpl
old mode 100755
new mode 100644
index 783590b..d96ae47
--- a/admin/template/components/states.tpl
+++ b/admin/template/components/states.tpl
@@ -10,7 +10,7 @@ if(isset($this->_component['states']) && $this->_component['states'][$_states_id
// [data-v-component-states] [data-v-state-info-*] = $states['@@__data-v-state-info-(*)__@@']
-[data-v-component-states] [data-v-state-info-active_icon]|addClass = <?php echo $states['active_icon'];?>
+[data-v-component-states] [data-v-state-info-active_icon-use]|href = <?php echo '/admin/default/img/icons.svg#' . htmlspecialchars($states['active_icon']); ?>
[data-v-component-states] [data-v-state-info-active_name] = $states['active_name']
@state|before = <?php
@@ -20,7 +20,7 @@ if(isset($this->_component['states']) && $this->_component['states'][$_states_id
foreach ($elements as $index => $state) {?>
@state .dropdown-item|addClass = <?php if (isset($state['active']) && $state['active']) echo 'active'?>
- @state [data-v-state-icon]|addClass = <?php if (isset($state['icon'])) echo $state['icon'];?>
+ @state [data-v-state-icon-use]|href = <?php if (isset($state['icon'])) echo '/admin/default/img/icons.svg#' . htmlspecialchars($state['icon']); ?>
@state [data-v-state-name] = $state['name']
@state button|data-state = $state['name']
diff --git a/admin/template/components/users.tpl b/admin/template/components/users.tpl
index 00f75b3..ed2602f 100755
--- a/admin/template/components/users.tpl
+++ b/admin/template/components/users.tpl
@@ -35,4 +35,4 @@ if($users) {
$index++;
}
}
-?>
+?>
\ No newline at end of file
diff --git a/admin/template/content/categories.tpl b/admin/template/content/categories.tpl
index ef79d4e..e1995f6 100755
--- a/admin/template/content/categories.tpl
+++ b/admin/template/content/categories.tpl
@@ -95,7 +95,7 @@ foreach ($languages as $key => $language) {
[data-v-languages] [data-v-language_id]|name = <?php echo "taxonomy_item_content[$language_id][language_id]";?>
[data-v-languages] [data-v-language_id]|value = <?php echo $language_id;?>
- @language [data-v-language-lang-name]|innerText = <?php echo ucfirst($language['name']);?>
+ @language [data-v-language-lang-name]|innerText = <?php echo htmlspecialchars(ucfirst($language['name'] ?? ''));?>
@language [data-v-language-*]|innerText = $taxonomy_item['languages'][$language_id]['@@__data-v-language-(*)__@@']
@language [data-v-language-*]|name = <?php echo "taxonomy_item_content[$language_id][@@__data-v-language-(*)__@@]";?>
@language input[data-v-language-*]|value = $taxonomy_item['languages'][$language_id]['@@__data-v-language-(*)__@@']
diff --git a/admin/template/content/edit.tpl b/admin/template/content/edit.tpl
index 38fb16a..48573a6 100755
--- a/admin/template/content/edit.tpl
+++ b/admin/template/content/edit.tpl
@@ -39,7 +39,7 @@
@templates-select-option|before = <?php
if ($optgroup != $option['folder']) {
$optgroup = $option['folder'];
- echo '<optgroup label="' . ucfirst($optgroup ?? '') . '">';
+ echo '<optgroup label="' . htmlspecialchars(ucfirst($optgroup ?? '')) . '">';
}
?>
@@ -52,7 +52,7 @@ if ($optgroup != $option['folder']) {
@templates-select-option|value = <?php echo $option['file'];?>
@templates-select-option|addNewAttribute = <?php if (isset($this->{{type}}['template']) && ($option['file'] == $this->{{type}}['template'])) echo 'selected';?>
-@templates-select-option = <?php echo ucfirst($option['title']);?>
+@templates-select-option = <?php echo htmlspecialchars(ucfirst($option['title'] ?? ''));?>
@@ -68,12 +68,14 @@ 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';?>
+ [data-v-languages] [data-v-language-id]|data-language = $language['code']
+ [data-v-languages] [data-v-language-id]|data-default = <?php if ($language['default']) echo 'true'; else echo 'false';?>
@language [data-v-language-name] = $language['name']
@language [data-v-language-img]|title = $language['name']
- @language [data-v-language-img]|src = <?php echo 'language/' . $language['code'] . '/' . $language['code'] . '.png';?>
+ @language [data-v-language-img]|src = <?php echo 'language/' . htmlspecialchars($language['code']) . '/' . htmlspecialchars($language['code']) . '.png';?>
@language [data-v-language-link]|href = <?php echo '#lang-' . $language['code'] . '-' . $_lang_instance?>
@language [data-v-language-link]|addClass = <?php if ($_i == 0) echo 'active';?>
diff --git a/admin/template/content/fields.tpl b/admin/template/content/fields.tpl
old mode 100644
new mode 100755
diff --git a/admin/template/content/menus.tpl b/admin/template/content/menus.tpl
old mode 100644
new mode 100755
diff --git a/admin/template/content/menus/menu.tpl b/admin/template/content/menus/menu.tpl
old mode 100644
new mode 100755
index ab45618..eced1ae
--- a/admin/template/content/menus/menu.tpl
+++ b/admin/template/content/menus/menu.tpl
@@ -63,7 +63,7 @@ if ($_categories) {
foreach($_categories as $id => $menu) {
$uniq = Vvveb\System\Functions\Str::random(5);
- $menu_id = 'menu-' . $menu['menu_item_id'];
+ $menu_id = 'menu-' . $menu['menu_item_id'] . '-thumb';
$menu_input = "menu-{$menu['menu_item_id']}-input";
$menu_hash = "#$menu_id";
@@ -126,7 +126,7 @@ foreach ($languages as $key => $language) {
[data-v-languages] input[data-v-language_id]|value = <?php echo $language_id;?>
[data-v-languages] input[data-v-language_id]|name = <?php echo "menu_item_content[$language_id][language_id]";?>
- @language [data-v-language-lang-name]|innerText = <?php echo ucfirst(htmlspecialchars($language['name']));?>
+ @language [data-v-language-lang-name]|innerText = <?php echo htmlspecialchars(ucfirst($language['name'] ?? ''));?>
@language [data-v-language-*]|innerText = $menu['languages'][$language_id]['@@__data-v-language-(*)__@@']
@language [data-v-language-*]|name = <?php echo "menu_item_content[$language_id][@@__data-v-language-(*)__@@]";?>
@language input[data-v-language-*]|value = $menu['languages'][$language_id]['@@__data-v-language-(*)__@@']
@@ -142,4 +142,4 @@ foreach ($languages as $key => $language) {
?>
-import(content/sites.tpl)
\ No newline at end of file
+import(content/sites.tpl)
diff --git a/admin/template/content/pages.tpl b/admin/template/content/pages.tpl
index b19fdfe..6674693 100755
--- a/admin/template/content/pages.tpl
+++ b/admin/template/content/pages.tpl
@@ -29,8 +29,7 @@ if(isset($this->posts) && is_array($this->posts))
[data-v-posts] [data-v-post] [data-v-img]|src =
<?php
- echo 'http://anne2.givan.ro/image/' .$post['image'];
- //echo htmlspecialchars(str_replace('large', '@@__class:image_([a-zA-Z_]+)__@@', $post['images'][$post['main_image']]['url']));
+ echo '/image/' . htmlspecialchars($post['image'] ?? '');
?>
diff --git a/admin/template/content/post.tpl b/admin/template/content/post.tpl
old mode 100644
new mode 100755
index c84139d..4c2ef85
--- a/admin/template/content/post.tpl
+++ b/admin/template/content/post.tpl
@@ -6,7 +6,7 @@ import(content/edit.tpl, {"type":"post"})
[data-v-post] [data-v-url] = $this->post['url']
[data-v-post] [data-v-design_url]|href = $this->post['design_url']
-[data-v-template_missing] = $this->template_missing
+[data-v-template_missing] = <?php echo $this->template_missing ?? ''?>
[data-v-type_name_plural] = $this->type_name_plural
[data-v-type-name] = $this->type_name
[data-v-type] = $this->type
diff --git a/admin/template/content/posts.tpl b/admin/template/content/posts.tpl
index 582b805..6bf838b 100755
--- a/admin/template/content/posts.tpl
+++ b/admin/template/content/posts.tpl
@@ -5,4 +5,4 @@ import(listing.tpl, {"type":"post", "list": "posts"})
[data-v-type] = $this->type
a[data-v-addurl]|href = $this->addUrl
-import(filters.tpl)
+import(filters.tpl)
\ No newline at end of file
diff --git a/admin/template/content/revisions.tpl b/admin/template/content/revisions.tpl
old mode 100644
new mode 100755
diff --git a/admin/template/content/sites.tpl b/admin/template/content/sites.tpl
old mode 100644
new mode 100755
diff --git a/admin/template/content/tags.tpl b/admin/template/content/tags.tpl
old mode 100644
new mode 100755
diff --git a/admin/template/content/taxonomy.tpl b/admin/template/content/taxonomy.tpl
index 6dfd79d..c5bd7db 100755
--- a/admin/template/content/taxonomy.tpl
+++ b/admin/template/content/taxonomy.tpl
@@ -35,7 +35,7 @@ foreach ($this->languagesList as $language) {
[data-v-languages] [data-v-language] [data-v-language-name] = $language['name']
[data-v-languages] [data-v-language] [data-v-language-img]|title = $language['name']
- [data-v-languages] [data-v-language] [data-v-language-img]|src = <?php echo 'language/' . $language['code'] . '/' . $language['code'] . '.png';?>
+ [data-v-languages] [data-v-language] [data-v-language-img]|src = <?php echo 'language/' . htmlspecialchars($language['code']) . '/' . htmlspecialchars($language['code']) . '.png';?>
[data-v-languages] [data-v-language] [data-v-language-link]|href = <?php echo '#lang-' . $language['code'] . '-' . $_lang_instance?>
[data-v-languages] [data-v-language] [data-v-language-link]|addClass = <?php if ($_i == 0) echo 'active';?>
diff --git a/admin/template/crud.tpl b/admin/template/crud.tpl
index fcc22dc..6c4eb2e 100755
--- a/admin/template/crud.tpl
+++ b/admin/template/crud.tpl
@@ -42,7 +42,7 @@ import(common.tpl)
[data-v-{{type}}] [data-v-{{type}}-*] [data-v-option]|value = $value
[data-v-{{type}}] [data-v-{{type}}-*] [data-v-option]|addNewAttribute = <?php if ($value == $selected) echo 'selected';?>
- [data-v-{{type}}] [data-v-{{type}}-*] [data-v-option] = <?php if (is_array($text)) { if (isset($text['name'])) echo Vvveb\humanReadable($text['name']);} else echo Vvveb\humanReadable($text);?>
+ [data-v-{{type}}] [data-v-{{type}}-*] [data-v-option] = <?php if (is_array($text)) { if (isset($text['name'])) echo htmlspecialchars(Vvveb\humanReadable($text['name']));} else echo htmlspecialchars(Vvveb\humanReadable($text));?>
[data-v-{{type}}] [data-v-{{type}}-*] [data-v-option]|after = <?php
} ?>
diff --git a/admin/template/editor/editor.tpl b/admin/template/editor/page-builder.tpl
old mode 100644
new mode 100755
similarity index 100%
rename from admin/template/editor/editor.tpl
rename to admin/template/editor/page-builder.tpl
diff --git a/admin/template/error403.tpl b/admin/template/error403.tpl
index dc8eade..8c073a4 100755
--- a/admin/template/error403.tpl
+++ b/admin/template/error403.tpl
@@ -6,6 +6,7 @@ import(ifmacros.tpl)
[data-v-exception-lines] [data-v-exception-line]|deleteAllButFirstChild
[data-v-exception-lines] [data-v-exception-line]|before = <?php
+if (isset($this->lines) && is_array($this->lines)) {
foreach ($this->lines as $index => $line) {?>
[data-v-exception-lines] [data-v-exception-line] = $line
@@ -13,7 +14,7 @@ foreach ($this->lines as $index => $line) {?>
[data-v-exception-lines] [data-v-exception-line]|addClass = <?php if ($index == 7) echo 'selected';?>
[data-v-exception-lines] [data-v-exception-line]|after = <?php
-} ?>
+} } ?>
body|prepend = <?php $debug = constant('DEBUG');?>
[data-debug]|if_exists = $debug
diff --git a/admin/template/error404.tpl b/admin/template/error404.tpl
index 3599585..df6aea9 100755
--- a/admin/template/error404.tpl
+++ b/admin/template/error404.tpl
@@ -1,6 +1,7 @@
import(admin.tpl)
import(ifmacros.tpl)
+[data-v-message]|innerText = $this->message
[data-v-exception-*]|innerText = $this->@@__data-v-exception-(*)__@@
[data-v-exception-lines] [data-v-exception-line]|deleteAllButFirstChild
diff --git a/admin/template/error500.tpl b/admin/template/error500.tpl
index dfa91d7..dbc97b6 100755
--- a/admin/template/error500.tpl
+++ b/admin/template/error500.tpl
@@ -1,10 +1,11 @@
import(admin.tpl)
import(ifmacros.tpl)
+[data-v-message]|innerText = $this->message
[data-v-exception-*]|innerText = $this->@@__data-v-exception-(*)__@@
[data-v-debug]|before = <?php if (defined('DEBUG') && DEBUG == true) { ?>
-[data-v-debug]|after = <?php } ?>
+[data-v-debug]|after = <?php } ?>
[data-v-exception-lines] [data-v-exception-line]|deleteAllButFirstChild
diff --git a/admin/template/field.tpl b/admin/template/field.tpl
old mode 100644
new mode 100755
diff --git a/admin/template/field/field-group.tpl b/admin/template/field/field-group.tpl
index 58251e2..141237d 100755
--- a/admin/template/field/field-group.tpl
+++ b/admin/template/field/field-group.tpl
@@ -135,4 +135,4 @@ if(isset($this->fieldTypes) && is_array($this->fieldTypes)) {
@option = $option['name']
@option|addNewAttribute = <?php if($option['type'] == $groupSubtype) echo 'selected';?>
-@option|after = <?php } ?>
\ No newline at end of file
+@option|after = <?php } ?>
diff --git a/admin/template/field/field-group/renderfields.tpl b/admin/template/field/field-group/renderfields.tpl
new file mode 100755
index 0000000..a6766f7
--- /dev/null
+++ b/admin/template/field/field-group/renderfields.tpl
@@ -0,0 +1,25 @@
+import(fields/*.tpl)
+import(field.tpl);
+
+body|append = <?php
+foreach ($this->fields as $name => $field) {
+ if (!$field) continue;
+ $function = 'field_' . $field['type'];
+ $function($field);
+}
+?>
+
+[data-v-field-google_map] input.address|value = $field['value']['address']
+[data-v-field-google_map] input.lat|value = $field['value']['lat']
+[data-v-field-google_map] input.long|value = $field['value']['long']
+[data-v-field-google_map] input.zoom|value = $field['value']['zoom']
+
+[data-v-field-google_map] input.address|name = <?php echo $field['name'] . '[address]';?>
+[data-v-field-google_map] input.lat|name = <?php echo $field['name'] . '[lat]';?>
+[data-v-field-google_map] input.long|name = <?php echo $field['name'] . '[long]';?>
+[data-v-field-google_map] input.zoom|name = <?php echo $field['name'] . '[zoom]';?>
+
+
+//[data-v-field-google_map] input.zoom|style = <?php echo "background:red";?>
+
+import(ifmacros.tpl);
diff --git a/admin/template/fields/accordion.tpl b/admin/template/fields/accordion.tpl
new file mode 100755
index 0000000..1044bfd
--- /dev/null
+++ b/admin/template/fields/accordion.tpl
@@ -0,0 +1 @@
+body|append = from(fields/accordion.html|body > *)
diff --git a/admin/template/fields/checkbox.tpl b/admin/template/fields/checkbox.tpl
new file mode 100755
index 0000000..db7fdf5
--- /dev/null
+++ b/admin/template/fields/checkbox.tpl
@@ -0,0 +1,5 @@
+body|append = from(fields/checkbox.html|body > *)
+
+[data-v-field-checkbox] input|addNewAttribute = <?php if ((isset($field['checked']) && $field['checked'])) echo 'checked';?>
+[data-v-field-checkbox] input|value = $field['value']
+
diff --git a/admin/template/fields/color.tpl b/admin/template/fields/color.tpl
new file mode 100755
index 0000000..d1a11f2
--- /dev/null
+++ b/admin/template/fields/color.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/color.html|body > *)
+
diff --git a/admin/template/fields/date.tpl b/admin/template/fields/date.tpl
new file mode 100755
index 0000000..49bf58e
--- /dev/null
+++ b/admin/template/fields/date.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/date.html|body > *)
+
diff --git a/admin/template/fields/date_time.tpl b/admin/template/fields/date_time.tpl
new file mode 100755
index 0000000..c4fbb14
--- /dev/null
+++ b/admin/template/fields/date_time.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/date_time.html|body > *)
+
diff --git a/admin/template/fields/email.tpl b/admin/template/fields/email.tpl
new file mode 100755
index 0000000..b1669ec
--- /dev/null
+++ b/admin/template/fields/email.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/email.html|body > *)
+
diff --git a/admin/template/fields/file.tpl b/admin/template/fields/file.tpl
new file mode 100755
index 0000000..ac16f20
--- /dev/null
+++ b/admin/template/fields/file.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/file.html|body > *)
+
diff --git a/admin/template/fields/gallery.tpl b/admin/template/fields/gallery.tpl
new file mode 100755
index 0000000..615d31c
--- /dev/null
+++ b/admin/template/fields/gallery.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/gallery.html|body > *)
+
diff --git a/admin/template/fields/google_map.tpl b/admin/template/fields/google_map.tpl
new file mode 100755
index 0000000..94d9335
--- /dev/null
+++ b/admin/template/fields/google_map.tpl
@@ -0,0 +1,3 @@
+body|append = from(fields/google_map.html|body > *)
+
+
diff --git a/admin/template/fields/hidden.tpl b/admin/template/fields/hidden.tpl
new file mode 100755
index 0000000..50fb217
--- /dev/null
+++ b/admin/template/fields/hidden.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/hidden.html|body > *)
+
diff --git a/admin/template/fields/image.tpl b/admin/template/fields/image.tpl
new file mode 100755
index 0000000..27499f8
--- /dev/null
+++ b/admin/template/fields/image.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/image.html|body > *)
+
diff --git a/admin/template/fields/link.tpl b/admin/template/fields/link.tpl
new file mode 100755
index 0000000..a8b8dec
--- /dev/null
+++ b/admin/template/fields/link.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/link.html|body > *)
+
diff --git a/admin/template/fields/message.tpl b/admin/template/fields/message.tpl
new file mode 100755
index 0000000..b48dc03
--- /dev/null
+++ b/admin/template/fields/message.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/message.html|body > *)
+
diff --git a/admin/template/fields/month.tpl b/admin/template/fields/month.tpl
new file mode 100755
index 0000000..07f83ad
--- /dev/null
+++ b/admin/template/fields/month.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/month.html|body > *)
+
diff --git a/admin/template/fields/number.tpl b/admin/template/fields/number.tpl
new file mode 100755
index 0000000..91aa7ed
--- /dev/null
+++ b/admin/template/fields/number.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/number.html|body > *)
+
diff --git a/admin/template/fields/oembed.tpl b/admin/template/fields/oembed.tpl
new file mode 100755
index 0000000..1ba52df
--- /dev/null
+++ b/admin/template/fields/oembed.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/oembed.html|body > *)
+
diff --git a/admin/template/fields/optgroup.tpl b/admin/template/fields/optgroup.tpl
new file mode 100755
index 0000000..2dde973
--- /dev/null
+++ b/admin/template/fields/optgroup.tpl
@@ -0,0 +1,39 @@
+body|append = from(fields/optgroup.html|body > *)
+/*
+[data-v-field-*] select|placeholder = $field['placeholder']
+[data-v-field-*] select|name = $field['name']
+[data-v-field-*] select|addNewAttribute = <?php if (isset($field['readonly']) && $field['readonly']) echo 'readonly';?>
+[data-v-field-*] select|addNewAttribute = <?php if (isset($field['required']) && $field['required']) echo 'required';?>
+*/
+
+@select = [data-v-field-optgroup] select
+@optgroup = [data-v-field-optgroup] select optgroup
+@option = [data-v-field-optgroup] select option
+@option|deleteAllButFirstChild
+@optgroup|deleteAllButFirstChild
+
+@optgroup|before = <?php
+$count = 0;
+$option_index = 0;
+$option = [];
+if(isset($field['options']) && is_array($field['options'])) {
+ foreach ($field['options'] as $optname => $options) { ?>
+
+ @optgroup|label = <?php echo htmlspecialchars(ucfirst($optname));?>
+
+ @option|before = <?php
+ foreach ($options as $value => $name) { ?>
+
+
+ @option|innerText = $name
+ @option|value = $value
+
+ @option|addNewAttribute = <?php if (isset($field['value']) && $field['value'] == $value) echo 'selected';?>
+
+ @option|after = <?php
+ $count++;
+ } ?>
+
+ @optgroup|after = <?php
+ }
+}?>
diff --git a/admin/template/fields/password.tpl b/admin/template/fields/password.tpl
new file mode 100755
index 0000000..fe6d3f4
--- /dev/null
+++ b/admin/template/fields/password.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/password.html|body > *)
+
diff --git a/admin/template/fields/post.tpl b/admin/template/fields/post.tpl
new file mode 100755
index 0000000..eb62db9
--- /dev/null
+++ b/admin/template/fields/post.tpl
@@ -0,0 +1 @@
+body|append = from(fields/post.html|body > *)
diff --git a/admin/template/fields/product.tpl b/admin/template/fields/product.tpl
new file mode 100755
index 0000000..30991c3
--- /dev/null
+++ b/admin/template/fields/product.tpl
@@ -0,0 +1 @@
+body|append = from(fields/product.html|body > *)
diff --git a/admin/template/fields/radio.tpl b/admin/template/fields/radio.tpl
new file mode 100755
index 0000000..502e708
--- /dev/null
+++ b/admin/template/fields/radio.tpl
@@ -0,0 +1,4 @@
+body|append = from(fields/radio.html|body > *)
+
+[data-v-field-checkbox] input|addNewAttribute = <?php if ((isset($field['checked']) && $field['checked'])) echo 'checked';?>
+[data-v-field-checkbox] input|value = $field['value']
diff --git a/admin/template/fields/range.tpl b/admin/template/fields/range.tpl
new file mode 100755
index 0000000..13e5202
--- /dev/null
+++ b/admin/template/fields/range.tpl
@@ -0,0 +1,5 @@
+body|append = from(fields/range.html|body > *)
+
+[data-v-field-range] input|min = $field['min']
+[data-v-field-range] input|max = $field['max']
+
diff --git a/admin/template/fields/select.tpl b/admin/template/fields/select.tpl
new file mode 100755
index 0000000..fc6ee0f
--- /dev/null
+++ b/admin/template/fields/select.tpl
@@ -0,0 +1,32 @@
+body|append = from(fields/select.html|body > *)
+
+[data-v-field-*] select|placeholder = $field['placeholder']
+[data-v-field-*] select|name = $field['name']
+[data-v-field-*] select|rows = $field['rows']
+[data-v-field-*] select|id = <?php if (isset($field['id'])) echo 'field-' . $field['name'] . $field['id'];?>
+[data-v-field-*] select|addNewAttribute = <?php if (isset($field['id'])) echo 'data-v-field-' . $field['id'];?>
+[data-v-field-*] select|addNewAttribute = <?php if (isset($field['readonly']) && $field['readonly']) echo 'readonly';?>
+[data-v-field-*] select|addNewAttribute = <?php if (isset($field['required']) && $field['required']) echo 'required';?>
+
+
+@select = [data-v-field-select] select
+@option = [data-v-field-select] select option
+@option|deleteAllButFirstChild
+
+@option|before = <?php
+$count = 0;
+$option_index = 0;
+$option = [];
+if(isset($field['options']) && is_array($field['options'])) {
+ foreach ($field['options'] as $value => $name) { ?>
+
+
+ @option|innerText = $name
+ @option|value = $value
+
+ @option|addNewAttribute = <?php if (isset($field['value']) && $field['value'] == $value) echo 'selected';?>
+
+ @option|after = <?php
+ $count++;
+ }
+}?>
diff --git a/admin/template/fields/tab.tpl b/admin/template/fields/tab.tpl
new file mode 100755
index 0000000..b187dab
--- /dev/null
+++ b/admin/template/fields/tab.tpl
@@ -0,0 +1 @@
+body|append = from(fields/tab.html|body > *)
diff --git a/admin/template/fields/taxonomy.tpl b/admin/template/fields/taxonomy.tpl
new file mode 100755
index 0000000..0b182bf
--- /dev/null
+++ b/admin/template/fields/taxonomy.tpl
@@ -0,0 +1 @@
+body|append = from(fields/taxonomy.html|body > *)
diff --git a/admin/template/fields/tel.tpl b/admin/template/fields/tel.tpl
new file mode 100755
index 0000000..2f5b5ff
--- /dev/null
+++ b/admin/template/fields/tel.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/tel.html|body > *)
+
diff --git a/admin/template/fields/text.tpl b/admin/template/fields/text.tpl
new file mode 100755
index 0000000..5483105
--- /dev/null
+++ b/admin/template/fields/text.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/text.html|body > *)
+
diff --git a/admin/template/fields/textarea.tpl b/admin/template/fields/textarea.tpl
new file mode 100755
index 0000000..ff02096
--- /dev/null
+++ b/admin/template/fields/textarea.tpl
@@ -0,0 +1,11 @@
+body|append = from(fields/textarea.html|body > *)
+
+[data-v-field-*] textarea|placeholder = $field['placeholder']
+[data-v-field-*] textarea = $field['value']
+[data-v-field-*] textarea|name = $field['name']
+[data-v-field-*] textarea|rows = $field['rows']
+[data-v-field-*] textarea|cols = $field['cols']
+// [data-v-field-*] textarea|id = <?php if (isset($field['id'])) echo 'field-' . $field['name'] . $field['id'];?>
+[data-v-field-*] textarea|addNewAttribute = <?php if (isset($field['id'])) echo 'data-v-field-' . $field['id'];?>
+[data-v-field-*] textarea|addNewAttribute = <?php if (isset($field['readonly']) && $field['readonly']) echo 'readonly';?>
+[data-v-field-*] textarea|addNewAttribute = <?php if (isset($field['required']) && $field['required']) echo 'required';?>
diff --git a/admin/template/fields/time.tpl b/admin/template/fields/time.tpl
new file mode 100755
index 0000000..d9e7094
--- /dev/null
+++ b/admin/template/fields/time.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/time.html|body > *)
+
diff --git a/admin/template/fields/toggle.tpl b/admin/template/fields/toggle.tpl
new file mode 100755
index 0000000..dd34f05
--- /dev/null
+++ b/admin/template/fields/toggle.tpl
@@ -0,0 +1 @@
+body|append = from(fields/toggle.html|body > *)
diff --git a/admin/template/fields/url.tpl b/admin/template/fields/url.tpl
new file mode 100755
index 0000000..8af8b47
--- /dev/null
+++ b/admin/template/fields/url.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/url.html|body > *)
+
diff --git a/admin/template/fields/user.tpl b/admin/template/fields/user.tpl
new file mode 100755
index 0000000..f3422a7
--- /dev/null
+++ b/admin/template/fields/user.tpl
@@ -0,0 +1 @@
+body|append = from(fields/user.html|body > *)
diff --git a/admin/template/fields/week.tpl b/admin/template/fields/week.tpl
new file mode 100755
index 0000000..e91e594
--- /dev/null
+++ b/admin/template/fields/week.tpl
@@ -0,0 +1,2 @@
+body|append = from(fields/week.html|body > *)
+
diff --git a/admin/template/fields/wysiwyg.tpl b/admin/template/fields/wysiwyg.tpl
new file mode 100755
index 0000000..117b4bd
--- /dev/null
+++ b/admin/template/fields/wysiwyg.tpl
@@ -0,0 +1 @@
+body|append = from(fields/wysiwyg.html|body > *)
diff --git a/admin/template/filters.tpl b/admin/template/filters.tpl
old mode 100644
new mode 100755
index 41272b9..36b84d6
--- a/admin/template/filters.tpl
+++ b/admin/template/filters.tpl
@@ -4,7 +4,7 @@
#filters input[name="action"]|after = <?php } ?>
#filters input[name="type"]|value = <?php echo $this->type ?? '';?>
-#filters|addClass = <?php if ($this->filter) echo 'show';?>
+#filters|addClass = <?php if ($this->filter ?? false) echo 'show';?>
#filters input[type="text"],#filters input[type="search"]|value = <?php
$name = str_replace(['filter[',']'], '', '@@__name__@@');
if (isset($this->filter[$name])) echo htmlspecialchars($this->filter[$name]);
@@ -46,4 +46,4 @@ if (isset($this->filter[$text])) echo htmlspecialchars($this->filter[$text]);
@option|addNewAttribute = <?php if ($key == $selected) echo 'selected';?>
#filters #all-sites|addNewAttribute = <?php if (isset($_GET['filter']['site_id']) && !$_GET['filter']['site_id']) echo 'checked';?>
-#filters #current-site|addNewAttribute = <?php if (!isset($_GET['filter']['site_id']) || $_GET['filter']['site_id']) echo 'checked';?>
\ No newline at end of file
+#filters #current-site|addNewAttribute = <?php if (!isset($_GET['filter']['site_id']) || $_GET['filter']['site_id']) echo 'checked';?>
diff --git a/admin/template/localization/currencies.tpl b/admin/template/localization/currencies.tpl
index 05531bf..5a5000b 100755
--- a/admin/template/localization/currencies.tpl
+++ b/admin/template/localization/currencies.tpl
@@ -2,27 +2,4 @@ import(listing.tpl, {"type":"currency", "list": "currencies"})
import(filters.tpl)
-/*
-import(common.tpl)
-import(pagination.tpl)
-
-@currency = [data-v-currencies] [data-v-currency]
-@currency|deleteAllButFirstChild
-
-@currency|before = <?php
-$count = 0;
-if(isset($this->currencies) && is_array($this->currencies)) {
- foreach ($this->currencies as $index => $currency) { ?>
-
- @currency [data-v-*]|innerText = $currency['@@__data-v-(*)__@@']
- @currency input[data-v-*]|value = $currency['@@__data-v-(*)__@@']
- @currency a[data-v-*]|href = $currency['@@__data-v-(*)__@@']
- @currency [data-v-img]|src = $currency['image']
-
- @currency|after = <?php
- $count++;
- }
-}?>
-
-*/
\ No newline at end of file
diff --git a/admin/template/localization/currency.tpl b/admin/template/localization/currency.tpl
old mode 100644
new mode 100755
index 6cc7b8e..1e415c4
--- a/admin/template/localization/currency.tpl
+++ b/admin/template/localization/currency.tpl
@@ -5,4 +5,4 @@ import(crud.tpl, {"type":"currency"})
[data-v-currency] [data-v-image]|data-v-image = $this->currency['image_url']
[data-v-currency] input[data-v-image]|value = $this->currency['image']
-[data-v-currency] img[data-v-image]|src = <?php echo (isset($this->currency['image_url']) && $this->currency['image_url']) ? $this->currency['image_url'] : PUBLIC_PATH . 'media/placeholder.svg';?>
+[data-v-currency] img[data-v-image]|src = <?php echo (isset($this->currency['image_url']) && $this->currency['image_url']) ? $this->currency['image_url'] : PUBLIC_PATH . 'media/placeholder.svg';?>
\ No newline at end of file
diff --git a/admin/template/localization/languages.tpl b/admin/template/localization/languages.tpl
index 78fdb74..9eb2e8a 100755
--- a/admin/template/localization/languages.tpl
+++ b/admin/template/localization/languages.tpl
@@ -2,56 +2,5 @@ import(listing.tpl, {"type":"language", "list": "languages"})
[data-v-language-translations-url]|href = <?php echo Vvveb\url(['module' => 'localization/translations', 'action' => 'domains', 'lang' =>$language['code']]);?>
-/*
-
-import(common.tpl)
-
-[data-v-language-list] option|deleteAllButFirst
-
-[data-v-language-list] option|before = <?php
- foreach ($this->languagesList as $code => $language) {
- $code = $language['code'] ?? '';
- $shortcode = Vvveb\filter('/\w+/',$code);
-
-?>
-
- [data-v-language-list] option img|src = <?php
- echo '/img/flags/' . $shortcode . '.png';
- ?>
-
- [data-v-language-list] option|style = <?php
- echo 'background-image:url(/img/flags/' . $shortcode . '.png)';
- ?>
-
- [data-v-language-list] option|value = $code
- [data-v-language-list] option = <?php
- if (isset($language['emoji'])) {
- echo $language['emoji'] . ' ';
- }
- echo $language['name'];
- ?>
-
-[data-v-language-list] option|after = <?php
-} ?>
-
-
-@language = [data-v-languages] [data-v-language]
-@language|deleteAllButFirst
-
-@language|before = <?php
- foreach ($this->installedLanguages as $code => $language) {
- $locale = $language['locale'] ?? '';
-?>
-
- @language img|src = $language['img']
-
- @language [data-v-language-*]|innerText = $language['@@__data-v-language-(*)__@@']
- @language a[data-v-language-*]|href = $language['@@__data-v-language-(*)__@@']
-
- @language [data-v-language-default]|if_exists = $language['default']
-
-@language|after = <?php
-} ?>
-*/
import(filters.tpl)
diff --git a/admin/template/localization/translations/domain.tpl b/admin/template/localization/translations/domain.tpl
index b538839..a454cf1 100755
--- a/admin/template/localization/translations/domain.tpl
+++ b/admin/template/localization/translations/domain.tpl
@@ -1,5 +1,4 @@
import(common.tpl)
-import(pagination.tpl)
[data-v-save-url]|href = $this->saveUrl
[data-v-domains-url]|href = $this->domainsUrl
diff --git a/admin/template/localization/translations/domains.tpl b/admin/template/localization/translations/domains.tpl
index fd8fd40..0c5f7af 100755
--- a/admin/template/localization/translations/domains.tpl
+++ b/admin/template/localization/translations/domains.tpl
@@ -1,5 +1,5 @@
import(common.tpl)
-
+import(pagination.tpl)
@domain = [data-v-domains] [data-v-domain]
@domain|deleteAllButFirst
diff --git a/admin/template/media/media.tpl b/admin/template/media/media.tpl
index 9c9cc61..201ad9d 100755
--- a/admin/template/media/media.tpl
+++ b/admin/template/media/media.tpl
@@ -16,7 +16,7 @@ foreach ($this->languagesList as $language) {?>
@language [data-v-language-name] = $language['name']
@language [data-v-language-img]|title = $language['name']
- @language [data-v-language-img]|src = <?php echo 'language/' . $language['code'] . '/' . $language['code'] . '.png';?>
+ @language [data-v-language-img]|src = <?php echo 'language/' . htmlspecialchars($language['code']) . '/' . htmlspecialchars($language['code']) . '.png';?>
@language [data-v-language-link]|href = <?php echo '#lang-' . $language['code'] . '-' . $_lang_instance?>
@language [data-v-language-link]|addClass = <?php if ($_i == 0) echo 'active';?>
diff --git a/admin/template/menu.tpl b/admin/template/menu.tpl
old mode 100755
new mode 100644
index f8f856b..d4dfd88
--- a/admin/template/menu.tpl
+++ b/admin/template/menu.tpl
@@ -24,7 +24,7 @@ foreach($this->menu as $key => $menu_item) {
//icon
@menu_item [data-v-menu-item-icon]|if_exists = $menu_item['icon']
- @menu_item [data-v-menu-item-icon]|class = $menu_item['icon']
+ @menu_item [data-v-menu-item-icon-use]|href = <?php echo '/admin/default/img/icons.svg#' . htmlspecialchars($menu_item['icon']); ?>
//icon img
@menu_item [data-v-menu-item-icon-img]|if_exists = $menu_item['icon-img']
@@ -37,6 +37,7 @@ foreach($this->menu as $key => $menu_item) {
@menu_item|addClass = <?php
if (isset($menu_item['heading'])) echo 'heading';
+ if (isset($menu_item['divider'])) echo 'dropdown-divider';
if (isset($menu_item['class'])) echo htmlspecialchars($menu_item['class']);
?>
@menu_item [data-v-menu-item-url]|addClass = <?php if (isset($menu_item['items'])) echo 'items';?>
@@ -46,7 +47,7 @@ foreach($this->menu as $key => $menu_item) {
//@submenumenu_item|id = <?php echo '#menu-' . htmlspecialchars($key);?>
//@submenumenu_item|addClass = <?php echo 'dropdown-menu';?>
@submenumenu_item|addClass = <?php
- if (isset($menu_item['show_on_modules']) && in_array($_GET['module'], $menu_item['show_on_modules'])) echo 'show';
+ if (isset($menu_item['show_on_modules']) && isset($_GET['module']) && in_array($_GET['module'], $menu_item['show_on_modules'])) echo 'show';
?>
//@submenumenu_item|if_exists = $menu_item['items']
@@ -55,9 +56,10 @@ foreach($this->menu as $key => $menu_item) {
if (!function_exists('_admin_menu_print')) {
function _admin_menu_print($items) {
?>
-
+
@submenumenu_item [data-v-submenu-item]|addClass = <?php
if (isset($submenu_item['heading'])) echo ' heading';
+ if (isset($submenu_item['divider'])) echo ' dropdown-divider';
if (isset($submenu_item['class'])) echo htmlspecialchars($submenu_item['class']);
?>
@@ -74,7 +76,7 @@ foreach($this->menu as $key => $menu_item) {
//icon
@submenumenu_item [data-v-submenu-item-icon]|if_exists = $submenu_item['icon']
- @submenumenu_item [data-v-submenu-item-icon]|class = $submenu_item['icon']
+ @submenumenu_item [data-v-submenu-item-icon-use]|href = <?php echo '/admin/default/img/icons.svg#' . htmlspecialchars($submenu_item['icon']); ?>
//icon img
@submenumenu_item [data-v-submenu-item-icon-img]|if_exists = $submenu_item['icon-img']
@@ -106,4 +108,5 @@ foreach($this->menu as $key => $menu_item) {
if (isset($menu_item['items'])) {
_admin_menu_print($menu_item['items']);
}
-} ?>
+}
+?>
diff --git a/admin/template/order/order.tpl b/admin/template/order/order.tpl
old mode 100644
new mode 100755
index 97678e7..c7f50e5
--- a/admin/template/order/order.tpl
+++ b/admin/template/order/order.tpl
@@ -57,6 +57,30 @@ if(is_array($logs)) foreach ($logs as $index => $log) {
@log|after = <?php }?>
+@shipment = [data-v-shipments] [data-v-shipment]
+@shipment|deleteAllButFirstChild
+@shipment|before = <?php
+$shipments = $this->shipment ?? [];
+if(is_array($shipments)) foreach ($shipments as $index => $shipment) {?>
+
+ //catch all data attributes
+ @shipment [data-v-shipment-*]|innerText = $shipment['@@__data-v-shipment-(*)__@@']
+
+@shipment|after = <?php }?>
+
+
+@transaction = [data-v-transactions] [data-v-transaction]
+@transaction|deleteAllButFirstChild
+@transaction|before = <?php
+$transactions = $this->transactions ?? [];
+if(is_array($transactions)) foreach ($transactions as $index => $transaction) {?>
+
+ //catch all data attributes
+ @transaction [data-v-transaction-*]|innerText = $transaction['@@__data-v-transaction-(*)__@@']
+
+@transaction|after = <?php }?>
+
+
[data-v-order] [data-v-order-*]|innerText =
<?php
$name = '@@__data-v-order-(*)__@@';
@@ -81,6 +105,12 @@ if(is_array($logs)) foreach ($logs as $index => $log) {
[data-v-order-print-shipping-url]|href = $this->printShippingUrl
[data-v-order-print-invoice-url]|href = $this->printInvoiceUrl
+#payment-capture-form input[name="order_id"]|value = <?php echo isset($this->order['order_id']) ? $this->order['order_id'] : '';?>
+#payment-capture-form input[name="amount"]|value = <?php echo isset($this->remaining_capture) ? $this->remaining_capture : '';?>
+#payment-refund-form input[name="order_id"]|value = <?php echo isset($this->order['order_id']) ? $this->order['order_id'] : '';?>
+#payment-refund-form input[name="amount"]|value = <?php echo isset($this->remaining_refund) ? $this->remaining_refund : '';?>
+#payment-void-form input[name="order_id"]|value = <?php echo isset($this->order['order_id']) ? $this->order['order_id'] : '';?>
+
@payment = [data-v-payments] [data-v-payment]
@payment|deleteAllButFirstChild
diff --git a/admin/template/order/orders.tpl b/admin/template/order/orders.tpl
index 048720b..095f81b 100755
--- a/admin/template/order/orders.tpl
+++ b/admin/template/order/orders.tpl
@@ -14,9 +14,9 @@ if(isset($this->orders) && is_array($this->orders)) {
[data-v-orders] [data-v-order] [data-v-*]|innerText = $order['@@__data-v-(*)__@@']
[data-v-orders] [data-v-order] input[data-v-*]|value = $order['@@__data-v-(*)__@@']
- [data-v-orders] [data-v-order] .badge[data-v-order_status]|addClass = <?php echo $order['class'];?>
- [data-v-orders] [data-v-order] .badge[data-v-payment_status]|addClass = <?php echo $order['payment_class'];?>
- [data-v-orders] [data-v-order] .badge[data-v-shipping_status]|addClass = <?php echo $order['shipping_class'];?>
+ [data-v-orders] [data-v-order] .badge[data-v-order_status]|addClass = <?php echo $order['class'] ?? '';?>
+ [data-v-orders] [data-v-order] .badge[data-v-payment_status]|addClass = <?php echo $order['payment_class'] ?? '';?>
+ [data-v-orders] [data-v-order] .badge[data-v-shipping_status]|addClass = <?php echo $order['shipping_class'] ?? '';?>
[data-v-orders] [data-v-order]|after = <?php
}
diff --git a/admin/template/order/subscription.tpl b/admin/template/order/subscription.tpl
index 381665b..2f9a087 100755
--- a/admin/template/order/subscription.tpl
+++ b/admin/template/order/subscription.tpl
@@ -1 +1,4 @@
import(crud.tpl, {"type":"subscription"})
+
+/* lifecycle action buttons carry the subscription id */
+[data-v-subscription-action-id]|value = $this->subscription['subscription_id']
diff --git a/admin/template/order/warehouse.tpl b/admin/template/order/warehouse.tpl
new file mode 100755
index 0000000..ea49fa9
--- /dev/null
+++ b/admin/template/order/warehouse.tpl
@@ -0,0 +1,52 @@
+import(crud.tpl, {"type":"warehouse"})
+
+@country = [data-v-countries] [data-v-country]
+@country|deleteAllButFirstChild
+
+@country|before = <?php
+$count = 0;
+$country_index = 0;
+if(isset($this->countries) && is_array($this->countries)) {
+ foreach ($this->countries as $country_index => $country) {?>
+
+ [data-v-country-*]|innerText = $country['@@__data-v-country-(*)__@@']
+ option[data-v-country-*]|value = $country['@@__data-v-country-(*)__@@']
+ @country|addNewAttribute = <?php if (isset($this->warehouse['country_id']) && ($country['country_id'] == $this->warehouse['country_id'])) echo 'selected';?>
+
+ @country|after = <?php
+ $count++;
+ }
+}?>
+
+@region = [data-v-regions] [data-v-region]
+@region|deleteAllButFirstChild
+
+@region|before = <?php
+$count = 0;
+$region_index = 0;
+if(isset($this->regions) && is_array($this->regions)) {
+ foreach ($this->regions as $region_index => $region) {?>
+
+ [data-v-region-*]|innerText = $region['@@__data-v-region-(*)__@@']
+ option[data-v-region-*]|value = $region['@@__data-v-region-(*)__@@']
+ @region|addNewAttribute = <?php if (isset($this->warehouse['region_id']) && ($region['region_id'] == $this->warehouse['region_id'])) echo 'selected';?>
+
+ @region|after = <?php
+ $count++;
+ }
+}?>
+
+//warehouse products
+@warehouse-product = [data-v-warehouse] [data-v-warehouse-product] [data-v-product]
+@warehouse-product|deleteAllButFirst
+
+@warehouse-product|before = <?php
+if(isset($this->warehouse['warehouse_product']) && is_array($this->warehouse['warehouse_product']))
+foreach ($this->warehouse['warehouse_product'] as $warehouse_product_id => $product) {
+?>
+ @warehouse-product input[data-v-product-*]|value = $product['@@__data-v-product-(*)__@@']
+ @warehouse-product [data-v-product-*] = $product['@@__data-v-product-(*)__@@']
+
+@warehouse-product|after = <?php
+ }
+?>
diff --git a/admin/template/order/warehouses.tpl b/admin/template/order/warehouses.tpl
new file mode 100755
index 0000000..cf888ff
--- /dev/null
+++ b/admin/template/order/warehouses.tpl
@@ -0,0 +1 @@
+import(listing.tpl, {"type":"warehouse", "list": "warehouse"})
diff --git a/admin/template/pagination.tpl b/admin/template/pagination.tpl
index d2caf2e..2cec59d 100755
--- a/admin/template/pagination.tpl
+++ b/admin/template/pagination.tpl
@@ -7,7 +7,10 @@
[data-pagination]|before = <?php $maxpages = 5; $visible_pages = 3; if(isset($this->count)) {
if (isset($this->limit)) $limit = $this->limit; else $limit = 10;
-$pagecount = ceil($this->count / $limit);
+$pagecount = 0;
+if ($this->count) {
+ $pagecount = ceil($this->count / $limit);
+}
$page = 1;
$page_stop = $pagecount;
diff --git a/admin/template/plugin/market.tpl b/admin/template/plugin/market.tpl
index e4c6dc2..af00646 100755
--- a/admin/template/plugin/market.tpl
+++ b/admin/template/plugin/market.tpl
@@ -15,8 +15,8 @@ if(isset($this->plugins) && is_array($this->plugins))
@plugin a[data-v-plugin-*]|href = $plugin['@@__data-v-plugin-(.+)__@@']
@plugin img[data-v-plugin-*]|src = $plugin['@@__data-v-plugin-(.+)__@@']
@plugin img[data-v-plugin-icon]|src = $plugin['icon']
- @plugin img[data-v-plugin-*]|src = <?php echo 'https://www.vvveb.com' . $plugin['@@__data-v-plugin-(*)__@@'] ?? ''; ?>
- @plugin a[data-v-plugin-*]|href = <?php echo 'https://plugins.vvveb.com' . $plugin['@@__data-v-plugin-(*)__@@'] ?? ''; ?>
+ @plugin img[data-v-plugin-*]|src = <?php echo htmlspecialchars('https://www.vvveb.com' . ($plugin['@@__data-v-plugin-(*)__@@'] ?? '')); ?>
+ @plugin a[data-v-plugin-*]|href = <?php echo htmlspecialchars('https://plugins.vvveb.com' . ($plugin['@@__data-v-plugin-(*)__@@'] ?? '')); ?>
@plugin [data-v-plugin-install-url]|href = <?php echo Vvveb\url( ['module' => 'plugin/market', 'action' => 'install', 'slug' => $plugin['slug']]); ?>
@plugin [data-v-plugin-install-url]|data-slug = $plugin['slug']
@@ -35,8 +35,8 @@ if(isset($this->categories) && is_array($this->categories)) {
foreach ($this->categories as $category) {?>
@category [data-v-category-link] = $category['name']
- @category [data-v-category-*]|innerText = $category[''@@__data-v-theme-(*)__@@'']
- @category img[data-v-category-*]|src = $category[''@@__data-v-theme-(*)__@@'']
+ @category [data-v-category-*]|innerText = $category['@@__data-v-theme-(*)__@@']
+ @category img[data-v-category-*]|src = $category['@@__data-v-theme-(*)__@@']
@category [data-v-category-link]|addClass = <?php if (isset($this->taxonomy_item_id) && $category['taxonomy_item_id'] == $this->taxonomy_item_id) echo 'active';?>
@category [data-v-category-link]|href = <?php echo htmlspecialchars(Vvveb\url(['module' => 'plugin/market', 'taxonomy_item_id' => $category['taxonomy_item_id']]));?>
diff --git a/admin/template/plugin/plugins_list.tpl b/admin/template/plugin/plugins_list.tpl
index 8d787d2..3eb669d 100755
--- a/admin/template/plugin/plugins_list.tpl
+++ b/admin/template/plugin/plugins_list.tpl
@@ -11,7 +11,7 @@ if(isset($this->plugins) && is_array($this->plugins)) {
if (isset($plugin['system'])) continue;//don't display system plugins
?>
- @plugin|id = <?php echo 'plugin-' . $plugin['slug'];?>
+ @plugin|id = <?php echo 'plugin-' . htmlspecialchars($plugin['slug']);?>
@plugin img[data-v-plugin-screenshot]|src = $plugin['screenshot']
@plugin input[data-v-vvveb-action]|value = $plugin['slug']
diff --git a/admin/template/product/categories.tpl b/admin/template/product/categories.tpl
index 5cc2a09..05b8481 100755
--- a/admin/template/product/categories.tpl
+++ b/admin/template/product/categories.tpl
@@ -93,7 +93,7 @@ foreach ($languages as $key => $language) {
[data-v-languages] [data-v-language_id]|name = <?php echo "taxonomy_item_content[$language_id][language_id]";?>
[data-v-languages] [data-v-language_id]|value = $language_id
- @language [data-v-language-lang-name]|innerText = <?php echo ucfirst($language['name']);?>
+ @language [data-v-language-lang-name]|innerText = <?php echo htmlspecialchars(ucfirst($language['name'] ?? ''));?>
@language [data-v-language-*]|innerText = $taxonomy_item['languages'][$language_id]['@@__data-v-language-(*)__@@']
@language [data-v-language-*]|name = <?php echo "taxonomy_item_content[$language_id][@@__data-v-language-(*)__@@]";?>
@language input[data-v-language-*]|value = $taxonomy_item['languages'][$language_id]['@@__data-v-language-(*)__@@']
@@ -106,4 +106,4 @@ foreach ($languages as $key => $language) {
@language|after = <?php
$_i++;
}
-?>
\ No newline at end of file
+?>
diff --git a/admin/template/product/fields.tpl b/admin/template/product/fields.tpl
index 9679c26..7932ff9 100755
--- a/admin/template/product/fields.tpl
+++ b/admin/template/product/fields.tpl
@@ -1,3 +1,3 @@
import(listing.tpl, {"type":"field", "list": "fields"})
-import(filters.tpl)
+import(filters.tpl)
\ No newline at end of file
diff --git a/admin/template/product/product.tpl b/admin/template/product/product.tpl
index 98ed303..9c87ed9 100755
--- a/admin/template/product/product.tpl
+++ b/admin/template/product/product.tpl
@@ -28,7 +28,7 @@ import(product/product/digital_asset.tpl)
if ($value) echo 'checked';
?>
-[data-v-template_missing] = $this->template_missing
+[data-v-template_missing] = <?php echo $this->template_missing ?>
[data-v-type_name_plural] = $this->type_name_plural
[data-v-type-name] = $this->type_name
[data-v-type] = $this->type
diff --git a/admin/template/product/product/gallery.tpl b/admin/template/product/product/gallery.tpl
old mode 100644
new mode 100755
index 89f6c17..bbb49d7
--- a/admin/template/product/product/gallery.tpl
+++ b/admin/template/product/product/gallery.tpl
@@ -25,11 +25,6 @@ foreach ($this->product['images'] as $product_image_id => $image) {
@image-gallery .product_image_input|data-target-input = $gallery_input_hash
@image-gallery .product_image_input|id = $gallery_input
- /*
- @image-gallery [name="product_image[]"] = $image['image']
- @image-gallery [name="product_image[]"]|data-target-input = $gallery_input_hash
- @image-gallery [name="product_image[]"]|id = $gallery_input
- */
@image-gallery|after = <?php
}
?>
diff --git a/admin/template/product/product/option.tpl b/admin/template/product/product/option.tpl
old mode 100644
new mode 100755
index b2eae3d..6a4cc27
--- a/admin/template/product/product/option.tpl
+++ b/admin/template/product/product/option.tpl
@@ -21,6 +21,8 @@ foreach ($this->product['product_option'] as $product_option_id => $poption) {
@product-option [data-v-poption-option_id]|before = <?php $selected = $poption['option_id'] ?? false;?>
@product-option [data-v-poption-required]|addNewAttribute = <?php if ($poption['required'] == '1') echo 'checked';?>
+ @product-option input[data-v-poption-required]|value = <?php echo '0';?>
+ @product-option input[role="switch"]|value = '1'
@product-option a[data-v-poption-product_option_id]|href = <?php echo '#option-' . $poption['product_option_id'];?>
@product-option a[data-v-poption-product_option_id]|data-id = $poption['product_option_id']
diff --git a/admin/template/product/taxonomy.tpl b/admin/template/product/taxonomy.tpl
index e1d9f9f..84a8236 100755
--- a/admin/template/product/taxonomy.tpl
+++ b/admin/template/product/taxonomy.tpl
@@ -37,7 +37,7 @@ foreach ($this->languagesList as $language) {
[data-v-languages] [data-v-language] [data-v-language-name] = $language['name']
[data-v-languages] [data-v-language] [data-v-language-img]|title = $language['name']
- [data-v-languages] [data-v-language] [data-v-language-img]|src = <?php echo 'language/' . $language['code'] . '/' . $language['code'] . '.png';?>
+ [data-v-languages] [data-v-language] [data-v-language-img]|src = <?php echo 'language/' . htmlspecialchars($language['code']) . '/' . htmlspecialchars($language['code']) . '.png';?>
[data-v-languages] [data-v-language] [data-v-language-link]|href = <?php echo '#lang-' . $language['code'] . '-' . $_lang_instance?>
[data-v-languages] [data-v-language] [data-v-language-link]|addClass = <?php if ($_i == 0) echo 'active';?>
diff --git a/admin/template/settings/email.tpl b/admin/template/settings/email.tpl
index a57424d..ea19eaa 100755
--- a/admin/template/settings/email.tpl
+++ b/admin/template/settings/email.tpl
@@ -33,11 +33,19 @@ import(common.tpl)
#input-mail-driver option|after = <?php
} } ?>
-/*
-.settings select[data-v-setting] option|addNewAttribute = <?php
- $value = '@@__value__@@';
+#input-mail-smtp-encryption option|deleteAllButFirst
+
+#input-mail-smtp-encryption option|before = <?php
+ if (isset($this->smtp_encryption_options)) {
$setting = $_POST['settings'][$_setting] ?? \Vvveb\arrayPath($this->email, $_setting) ?? '';
- if ($setting == $value) echo 'selected';
-?>
+ foreach ($this->smtp_encryption_options as $value => $text) {
+ ?>
+
+ #input-mail-smtp-encryption option|innerText = $text
+ #input-mail-smtp-encryption option|value = $value
+ #input-mail-smtp-encryption option|addNewAttribute = <?php if ($setting == $value) echo 'selected';?>
+
+#input-mail-smtp-encryption option|after = <?php
+} } ?>
+
-*/
diff --git a/admin/template/settings/notifications.tpl b/admin/template/settings/notifications.tpl
new file mode 100755
index 0000000..39dec40
--- /dev/null
+++ b/admin/template/settings/notifications.tpl
@@ -0,0 +1,186 @@
+import(common.tpl)
+
+[data-v-notif-category]|deleteAllButFirst
+
+[data-v-notif-category]|before = <?php
+$categoryLabels = $this->categories ?? [];
+foreach (($this->groupedEvents ?? []) as $cat => $catEvents) { ?>
+
+[data-v-category-name] = <?php echo $categoryLabels[$cat] ?? ucfirst($cat); ?>
+
+[data-v-event-row]|deleteAllButFirst
+
+[data-v-event-row]|before = <?php
+ $webhookNames = array_values((array) ($this->webhookNames ?? []));
+ foreach ($catEvents as $evt) {
+ $eventName = $evt['event'];
+ $cfg = ($this->events ?? [])[$eventName] ?? [];
+ $evtProviders = $cfg['providers'] ?? ['email'];
+ $evtRecipients = $cfg['recipients'] ?? ($evt['default_recipients'] ?? ['site_admin']);
+ $extraEmails = implode(', ', $cfg['additional_emails'] ?? []);
+ $extraPhones = implode(', ', $cfg['additional_phones'] ?? []);
+ $evtWebhooks = $cfg['additional_webhooks'] ?? [];
+?>
+
+[data-v-event-name] = <?php echo $eventName; ?>
+
+[data-v-event-desc] = <?php echo htmlspecialchars($evt['description']); ?>
+
+
+/* recipient checkboxes */
+[data-v-recipient-check]|deleteAllButFirst
+
+[data-v-recipient-check]|before = <?php
+ foreach (['site_admin' => 'Site admin', 'user' => 'User (subject)', 'admin_user' => 'Admin user'] as $rt => $rl) { ?>
+
+[data-v-recipient-check] .recipient-check-input|value = <?php echo $rt; ?>
+
+[data-v-recipient-check] .recipient-check-input|name = <?php echo 'settings[events][' . $eventName . '][recipients][]';?>
+
+[data-v-recipient-check] .recipient-check-input|addNewAttribute = <?php if (in_array($rt, $evtRecipients)) echo 'checked';?>
+
+[data-v-recipient-label] = <?php echo $rl; ?>
+
+[data-v-recipient-check]|after = <?php } ?>
+
+
+/* provider checkboxes */
+[data-v-provider-check]|deleteAllButFirst
+
+[data-v-provider-check]|before = <?php
+ foreach (($this->providerSlugs ?? []) as $ps) { ?>
+
+[data-v-provider-check] .provider-check-input|value = <?php echo $ps; ?>
+
+[data-v-provider-check] .provider-check-input|name = <?php echo 'settings[events][' . $eventName . '][providers][]';?>
+
+[data-v-provider-check] .provider-check-input|addNewAttribute = <?php if (in_array($ps, $evtProviders)) echo 'checked';?>
+
+[data-v-provider-label] = <?php echo ucfirst($ps); ?>
+
+[data-v-provider-check]|after = <?php } ?>
+
+
+/* extra emails / phones */
+.extra-emails|name = <?php echo 'settings[events][' . $eventName . '][additional_emails]';?>
+
+.extra-emails|value = <?php echo htmlspecialchars($extraEmails); ?>
+
+.extra-phones|name = <?php echo 'settings[events][' . $eventName . '][additional_phones]';?>
+
+.extra-phones|value = <?php echo htmlspecialchars($extraPhones); ?>
+
+
+/* named webhook checkboxes */
+[data-v-webhook-check]|deleteAllButFirst
+
+[data-v-webhook-check]|before = <?php
+ if (! $webhookNames) {
+ echo '<!-- no webhooks defined -->';
+ }
+ foreach ($webhookNames as $whName) { ?>
+
+[data-v-webhook-check] .webhook-check-input|value = <?php echo $whName; ?>
+
+[data-v-webhook-check] .webhook-check-input|name = <?php echo 'settings[events][' . $eventName . '][additional_webhooks][]';?>
+
+[data-v-webhook-check] .webhook-check-input|addNewAttribute = <?php if (in_array($whName, $evtWebhooks)) echo 'checked';?>
+
+[data-v-webhook-label] = <?php echo $whName; ?>
+
+[data-v-webhook-check]|after = <?php } ?>
+
+[data-v-no-webhooks]|addNewAttribute = <?php if ($webhookNames) echo 'style="display:none"';?>
+
+[data-v-event-row]|after = <?php } ?>
+
+[data-v-notif-category]|after = <?php } ?>
+
+
+[data-v-provider-card]|deleteAllButFirst
+
+[data-v-provider-card]|before = <?php
+$providersCfg = $this->providers ?? [];
+$providerFieldsAll = $this->providerFields ?? [];
+
+foreach (($this->providerSlugs ?? []) as $slug) {
+ $provConfig = $providersCfg[$slug] ?? [];
+ $fields = $providerFieldsAll[$slug] ?? [];
+ $isEnabled = $provConfig['enabled'] ?? false;
+?>
+
+[data-v-provider-name] = <?php echo ucfirst($slug); ?>
+
+[data-v-provider-card] .provider-enabled-input|name = <?php echo 'settings[providers][' . $slug . '][enabled]';?>
+
+[data-v-provider-card] .provider-enabled-input|addNewAttribute = <?php if ($isEnabled) echo 'checked';?>
+
+
+/* generic settings fields (skip 'list' type — rendered by dedicated editors) */
+[data-v-provider-field]|deleteAllButFirst
+
+[data-v-provider-field]|before = <?php
+ foreach ($fields as $field) {
+ if (($field['type'] ?? '') === 'list') continue;
+ $type = $field['type'] ?? 'text';
+ $name = $field['name'] ?? '';
+ $val = $provConfig[$name] ?? '';
+ $fname = 'settings[providers][' . $slug . '][' . $name . ']';
+?>
+
+[data-v-field-label] = <?php echo htmlspecialchars($field['label'] ?? $name); ?>
+
+[data-v-provider-field] .field-input|outerHTML = <?php
+ if ($type === 'textarea') {
+ echo '<textarea class="form-control field-input" name="' . htmlspecialchars($fname) . '" rows="2"' . (!empty($field['placeholder']) ? ' placeholder="' . htmlspecialchars($field['placeholder']) . '"' : '') . '>' . htmlspecialchars((string) $val) . '</textarea>';
+ } else {
+ $htmlType = in_array($type, ['password', 'url', 'number'], true) ? $type : 'text';
+ echo '<input type="' . $htmlType . '" class="form-control field-input" name="' . htmlspecialchars($fname) . '" value="' . htmlspecialchars((string) $val) . '"' . (!empty($field['placeholder']) ? ' placeholder="' . htmlspecialchars($field['placeholder']) . '"' : '') . '>';
+ }
+?>
+
+[data-v-field-desc] = <?php echo htmlspecialchars($field['description'] ?? ''); ?>
+
+[data-v-provider-field]|after = <?php } ?>
+
+
+/* webhooks editor only applies to the webhooks provider card */
+[data-v-webhooks-editor]|addNewAttribute = <?php if ($slug !== 'webhooks') echo 'style="display:none"';?>
+
+
+[data-v-webhook-row]|deleteAllButFirst
+
+[data-v-webhook-row]|before = <?php
+ if ($slug === 'webhooks') {
+ foreach ($provConfig['webhooks'] ?? [] as $wi => $wh) {
+ $wbase = 'settings[providers][webhooks][webhooks][' . $wi . ']';
+?>
+
+.wh-enabled|name = <?php echo $wbase . '[enabled]';?>
+
+.wh-enabled|addNewAttribute = <?php if (! empty($wh['enabled'])) echo 'checked';?>
+
+.wh-name|name = <?php echo $wbase . '[name]';?>
+
+.wh-name|value = <?php echo htmlspecialchars($wh['name'] ?? ''); ?>
+
+.wh-url|name = <?php echo $wbase . '[url]';?>
+
+.wh-url|value = <?php echo htmlspecialchars($wh['url'] ?? ''); ?>
+
+.wh-method|name = <?php echo $wbase . '[method]';?>
+
+.wh-method option|addNewAttribute = <?php if (($wh['method'] ?? 'POST') == '@@__value__@@') echo 'selected';?>
+
+.wh-headers|name = <?php echo $wbase . '[headers]';?>
+
+.wh-headers = <?php echo htmlspecialchars(is_array($wh['headers'] ?? '') ? implode("\n", array_map(fn ($k, $v) => "$k: $v", array_keys($wh['headers']), $wh['headers'])) : ($wh['headers'] ?? '')); ?>
+
+[data-v-webhook-row]|after = <?php } } ?>
+
+[data-v-provider-card]|after = <?php } ?>
+
+
+#low-stock-threshold|value = <?php echo htmlspecialchars((string) ($this->lowStockThreshold ?? '')); ?>
+
+#global-cooldown|value = <?php echo htmlspecialchars((string) ($this->providers['global']['cooldown'] ?? '')); ?>
diff --git a/admin/template/settings/site.tpl b/admin/template/settings/site.tpl
old mode 100644
new mode 100755
index 888389b..2ca6574
--- a/admin/template/settings/site.tpl
+++ b/admin/template/settings/site.tpl
@@ -170,30 +170,7 @@ select[data-v-formats]|before =
[data-v-formats] [data-v-option]|after = <?php
} ?>
-/*
-select[data-v-setting]|before =
-<?php
- $name = '@@__data-v-setting__@@';
-
- $selected = '';
- if (isset($this->setting[$name]))
- $selected = $this->setting[$name];
-?>
-
-[data-v-setting] [data-v-option]|deleteAllButFirstChild
-[data-v-setting] [data-v-option]|before = <?php
- if (isset($this->$name))
- foreach ($this->$name as $value => $text) {
- ?>
-
- [data-v-setting] [data-v-option]|value = $value
- [data-v-setting] [data-v-option]|addNewAttribute = <?php if ($value == $selected) echo 'selected';?>
- [data-v-setting] [data-v-option] = $text
-
-[data-v-setting] [data-v-option]|after = <?php
-} ?>
-*/
input[type="checkbox"][data-v-setting]|addNewAttribute = <?php
if (isset($this->setting[$_setting])) echo 'checked';
@@ -332,4 +309,50 @@ foreach ($this->modules as $namespace => $module) {
[name="routes-type"]|addNewAttribute = <?php if (isset($this->routesType) && $this->routesType == '@@__value__@@') echo 'checked';?>
-#siteRoutes|style = <?php if (isset($this->routesType) && $this->routesType == 'global') echo 'display:none';?>
\ No newline at end of file
+#siteRoutes|style = <?php if (isset($this->routesType) && $this->routesType == 'global') echo 'display:none';?>
+
+
+[data-v-payment]|deleteAllButFirst
+[data-v-payment]|before = <?php
+ if ($this->paymentMethods) {
+ foreach ($this->paymentMethods as $key => $payment) {
+?>
+
+ [data-v-payment] [data-v-payment-*] = $payment['@@__data-v-payment-(*)__@@']
+
+ [data-v-payment] input[data-v-payment-key] = $key
+ [data-v-payment] input[data-v-payment-key]|id = <?php echo 'payment-' . htmlspecialchars($key);?>
+ [data-v-payment] [data-v-payment-title]|for = <?php echo 'payment-' . htmlspecialchars($key);?>
+
+ [data-v-payment] input[data-v-payment-key]|addNewAttribute = <?php
+ if (isset($this->site['payment_method']) && ($key == $this->site['payment_method'])) echo 'checked'
+ ?>
+
+[data-v-payment]|after = <?php
+ }
+ }
+?>
+
+[data-v-shipping]|deleteAllButFirst
+[data-v-shipping]|before = <?php
+ if ($this->shippingMethods) {
+ foreach ($this->shippingMethods as $key => $shipping) {
+?>
+
+ [data-v-shipping-*] = $shipping['@@__data-v-shipping-(*)__@@']
+
+ [data-v-shipping] input[data-v-shipping-key] = $key
+ [data-v-shipping] input[data-v-shipping-key]|id = <?php echo 'shipping-' . htmlspecialchars($key);?>
+ [data-v-shipping] [data-v-shipping-title]|for = <?php echo 'shipping-' . htmlspecialchars($key);?>
+
+ [data-v-shipping] input[data-v-shipping-key]|addNewAttribute = <?php
+ if (isset($this->site['shipping_method']) && ($key == $this->site['shipping_method'])) echo 'checked'
+ ?>
+
+
+[data-v-shipping]|after = <?php
+ }
+ }
+?>
+/* catalogue prices include tax toggle */
+input[data-v-setting-prices_include_tax][type=checkbox]|addNewAttribute = <?php if (! empty($this->setting['prices_include_tax'])) echo 'checked';?>
diff --git a/admin/template/settings/sites.tpl b/admin/template/settings/sites.tpl
index 729fea4..8917ecf 100755
--- a/admin/template/settings/sites.tpl
+++ b/admin/template/settings/sites.tpl
@@ -26,4 +26,4 @@ if(isset($this->sitesList) && is_array($this->sitesList)) {
@site|after = <?php
}
-}?>
+}?>
\ No newline at end of file
diff --git a/admin/template/settings/tax-rate.tpl b/admin/template/settings/tax-rate.tpl
index 6d2a5f4..048eb62 100755
--- a/admin/template/settings/tax-rate.tpl
+++ b/admin/template/settings/tax-rate.tpl
@@ -15,3 +15,18 @@ if(isset($this->region_groups) && is_array($this->region_groups)) {
$count++;
}
}?>
+
+form[data-v-tax_rate]|append = <?php
+if (! empty($this->user_groups)) {
+ echo '<div class="mb-3 row"><label class="col-sm-2 col-form-label">' . htmlspecialchars($this->user_groups_label ?? 'Customer groups') . '</label><div class="col-sm-10">';
+ echo '<div class="form-text mb-2">' . htmlspecialchars($this->user_groups_hint ?? '') . '</div>';
+ $selected = $this->rate_user_groups ?? [];
+ foreach ($this->user_groups as $user_group) {
+ $id = (int)($user_group['user_group_id'] ?? 0);
+ $name = htmlspecialchars($user_group['name'] ?? ('#' . $id));
+ $checked = in_array($id, $selected) ? ' checked' : '';
+ echo '<div class="form-check"><input class="form-check-input" type="checkbox" name="user_group[]" value="' . $id . '"' . $checked . '><label class="form-check-label">' . $name . '</label></div>';
+ }
+ echo '</div></div>';
+}
+?>
diff --git a/admin/template/theme/market.tpl b/admin/template/theme/market.tpl
old mode 100644
new mode 100755
index d1906e5..583801a
--- a/admin/template/theme/market.tpl
+++ b/admin/template/theme/market.tpl
@@ -11,8 +11,8 @@ if(isset($this->themes) && is_array($this->themes)) {
@theme [data-v-theme-*]|innerText = $theme['@@__data-v-theme-(*)__@@']
@theme button[data-v-theme-*]|value = $theme['@@__data-v-theme-(*)__@@']
@theme a[data-v-theme-*]|href = $theme['@@__data-v-theme-(*)__@@']
- @theme img[data-v-theme-*]|src = <?php echo 'https://themes.vvveb.com' . $theme['@@__data-v-theme-(*)__@@']; ?>
- @theme a[data-v-theme-*]|href = <?php echo 'https://themes.vvveb.com' . $theme['@@__data-v-theme-(*)__@@'] ?? ''; ?>
+ @theme img[data-v-theme-*]|src = <?php echo htmlspecialchars('https://themes.vvveb.com' . ($theme['@@__data-v-theme-(*)__@@'] ?? '')); ?>
+ @theme a[data-v-theme-*]|href = <?php echo htmlspecialchars('https://themes.vvveb.com' . ($theme['@@__data-v-theme-(*)__@@'] ?? '')); ?>
@theme [data-v-theme-install-url]|href = <?php echo Vvveb\url( ['module' => 'theme/market', 'action' => 'install', 'slug' => $theme['slug']]); ?>
@theme [data-v-theme-install-url]|data-slug = $theme['slug']
@@ -29,8 +29,8 @@ if(isset($this->categories) && is_array($this->categories)) {
foreach ($this->categories as $category) {?>
@category [data-v-category-link] = $category['name']
- @category [data-v-category-*]|innerText = $category[''@@__data-v-theme-(*)__@@'']
- @category img[data-v-category-*]|src = $category[''@@__data-v-theme-(*)__@@'']
+ @category [data-v-category-*]|innerText = $category['@@__data-v-theme-(*)__@@']
+ @category img[data-v-category-*]|src = $category['@@__data-v-theme-(*)__@@']
@category [data-v-category-link]|addClass = <?php if (isset($this->taxonomy_item_id) && $category['taxonomy_item_id'] == $this->taxonomy_item_id) echo 'active';?>
@category [data-v-category-link]|href = <?php echo htmlspecialchars(Vvveb\url(['module' => 'theme/market', 'taxonomy_item_id' => $category['taxonomy_item_id']]));?>
diff --git a/admin/template/theme/themes_list.tpl b/admin/template/theme/themes_list.tpl
index 85e1d94..dc2acb6 100755
--- a/admin/template/theme/themes_list.tpl
+++ b/admin/template/theme/themes_list.tpl
@@ -15,7 +15,7 @@ if(isset($this->themes) && is_array($this->themes)) {
[data-v-themes] [data-v-theme] [data-v-theme-duplicate-url]|href = <?php echo Vvveb\url(['module' => 'theme/themes', 'action' => 'duplicate', 'theme' => $theme['folder']]);?>
[data-v-themes] [data-v-theme] [data-v-theme-delete-url]|href = <?php echo Vvveb\url(['module' => 'theme/themes', 'action' => 'delete', 'theme' => $theme['folder']]);?>
[data-v-themes] [data-v-theme] [data-v-theme-preview-url]|href = <?php echo Vvveb\url('index/index') . '?theme=' . $theme['folder'];?>
- [data-v-themes] [data-v-theme] [data-v-theme-edit-url]|href = <?php echo Vvveb\url(['module' => 'editor/editor']) . '&url=/&template=index.html&theme=' . $theme['folder'];?>
+ [data-v-themes] [data-v-theme] [data-v-theme-edit-url]|href = <?php echo Vvveb\url(['module' => 'editor/page-builder']) . '&url=/&template=index.html&theme=' . $theme['folder'];?>
[data-v-themes] [data-v-theme] [data-v-theme-code-url]|href = <?php echo Vvveb\url(['module' => 'editor/code']) . '&type=themes#%2F' . $theme['folder'];?>
[data-v-themes] [data-v-theme] [data-v-theme-fonts-url]|href = <?php echo Vvveb\url(['module' => 'theme/fonts', 'theme' => $theme['folder']]);?>
[data-v-themes] [data-v-theme]|after = <?php
@@ -36,7 +36,7 @@ if (!function_exists("import_generate_list")) {
$import_generate_list = function (&$import, $path) use ($list, &$import_generate_list) {
foreach ($import as $name => $value ) {
$hasChildren = is_array($value);
- $uniqId = $name . rand();
+ $uniqId = $name . random_int(0, PHP_INT_MAX);
?>
diff --git a/admin/template/tools/media-backup.tpl b/admin/template/tools/media-backup.tpl
new file mode 100755
index 0000000..85af493
--- /dev/null
+++ b/admin/template/tools/media-backup.tpl
@@ -0,0 +1,43 @@
+import(common.tpl)
+
+[data-v-media-count]|innerText = $this->mediaCount
+[data-v-media-size]|innerText = $this->mediaSize
+
+@backup = [data-v-backups] [data-v-backup]
+@backup|deleteAllButFirstChild
+
+@backupFile = [data-v-backups] [data-v-backup] [data-v-backup-files] [data-v-backup-file]
+@backupFile|deleteAllButFirstChild
+
+@backup|before = <?php
+$count = 0;
+if(isset($this->backups) && is_array($this->backups)) {
+ foreach ($this->backups as $index => $backup) {
+ $key = 'key-' . $backup['key'];
+ $count++;
+ ?>
+
+ @backup [data-v-backup-target]|data-bs-target = <?php echo '#' . $key;?>
+ @backup [data-v-backup-id]|id = $key
+
+ @backup [data-v-backup-*]|innerText = $backup['@@__data-v-backup-(*)__@@']
+ @backup input[data-v-backup-*]|value = $backup['@@__data-v-backup-(*)__@@']
+ @backup button[data-v-backup-*]|value = $backup['@@__data-v-backup-(*)__@@']
+
+ @backup a[data-v-backup-*]|href = $backup['@@__data-v-backup-(*)__@@']
+
+ @backupFile|before = <?php
+ if(isset($backup['files']) && is_array($backup['files'])) {
+ foreach ($backup['files'] as $fIndex => $file) {
+ ?>
+ @backupFile [data-v-*]|innerText = $file['@@__data-v-(*)__@@']
+ @backupFile input[data-v-*]|value = $file['@@__data-v-(*)__@@']
+ @backupFile button[data-v-*]|value = $file['@@__data-v-(*)__@@']
+ @backupFile a[data-v-*]|href = $file['@@__data-v-(*)__@@']
+ @backupFile|after = <?php
+ }
+ }
+ ?>
+
+ @backup|after = <?php }
+}?>
diff --git a/admin/template/tools/plugins-backup.tpl b/admin/template/tools/plugins-backup.tpl
new file mode 100755
index 0000000..4b66ba7
--- /dev/null
+++ b/admin/template/tools/plugins-backup.tpl
@@ -0,0 +1,63 @@
+import(common.tpl)
+
+@plugin = [data-v-plugins] [data-v-plugin]
+@plugin|deleteAllButFirstChild
+
+@backup = [data-v-backups] [data-v-backup]
+@backup|deleteAllButFirstChild
+
+@backupFile = [data-v-backups] [data-v-backup] [data-v-files] [data-v-file]
+@backupFile|deleteAllButFirstChild
+
+@plugin|before = <?php
+if(isset($this->plugins) && is_array($this->plugins)) {
+ foreach ($this->plugins as $index => $plugin) {
+ ?>
+ @plugin input[data-v-plugin-input]|value = $plugin['slug']
+ @plugin input[data-v-plugin-input]|id = <?php echo 'plugin-' . $plugin['slug'];?>
+ @plugin label[data-v-plugin-label]|for = <?php echo 'plugin-' . $plugin['slug'];?>
+
+ @plugin [data-v-plugin-name]|innerText = $plugin['name']
+ @plugin [data-v-plugin-slug]|innerText = $plugin['slug']
+ @plugin [data-v-plugin-version]|innerText = $plugin['version']
+ @plugin [data-v-plugin-description]|innerText = $plugin['description']
+ @plugin [data-v-plugin-status]|innerText = $plugin['status']
+ @plugin [data-v-plugin-status]|addClass = <?php if ($plugin['status'] == 'active') echo 'bg-success-subtle';?>
+ @plugin img[data-v-plugin-thumb_url]|src = $plugin['thumb_url']
+ @plugin img[data-v-plugin-thumb_url]|hide = <?php $plugin['thumb_url']?>
+
+ @plugin|after = <?php }
+}?>
+
+@backup|before = <?php
+$count = 0;
+if(isset($this->backups) && is_array($this->backups)) {
+ foreach ($this->backups as $index => $backup) {
+ $key = 'key-' . $backup['key'];
+ $count++;
+ ?>
+
+ @backup [data-v-backup-target]|data-bs-target = <?php echo '#' . $key;?>
+ @backup [data-v-backup-id]|id = $key
+
+ @backup [data-v-backup-*]|innerText = $backup['@@__data-v-backup-(*)__@@']
+ @backup input[data-v-backup-*]|value = $backup['@@__data-v-backup-(*)__@@']
+ @backup button[data-v-backup-*]|value = $backup['@@__data-v-backup-(*)__@@']
+
+ @backup a[data-v-backup-*]|href = $backup['@@__data-v-backup-(*)__@@']
+
+ @backupFile|before = <?php
+ if(isset($backup['files']) && is_array($backup['files'])) {
+ foreach ($backup['files'] as $fIndex => $file) {
+ ?>
+ @backupFile [data-v-file-*]|innerText = $file['@@__data-v-file-(*)__@@']
+ @backupFile input[data-v-file-*]|value = $file['@@__data-v-file-(*)__@@']
+ @backupFile button[data-v-file-*]|value = $file['@@__data-v-file-(*)__@@']
+ @backupFile a[data-v-file-*]|href = $file['@@__data-v-file-(*)__@@']
+ @backupFile|after = <?php
+ }
+ }
+ ?>
+
+ @backup|after = <?php }
+}?>
diff --git a/admin/template/tools/queue.tpl b/admin/template/tools/queue.tpl
new file mode 100755
index 0000000..90e22c4
--- /dev/null
+++ b/admin/template/tools/queue.tpl
@@ -0,0 +1,78 @@
+import(common.tpl)
+
+/* Queue monitoring page — provider settings, worker commands, stats, failed jobs */
+
+[data-v-queue-worker-cli] = $this->worker_cli
+[data-v-queue-drain-cli] = $this->drain_cli
+[data-v-cron-url] = $this->cron_url
+
+[data-v-failed-count] = $this->failedCount
+
+/* ── Provider settings form ── */
+#queue-settings-form|before = <?php
+use function Vvveb\__;
+
+$config = $this->config ?? [];
+$providers = $this->providers ?? [];
+$provider = $this->provider ?? 'database';
+?>
+
+#queue-settings-form option[value="database"]|addNewAttribute = <?php echo ($provider === 'database') ? 'selected' : '';?>
+#queue-settings-form option[value="redis"]|addNewAttribute = <?php echo ($provider === 'redis') ? 'selected' : '';?>
+
+[data-v-queue-provider-note]|innerText = <?php
+ $currentProvider = $providers[$provider] ?? [];
+ echo ($currentProvider['note'] ?? '') . (empty($currentProvider['available']) ? ' (' . __('phpredis extension missing!') . ')' : '');
+?>
+
+[data-v-queue-driver]|innerText = <?php echo __('Inherited from site database connection:') . ' <strong>' . ($this->driverLabel ?? '') . '</strong>';?>
+
+#q-max-attempts|value = <?php echo (int) ($config['max_attempts'] ?? 3);?>
+#q-base-delay|value = <?php echo (int) ($config['retry']['base_delay_seconds'] ?? 30);?>
+#q-max-delay|value = <?php echo (int) ($config['retry']['max_delay_seconds'] ?? 3600);?>
+#q-reserved-timeout|value = <?php echo (int) ($config['reserved_timeout_seconds'] ?? 300);?>
+
+#cron-pass-enabled|addNewAttribute = <?php echo ! empty($config['cron_pass']['enabled']) ? 'checked' : '';?>
+
+/* ── Queues stats table ── */
+@queues = [data-v-component-queues]
+
+@queues tr[data-v-queue-stat]|before = <?php
+$queueStats = $this->queueStats ?? [];
+
+foreach ($queueStats as $queueName => $stats) {
+ $pending = (int) ($stats['ready'] ?? 0) + (int) ($stats['delayed'] ?? 0);
+?>
+
+@queues [data-v-queue-name]|innerText = <?php echo $queueName;?>
+@queues [data-v-queue-ready]|innerText = <?php echo (int) ($stats['ready'] ?? 0);?>
+@queues [data-v-queue-delayed]|innerText = <?php echo (int) ($stats['delayed'] ?? 0);?>
+@queues [data-v-queue-reserved]|innerText = <?php echo (int) ($stats['reserved'] ?? 0);?>
+@queues [data-v-queue-size]|innerText = <?php echo $pending + (int) ($stats['reserved'] ?? 0);?>
+
+@queues tr[data-v-queue-stat]|after = <?php } ?>
+
+@queues tr[data-v-no-queues]|style = <?php echo count($queueStats ?? []) ? 'display:none' : '';?>
+
+/* ── Failed jobs table ── */
+@failed = [data-v-component-failed-jobs]
+
+@failed tr[data-v-failed-job]|before = <?php
+$failedJobs = $this->failedJobs ?? [];
+?>
+
+@failed tr[data-v-failed-job]|before = <?php foreach ($failedJobs as $failedJob) { ?>
+
+@failed [data-v-failed-job-job]|innerText = <?php echo $failedJob['job'];?>
+@failed [data-v-failed-job-id]|innerText = <?php echo $failedJob['id'];?>
+@failed [data-v-failed-job-queue]|innerText = <?php echo $failedJob['queue'];?>
+@failed [data-v-failed-job-error]|innerText = <?php echo mb_substr($failedJob['error'] ?? '', 0, 200);?>
+@failed [data-v-failed-job-attempts]|innerText = <?php echo (int) ($failedJob['attempts'] ?? 0) . '/' . (int) ($failedJob['max_attempts'] ?? 0);?>
+@failed [data-v-failed-job-failed_at]|innerText = <?php echo date('Y-m-d H:i:s', (int) ($failedJob['failed_at'] ?? time()));?>
+
+@failed [data-v-failed-job-id-value]|value = <?php echo $failedJob['id'];?>
+@failed [data-v-failed-job-id-value-delete]|value = <?php echo $failedJob['id'];?>
+
+@failed tr[data-v-failed-job]|after = <?php } ?>
+
+@failed tr[data-v-no-failed-jobs]|style = <?php echo count($failedJobs ?? []) ? 'display:none' : '';?>
diff --git a/admin/template/tools/search.tpl b/admin/template/tools/search.tpl
old mode 100644
new mode 100755
diff --git a/admin/template/tools/themes-backup.tpl b/admin/template/tools/themes-backup.tpl
new file mode 100755
index 0000000..191cdaa
--- /dev/null
+++ b/admin/template/tools/themes-backup.tpl
@@ -0,0 +1,62 @@
+import(common.tpl)
+
+@theme = [data-v-themes] [data-v-theme]
+@theme|deleteAllButFirstChild
+
+@backup = [data-v-backups] [data-v-backup]
+@backup|deleteAllButFirstChild
+
+@backupFile = [data-v-backups] [data-v-backup] [data-v-files] [data-v-file]
+@backupFile|deleteAllButFirstChild
+
+@theme|before = <?php
+if(isset($this->themes) && is_array($this->themes)) {
+ foreach ($this->themes as $index => $theme) {
+ ?>
+ @theme input[data-v-theme-input]|value = $theme['slug']
+ @theme input[data-v-theme-input]|id = <?php echo 'theme-' . $theme['slug'];?>
+ @theme label[data-v-theme-label]|for = <?php echo 'theme-' . $theme['slug'];?>
+
+ @theme [data-v-theme-name]|innerText = $theme['name']
+ @theme [data-v-theme-slug]|innerText = $theme['slug']
+ @theme [data-v-theme-version]|innerText = $theme['version']
+ @theme [data-v-theme-description]|innerText = $theme['description']
+ @theme [data-v-theme-status]|innerText = $theme['status']
+ @theme img[data-v-theme-thumb_url]|src = $theme['thumb_url']
+ @theme img[data-v-theme-thumb_url]|hide = <?php $theme['thumb_url'] ?>
+
+ @theme|after = <?php }
+}?>
+
+@backup|before = <?php
+$count = 0;
+if(isset($this->backups) && is_array($this->backups)) {
+ foreach ($this->backups as $index => $backup) {
+ $key = 'key-' . $backup['key'];
+ $count++;
+ ?>
+
+ @backup [data-v-backup-target]|data-bs-target = <?php echo '#' . $key;?>
+ @backup [data-v-backup-id]|id = $key
+
+ @backup [data-v-backup-*]|innerText = $backup['@@__data-v-backup-(*)__@@']
+ @backup input[data-v-backup-*]|value = $backup['@@__data-v-backup-(*)__@@']
+ @backup button[data-v-backup-*]|value = $backup['@@__data-v-backup-(*)__@@']
+
+ @backup a[data-v-backup-*]|href = $backup['@@__data-v-backup-(*)__@@']
+
+ @backupFile|before = <?php
+ if(isset($backup['files']) && is_array($backup['files'])) {
+ foreach ($backup['files'] as $fIndex => $file) {
+ ?>
+ @backupFile [data-v-file-*]|innerText = $file['@@__data-v-file-(*)__@@']
+ @backupFile input[data-v-file-*]|value = $file['@@__data-v-file-(*)__@@']
+ @backupFile button[data-v-file-*]|value = $file['@@__data-v-file-(*)__@@']
+ @backupFile a[data-v-file-*]|href = $file['@@__data-v-file-(*)__@@']
+ @backupFile|after = <?php
+ }
+ }
+ ?>
+
+ @backup|after = <?php }
+}?>
diff --git a/public/admin/default b/public/admin/default
index 4cdf289..2394323 160000
--- a/public/admin/default
+++ b/public/admin/default
@@ -1 +1 @@
-Subproject commit 4cdf289f5555414fac04186bab3673c7fee9dd85
+Subproject commit 23943239ecef6dae8f3ef6918db477c6a671808b
diff --git a/public/css/vvvebjs-editor-helpers.css b/public/css/vvvebjs-editor-helpers.css
index dc67d44..0ad801a 100755
--- a/public/css/vvvebjs-editor-helpers.css
+++ b/public/css/vvvebjs-editor-helpers.css
@@ -1,57 +1,65 @@
body {
scrollbar-color: rgba(var(--bs-body-color-rgb), 0.1) #fff;
- scrollbar-width: thin; }
- body::-webkit-scrollbar {
- width: 0.5rem;
- background-color: rgba(var(--bs-body-bg-rgb), 0.1);
- -webkit-box-shadow: none; }
- body::-webkit-scrollbar-track {
- -webkit-box-shadow: inset 0 0 1px rgba(var(--bs-body-color-rgb), 0.05); }
- body::-webkit-scrollbar-thumb {
- background-color: rgba(var(--bs-body-color-rgb), 0.15);
- outline: 1px solid slategrey; }
+ scrollbar-width: thin;
+}
+body::-webkit-scrollbar {
+ width: 0.5rem;
+ background-color: rgba(var(--bs-body-bg-rgb), 0.1);
+ -webkit-box-shadow: none;
+}
+body::-webkit-scrollbar-track {
+ -webkit-box-shadow: inset 0 0 1px rgba(var(--bs-body-color-rgb), 0.05);
+}
+body::-webkit-scrollbar-thumb {
+ background-color: rgba(var(--bs-body-color-rgb), 0.15);
+ outline: 1px solid slategrey;
+}
[data-vvveb-disabled] {
pointer-events: none;
- position: relative; }
- [data-vvveb-disabled]::after {
- content: "Non-editable area";
- position: absolute;
- left: 0px;
- top: 0px;
- width: 100%;
- height: 100%;
- padding-top: 5px;
- font-weight: 600;
- font-size: 12px;
- text-align: center;
- background: rgba(252, 252, 252, 0.85);
- border: 1px dashed #999;
- overflow: hidden;
- display: flex;
- align-items: center;
- justify-content: center; }
+ position: relative;
+}
+[data-vvveb-disabled]::after {
+ content: "Non-editable area";
+ position: absolute;
+ left: 0px;
+ top: 0px;
+ width: 100%;
+ height: 100%;
+ padding-top: 5px;
+ font-weight: 600;
+ font-size: 12px;
+ text-align: center;
+ background: rgba(252, 252, 252, 0.85);
+ border: 1px dashed #999;
+ overflow: hidden;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
[data-vvveb-disabled-area] *:not([data-vvveb-edit-exception]) {
pointer-events: none;
- position: relative; }
- [data-vvveb-disabled-area] *:not([data-vvveb-edit-exception])::after {
- content: "Non-editable area";
- position: absolute;
- left: 0px;
- top: 0px;
- width: 100%;
- height: 100%;
- padding-top: 5px;
- font-weight: 600;
- font-size: 12px;
- text-align: center;
- background: rgba(252, 252, 252, 0.85);
- border: 1px dashed #999;
- overflow: hidden;
- display: flex;
- align-items: center;
- justify-content: center; }
+ position: relative;
+}
+[data-vvveb-disabled-area] *:not([data-vvveb-edit-exception])::after {
+ content: "Non-editable area";
+ position: absolute;
+ left: 0px;
+ top: 0px;
+ width: 100%;
+ height: 100%;
+ padding-top: 5px;
+ font-weight: 600;
+ font-size: 12px;
+ text-align: center;
+ background: rgba(252, 252, 252, 0.85);
+ border: 1px dashed #999;
+ overflow: hidden;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
/*
Prevents iframe mouse events that prevents clicking on the component
@@ -64,21 +72,35 @@ Prevents iframe mouse events that prevents clicking on the component
[data-component-twitter] > iframe,
[data-component-iframe] > iframe,
[data-component-openstreetmap] > iframe {
- pointer-events: none; }
+ pointer-events: none;
+}
-[contenteditable="true"] {
- outline: none; }
- [contenteditable="true"]:focus-visible {
- outline: none; }
+[contenteditable=true] {
+ outline: none;
+}
+[contenteditable=true]:focus-visible {
+ outline: none;
+}
.is-dragged {
pointer-events: none;
opacity: 0.15;
position: relative;
+ /*
+ &:after {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ left: 0;
+ background: rgba(255,255,0,0.1);
+ content: " ";
+ top: 0;
+ }*/
}
.vvveb-hidden {
- display: none !important; }
+ display: none !important;
+}
body.vvveb-hidden {
display: unset !important;
@@ -113,46 +135,50 @@ body.vvveb-hidden .vvveb-hidden:hover::after, body.vvveb-hidden .d-none:hover::a
display: none;
}
-section .container div > .row > [class*="col-"]:empty,
+section .container div > .row > [class*=col-]:empty,
section .container div > .row > .col:empty,
-section .container > .row > [class*="col-"]:empty,
-section .container > .row > .col:empty, section .container-fluid div > .row > [class*="col-"]:empty,
+section .container > .row > [class*=col-]:empty,
+section .container > .row > .col:empty, section .container-fluid div > .row > [class*=col-]:empty,
section .container-fluid div > .row > .col:empty,
-section .container-fluid > .row > [class*="col-"]:empty,
+section .container-fluid > .row > [class*=col-]:empty,
section .container-fluid > .row > .col:empty {
background: var(--bs-tertiary-bg);
min-height: 200px;
outline: 1px solid var(--bs-border-color);
outline-offset: -0.5rem;
- display: flex; }
- section .container div > .row > [class*="col-"]:empty:after,
- section .container div > .row > .col:empty:after,
- section .container > .row > [class*="col-"]:empty:after,
- section .container > .row > .col:empty:after, section .container-fluid div > .row > [class*="col-"]:empty:after,
- section .container-fluid div > .row > .col:empty:after,
- section .container-fluid > .row > [class*="col-"]:empty:after,
- section .container-fluid > .row > .col:empty:after {
- content: 'Drag elements here';
- font-size: 85%;
- color: var(--bs-secondary);
- display: block;
- vertical-align: middle;
- display: flex;
- align-self: center;
- margin: auto; }
-
-section:hover .container div > .row > [class*="col-"],
-section:hover .container div > .row > .col, section:hover .container > .row > [class*="col-"],
-section:hover .container > .row > .col, section:hover .container-fluid div > .row > [class*="col-"],
-section:hover .container-fluid div > .row > .col, section:hover .container-fluid > .row > [class*="col-"],
+ display: flex;
+}
+section .container div > .row > [class*=col-]:empty:after,
+section .container div > .row > .col:empty:after,
+section .container > .row > [class*=col-]:empty:after,
+section .container > .row > .col:empty:after, section .container-fluid div > .row > [class*=col-]:empty:after,
+section .container-fluid div > .row > .col:empty:after,
+section .container-fluid > .row > [class*=col-]:empty:after,
+section .container-fluid > .row > .col:empty:after {
+ content: "Drag elements here";
+ font-size: 85%;
+ color: var(--bs-secondary);
+ display: block;
+ vertical-align: middle;
+ display: flex;
+ align-self: center;
+ margin: auto;
+}
+
+section:hover .container div > .row > [class*=col-],
+section:hover .container div > .row > .col, section:hover .container > .row > [class*=col-],
+section:hover .container > .row > .col, section:hover .container-fluid div > .row > [class*=col-],
+section:hover .container-fluid div > .row > .col, section:hover .container-fluid > .row > [class*=col-],
section:hover .container-fluid > .row > .col {
outline: 1px dashed rgba(var(--bs-success-rgb), 0.35);
- outline-offset: -2px; }
+ outline-offset: -2px;
+}
-.row:hover > [class*="col-"],
+.row:hover > [class*=col-],
.row:hover > .col {
outline: 1px dashed rgba(var(--bs-success-rgb), 0.35);
- outline-offset: -2px; }
+ outline-offset: -2px;
+}
#vvvebjs-new-section {
@@ -181,13 +207,14 @@ section:hover .container-fluid > .row > .col {
#vvvebjs-new-section button {
margin: 0.5rem;
- background: #0030C0;
+ background: #222;
padding: 0.4rem 2.5rem;
color: #fff;
font-size: 14px;
- border-radius: 3px;
- border-color: #0030C0;
+ border-radius: 6px;
+ border-color: #222;
border-width: 1px;
+ box-shadow:0 4px 4px rgba(0, 0, 0, 0.08), 0 6px 12px rgba(0, 0, 0, 0.012), 0 6px 12px rgba(255, 255, 255, 0.12) inset, 0 1px 1px rgba(255, 255, 255, 0.2) inset;
}
#vvvebjs-new-section button:hover {
diff --git a/public/themes/landing b/public/themes/landing
index 431a650..a801d3a 160000
--- a/public/themes/landing
+++ b/public/themes/landing
@@ -1 +1 @@
-Subproject commit 431a6509dc4b4f4d9a31e9dc9ec6c59a7494ebc5
+Subproject commit a801d3ac808d9ae0a78858b87c6036381387fd14