update core

This commit is contained in:
Paul Spenke
2023-06-18 20:45:00 +08:00
parent de0f453003
commit 8db48bb9ab
14 changed files with 192 additions and 288 deletions
-192
View File
@@ -1,192 +0,0 @@
![Plugi](https://github.com/deepDiverPaul/plugi-core/blob/408b24e1ed4c9e61fab9af6f8bfec2c939bcdd67/dist/images/plugi-banner.png)
# PHPagebuilder
> PHPagebuilder is a drag and drop pagebuilder to manage pages in any PHP project.
PHPagebuilder can be used as an ultra lightweight CMS to quickly spin up new websites, or can be integrated into existing projects or your favorite frameworks (such as [this version](https://github.com/HansSchouten/Laravel-Pagebuilder) for Laravel). The server-side code does not depend on any other libraries and is blazing fast. It includes an optional website manager with a [Bootstrap UI](https://getbootstrap.com) and integrates the most popular open source drag and drop pagebuilder: [GrapesJS](https://grapesjs.com/). This package is made with customization in mind, allowing you to configure, disable or replace any of its modules.
## Table of Contents
- [How does it help me?](#how-does-it-help-me)
- [Features](#features)
- [Installation](#installation)
- [Customization](#customization)
## How does it help me?
Whether you are a novice or an experienced web developer, PHPagebuilder can make your life easier if you find yourself in any of the following:
- You just want to create a basic website that you can easily manage from any device.
- You get lost installing, configuring, updating or simply using feature abundant CMS systems like Wordpress, Drupal.
- You don't like the limited page editors in CMSs you've tried.
- You want to build a custom website for a client within a few hours.
- Your clients get lost in feature abundant admin panels like Drupal.
- You hate to rely on messy plugins for features you can write in no-time in plain PHP yourself, but still want to have some admin functionality to allow other people to manage the websites you create.
- You would like to have advanced functionality (search functionality, views displaying data of remote sources, etc.) easily manageable by your clients.
## Features
### Page Builder
PHPagebuilder features a page builder built on [GrapesJS](https://grapesjs.com/).
![PageBuilder](https://user-images.githubusercontent.com/5946444/70818285-97c81a80-1dd3-11ea-84b0-2a6ff3a8765a.png)
### Website Manager
A basic website manager is included with a [Bootstrap](https://getbootstrap.com/) UI. This website manager offers basic functionality to add or remove pages and to edit page settings like page title or URL. Clicking the edit button will open the page builder.
![Website Manager](https://user-images.githubusercontent.com/5946444/67484882-4029f000-f669-11e9-9a1f-8a0e1c53e308.jpg)
You don't want to use the website manager? No worries, it is included for people who want to use PHPagebuilder directly out of the box. Read [here](#customize-the-website-manager) how to disable or replace the website manager.
## Installation
To install PHPagebuilder you either follow the quick start path, for quickly spinning up a new website, or you integrate it in your own framework or favorite project structure.
### Requirements
- PHP version >= 7
- A cool project
### Quick start :rocket:
If you want to quickly start a new project with drag and drop page management functionality, you can download the [boilerplate](https://github.com/HansSchouten/PHPagebuilder-boilerplate) project structure and follow the steps over there.
### Integrate into existing project or framework
#### Add code with Composer
If you are using Composer for managing PHP dependencies, you can simply run:
```
composer require hansschouten/phpagebuilder
```
Next, the PHPagebuilder can be initialised using the following PHP code:
```PHP
require_once __DIR__ . '/vendor/autoload.php';
$config = require __DIR__ . '/config.php';
$builder = new PHPageBuilder\PHPageBuilder($config);
$builder->handleRequest();
```
`config.php` should contain a copy of `config/config.example.php`, filled with your settings.
#### Add code without Composer
Are you not using Composer? No worries, this project is written in plain PHP without any dependencies, so it can be directly included in any PHP project!
Just download the latest release into a separate folder inside your project (we named the folder: `phpagebuilder`).
Next, you simply include the following code in the PHP file that should launch the page builder:
```PHP
$installationFolder = __DIR__ . '/phpagebuilder';
require_once $installationFolder . '/src/Core/helpers.php';
spl_autoload_register('phpb_autoload');
$config = require __DIR__ . '/config.php';
$builder = new PHPageBuilder\PHPageBuilder($config);
$builder->handleRequest();
```
`config.php` should contain a copy of `config/config.example.php`, filled with your settings.
### Configure a database
If you use PHPagebuilder out of the box, it requires a database for storing your pages. Just create a database and run the queries from `config/create-tables.sql`. Next, add the database credentials to your config file.
## Create a theme
The `config.php` contains a config key `theme` in which a `themes_folder` and `active_theme` are specified. To create a new theme, add a new folder to the configured themes folder. The name of this folder will be the identifier of the theme, which can be used to select the theme in the `theme > active_theme` configuration.
A theme should have the following folder structure:
- **/blocks**
The blocks folder contains a sub folder for each block that can be used in the page builder. The folder of a single block contains a `view.php` or a `view.html`. If a `view.html` is used, the block content (the html elements) are fully editable inside the page builder. If `view.php` is used, the block can be rendered with server-side logic (PHP) and hence the html content itself cannot be changed from within the page builder.
- **/layouts**
The layouts folder contains a sub folder for each page layout. A page layout contains a `view.php` file which defines the base html structure with all stylesheets and scripts needed for the blocks dragged on this type of page. Each layout requires the string: `<?= $body ?>` on the location at which the html blocks need to be added in the page layout.
- **/public**
The public folder contains all assets (css, javascript, images, etc) that should be publicly accessible. The `[theme-url]` shortcode can be used to point to a file in the public folder of the currently active theme. For instance the file `public/css/style.css` can be loaded via `<link rel="stylesheet" href="[theme-url]/css/style.css">`.
### Blocks inside blocks
#### Include a block into a block or layout file
A shortcode can be used to include a block inside another block or into a layout file. For instance, adding the shortcode: `[block slug="header"]` to `layouts/master/view.php` includes the block: `blocks/header/view.php` inside each page that uses the `master` layout.
#### Nested blocks in the page builder
To allow dropping blocks into a block in the page builder, a blocks container should be added. To add a blocks container, simply add `[blocks-container]` at the desired location in a block view file. The following html syntax allows dropping blocks inside a bootstrap container element:
```html
<div class="container">
[blocks-container]
</div>
```
An alternative method is adding the `phpb-blocks-container` attribute to a html element, as shown in this example:
```html
<div class="row">
<div class="col-md-6" phpb-blocks-container>
</div>
<div class="col-md-6" phpb-blocks-container>
</div>
</div>
```
## Extending PHPageBuilder
PHPageBuilder allows you to create new blocks and layouts for your theme very easily. This is great for building specific websites & templates, however if you use PHPageBuilder in a CMS environment, you probably want to provide Plugins / Modules the ability to create their own blocks without modifying your theme's pre-existing components.
PHPageBuilder allows you to register blocks, layouts and assets (CSS, JS) from Plugins, Composer Packages or through any other environment.
### Adding a New Block
```php
/**
* @param string $slug - A Unique identifier for the block. Prefix author to avoid conflict.
* @param string $directoryPath - Path to the directory of the Block.
*/
\PHPageBuilder\Extensions::registerBlock($slug, $directoryPath);
// Registering an example block:
\PHPageBuilder\Extensions::registerBlock('foo-navbar', MY_PLUGIN_DIRECTORY . '/blocks/foo-navbar');
```
### Adding a New Layout
```php
/**
* @param string $slug - A Unique identifier for the layout. Prefix author to avoid conflict.
* @param string $directoryPath - Path to the directory of the Layout.
*/
\PHPageBuilder\Extensions::registerLayout($slug, $directoryPath);
// Registering an example layout:
\PHPageBuilder\Extensions::registerLayout('foo-master', MY_PLUGIN_DIRECTORY . '/layouts/foo-master');
```
### Adding Assets (CSS & JS)
```php
/**
* @param string $src - URL of the Asset file.
* @param string $type - 'style' or 'script'
* @param string $location - 'header' or 'footer'
* @param array['$key' => '$value'] $attributes - Array of attributes to add to the tag.
*/
\PHPageBuilder\Extensions::registerAsset($src, $type, $location, $attributes = []);
// Registering assets:
\PHPageBuilder\Extensions::registerAsset('/assets/bootstrap.css', 'style', 'header');
\PHPageBuilder\Extensions::registerAsset('/assets/alpine.min.js', 'script', 'header', [
'defer' => true
]);
```
Blocks & Layouts are created in the same manner as described in [Create A Theme](#create-a-theme), but they aren't limited to any theme directory.
## Customize PHPageBuilder
PHPagebuilder is build with customization in mind. It comes with an extensive example config file in wich you can easily adapt the pagebuilder to your needs.
PHPagebuilder consists of four modules (Auth, Website Manager, Pagebuilder, Routing) each of which you can disable or replace with your own implementation. To replace a module with your own implementation, implement the corresponding Contract and replace the default class by your own class in the config file.
### Customize the Website Manager
#### Disable the module
Do you already have admin login functionality in your project? Then you can disable the website manager module by setting `use_website_manager` to `false` in your config. Next, you use or implement the page create/edit/remove functionality in your project and then directly launch the pagebuilder. You can render the pagebuilder from your project by using the `PHPageBuilder\Modules\GrapesJS\PageBuilder` class.
#### Replace the module
If you want to use the CMS routing functionality of PHPagebuilder, but you want to have a different website manager, you can replace the website manager for your own implementation. Make sure leave `use_website_manager` to `true` in your config, implement the WebsiteManagerContract and add your own class to your config file.
+3 -5
View File
@@ -38,7 +38,7 @@ CREATE TABLE `menus` (
--
INSERT INTO `menus` (`id`, `name`, `pages`) VALUES
(1, 'Main', '1,3'),
(1, 'Main', '1,2'),
(2, 'Footer', '1');
-- --------------------------------------------------------
@@ -62,8 +62,7 @@ CREATE TABLE `pages` (
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, 'Sitemap', 'sitemap', NULL, '2023-06-05 07:11:15', '2023-06-05 07:10:41'),
(3, 'About', 'master', NULL, '2023-06-05 07:10:57', '2023-06-05 07:10:57');
(2, 'About', 'master', NULL, '2023-06-05 07:10:57', '2023-06-05 07:10:57');
-- --------------------------------------------------------
@@ -89,8 +88,7 @@ CREATE TABLE `page_translations` (
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', 'Sitemap', '', '', '/sitemap.xml', '2023-06-05 07:10:41', '2023-06-05 07:10:41'),
(3, 3, 'de', 'About', 'About', 'Description', '/about', '2023-06-05 07:10:57', '2023-06-05 07:10:57');
(2, 2, 'de', 'About', 'About', 'Description', '/about', '2023-06-05 07:10:57', '2023-06-05 07:10:57');
-- --------------------------------------------------------
+73
View File
@@ -0,0 +1,73 @@
<?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;",
];
+1 -1
View File
File diff suppressed because one or more lines are too long
+59 -59
View File
@@ -18,13 +18,13 @@ function Kr() {
j[e](), Te = e;
j.length = 0, Te = -1, Me = !1;
}
var z, k, Z, xt, $e = !0;
var z, k, Z, xt, Ie = !0;
function Dr(e) {
$e = !1, e(), $e = !0;
Ie = !1, e(), Ie = !0;
}
function Br(e) {
z = e.reactive, Z = e.release, k = (t) => e.effect(t, { scheduler: (r) => {
$e ? Lr(r) : r();
Ie ? Lr(r) : r();
} }), xt = e.raw;
}
function lt(e) {
@@ -181,7 +181,7 @@ function Mt(e, t = () => {
initialValue: void 0,
_x_interceptor: !0,
initialize(n, i, o) {
return e(this.initialValue, () => Gr(n, i), (s) => Ie(n, i, s), i, o);
return e(this.initialValue, () => Gr(n, i), (s) => Pe(n, i, s), i, o);
}
};
return t(r), (n) => {
@@ -199,20 +199,20 @@ function Mt(e, t = () => {
function Gr(e, t) {
return t.split(".").reduce((r, n) => r[n], e);
}
function Ie(e, t, r) {
function Pe(e, t, r) {
if (typeof t == "string" && (t = t.split(".")), t.length === 1)
e[t[0]] = r;
else {
if (t.length === 0)
throw error;
return e[t[0]] || (e[t[0]] = {}), Ie(e[t[0]], t.slice(1), r);
return e[t[0]] || (e[t[0]] = {}), Pe(e[t[0]], t.slice(1), r);
}
}
var Tt = {};
function S(e, t) {
Tt[e] = t;
}
function Pe(e, t) {
function $e(e, t) {
return Object.entries(Tt).forEach(([r, n]) => {
let i = null;
function o() {
@@ -257,15 +257,15 @@ function K(e, t, r = {}) {
return m(e, t)((i) => n = i, r), n;
}
function m(...e) {
return $t(...e);
return It(...e);
}
var $t = It;
var It = Pt;
function Qr(e) {
$t = e;
It = e;
}
function It(e, t) {
function Pt(e, t) {
let r = {};
Pe(r, e);
$e(r, e);
let n = [r, ...D(e)], i = typeof t == "function" ? Zr(n, t) : tn(n, t, e);
return Yr.bind(null, e, t, i);
}
@@ -333,7 +333,7 @@ function g(e, t) {
}
function Ye(e, t, r) {
if (t = Array.from(t), e._x_virtualDirectives) {
let o = Object.entries(e._x_virtualDirectives).map(([a, c]) => ({ name: a, value: c })), s = Pt(o);
let o = Object.entries(e._x_virtualDirectives).map(([a, c]) => ({ name: a, value: c })), s = $t(o);
o = o.map((a) => s.find((c) => c.name === a.name) ? {
name: `x-bind:${a.name}`,
value: `"${a.value}"`
@@ -342,7 +342,7 @@ function Ye(e, t, r) {
let n = {};
return t.map(Ft((o, s) => n[o] = s)).filter(Dt).map(sn(n, r)).sort(an).map((o) => on(e, o));
}
function Pt(e) {
function $t(e) {
return Array.from(e).map(Ft()).filter((t) => !Dt(t));
}
var je = !1, V = /* @__PURE__ */ new Map(), Rt = Symbol();
@@ -451,12 +451,12 @@ function T(e, ...t) {
}
var ft = !1;
function cn() {
ft && T("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."), ft = !0, document.body || T("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"), G(document, "alpine:init"), G(document, "alpine:initializing"), Ue(), kr((t) => $(t, M)), Et((t) => Vt(t)), Hr((t, r) => {
ft && T("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."), ft = !0, document.body || T("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"), G(document, "alpine:init"), G(document, "alpine:initializing"), Ue(), kr((t) => I(t, M)), Et((t) => Vt(t)), Hr((t, r) => {
Ye(t, r).forEach((n) => n());
});
let e = (t) => !fe(t.parentElement, !0);
Array.from(document.querySelectorAll(Ht())).filter(e).forEach((t) => {
$(t);
I(t);
}), G(document, "alpine:initialized");
}
var Qe = [], zt = [];
@@ -493,7 +493,7 @@ var Ut = [];
function ln(e) {
Ut.push(e);
}
function $(e, t = M, r = () => {
function I(e, t = M, r = () => {
}) {
nn(() => {
t(e, (n, i) => {
@@ -769,7 +769,7 @@ function bn(e, t) {
}
function mn(e) {
let t = !1;
$(e, (n, i) => {
I(e, (n, i) => {
M(n, (o, s) => {
if (t && un(o))
return s();
@@ -786,7 +786,7 @@ function wn(e) {
}), e(), lt(t);
}
function Yt(e, t, r, n = []) {
switch (e._x_bindings || (e._x_bindings = z({})), e._x_bindings[t] = r, t = n.includes("camel") ? $n(t) : t, t) {
switch (e._x_bindings || (e._x_bindings = z({})), e._x_bindings[t] = r, t = n.includes("camel") ? In(t) : t, t) {
case "value":
En(e, r);
break;
@@ -828,7 +828,7 @@ function On(e, t, r) {
Xt(e, t, r), Mn(e, t, r);
}
function Xt(e, t, r) {
[null, void 0, !1].includes(r) && In(t) ? e.removeAttribute(t) : (Qt(t) && (r = t), Cn(e, t, r));
[null, void 0, !1].includes(r) && Pn(t) ? e.removeAttribute(t) : (Qt(t) && (r = t), Cn(e, t, r));
}
function Cn(e, t, r) {
e.getAttribute(t) != r && e.setAttribute(t, r);
@@ -842,7 +842,7 @@ function Tn(e, t) {
n.selected = r.includes(n.value);
});
}
function $n(e) {
function In(e) {
return e.toLowerCase().replace(/-(\w)/g, (t, r) => r.toUpperCase());
}
function pt(e, t) {
@@ -877,10 +877,10 @@ function Qt(e) {
"nomodule"
].includes(e);
}
function In(e) {
function Pn(e) {
return !["aria-pressed", "aria-checked", "aria-expanded", "aria-selected"].includes(e);
}
function Pn(e, t, r) {
function $n(e, t, r) {
if (e._x_bindings && e._x_bindings[t] !== void 0)
return e._x_bindings[t];
let n = e.getAttribute(t);
@@ -905,14 +905,14 @@ function er(e, t) {
function Rn(e) {
(Array.isArray(e) ? e : [e]).forEach((r) => r(ne));
}
var P = {}, _t = !1;
var $ = {}, _t = !1;
function jn(e, t) {
if (_t || (P = z(P), _t = !0), t === void 0)
return P[e];
P[e] = t, typeof t == "object" && t !== null && t.hasOwnProperty("init") && typeof t.init == "function" && P[e].init(), Ct(P[e]);
if (_t || ($ = z($), _t = !0), t === void 0)
return $[e];
$[e] = t, typeof t == "object" && t !== null && t.hasOwnProperty("init") && typeof t.init == "function" && $[e].init(), Ct($[e]);
}
function Ln() {
return P;
return $;
}
var tr = {};
function Nn(e, t) {
@@ -932,7 +932,7 @@ function rr(e, t, r) {
let n = [];
for (; n.length; )
n.pop()();
let i = Object.entries(t).map(([s, a]) => ({ name: s, value: a })), o = Pt(i);
let i = Object.entries(t).map(([s, a]) => ({ name: s, value: a })), o = $t(i);
i = i.map((s) => o.find((a) => a.name === s.name) ? {
name: `x-bind:${s.name}`,
value: `"${s.value}"`
@@ -997,7 +997,7 @@ var Bn = {
throttle: er,
debounce: Zt,
evaluate: K,
initTree: $,
initTree: I,
nextTick: et,
prefixed: H,
prefix: rn,
@@ -1006,7 +1006,7 @@ var Bn = {
store: jn,
start: cn,
clone: bn,
bound: Pn,
bound: $n,
$data: Ot,
walk: M,
data: Kn,
@@ -1081,7 +1081,7 @@ function E(e, t, r) {
key: r
}));
}
function I(e, t, r, n, i, o) {
function P(e, t, r, n, i, o) {
const s = Be.get(e);
if (!s)
return;
@@ -1162,12 +1162,12 @@ function fr(e = !1) {
if (!e && (i = h(i), s = h(s), !L(r) && ke(s) && !ke(i)))
return s.value = i, !0;
const a = L(r) && nt(n) ? Number(n) < r.length : _e(r, n), c = Reflect.set(r, n, i, o);
return r === h(o) && (a ? ar(i, s) && I(r, "set", n, i, s) : I(r, "add", n, i)), c;
return r === h(o) && (a ? ar(i, s) && P(r, "set", n, i, s) : P(r, "add", n, i)), c;
};
}
function ci(e, t) {
const r = _e(e, t), n = e[t], i = Reflect.deleteProperty(e, t);
return i && r && I(e, "delete", t, void 0, n), i;
return i && r && P(e, "delete", t, void 0, n), i;
}
function ui(e, t) {
const r = Reflect.has(e, t);
@@ -1220,7 +1220,7 @@ function be(e, t = !1) {
function _r(e) {
e = h(e);
const t = h(this);
return ye(t).has.call(t, e) || (t.add(e), I(t, "add", e, e)), this;
return ye(t).has.call(t, e) || (t.add(e), P(t, "add", e, e)), this;
}
function hr(e, t) {
t = h(t);
@@ -1228,18 +1228,18 @@ function hr(e, t) {
let o = n.call(r, e);
o ? Er(r, n, e) : (e = h(e), o = n.call(r, e));
const s = i.call(r, e);
return r.set(e, t), o ? ar(t, s) && I(r, "set", e, t, s) : I(r, "add", e, t), this;
return r.set(e, t), o ? ar(t, s) && P(r, "set", e, t, s) : P(r, "add", e, t), this;
}
function gr(e) {
const t = h(this), { has: r, get: n } = ye(t);
let i = r.call(t, e);
i ? Er(t, r, e) : (e = h(e), i = r.call(t, e));
const o = n ? n.call(t, e) : void 0, s = t.delete(e);
return i && I(t, "delete", e, void 0, o), s;
return i && P(t, "delete", e, void 0, o), s;
}
function yr() {
const e = h(this), t = e.size !== 0, r = Y(e) ? new Map(e) : new Set(e), n = e.clear();
return t && I(e, "clear", void 0, void 0, r), n;
return t && P(e, "clear", void 0, void 0, r), n;
}
function me(e, t) {
return function(n, i) {
@@ -1484,17 +1484,17 @@ g("teleport", (e, { modifiers: t, expression: r }, { cleanup: n }) => {
a.stopPropagation(), e.dispatchEvent(new a.constructor(a.type, a));
});
}), ee(o, {}, e), x(() => {
t.includes("prepend") ? i.parentNode.insertBefore(o, i) : t.includes("append") ? i.parentNode.insertBefore(o, i.nextSibling) : i.appendChild(o), $(o), o._x_ignore = !0;
t.includes("prepend") ? i.parentNode.insertBefore(o, i) : t.includes("append") ? i.parentNode.insertBefore(o, i.nextSibling) : i.appendChild(o), I(o), o._x_ignore = !0;
}), n(() => o.remove());
});
var $r = () => {
var Ir = () => {
};
$r.inline = (e, { modifiers: t }, { cleanup: r }) => {
Ir.inline = (e, { modifiers: t }, { cleanup: r }) => {
t.includes("self") ? e._x_ignoreSelf = !0 : e._x_ignore = !0, r(() => {
t.includes("self") ? delete e._x_ignoreSelf : delete e._x_ignore;
});
};
g("ignore", $r);
g("ignore", Ir);
g("effect", (e, { expression: t }, { effect: r }) => r(m(e, t)));
function He(e, t, r, n) {
let i = e, o = (c) => n(c), s = {}, a = (c, u) => (l) => u(c, l);
@@ -1646,12 +1646,12 @@ function Mi(e, t, r, n) {
}
function Oe(e) {
let t = e ? parseFloat(e) : null;
return $i(t) ? t : e;
return Ii(t) ? t : e;
}
function Ti(e, t) {
return e == t;
}
function $i(e) {
function Ii(e) {
return !Array.isArray(e) && !isNaN(e);
}
function gt(e) {
@@ -1675,7 +1675,7 @@ g("html", (e, { expression: t }, { effect: r, evaluateLater: n }) => {
r(() => {
i((o) => {
x(() => {
e.innerHTML = o, e._x_ignoreSelf = !0, $(e), delete e._x_ignoreSelf;
e.innerHTML = o, e._x_ignoreSelf = !0, I(e), delete e._x_ignoreSelf;
});
});
});
@@ -1690,24 +1690,24 @@ g("bind", (e, { value: t, modifiers: r, expression: n, original: i }, { effect:
return;
}
if (t === "key")
return Ii(e, n);
return Pi(e, n);
let s = m(e, n);
o(() => s((a) => {
a === void 0 && typeof n == "string" && n.match(/\./) && (a = ""), x(() => Yt(e, t, a, r));
}));
});
function Ii(e, t) {
function Pi(e, t) {
e._x_keyExpression = t;
}
qt(() => `[${H("data")}]`);
g("data", re((e, { expression: t }, { cleanup: r }) => {
t = t === "" ? "{}" : t;
let n = {};
Pe(n, e);
$e(n, e);
let i = {};
Dn(i, n);
let o = K(e, t, { scope: i });
(o === void 0 || o === !0) && (o = {}), Pe(o, e);
(o === void 0 || o === !0) && (o = {}), $e(o, e);
let s = z(o);
Ct(s);
let a = ee(e, s);
@@ -1739,11 +1739,11 @@ g("show", (e, { modifiers: t, expression: r }, { effect: n }) => {
});
g("for", (e, { expression: t }, { effect: r, cleanup: n }) => {
let i = Ri(t), o = m(e, i.items), s = m(e, e._x_keyExpression || "index");
e._x_prevKeys = [], e._x_lookup = {}, r(() => Pi(e, i, o, s)), n(() => {
e._x_prevKeys = [], e._x_lookup = {}, r(() => $i(e, i, o, s)), n(() => {
Object.values(e._x_lookup).forEach((a) => a.remove()), delete e._x_prevKeys, delete e._x_lookup;
});
});
function Pi(e, t, r, n) {
function $i(e, t, r, n) {
let i = (s) => typeof s == "object" && !Array.isArray(s), o = e;
r((s) => {
ji(s) && s >= 0 && (s = Array.from(Array(s).keys(), (f) => f + 1)), s === void 0 && (s = []);
@@ -1790,12 +1790,12 @@ function Pi(e, t, r, n) {
let [_, y] = p[f], b = _ === "template" ? o : a[_];
b._x_currentIfEl && (b = b._x_currentIfEl);
let w = u[y], F = l[y], q = document.importNode(o.content, !0).firstElementChild, ut = z(w);
ee(q, ut, o), q._x_refreshXForScope = (Pr) => {
Object.entries(Pr).forEach(([Rr, jr]) => {
ee(q, ut, o), q._x_refreshXForScope = ($r) => {
Object.entries($r).forEach(([Rr, jr]) => {
ut[Rr] = jr;
});
}, x(() => {
b.after(q), $(q);
b.after(q), I(q);
}), typeof F == "object" && T("x-for key cannot be an object, it must be a string or an integer", o), a[F] = q;
}
for (let f = 0; f < O.length; f++)
@@ -1823,20 +1823,20 @@ function yt(e, t, r, n) {
function ji(e) {
return !Array.isArray(e) && !isNaN(e);
}
function Ir() {
function Pr() {
}
Ir.inline = (e, { expression: t }, { cleanup: r }) => {
Pr.inline = (e, { expression: t }, { cleanup: r }) => {
let n = fe(e);
n._x_refs || (n._x_refs = {}), n._x_refs[t] = e, r(() => delete n._x_refs[t]);
};
g("ref", Ir);
g("ref", Pr);
g("if", (e, { expression: t }, { effect: r, cleanup: n }) => {
let i = m(e, t), o = () => {
if (e._x_currentIfEl)
return e._x_currentIfEl;
let a = e.content.cloneNode(!0).firstElementChild;
return ee(a, {}, e), x(() => {
e.after(a), $(a);
e.after(a), I(a);
}), e._x_currentIfEl = a, e._x_undoIf = () => {
M(a, (c) => {
c._x_effects && c._x_effects.forEach(vt);
@@ -1870,7 +1870,7 @@ we("Mask", "mask", "mask");
function we(e, t, r) {
g(t, (n) => T(`You can't use [x-${t}] without first installing the "${e}" plugin here: https://alpinejs.dev/plugins/${r}`, n));
}
ne.setEvaluator(It);
ne.setEvaluator(Pt);
ne.setReactivityEngine({ reactive: ct, effect: Gn, release: Yn, raw: h });
var Li = ne, Ni = Li;
window.addEventListener("message", Fi, !1);
File diff suppressed because one or more lines are too long
-11
View File
@@ -6,7 +6,6 @@
"": {
"name": "plugi-core",
"dependencies": {
"@phosphor-icons/web": "^2.0.3",
"alpinejs": "^3.12.2",
"grapesjs": "^0.21.2"
},
@@ -473,11 +472,6 @@
"node": ">= 8"
}
},
"node_modules/@phosphor-icons/web": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@phosphor-icons/web/-/web-2.0.3.tgz",
"integrity": "sha512-9oYmohi2fo87w3DbtfjBoJxrklVojgXq2wuGcqxKccj2TxMq7UIusKDrGUZYOQHM9pUKkh+kvfmutETMGDR6gg=="
},
"node_modules/@types/backbone": {
"version": "1.4.15",
"resolved": "https://registry.npmjs.org/@types/backbone/-/backbone-1.4.15.tgz",
@@ -2211,11 +2205,6 @@
"fastq": "^1.6.0"
}
},
"@phosphor-icons/web": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@phosphor-icons/web/-/web-2.0.3.tgz",
"integrity": "sha512-9oYmohi2fo87w3DbtfjBoJxrklVojgXq2wuGcqxKccj2TxMq7UIusKDrGUZYOQHM9pUKkh+kvfmutETMGDR6gg=="
},
"@types/backbone": {
"version": "1.4.15",
"resolved": "https://registry.npmjs.org/@types/backbone/-/backbone-1.4.15.tgz",
-1
View File
@@ -24,7 +24,6 @@
"vite": "^4.3.9"
},
"dependencies": {
"@phosphor-icons/web": "^2.0.3",
"alpinejs": "^3.12.2",
"grapesjs": "^0.21.2"
}
+35
View File
@@ -2,6 +2,7 @@
namespace Plugi\Core;
use Exception;
use PDO;
/**
@@ -106,4 +107,38 @@ class DB
$stmt = $this->pdo->prepare($query);
return $stmt->execute($parameters);
}
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");
} catch (Exception $e) {
// We got an exception (table not found)
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)
{
// 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;
} catch (Exception $e) {
$stmt = $this->pdo->prepare($sql);
return $stmt->execute();
}
}
}
@@ -2,11 +2,4 @@ import Alpine from "alpinejs"
import './sass/app.scss'
import './js/app.js'
import "@phosphor-icons/web/thin";
import "@phosphor-icons/web/light";
import "@phosphor-icons/web/regular";
import "@phosphor-icons/web/bold";
import "@phosphor-icons/web/fill";
import "@phosphor-icons/web/duotone";
Alpine.start()
@@ -17,6 +17,9 @@ if (isset($_GET['tab'])) {
<?= phpb_registered_assets('admin-header') ?>
<link href="<?= phpb_asset('WebsiteManager.css') ?>" rel="stylesheet">
<link href="<?= phpb_asset('icons/duotone/style.css') ?>" rel="stylesheet">
<link href="<?= phpb_asset('icons/regular/style.css') ?>" rel="stylesheet">
<link href="<?= phpb_asset('icons/bold/style.css') ?>" rel="stylesheet">
</head>
<body>
@@ -24,14 +27,16 @@ if (isset($_GET['tab'])) {
<input id="my-drawer-2" type="checkbox" class="drawer-toggle" />
<div class="drawer-content flex flex-col items-center justify-top">
<!-- Page content here -->
<div class="navbar bg-base-100 lg:hidden">
<div class="navbar lg:hidden bg-base-100">
<div class="navbar-start">
<label for="my-drawer-2" class="btn btn-square btn-ghost drawer-button">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="inline-block w-5 h-5 stroke-current"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path></svg>
<label for="my-drawer-2" class="btn btn-square btn-accent drawer-button border-primary">
<i class="text-lg ph-bold ph-list"></i>
</label>
</div>
<div class="navbar-center">
<span class="text-xl"><?= phpb_trans('website-manager.title') ?></span>
<span class="text-xl text-primary">
<i class="inline-block ph-bold ph-brackets-square rotate-90"></i> <?= phpb_trans('website-manager.title') ?>
</span>
</div>
<div class="navbar-end">
<a href="<?= phpb_url('auth', ['action' => 'logout']) ?>" class="btn btn-square btn-ghost">
@@ -52,14 +57,14 @@ if (isset($_GET['tab'])) {
<label for="my-drawer-2" class="drawer-overlay"></label>
<ul class="menu p-4 w-80 h-full bg-base-200 text-base-content">
<!-- Sidebar content here -->
<div class="py-5 text-2xl text-center">
<h2><?= phpb_trans('website-manager.title') ?></h2>
<div class="py-5 text-2xl text-center text-primary">
<h2"><i class="inline-block ph-bold ph-brackets-square rotate-90"></i> <?= phpb_trans('website-manager.title') ?></h2>
</div>
<?php
foreach ($tabs as $slug => $tab) :
?>
<li class="mb-1">
<a class="<?= phpb_e($slug === $activeSlug ? 'bg-base-100' : '' ) ?>" href="?tab=<?= phpb_e($slug) ?>">
<a class="<?= phpb_e($slug === $activeSlug ? 'bg-accent text-primary' : '' ) ?>" href="?tab=<?= phpb_e($slug) ?>">
<?= $tab['icon'] ?: '<i class="ph ph-circles-four"></i>' ?> <?= phpb_e($tab['title']) ?>
</a>
</li>
@@ -9,7 +9,7 @@ return [
'menus' => [
'title' => phpb_trans('website-manager.menus'),
'include' => __DIR__ . '/menus.php',
'icon' => '<i class="ph ph-list"></i>',
'icon' => '<i class="ph ph-list-dashes"></i>',
],
'files' => [
'title' => phpb_trans('website-manager.files'),
+4
View File
@@ -175,6 +175,10 @@ 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);
}
}
/**
+1 -1
View File
@@ -18,7 +18,7 @@ module.exports = {
"secondary": "#374151",
"accent": "#FCE44D",
"neutral": "#000000",
"base-100": "#ebeaeb",
"base-100": "#f3f4f6",
"info": "#5292e0",
"success": "#65a30d",
"warning": "#f3b06d",