mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-09 13:06:14 +00:00
call hook preRun and check result
This commit is contained in:
parent
718d922950
commit
8b75ffaea1
|
@ -45,17 +45,38 @@ class SeedDMS_View_Common {
|
||||||
$this->imgpath = '../views/'.$theme.'/images/';
|
$this->imgpath = '../views/'.$theme.'/images/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call method with name in $get['action']
|
||||||
|
*
|
||||||
|
* Until 5.1.26 (6.0.19) this method took the name of the
|
||||||
|
* controller method to run from the element 'action' passed
|
||||||
|
* in the array $get. Since 5.1.27 (6.0.20) a PSR7 Request
|
||||||
|
* object is available in the controller and used to get the
|
||||||
|
* action.
|
||||||
|
*
|
||||||
|
* @params array $get $_GET or $_POST variables (since 5.1.27 this is no longer used)
|
||||||
|
* @return mixed return value of called method
|
||||||
|
*/
|
||||||
public function __invoke($get=array()) {
|
public function __invoke($get=array()) {
|
||||||
$this->callHook('preRun', isset($get['action']) ? $get['action'] : 'show');
|
$action = null;
|
||||||
if(isset($get['action']) && $get['action']) {
|
$request = $this->getParam('request');
|
||||||
if(method_exists($this, $get['action'])) {
|
if($request) {
|
||||||
$this->{$get['action']}();
|
if($request->isMethod('get'))
|
||||||
} else {
|
$action = $request->query->get('action');
|
||||||
echo "Missing action '".htmlspecialchars($get['action'])."'";
|
elseif($request->isMethod('post'))
|
||||||
}
|
$action = $request->request->get('action');
|
||||||
} else
|
}
|
||||||
$this->show();
|
if(!$this->callHook('preRun', $action ? $action : 'show')) {
|
||||||
$this->callHook('postRun', isset($get['action']) ? $get['action'] : 'show');
|
if($action) {
|
||||||
|
if(method_exists($this, $action)) {
|
||||||
|
$this->{$action}();
|
||||||
|
} else {
|
||||||
|
echo "Missing action '".htmlspecialchars($action)."'";
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
$this->show();
|
||||||
|
}
|
||||||
|
$this->callHook('postRun', $action ? $action : 'show');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setParams($params) {
|
public function setParams($params) {
|
||||||
|
@ -78,7 +99,7 @@ class SeedDMS_View_Common {
|
||||||
* @param string $name name of parameter
|
* @param string $name name of parameter
|
||||||
* @return boolean true if parameter exists otherwise false
|
* @return boolean true if parameter exists otherwise false
|
||||||
*/
|
*/
|
||||||
function hasParam($name) {
|
public function hasParam($name) {
|
||||||
return isset($this->params[$name]) ? true : false;
|
return isset($this->params[$name]) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user