Improved: The Router now accepts actions, either trough the _action as parameter, or on the URL pattern after the controller name Example: http://youdomain/[controllername]/[actionname]/ It is now possible to load as many navigations on the page as wanted by passing the name to the JsonNavigation::getInstance()->loadJsonNavigationArray('[NAME]'); call in the navigationAction of the Controller Building forms by simple adding the namespace use Nibiru\Factory\Form; and calling Example: Form::addInputTypeText( array( 'name' => 'lastname', 'value' => 'placeholder' ) ); To finalize the form the last call should be something like this: Form::addForm( array('name' => 'testform', 'method' => 'post', 'action' => '/' . Router::getInstance()->currentPage(), 'target' => '_self') ); The Database design has fully been refactored, now it contains an autoloading mechanism which can be triggert by createing a database folder in the application folder, a Example file is in the folder applicatoin/database The Database access can now be implemented anywhere in your application by adding the namespace to your database accessing Logic: use Nibiru\Factory\Db;
145 lines
2.2 KiB
PHP
145 lines
2.2 KiB
PHP
<?php
|
|
namespace Nibiru;
|
|
|
|
/**
|
|
* User - stephan
|
|
* Date - 24.01.17
|
|
* Time - 22:01
|
|
* @author - Stephan Kasdorf
|
|
* @category - [PLEASE SPECIFIY]
|
|
* @license - BSD License
|
|
*/
|
|
class Controller
|
|
{
|
|
private static $_instance;
|
|
private $_config = array();
|
|
protected $_request = array();
|
|
protected $_get = array();
|
|
protected $_post = array();
|
|
private $_current = array();
|
|
private $_next = array();
|
|
private $_controller = "index";
|
|
|
|
protected function __construct()
|
|
{
|
|
$this->_setConfig(Config::getInstance()->getConfig());
|
|
}
|
|
|
|
public static function getInstance()
|
|
{
|
|
$className = get_called_class();
|
|
if( self::$_instance == null )
|
|
{
|
|
self::$_instance = new $className();
|
|
}
|
|
return self::$_instance;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function getConfig()
|
|
{
|
|
return $this->_config;
|
|
}
|
|
|
|
/**
|
|
* @param array $config
|
|
*/
|
|
protected function _setConfig( $config )
|
|
{
|
|
$this->_config = $config;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getController()
|
|
{
|
|
return $this->_controller;
|
|
}
|
|
|
|
/**
|
|
* @param string $controller
|
|
*/
|
|
protected function setController( $controller )
|
|
{
|
|
$this->_controller = $controller;
|
|
}
|
|
|
|
/**
|
|
* @param $template
|
|
* @param $page
|
|
*/
|
|
public function action( $template, $page )
|
|
{
|
|
$this->_setCurrent( $this->getNext() );
|
|
$this->_setNext( $page );
|
|
$template->display( $this->getNext() );
|
|
}
|
|
|
|
public function varname( $template, $varname = array() )
|
|
{
|
|
if(is_array($varname))
|
|
{
|
|
$template->assign($varname);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function getCurrent()
|
|
{
|
|
return $this->_current;
|
|
}
|
|
|
|
/**
|
|
* @param array $current
|
|
*/
|
|
private function _setCurrent( $current )
|
|
{
|
|
$this->_current = $current;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function getNext()
|
|
{
|
|
return $this->_next;
|
|
}
|
|
|
|
/**
|
|
* @param array $next
|
|
*/
|
|
public function _setNext( $next )
|
|
{
|
|
$this->_next = $next;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getPost()
|
|
{
|
|
return $_POST;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getGet()
|
|
{
|
|
return $_GET;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getRequest()
|
|
{
|
|
return $_REQUEST;
|
|
}
|
|
|
|
} |