Version 0.3.5 beta

This commit is contained in:
Stephan Kasdorf
2018-03-14 16:37:09 +01:00
parent f7f7550833
commit c9f29ce086
152 changed files with 14954 additions and 1124 deletions

View File

@@ -33,16 +33,25 @@ class Auth extends Controller implements IAuth
return self::$_instance;
}
public function auth( $username, $password )
public function auth( $login, $password )
{
// TODO: Implement auth($username, $password) method.
$this->_setPassword($password);
$this->_setUsername($username);
$this->_setUsername($login);
echo "<pre>";
print_r(pdo::query("SELECT DES_DECRYPT(user_pass, '".Config::getInstance()->getConfig()["SECURITY"]["password_hash"]."') FROM user;"));
echo "</pre>";
die();
if(!array_key_exists('auth', $_SESSION))
{
$user_password = Pdo::query("SELECT DES_DECRYPT(user_pass, '".Config::getInstance()->getConfig()["SECURITY"]["password_hash"]."') AS pass FROM user WHERE user_login = '".$login."';");
if( $user_password["pass"] == $password )
{
$_SESSION['auth']['login'] = $login;
return true;
}
else
{
return false;
}
}
}
/**

View File

@@ -13,7 +13,8 @@ require_once __DIR__ . '/../i/db.php';
class Autoloader
{
const MY_FILE_NAME = "autoloader.php";
const DB_MODEL_FOLDER = "dbmodels";
const DB_MODEL_FOLDER = "dbmodel";
const MODUL_FOLDER = "modul";
private static $_filesInFoler = array();
private static $_instance;

View File

@@ -7,7 +7,8 @@
*/
namespace Nibiru;
use Nibiru\Autoloader\Autoloader;
require_once __DIR__ . '/../c/autoloader.php';
final class Dispatcher
{
@@ -29,6 +30,7 @@ final class Dispatcher
{
Router::getInstance();
Router::getInstance()->route();
Autoloader::getInstance()->runRequireOnce();
require_once __DIR__ . '/../../application/controller/' . Router::getInstance()->tplName() . 'Controller.php';
$class = "Nibiru\\".\Nibiru\Router::getInstance()->tplName()."Controller";
$controller = new $class();

View File

@@ -8,62 +8,31 @@ use Nibiru\Adapter;
* Time: 20:59
*/
class Form implements IForm
class Form extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_METHOD => '',
self::FORM_ACTION => '',
self::FORM_TARGET => ''
self::FORM_NAME => '',
self::FORM_METHOD => '',
self::FORM_ACTION => '',
self::FORM_TARGET => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct($this->_attributes);
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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 = '<form action="ACTION" method="METHOD" name="NAME" target="TARGET">' . "\n" . 'FIELDS</form>' . "\n";
$this->_element = '<form action="ACTION" method="METHOD" name="NAME" target="TARGET" ID CLASS>' . "\n" . 'FIELDS</form>' . "\n";
}
}

77
core/c/formattributes.php Executable file
View File

@@ -0,0 +1,77 @@
<?php
namespace Nibiru\Form;
/**
* Created by PhpStorm.
* User: mithril
* Date: 07.02.18
* Time: 21:57
*/
class FormAttributes
{
private $_attributes = array();
protected $_element;
use \Nibiru\Attributes\Form;
public function __construct( $attributes = false )
{
if($attributes)
{
try {
if( is_array( $attributes ) )
{
$this->_attributes = $attributes;
}
else
{
throw new \Exception( self::errorMessage( str_replace('.php', '', basename( __FILE__ )), __LINE__ ) );
}
} catch (\Exception $e)
{
self::exceptionMessage( $e );
}
}
}
/**
* @return array
*/
protected function getAttributes( )
{
return $this->_attributes;
}
/**
* @param array $attributes
*/
protected 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;
}
}
$this->_element = str_replace(' ID', '', $this->_element);
$this->_element = str_replace(' CLASS', '', $this->_element);
$this->_element = str_replace(' SPEECH', '', $this->_element);
$this->_element = str_replace(' FORM', '', $this->_element);
$this->_element = str_replace(' placeholder="PLACEHOLDER"', '', $this->_element);
$this->_element = str_replace(' required="REQUIRED"', '', $this->_element);
$this->_element = str_replace(' value="VALUE"', '', $this->_element);
$this->_element = str_replace(' ', ' ', $this->_element);
$this->_element = str_replace(' type="TYPE"', '', $this->_element);
}
/**
* @return mixed
*/
protected function getElement( )
{
return $this->_element;
}
}

View File

@@ -33,6 +33,20 @@ final class Pdo extends Mysql implements IPdo
return $result;
}
public static function updateColumnByFieldWhere( $tablename = self::PLACE_TABLE_NAME,
$column_name = IMysql::PLACE_COLUMN_NAME,
$parameter_name = IMysql::PLACE_SEARCH_TERM,
$field_name = IMysql::PLACE_FIELD_NAME,
$where_value = IMysql::PLACE_WHERE_VALUE )
{
$statement = parent::getInstance()->getConn();
$query = "UPDATE " . $tablename . " SET " . $column_name . " = :" . $column_name . " WHERE " . $field_name . " = :". $field_name;
$insert = $statement->prepare($query);
$insert->bindParam( ':'.$column_name, $parameter_name );
$insert->bindParam( ':'.$field_name, $where_value );
$insert->execute();
}
public static function fetchRowInArrayById($tablename = self::PLACE_TABLE_NAME, $id = self::NO_ID )
{
$result = array();
@@ -62,15 +76,23 @@ final class Pdo extends Mysql implements IPdo
return $result;
}
/**
* @desc selects the given table row by given parameter and column
* @param string $tablename
* @param string $column_name
* @param string $parameter_name
* @return mixed
*/
public static function fetchRowInArrayByWhere($tablename = IMysql::PLACE_TABLE_NAME,
$column_name = IMysql::PLACE_COLUMN_NAME,
$parameter_name = IMysql::PLACE_SEARCH_TERM)
{
$statement = parent::getInstance()->getConn();
$prepare = $statement->prepare("SELECT * FROM " . $tablename . " WHERE " . $column_name . " = :" . $parameter_name . ";");
$prepare = $statement->prepare("SELECT * FROM " . $tablename . " WHERE " . $column_name . " = :" . $column_name . ";");
$prepare->bindParam(":".$column_name, $parameter_name, \PDO::PARAM_STR);
$prepare->execute();
$rowset = array_shift($prepare->fetchAll());
$r = $prepare->fetchAll();
$rowset = array_shift( $r );
foreach(array_keys($rowset) as $entry)
{
if(is_string($entry))
@@ -94,6 +116,13 @@ final class Pdo extends Mysql implements IPdo
return $result;
}
/**
* @desc will insert the array with fieldnames into the database, if the last parameter is set it should be a string containing the
* fieldname that should be encrypted
* @param string $tablename
* @param string $array_name
* @param bool $encrypted
*/
public static function insertArrayIntoTable( $tablename = IMysql::PLACE_TABLE_NAME, $array_name = IMysql::PLACE_ARRAY_NAME, $encrypted = IMysql::PLACE_DES_ENCRYPT )
{
$statement = parent::getInstance()->getConn();
@@ -125,15 +154,33 @@ final class Pdo extends Mysql implements IPdo
{
if( ++$i === $numItems )
{
$row .= ":" . $field ;
if($field == $encrypted)
{
$row .= "DES_ENCRYPT(:".$encrypted.", :key)";
}
else
{
$row .= ":" . $field ;
}
}
else
{
$row .= ":" . $field . ", ";
if($field == $encrypted)
{
$row .= "DES_ENCRYPT(:".$encrypted.", :key), ";
}
else
{
$row .= ":" . $field . ", ";
}
}
}
$row .= " )";
$query = $statement->prepare('INSERT INTO ' . $tablename . $row);
if($encrypted)
{
$array_name['key'] = Config::getInstance()->getConfig()[View::NIBIRU_SECURITY]["password_hash"];
}
$query->execute( $entry );
}
}
@@ -160,15 +207,33 @@ final class Pdo extends Mysql implements IPdo
{
if( ++$i === $numItems )
{
$row .= ":" . $field ;
if($field == $encrypted)
{
$row .= "DES_ENCRYPT(:".$encrypted.", :key)";
}
else
{
$row .= ":" . $field ;
}
}
else
{
$row .= ":" . $field . ", ";
if($field == $encrypted)
{
$row .= "DES_ENCRYPT(:".$encrypted.", :key), ";
}
else
{
$row .= ":" . $field . ", ";
}
}
}
$row .= " )";
$query = $statement->prepare('INSERT INTO ' . $tablename . $row);
if($encrypted)
{
$array_name['key'] = Config::getInstance()->getConfig()[View::NIBIRU_SECURITY]["password_hash"];
}
$query->execute( $array_name );
}

View File

@@ -17,9 +17,9 @@ class Settings
private static $_instance;
private static $_is_db_connection = false;
protected function __construct()
protected function __construct( )
{
//Constructor
}
public static function getInstance()

38
core/c/typebutton.php Executable file
View File

@@ -0,0 +1,38 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: Stephan Kasdorf
* Date: 12.02.18
* Time: 19:58
*/
class TypeButton extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_NAME => '',
self::FORM_ATTRIBUTE_TYPE => ''
);
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( self::loadAttributeValues( $attributes ) );
return $this->getElement();
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<button type="TYPE" value="VALUE" ID CLASS>NAME' . "</button>\n";
}
}

View File

@@ -9,61 +9,30 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeCheckbox implements IForm
class TypeCheckbox extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => ''
self::FORM_NAME => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="checkbox" name="NAME" value="VALUE" ID CLASS>' . 'VALUE<br>' . "\n";
}

View File

@@ -9,59 +9,29 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeColor implements IForm
class TypeColor extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_VALUE => ''
self::FORM_VALUE => '',
self::FORM_NAME => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="color" name="NAME" value="VALUE" ID CLASS>' . "\n";
}

View File

@@ -9,62 +9,29 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeDate implements IForm
class TypeDate extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_VALUE => '',
self::FORM_NAME => ''
self::FORM_VALUE => '',
self::FORM_NAME => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="date" name="NAME" value="VALUE" ID CLASS>' . "\n";
}
}

View File

@@ -9,60 +9,29 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeDatetime implements IForm
class TypeDatetime extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_VALUE => '',
self::FORM_NAME => ''
self::FORM_VALUE => '',
self::FORM_NAME => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="datetime-local" name="NAME" value="VALUE" ID CLASS>' . "\n";
}

View File

@@ -9,59 +9,30 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeEmail implements IForm
class TypeEmail extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => ''
self::FORM_NAME => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_PLACEHOLDER => '',
self::FORM_ATTRIBUTE_REQUIRED => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="email" name="NAME" placeholder="PLACEHOLDER" required="REQUIRED" ID CLASS>' . "\n";
}

View File

@@ -9,60 +9,28 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeFileUpload implements IForm
class TypeFileUpload extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => ''
self::FORM_NAME => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="file" name="NAME" ID CLASS>' . "\n";
}

View File

@@ -9,61 +9,29 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeHidden implements IForm
class TypeHidden extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => ''
self::FORM_NAME => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="hidden" value="VALUE" name="NAME" ID CLASS>' . "\n";
}

View File

@@ -9,60 +9,28 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeImageSubmit implements IForm
class TypeImageSubmit extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_ATTRIBUTE_SRC => ''
self::FORM_ATTRIBUTE_SRC => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="image" src="SRC" ID CLASS>' . "\n";
}

37
core/c/typelabel.php Executable file
View File

@@ -0,0 +1,37 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Created by PhpStorm.
* User: mithril
* Date: 07.02.18
* Time: 21:06
*/
class TypeLabel extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_FOR => '',
self::FORM_ATTRIBUTE_FORM => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( self::loadAttributeValues( $attributes ) );
return $this->getElement();
}
/**
* @param mixed $element
*/
private function _setElement( )
{
$this->_element = '<label for="FOR" ID CLASS>VALUE</label>' . "\n";
}
}

View File

@@ -9,60 +9,29 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeNumber implements IForm
class TypeNumber extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => ''
self::FORM_NAME => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="number" name="NAME" value="VALUE" ID CLASS>' . "\n";
}

View File

@@ -9,59 +9,28 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeOption implements IForm
class TypeOption extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_VALUE => ''
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
private $_element;
public function loadElement( $attributes )
{
self::__construct( $this->_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";
$this->_element = '<option value="VALUE" ID CLASS>VALUE</option>' . "\n";
}

View File

@@ -9,59 +9,30 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypePassword implements IForm
class TypePassword extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => ''
self::FORM_NAME => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_PLACEHOLDER => '',
self::FORM_ATTRIBUTE_REQUIRED => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="password" name="NAME" placeholder="PLACEHOLDER" required="REQUIRED" ID CLASS>' . "\n";
}

View File

@@ -9,61 +9,31 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeRadio implements IForm
class TypeRadio extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => ''
self::FORM_NAME => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_ID => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="radio" name="NAME" value="VALUE" ID CLASS>' . 'VALUE<br>' . "\n";
}

View File

@@ -9,60 +9,29 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeRange implements IForm
class TypeRange extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => ''
self::FORM_NAME => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_ID => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="range" name="NAME" value="VALUE" ID CLASS>' . "\n";
}

View File

@@ -9,59 +9,28 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeReset implements IForm
class TypeReset extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_VALUE => ''
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_ID => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="reset" value="VALUE" ID CLASS>' . "\n";
}

View File

@@ -9,59 +9,27 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeSearch implements IForm
class TypeSearch extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_ID => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="search" ID CLASS>' . "\n";
}

View File

@@ -9,59 +9,28 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeSelect implements IForm
class TypeSelect extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => ''
self::FORM_NAME => '',
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_ID => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<select name="NAME" ID CLASS>' . "\n" . 'OPTIONS' . "\n" . '</select>' . "\n";
}

View File

@@ -9,61 +9,28 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeSubmit implements IForm
class TypeSubmit extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_VALUE => ''
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="submit" value="VALUE" ID CLASS>' . "\n";
}
}

View File

@@ -9,60 +9,31 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeTelefon implements IForm
class TypeTelefon extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE
self::FORM_NAME => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_PLACEHOLDER => '',
self::FORM_ATTRIBUTE_REQUIRED => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="tel" name="NAME" value="VALUE" placeholder="PLACEHOLDER" required="REQUIRED" CLASS ID>' . "\n";
}

View File

@@ -9,69 +9,32 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeText implements IForm
class TypeText extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_NAME => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_SPEECH => ''
self::FORM_NAME => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_SPEECH => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_PLACEHOLDER => '',
self::FORM_ATTRIBUTE_REQUIRED => ''
);
private $_element;
public function loadElement( $attributes )
{
if(!array_key_exists('speech', $attributes))
{
$attributes['speech'] = '';
}
else
{
$attributes['speech'] = ' x-webkit-speech';
}
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="text" name="NAME" value="VALUE" placeholder="PLACEHOLDER" required="REQUIRED" SPEECH ID CLASS>' . "\n";
}

View File

@@ -9,21 +9,24 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeTextarea implements IForm
class TypeTextarea extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_ATTRIBUTE_COLS => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_ROWS => '',
self::FORM_NAME => ''
self::FORM_ATTRIBUTE_COLS => '',
self::FORM_VALUE => '',
self::FORM_ATTRIBUTE_ROWS => '',
self::FORM_NAME => '',
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_PLACEHOLDER => '',
self::FORM_ATTRIBUTE_REQUIRED => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $attributes ) );
return $this->getElement();
}
@@ -35,36 +38,12 @@ class TypeTextarea implements IForm
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";
$this->_element = '<textarea name="NAME" rows="ROWS" cols="COLS" placeholder="PLACEHOLDER" required="REQUIRED" ID CLASS>' . "VALUE" . '</textarea>' . "\n";
}

View File

@@ -9,59 +9,27 @@ use Nibiru\Adapter;
* Time: 21:42
*/
class TypeUrl implements IForm
class TypeUrl extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_ID => ''
);
private $_element;
public function loadElement( $attributes )
{
parent::__construct( $this->_attributes );
$this->_setElement();
$this->_setAttributes( $attributes );
$this->_setAttributes( self::loadAttributeValues( $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";
$this->_element = '<input type="url" ID CLASS>' . "\n";
}

View File

@@ -12,10 +12,13 @@ class View extends Controller implements IView
{
private static $_instance;
const NIBIRU_SETTINGS = "SETTINGS";
const NIBIRU_SECURITY = "SECURITY";
const NIBIRU_ROUTING = "ROUTING";
const NIBIRU_FILE_END = ".tpl";
const NIBIRU_SETTINGS = "SETTINGS";
const NIBIRU_URL = "pageurl";
const NIBIRU_ERROR = "ERROR";
const NIBIRU_SECURITY = "SECURITY";
const NIBIRU_ROUTING = "ROUTING";
const NIBIRU_EMAIL = "EMAIL";
const NIBIRU_FILE_END = ".tpl";
private static $smarty = array();
private static $engine = array();