Version 0.9.5 beta - changed request, get, post logic in order to jsut accept parameters, and also the full array.
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Nibiru;
|
namespace Nibiru;
|
||||||
|
use Cassandra\Type\Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User - stephan
|
* User - stephan
|
||||||
* Date - 24.01.17
|
* Date - 24.01.17
|
||||||
@@ -11,142 +13,178 @@ namespace Nibiru;
|
|||||||
|
|
||||||
class Controller extends View
|
class Controller extends View
|
||||||
{
|
{
|
||||||
private static $_instance;
|
private static $_instance;
|
||||||
private $_config = array();
|
private $_config = array();
|
||||||
protected $_request = array();
|
protected $_request = array();
|
||||||
protected $_get = array();
|
protected $_get = array();
|
||||||
protected $_post = array();
|
protected $_post = array();
|
||||||
private $_current = array();
|
private $_current = array();
|
||||||
private $_next = array();
|
private $_next = array();
|
||||||
private $_controller = "index";
|
private $_controller = "index";
|
||||||
|
|
||||||
protected function __construct()
|
protected function __construct()
|
||||||
{
|
{
|
||||||
$this->_setConfig(Config::getInstance()->getConfig());
|
$this->_setConfig(Config::getInstance()->getConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getInstance(): View
|
public static function getInstance(): View
|
||||||
{
|
{
|
||||||
$className = get_called_class();
|
$className = get_called_class();
|
||||||
if( self::$_instance == null )
|
if( self::$_instance == null )
|
||||||
{
|
{
|
||||||
self::$_instance = new $className();
|
self::$_instance = new $className();
|
||||||
}
|
}
|
||||||
return self::$_instance;
|
return self::$_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getConfig()
|
protected function getConfig()
|
||||||
{
|
{
|
||||||
return $this->_config;
|
return $this->_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $config
|
* @param array $config
|
||||||
*/
|
*/
|
||||||
protected function _setConfig( $config )
|
protected function _setConfig( $config )
|
||||||
{
|
{
|
||||||
$this->_config = $config;
|
$this->_config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getController()
|
public function getController()
|
||||||
{
|
{
|
||||||
return $this->_controller;
|
return $this->_controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $controller
|
* @param string $controller
|
||||||
*/
|
*/
|
||||||
protected function setController( $controller )
|
protected function setController( $controller )
|
||||||
{
|
{
|
||||||
$this->_controller = $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() )
|
/**
|
||||||
{
|
* @param $template
|
||||||
if(is_array($varname))
|
* @param $page
|
||||||
{
|
*/
|
||||||
$template->assign($varname);
|
public function action( $template, $page )
|
||||||
}
|
{
|
||||||
}
|
$this->_setCurrent( $this->getNext() );
|
||||||
|
$this->_setNext( $page );
|
||||||
|
$template->display( $this->getNext() );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public function varname( $template, $varname = array() )
|
||||||
* @return array
|
{
|
||||||
*/
|
if(is_array($varname))
|
||||||
protected function getCurrent()
|
{
|
||||||
{
|
$template->assign($varname);
|
||||||
return $this->_current;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $current
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function _setCurrent( $current )
|
protected function getCurrent()
|
||||||
{
|
{
|
||||||
$this->_current = $current;
|
return $this->_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @param array $current
|
||||||
*/
|
*/
|
||||||
protected function getNext()
|
private function _setCurrent( $current )
|
||||||
{
|
{
|
||||||
return $this->_next;
|
$this->_current = $current;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $next
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function _setNext( $next )
|
protected function getNext()
|
||||||
{
|
{
|
||||||
$this->_next = $next;
|
return $this->_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @param array $next
|
||||||
*/
|
*/
|
||||||
public function getPost()
|
public function _setNext( $next )
|
||||||
{
|
{
|
||||||
return $_POST;
|
$this->_next = $next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @param string $param
|
||||||
*/
|
* @param bool $params
|
||||||
public function getGet()
|
* @return string|null
|
||||||
{
|
*/
|
||||||
return $_GET;
|
public function getPost( string $param, bool $params = false ) :mixed
|
||||||
}
|
{
|
||||||
|
if($param!="")
|
||||||
|
{
|
||||||
|
return $_POST[$param];
|
||||||
|
}
|
||||||
|
elseif($params)
|
||||||
|
{
|
||||||
|
return $_POST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @param string $param
|
||||||
*/
|
* @param bool $params
|
||||||
public function getRequest()
|
* @return string|null
|
||||||
{
|
*/
|
||||||
return $_REQUEST;
|
public function getGet( string $param, bool $params = false ) :?string
|
||||||
}
|
{
|
||||||
|
if($param!="")
|
||||||
|
{
|
||||||
|
return $_GET[$param];
|
||||||
|
}
|
||||||
|
elseif($params)
|
||||||
|
{
|
||||||
|
return $_GET;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @param string $param
|
||||||
*/
|
* @param bool $params
|
||||||
public function getServer()
|
* @return mixed
|
||||||
{
|
*/
|
||||||
return $_SERVER;
|
public function getRequest( string $param, bool $params = false ) :?string
|
||||||
}
|
{
|
||||||
|
if($param!="")
|
||||||
|
{
|
||||||
|
return $_REQUEST[$param];
|
||||||
|
}
|
||||||
|
elseif($params)
|
||||||
|
{
|
||||||
|
return $_REQUEST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $param
|
||||||
|
* @param bool $params
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getServer( string $param, bool $params = false ) :?string
|
||||||
|
{
|
||||||
|
if($param!="")
|
||||||
|
{
|
||||||
|
return $_SERVER[$param];
|
||||||
|
}
|
||||||
|
elseif($params)
|
||||||
|
{
|
||||||
|
return $_SERVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user