This commit is contained in:
Ulf Gebhardt 2016-06-08 19:30:35 +02:00
parent 433bbeeb57
commit bb899ba1b2
6 changed files with 164 additions and 13 deletions

View File

@ -1,20 +1,56 @@
<?php
/**
* System - PHP Framework
*
* PHP Version 5.6
*
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/webcraftmedia/system
* @package SYSTEM\LIB
*/
namespace LIB;
/**
* Lib Class provided by System to define API to load libs.
* @todo better abstraction model
*/
abstract class lib {
/**
* Call php lib include
*
* @return bool Returns true or false depending if lib could be loaded.
*/
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();}
/**
* Call css lib include
*
* @return string Returns path of the css lib to be included.
*/
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?
}
return static::css_path();}
/**
* Call js lib include
*
* @return string Returns path of the js lib to be included.
*/
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();
}
return static::js_path();}
/**
* Default Version for every lib if not overritten by derived class
*
* @return string Returns version string of the library.
*/
public static function version(){
return 'The library '.static::get_class().' did not specify a version';}
}

View File

@ -1,7 +1,29 @@
<?php
/**
* System - PHP Framework
*
* PHP Version 5.6
*
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/webcraftmedia/system
* @package SYSTEM\LIB
*/
namespace LIB;
/**
* lib_controll Class provided by System to register libs.
*/
class lib_controll {
/** array Variable to store all registred libs*/
private static $libs = array();
/**
* Check if given class is a valid lib
*
* @param string $lib Lib Class
* @return bool Returns true or false.
*/
private static function check_lib($lib){
if( !\class_exists($lib) ||
!\is_array($parents = \class_parents($lib)) ||
@ -9,12 +31,22 @@ class lib_controll {
return false;}
return true;}
/**
* Register given class as lib
*
* @param string $classname Lib Class
* @return null Returns null.
*/
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);
}
array_push(self::$libs,$classname);}
/**
* Get all registered libs available
*
* @return array Returns array with lib classes.
*/
public static function all(){
return self::$libs;}
}

View File

@ -1,5 +1,25 @@
<?php
/**
* System - PHP Framework
*
* PHP Version 5.6
*
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/webcraftmedia/system
* @package SYSTEM\LIB
*/
namespace LIB;
/**
* css lib Class provided by System to provide css libs.
* @todo better abstraction model
*/
abstract class lib_css extends lib{
protected static function css_path(){} //css webpath
/**
* Get Css lib include path
*
* @return string Returns path of the css lib to be included (webpath).
*/
protected static function css_path(){}
}

View File

@ -1,5 +1,25 @@
<?php
/**
* System - PHP Framework
*
* PHP Version 5.6
*
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/webcraftmedia/system
* @package SYSTEM\LIB
*/
namespace LIB;
/**
* js lib Class provided by System to provide js libs.
* @todo better abstraction model
*/
abstract class lib_js extends lib{
/**
* Get js lib include path
*
* @return string Returns path of the js lib to be included (webpath).
*/
protected static function js_path(){} //js webpath
}

View File

@ -1,6 +1,32 @@
<?php
/**
* System - PHP Framework
*
* PHP Version 5.6
*
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/webcraftmedia/system
* @package SYSTEM\LIB
*/
namespace LIB;
/**
* js+css lib Class provided by System to provide js+css libs.
* @todo better abstraction model
*/
abstract class lib_jscss extends lib{
/**
* Get js lib include path
*
* @return string Returns path of the js lib to be included (webpath).
*/
protected static function js_path(){}
/**
* Get Css lib include path
*
* @return string Returns path of the css lib to be included (webpath).
*/
protected static function css_path(){}
}

View File

@ -1,8 +1,25 @@
<?php
/**
* System - PHP Framework
*
* PHP Version 5.6
*
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/webcraftmedia/system
* @package SYSTEM\LIB
*/
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
}
/**
* php lib Class provided by System to provide php libs.
* @todo better abstraction model
*/
abstract class lib_php extends lib{
/**
* include the php files to be used
*
* @return null Returns null
*/
protected static function php_autoload(){}
}