Initial commit
This commit is contained in:
36
engine/class.plugin.php
Normal file
36
engine/class.plugin.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class Plugin {
|
||||
public string $plugin_path; // Полный путь до плагина
|
||||
public string $plugin_dir; // Папка плагина
|
||||
|
||||
public function __construct($plugin_dir)
|
||||
{
|
||||
$this->plugin_dir = $plugin_dir;
|
||||
$this->plugin_path = $this->get_plugins_dir() . SLASH . $this->plugin_dir . SLASH;
|
||||
}
|
||||
|
||||
public function get_plugins_dir() {
|
||||
return ROOT_DIR . SLASH . PLAYAREA_DIR_NAME . SLASH . "plugins";
|
||||
}
|
||||
|
||||
public function template_load($name, $variables = array(), $new = true)
|
||||
{
|
||||
global $b;
|
||||
$plugin_template_path = $this->plugin_path . "template" . $name;
|
||||
return $b->template_load_by_path($plugin_template_path, $variables, $new);
|
||||
}
|
||||
|
||||
public function router_add($page, $func, $methods = array("GET", "POST"))
|
||||
{
|
||||
global $b;
|
||||
$b->router_add($page, function () use ($func) { $func(); }, $methods);
|
||||
}
|
||||
|
||||
public function get_assets_path(): string
|
||||
{
|
||||
global $b;
|
||||
$root = $b->router_get_root_uri();
|
||||
return $root . SLASH . PLAYAREA_DIR_NAME . SLASH . 'plugins' . SLASH . $this->plugin_dir . SLASH . "assets". SLASH;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user