mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 17:54:55 +02:00
Merge branch 'main' into develop
This commit is contained in:
@@ -343,16 +343,16 @@ function getDatabasePages($withHidden = false): array
|
||||
|
||||
function loadPageFromFileSystem($page, &$found): string
|
||||
{
|
||||
$file = SYSTEM . 'pages/' . $page . '.php';
|
||||
// feature: load pages from templates/ dir
|
||||
global $template_path;
|
||||
$file = $template_path . '/pages/' . $page . '.php';
|
||||
if (!is_file($file)) {
|
||||
// feature: convert camelCase to snake_case
|
||||
// so instead of forum/move_thread
|
||||
// we can write: forum/moveThread
|
||||
$file = SYSTEM . 'pages/' . camelCaseToUnderscore($page) . '.php';
|
||||
$file = SYSTEM . 'pages/' . $page . '.php';
|
||||
if (!is_file($file)) {
|
||||
// feature: load pages from templates/ dir
|
||||
global $template_path;
|
||||
$file = $template_path . '/pages/' . $page . '.php';
|
||||
// feature: convert camelCase to snake_case
|
||||
// so instead of forum/move_thread
|
||||
// we can write: forum/moveThread
|
||||
$file = SYSTEM . 'pages/' . camelCaseToUnderscore($page) . '.php';
|
||||
if (!is_file($file)) {
|
||||
$found = false;
|
||||
}
|
||||
|
@@ -11,6 +11,81 @@ class Plugins {
|
||||
private static $error = null;
|
||||
private static $plugin_json = [];
|
||||
|
||||
public static function getAdminPages()
|
||||
{
|
||||
return Cache::remember('plugins_admin_pages', 10 * 60, function () {
|
||||
$adminPages = [];
|
||||
foreach(self::getAllPluginsJson() as $plugin) {
|
||||
if (!self::getAutoLoadOption($plugin, 'admin-pages', true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$adminPagesDefaultPriority = 1000;
|
||||
if (isset($plugin['admin-pages-default-priority'])) {
|
||||
$adminPagesDefaultPriority = $plugin['admin-pages-default-priority'];
|
||||
}
|
||||
|
||||
//
|
||||
// Get all plugins/*/admin-pages/*.php pages
|
||||
//
|
||||
$pluginAdminPages = glob(PLUGINS . $plugin['filename'] . '/admin-pages/*.php');
|
||||
foreach ($pluginAdminPages as $file) {
|
||||
$file = str_replace(PLUGINS, 'plugins/', $file);
|
||||
$name = pathinfo($file, PATHINFO_FILENAME);
|
||||
|
||||
$adminPages[] = ['name' => $name, 'file' => $file, 'priority' => $adminPagesDefaultPriority];
|
||||
}
|
||||
|
||||
if (self::getAutoLoadOption($plugin, 'admin-pages-sub-folders', true)) {
|
||||
//
|
||||
// Get all plugins/*/admin-pages/subFolder/*.php pages
|
||||
//
|
||||
$pluginAdminPagesSubFolders = glob(PLUGINS . $plugin['filename'] . '/admin-pages/*', GLOB_ONLYDIR);
|
||||
foreach ($pluginAdminPagesSubFolders as $folder) {
|
||||
$folderName = pathinfo($folder, PATHINFO_FILENAME);
|
||||
|
||||
$subFiles = glob(PLUGINS . $plugin['filename'] . '/admin-pages/' . $folderName . '/*.php');
|
||||
foreach ($subFiles as $file) {
|
||||
$file = str_replace(PLUGINS, 'plugins/', $file);
|
||||
$name = $folderName . '/' . pathinfo($file, PATHINFO_FILENAME);
|
||||
|
||||
$adminPages[] = ['name' => $name, 'file' => $file, 'priority' => $adminPagesDefaultPriority];
|
||||
}
|
||||
|
||||
$subFolders = glob(PLUGINS . $plugin['filename'] . '/admin-pages/' . $folderName . '/*', GLOB_ONLYDIR);
|
||||
foreach ($subFolders as $subFolder) {
|
||||
$subFolderName = pathinfo($subFolder, PATHINFO_FILENAME);
|
||||
$subSubFiles = glob(PLUGINS . $plugin['filename'] . '/admin-pages/' . $folderName . '/' . $subFolderName . '/*.php');
|
||||
|
||||
foreach ($subSubFiles as $subSubFile) {
|
||||
$subSubFile = str_replace(PLUGINS, 'plugins/', $subSubFile);
|
||||
$name = $folderName . '/' . $subFolderName . '/' . pathinfo($subSubFile, PATHINFO_FILENAME);
|
||||
|
||||
$adminPages[] = ['name' => $name, 'file' => $subSubFile, 'priority' => $adminPagesDefaultPriority];;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
usort($adminPages, function ($a, $b)
|
||||
{
|
||||
if ($a['priority'] == $b['priority']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($a['priority'] > $b['priority']) ? -1 : 1;
|
||||
});
|
||||
|
||||
$ret = [];
|
||||
foreach ($adminPages as $value) {
|
||||
$ret[$value['name']] = $value['file'];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
});
|
||||
}
|
||||
|
||||
public static function getRoutes()
|
||||
{
|
||||
$cache = Cache::getInstance();
|
||||
@@ -411,20 +486,13 @@ class Plugins {
|
||||
$continue = true;
|
||||
|
||||
if(!isset($plugin_json['name']) || empty(trim($plugin_json['name']))) {
|
||||
self::$warnings[] = 'Plugin "name" tag is not set.';
|
||||
}
|
||||
if(!isset($plugin_json['description']) || empty(trim($plugin_json['description']))) {
|
||||
self::$warnings[] = 'Plugin "description" tag is not set.';
|
||||
self::$error = 'Plugin "name" tag is not set.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isset($plugin_json['version']) || empty(trim($plugin_json['version']))) {
|
||||
self::$warnings[] = 'Plugin "version" tag is not set.';
|
||||
}
|
||||
if(!isset($plugin_json['author']) || empty(trim($plugin_json['author']))) {
|
||||
self::$warnings[] = 'Plugin "author" tag is not set.';
|
||||
}
|
||||
if(!isset($plugin_json['contact']) || empty(trim($plugin_json['contact']))) {
|
||||
self::$warnings[] = 'Plugin "contact" tag is not set.';
|
||||
}
|
||||
|
||||
if(isset($plugin_json['require'])) {
|
||||
$require = $plugin_json['require'];
|
||||
|
@@ -1 +1 @@
|
||||
<input type="submit" name="{{ button_name }}" value="{{ button_name }}" />
|
||||
<input {% if noSubmit is not defined %}type="submit"{% endif %} name="{{ button_name }}" value="{{ button_name }}" />
|
||||
|
Reference in New Issue
Block a user