#3 docu lib
This commit is contained in:
parent
433bbeeb57
commit
bb899ba1b2
44
lib/lib.php
44
lib/lib.php
@ -1,20 +1,56 @@
|
|||||||
<?php
|
<?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;
|
namespace LIB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lib Class provided by System to define API to load libs.
|
||||||
|
* @todo better abstraction model
|
||||||
|
*/
|
||||||
abstract class lib {
|
abstract class lib {
|
||||||
|
/**
|
||||||
|
* Call php lib include
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending if lib could be loaded.
|
||||||
|
*/
|
||||||
public static function php(){
|
public static function php(){
|
||||||
if(!\method_exists(static::get_class(), 'php_autoload')){
|
if(!\method_exists(static::get_class(), 'php_autoload')){
|
||||||
throw new \SYSTEM\LOG\ERROR('Function php_autoload not implemented in '.static::get_class());}
|
throw new \SYSTEM\LOG\ERROR('Function php_autoload not implemented in '.static::get_class());}
|
||||||
return static::php_autoload();}
|
return static::php_autoload();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call css lib include
|
||||||
|
*
|
||||||
|
* @return string Returns path of the css lib to be included.
|
||||||
|
*/
|
||||||
public static function css(){
|
public static function css(){
|
||||||
if(!\method_exists(static::get_class(), 'css_path')){
|
if(!\method_exists(static::get_class(), 'css_path')){
|
||||||
throw new \SYSTEM\LOG\ERROR('Function css_path not implemented in '.static::get_class());}
|
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(){
|
public static function js(){
|
||||||
if(!\method_exists(static::get_class(), 'js_path')){
|
if(!\method_exists(static::get_class(), 'js_path')){
|
||||||
throw new \SYSTEM\LOG\ERROR('Function js_path not implemented in '.static::get_class());}
|
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(){
|
public static function version(){
|
||||||
return 'The library '.static::get_class().' did not specify a version';}
|
return 'The library '.static::get_class().' did not specify a version';}
|
||||||
}
|
}
|
||||||
@ -1,20 +1,52 @@
|
|||||||
<?php
|
<?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;
|
namespace LIB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lib_controll Class provided by System to register libs.
|
||||||
|
*/
|
||||||
class lib_controll {
|
class lib_controll {
|
||||||
|
/** array Variable to store all registred libs*/
|
||||||
private static $libs = array();
|
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){
|
private static function check_lib($lib){
|
||||||
if( !\class_exists($lib) ||
|
if( !\class_exists($lib) ||
|
||||||
!\is_array($parents = \class_parents($lib)) ||
|
!\is_array($parents = \class_parents($lib)) ||
|
||||||
!\array_search('LIB\lib', $parents)){
|
!\array_search('LIB\lib', $parents)){
|
||||||
return false;}
|
return false;}
|
||||||
return true;}
|
return true;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register given class as lib
|
||||||
|
*
|
||||||
|
* @param string $classname Lib Class
|
||||||
|
* @return null Returns null.
|
||||||
|
*/
|
||||||
public static function register($classname){
|
public static function register($classname){
|
||||||
if(!self::check_lib($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!');}
|
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(){
|
public static function all(){
|
||||||
return self::$libs;}
|
return self::$libs;}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,25 @@
|
|||||||
<?php
|
<?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;
|
namespace LIB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* css lib Class provided by System to provide css libs.
|
||||||
|
* @todo better abstraction model
|
||||||
|
*/
|
||||||
abstract class lib_css extends lib{
|
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(){}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,25 @@
|
|||||||
<?php
|
<?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;
|
namespace LIB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* js lib Class provided by System to provide js libs.
|
||||||
|
* @todo better abstraction model
|
||||||
|
*/
|
||||||
abstract class lib_js extends lib{
|
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
|
protected static function js_path(){} //js webpath
|
||||||
}
|
}
|
||||||
@ -1,6 +1,32 @@
|
|||||||
<?php
|
<?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;
|
namespace LIB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* js+css lib Class provided by System to provide js+css libs.
|
||||||
|
* @todo better abstraction model
|
||||||
|
*/
|
||||||
abstract class lib_jscss extends lib{
|
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(){}
|
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(){}
|
protected static function css_path(){}
|
||||||
}
|
}
|
||||||
@ -1,8 +1,25 @@
|
|||||||
<?php
|
<?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;
|
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(){}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user