REFACTORING: updated the base template with some examples, also added annotations for autocomplete in the core view and controller core.

This commit is contained in:
Stephan Kasdorf
2019-11-03 23:30:44 +01:00
parent 70dccc3f15
commit 7306db234e
20 changed files with 291 additions and 132 deletions

View File

@@ -0,0 +1,23 @@
<?php
namespace Nibiru;
use Nibiru\Adapter\Controller;
class controllerController extends Controller
{
public function pageAction()
{
View::assign([
'name' => 'rapid prototyping framework',
'title' => 'Nibiru Controller Example',
'css' => Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS]["smarty.css"],
'js' => Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS]["smarty.js"]
]);
}
public function navigationAction()
{
JsonNavigation::getInstance()->loadJsonNavigationArray();
}
}

View File

@@ -0,0 +1,88 @@
<?php
namespace Nibiru;
use Nibiru\Adapter\Controller;
use Nibiru\Factory\Form;
class formsController extends Controller
{
private $form;
public function __construct()
{
Form::create();
Form::addTypeLabel(
array(
'value' => 'Full Name',
'for' => 'full-name',
'class' => 'contacts-label'
)
);
Form::addInputTypeText(
array(
'name' => 'full-name',
'required' => 'required',
'id' => 'full-name',
'class' => 'contacts-input form-control'
),
array(
'class' => 'input-text'
)
);
Form::addTypeLabel(
array(
'value' => 'Email',
'for' => 'email',
'class' => 'contacts-label'
)
);
Form::addInputTypeText(
array(
'name' => 'email',
'required' => 'required',
'id' => 'email',
'class' => 'contacts-input form-control'
),
array(
'class' => 'input-email'
)
);
Form::addTypeButton(
array(
'class' => 'btn-block btn-info',
'name' => 'Send Message'
)
);
$this->form = Form::addForm(
array(
'name' => 'newregister',
'method' => 'post',
'action' => 'YOURPOSTURL',
'target' => '_self'
)
);
}
public function pageAction()
{
View::assign([
'name' => 'rapid prototyping framework',
'title' => 'Nibiru Forms Example',
'formdata' => $this->form,
'css' => Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS]["smarty.css"],
'js' => Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS]["smarty.js"]
]);
}
public function navigationAction()
{
JsonNavigation::getInstance()->loadJsonNavigationArray();
}
}

View File

@@ -12,21 +12,15 @@ use Nibiru\Adapter\Controller;
class indexController extends Controller
{
public function __construct()
{
}
public function pageAction()
{
View::getInstance()->assign(
array(
'name' => 'Beispielseite',
'title' => 'Stephan Kasdorf - Nibiru Example',
View::assign([
'name' => 'rapid prototyping framework',
'title' => 'Nibiru Example Startpage',
'css' => Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS]["smarty.css"],
'js' => Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS]["smarty.js"]
)
);
]);
}
public function navigationAction()

View File

@@ -1,6 +1,8 @@
{
"navigation" :
{
"Home": { "link": "/", "tooltip": "Home", "icon": "icon icon-home", "footer": "false" }
"Home": { "link": "/", "tooltip": "Home", "icon": "icon icon-home", "footer": "false" },
"Controller": { "link": "/controller", "tooltip": "Controller", "icon": "icon icon-pencil", "footer": "false" },
"Forms": { "link": "/forms", "tooltip": "Forms", "icon": "icon icon-clipboard", "footer": "false" }
}
}

View File

@@ -36,7 +36,7 @@ smarty.css[] = "public/css/v3/toolkit-inverse.css"
smarty.css[] = "public/css/v3/application.css"
smarty.css[] = "public/css/v3/jquery-ui.css"
smarty.css[] = "public/css/v3/nibiru-debug.css"
smarty.css[] = "public/css/v3/tiamat-form.css"
;;smarty.css[] = "public/css/v3/tiamat-form.css"
smarty.js[] = "public/js/v3/jquery.min.js"
smarty.js[] = "public/js/v3/tether.min.js"
smarty.js[] = "public/js/v3/jquery-ui.js"
@@ -48,7 +48,8 @@ smarty.js[] = "public/js/v3/nibiru-debug.js"
[ROUTING]
route[index] = "/"
route[example] = "/example"
route[controller] = "/controller"
route[forms] = "/forms"
[DATABASE]
username = "YOURUSER"

View File

@@ -0,0 +1,31 @@
{include 'shared/header.tpl'}
<body>
<div class="container">
<div class="with-iconav">
{include file="navigation.tpl"}
</div>
<div class="col-sm-12 content">
<div class="dashhead">
<div class="dashhead-titles">
<h6 class="dashhead-subtitle">{$name}</h6>
<h2 class="dashhead-title">{$title}</h2>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="col-lg-12">
<div class="col-md-12 text-center"><img src="public/img/logos/MediumSquareLogo.png"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="col-md-12 text-center">This is just a basic example for a controller, for more details read this section: <a href="https://www.nibiru-framework.com/documentation/controller">Controllers</a>. </div>
</div>
</div>
</div>
{include 'shared/footer.tpl'}
</body>
</html>

View File

@@ -0,0 +1,34 @@
{include 'shared/header.tpl'}
<body>
<div class="container">
<div class="with-iconav">
{include file="navigation.tpl"}
</div>
<div class="col-sm-12 content">
<div class="dashhead">
<div class="dashhead-titles">
<h6 class="dashhead-subtitle">Rapid Prototyping Framework</h6>
<h2 class="dashhead-title">{$title}</h2>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="col-md-12 text-center"><img src="public/img/logos/MediumSquareLogo.png"></div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
{$formdata}
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="col-md-12 text-center">This is just a basic example for a form, for more details read this section: <a href="https://www.nibiru-framework.com/documentation/forms">Forms</a>. </div>
</div>
</div>
</div>
{include 'shared/footer.tpl'}
</body>
</html>

View File

@@ -7,39 +7,25 @@
<div class="col-sm-12 content">
<div class="dashhead">
<div class="dashhead-titles">
<h6 class="dashhead-subtitle">Rapid Prototyping Framework</h6>
<h2 class="dashhead-title">Nibiru</h2>
<h6 class="dashhead-subtitle">{$name}</h6>
<h2 class="dashhead-title">{$title}</h2>
</div>
<div class="btn-toolbar dashhead-toolbar">
<div class="btn-toolbar-item input-with-icon">
<input type="text" value="01/01/15 - 01/08/15" class="form-control" data-provide="datepicker">
<span class="icon icon-calendar"></span>
<div class="row">
<div class="col-lg-12">
<div class="col-lg-12">
<div class="col-md-12 text-center"><img src="public/img/logos/MediumSquareLogo.png"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="col-md-12 text-center">This is just a basic example, for more details read this section: <a href="https://www.nibiru-framework.com/">Nibiru Framework</a>. </div>
</div>
</div>
</div>
</div>
</div>
<div id="docsModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Example modal</h4>
</div>
<div class="modal-body">
<p>You're looking at an example modal in the dashboard theme.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Cool, got it!</button>
</div>
</div>
</div>
</div>
{include 'shared/footer.tpl'}
</body>
</html>

View File

@@ -13,6 +13,11 @@ use Nibiru;
abstract class Controller extends Nibiru\Controller implements IController
{
public function __construct()
{
//basic constructor for the Controller can be overwritten
}
/**
* This should be part of any extended controller
* class in order to implement a page structure

View File

@@ -16,6 +16,9 @@ class Auth extends Controller implements IAuth
private $_username = "";
private $_password = "";
/**
* Auth constructor.
*/
protected function __construct()
{
parent::__construct();
@@ -23,7 +26,10 @@ class Auth extends Controller implements IAuth
}
public static function getInstance()
/**
* @return View
*/
public static function getInstance(): View
{
$className = get_called_class();
if( self::$_instance == null )
@@ -33,6 +39,11 @@ class Auth extends Controller implements IAuth
return self::$_instance;
}
/**
* @param $login
* @param $password
* @return bool
*/
public function auth( $login, $password )
{
// TODO: Implement auth($username, $password) method.
@@ -41,7 +52,7 @@ class Auth extends Controller implements IAuth
if(!array_key_exists('auth', $_SESSION))
{
$user_password = Pdo::query("SELECT DES_DECRYPT(user_pass, '".Config::getInstance()->getConfig()["SECURITY"]["password_hash"]."') AS pass FROM user WHERE user_login = '".$login."';");
$user_password = Pdo::query("SELECT DES_DECRYPT(user_pass, '".Config::getInstance()->getConfig()[IView::NIBIRU_SECURITY]["password_hash"]."') AS pass FROM user WHERE user_login = '".$login."';");
if( $user_password["pass"] == $password )
{
$session_id = session_id();
@@ -103,23 +114,4 @@ class Auth extends Controller implements IAuth
{
$this->_password = $password;
}
/**
* This should be part of any extended controller
* class in order to implement a page structure
* @return array
*/
public function pageAction()
{
// TODO: Implement pageAction() method.
}
/**
* This is the part where you can add titles to
* your page navigation.
*/
public function navigationAction()
{
// TODO: Implement navigationAction() method.
}
}

View File

@@ -25,7 +25,7 @@ class Controller extends View
$this->_setConfig(Config::getInstance()->getConfig());
}
public static function getInstance()
public static function getInstance(): View
{
$className = get_called_class();
if( self::$_instance == null )

View File

@@ -22,7 +22,7 @@ class JsonNavigation extends Config
private static $_name = false;
private static $_section_name = self::NAVIGATION;
public static function getInstance()
public static function getInstance(): JsonNavigation
{
parent::getInstance();
self::setFileContentString();
@@ -36,7 +36,7 @@ class JsonNavigation extends Config
/**
* @return string
*/
protected static function getSectionName()
protected static function getSectionName(): string
{
return self::$_section_name;
}
@@ -44,23 +44,23 @@ class JsonNavigation extends Config
/**
* @param string $section_name
*/
private static function setSectionName( $section_name )
private static function setSectionName( string $section_name )
{
self::$_section_name = $section_name;
}
/**
* @return boolean
*/
protected static function getName()
/**
* @return string
*/
protected static function getName(): string
{
return self::$_name;
}
/**
* @param boolean $name
*/
private static function setName( $name )
/**
* @param $name
*/
private static function setName( string $name )
{
self::$_name = $name;
}
@@ -74,7 +74,7 @@ class JsonNavigation extends Config
}
/**
* @param null $file_content
* Content String
*/
private static function setFileContentString( )
{
@@ -84,30 +84,31 @@ class JsonNavigation extends Config
/**
* @return array
*/
protected static function getFileContentArray( )
protected static function getFileContentArray( ): array
{
return self::$_file_content_array;
}
/**
* @param array $file_content_array
* will set the file Content array
*/
private static function setFileContentArray( )
{
self::$_file_content_array = file( Settings::SETTINGS_PATH . parent::getInstance()->getConfig()["SETTINGS"][self::getSectionName()] );
}
/**
* @return array
*/
protected static function getNavigation( )
/**
* @return \RecursiveIteratorIterator
*/
protected static function getNavigation( ): \RecursiveIteratorIterator
{
return self::$_navigation;
}
/**
* @param array $navigation
*/
/**
* Will load the navigation json file to the $_navigation
* variable
*/
private static function setNavigation( )
{
self::$_navigation = new \RecursiveIteratorIterator(
@@ -139,8 +140,9 @@ class JsonNavigation extends Config
/**
* Loads the navigation from a json file into
* the view, making the variables available
*/
public function loadJsonNavigationArray( $name = false )
* @param string $name
*/
public function loadJsonNavigationArray( string $name = '' )
{
if( $name )
{

View File

@@ -12,14 +12,6 @@ class View implements IView
{
private static $_instance;
const NIBIRU_SETTINGS = "SETTINGS";
const NIBIRU_URL = "pageurl";
const NIBIRU_ERROR = "ERROR";
const NIBIRU_SECURITY = "SECURITY";
const NIBIRU_ROUTING = "ROUTING";
const NIBIRU_EMAIL = "EMAIL";
const NIBIRU_FILE_END = ".tpl";
private static $smarty = array();
private static $engine = array();
@@ -36,7 +28,10 @@ class View implements IView
self::_setEngine();
}
public static function getInstance()
/**
* @return View
*/
public static function getInstance(): View
{
$className = get_called_class();
if( self::$_instance == null )
@@ -47,7 +42,18 @@ class View implements IView
}
/**
* @return array
* @param array $varname
*/
public static function assign( $varname = array() )
{
if(is_array($varname))
{
Controller::getInstance()->varname( self::getInstance()->getEngine(), $varname );
}
}
/**
* @return \Smarty
*/
public function getEngine(): \Smarty
{
@@ -68,17 +74,6 @@ class View implements IView
self::$engine->assign('debuging', Config::getInstance()->getConfig()[Engine::T_ENGINE]["debugbar"]);
}
/**
* @param array $varname
*/
public function assign( $varname = array() )
{
if(is_array($varname))
{
Controller::getInstance()->varname( $this->getEngine(), $varname );
}
}
/**
* @param $page
*/

View File

@@ -42,7 +42,7 @@ class Form
* @desc is used internaly for assambly only
* @param $option
*/
private static function assambleOptions( $option )
private static function assembleOptions( $option )
{
if($option == false)
{
@@ -76,7 +76,7 @@ class Form
* @desc is used internally for assambly only
* @param $element
*/
private static function assamble( $element )
private static function assemble( $element )
{
if( self::getDiv() )
{
@@ -174,7 +174,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeText() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -188,7 +188,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeSubmit() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -202,7 +202,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeTextarea() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -217,7 +217,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeRadio() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -231,7 +231,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeCheckbox() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -245,7 +245,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypePassword() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -259,7 +259,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeDate() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -273,7 +273,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeEmail() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -287,7 +287,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeColor() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -301,7 +301,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeDatetime() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -315,7 +315,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeFileUpload() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -329,7 +329,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeHidden() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -343,7 +343,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeImageSubmit() );
self::assamble( self::getElement()->loadElement( $attrbutes ) );
self::assemble( self::getElement()->loadElement( $attrbutes ) );
}
/**
@@ -357,7 +357,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeNumber() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -372,7 +372,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeRange() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -386,7 +386,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeReset() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -400,7 +400,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeSearch() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -414,7 +414,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeTelefon() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -428,7 +428,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeUrl() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -443,8 +443,8 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeSelect() );
self::assamble( self::displaySelect( self::getElement()->loadElement( $attributes ) ) );
self::assambleOptions( false );
self::assemble( self::displaySelect( self::getElement()->loadElement( $attributes ) ) );
self::assembleOptions( false );
}
/**
@@ -459,7 +459,7 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeButton() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -469,7 +469,7 @@ class Form
public static function addSelectOption( $attributes )
{
self::setElement( new TypeOption() );
self::assambleOptions( self::getElement()->loadElement( $attributes ) );
self::assembleOptions( self::getElement()->loadElement( $attributes ) );
}
/**
@@ -483,6 +483,6 @@ class Form
self::setDiv( $div );
}
self::setElement( new TypeLabel() );
self::assamble( self::getElement()->loadElement( $attributes ) );
self::assemble( self::getElement()->loadElement( $attributes ) );
}
}

View File

@@ -10,5 +10,11 @@ namespace Nibiru;
*/
interface IView
{
const NIBIRU_SETTINGS = "SETTINGS";
const NIBIRU_URL = "pageurl";
const NIBIRU_ERROR = "ERROR";
const NIBIRU_SECURITY = "SECURITY";
const NIBIRU_ROUTING = "ROUTING";
const NIBIRU_EMAIL = "EMAIL";
const NIBIRU_FILE_END = ".tpl";
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB