Refactoring old code
More like removing old code. Added some memento notes for myself in there.
This commit is contained in:
parent
6a1056306f
commit
09d1744910
2 changed files with 21 additions and 72 deletions
|
@ -101,13 +101,6 @@ class Controller extends Object
|
||||||
$module = new Module();
|
$module = new Module();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determines if the module is private and should be, well, private
|
|
||||||
// @todo Is this even a thing anymore? thinking this was replaced with putting code in ./classes
|
|
||||||
if ($module->private == true)
|
|
||||||
{
|
|
||||||
Browser::goHome();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determines if we need to serve over HTTP or HTTPS
|
// Determines if we need to serve over HTTP or HTTPS
|
||||||
if ($module->secure == false && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'])
|
if ($module->secure == false && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'])
|
||||||
{
|
{
|
||||||
|
@ -232,11 +225,6 @@ class Controller extends Object
|
||||||
// Attempts to execute the default method
|
// Attempts to execute the default method
|
||||||
if ($default_method == $role_method || method_exists($module, $default_method))
|
if ($default_method == $role_method || method_exists($module, $default_method))
|
||||||
{
|
{
|
||||||
if (isset($requested_id))
|
|
||||||
{
|
|
||||||
$module->setRequest(['id' => $requested_id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Starts a timer before the module is executed
|
// Starts a timer before the module is executed
|
||||||
if ($profiler)
|
if ($profiler)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,19 +43,12 @@ class Module extends Object
|
||||||
*/
|
*/
|
||||||
protected $db = null;
|
protected $db = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Fluid or Fixed?
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
protected $fluid = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page Title
|
* Page Title
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var string, null by default
|
* @var string, null by default
|
||||||
|
* @todo Move to public scope
|
||||||
*/
|
*/
|
||||||
protected $title = null;
|
protected $title = null;
|
||||||
|
|
||||||
|
@ -64,6 +57,7 @@ class Module extends Object
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var string, null by default
|
* @var string, null by default
|
||||||
|
* @todo Move to public scope
|
||||||
*/
|
*/
|
||||||
protected $description = null;
|
protected $description = null;
|
||||||
|
|
||||||
|
@ -72,6 +66,7 @@ class Module extends Object
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var string, null by default
|
* @var string, null by default
|
||||||
|
* @todo Move to public scope
|
||||||
*/
|
*/
|
||||||
protected $keywords = null;
|
protected $keywords = null;
|
||||||
|
|
||||||
|
@ -80,39 +75,19 @@ class Module extends Object
|
||||||
*
|
*
|
||||||
* Whether or not the page should be loaded via SSL.
|
* Whether or not the page should be loaded via SSL.
|
||||||
*
|
*
|
||||||
* @access protected
|
* @var boolean defaults to false
|
||||||
* @var boolean, null by default
|
|
||||||
*/
|
*/
|
||||||
protected $secure = null;
|
public $secure = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Private
|
|
||||||
*
|
|
||||||
* Whether or not the page can be accessed directly.
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var boolean, false by default
|
|
||||||
*/
|
|
||||||
protected $private = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Security Settings
|
* Security Settings
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var boolean, null by default
|
* @var boolean, null by default
|
||||||
|
* @todo Move to public scope
|
||||||
*/
|
*/
|
||||||
protected $security = null;
|
protected $security = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Session
|
|
||||||
*
|
|
||||||
* Whether or not a session should be established.
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var boolean, null by default
|
|
||||||
*/
|
|
||||||
protected $session = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AJAX
|
* AJAX
|
||||||
*
|
*
|
||||||
|
@ -122,6 +97,7 @@ class Module extends Object
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var boolean, false (not AJAX) by default
|
* @var boolean, false (not AJAX) by default
|
||||||
|
* @todo Move to public scope
|
||||||
*/
|
*/
|
||||||
protected $ajax = false;
|
protected $ajax = false;
|
||||||
|
|
||||||
|
@ -132,6 +108,7 @@ class Module extends Object
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var string or array, null by default
|
* @var string or array, null by default
|
||||||
|
* @todo Move to public scope
|
||||||
*/
|
*/
|
||||||
protected $method = null;
|
protected $method = null;
|
||||||
|
|
||||||
|
@ -142,6 +119,7 @@ class Module extends Object
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var array, null by default
|
* @var array, null by default
|
||||||
|
* @todo Move to public scope
|
||||||
*/
|
*/
|
||||||
protected $validate = null;
|
protected $validate = null;
|
||||||
|
|
||||||
|
@ -154,15 +132,16 @@ class Module extends Object
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var string or boolean, null by default
|
* @var string or boolean, null by default
|
||||||
|
* @todo Move to public scope
|
||||||
*/
|
*/
|
||||||
protected $hash = null;
|
protected $hash = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Template
|
* Template
|
||||||
*
|
*
|
||||||
* Defaults to null but could be set to any valid template basename. The
|
* This is the parent template that will be loaded if you are using the
|
||||||
* value is overwritten by the config value if not set by the module. The
|
* 'template' return type in the Display class. Parent templates are found
|
||||||
* display engine determines what the file extension should be.
|
* in ./templates/__shared and use the phtml extension.
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var string, 'index' by default
|
* @var string, 'index' by default
|
||||||
|
@ -179,8 +158,11 @@ class Module extends Object
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var array
|
* @var array
|
||||||
|
* @todo Move to public scope and rename __return so it's kinda obscured
|
||||||
*/
|
*/
|
||||||
protected $return_data = array();
|
protected $return_data = array();
|
||||||
|
|
||||||
|
// @todo Document me
|
||||||
public $return = array();
|
public $return = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,7 +174,7 @@ class Module extends Object
|
||||||
* controller (the registration page calls the login page in this manner.
|
* controller (the registration page calls the login page in this manner.
|
||||||
*
|
*
|
||||||
* @param boolean $autorun optional flag to autorun __default()
|
* @param boolean $autorun optional flag to autorun __default()
|
||||||
* @param boolean $valiate optional flag to disable input validation during autorun
|
* @param boolean $valiate optional flag to disable autorun validation
|
||||||
*/
|
*/
|
||||||
public function __construct($autorun = false, $validate = true)
|
public function __construct($autorun = false, $validate = true)
|
||||||
{
|
{
|
||||||
|
@ -209,6 +191,7 @@ class Module extends Object
|
||||||
|
|
||||||
if ($errors !== false)
|
if ($errors !== false)
|
||||||
{
|
{
|
||||||
|
// @todo Fatal error perhaps?
|
||||||
exit('Errors encountered, this is a @todo for form validation when calling modules from inside of modules');
|
exit('Errors encountered, this is a @todo for form validation when calling modules from inside of modules');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,9 +205,6 @@ class Module extends Object
|
||||||
*
|
*
|
||||||
* This function is overloaded by the module. The __default() method is
|
* This function is overloaded by the module. The __default() method is
|
||||||
* where you want to place any code that needs to be executed at runtime.
|
* where you want to place any code that needs to be executed at runtime.
|
||||||
* The reason the code isn't in the constructor is because the module must
|
|
||||||
* be instantiated before the code is executed so that the controller
|
|
||||||
* script is aware of the authentication requirements.
|
|
||||||
*/
|
*/
|
||||||
public function __default()
|
public function __default()
|
||||||
{
|
{
|
||||||
|
@ -240,6 +220,7 @@ class Module extends Object
|
||||||
*
|
*
|
||||||
* @param string $name name of the variable to be set
|
* @param string $name name of the variable to be set
|
||||||
* @param mixed $value value of the variable to be set
|
* @param mixed $value value of the variable to be set
|
||||||
|
* @todo Ditch the $name check once everything is public
|
||||||
*/
|
*/
|
||||||
public function __set($name, $value)
|
public function __set($name, $value)
|
||||||
{
|
{
|
||||||
|
@ -261,6 +242,7 @@ class Module extends Object
|
||||||
*
|
*
|
||||||
* @param string $name name of the variable requested
|
* @param string $name name of the variable requested
|
||||||
* @return mixed value of the variable or boolean false
|
* @return mixed value of the variable or boolean false
|
||||||
|
* @todo Unsure how necessary this will be moving forward, ideally would like to delete entirely
|
||||||
*/
|
*/
|
||||||
public function __get($name)
|
public function __get($name)
|
||||||
{
|
{
|
||||||
|
@ -279,27 +261,6 @@ class Module extends Object
|
||||||
return $this->$name;
|
return $this->$name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Request
|
|
||||||
*
|
|
||||||
* @param array $request data to be loaded into the request variable
|
|
||||||
* @return boolean whether or not the assignment was successful
|
|
||||||
*/
|
|
||||||
public function setRequest($request)
|
|
||||||
{
|
|
||||||
$backtrace = debug_backtrace();
|
|
||||||
|
|
||||||
if ($backtrace[1]['class'] == 'Controller')
|
|
||||||
{
|
|
||||||
$this->request = $request;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception('Only Controller can perform setRequest()');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate
|
* Validate
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue