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

@ -3,29 +3,16 @@
root = true
[*]
tab_width = 3
[*.{php,phpt,inc,phtml}]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = tab
indent_size = 3
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
charset = utf-8
end_of_line = lf
indent_style = tab
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80
[COMMIT_EDITMSG]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80

View File

@ -1,8 +1,7 @@
<?php
// import autoload
//Autoloader
Class Autoloader {
//Autoloader
class Autoloader {
protected static $extension = ".php";
protected static $root = __DIR__;
protected static $files = [];
@ -34,7 +33,6 @@ Class Autoloader {
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,6 +45,9 @@ ini_set('session.cookie_secure', '1');
session_start ();
mb_internal_encoding ("UTF-8");
// import configs
require_once '../config/config.php';
// Logs
$logManager = new LogManager();
@ -56,13 +57,10 @@ $langMng = new LanguageManager($langTag);
$langMng->load();
//D B Conector
//Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);
Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);
// 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,13 +17,14 @@ 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);

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,13 +1,13 @@
<?php
class Template extends Partial{
var $assignedValues = [];
var $partBuffer;
var $path;
var $debug;
class Template{
private $assignedValues = [];
private $partBuffer;
private $path;
private $debug;
function __construct($path = "", $debug = false) {
$this->debug = $debug;
if (!empty('app/templates/' . $path . '.phtml') && file_exists('app/templates/' . $path . '.phtml')) {
if (!empty('../app/templates/' . $path . '.phtml') && file_exists('../app/templates/' . $path . '.phtml')) {
$this->path = $path;
} else {
echo '<pre>';
@ -26,9 +26,9 @@ class Template extends Partial{
function render() {
extract($this->assignedValues);
if (!empty('app/controls/' . $this->path . '.php') && file_exists('app/controls/' . $this->path . '.php')) {
include('app/controls/' . $this->path . '.php');
if (!empty('../app/controls/' . $this->path . '.php') && file_exists('../app/controls/' . $this->path . '.php')) {
include('../app/controls/' . $this->path . '.php');
}
require_once('app/templates/' . $this->path . '.phtml');
require_once('../app/templates/' . $this->path . '.phtml');
}
}

View File

@ -1,18 +0,0 @@
Options -Indexes
Options -MultiViews -Indexes
RewriteEngine On
RewriteBase /vasek/home-update/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !.css
RewriteCond %{REQUEST_FILENAME} !.js
RewriteRule (.*) index.php?url=$1 [QSA,L]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_FILENAME} !api.php
RewriteCond %{REQUEST_FILENAME} !apiFront.php
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
AddType application/x-httpd-php .php .phtml

View File

@ -1,5 +1,3 @@
<?php
echo('GET [url]: ' . $_GET['url']);
require_once __DIR__ . '/../app/Bootstrap.php';