refactoring new project structure

This commit is contained in:
xinatorus
2020-04-21 17:59:37 +02:00
parent c520cf847c
commit 85b10e1098
14 changed files with 57 additions and 91 deletions

View File

@@ -1,40 +1,38 @@
<?php
// import autoload
//Autoloader
class Autoloader {
protected static $extension = ".php";
protected static $root = __DIR__;
protected static $files = [];
Class Autoloader {
protected static $extension = ".php";
protected static $root = __DIR__;
protected static $files = [];
static function ClassLoader ($className = ""){
$directorys = new RecursiveDirectoryIterator(static::$root, RecursiveDirectoryIterator::SKIP_DOTS);
static function ClassLoader ($className = ""){
$directorys = new RecursiveDirectoryIterator(static::$root, RecursiveDirectoryIterator::SKIP_DOTS);
//echo '<pre>';
//var_dump($directorys);
//echo '</pre>';
//echo '<pre>';
//var_dump($directorys);
//echo '</pre>';
$files = new RecursiveIteratorIterator($directorys, RecursiveIteratorIterator::LEAVES_ONLY);
$files = new RecursiveIteratorIterator($directorys, RecursiveIteratorIterator::LEAVES_ONLY);
$filename = $className . static::$extension;
$filename = $className . static::$extension;
foreach ($files as $key => $file) {
if (strtolower($file->getFilename()) === strtolower($filename) && $file->isReadable()) {
include_once $file->getPathname();
return;
}
}
}
foreach ($files as $key => $file) {
if (strtolower($file->getFilename()) === strtolower($filename) && $file->isReadable()) {
include_once $file->getPathname();
return;
}
}
}
static function setRoot($rootPath){
static::$root = $rootPath;
}
static function setRoot($rootPath){
static::$root = $rootPath;
}
}
spl_autoload_register("Autoloader::ClassLoader");
Autoloader::setRoot('/var/www/dev.steelants.cz/vasek/home-update/');
//Debug
error_reporting(E_ALL);
ini_set( 'display_errors','1');
@@ -47,22 +45,22 @@ ini_set('session.cookie_secure', '1');
session_start ();
mb_internal_encoding ("UTF-8");
//Logs
// import configs
require_once '../config/config.php';
// Logs
$logManager = new LogManager();
//Language
// Language
$langTag = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$langMng = new LanguageManager($langTag);
$langMng->load();
//DB Conector
//Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);
//D B Conector
Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);
//TODO: Přesunout do Login Pohledu
// TODO: Přesunout do Login Pohledu
$userManager = new UserManager();
// import routes
require_once '../app/Routes.php';

View File

@@ -3,7 +3,7 @@
$router = new Router();
$router->setDefault(function(){
echo '404';
echo $_GET['URL'].': 404';
});
//Pages

View File

@@ -17,18 +17,19 @@ class LanguageManager
function load()
{
$file = './app/lang/en.php';
$file = '../lang/en.php';
if (!file_exists($file)){
echo 'ERROR: en.php not found';
die();
//TODO add lng EXEPTIONS
}
$arrayFirst = include($file);
$file = './app/lang/' . $this->lngCode . '.php';
$file = '../lang/' . $this->lngCode . '.php';
$arraySecond = [];
if (file_exists($file)){
$arraySecond = include($file);
}
$this->lngDatabase = array_merge($arrayFirst,$arraySecond);
$this->lngDatabase = array_merge($arrayFirst, $arraySecond);
return true;
}

View File

@@ -48,7 +48,7 @@ class LogManager
$record = "[".date("H:m:s")."][".$type."]" . $value . "\n";
if (strlen($record) > 65 ) {
$record = Utilities::stringInsert($record,"\n",65);
}
}
fwrite($this->logFile, $record);
}

View File

@@ -1,13 +1,13 @@
<?php
class Partial{
var $assignedValues = [];
var $partBuffer;
var $path;
var $debug;
private $assignedValues = [];
private $partBuffer;
private $path;
private $debug;
function __construct($path = "", $debug = false) {
$this->debug = $debug;
if (!empty('app/templates/part/' . $path . '.phtml') && file_exists('app/templates/part/' . $path . '.phtml')) {
if (!empty('../app/templates/part/' . $path . '.phtml') && file_exists('../app/templates/part/' . $path . '.phtml')) {
$this->path = $path;
} else {
echo '<pre>';
@@ -29,6 +29,6 @@ class Partial{
extract($this->assignedValues);
}
require('app/templates/part/' . $this->path . '.phtml');
require('../app/templates/part/' . $this->path . '.phtml');
}
}

View File

@@ -1,123 +0,0 @@
<?php
return $lang = [
//Menu
'm_home' => 'Domů',
'm_dashboard' => 'Nástěnka',
'm_settings' => 'Nastavení',
'm_automatization' => 'Automatizace',
'm_scenes' => 'Scény',
'm_log' => 'Log',
//Buttons
'b_year' => 'Rok',
'b_month' => 'Měsíc',
'b_week' => 'Týden',
'b_day' => 'Den',
'b_hour' => 'Hodina',
'b_next' => 'Další',
'b_create' => 'Vytvořit',
'b_edit' => 'Upravit',
'b_remove' => 'Smazat',
'b_finish' => 'Dokončit',
'b_approve' => 'Povolit',
'b_disable' => 'Zakázat',
'b_save' => 'Uložit',
'b_logOut' => 'Odhlásit',
'b_sendTestNotification' => 'Odeslat testovací notifikaci',
'b_rooms' => 'Místnosti',
'b_restart' => 'Restart',
'b_disable' => 'Deaktivovat',
'b_select' => 'Zvolit',
'b_ota' => 'ota',
//labels
'l_choseDevice' => 'Zvolte zařízení:',
'l_inHome' => 'Při příchodu',
'l_outHome' => 'Pri odchodu',
'l_sunSet' => 'Západ Slunce',
'l_sunRice' => 'Východ Slunce',
'l_time' => 'Čase',
'l_deviceValue' => 'Hodnotě zařízení',
'l_runAt' => 'Spustit při',
'l_resetAt' => 'Restartovat při',
'l_affectedDevices' => 'Ovlivněná zařízení',
'l_atDays' => 'Ve dny',
'l_read' => 'Číst',
'l_use' => 'Použít',
'l_edit' => 'Upravit',
'l_owner' => 'Vlastník',
'l_member' => 'Člen Domácnosti',
'l_permission' => 'Oprávmnění',
'l_inMinutes' => 'v minutách',
'l_sleepTime' => 'Doba spánku zařízení',
'l_atHome' => 'Doma Jsou',
'l_nameAt' => 'Název',
'l_lastSeen' => 'Naposledy připojeno',
'l_notificationStatus' => 'Notification status',
'l_userName' => 'Uživatelské jméno',
'l_password' => 'Heslo',
'l_oldPassword' => 'Staré Heslo',
'l_newPassword' => 'Nové Heslo',
'l_uploadFirmware' => 'Nahrát Firmware',
'l_userAvatar' => 'Avatar',
'l_userEmail' => 'Email',
'l_roomName' => 'Jméno Místnosti',
//Title
't_createScene' => 'Vytvořit scénu',
't_editScene' => 'Upravit scénu',
't_createAutomation' => 'Vytvořit Automatizaci',
't_addDevice' => 'Přidat Zařízení',
't_editDevice' => 'Upravit Zařízení',
't_pageAfterLogIn' => 'stránka po přihlášení',
't_profile' => 'Profil',
't_notification' => 'Notificatifikace',
't_experimental' => 'Experimental',
't_createuser' => 'Vytvořit Uživatele',
't_changePassword' => 'Změnit Heslo',
't_networkSetting' => 'Nastavení Sítě',
't_deviceVersion' => 'Nastavení Verze',
't_ota' => 'OTA',
't_listUsers' => 'Seznam Uživatelů',
't_avatar' => 'Avatar',
't_listRooms' => 'Seznam Místností',
't_roomName' => 'Jméno Místnosti',
't_createRoom' => 'Vytvořit Místnost',
//constants
'temp' => 'Teplota',
'humi' => 'Vlhkost',
'light' => 'Světlo',
'battery' => 'Baterie',
'on/off' => 'Vypínač',
//words
'w_title' => 'Název',
'w_icon' => 'Ikona',
'w_no' => 'žádná',
'w_noOne' => 'Nikdo',
'w_someOne' => 'Někdo',
'w_room' => 'Místnost',
'w_moduls' => 'Moduly',
'w_home' => 'Doma',
'w_neni' => 'Není',
'w_is' => 'je',
//tables
't_time' => 'Čas',
't_state' => 'Stav',
't_userName' => 'Uživatelské Jméno',
't_action' => 'Akce',
//Days Long
'd_monday' => 'Pondělí',
'd_tuesday' => 'Ůterí',
'd_wednesday' => 'Středa',
'd_thursday' => 'Čtvrtek',
'd_friday' => 'Pátek',
'd_saturday' => 'Sobota',
'd_sunday' => 'Neděle',
//example
'' => '',
];

View File

@@ -1,123 +0,0 @@
<?php
return $lang = [
//Menu
'm_home' => 'Home',
'm_dashboard' => 'Dashboard',
'm_settings' => 'Setting',
'm_automatization' => 'Automatization',
'm_scenes' => 'Scenes',
'm_log' => 'Log',
//Buttons
'b_year' => 'Year',
'b_month' => 'Month',
'b_week' => 'Week',
'b_day' => 'Day',
'b_hour' => 'Hour',
'b_next' => 'Next',
'b_create' => 'Create',
'b_edit' => 'Edit',
'b_remove' => 'Remove',
'b_finish' => 'Finish',
'b_approve' => 'Approve',
'b_disable' => 'Disable',
'b_save' => 'Save',
'b_logOut' => 'Logout',
'b_sendTestNotification' => 'Send Test Notification',
'b_rooms' => 'Rooms',
'b_restart' => 'Restart',
'b_disable' => 'disabele',
'b_select' => 'Select',
'b_ota' => 'ota',
//labels
'l_choseDevice' => 'Chose device:',
'l_inHome' => 'When entering',
'l_outHome' => 'When exiting',
'l_sunSet' => 'Sun Set',
'l_sunRice' => 'Sun Rise',
'l_time' => 'Time',
'l_deviceValue' => 'Device Valalue',
'l_runAt' => 'Run at',
'l_resetAt' => 'Reset at',
'l_affectedDevices' => 'Affected devices',
'l_atDays' => 'At days',
'l_read' => 'Read',
'l_use' => 'Use',
'l_edit' => 'Edit',
'l_owner' => 'Owner',
'l_member' => 'Home Member',
'l_permission' => 'Permission',
'l_inMinutes' => 'in minutes',
'l_sleepTime' => 'Device sleep Time',
'l_atHome' => 'At home',
'l_nameAt' => 'Name',
'l_lastSeen' => 'Last Seen',
'l_notificationStatus' => 'Notification status',
'l_userName' => 'Username',
'l_password' => 'Password',
'l_oldPassword' => 'Old Password',
'l_newPassword' => 'New Password',
'l_uploadFirmware' => 'Upload Firmware',
'l_userAvatar' => 'Avatar',
'l_userEmail' => 'Email',
'l_roomName' => 'Room Name',
//Title
't_createScene' => 'Create Scene',
't_editScene' => 'Edit scénu',
't_createAutomation' => 'Create Automation',
't_addDevice' => 'Add Device',
't_editDevice' => 'Edit Device',
't_pageAfterLogIn' => 'Page After Login',
't_profile' => 'Profile',
't_notification' => 'Notification',
't_experimental' => 'Experimental',
't_createuser' => 'Create User',
't_changePassword' => 'Change Password',
't_networkSetting' => 'Network Setting',
't_deviceVersion' => 'Version Setting',
't_ota' => 'OTA',
't_listUsers' => 'User List',
't_avatar' => 'Avatar',
't_listRooms' => 'Room List',
't_roomName' => 'Room Name',
't_createRoom' => 'Create Rom',
//constants
'humi' => 'Humidity',
'temp' => 'Temperature',
'light' => 'Light',
'battery' => 'Batteri',
'on/off' => 'Switch',
//words
'w_title' => 'Name',
'w_icon' => 'Icon',
'w_no' => 'no',
'w_noOne' => 'noone',
'w_someOne' => 'Some',
'w_room' => 'Room',
'w_moduls' => 'Moduls',
'w_home' => 'Home',
'w_neni' => 'At',
'w_is' => 'is',
//tables
't_time' => 'Time',
't_state' => 'State',
't_userName' => 'State',
't_action' => 'Action',
//Days Long
'd_monday' => 'Monday',
'd_tuesday' => 'Tuesday',
'd_wednesday' => 'Wednesday',
'd_thursday' => 'Thursday',
'd_friday' => 'Friday',
'd_saturday' => 'Saturday',
'd_sunday' => 'Sunday',
//example
'' => '',
];

View File

@@ -1,102 +0,0 @@
<?php
return $lang = [
//Menu
'm_home' => 'Home',
'm_dashboard' => 'Controlepaneel',
'm_settings' => 'Instellingen',
'm_automatization' => 'Automatisatie',
'm_scenes' => 'Scénes',
'm_log' => 'Log',
//Buttons
'b_year' => 'Jaar',
'b_month' => 'Maand',
'b_week' => 'Week',
'b_day' => 'Dag',
'b_hour' => 'Uur',
'b_next' => 'Volgende',
'b_create' => 'Maak',
'b_edit' => 'Bewerk',
'b_remove' => 'Verwijder',
'b_approve' => 'Keur goed',
'b_disable' => 'Zet uit',
'b_save' => 'Opslaan',
'b_logOut' => 'Log Uit',
'b_sendTestNotification' => 'Verzend Test Notificatie',
'b_rooms' => 'Kamers',
'b_restart' => 'Herstart',
'b_disable' => 'Zet uit',
'b_select' => 'Selecteer',
//labels
'l_choseDevice' => 'Kies apparaat:',
'l_inHome' => 'Bij het inkomen',
'l_outHome' => 'Bij het buitengaan',
'l_sunSet' => 'Zonsondergang',
'l_sunRice' => 'Zonsopkomst',
'l_time' => 'Tijd',
'l_deviceValue' => 'Apparaat Waarde',
'l_runAt' => 'Voer uit bij',
'l_resetAt' => 'Reset bij',
'l_affectedDevices' => 'Getroffen apparaten',
'l_atDays' => 'Op dagen ',
'l_read' => 'Lees',
'l_use' => 'Gebruik',
'l_edit' => 'Bewerk',
'l_owner' => 'eigenaar',
'l_member' => 'Huis lid',
'l_permission' => 'Permissie',
'l_inMinutes' => 'in minuten',
'l_sleepTime' => 'Apparaat slaaptijd',
'l_atHome' => 'Thuis',
'l_nameAt' => 'Naam',
'l_lastSeen' => 'Laatst gezien',
'l_notificationStatus' => 'Notificatie status',
//Title
't_createScene' => 'Maak scéne',
't_editScene' => 'Bewerk scéne',
't_createAutomation' => 'Maak automatisatie',
't_addDevice' => 'Voeg apparaat toe',
't_editDevice' => 'Bewerk apparaat',
't_pageAfterLogIn' => 'Pagina na Login',
't_profile' => 'Profiel',
't_notification' => 'Notificatie',
't_experimental' => 'experimenteel',
//constants
'humi' => 'Vochtigheid',
'temp' => 'Temperatuur',
'light' => 'Licht',
'battery' => 'Batterij',
'on/off' => 'Schakelaar',
//words
'w_title' => 'Naam',
'w_icon' => 'Icoon',
'w_no' => 'nee',
'w_noOne' => 'niemand',
'w_someOne' => 'Sommige',
'w_room' => 'Kamer',
'w_moduls' => 'Modules',
'w_home' => 'Huis',
'w_neni' => 'Bij',
'w_is' => 'is',
//tables
't_time' => 'Tijd',
't_state' => 'Status',
//Days Long
'd_monday' => 'Maandag',
'd_tuesday' => 'Dinsdag',
'd_wednesday' => 'Woensdag',
'd_thursday' => 'Donderdag',
'd_friday' => 'Vrijdag',
'd_saturday' => 'Zaterdag',
'd_sunday' => 'Zondag',
//example
'' => '',
];

View File

@@ -1,110 +0,0 @@
<?php
return $lang = [
//Menu
'm_home' => 'Strona główna',
'm_dashboard' => 'Panel urządzeń',
'm_settings' => 'Ustawienia',
'm_automatization' => 'Zaplanowane działania',
'm_scenes' => 'Scenariusze',
'm_log' => 'Logi',
//Buttons
'b_year' => 'Rok',
'b_month' => 'Miesiąc',
'b_week' => 'Tydzień',
'b_day' => 'Dzień',
'b_hour' => 'Godzina',
'b_next' => 'Dalej',
'b_create' => 'Utwórz',
'b_edit' => 'Edytuj',
'b_remove' => 'Usuń',
'b_finish' => 'Dokončit', //newOne
'b_approve' => 'Zaakceptuj',
'b_disable' => 'Wyłącz',
'b_save' => 'Zapisz',
'b_logOut' => 'Wyloguj',
'b_sendTestNotification' => 'Wyślij próbne powiadomienie',
'b_rooms' => 'Pokoje',
'b_restart' => 'Zrestartuj',
'b_disable' => 'Wyłącz',
'b_select' => 'Wybierz',
//labels
'l_choseDevice' => 'Wybierz urządzenie:',
'l_inHome' => 'Przy wchodzeniu',
'l_outHome' => 'Przy wychodzeniu',
'l_sunSet' => 'Zachodzie słońca',
'l_sunRice' => 'Zschodzie słońca',
'l_time' => 'O określonym czasie',
'l_deviceValue' => 'Przy wartości urządzenia',
'l_runAt' => 'Uruchom o',
'l_resetAt' => 'Resetuj o',
'l_affectedDevices' => 'Ma wpływ na urządzenia',
'l_atDays' => 'W dni',
'l_read' => 'Odczytywanie',
'l_use' => 'Używanie',
'l_edit' => 'Edytowanie',
'l_owner' => 'Właściciel',
'l_member' => 'Domownik',
'l_permission' => 'Uprawnienia',
'l_inMinutes' => 'w minutach',
'l_sleepTime' => 'Czas snu urządzenia',
'l_atHome' => 'W domu',
'l_nameAt' => 'Nazwa',
'l_lastSeen' => 'Ostatnio zaktualizowany',
'l_notificationStatus' => 'Stan powiadomienia',
'l_userName' => 'Username', //newOne
'l_password' => 'Password', //newOne
'l_oldPassword' => 'Old Password', //newOne
'l_newPassword' => 'New Password', //newOne
//Title
't_createScene' => 'Utwórz scenariusz',
't_editScene' => 'Edytuj scenariusz',
't_createAutomation' => 'Utwórz automację',
't_addDevice' => 'Dodaj Urządzenie',
't_editDevice' => 'Edutuj urządzenie',
't_pageAfterLogIn' => 'Strona Po Zalogowaniu',
't_profile' => 'Profil',
't_notification' => 'Powiadomienie',
't_experimental' => 'Eksperymentalne',
't_createuser' => 'Vytvořit Uživatele', //newOne
't_changePassword' => 'Změnit Heslo', //newOne
//constants
'humi' => 'Wilgotność',
'temp' => 'Temperatura',
'light' => 'Światło',
'battery' => 'Bateria',
'on/off' => 'Przełącznik',
//words
'w_title' => 'Nazwa',
'w_icon' => 'ikony',
'w_no' => 'Brak',
'w_noOne' => 'nikt',
'w_someOne' => 'Ktoś',
'w_room' => 'Pokój',
'w_moduls' => 'Moduły',
'w_home' => 'Dom',
'w_neni' => 'W',
'w_is' => 'jest',
//tables
't_time' => 'Czas',
't_state' => 'Stan',
't_userName' => 'State', //newOne
't_action' => 'Action', //newOne
//Days Long
'd_monday' => 'Poniedziałek',
'd_tuesday' => 'Wtorek',
'd_wednesday' => 'Środa',
'd_thursday' => 'Czwartek',
'd_friday' => 'Piątek',
'd_saturday' => 'Sobota',
'd_sunday' => 'Niedziela',
//example
'' => '',
];