initial commit

This commit is contained in:
Paul Spenke
2023-06-09 10:24:36 +08:00
parent 00ceb09c93
commit b493973559
146 changed files with 19956 additions and 0 deletions
@@ -0,0 +1,20 @@
<?php
return [
'pages' => [
'title' => phpb_trans('website-manager.pages'),
'include' => __DIR__ . '/pages.php',
],
'menus' => [
'title' => phpb_trans('website-manager.menus'),
'include' => __DIR__ . '/menus.php',
],
'files' => [
'title' => phpb_trans('website-manager.files'),
'include' => __DIR__ . '/files.php',
],
'settings' => [
'title' => phpb_trans('website-manager.settings'),
'include' => __DIR__ . '/settings.php',
],
];
@@ -0,0 +1,44 @@
<div class="mb-8 flex justify-center">
<input type="file" id="fileupload" class="file-input file-input-bordered file-input-sm file-input-primary w-full max-w-md" name="fileupload" onchange="uploadFile()" onselect="uploadFile()" />
</div>
<div class="flex flex-wrap gap-4">
<?php
foreach ($files as $file) :
?>
<div class="relative">
<img src="<?= phpb_e($file->getUrl()) ?>" alt="<?= phpb_e($file->public_id) ?>" class="h-40 rounded">
<div class="absolute top-1 right-1">
<button onclick="deleteFile('<?= phpb_e($file->public_id) ?>')" class="btn btn-error btn-circle btn-sm mb-2">
<i class="ph-duotone ph-trash"></i>
</button>
</div>
</div>
<?php
endforeach;
?>
</div>
<script>
async function uploadFile() {
let formData = new FormData();
const fileupload = document.getElementById('fileupload');
formData.append("files", fileupload.files[0]);
await fetch('<?= phpb_url('pagebuilder', ['action' => 'upload', 'page' => '1']) ?>', {
method: "POST",
body: formData
}).then(() => {
location.reload();
}).catch(() => {alert('An Error occured.')});
}
async function deleteFile(id) {
let formData = new FormData();
formData.append("id", id);
await fetch('<?= phpb_url('pagebuilder', ['action' => 'upload_delete', 'page' => '1']) ?>', {
method: "POST",
body: formData
}).then(() => {
location.reload();
}).catch(() => {alert('An Error occured.')});
}
</script>
@@ -0,0 +1,91 @@
<?php
use PHPageBuilder\Repositories\PageRepository;
$setting = phpb_instance('setting');
$pageRepository = new PageRepository;
$pages = $pageRepository->getAll();
?>
<form method="post" action="<?= phpb_url('website_manager', ['route' => 'menus', 'action' => 'update', 'tab' => 'menus']) ?>">
<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-8">
<template x-for="menu in menus">
<div class="">
<div class="px-6 mb-4 flex justify-between">
<div class="text-2xl font-bold" x-text="menu.name"></div>
<div class="dropdown dropdown-end dropdown-hover" x-show="(menu.pages.length < pages.length)">
<label tabindex="0" class="btn btn-circle btn-sm">
<i class="text-2xl ph-bold ph-plus"></i>
</label>
<ul tabindex="0" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-52">
<template x-for="page in pages.filter(p=> !menu.pages.map(m=>m.id).includes(p.id))">
<li>
<a href="javascript:void(0)" @click="menu.pages.push(page)">
<span x-text="page.id" class="mr-3 font-bold"></span>
<span x-text="page.title"></span>
</a>
</li>
</template>
</ul>
</div>
</div>
<div class="">
<input type="hidden" :name="menu.name" :value="menu.pages.map(p=>p.id).join(',')">
<template x-for="(page, index) in menu.pages">
<div class="flex flex-nowrap gap-4 px-6 py-4 border-l border-r last:border-b border-t first-of-type:rounded-t last:rounded-b">
<div class="flex-none w-6" x-text="page.id"></div>
<div class="grow" x-text="page.title"></div>
<div class="flex-none w-60" x-text="page.route"></div>
<div class="flex-none">
<button type="button" @click.stop.prevent="arraymove(menu.pages,index,index-1)" class="btn btn-outline btn-circle btn-xs" :disabled="index === 0">
<i class="ph-fill ph-arrow-fat-up"></i>
</button>
<button type="button" @click.stop.prevent="arraymove(menu.pages,index,index+1)" class="btn btn-outline btn-circle btn-xs" :disabled="index === menu.pages.length - 1">
<i class="ph-fill ph-arrow-fat-down"></i>
</button>
<button @click.stop.prevent="arraymove(menu.pages,index)" class="btn btn-outline btn-circle btn-error btn-xs">
<i class="ph-duotone ph-trash"></i>
</button>
</div>
</div>
</template>
</div>
</div>
</template>
</div>
<div class="text-center mt-8">
<button class="btn btn-primary btn-sm">
<?= phpb_trans('website-manager.save-menus'); ?>
</button>
</div>
</div>
</form>
<script>
function arraymove(arr, fromIndex, toIndex = false) {
console.log(arr)
const element = arr[fromIndex];
arr.splice(fromIndex, 1);
if(toIndex !== false){
arr.splice(toIndex, 0, element);
}
}
</script>
@@ -0,0 +1,67 @@
<div class="main-spacing">
<?php
if (phpb_flash('message')):
?>
<div class="alert alert-<?= phpb_flash('message-type') ?>">
<?= phpb_flash('message') ?>
</div>
<?php
endif;
?>
<div class="table-responsive">
<table class="table table-zebra">
<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>
</div>
</div>
<div class="text-center mt-8">
<a href="<?= phpb_url('website_manager', ['route' => 'page_settings', 'action' => 'create']) ?>" class="btn btn-primary btn-sm">
<?= phpb_trans('website-manager.add-new-page') ?>
</a>
</div>
@@ -0,0 +1,99 @@
<?php
use PHPageBuilder\Extensions;
$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="form-control w-full mb-6">
<label for="languages" class="label">
<span class="label-text"><?= phpb_trans('website-manager.website-languages') ?></span>
</label>
<select class="select select-bordered w-full" id="languages" name="languages[]" title="<?= phpb_trans('website-manager.languages-selector-placeholder') ?>" required multiple>
<?php
foreach (phpb_trans('languages') as $locale => $localeText):
?>
<option value="<?= phpb_e($locale) ?>" <?= phpb_e($settingIns::has('languages', $locale)) ? 'selected' : '' ?>><?= phpb_e($localeText) ?></option>
<?php
endforeach;
?>
</select>
</div>
<div class="flex flex-col gap-6">
<?php
foreach (Extensions::getConfigs() as $extKey => $config):
if(count(Extensions::getSettings($extKey)) === 0){
continue;
}
?>
<details class="collapse collapse-plus bg-base-200">
<summary class="collapse-title text-xl font-medium"><?= phpb_e($config['title']) ?></summary>
<div class="collapse-content">
<div class="">
<?php
foreach (Extensions::getSettings($extKey) as $setting):
?>
<?php
if ($setting['type'] === 'text'):
?>
<div class="form-control w-full">
<label class="label">
<span class="label-text"><?= phpb_e($setting['label'] ?: $setting['name']) ?></span>
</label>
<input type="text" name="<?= phpb_e($setting['key']) ?>" value="<?= phpb_e($setting['value']) ?>" class="input input-bordered w-full" />
</div>
<?php
endif;
?>
<?php
if ($setting['type'] === 'toggle'):
?>
<div class="form-control" x-data="{state: <?= phpb_e($setting['value']) ?>}">
<label class="label cursor-pointer">
<span class="label-text"><?= phpb_e($setting['label'] ?: $setting['name']) ?></span>
<input type='hidden' :value="state" name="<?= phpb_e($setting['key']) ?>">
<input type="checkbox" class="toggle" x-model="state" />
</label>
</div>
<?php
endif;
?>
<?php
endforeach;
?>
</div>
</div>
</details>
<?php
endforeach;
?>
</div>
<button class="btn btn-primary btn-sm mt-8">
<?= phpb_trans('website-manager.save-settings'); ?>
</button>
<!-- <div class="mt-8">-->
<!-- --><?php //= phpb_trans('website-manager.pagebuilder-block-images') ?>
<!-- </div>-->
<!-- <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>