Update Version 0.4.0 beta 09.07.2018
- Bugfix on the form classes, now the select option is correctly set back. - Update for the database adapter - Improvement of the form elements, added onchange on the select boxes, the form tag now can have no element if needed. - Implementation of the Postgres and MySQL Adapter with propper Namespacing. - Minor bugfixing
This commit is contained in:
17
README.md
17
README.md
@@ -1,6 +1,6 @@
|
||||
# Nibiru
|
||||
### Rapid Prototyping PHP Framework
|
||||
Version 0.3.5 beta
|
||||
Version 0.4.0 beta
|
||||
## Introduction
|
||||
|
||||
<div style="word-spacing: 2px; letter-spacing: 0.1px; font-size: 12px; margin-bottom: 15px;">Nibiru is a rapid prototyping framework written in PHP and based on the MVC design pattern. Now one may say that writing <br>
|
||||
@@ -55,7 +55,6 @@ Engine Implementation.</div>
|
||||
<li>Dwoo tempalte eninge tests</li>
|
||||
<li>Twig tempalte eninge tests</li>
|
||||
</ul>
|
||||
<h1>Previous version</h1>
|
||||
<h1>Version 0.3 beta 04.02.2018</h1>
|
||||
<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>
|
||||
@@ -65,8 +64,7 @@ Engine Implementation.</div>
|
||||
<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>
|
||||
|
||||
<h1>Update</h1>
|
||||
<h1>Previous version</h1>
|
||||
<p>Version 0.3.5 beta 14.03.2018</p>
|
||||
<ul>
|
||||
<li>Bugfix on the Router, now the currentPage will be returned correctly.</li>
|
||||
@@ -75,6 +73,17 @@ Engine Implementation.</div>
|
||||
<li>Added missing form elements, migration to a Form factory, in order to easy configure and install a form anywhere you like</li>
|
||||
<li>Minor bugfixing</li>
|
||||
</ul>
|
||||
|
||||
<h1>Update</h1>
|
||||
<p>Version 0.4.0 beta 09.07.2018</p>
|
||||
<ul>
|
||||
<li>Bugfix on the form classes, now the select option is correctly set back.</li>
|
||||
<li>Update for the database adapter</li>
|
||||
<li>Improvement of the form elements, added onchange on the select boxes, the form tag now can have no element if needed.</li>
|
||||
<li>Implementation of the Postgres and MySQL Adapter with propper Namespacing.</li>
|
||||
<li>Minor bugfixing</li>
|
||||
</ul>
|
||||
|
||||
<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>
|
||||
|
||||
Author: Stephan Kasdorf<br><br>
|
||||
@@ -33,9 +33,4 @@ class indexController extends View implements IController
|
||||
{
|
||||
JsonNavigation::getInstance()->loadJsonNavigationArray();
|
||||
}
|
||||
|
||||
public function formAction( $action = false, $name = "", $type = "", $labeled = false, $data = array() )
|
||||
{
|
||||
// TODO: Implement formAction() method.
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace Nibiru\Model;
|
||||
use Nibiru\Adapter\Db;
|
||||
use Nibiru\Adapter\MySQL\Db;
|
||||
use Nibiru\Pdo;
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
|
||||
0
application/module/empty
Normal file
0
application/module/empty
Normal file
@@ -24,7 +24,7 @@ register.text = "PATHTOYOURHTMLTEMPLATE"
|
||||
pageurl = "YOURPAGEURLWITHPROTOCOL"
|
||||
navigation = "navigation.json"
|
||||
dbmodel = "/../../application/model/"
|
||||
modul = "/../../application/modul/"
|
||||
module = "/../../application/module/"
|
||||
background.img[] = "public/img/nibiru3.jpg"
|
||||
smarty.css[] = "public/css/v3/roboto.css"
|
||||
smarty.css[] = "public/css/v3/toolkit-inverse.css"
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace Nibiru\Adapter;
|
||||
use Nibiru\IDb;
|
||||
namespace Nibiru\Adapter\MySQL;
|
||||
|
||||
use Nibiru\Pdo;
|
||||
use Nibiru\Factory;
|
||||
use Nibiru\Adapter\IDb;
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
342
core/a/postgres.db.php
Normal file
342
core/a/postgres.db.php
Normal file
@@ -0,0 +1,342 @@
|
||||
<?php
|
||||
|
||||
namespace Nibiru\Adapter\Postgres;
|
||||
|
||||
use Nibiru\Postgres;
|
||||
use Nibiru\Factory;
|
||||
use Nibiru\Adapter\IDb;
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: kasdorf
|
||||
* Date: 17.01.18
|
||||
* Time: 09:01
|
||||
*/
|
||||
abstract class Db implements IDb
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc class parameters
|
||||
*/
|
||||
private static $table = array();
|
||||
private $_multithreatCount = 0;
|
||||
private $_nextIndex = NULL;
|
||||
|
||||
/**
|
||||
* @desc load the table array from the model in order to have the correct fields and the correct table name
|
||||
* @param array $tableArray
|
||||
*/
|
||||
protected static function initTable( $tableArray = array() )
|
||||
{
|
||||
self::setTable( $tableArray );
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc getter for the table constant array
|
||||
* @return array
|
||||
*/
|
||||
private static function getTable()
|
||||
{
|
||||
return self::$table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc setter for the table constant array
|
||||
* @param array $table
|
||||
*/
|
||||
private static function setTable( $table )
|
||||
{
|
||||
self::$table = $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc Selects a rowset by the dataset id
|
||||
* @param bool $id
|
||||
* @return array|mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function selectRowsetById($id = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Postgres::query("SELECT * FROM " . self::getTable()['table'] . " WHERE " . self::getTable()['fields']['id'] . " = " . $id . ";" );
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
throw new \Exception(print_r($e, true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc Selects a columnlist by a given field array from the current selected table
|
||||
* @param array $fieldarray
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function selectColumnByFieldArray( $fieldarray = array() )
|
||||
{
|
||||
try
|
||||
{
|
||||
$numItems = count($fieldarray);
|
||||
$i=0;
|
||||
$fields = "";
|
||||
foreach($fieldarray as $key=>$field)
|
||||
{
|
||||
if(++$i === $numItems)
|
||||
{
|
||||
$fields .= $field . " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$fields .= $field . ", ";
|
||||
}
|
||||
}
|
||||
return Postgres::query("SELECT " . $fields . "FROM " . self::getTable()['table'] . ";");
|
||||
}
|
||||
catch(\Exception $e)
|
||||
{
|
||||
throw new \Exception(print_r($e, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function insertRowsetById($rowset = array(), $id = false)
|
||||
{
|
||||
// TODO: Implement insertRowsetById() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc Selects a Field by max value, or multiple fields by max value, same with min fields.
|
||||
* Both can be combined.
|
||||
* @param string|array $min
|
||||
* @param string|array $max
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function selectDatasetByMinMax($min = false, $max = false)
|
||||
{
|
||||
if($min)
|
||||
{
|
||||
$fields = "";
|
||||
if(is_array($min))
|
||||
{
|
||||
$numItems = count($min);
|
||||
$i = 0;
|
||||
foreach ($min as $key=>$item)
|
||||
{
|
||||
if(++$i === $numItems)
|
||||
{
|
||||
$fields .= "MIN(" . $item .") as min_" .$item . " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$fields .= "MIN(" . $item .") as min_".$item.", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$fields .= "MIN(".$min.") as min_" . $min . " ";
|
||||
}
|
||||
}
|
||||
if($max)
|
||||
{
|
||||
$mfields = "";
|
||||
if(is_array($max))
|
||||
{
|
||||
$numItems = count($max);
|
||||
$y = 0;
|
||||
foreach ($max as $key=>$item)
|
||||
{
|
||||
if(++$y === $numItems)
|
||||
{
|
||||
$mfields .= "MAX(" . $item .") as max_" .$item . " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$mfields .= "MAX(" . $item .") as max_".$item.", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mfields .= "MAX(".$max.") as max_" . $max . " ";
|
||||
}
|
||||
}
|
||||
if(!empty($fields))
|
||||
{
|
||||
if(!empty($mfields))
|
||||
{
|
||||
$result = Postgres::query("SELECT " . $fields . ", " . $mfields . " FROM " . self::getTable()['table']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = Postgres::query("SELECT " . $fields . " FROM " . self::getTable()['table']);
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($mfields) && empty($fields))
|
||||
{
|
||||
$result = Postgres::query("SELECT " . $mfields . " FROM " . self::getTable()['table']);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc Gets the next dataset ID for insertation, if the dataset should be iterated and not be related to the last insert id because that one is already
|
||||
* present it can also be iterated
|
||||
* @param bool $iterate
|
||||
* @return int|mixed|null
|
||||
*/
|
||||
public function nextInsertIndex($iterate = false)
|
||||
{
|
||||
if(!$iterate)
|
||||
{
|
||||
$cur = array_shift(Postgres::query('SELECT MAX(id) AS id FROM ' . self::getTable()['table'] . ';'));
|
||||
if(empty(array_filter($cur)))
|
||||
{
|
||||
$cur["id"] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cur["id"]++;
|
||||
}
|
||||
$this->_nextIndex = $cur["id"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_nextIndex++;
|
||||
}
|
||||
return $this->_nextIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc returns the rowset by the selected field and value array
|
||||
* @param array $fieldValue
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function selectRowsetByFieldValue( $fieldValue = array() )
|
||||
{
|
||||
return Postgres::fetchRowInArrayByWhere(self::getTable()['table'], $fieldValue['field'], $fieldValue['value']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc selects only one field from the field value array and returns the result
|
||||
* @param array $fieldValue
|
||||
* @return array
|
||||
*/
|
||||
public function selectFieldByFieldValue( $fieldValue = array() )
|
||||
{
|
||||
return Postgres::query("SELECT " . $fieldValue['field'] . " FROM " . self::getTable()['table'] . " WHERE " . $fieldValue['field'] . " = '" . $fieldValue['value'] . "';");
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc deletes all content in the table use with caution
|
||||
*/
|
||||
public function truncateTable()
|
||||
{
|
||||
Postgres::query('DELETE FROM ' . self::getTable()['table'] . ';');
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc deletes entry by ID from the database
|
||||
* @param bool $id
|
||||
*/
|
||||
public function deleteEntryById( $id = false )
|
||||
{
|
||||
if($id)
|
||||
{
|
||||
Postgres::query('DELETE FROM ' . self::getTable()['table'] . ' WHERE id = ' . $id . ';' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc deletes entry by fieldname and value from the database
|
||||
* @param array $fieldValue
|
||||
*/
|
||||
public function deleteEntryByFieldValue( $fieldValue = array() )
|
||||
{
|
||||
if(array_key_exists('field', $fieldValue))
|
||||
{
|
||||
Postgres::query("DELETE FROM " . self::getTable()['table'] . " WHERE " . $fieldValue["field"] . " = '" . $fieldValue["value"] . "'" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc Loads the complete Table to an array, only use for small tables, otherwise load the table with its limits.
|
||||
* @param array $sortfield['name'], $sortfield['order'], or as in the followin example:
|
||||
* q
|
||||
* @return array
|
||||
*/
|
||||
public function loadTableToArray( $sortfield = array() )
|
||||
{
|
||||
if(sizeof($sortfield)>0)
|
||||
{
|
||||
$name = implode(', ', $sortfield['name']);
|
||||
$result = Postgres::query('SELECT * FROM ' . self::getTable()['table'] . ' ORDER BY ' . $name . ' ' . $sortfield['order']. ';');
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = Postgres::query('SELECT * FROM ' . self::getTable()['table'] . ';');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function loadMultithreadCount()
|
||||
{
|
||||
if( $this->_multithreatCount < Postgres::getInstance()->getMultithreading() )
|
||||
{
|
||||
$this->_multithreatCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_multithreatCount = 0;
|
||||
}
|
||||
return $this->_multithreatCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc returns the last inserted id from the corresponding table Model
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLastInsertID( $sequences = false )
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if(!$sequences)
|
||||
{
|
||||
$result = Postgres::query('SELECT MAX(id) AS id FROM ' . self::getTable()['table'] . ';');
|
||||
return array_shift($result)["id"];
|
||||
}
|
||||
else
|
||||
{
|
||||
//Limbas sequence abfragen
|
||||
Postgres::query('SELECT last_value AS id FROM seq_' . self::getTable()['table'] . '_id ;');
|
||||
return array_shift($result)["id"];
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
throw new \Exception(print_r($e, true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc gets the row count of a table
|
||||
* @return mixed
|
||||
*/
|
||||
public function insertedRowCount()
|
||||
{
|
||||
$result = Postgres::query("SELECT count(*) as sum FROM " . self::getTable()['table'] . ";");
|
||||
return array_shift($result)['sum'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc returns all columns as an array from the current table
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function getAllColumnsAsArray()
|
||||
{
|
||||
$result = Postgres::query("SELECT * FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '" . self::getTable()['table'] . "';");
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,8 @@ class Auth extends Controller implements IAuth
|
||||
$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_id = session_id();
|
||||
$_SESSION['auth']['id'] = $session_id;
|
||||
$_SESSION['auth']['login'] = $login;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class Autoloader
|
||||
{
|
||||
const MY_FILE_NAME = "autoloader.php";
|
||||
const DB_MODEL_FOLDER = "dbmodel";
|
||||
const MODUL_FOLDER = "modul";
|
||||
const MODULE_FOLDER = "module";
|
||||
|
||||
private static $_filesInFoler = array();
|
||||
private static $_instance;
|
||||
@@ -56,7 +56,33 @@ class Autoloader
|
||||
*/
|
||||
private static function _setFilesInFoler( )
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::DB_MODEL_FOLDER] ));
|
||||
$modelFolder = Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::DB_MODEL_FOLDER];
|
||||
if(is_array($modelFolder))
|
||||
{
|
||||
foreach ($modelFolder as $folder)
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . $folder ));
|
||||
foreach ($iterator as $item)
|
||||
{
|
||||
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
||||
{
|
||||
self::$_filesInFoler[] = $item->getPathName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . $modelFolder ));
|
||||
foreach ($iterator as $item)
|
||||
{
|
||||
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
||||
{
|
||||
self::$_filesInFoler[] = $item->getPathName();
|
||||
}
|
||||
}
|
||||
}
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::MODULE_FOLDER] ));
|
||||
foreach ($iterator as $item)
|
||||
{
|
||||
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
||||
|
||||
@@ -142,4 +142,11 @@ class Controller
|
||||
return $_REQUEST;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getServer()
|
||||
{
|
||||
return $_SERVER;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,9 @@ class Form extends FormAttributes implements IForm
|
||||
self::FORM_ACTION => '',
|
||||
self::FORM_TARGET => '',
|
||||
self::FORM_ATTRIBUTE_ID => '',
|
||||
self::FORM_ATTRIBUTE_CLASS => ''
|
||||
self::FORM_ATTRIBUTE_CLASS => '',
|
||||
self::FORM_ENCTYPE => '',
|
||||
self::FORM_ATTRIBUTE_ONSUBMIT => ''
|
||||
);
|
||||
|
||||
public function loadElement( $attributes )
|
||||
@@ -32,7 +34,7 @@ class Form extends FormAttributes implements IForm
|
||||
*/
|
||||
private function _setElement( )
|
||||
{
|
||||
$this->_element = '<form action="ACTION" method="METHOD" name="NAME" target="TARGET" ID CLASS>' . "\n" . 'FIELDS</form>' . "\n";
|
||||
$this->_element = '<form action="ACTION" method="METHOD" name="NAME" target="TARGET" enctype="ENCTYPE" onsubmit="ONSUBMIT" ID CLASS>' . "\n" . 'FIELDS</form>' . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,6 +58,9 @@ class FormAttributes
|
||||
}
|
||||
$this->_element = str_replace(' ID', '', $this->_element);
|
||||
$this->_element = str_replace(' CLASS', '', $this->_element);
|
||||
$this->_element = str_replace(' enctype="ENCTYPE"', '', $this->_element);
|
||||
$this->_element = str_replace(' onsubmit="ONSUBMIT"', '', $this->_element);
|
||||
$this->_element = str_replace(' action="ACTION"', '', $this->_element);
|
||||
$this->_element = str_replace(' SPEECH', '', $this->_element);
|
||||
$this->_element = str_replace(' FORM', '', $this->_element);
|
||||
$this->_element = str_replace(' placeholder="PLACEHOLDER"', '', $this->_element);
|
||||
@@ -65,6 +68,9 @@ class FormAttributes
|
||||
$this->_element = str_replace(' value="VALUE"', '', $this->_element);
|
||||
$this->_element = str_replace(' ', ' ', $this->_element);
|
||||
$this->_element = str_replace(' type="TYPE"', '', $this->_element);
|
||||
$this->_element = str_replace(' onchange="ONCHANGE"', '', $this->_element);
|
||||
$this->_element = str_replace(' SELECTED', '', $this->_element);
|
||||
$this->_element = str_replace(' CONTEXT', '', $this->_element);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,12 @@ final class Pdo extends Mysql implements IPdo
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function selectDatasetByFieldAndValue($tablename = self::PLACE_TABLE_NAME, $fieldAndValue = array() )
|
||||
{
|
||||
$result = parent::getInstance()->getConn()->query("SELECT * FROM " . $tablename . " WHERE " . $fieldAndValue['name'] . " = '" . $fieldAndValue['value'] . "';");
|
||||
return $result->fetchAll();
|
||||
}
|
||||
|
||||
public static function updateColumnByFieldWhere( $tablename = self::PLACE_TABLE_NAME,
|
||||
$column_name = IMysql::PLACE_COLUMN_NAME,
|
||||
$parameter_name = IMysql::PLACE_SEARCH_TERM,
|
||||
|
||||
@@ -152,4 +152,9 @@ class Postgres extends Odbc implements IPostgres
|
||||
}
|
||||
}
|
||||
|
||||
public static function truncateTable($tablename = IOdbc::PLACE_TABLE_NAME)
|
||||
{
|
||||
\odbc_exec(parent::getInstance( self::getSettingsSection() )->getConn(), "DELETE FROM " . $tablename . ";");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -171,7 +171,7 @@ class Router extends Config
|
||||
public function currentPage()
|
||||
{
|
||||
//self::RouterDebug(self::$_cur_page);
|
||||
return self::$_cur_page;
|
||||
return self::getCurPage();
|
||||
}
|
||||
|
||||
public static function RouterDebug($value)
|
||||
|
||||
@@ -14,7 +14,9 @@ class TypeOption extends FormAttributes implements IForm
|
||||
private $_attributes = array(
|
||||
self::FORM_VALUE => '',
|
||||
self::FORM_ATTRIBUTE_ID => '',
|
||||
self::FORM_ATTRIBUTE_CLASS => ''
|
||||
self::FORM_ATTRIBUTE_CLASS => '',
|
||||
self::FORM_ATTRIBUTE_SELECTED => '',
|
||||
self::FORM_ATTRIBUTE_CONTEXT => ''
|
||||
);
|
||||
|
||||
public function loadElement( $attributes )
|
||||
@@ -30,9 +32,6 @@ class TypeOption extends FormAttributes implements IForm
|
||||
*/
|
||||
private function _setElement( )
|
||||
{
|
||||
$this->_element = '<option value="VALUE" ID CLASS>VALUE</option>' . "\n";
|
||||
$this->_element = '<option value="VALUE" ID CLASS SELECTED>CONTEXT</option>' . "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -14,7 +14,8 @@ class TypeSelect extends FormAttributes implements IForm
|
||||
private $_attributes = array(
|
||||
self::FORM_NAME => '',
|
||||
self::FORM_ATTRIBUTE_CLASS => '',
|
||||
self::FORM_ATTRIBUTE_ID => ''
|
||||
self::FORM_ATTRIBUTE_ID => '',
|
||||
self::FORM_ATTRIBUTE_ONCHANGE => ''
|
||||
);
|
||||
|
||||
public function loadElement( $attributes )
|
||||
@@ -30,9 +31,6 @@ class TypeSelect extends FormAttributes implements IForm
|
||||
*/
|
||||
private function _setElement( )
|
||||
{
|
||||
$this->_element = '<select name="NAME" ID CLASS>' . "\n" . 'OPTIONS' . "\n" . '</select>' . "\n";
|
||||
$this->_element = '<select name="NAME" onchange="ONCHANGE" ID CLASS>' . "\n" . 'OPTIONS' . "\n" . '</select>' . "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -43,9 +43,16 @@ class Form
|
||||
* @param $option
|
||||
*/
|
||||
private static function assambleOptions( $option )
|
||||
{
|
||||
if($option == false)
|
||||
{
|
||||
self::$option = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$option .= $option;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc is used internally for assambly only
|
||||
@@ -57,6 +64,14 @@ class Form
|
||||
return str_replace( 'OPTIONS', self::$option, $select );
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc clear all form data in order to build a new one
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
self::$form = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc is used internally for assambly only
|
||||
* @param $element
|
||||
@@ -144,7 +159,7 @@ class Form
|
||||
{
|
||||
self::setDiv( $div );
|
||||
}
|
||||
self::setElement( new \Nibiru\Form\Form() );
|
||||
self::setElement( new \Sunrise\Form\Form() );
|
||||
return self::display( self::getElement()->loadElement( $attributes ) );
|
||||
}
|
||||
|
||||
@@ -429,7 +444,7 @@ class Form
|
||||
}
|
||||
self::setElement( new TypeSelect() );
|
||||
self::assamble( self::displaySelect( self::getElement()->loadElement( $attributes ) ) );
|
||||
|
||||
self::assambleOptions( false );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
* @category - [PLEASE SPECIFIY]
|
||||
* @license - BSD License
|
||||
*/
|
||||
if(session_status() == PHP_SESSION_NONE)
|
||||
{
|
||||
session_start();
|
||||
}
|
||||
/**
|
||||
* @desc Nibiru framework functionality
|
||||
*/
|
||||
@@ -29,7 +32,8 @@ 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__ . '/a/mysql.db.php';
|
||||
require_once __DIR__ . '/a/postgres.db.php';
|
||||
require_once __DIR__ . '/f/db.php';
|
||||
/**
|
||||
* @desc MVC functionality
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Nibiru;
|
||||
namespace Nibiru\Adapter;
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: kasdorf
|
||||
|
||||
@@ -18,6 +18,7 @@ interface IForm
|
||||
const FORM_METHOD_TYPE = array('post', 'get');
|
||||
const FORM_ACTION = 'action';
|
||||
const FORM_TARGET = 'target';
|
||||
const FORM_ENCTYPE = 'enctype';
|
||||
const FORM_TARGET_TYPE = array('_blank', '_self', '_parent', '_top');
|
||||
const FORM_TYPE_TEXT = 'text';
|
||||
const FORM_TYPE_SUBMIT = 'submit';
|
||||
@@ -34,6 +35,10 @@ interface IForm
|
||||
const FORM_ATTRIBUTE_PLACEHOLDER = 'placeholder';
|
||||
const FORM_ATTRIBUTE_REQUIRED = 'required';
|
||||
const FORM_ATTRIBUTE_TYPE = 'type';
|
||||
const FORM_ATTRIBUTE_ONCHANGE = 'onchange';
|
||||
const FORM_ATTRIBUTE_ONSUBMIT = 'onsubmit';
|
||||
const FORM_ATTRIBUTE_SELECTED = 'selected';
|
||||
const FORM_ATTRIBUTE_CONTEXT = 'context';
|
||||
|
||||
/**
|
||||
* @desc loads the current Form element to the form
|
||||
|
||||
Reference in New Issue
Block a user