Make plugins list and switcher
This commit is contained in:
@@ -11,8 +11,8 @@ class Device extends Template
|
||||
$roomManager = new RoomManager ();
|
||||
$langMng = new LanguageManager ('en');
|
||||
|
||||
if (!$userManager->isLogin ()) {
|
||||
header ('Location: ' . BASEURL . 'device');
|
||||
if (!$userManager->isLogin()){
|
||||
header('Location: ' . BASEURL . 'login');
|
||||
}
|
||||
|
||||
$template = new Template ('device');
|
||||
|
38
app/views/Plugins.php
Normal file
38
app/views/Plugins.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
class Plugins extends Template
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
$userManager = new UserManager();
|
||||
$langMng = new LanguageManager('en');
|
||||
|
||||
|
||||
if (!$userManager->isLogin()){
|
||||
header('Location: ' . BASEURL . 'login');
|
||||
}
|
||||
|
||||
$dir = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/';
|
||||
$pluginsFiles = array_diff(scandir($dir), ['..', '.']);
|
||||
|
||||
$plugins = array();
|
||||
|
||||
foreach ($pluginsFiles as $key => $pluginFile) {
|
||||
$status = (strpos($pluginFile, "!") !== false ? false : true);
|
||||
$plugins[$key]['name'] = str_replace("!", "", str_replace(".php", "", $pluginFile));
|
||||
$plugins[$key]['status'] = $status;
|
||||
}
|
||||
|
||||
sort($plugins);
|
||||
|
||||
$template = new Template('plugins');
|
||||
$template->prepare('baseDir', BASEDIR);
|
||||
$template->prepare('debugMod', DEBUGMOD);
|
||||
$template->prepare('title', 'Plugins');
|
||||
$template->prepare('langMng', $langMng);
|
||||
$template->prepare('plugins', $plugins);
|
||||
|
||||
|
||||
|
||||
$template->render();
|
||||
}
|
||||
}
|
@@ -6,6 +6,11 @@
|
||||
'lngKey' => 'devices',
|
||||
'path' => 'device',
|
||||
],
|
||||
'fas fa-plug' => [
|
||||
'slug' => 'plugins',
|
||||
'lngKey' => 'plugins',
|
||||
'path' => 'plugins',
|
||||
],
|
||||
'fa-wrench' => [
|
||||
'slug' => 'setting',
|
||||
'lngKey' => 'settings',
|
||||
|
54
app/views/templates/plugins.phtml
Normal file
54
app/views/templates/plugins.phtml
Normal file
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<?php
|
||||
$partial = new Partial('head');
|
||||
$partial->prepare('baseDir', $BASEDIR);
|
||||
$partial->render();
|
||||
?>
|
||||
<title><?php echo $TITLE ?></title>
|
||||
</head>
|
||||
<body class="no-transitions">
|
||||
<div class="row no-gutters main">
|
||||
<div class="col-md-3 d-sm-none"></div>
|
||||
<div class="col-md-3 nav-container">
|
||||
<?php
|
||||
$partial = new Partial('menu');
|
||||
$partial->prepare('item', 'plugins');
|
||||
$partial->prepare('langMng',$LANGMNG);
|
||||
$partial->prepare('debugMod',$DEBUGMOD);
|
||||
$partial->render();
|
||||
?>
|
||||
</div>
|
||||
<div class="col-md-9 main-body">
|
||||
<div class="col-12 col-sm-9 mx-auto mt-4">
|
||||
<h1><?php echo $LANGMNG->get('t_Plugins'); ?></h1>
|
||||
|
||||
<div class="row mb-4">
|
||||
<?php if ($PLUGINS): ?>
|
||||
<?php foreach ($PLUGINS as $plugin): ?>
|
||||
<div class="content">
|
||||
<form method="post" action="">
|
||||
<input type="hidden" name="name" value="<?php echo $plugin['name']; ?>"/>
|
||||
<input type="hidden" name="actualStatus" value="<?php echo $plugin['status']; ?>"/>
|
||||
<a onclick="$(this).closest('form').submit();">
|
||||
<div class="panel box content <?php echo ($plugin['status'] ? '' : 'disabled '); ?>p-4">
|
||||
<h5><?php echo $plugin['name']; ?></h5>
|
||||
</div>
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$partial = new Partial('footer');
|
||||
$partial->prepare('baseDir', BASEDIR);
|
||||
$partial->render();
|
||||
//TODO js do main.js
|
||||
?>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user