Version 0.3 beta 04.02.2018

Improved: The Router now accepts actions, either trough the _action as parameter, or on the URL pattern after the controller name Example: http://youdomain/[controllername]/[actionname]/
It is now possible to load as many navigations on the page as wanted by passing the name to the JsonNavigation::getInstance()->loadJsonNavigationArray('[NAME]'); call in the navigationAction of the Controller
Building forms by simple adding the namespace use Nibiru\Factory\Form; and calling Example: Form::addInputTypeText( array( 'name' => 'lastname', 'value' => 'placeholder' ) ); To finalize the form the last call should be something like this: Form::addForm( array('name' => 'testform', 'method' => 'post', 'action' => '/' . Router::getInstance()->currentPage(), 'target' => '_self') );
The Database design has fully been refactored, now it contains an autoloading mechanism which can be triggert by createing a database folder in the application folder, a Example file is in the folder applicatoin/database
The Database access can now be implemented anywhere in your application by adding the namespace to your database accessing Logic: use Nibiru\Factory\Db;
This commit is contained in:
Stephan Kasdorf
2018-02-04 22:16:21 +01:00
parent 16d86ad95e
commit 86433af5bf
39 changed files with 2292 additions and 232 deletions

View File

@@ -36,9 +36,9 @@ Engine Implementation.</div>
<li>soap interface to a given SOAP server</li>
<li>Dwoo tempalte eninge tests</li>
<li>Twig tempalte eninge tests</li>
<li>Improved routing</li>
<li>Database access functionallity for the db.php Factory</li>
</ul>
<h1>Update</h1>
<h1>Previous version</h1>
<p>Version 0.2 beta 19.07.2017</p>
<ul>
<li>Dispatcher update now supports actions within Controllers</li>
@@ -54,6 +54,16 @@ Engine Implementation.</div>
<li>Dwoo tempalte eninge tests</li>
<li>Twig tempalte eninge tests</li>
</ul>
<h1>Update</h1>
<p>Version 0.3 beta 04.02.2018</p>
<ul>
<li>Improved: The Router now accepts actions, either trough the _action as parameter, or on the URL pattern after the controller name Example: http://youdomain/[controllername]/[actionname]/</li>
<li>It is now possible to load as many navigations on the page as wanted by passing the name to the <br>JsonNavigation::getInstance()->loadJsonNavigationArray('[NAME]'); <br>call in the navigationAction of the Controller</li>
<li>Building forms by simple adding the namespace<br> use Nibiru\Factory\Form; <br>and calling Example:<br> Form::addInputTypeText( array( 'name' => 'lastname', 'value' => 'placeholder' ) );<br> To finalize the form the last call should be something like this:<br>Form::addForm( array('name' => 'testform', 'method' => 'post', 'action' => '/' . Router::getInstance()->currentPage(), 'target' => '_self') );</li>
<li>The Database design has fully been refactored, now it contains an autoloading mechanism which can be triggert by createing a database folder in the application folder, a Example file is in the folder applicatoin/database</li>
<li>The Database access can now be implemented anywhere in your application by adding the namespace to your database accessing Logic:<br>use Nibiru\Factory\Db;</li>
</ul>
</div>
<div style="word-spacing: 2px; letter-spacing: 0.1px; font-size: 15px; margin-bottom: 15px;">The start is done, have success with PHP prototyping, and always remember to have fun!</div>

View File

@@ -0,0 +1,40 @@
<?php
namespace Nibiru\Model;
use Nibiru\Adapter\Db;
use Nibiru\Pdo;
/**
* Created by PhpStorm.
* User: kasdorf
* Date: 21.11.17
* Time: 11:22
*/
class Users extends Db
{
const TABLE = array(
'table' => 'user',
'field' => array(
'user_id' => 'user_id',
'user_name' => 'user_name',
'user_pass' => 'user_pass',
'user_active' => 'user_active',
'user_date' => 'user_date'
)
);
public function __construct()
{
self::initTable( self::TABLE );
}
public function selectRowsetById($id = false)
{
$id = array(
self::TABLE['field']['user_id'] => $id
);
return Pdo::fetchRowInArrayById(
self::TABLE['table'], $id
);
}
}

72
core/a/db.php Normal file
View File

@@ -0,0 +1,72 @@
<?php
namespace Nibiru\Adapter;
use Nibiru\IDb;
use Nibiru\Pdo;
/**
* Created by PhpStorm.
* User: Stephan Kadsorf
* Date: 26.01.18
* Time: 17:24
*/
abstract class Db implements IDb
{
private static $table = array();
protected static function initTable( $table = array() )
{
self::setTable( $table );
}
/**
* @return array
*/
protected static function getTable()
{
return self::$table;
}
/**
* @param array $table
*/
private static function setTable( $table = array() )
{
if( sizeof($table)>0 )
{
self::$table = $table;
}
}
public function loadTableAsArray()
{
$result = Pdo::fetchTableAsArray( self::getTable()['table'] );
return $result;
}
public function selectRowsetById($id = false)
{
// TODO: Implement selectRowsetById() method.
}
public function insertRowsetById($rowset = array(), $id = false)
{
// TODO: Implement insertRowsetById() method.
}
public function selectDatasetByMinMax($min = false, $max = false)
{
// TODO: Implement selectDatasetByMinMax() method.
}
public function insertArrayIntoTable($dataset = array())
{
// TODO: Implement insertArrayIntoTable() method.
}
public function nextInsertIndex()
{
// TODO: Implement nextInsertIndex() method.
}
}

69
core/c/autoloader.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace Nibiru\Autoloader;
use Nibiru\Config;
use Nibiru\View;
require_once __DIR__ . '/../i/db.php';
/**
* Created by PhpStorm.
* User: kasdorf
* Date: 10.11.17
* Time: 09:44
*/
class Autoloader
{
const MY_FILE_NAME = "autoloader.php";
const DB_MODEL_FOLDER = "dbmodels";
private static $_filesInFoler = array();
private static $_instance;
protected function __construct()
{
self::_setFilesInFoler();
}
public static function getInstance()
{
$className = get_called_class();
if(self::$_instance==null) self::$_instance = new $className();
return self::$_instance;
}
/**
* @desc includes all database model files in preparation for the
* database factory model
*/
public function runRequireOnce()
{
foreach (self::getFilesInFoler() as $file)
{
require_once $file;
}
}
/**
* @return array
*/
private static function getFilesInFoler()
{
return self::$_filesInFoler;
}
/**
* @param array $filesInFoler
*/
private static function _setFilesInFoler( )
{
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::DB_MODEL_FOLDER] ));
foreach ($iterator as $item)
{
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
{
self::$_filesInFoler[] = $item->getPathName();
}
}
}
}

View File

@@ -22,7 +22,6 @@ class Controller
protected function __construct()
{
$this->_setController();
$this->_setConfig(Config::getInstance()->getConfig());
}
@@ -63,13 +62,9 @@ class Controller
/**
* @param string $controller
*/
private function _setController( )
protected function setController( $controller )
{
if(array_key_exists( IController::CONTROLLER_REQUEST_NAME, $this->getRequest()) )
{
$this->_setNext( $this->getRequest()[IController::CONTROLLER_REQUEST_NAME] );
$this->_controller = $this->getNext();
}
$this->_controller = $controller;
}
/**

View File

@@ -32,7 +32,6 @@ final class Dispatcher
require_once __DIR__ . '/../../application/controller/' . Router::getInstance()->tplName() . 'Controller.php';
$class = "Nibiru\\".\Nibiru\Router::getInstance()->tplName()."Controller";
$controller = new $class();
if(array_key_exists('_action', $_REQUEST))
{
$action = $_REQUEST['_action']."Action";

View File

@@ -1,169 +1,69 @@
<?php
namespace Nibiru;
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: stephan
* Date: 24.01.17
* Time: 15:48
* User: mithril
* Date: 26.01.18
* Time: 20:59
*/
class Form implements IForm
{
use Messages;
/**
* @desc class wide parameters
* @var
*/
protected static $_instance;
private static $fieldset_name;
private static $action;
private static $name;
private static $type;
private static $fields = array();
private static $form = self::TYPE_FORM;
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_METHOD => '',
self::FORM_ACTION => '',
self::FORM_TARGET => ''
);
protected function __construct($action, $name, $type)
{
try {
if($action != "")
{
self::setFormAction($action);
}
if($name != "")
{
self::setFormName($name);
}
if($type != "")
{
self::setFormType($type);
}
} catch (\Exception $e)
{
Debug::getInstance()->toDebug($e->getMessage());
}
}
private $_element;
private static function setCurrentForm($form = self::TYPE_FORM)
public function loadElement( $attributes )
{
if(self::getFieldsetName())
{
self::$form = self::TYPE_FORM_FIELDSET;
}
else
{
self::$form = $form;
}
}
protected static function getCurrentForm()
{
return self::$form;
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* Call this method to get singleton
*
* @return Form
* @return array
*/
public static function getInstance($action, $name, $type)
protected function getAttributes( )
{
static $instance = null;
if ($instance === null)
{
$instance = new Form($action, $name, $type);
}
return $instance;
return $this->_attributes;
}
public static function setFormAction($action)
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
try{
if(is_string($action))
{
self::setCurrentForm(str_replace("{action}", $action, self::getCurrentForm()));
}
else
{
throw new \Exception(Messages::msg_error_string());
}
} catch (\Exception $e)
foreach( $attributes as $key=>$entry )
{
Debug::getInstance()->toDebug($e->getMessage());
}
}
private static function getFormAction()
{
return self::$action;
}
public static function setFormName($name)
{
try{
if(is_string($name))
switch ($key)
{
self::setCurrentForm(str_replace("{name}", $name, self::getCurrentForm()));
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
else
{
throw new \Exception(Messages::msg_error_string());
}
} catch (\Exception $e)
{
Debug::getInstance()->toDebug($e->getMessage());
}
}
/**
* @desc set the form type corresponding to the HTML5 standard
*
* @param $type
* @return mixed
*/
public static function setFormType($type)
protected function getElement( )
{
try{
if(is_string($type))
{
self::setCurrentForm(str_replace("{type}", $type, self::getCurrentForm()));
}
else
{
throw new \Exception(Messages::msg_error_string());
}
} catch (\Exception $e)
{
Debug::getInstance()->toDebug($e->getMessage());
}
return $this->_element;
}
/**
* @return mixed
*/
protected static function getFieldsetName()
{
return self::$fieldset_name;
}
/**
* @param mixed $fieldset_name
*/
private static function setFieldsetName( $fieldset_name )
{
self::$fieldset_name = $fieldset_name;
}
/**
* @desc output the form with all current fields and values
* @param mixed $element
*/
public function displayForm()
private function _setElement( )
{
// TODO: Implement displayForm() method.
$this->_element = '<form action="ACTION" method="METHOD" name="NAME" target="TARGET">' . "\n" . 'FIELDS</form>' . "\n";
}
public function addFieldset($name)
{
self::setFieldsetName($name);
}
}

View File

@@ -19,6 +19,8 @@ class JsonNavigation extends Config
private static $_instance;
private static $_file_content_string = NULL;
private static $_file_content_array = array();
private static $_name = false;
private static $_section_name = self::NAVIGATION;
public static function getInstance()
{
@@ -31,6 +33,38 @@ class JsonNavigation extends Config
return self::$_instance;
}
/**
* @return string
*/
protected static function getSectionName()
{
return self::$_section_name;
}
/**
* @param string $section_name
*/
private static function setSectionName( $section_name )
{
self::$_section_name = $section_name;
}
/**
* @return boolean
*/
protected static function getName()
{
return self::$_name;
}
/**
* @param boolean $name
*/
private static function setName( $name )
{
self::$_name = $name;
}
/**
* @return null
*/
@@ -44,7 +78,7 @@ class JsonNavigation extends Config
*/
private static function setFileContentString( )
{
self::$_file_content_string = file_get_contents( Settings::SETTINGS_PATH . parent::getInstance()->getConfig()["SETTINGS"]["navigation"] );
self::$_file_content_string = file_get_contents( Settings::SETTINGS_PATH . parent::getInstance()->getConfig()["SETTINGS"][self::getSectionName()] );
}
/**
@@ -60,7 +94,7 @@ class JsonNavigation extends Config
*/
private static function setFileContentArray( )
{
self::$_file_content_array = file( Settings::SETTINGS_PATH . parent::getInstance()->getConfig()["SETTINGS"]["navigation"] );
self::$_file_content_array = file( Settings::SETTINGS_PATH . parent::getInstance()->getConfig()["SETTINGS"][self::getSectionName()] );
}
/**
@@ -106,12 +140,22 @@ class JsonNavigation extends Config
* Loads the navigation from a json file into
* the view, making the variables available
*/
public function loadJsonNavigationArray( )
public function loadJsonNavigationArray( $name = false )
{
if( $name )
{
self::$_navigation_array = array();
self::setSectionName( $name );
self::setName( $name );
parent::getInstance();
self::setFileContentString();
self::setFileContentArray();
self::setNavigation();
}
$nav = self::getNavigation();
foreach ( $nav as $item => $value)
{
if($item == self::NAVIGATION)
if($item == self::getSectionName())
{
$keys = array_keys($value);
for($i=0; sizeof($keys)>$i;$i++)
@@ -137,6 +181,13 @@ class JsonNavigation extends Config
}
}
}
View::getInstance()->getEngine()->assignGlobal("navigationJson", self::$_navigation_array);
if( $name )
{
View::getInstance()->getEngine()->assignGlobal(self::getName(), self::$_navigation_array);
}
else
{
View::getInstance()->getEngine()->assignGlobal("navigationJson", self::$_navigation_array);
}
}
}

View File

@@ -35,6 +35,7 @@ final class Pdo extends Mysql implements IPdo
public static function fetchRowInArrayById($tablename = self::PLACE_TABLE_NAME, $id = self::NO_ID )
{
$result = array();
$statement = parent::getInstance()->getConn();
$describe = $statement->query('DESC ' . $tablename);
$describe->execute();
@@ -48,7 +49,8 @@ final class Pdo extends Mysql implements IPdo
}
$prepare = $statement->prepare("SELECT * FROM " . $tablename . " WHERE " . $id_name . " = :" . $id_name . ";");
$prepare->execute($id);
$rowset = array_shift($prepare->fetchAll());
$fetchAll = $prepare->fetchAll();
$rowset = array_shift($fetchAll);
foreach(array_keys($rowset) as $entry)
{

View File

@@ -16,6 +16,7 @@ class Router extends Config
private static $_instance;
private static $_cur_page;
private static $_routes = array();
private static $_action;
protected function __construct()
{
@@ -33,8 +34,9 @@ class Router extends Config
private static function loadRouting()
{
Config::setConfig(Config::getInstance()->getEnv());
self::$_routing = Config::getInstance()->getConfig()[View::ATM_ROUTING];
self::$_routing = Config::getInstance()->getConfig()[View::NIBIRU_ROUTING];
self::setRoutes(self::$_routing);
self::setCurRoute();
}
/**
@@ -48,11 +50,15 @@ class Router extends Config
/**
* @param mixed $cur_route
*/
private static function _setCurRoute( )
private static function setCurRoute( )
{
if( Controller::getInstance()->getController() != IController::START_CONTROLLER_NAME )
if( self::getCurPage() != IController::START_CONTROLLER_NAME )
{
self::$_cur_route = Controller::getInstance()->getController();
self::$_cur_route = self::getCurPage();
if(self::getAction())
{
self::$_cur_route .= '/' . self::getAction() . '/';
}
}
else
{
@@ -76,7 +82,21 @@ class Router extends Config
self::$_routes = $routes;
}
/**
* @return mixed
*/
protected static function getAction()
{
return self::$_action;
}
/**
* @param mixed $action
*/
private static function setAction( $action )
{
$_REQUEST['_action'] = $action;
}
public function route()
{
@@ -118,7 +138,6 @@ class Router extends Config
*/
private static function setCurPage( )
{
self::_setCurRoute();
if( self::getCurRoute() == null )
{
$uri_parts = explode('/', $_SERVER["REQUEST_URI"]);
@@ -131,6 +150,10 @@ class Router extends Config
else
{
self::$_cur_page = $uri_parts[1];
if(array_key_exists(2, $uri_parts))
{
self::setAction($uri_parts[2]);
}
}
}
}
@@ -138,7 +161,6 @@ class Router extends Config
{
self::$_cur_page = self::getCurRoute();
}
}
/**

View File

@@ -80,7 +80,7 @@ class Settings
}
else
{
self::$_config = parse_ini_file('../' . self::SETTINGS_PATH . $current_settings_file, View::ATM_SETTINGS);
self::$_config = parse_ini_file('../' . self::SETTINGS_PATH . $current_settings_file, View::NIBIRU_SETTINGS);
}
}
}

71
core/c/typecheckbox.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeCheckbox implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* TODO: Impplement the linebreak optional
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="checkbox" name="NAME" value="VALUE">' . 'VALUE<br>' . "\n";
}
}

69
core/c/typecolor.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeColor implements IForm
{
private $_attributes = array(
self::FORM_VALUE => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="color" name="NAME" value="VALUE">' . "\n";
}
}

70
core/c/typedate.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeDate implements IForm
{
private $_attributes = array(
self::FORM_VALUE => '',
self::FORM_NAME => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="date" name="NAME" value="VALUE">' . "\n";
}
}

70
core/c/typedatetime.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeDatetime implements IForm
{
private $_attributes = array(
self::FORM_VALUE => '',
self::FORM_NAME => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="datetime-local" name="NAME" value="VALUE">' . "\n";
}
}

69
core/c/typeemail.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeEmail implements IForm
{
private $_attributes = array(
self::FORM_NAME => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="email" name="NAME">' . "\n";
}
}

70
core/c/typefileupload.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: Stephan Kasdorf
* Date: 26.01.18
* Time: 21:42
*/
class TypeFileUpload implements IForm
{
private $_attributes = array(
self::FORM_NAME => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="file" name="NAME">' . "\n";
}
}

71
core/c/typehidden.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeHidden implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="hidden" value="VALUE" name="NAME">' . "\n";
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeImageSubmit implements IForm
{
private $_attributes = array(
self::FORM_ATTRIBUTE_SRC => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="image" src="SRC">' . "\n";
}
}

70
core/c/typenumber.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeNumber implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="number" name="NAME" value="VALUE">' . "\n";
}
}

69
core/c/typeoption.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeOption implements IForm
{
private $_attributes = array(
self::FORM_VALUE => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<option value="VALUE">VALUE</option>' . "\n";
}
}

69
core/c/typepassword.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypePassword implements IForm
{
private $_attributes = array(
self::FORM_NAME => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="password" name="NAME">' . "\n";
}
}

71
core/c/typeradio.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeRadio implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* TODO: Impplement the linebreak optional
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="radio" name="NAME" value="VALUE">' . 'VALUE<br>' . "\n";
}
}

70
core/c/typerange.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeRange implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="range" name="NAME" value="VALUE">' . "\n";
}
}

69
core/c/typereset.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeReset implements IForm
{
private $_attributes = array(
self::FORM_VALUE => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="reset" value="VALUE">' . "\n";
}
}

69
core/c/typesearch.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeSearch implements IForm
{
private $_attributes = array(
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="search">' . "\n";
}
}

69
core/c/typeselect.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeSelect implements IForm
{
private $_attributes = array(
self::FORM_NAME => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<select name="NAME">' . "\n" . 'OPTIONS' . "\n" . '</select>' . "\n";
}
}

69
core/c/typesubmit.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeSubmit implements IForm
{
private $_attributes = array(
self::FORM_VALUE => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="submit" value="VALUE">' . "\n";
}
}

70
core/c/typetelefon.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: Stephan Kasdorf
* Date: 26.01.18
* Time: 21:42
*/
class TypeTelefon implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="tel" name="NAME" value="VALUE">' . "\n";
}
}

79
core/c/typetext.php Normal file
View File

@@ -0,0 +1,79 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeText implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_SPEECH => ''
);
private $_element;
public function loadElement( $attributes )
{
if(!array_key_exists('speech', $attributes))
{
$attributes['speech'] = '';
}
else
{
$attributes['speech'] = ' x-webkit-speech';
}
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="text" name="NAME" value="VALUE"SPEECH>' . "\n";
}
}

72
core/c/typetextarea.php Normal file
View File

@@ -0,0 +1,72 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeTextarea implements IForm
{
private $_attributes = array(
self::FORM_ATTRIBUTE_COLS => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_ROWS => '',
self::FORM_NAME => ''
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<textarea name="NAME" rows="ROWS" cols="COLS">' . "\n" . "VALUE" . "\n" . '</textarea>' . "\n";
}
}

69
core/c/typeurl.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 21:42
*/
class TypeUrl implements IForm
{
private $_attributes = array(
);
private $_element;
public function loadElement( $attributes )
{
$this->_setElement();
$this->_setAttributes( $attributes );
return $this->getElement();
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
private function _setAttributes( $attributes )
{
foreach( $attributes as $key=>$entry )
{
switch ($key)
{
case array_key_exists($key, $this->_attributes):
$this->_element = str_replace(strtoupper($key), $entry, $this->getElement());
break;
}
}
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<input type="url">' . "\n";
}
}

View File

@@ -12,9 +12,10 @@ class View extends Controller implements IView
{
private static $_instance;
const ATM_SETTINGS = "SETTINGS";
const ATM_ROUTING = "ROUTING";
const ATM_FILE_END = ".tpl";
const NIBIRU_SETTINGS = "SETTINGS";
const NIBIRU_SECURITY = "SECURITY";
const NIBIRU_ROUTING = "ROUTING";
const NIBIRU_FILE_END = ".tpl";
private static $smarty = array();
private static $engine = array();
@@ -99,10 +100,10 @@ class View extends Controller implements IView
public function display( $page )
{
preg_match_all("/".self::ATM_FILE_END."/", $page, $matches);
if(!array_key_exists(self::ATM_FILE_END, array_flip(array_shift($matches))))
preg_match_all("/".self::NIBIRU_FILE_END."/", $page, $matches);
if(!array_key_exists(self::NIBIRU_FILE_END, array_flip(array_shift($matches))))
{
$page = str_replace("/", "", $page) . self::ATM_FILE_END;
$page = str_replace("/", "", $page) . self::NIBIRU_FILE_END;
}
Controller::getInstance()->action( $this->getEngine(), $page );
}

57
core/f/db.php Normal file
View File

@@ -0,0 +1,57 @@
<?php
namespace Nibiru\Factory;
use Nibiru\Autoloader\Autoloader;
require_once __DIR__ . '/../c/autoloader.php';
/**
* Created by PhpStorm.
* User: kasdorf
* Date: 10.11.17
* Time: 09:24
*/
class Db
{
protected static $_model = null;
/**
* @desc loads the database model through the correct Factory,
* all database functionallity has to be run trough this
* factory
* @param string $modelName
* @return null
* @throws \Exception
*/
public static function loadModel( $modelName = "")
{
try {
if( $modelName != "" )
{
Autoloader::getInstance()->runRequireOnce();
self::_setModel( $modelName );
return self::getModel();
}
} catch(\Exception $e)
{
throw new \Exception( $e->getMessage() );
}
}
/**
* @return null
*/
protected static function getModel()
{
return self::$_model;
}
/**
* @param null $model
*/
private static function _setModel( $model )
{
$fmodel = "\\Nibiru\\Model\\".$model;
self::$_model = new $fmodel;
}
}

317
core/f/form.php Normal file
View File

@@ -0,0 +1,317 @@
<?php
namespace Nibiru\Factory;
use Nibiru\Form\TypeCheckbox;
use Nibiru\Form\TypeColor;
use Nibiru\Form\TypeDatetime;
use Nibiru\Form\TypeEmail;
use Nibiru\Form\TypeFileUpload;
use Nibiru\Form\TypeHidden;
use Nibiru\Form\TypeImageSubmit;
use Nibiru\Form\TypeNumber;
use Nibiru\Form\TypeOption;
use Nibiru\Form\TypePassword;
use Nibiru\Form\TypeRadio;
use Nibiru\Form\TypeRange;
use Nibiru\Form\TypeReset;
use Nibiru\Form\TypeSearch;
use Nibiru\Form\TypeSelect;
use Nibiru\Form\TypeSubmit;
use Nibiru\Form\TypeTelefon;
use Nibiru\Form\TypeTextarea;
use Nibiru\Form\TypeText;
use Nibiru\Form\TypeDate;
use Nibiru\Form\TypeUrl;
/**
* Created by PhpStorm.
* User: mithril
* Date: 26.01.18
* Time: 20:57
*/
class Form
{
private static $element;
private static $form;
private static $option;
/**
* @desc is used internaly for assambly only
* @param $option
*/
private static function assambleOptions( $option )
{
self::$option .= $option;
}
/**
* @desc is used internally for assambly only
* @param $select
* @return mixed
*/
private static function displaySelect( $select )
{
return str_replace( 'OPTIONS', self::$option, $select );
}
/**
* @desc is used internally for assambly only
* @param $element
*/
private static function assamble( $element )
{
self::$form .= $element;
}
/**
* @desc replaces the final form fields into the form tags
* @param $form
* @return mixed
*/
private static function display( $form )
{
return str_replace( 'FIELDS', self::$form, $form );
}
/**
* @return mixed
*/
protected static function getElement()
{
return self::$element;
}
/**
* @param mixed $element
*/
private static function setElement( $element )
{
self::$element = $element;
}
/**
* @desc adds the form tags around the form has to be called in the end, after adding all fields
* @param $attributes
* @return mixed
*/
public static function addForm( $attributes )
{
self::setElement( new \Nibiru\Form\Form() );
return self::display( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds an input type Textfield
* @param $attributes
*/
public static function addInputTypeText( $attributes )
{
self::setElement( new TypeText() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds an input type Submit
* @param $attributes
*/
public static function addInputTypeSubmit( $attributes )
{
self::setElement( new TypeSubmit() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds an input textarea field with the size of the column and the rows
* @param $attributes
*/
public static function addInputTypeTextarea( $attributes )
{
self::setElement( new TypeTextarea() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds an input type of a radio button, should be a selection of
* more then one
* @param $attributes
*/
public static function addInputTypeRadio( $attributes )
{
self::setElement( new TypeRadio() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds an input type of a Checkbox button, should be a tick more of one
* @param $attributes
*/
public static function addInputTypeCheckbox( $attributes )
{
self::setElement( new TypeCheckbox() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a input field for password entry
* @param $attributes
*/
public static function addInputTypePassword( $attributes )
{
self::setElement( new TypePassword() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a calendar field with the given date value
* @param $attributes
*/
public static function addInputTypeDate( $attributes )
{
self::setElement( new TypeDate() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a field for entering the email address
* @param $attributes
*/
public static function addInputTypeEmail( $attributes )
{
self::setElement( new TypeEmail() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a field for entering a color-picker field
* @param $attributes
*/
public static function addInputTypeColor( $attributes )
{
self::setElement( new TypeColor() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a field for entering a date and time field
* @param $attributes
*/
public static function addInputTypeDatetime( $attributes )
{
self::setElement( new TypeDatetime() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a file upload field to the form
* @param $attributes
*/
public static function addTypeFileUpload( $attributes )
{
self::setElement( new TypeFileUpload() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a hidden field to the form
* @param $attributes
*/
public static function addTypeHidden( $attributes )
{
self::setElement( new TypeHidden() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds an image as the submit button to the form
* @param $attrbutes
*/
public static function addTypeImageSubmit( $attrbutes )
{
self::setElement( new TypeImageSubmit() );
self::assamble( self::getElement()->loadElement( $attrbutes ) );
}
/**
* @desc adds a field for entering a number
* @param $attributes
*/
public static function addTypeNumber( $attributes )
{
self::setElement( new TypeNumber() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a control for entering a number whose exact value is not important (like a slider control).
* Default range is from 0 to 100, to the form
* @param $attributes
*/
public static function addTypeRange( $attributes )
{
self::setElement( new TypeRange() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a reset button (resets all form values to default values), to the form
* @param $attributes
*/
public static function addTypeReset( $attributes )
{
self::setElement( new TypeReset() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a text field for entering a search string to the form
* @param $attributes
*/
public static function addTypeSearch( $attributes )
{
self::setElement( new TypeSearch() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a field for entering a telefon number
* @param $attributes
*/
public static function addTypeTelefon( $attributes )
{
self::setElement( new TypeTelefon() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a field for entering a URL to the form
* @param $attributes
*/
public static function addTypeUrl( $attributes )
{
self::setElement( new TypeUrl() );
self::assamble( self::getElement()->loadElement( $attributes ) );
}
/**
* @desc adds a select area to the form, should be added to the form after
* an option field has been added
* @param $attributes
*/
public static function addSelect( $attributes )
{
self::setElement( new TypeSelect() );
self::assamble( self::displaySelect( self::getElement()->loadElement( $attributes ) ) );
}
/**
* @desc adds an option field to the form, should be used upfront to the select field
* @param $attributes
*/
public static function addSelectOption( $attributes )
{
self::setElement( new TypeOption() );
self::assambleOptions( self::getElement()->loadElement( $attributes ) );
}
}

View File

@@ -17,17 +17,9 @@ require_once __DIR__ . '/c/config.php';
require_once __DIR__ . '/c/router.php';
require_once __DIR__ . '/i/engine.php';
require_once __DIR__ . '/c/engine.php';
require_once __DIR__ . '/i/form.php';
require_once __DIR__ . '/c/form.php';
require_once __DIR__ . '/i/input.php';
require_once __DIR__ . '/c/input.php';
require_once __DIR__ . '/i/formfromtable.php';
require_once __DIR__ . '/c/formfromtable.php';
require_once __DIR__ . '/i/controller.php';
require_once __DIR__ . '/c/controller.php';
require_once __DIR__ . '/i/view.php';
require_once __DIR__ . '/c/view.php';
require_once __DIR__ . '/c/json-navigation.php';
/**
* @desc Database connectivity
*/
require_once __DIR__ . '/i/mysql.php';
require_once __DIR__ . '/c/mysql.php';
require_once __DIR__ . '/i/pdo.php';
@@ -36,6 +28,42 @@ require_once __DIR__ . '/i/odbc.php';
require_once __DIR__ . '/c/odbc.php';
require_once __DIR__ . '/i/postgres.php';
require_once __DIR__ . '/c/postgres.php';
require_once __DIR__ . '/i/db.php';
require_once __DIR__ . '/a/db.php';
require_once __DIR__ . '/f/db.php';
/**
* @desc MVC functionality
*/
require_once __DIR__ . '/i/form.php';
require_once __DIR__ . '/f/form.php';
require_once __DIR__ . '/c/form.php';
require_once __DIR__ . '/c/typetext.php';
require_once __DIR__ . '/c/typepassword.php';
require_once __DIR__ . '/c/typeemail.php';
require_once __DIR__ . '/c/typesubmit.php';
require_once __DIR__ . '/c/typetextarea.php';
require_once __DIR__ . '/c/typeradio.php';
require_once __DIR__ . '/c/typedate.php';
require_once __DIR__ . '/c/typedatetime.php';
require_once __DIR__ . '/c/typetelefon.php';
require_once __DIR__ . '/c/typesearch.php';
require_once __DIR__ . '/c/typehidden.php';
require_once __DIR__ . '/c/typeimagesubmit.php';
require_once __DIR__ . '/c/typenumber.php';
require_once __DIR__ . '/c/typereset.php';
require_once __DIR__ . '/c/typefileupload.php';
require_once __DIR__ . '/c/typecheckbox.php';
require_once __DIR__ . '/c/typecolor.php';
require_once __DIR__ . '/c/typeoption.php';
require_once __DIR__ . '/c/typeselect.php';
require_once __DIR__ . '/c/typerange.php';
require_once __DIR__ . '/c/typeurl.php';
require_once __DIR__ . '/i/controller.php';
require_once __DIR__ . '/c/controller.php';
require_once __DIR__ . '/i/view.php';
require_once __DIR__ . '/c/view.php';
require_once __DIR__ . '/c/json-navigation.php';
/**
* @desc currently unfinished

View File

@@ -10,12 +10,7 @@ namespace Nibiru;
*/
interface IController
{
/**
* @desc start name for the current Controller
* request search value for the Controller
*/
const START_CONTROLLER_NAME = "index";
const CONTROLLER_REQUEST_NAME = "controller";
/**
* This should be part of any extended controller
@@ -31,23 +26,4 @@ interface IController
public function navigationAction();
/**
* Here you can add any form data for handling in your
* controller
*
* @param bool $action
* @param string $name
* @param string $type
* @param bool $labeled
* @param array $data
*
* @return array
*/
public function formAction( $action = false, $name = <<<NAME
NAME
, $type = <<<METHOD
METHOD
, $labeled = false , $data = array()
);
}

52
core/i/db.php Normal file
View File

@@ -0,0 +1,52 @@
<?php
namespace Nibiru;
/**
* Created by PhpStorm.
* User: kasdorf
* Date: 10.11.17
* Time: 09:06
*/
interface IDb
{
/**
* @desc Has to select a given Rowset by the index ID of the table
* @param bool $id
* @return mixed
*/
public function selectRowsetById( $id = false );
/**
* @desc inserts a rowset into the table, by the given nextInsertIndex return
* value for the table
* @param bool $id
* @return mixed
*/
public function insertRowsetById( $rowset = array(), $id = false );
/**
* @desc in order to have a page navigation a dataset should also be selectable
* by a min and max value, result limitation
* @param bool $min
* @param bool $max
* @return mixed
*/
public function selectDatasetByMinMax( $min = false, $max = false );
/**
* @desc insert a given array by a format into the table of the database
* @param array $dataset
* @return mixed
*/
public function insertArrayIntoTable( $dataset = array() );
/**
* @desc beacause there is no autoindex this has to be part of every database model
* class, so the next index is always correctly set
* @return mixed
*/
public function nextInsertIndex();
}

View File

@@ -1,44 +1,38 @@
<?php
namespace Nibiru;
namespace Nibiru\Form;
/**
* Created by PhpStorm.
* User: stephan
* Date: 24.01.17
* Time: 10:20
* User: mithril
* Date: 26.01.18
* Time: 20:59
*/
interface IForm
{
/**
* @desc Basic Form template
*/
const TYPE_FORM = "<form action=\"{action}\" method=\"{type}\" name=\"{name}\">" . "\n" . "{fields}" . "\n" . "<input type='submit' value='speichern'>\t\t" . "</form>" . "\n";
const TYPE_FORM_FIELDSET = "<form action=\"{action}\" method=\"{type}\" name=\"{name}\">"."\n"."<fieldset><label>{flname}</label>" . "\n" . "{fields}" . "\n" . "<input type='submit' value='speichern'>" . "\t\t" . "</fieldset>"."\n"."</form>" . "\n";
/**
* @desc add the form action in order to set the path
* for the controller
* @param $action
* @desc Constant Form attributes
*/
const FORM_NAME = 'name';
const FORM_VALUE = 'value';
const FORM_METHOD = 'method';
const FORM_METHOD_TYPE = array('post', 'get');
const FORM_ACTION = 'action';
const FORM_TARGET = 'target';
const FORM_TARGET_TYPE = array('_blank', '_self', '_parent', '_top');
const FORM_TYPE_TEXT = 'text';
const FORM_TYPE_SUBMIT = 'submit';
const FORM_TYPE_BUTTON = 'button';
const FORM_ATTRIBUTE_ROWS = 'rows';
const FORM_ATTRIBUTE_COLS = 'cols';
const FORM_ATTRIBUTE_SPEECH = 'speech';
const FORM_ATTRIBUTE_SRC = 'src';
const FORM_ATTRIBUTE_ALT = 'alt';
const FORM_ATTRIBUTE_ID = 'id';
/**
* @desc loads the current Form element to the form
* @param $element
* @return mixed
*/
public static function setFormAction($action);
/**
* @desc set the form type, two types (post, get)
* @param $type
* @return mixed
*/
public static function setFormType($type);
/**
* @desc set the name for the form
* @param $name
* @return mixed
*/
public static function setFormName($name);
/**
* @desc display the form data on the html layout
* @return mixed
*/
public function displayForm();
public function loadElement( $attributes );
}