Skip to content

Commit

Permalink
Version 0.9.6 beta - added new form elements, also added a nibiru bin…
Browse files Browse the repository at this point in the history
…ary in order to create modules and plugins.
  • Loading branch information
bittomine committed Apr 3, 2023
1 parent fbe7f59 commit b1bded6
Show file tree
Hide file tree
Showing 60 changed files with 204 additions and 66 deletions.
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Empty file modified core/c/auth.php
100644 → 100755
Empty file.
17 changes: 15 additions & 2 deletions core/c/autoloader.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,22 @@ public function runRequireOnce()
{
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(
Expand Down
Empty file modified core/c/config.php
100644 → 100755
Empty file.
19 changes: 15 additions & 4 deletions core/c/controller.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -54,19 +55,29 @@ protected function _setConfig( $config )
}

/**
* @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];
}
}

/**
Expand Down
Empty file modified core/c/debug.php
100644 → 100755
Empty file.
Empty file modified core/c/dispatcher.php
100644 → 100755
Empty file.
Empty file modified core/c/display.php
100644 → 100755
Empty file.
Empty file modified core/c/engine.php
100644 → 100755
Empty file.
Empty file modified core/c/form.php
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions core/c/formattributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ protected function _setAttributes( $attributes )
$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);
Expand All @@ -88,6 +89,7 @@ protected function _setAttributes( $attributes )
$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);
}

/**
Expand Down
92 changes: 37 additions & 55 deletions core/c/jsonnavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,61 +137,43 @@ public function displayRawJsonNavigation( )
}
}

/**
* 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);
}
}
14 changes: 12 additions & 2 deletions core/c/model.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private function generateClassByTableName( $table = false )
$numItems = count($tablefields);
$i = 0;
$fieldarray = "";
$parameters = "";
foreach($this->getTables()[$table] as $field)
{
if( $i==0 )
Expand All @@ -87,15 +88,25 @@ private function generateClassByTableName( $table = false )

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);
Expand All @@ -119,7 +130,6 @@ private function generateClassByTableName( $table = false )
$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);
Expand Down
7 changes: 7 additions & 0 deletions core/c/nibiru.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace Nibiru;

class Nibiru
{
//TODO: Generator Class in order to generate Modules fast
}
Empty file modified core/c/pdo.php
100644 → 100755
Empty file.
Empty file modified core/c/postgresql.php
100644 → 100755
Empty file.
Empty file modified core/c/psql.php
100644 → 100755
Empty file.
Empty file modified core/c/registry.php
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion core/c/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static function setCurRoute( )
/**
* @return mixed
*/
public function getRoutes()
public static function getRoutes()
{
return self::$_routes;
}
Expand Down
Empty file modified core/c/settings.php
100644 → 100755
Empty file.
Empty file modified core/c/table.php
100644 → 100755
Empty file.
Empty file modified core/c/typecheckbox.php
100644 → 100755
Empty file.
39 changes: 39 additions & 0 deletions core/c/typecloseany.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Copyright 2020 Nibiru Framework
* Licence: BSD 4-Old License
* Author: Stephan Kasdorf
* File: typeclosediv.php
* Date: 05.09.20
*/
class TypeCloseAny extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_VALUE => '',
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 = '</ANY>' . "\n";
}
}
Empty file modified core/c/typeclosediv.php
100644 → 100755
Empty file.
Empty file modified core/c/typecolor.php
100644 → 100755
Empty file.
Empty file modified core/c/typedate.php
100644 → 100755
Empty file.
Empty file modified core/c/typedatetime.php
100644 → 100755
Empty file.
Empty file modified core/c/typeemail.php
100644 → 100755
Empty file.
Empty file modified core/c/typefileupload.php
100644 → 100755
Empty file.
Empty file modified core/c/typehidden.php
100644 → 100755
Empty file.
Empty file modified core/c/typeimagesubmit.php
100644 → 100755
Empty file.
Empty file modified core/c/typenumber.php
100644 → 100755
Empty file.
40 changes: 40 additions & 0 deletions core/c/typeopenany.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
namespace Nibiru\Form;
use Nibiru\Adapter;
/**
* Copyright 2020 Nibiru Framework
* Licence: BSD 4-Old License
* Author: Stephan Kasdorf
* File: typeopendiv.php
* Date: 05.09.20
*/
class TypeOpenAny extends FormAttributes implements IForm
{
private $_attributes = array(
self::FORM_VALUE => '',
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 = '<ANY href="HREF" ID CLASS>' . 'VALUE' . "\n";
}
}
Empty file modified core/c/typeopendiv.php
100644 → 100755
Empty file.
Empty file modified core/c/typeoption.php
100644 → 100755
Empty file.
Empty file modified core/c/typepassword.php
100644 → 100755
Empty file.
Empty file modified core/c/typeradio.php
100644 → 100755
Empty file.
Empty file modified core/c/typerange.php
100644 → 100755
Empty file.
Empty file modified core/c/typereset.php
100644 → 100755
Empty file.
Empty file modified core/c/typesearch.php
100644 → 100755
Empty file.
Empty file modified core/c/typeselect.php
100644 → 100755
Empty file.
Empty file modified core/c/typesubmit.php
100644 → 100755
Empty file.
Empty file modified core/c/typetelefon.php
100644 → 100755
Empty file.
Empty file modified core/c/typetext.php
100644 → 100755
Empty file.
Empty file modified core/c/typetextarea.php
100644 → 100755
Empty file.
Empty file modified core/c/typeurl.php
100644 → 100755
Empty file.
25 changes: 25 additions & 0 deletions core/f/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -11,7 +13,9 @@
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;
Expand Down Expand Up @@ -506,4 +510,25 @@ public static function addCloseDiv( )
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 ));
}
}
Loading

0 comments on commit b1bded6

Please sign in to comment.