refactoring new project structure
This commit is contained in:
parent
c520cf847c
commit
85b10e1098
@ -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_style = tab
|
||||
indent_size = 3
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = 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
|
@ -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';
|
||||
|
@ -3,7 +3,7 @@
|
||||
$router = new Router();
|
||||
|
||||
$router->setDefault(function(){
|
||||
echo '404';
|
||||
echo $_GET['URL'].': 404';
|
||||
});
|
||||
|
||||
//Pages
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -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
|
@ -1,5 +1,3 @@
|
||||
<?php
|
||||
|
||||
echo('GET [url]: ' . $_GET['url']);
|
||||
|
||||
require_once __DIR__ . '/../app/Bootstrap.php';
|
||||
|
Loading…
Reference in New Issue
Block a user