Initial commit
This commit is contained in:
80
playarea/plugins/bive-admin-panel/scripts/settings.php
Normal file
80
playarea/plugins/bive-admin-panel/scripts/settings.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
defined( 'ROOT_DIR' ) || exit;
|
||||
|
||||
// Страницы настройки движка
|
||||
|
||||
$b->admin_page_set("content", "settings", "Настройки", array(), "bive_settings_page", false, "settings");
|
||||
$b->admin_page_set("settings", "main_settings","Основные", array(), "bive_settings_page");
|
||||
|
||||
function bive_get_settings_template_path(): string
|
||||
{
|
||||
return "bive-admin-panel/template/settings/settings.php";
|
||||
}
|
||||
|
||||
function bive_settings_page()
|
||||
{
|
||||
global $b;
|
||||
$b->template_load(bive_get_settings_template_path(), array("settings_list" => array("bive_site_name")));
|
||||
}
|
||||
|
||||
// Сохранение настроек
|
||||
|
||||
$b->event_add("settings_save", "bive_settings_save");
|
||||
|
||||
function bive_settings_save($args)
|
||||
{
|
||||
global $b;
|
||||
foreach ($args as $arg => $value) $b->setting_set($arg, $value);
|
||||
$b->alerts_add("Данные успешно сохранены.", "info", "admin_item");
|
||||
|
||||
if($args["b_wingman"]) {
|
||||
$admin_page = $b->ls_get_key("admin_page");
|
||||
$b->admin_page_render($admin_page, true);
|
||||
exit();
|
||||
}
|
||||
|
||||
$b->router_refresh();
|
||||
exit();
|
||||
}
|
||||
|
||||
// Поля для настроек
|
||||
|
||||
$b->setting_register("bive_site_name", "Название сайта", "plain_text");
|
||||
|
||||
class SettingPage {
|
||||
public array $settings_list = array();
|
||||
public string $parent_slug;
|
||||
public string $page_slug;
|
||||
public string $page_title;
|
||||
public array $params = array();
|
||||
public bool $hide = false;
|
||||
public bool $icon = false;
|
||||
|
||||
public function __construct($parent_slug, $page_slug, $page_title, $params = array(), $hide = false, $icon = false)
|
||||
{
|
||||
$this->parent_slug = $parent_slug;
|
||||
$this->page_slug = $page_slug;
|
||||
$this->page_title = $page_title;
|
||||
$this->params = $params;
|
||||
$this->hide = $hide;
|
||||
$this->icon = $icon;
|
||||
}
|
||||
|
||||
public function func(): Closure {
|
||||
$settings_list = $this->settings_list;
|
||||
return function () use ($settings_list) {
|
||||
global $b;
|
||||
$b->template_load(bive_get_settings_template_path(), array("settings_list" => $settings_list));
|
||||
};
|
||||
}
|
||||
|
||||
public function add(string $setting_id){
|
||||
$this->settings_list[] = $setting_id;
|
||||
}
|
||||
|
||||
public function create(){
|
||||
global $b;
|
||||
$b->admin_page_set($this->parent_slug, $this->page_slug, $this->page_title, $this->params, $this->func(), $this->hide, $this->icon);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user