Merge pull request #1 from deepDiverPaul/feature/prepare-db
Feature/prepare db
This commit is contained in:
@@ -1,73 +1,60 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'settings' => "CREATE TABLE `settings` (
|
||||
`id` int NOT NULL,
|
||||
`setting` varchar(50) NOT NULL,
|
||||
`value` mediumtext NOT NULL,
|
||||
`is_array` tinyint(1) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
|
||||
ALTER TABLE `settings`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `setting` (`setting`);
|
||||
ALTER TABLE `settings`
|
||||
MODIFY `id` int NOT NULL AUTO_INCREMENT;",
|
||||
'pages' => "CREATE TABLE `pages` (
|
||||
`id` int NOT NULL,
|
||||
`name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`layout` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`data` longtext CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci,
|
||||
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
|
||||
INSERT INTO `pages` (`id`, `name`, `layout`, `data`, `updated_at`, `created_at`) VALUES
|
||||
(1, 'Home', 'master', NULL, '2023-06-05 07:10:09', '2023-06-05 07:10:09'),
|
||||
(2, 'About', 'master', NULL, '2023-06-05 07:10:57', '2023-06-05 07:10:57');
|
||||
ALTER TABLE `pages`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
ALTER TABLE `pages`
|
||||
MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;",
|
||||
'menus' => "CREATE TABLE `menus` (
|
||||
`id` int NOT NULL,
|
||||
`name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
|
||||
`pages` mediumtext CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
|
||||
INSERT INTO `menus` (`id`, `name`, `pages`) VALUES
|
||||
(1, 'Main', '1,2'),
|
||||
(2, 'Footer', '1');
|
||||
ALTER TABLE `menus`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `menu` (`name`);",
|
||||
'page_translations' => "CREATE TABLE `page_translations` (
|
||||
`id` int NOT NULL,
|
||||
`page_id` int NOT NULL,
|
||||
`locale` varchar(50) NOT NULL,
|
||||
`title` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`meta_title` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`meta_description` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`route` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
|
||||
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
|
||||
INSERT INTO `page_translations` (`id`, `page_id`, `locale`, `title`, `meta_title`, `meta_description`, `route`, `updated_at`, `created_at`) VALUES
|
||||
(1, 1, 'de', 'Home', 'Home', 'Home', '/', '2023-06-05 07:10:09', '2023-06-05 07:10:09'),
|
||||
(2, 2, 'de', 'About', 'About', 'Description', '/about', '2023-06-05 07:10:57', '2023-06-05 07:10:57');
|
||||
ALTER TABLE `page_translations`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `page_id` (`page_id`,`locale`);
|
||||
ALTER TABLE `page_translations`
|
||||
MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;",
|
||||
'uploads' => "CREATE TABLE `uploads` (
|
||||
`id` int NOT NULL,
|
||||
`public_id` varchar(50) NOT NULL,
|
||||
`original_file` varchar(512) NOT NULL,
|
||||
`mime_type` varchar(50) NOT NULL,
|
||||
`server_file` varchar(512) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
|
||||
ALTER TABLE `uploads`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `public_id` (`public_id`),
|
||||
ADD UNIQUE KEY `server_file` (`server_file`);
|
||||
ALTER TABLE `uploads`
|
||||
MODIFY `id` int NOT NULL AUTO_INCREMENT;",
|
||||
'settings' => [
|
||||
'columns' => [
|
||||
'setting' => 'varchar(50) NOT NULL',
|
||||
'value' => 'mediumtext NOT NULL',
|
||||
'is_array' => 'tinyint(1) NOT NULL',
|
||||
],
|
||||
'uniqueKeys' => [
|
||||
'setting' => ['setting']
|
||||
],
|
||||
],
|
||||
'pages' => [
|
||||
'columns' => [
|
||||
'name' => 'varchar(255)',
|
||||
'layout' => 'varchar(255)',
|
||||
'data' => 'longtext',
|
||||
'updated_at' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
|
||||
'created_at' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||
],
|
||||
'uniqueKeys' => [],
|
||||
],
|
||||
'menus' => [
|
||||
'columns' => [
|
||||
'name' => 'varchar(255)',
|
||||
'pages' => 'mediumtext',
|
||||
],
|
||||
'uniqueKeys' => [
|
||||
'name' => ['name']
|
||||
],
|
||||
],
|
||||
'page_translations' => [
|
||||
'columns' => [
|
||||
'page_id' => 'int NOT NULL',
|
||||
'locale' => 'varchar(50) NOT NULL',
|
||||
'title' => 'varchar(255)',
|
||||
'meta_title' => 'varchar(255)',
|
||||
'meta_description' => 'varchar(255)',
|
||||
'route' => 'varchar(255)',
|
||||
'updated_at' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
|
||||
'created_at' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||
],
|
||||
'uniqueKeys' => [
|
||||
'page_id' => ['page_id','locale']
|
||||
],
|
||||
],
|
||||
'uploads' => [
|
||||
'columns' => [
|
||||
'public_id' => 'varchar(50)',
|
||||
'original_file' => 'varchar(512)',
|
||||
'mime_type' => 'varchar(50)',
|
||||
'server_file' => 'varchar(512)',
|
||||
],
|
||||
'uniqueKeys' => [
|
||||
'public_id' => ['public_id'],
|
||||
'server_file' => ['server_file']
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -45,8 +45,10 @@ return [
|
||||
'settings-updated' => 'Einstellungen aktualisiert',
|
||||
'save-menus' => 'Menus speichern',
|
||||
'menus-updated' => 'Menus aktualisiert',
|
||||
'db-updated' => 'Datenbank aktualisiert',
|
||||
'pagebuilder-block-images' => 'Seiteneditor Vorschaubilder',
|
||||
'render-thumbs' => 'Vorschaubilder generieren'
|
||||
'render-thumbs' => 'Vorschaubilder generieren',
|
||||
'check-database' => 'Datenbank überprüfen im Info-Tab'
|
||||
],
|
||||
'pagebuilder' => [
|
||||
'filter-placeholder' => 'Filter',
|
||||
|
||||
@@ -45,8 +45,10 @@ return [
|
||||
'settings-updated' => 'Settings successfully updated',
|
||||
'save-menus' => 'Save menus',
|
||||
'menus-updated' => 'Menus updated',
|
||||
'db-updated' => 'Database updated',
|
||||
'pagebuilder-block-images' => 'Pagebuilder block thumbnails',
|
||||
'render-thumbs' => 'Render Thumbnails'
|
||||
'render-thumbs' => 'Render Thumbnails',
|
||||
'check-database' => 'Check database'
|
||||
],
|
||||
'pagebuilder' => [
|
||||
'filter-placeholder' => 'Filter',
|
||||
|
||||
@@ -45,8 +45,10 @@ return [
|
||||
'selected-theme' => 'Selected theme',
|
||||
'save-menus' => 'Save menus',
|
||||
'menus-updated' => 'Menus updated',
|
||||
'db-updated' => 'Database updated',
|
||||
'pagebuilder-block-images' => 'Listado de bloques',
|
||||
'render-thumbs' => 'Mostrar Miniaturas',
|
||||
'check-database' => 'Check database'
|
||||
],
|
||||
'pagebuilder' => [
|
||||
'filter-placeholder' => 'Filtrar',
|
||||
|
||||
@@ -45,8 +45,10 @@ return [
|
||||
'settings-updated' => 'Instellingen opgeslagen',
|
||||
'save-menus' => 'Save menus',
|
||||
'menus-updated' => 'Menus updated',
|
||||
'db-updated' => 'Database updated',
|
||||
'pagebuilder-block-images' => 'Pagebuilder blok afbeeldingen',
|
||||
'render-thumbs' => 'Blok afbeeldingen genereren',
|
||||
'check-database' => 'Check database'
|
||||
],
|
||||
'pagebuilder' => [
|
||||
'filter-placeholder' => 'Filter',
|
||||
|
||||
+99
-30
@@ -4,6 +4,7 @@ namespace Plugi\Core;
|
||||
|
||||
use Exception;
|
||||
use PDO;
|
||||
use Plugi\Extensions;
|
||||
|
||||
/**
|
||||
* Class DB
|
||||
@@ -54,17 +55,25 @@ class DB
|
||||
*/
|
||||
public function all(string $table, $columns = '*')
|
||||
{
|
||||
if (is_array($columns)) {
|
||||
foreach ($columns as &$column) {
|
||||
$column = preg_replace('/[^a-zA-Z_]*/', '', $column);
|
||||
try {
|
||||
if (is_array($columns)) {
|
||||
foreach ($columns as &$column) {
|
||||
$column = preg_replace('/[^a-zA-Z_]*/', '', $column);
|
||||
}
|
||||
$columns = implode(',', $columns);
|
||||
$stmt = $this->pdo->prepare("SELECT {$columns} FROM {$table}");
|
||||
} else {
|
||||
$stmt = $this->pdo->prepare("SELECT * FROM {$table}");
|
||||
}
|
||||
$columns = implode(',', $columns);
|
||||
$stmt = $this->pdo->prepare("SELECT {$columns} FROM {$table}");
|
||||
} else {
|
||||
$stmt = $this->pdo->prepare("SELECT * FROM {$table}");
|
||||
$stmt->execute();
|
||||
return $stmt->fetchAll();
|
||||
} catch (\PDOException $e) {
|
||||
$_SESSION["phpb_flash"] = [
|
||||
'message-type' => 'error',
|
||||
'message' => phpb_trans('website-manager.check-database')
|
||||
];
|
||||
return [];
|
||||
}
|
||||
$stmt->execute();
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,36 +118,96 @@ class DB
|
||||
}
|
||||
|
||||
function tableExists($table) {
|
||||
|
||||
// Try a select statement against the table
|
||||
// Run it in try-catch in case PDO is in ERRMODE_EXCEPTION.
|
||||
try {
|
||||
$result = $this->pdo->query("SELECT 1 FROM {$table} LIMIT 1");
|
||||
$this->pdo->query("SELECT 1 FROM {$table} LIMIT 1");
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
// We got an exception (table not found)
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Result is either boolean FALSE (no table found) or PDOStatement Object (table found)
|
||||
return $result !== FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a custom query with user input data passed as $parameters.
|
||||
*
|
||||
* @param string $table
|
||||
* @param string $sql
|
||||
* @return bool
|
||||
*/
|
||||
public function prepare(string $table, string $sql)
|
||||
public function columnExists(string $table, string $column)
|
||||
{
|
||||
// check if table with the name $table exists. if not, execute $query.'
|
||||
try {
|
||||
$result = $this->pdo->query("SELECT 1 FROM {$table} LIMIT 1");
|
||||
return TRUE;
|
||||
$rs = $this->pdo->query("SELECT * FROM {$table} LIMIT 0");
|
||||
for ($i = 0; $i < $rs->columnCount(); $i++) {
|
||||
$col = $rs->getColumnMeta($i);
|
||||
$columns[] = $col['name'];
|
||||
}
|
||||
if (in_array($column, $columns)) return true;
|
||||
return false;
|
||||
} catch (Exception $e) {
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
return $stmt->execute();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function uniqueKeyExists(string $table, string $key)
|
||||
{
|
||||
// check if table with the name $table exists. if not, execute $query.'
|
||||
try {
|
||||
$keys = $this->select(
|
||||
"SELECT CONSTRAINT_NAME FROM information_schema.TABLE_CONSTRAINTS WHERE CONSTRAINT_NAME = ? AND TABLE_SCHEMA = 'plugi' AND TABLE_NAME = ? AND CONSTRAINT_TYPE = 'UNIQUE'",
|
||||
[$key, $table]
|
||||
);
|
||||
if (count($keys) === 1) return true;
|
||||
return false;
|
||||
} catch (Exception $e) {
|
||||
print_r($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDBDefinition() {
|
||||
$tables = include __DIR__.'/../../config/tables.php';
|
||||
foreach (Extensions::getConfigs() as $extkey => $config){
|
||||
if(key_exists('tables', $config)){
|
||||
foreach ($config['tables'] as $table => $definition){
|
||||
$tables['ext__'.$extkey.'_'.$table] = $definition;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tables;
|
||||
}
|
||||
|
||||
public function diffDB() {
|
||||
$tables = $this->getDBDefinition();
|
||||
$diff = [];
|
||||
|
||||
foreach ($tables as $table => $tableDefinition) {
|
||||
if ($this->tableExists($table) === false) {
|
||||
$diff[$table] = false;
|
||||
} else {
|
||||
$diff[$table]['columns'] = [];
|
||||
foreach ($tableDefinition['columns'] as $column => $columnDefinition) {
|
||||
if(!$this->columnExists($table, $column)) $diff[$table]['columns'][$column] = $columnDefinition;
|
||||
}
|
||||
$diff[$table]['uniqueKeys'] = [];
|
||||
foreach ($tableDefinition['uniqueKeys'] as $key => $keyDefinition) {
|
||||
if(!$this->uniqueKeyExists($table, $key)) $diff[$table]['uniqueKeys'][$key] = '`'.implode('`,`', $keyDefinition).'`';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $diff;
|
||||
}
|
||||
|
||||
public function resolveDiffDB() {
|
||||
$diff = $this->diffDB();
|
||||
foreach ($diff as $table => $tableDiff) {
|
||||
if($tableDiff === false){
|
||||
$this->query("CREATE TABLE {$table} (`id` int NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3");
|
||||
$this->query("ALTER TABLE {$table} ADD PRIMARY KEY (`id`)");
|
||||
$this->query("ALTER TABLE {$table} MODIFY `id` int NOT NULL AUTO_INCREMENT");
|
||||
} elseif (is_array($tableDiff)) {
|
||||
foreach ($tableDiff['columns'] as $column => $columnDefinition) {
|
||||
$this->query("ALTER TABLE {$table} ADD {$column} {$columnDefinition}");
|
||||
}
|
||||
foreach ($tableDiff['uniqueKeys'] as $key => $keyDefinition) {
|
||||
$this->query("ALTER TABLE {$table} ADD UNIQUE KEY {$key} ($keyDefinition)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,13 @@ class WebsiteManager implements WebsiteManagerContract
|
||||
}
|
||||
}
|
||||
|
||||
if ($route === 'database') {
|
||||
if ($action === 'update') {
|
||||
$this->handleUpdateDB();
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
if ($route === 'page_settings') {
|
||||
if ($action === 'create') {
|
||||
$this->handleCreate();
|
||||
@@ -155,6 +162,21 @@ class WebsiteManager implements WebsiteManagerContract
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle requests for updating the website DB.
|
||||
*/
|
||||
public function handleUpdateDB()
|
||||
{
|
||||
global $phpb_db;
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$phpb_db->resolveDiffDB();
|
||||
phpb_redirect(phpb_url('website_manager', ['tab' => 'info']), [
|
||||
'message-type' => 'success',
|
||||
'message' => phpb_trans('website-manager.db-updated')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the website manager overview page.
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,18 @@
|
||||
<div class="text-center text-3xl font-bold mb-8 mt-2">
|
||||
<?= phpb_e($tabs[$activeSlug]['title']) ?>
|
||||
</div>
|
||||
<?php
|
||||
if (phpb_flash('message')):
|
||||
?>
|
||||
<div class="hidden alert-success alert-error"></div>
|
||||
<div class="alert alert-<?= phpb_flash('message-type') ?> mb-6">
|
||||
<?= phpb_flash('message-type') === 'success' ? '<i class="text-xl ph-duotone ph-info"></i>' : '' ?>
|
||||
<?= phpb_flash('message-type') === 'error' ? '<i class="text-xl ph-duotone ph-warning-circle"></i>' : '' ?>
|
||||
<span><?= phpb_flash('message') ?></span>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<div class="">
|
||||
<?php
|
||||
include $tabs[$activeSlug]['include'];
|
||||
|
||||
@@ -1,12 +1,60 @@
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table table-zebra">
|
||||
<tbody>
|
||||
<!-- row 1 -->
|
||||
<tr>
|
||||
<th class="w-60">PHP Version</th>
|
||||
<td><?= phpversion() ?>n</td>
|
||||
<td><?= phpversion() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="w-60">Database</th>
|
||||
<td>
|
||||
<form method="post" action="<?= phpb_url('website_manager', ['route' => 'database', 'action' => 'update', 'tab' => 'info']) ?>">
|
||||
<?php
|
||||
global $phpb_db;
|
||||
$diff = $phpb_db->diffDB();
|
||||
$actionNeeded = false;
|
||||
foreach ($diff as $table => $tableDiff) :
|
||||
if(!is_array($tableDiff)) $actionNeeded = true;
|
||||
?>
|
||||
<div>
|
||||
table <strong><?= phpb_e($table) ?></strong> (<?= phpb_e(is_array($tableDiff) ? (empty($tableDiff['columns']) && empty($tableDiff['uniqueKeys']) ? 'is fine' : 'has diff') : 'is not existent') ?>)
|
||||
</div>
|
||||
<?php
|
||||
if (is_array($tableDiff)) :
|
||||
foreach ($tableDiff['columns'] as $column => $def) :
|
||||
$actionNeeded = true;
|
||||
?>
|
||||
<div class="ml-4">
|
||||
<i class="ph ph-arrow-elbow-down-right"></i> column <strong><?= phpb_e($column) ?></strong> (not existent)
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
<?php
|
||||
if (is_array($tableDiff)) :
|
||||
foreach ($tableDiff['uniqueKeys'] as $key => $def) :
|
||||
$actionNeeded = true;
|
||||
?>
|
||||
<div class="ml-4">
|
||||
<i class="ph ph-arrow-elbow-down-right"></i> unique key <strong><?= phpb_e($key) ?></strong> (not existent)
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
<?php
|
||||
endforeach;
|
||||
if ($actionNeeded) :
|
||||
?>
|
||||
<button class="btn" type="submit">Update</button>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- row 2 -->
|
||||
<tr>
|
||||
<th class="align-top">Installed extensions</th>
|
||||
<td>
|
||||
|
||||
@@ -11,18 +11,6 @@ $pages = $pageRepository->getAll();
|
||||
|
||||
<div class="main-spacing" >
|
||||
|
||||
<?php
|
||||
if (phpb_flash('message')):
|
||||
?>
|
||||
<div class="hidden alert-success"></div>
|
||||
<div class="alert alert-<?= phpb_flash('message-type') ?> mb-6">
|
||||
<i class="text-xl ph-duotone ph-info"></i>
|
||||
<span><?= phpb_flash('message') ?></span>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
<div x-data="{menus: <?= phpb_e($menusJson) ?>, pages: <?= phpb_e($menuPagesJson) ?>}" class="flex flex-col gap-12">
|
||||
<template x-for="menu in menus">
|
||||
<div class="">
|
||||
|
||||
@@ -1,62 +1,50 @@
|
||||
|
||||
<table class="table table-zebra w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-5">ID</th>
|
||||
<th><?= phpb_trans('website-manager.name') ?></th>
|
||||
<th><?= phpb_trans('website-manager.route') ?></th>
|
||||
<th class="w-44"><?= phpb_trans('website-manager.actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if (phpb_flash('message')):
|
||||
foreach ($pages as $page):
|
||||
?>
|
||||
<div class="alert alert-<?= phpb_flash('message-type') ?> mb-6">
|
||||
<i class="text-xl ph-duotone ph-info"></i>
|
||||
<span><?= phpb_flash('message') ?></span>
|
||||
</div>
|
||||
<tr>
|
||||
<td>
|
||||
<?= phpb_e($page->getId()) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= phpb_e($page->getName()) ?>
|
||||
</td>
|
||||
<td>
|
||||
<div class="hidden pl-4 pl-8"></div>
|
||||
<div class="pl-<?= phpb_e((count(explode('/', $page->getRoute()))-2)*4) ?>">
|
||||
<?= phpb_e($page->getRoute()) ?>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td class="actions">
|
||||
<a href="<?= phpb_e(phpb_full_url($page->getRoute())) ?>" title="<?= phpb_trans('website-manager.view') ?>" target="_blank" class="btn btn-light btn-outline btn-sm btn-circle">
|
||||
<i class="text-xl ph-duotone ph-eye"></i>
|
||||
</a>
|
||||
<a href="<?= phpb_url('pagebuilder', ['page' => $page->getId()]) ?>" class="btn btn-primary btn-sm btn-circle" title="<?= phpb_trans('website-manager.edit') ?>">
|
||||
<i class="text-xl ph-duotone ph-pencil-line"></i>
|
||||
</a>
|
||||
<a href="<?= phpb_url('website_manager', ['route' => 'page_settings', 'action' => 'edit', 'page' => $page->getId()]) ?>" title="<?= phpb_trans('website-manager.settings') ?>" class="btn btn-secondary btn-sm btn-circle">
|
||||
<i class="text-xl ph-duotone ph-gear"></i>
|
||||
</a>
|
||||
<a href="<?= phpb_url('website_manager', ['route' => 'page_settings', 'action' => 'destroy', 'page' => $page->getId()]) ?>" title="<?= phpb_trans('website-manager.remove') ?>" class="btn btn-error btn-sm btn-circle">
|
||||
<i class="text-xl ph-duotone ph-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endif;
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
<table class="table table-zebra w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-5">ID</th>
|
||||
<th><?= phpb_trans('website-manager.name') ?></th>
|
||||
<th><?= phpb_trans('website-manager.route') ?></th>
|
||||
<th class="w-44"><?= phpb_trans('website-manager.actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($pages as $page):
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<?= phpb_e($page->getId()) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= phpb_e($page->getName()) ?>
|
||||
</td>
|
||||
<td>
|
||||
<div class="hidden pl-4 pl-8"></div>
|
||||
<div class="pl-<?= phpb_e((count(explode('/', $page->getRoute()))-2)*4) ?>">
|
||||
<?= phpb_e($page->getRoute()) ?>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td class="actions">
|
||||
<a href="<?= phpb_e(phpb_full_url($page->getRoute())) ?>" title="<?= phpb_trans('website-manager.view') ?>" target="_blank" class="btn btn-light btn-outline btn-sm btn-circle">
|
||||
<i class="text-xl ph-duotone ph-eye"></i>
|
||||
</a>
|
||||
<a href="<?= phpb_url('pagebuilder', ['page' => $page->getId()]) ?>" class="btn btn-primary btn-sm btn-circle" title="<?= phpb_trans('website-manager.edit') ?>">
|
||||
<i class="text-xl ph-duotone ph-pencil-line"></i>
|
||||
</a>
|
||||
<a href="<?= phpb_url('website_manager', ['route' => 'page_settings', 'action' => 'edit', 'page' => $page->getId()]) ?>" title="<?= phpb_trans('website-manager.settings') ?>" class="btn btn-secondary btn-sm btn-circle">
|
||||
<i class="text-xl ph-duotone ph-gear"></i>
|
||||
</a>
|
||||
<a href="<?= phpb_url('website_manager', ['route' => 'page_settings', 'action' => 'destroy', 'page' => $page->getId()]) ?>" title="<?= phpb_trans('website-manager.remove') ?>" class="btn btn-error btn-sm btn-circle">
|
||||
<i class="text-xl ph-duotone ph-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="text-center mt-8">
|
||||
|
||||
@@ -7,18 +7,6 @@ $settingIns = phpb_instance('setting');
|
||||
|
||||
<form method="post" action="<?= phpb_url('website_manager', ['route' => 'settings', 'action' => 'update', 'tab' => 'settings']) ?>">
|
||||
|
||||
<div class="max-w-lg mx-auto text-center">
|
||||
<?php
|
||||
if (phpb_flash('message')):
|
||||
?>
|
||||
<div class="alert alert-<?= phpb_flash('message-type') ?> mb-6">
|
||||
<i class="text-xl ph-duotone ph-info"></i>
|
||||
<span><?= phpb_flash('message') ?></span>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
<div class="w-full mb-6">
|
||||
<div class="label-text text-left"><?= phpb_trans('website-manager.website-languages') ?></div>
|
||||
<?php
|
||||
@@ -28,7 +16,6 @@ $settingIns = phpb_instance('setting');
|
||||
<label class="label cursor-pointer">
|
||||
<span class="label-text"><?= phpb_e($localeText) ?></span>
|
||||
<input type="checkbox" name="languages[]" value="<?= phpb_e($locale) ?>" <?= phpb_e($settingIns::has('languages', $locale)) ? 'checked' : '' ?> class="checkbox checkbox-sm" />
|
||||
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
@@ -128,6 +115,5 @@ $settingIns = phpb_instance('setting');
|
||||
<!-- <a href="--><?php //= phpb_url('website_manager', ['route' => 'settings', 'action' => 'renderBlockThumbs']) ?><!--" class="btn btn-secondary btn-sm mr-1">-->
|
||||
<!-- --><?php //= phpb_trans('website-manager.render-thumbs') ?>
|
||||
<!-- </a>-->
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
@@ -176,10 +176,6 @@ class Plugi
|
||||
{
|
||||
global $phpb_db;
|
||||
$phpb_db = new DB($config);
|
||||
$tables = include __DIR__.'/../config/tables.php';
|
||||
foreach ($tables as $table => $sql) {
|
||||
$phpb_db->prepare($table, $sql);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user