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:
@@ -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.
|
||||
}
|
||||
}
|
||||
@@ -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 )
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user