lib framework, michelf lib restructure, saimod docu update, sai better error messages

This commit is contained in:
Ulf Gebhardt 2015-06-06 20:22:51 +02:00
parent bb54a0ae37
commit c795a4aacb
17 changed files with 78 additions and 4 deletions

3
lib/Michelf/autoload.inc Normal file
View File

@ -0,0 +1,3 @@
<?php
\SYSTEM\autoload::registerFolder(dirname(__FILE__),'LIB');
\LIB\lib_controll::register('\LIB\lib_michelf');

View File

@ -0,0 +1,10 @@
<?php
namespace LIB;
class lib_michelf extends \LIB\lib_php{
public static function get_class($params = null){
return self::class;}
public static function php_autoload(){
\SYSTEM\autoload::registerFolder(dirname(__FILE__).'/lib','Michelf');
return true;}
}

View File

@ -1,2 +1,3 @@
<?php
\SYSTEM\autoload::registerFolder(dirname(__FILE__).'/Michelf','Michelf');
\SYSTEM\autoload::registerFolder(dirname(__FILE__),'LIB');
require_once dirname(__FILE__).'/Michelf/autoload.inc';

18
lib/lib.php Normal file
View File

@ -0,0 +1,18 @@
<?php
namespace LIB;
abstract class lib {
public static function php(){
if(!\method_exists(static::get_class(), 'php_autoload')){
throw new \SYSTEM\LOG\ERROR('Function php_autoload not implemented in '.static::get_class());}
return static::php_autoload();}
public static function css(){
if(!\method_exists(static::get_class(), 'css_path')){
throw new \SYSTEM\LOG\ERROR('Function css_path not implemented in '.static::get_class());}
return static::css_path(); //use tpl here? yes? any negative effex?
}
public static function js(){
if(!\method_exists(static::get_class(), 'js_path')){
throw new \SYSTEM\LOG\ERROR('Function js_path not implemented in '.static::get_class());}
return static::js_path();
}
}

17
lib/lib_controll.php Normal file
View File

@ -0,0 +1,17 @@
<?php
namespace LIB;
class lib_controll {
private static $libs = array();
private static function check_lib($lib){
if( !\class_exists($lib) ||
!\is_array($parents = \class_parents($lib)) ||
!\array_search('LIB\lib', $parents)){
return false;}
return true;}
public static function register($classname){
if(!self::check_lib($classname)){
throw new \SYSTEM\LOG\ERROR('Problem with your lib class: '.$classname.'; it might not be available or inherits from the wrong class!');}
array_push(self::$libs,$classname);
}
}

5
lib/lib_css.php Normal file
View File

@ -0,0 +1,5 @@
<?php
namespace LIB;
abstract class lib_css extends lib{
protected static abstract function css_path(); //css webpath
}

5
lib/lib_js.php Normal file
View File

@ -0,0 +1,5 @@
<?php
namespace LIB;
abstract class lib_js extends lib{
protected static function js_path(){} //js webpath
}

6
lib/lib_jscss.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace LIB;
abstract class lib_jscss extends lib{
protected static abstract function js_path();
protected static abstract function css_path();
}

8
lib/lib_php.php Normal file
View File

@ -0,0 +1,8 @@
<?php
namespace LIB;
//dont use system paths? for php yes - for js css not possibledue webpath -> PLIB object?
//or mask all paths using api
abstract class lib_php extends lib{
protected static function php_autoload(){} //autload magic? require_once lib\autoload.inc -> should do the trick -> do that in lib
}

View File

@ -25,6 +25,7 @@ class saimod_sys_docu extends \SYSTEM\SAI\SaiModule {
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_docu_action_doc($cat = 'System',$doc = '1_system_md'){
\LIB\lib_michelf::php();
$document = \SYSTEM\DOCU\docu::getDocuments()[$cat];
foreach($document as $docu){
if(str_replace(array('.',' ','\\','/'), '_', basename($docu)) == $doc){

View File

@ -16,15 +16,15 @@ class sai {
public static function register_start($module){
if(!self::check_module($module)){
throw new \SYSTEM\LOG\ERROR('Problem with your Sysmodule class: '.$module);}
throw new \SYSTEM\LOG\ERROR('Problem with your Sysmodule class: '.$module.'; it might not be available or inherits from the wrong class!');}
self::$module_start = $module;}
public static function register($module){
if(!self::check_module($module)){
throw new \SYSTEM\LOG\ERROR('Problem with your Sysmodule class: '.$module);}
throw new \SYSTEM\LOG\ERROR('Problem with your Sysmodule class: '.$module.'; it might not be available or inherits from the wrong class!');}
array_push(self::$modules,$module);}
public static function register_sys($module){
if(!self::check_module($module)){
throw new \SYSTEM\LOG\ERROR('Problem with your Sysmodule class: '.$module);}
throw new \SYSTEM\LOG\ERROR('Problem with your Sysmodule class: '.$module.'; it might not be available or inherits from the wrong class!');}
array_push(self::$modules_sys,$module);}
public static function getStartModule(){