diff --git a/composer.json b/composer.json index c03b6c9..6a1239c 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,13 @@ "vendor-dir": "core/l" }, "require": { - "php": ">=7.1.0", + "php": ">=8.1.0", "smarty/smarty": "^3.1", - "phpmailer/phpmailer": "^6.1" + "phpmailer/phpmailer": "^6.1", + "dasprid/enum": "^1.0.3", + "bacon/bacon-qr-code": ">=1.0.3", + "mevdschee/php-crud-api": "^2.14", + "symfony/psr-http-message-bridge": "^2.1", + "laminas/laminas-diactoros": "^2.24" } } \ No newline at end of file diff --git a/core/c/auth.php b/core/c/auth.php old mode 100644 new mode 100755 diff --git a/core/c/autoloader.php b/core/c/autoloader.php old mode 100644 new mode 100755 index 0a1e536..70c81d6 --- a/core/c/autoloader.php +++ b/core/c/autoloader.php @@ -138,9 +138,22 @@ class Autoloader { foreach (self::getFilesInFoler() as $file) { - $required[] = $file; - require_once $file; + if(!strstr($file, self::PLUGINS_FOLDER)) + { + $required[] = $file; + require_once $file; + } + else + { + $plugins[] = $file; + } } + foreach($plugins as $plugin) + { + $required[] = $plugin; + require_once $plugin; + } + if(self::isDebug()) { View::getInstance()->assign( diff --git a/core/c/config.php b/core/c/config.php old mode 100644 new mode 100755 diff --git a/core/c/controller.php b/core/c/controller.php old mode 100644 new mode 100755 index a5df02c..a870b74 --- a/core/c/controller.php +++ b/core/c/controller.php @@ -25,9 +25,10 @@ class Controller extends View protected function __construct() { $this->_setConfig(Config::getInstance()->getConfig()); + $this->_setController(); } - public static function getInstance(): View + public static function getInstance(): View|Controller { $className = get_called_class(); if( self::$_instance == null ) @@ -54,19 +55,29 @@ class Controller extends View } /** + * @desc will return the current controller name * @return string */ - public function getController() + public function getController(): string { return $this->_controller; } /** + * @desc will set the current controller name * @param string $controller */ - protected function setController( $controller ) + protected function _setController( string $controller = "" ) { - $this->_controller = $controller; + if($controller!="") + { + $this->_controller = $controller; + } + else + { + $url = explode("/", $_SERVER['REQUEST_URI']); + $this->_controller = $url[1]; + } } /** diff --git a/core/c/debug.php b/core/c/debug.php old mode 100644 new mode 100755 diff --git a/core/c/dispatcher.php b/core/c/dispatcher.php old mode 100644 new mode 100755 diff --git a/core/c/display.php b/core/c/display.php old mode 100644 new mode 100755 diff --git a/core/c/engine.php b/core/c/engine.php old mode 100644 new mode 100755 diff --git a/core/c/form.php b/core/c/form.php old mode 100644 new mode 100755 diff --git a/core/c/formattributes.php b/core/c/formattributes.php index fe3a36a..0ade6b1 100755 --- a/core/c/formattributes.php +++ b/core/c/formattributes.php @@ -67,6 +67,7 @@ class FormAttributes $this->_element = str_replace(' maxlength="MAXLENGTH"', '', $this->_element); $this->_element = str_replace(' min="MIN"', '', $this->_element); $this->_element = str_replace(' max="MAX"', '', $this->_element); + $this->_element = str_replace(' href="HREF"', '', $this->_element); $this->_element = str_replace(' step="STEP"', '', $this->_element); $this->_element = str_replace(' tabindex="TABINDEX"', '', $this->_element); $this->_element = str_replace(' SPEECH', '', $this->_element); @@ -88,6 +89,7 @@ class FormAttributes $this->_element = str_replace(' CHECKED', '', $this->_element); $this->_element = str_replace(' VALUE', '', $this->_element); $this->_element = str_replace(' PATTERN', '', $this->_element); + $this->_element = str_replace('ANY', '', $this->_element); } /** diff --git a/core/c/jsonnavigation.php b/core/c/jsonnavigation.php index 924be1f..3d5e301 100755 --- a/core/c/jsonnavigation.php +++ b/core/c/jsonnavigation.php @@ -137,61 +137,43 @@ class JsonNavigation extends Config } } - /** - * Loads the navigation from a json file into - * the view, making the variables available + /** + * Loads the navigation from a json file into + * the view, making the variables available * @param string $name */ - public function loadJsonNavigationArray( string $name = '' ) - { - 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::getSectionName()) - { - $keys = array_keys($value); - for($i=0; sizeof($keys)>$i;$i++) - { - if(array_key_exists('link', $value[$keys[$i]])) - { - self::$_navigation_array[] = array( - 'title' => $keys[$i], - 'icon' => $value[$keys[$i]]["icon"], - 'link' => $value[$keys[$i]]["link"], - 'tooltip' => $value[$keys[$i]]["tooltip"], - 'footer' => $value[$keys[$i]]['footer'] - ); - } - elseif(array_key_exists('onclick', $value[$keys[$i]])) - { - self::$_navigation_array[] = array( - 'title' => $keys[$i], - 'icon' => $value[$keys[$i]]["icon"], - 'tooltip' => $value[$keys[$i]]["tooltip"], - 'onclick' => $value[$keys[$i]]["onclick"], - 'footer' => $value[$keys[$i]]['footer'] - ); - } - } - } - } - if( $name ) - { - View::getInstance()->getEngine()->assignGlobal(self::getName(), self::$_navigation_array); - } - else - { - View::getInstance()->getEngine()->assignGlobal("navigationJson", self::$_navigation_array); - } - } + public function loadJsonNavigationArray( string $name = 'navigation' ) + { + 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::getSectionName()) + { + $keys = array_keys($value); + for($i=0; sizeof($keys)>$i;$i++) + { + $fields = []; + $fieldKeys=array_keys($value[$keys[$i]]); + $fields['title']=$keys[$i]; + + foreach ($fieldKeys as $fieldKey) + { + if(array_key_exists($fieldKey, $value[$keys[$i]])) + { + $fields[$fieldKey]=$value[$keys[$i]][$fieldKey]; + } + } + self::$_navigation_array[] = $fields; + } + } + } + View::getInstance()->getEngine()->assignGlobal(self::getName(), self::$_navigation_array); + } } \ No newline at end of file diff --git a/core/c/model.php b/core/c/model.php old mode 100644 new mode 100755 index b04a56c..fa0ee21 --- a/core/c/model.php +++ b/core/c/model.php @@ -78,6 +78,7 @@ class Model extends Table $numItems = count($tablefields); $i = 0; $fieldarray = ""; + $parameters = ""; foreach($this->getTables()[$table] as $field) { if( $i==0 ) @@ -87,15 +88,25 @@ class Model extends Table if( ++$i === $numItems ) { + $parameters .= "private $".$field.";\n\t"; + $setters .= "public function _set".str_replace('_', '', ucfirst($field))."($".$field.")\n\t{\n\t\t\$this->".$field." = $".$field.";\n\t}\n\n\t"; + $getters .= "public function get".str_replace('_', '', ucfirst($field))."()\n\t{\n\t\treturn \$this->".$field.";\n\t}\n\n\t"; $fieldarray .= "\t\t\t\t\t\t\t\t'" . $field . "' => '" . $field . "'"."\n\t\t\t\t\t\t)"; } else { + $parameters .= "private $".$field.";\n\t"; + $setters .= "public function _set".str_replace('_', '', ucfirst($field))."($".$field.")\n\t{\n\t\t\$this->".$field." = $".$field.";\n\t}\n\n\t"; + $getters .= "public function get".str_replace('_', '', ucfirst($field))."()\n\t{\n\t\treturn \$this->".$field.";\n\t}\n\n\t"; $fieldarray .= "\t\t\t\t\t\t\t\t'" . $field . "' => '" . $field . "',\n"; } } - $template = str_replace('[FIELDARRAY]', $fieldarray, $this->getModelTemplate()); + + $template = str_replace('[CLASSPARAMETERS]', $parameters, $this->getModelTemplate()); + $template = str_replace('[FIELDARRAY]', $fieldarray, $template); + $template = str_replace('[SETTERS]', $setters, $template); + $template = str_replace('[GETTERS]', $getters, $template); $template = str_replace('[TABLE]', $table, $template); $template = str_replace('[CLASSNAME]', ucfirst($classname), $template); $template = str_replace('[FOLDERNAME]', ucfirst($this->getFolderNamespace()), $template); @@ -119,7 +130,6 @@ class Model extends Table $template = str_replace('[ADAPTER]', self::ADAPTER_MYSQL, $template); $template = str_replace('[CONNECTOR]', self::ADAPTER_PDO, $template); } - if(Config::getInstance()->getConfig()[self::CONFIG_SECTION][self::DB_OVERWRITE_MODELS]) { file_put_contents($this->getFolderOut() . '/' . $classname . self::PHP_FILE_ENDING, $template); diff --git a/core/c/nibiru.php b/core/c/nibiru.php new file mode 100644 index 0000000..c9812da --- /dev/null +++ b/core/c/nibiru.php @@ -0,0 +1,7 @@ + '', + self::FORM_ATTRIBUTE_ID => '', + self::FORM_ATTRIBUTE_CLASS => '', + self::FORM_ATTRIBUTE_ANY => '' + ); + + /** + * @param $attributes + * @return mixed + */ + public function loadElement($attributes) + { + parent::__construct( $this->_attributes ); + $this->_setElement(); + $this->_setAttributes( self::loadAttributeValues( $attributes ) ); + return $this->getElement(); + } + + /** + * just a closing div element + */ + private function _setElement( ) + { + $this->_element = '' . "\n"; + } +} \ No newline at end of file diff --git a/core/c/typeclosediv.php b/core/c/typeclosediv.php old mode 100644 new mode 100755 diff --git a/core/c/typecolor.php b/core/c/typecolor.php old mode 100644 new mode 100755 diff --git a/core/c/typedate.php b/core/c/typedate.php old mode 100644 new mode 100755 diff --git a/core/c/typedatetime.php b/core/c/typedatetime.php old mode 100644 new mode 100755 diff --git a/core/c/typeemail.php b/core/c/typeemail.php old mode 100644 new mode 100755 diff --git a/core/c/typefileupload.php b/core/c/typefileupload.php old mode 100644 new mode 100755 diff --git a/core/c/typehidden.php b/core/c/typehidden.php old mode 100644 new mode 100755 diff --git a/core/c/typeimagesubmit.php b/core/c/typeimagesubmit.php old mode 100644 new mode 100755 diff --git a/core/c/typenumber.php b/core/c/typenumber.php old mode 100644 new mode 100755 diff --git a/core/c/typeopenany.php b/core/c/typeopenany.php new file mode 100755 index 0000000..ce4c083 --- /dev/null +++ b/core/c/typeopenany.php @@ -0,0 +1,40 @@ + '', + self::FORM_ATTRIBUTE_ID => '', + self::FORM_ATTRIBUTE_CLASS => '', + self::FORM_ATTRIBUTE_ANY => '', + self::FORM_ATTRIBUTE_HREF => '' + ); + + /** + * @param $attributes + * @return mixed + */ + public function loadElement($attributes) + { + parent::__construct( $this->_attributes ); + $this->_setElement(); + $this->_setAttributes( self::loadAttributeValues( $attributes ) ); + return $this->getElement(); + } + + /** + * just the opening div element + */ + private function _setElement( ) + { + $this->_element = '' . 'VALUE' . "\n"; + } +} diff --git a/core/c/typeopendiv.php b/core/c/typeopendiv.php old mode 100644 new mode 100755 diff --git a/core/c/typeoption.php b/core/c/typeoption.php old mode 100644 new mode 100755 diff --git a/core/c/typepassword.php b/core/c/typepassword.php old mode 100644 new mode 100755 diff --git a/core/c/typeradio.php b/core/c/typeradio.php old mode 100644 new mode 100755 diff --git a/core/c/typerange.php b/core/c/typerange.php old mode 100644 new mode 100755 diff --git a/core/c/typereset.php b/core/c/typereset.php old mode 100644 new mode 100755 diff --git a/core/c/typesearch.php b/core/c/typesearch.php old mode 100644 new mode 100755 diff --git a/core/c/typeselect.php b/core/c/typeselect.php old mode 100644 new mode 100755 diff --git a/core/c/typesubmit.php b/core/c/typesubmit.php old mode 100644 new mode 100755 diff --git a/core/c/typetelefon.php b/core/c/typetelefon.php old mode 100644 new mode 100755 diff --git a/core/c/typetext.php b/core/c/typetext.php old mode 100644 new mode 100755 diff --git a/core/c/typetextarea.php b/core/c/typetextarea.php old mode 100644 new mode 100755 diff --git a/core/c/typeurl.php b/core/c/typeurl.php old mode 100644 new mode 100755 diff --git a/core/f/form.php b/core/f/form.php index 4124bf2..3ca020f 100644 --- a/core/f/form.php +++ b/core/f/form.php @@ -2,7 +2,9 @@ namespace Nibiru\Factory; use Nibiru\Form\TypeButton; use Nibiru\Form\TypeCheckbox; +use Nibiru\Form\TypeCloseAny; use Nibiru\Form\TypeCloseDiv; +use Nibiru\Form\TypeCloseSpan; use Nibiru\Form\TypeColor; use Nibiru\Form\TypeDatetime; use Nibiru\Form\TypeEmail; @@ -11,7 +13,9 @@ use Nibiru\Form\TypeHidden; use Nibiru\Form\TypeImageSubmit; use Nibiru\Form\TypeLabel; use Nibiru\Form\TypeNumber; +use Nibiru\Form\TypeOpenAny; use Nibiru\Form\TypeOpenDiv; +use Nibiru\Form\TypeOpenSpan; use Nibiru\Form\TypeOption; use Nibiru\Form\TypePassword; use Nibiru\Form\TypeRadio; @@ -506,4 +510,25 @@ class Form self::setElement( new TypeCloseDiv() ); self::assemble( self::getElement()->loadElement( false ) ); } + + /** + * @desc adds an opening span to the form element + * @param $attributes + * @return void + */ + public static function addOpenAny( $attributes ) + { + self::setElement( new TypeOpenAny() ); + self::assemble( self::getElement()->loadElement( $attributes )); + } + + /** + * @desc adds a closing span to the form element + * @return void + */ + public static function addCloseAny( $attributes ) + { + self::setElement( new TypeCloseAny() ); + self::assemble( self::getElement()->loadElement( $attributes )); + } } diff --git a/core/framework.php b/core/framework.php index c694100..930799f 100644 --- a/core/framework.php +++ b/core/framework.php @@ -83,6 +83,8 @@ require_once __DIR__ . '/c/typeurl.php'; require_once __DIR__ . '/c/typelabel.php'; require_once __DIR__ . '/c/typeopendiv.php'; require_once __DIR__ . '/c/typeclosediv.php'; +require_once __DIR__ . '/c/typeopenany.php'; +require_once __DIR__ . '/c/typecloseany.php'; require_once __DIR__ . '/i/view.php'; require_once __DIR__ . '/c/view.php'; require_once __DIR__ . '/i/controller.php'; diff --git a/core/i/auth.php b/core/i/auth.php old mode 100644 new mode 100755 diff --git a/core/i/controller.php b/core/i/controller.php old mode 100644 new mode 100755 diff --git a/core/i/db.php b/core/i/db.php old mode 100644 new mode 100755 diff --git a/core/i/engine.php b/core/i/engine.php old mode 100644 new mode 100755 diff --git a/core/i/form.php b/core/i/form.php old mode 100644 new mode 100755 index db43208..11622bd --- a/core/i/form.php +++ b/core/i/form.php @@ -50,6 +50,8 @@ interface IForm const FORM_ATTRIBUTE_TABINDEX = 'tabindex'; const FORM_ATTRIBUTE_DISABLED = 'disabled'; const FORM_ATTRIBUTE_PATTERN = 'pattern'; + const FORM_ATTRIBUTE_ANY = 'any'; + const FORM_ATTRIBUTE_HREF = 'href'; /** * @desc loads the current Form element to the form diff --git a/core/i/mysql.php b/core/i/mysql.php old mode 100644 new mode 100755 diff --git a/core/i/pdo.php b/core/i/pdo.php old mode 100644 new mode 100755 diff --git a/core/i/postgresql.php b/core/i/postgresql.php old mode 100644 new mode 100755 diff --git a/core/i/psql.php b/core/i/psql.php old mode 100644 new mode 100755 diff --git a/core/i/view.php b/core/i/view.php old mode 100644 new mode 100755 diff --git a/core/t/messages.php b/core/t/messages.php old mode 100644 new mode 100755 diff --git a/nibiru b/nibiru new file mode 100755 index 0000000..cffcd39 Binary files /dev/null and b/nibiru differ