diff --git a/README.md b/README.md index 595c3b6..64f9716 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,9 @@ Engine Implementation.
  • soap interface to a given SOAP server
  • Dwoo tempalte eninge tests
  • Twig tempalte eninge tests
  • -
  • Improved routing
  • +
  • Database access functionallity for the db.php Factory
  • -

    Update

    +

    Previous version

    Version 0.2 beta 19.07.2017

    + +

    Update

    +

    Version 0.3 beta 04.02.2018

    +
    The start is done, have success with PHP prototyping, and always remember to have fun!
    diff --git a/application/database/users.php b/application/database/users.php new file mode 100644 index 0000000..f143243 --- /dev/null +++ b/application/database/users.php @@ -0,0 +1,40 @@ + '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 + ); + } + +} \ No newline at end of file diff --git a/core/a/db.php b/core/a/db.php new file mode 100644 index 0000000..169ca99 --- /dev/null +++ b/core/a/db.php @@ -0,0 +1,72 @@ +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. + } + +} \ No newline at end of file diff --git a/core/c/autoloader.php b/core/c/autoloader.php new file mode 100644 index 0000000..b382f9f --- /dev/null +++ b/core/c/autoloader.php @@ -0,0 +1,69 @@ +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(); + } + } + } + + +} \ No newline at end of file diff --git a/core/c/controller.php b/core/c/controller.php index bdb6700..150f9e5 100644 --- a/core/c/controller.php +++ b/core/c/controller.php @@ -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; } /** diff --git a/core/c/dispatcher.php b/core/c/dispatcher.php index ccd6f7e..dd608ba 100644 --- a/core/c/dispatcher.php +++ b/core/c/dispatcher.php @@ -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"; diff --git a/core/c/form.php b/core/c/form.php index e85329e..d316a4e 100644 --- a/core/c/form.php +++ b/core/c/form.php @@ -1,169 +1,69 @@ '', + 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 = '
    ' . "\n" . 'FIELDS
    ' . "\n"; } - public function addFieldset($name) - { - self::setFieldsetName($name); - - } } \ No newline at end of file diff --git a/core/c/json-navigation.php b/core/c/json-navigation.php index f77ed78..2aa8893 100755 --- a/core/c/json-navigation.php +++ b/core/c/json-navigation.php @@ -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); + } } } \ No newline at end of file diff --git a/core/c/pdo.php b/core/c/pdo.php index c610510..d4cf197 100644 --- a/core/c/pdo.php +++ b/core/c/pdo.php @@ -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) { diff --git a/core/c/router.php b/core/c/router.php index 7825912..dbc52ca 100755 --- a/core/c/router.php +++ b/core/c/router.php @@ -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(); } - } /** diff --git a/core/c/settings.php b/core/c/settings.php index 8e8848e..0db06f9 100644 --- a/core/c/settings.php +++ b/core/c/settings.php @@ -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); } } } diff --git a/core/c/typecheckbox.php b/core/c/typecheckbox.php new file mode 100644 index 0000000..bf73285 --- /dev/null +++ b/core/c/typecheckbox.php @@ -0,0 +1,71 @@ + '', + 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 = '' . 'VALUE
    ' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typecolor.php b/core/c/typecolor.php new file mode 100644 index 0000000..c142175 --- /dev/null +++ b/core/c/typecolor.php @@ -0,0 +1,69 @@ + '' + ); + + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typedate.php b/core/c/typedate.php new file mode 100644 index 0000000..d607128 --- /dev/null +++ b/core/c/typedate.php @@ -0,0 +1,70 @@ + '', + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typedatetime.php b/core/c/typedatetime.php new file mode 100644 index 0000000..1491889 --- /dev/null +++ b/core/c/typedatetime.php @@ -0,0 +1,70 @@ + '', + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typeemail.php b/core/c/typeemail.php new file mode 100644 index 0000000..b1c35a7 --- /dev/null +++ b/core/c/typeemail.php @@ -0,0 +1,69 @@ + '' + ); + + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typefileupload.php b/core/c/typefileupload.php new file mode 100644 index 0000000..43a0188 --- /dev/null +++ b/core/c/typefileupload.php @@ -0,0 +1,70 @@ + '' + + ); + + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typehidden.php b/core/c/typehidden.php new file mode 100644 index 0000000..230ff90 --- /dev/null +++ b/core/c/typehidden.php @@ -0,0 +1,71 @@ + '', + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typeimagesubmit.php b/core/c/typeimagesubmit.php new file mode 100644 index 0000000..361ea15 --- /dev/null +++ b/core/c/typeimagesubmit.php @@ -0,0 +1,70 @@ + '' + + ); + + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typenumber.php b/core/c/typenumber.php new file mode 100644 index 0000000..849fb74 --- /dev/null +++ b/core/c/typenumber.php @@ -0,0 +1,70 @@ + '', + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typeoption.php b/core/c/typeoption.php new file mode 100644 index 0000000..f58365b --- /dev/null +++ b/core/c/typeoption.php @@ -0,0 +1,69 @@ + '' + ); + + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typepassword.php b/core/c/typepassword.php new file mode 100644 index 0000000..e459911 --- /dev/null +++ b/core/c/typepassword.php @@ -0,0 +1,69 @@ + '' + ); + + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typeradio.php b/core/c/typeradio.php new file mode 100644 index 0000000..1d1afd3 --- /dev/null +++ b/core/c/typeradio.php @@ -0,0 +1,71 @@ + '', + 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 = '' . 'VALUE
    ' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typerange.php b/core/c/typerange.php new file mode 100644 index 0000000..8e03497 --- /dev/null +++ b/core/c/typerange.php @@ -0,0 +1,70 @@ + '', + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typereset.php b/core/c/typereset.php new file mode 100644 index 0000000..17f35b2 --- /dev/null +++ b/core/c/typereset.php @@ -0,0 +1,69 @@ + '' + ); + + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typesearch.php b/core/c/typesearch.php new file mode 100644 index 0000000..62da381 --- /dev/null +++ b/core/c/typesearch.php @@ -0,0 +1,69 @@ +_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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typeselect.php b/core/c/typeselect.php new file mode 100644 index 0000000..7317f13 --- /dev/null +++ b/core/c/typeselect.php @@ -0,0 +1,69 @@ + '' + ); + + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typesubmit.php b/core/c/typesubmit.php new file mode 100644 index 0000000..246a3c2 --- /dev/null +++ b/core/c/typesubmit.php @@ -0,0 +1,69 @@ + '' + ); + + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typetelefon.php b/core/c/typetelefon.php new file mode 100644 index 0000000..b9b7a34 --- /dev/null +++ b/core/c/typetelefon.php @@ -0,0 +1,70 @@ + '', + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typetext.php b/core/c/typetext.php new file mode 100644 index 0000000..be069c7 --- /dev/null +++ b/core/c/typetext.php @@ -0,0 +1,79 @@ + '', + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typetextarea.php b/core/c/typetextarea.php new file mode 100644 index 0000000..d1757dc --- /dev/null +++ b/core/c/typetextarea.php @@ -0,0 +1,72 @@ + '', + 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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/typeurl.php b/core/c/typeurl.php new file mode 100644 index 0000000..d1a62b0 --- /dev/null +++ b/core/c/typeurl.php @@ -0,0 +1,69 @@ +_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 = '' . "\n"; + } + + + +} \ No newline at end of file diff --git a/core/c/view.php b/core/c/view.php index 2131c9e..14a08a0 100755 --- a/core/c/view.php +++ b/core/c/view.php @@ -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 ); } diff --git a/core/f/db.php b/core/f/db.php new file mode 100644 index 0000000..f90bf52 --- /dev/null +++ b/core/f/db.php @@ -0,0 +1,57 @@ +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; + } + +} \ No newline at end of file diff --git a/core/f/form.php b/core/f/form.php new file mode 100644 index 0000000..7f26356 --- /dev/null +++ b/core/f/form.php @@ -0,0 +1,317 @@ +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 ) ); + } + +} \ No newline at end of file diff --git a/core/framework.php b/core/framework.php index 1556304..82fc6f2 100644 --- a/core/framework.php +++ b/core/framework.php @@ -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 diff --git a/core/i/controller.php b/core/i/controller.php index 0db3b1a..f7df448 100644 --- a/core/i/controller.php +++ b/core/i/controller.php @@ -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 = <<" . "\n" . "{fields}" . "\n" . "\t\t" . "" . "\n"; - const TYPE_FORM_FIELDSET = "
    "."\n"."
    " . "\n" . "{fields}" . "\n" . "" . "\t\t" . "
    "."\n"."
    " . "\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 ); } \ No newline at end of file