1: <?php
2: if (!defined('XOOPS_ROOT_PATH')) exit();
3: require_once _MY_MODULE_PATH.'class/AbstractAction.class.php';
4:
5: class ModController
6: {
7: private $act;
8:
9: public function __construct()
10: {
11: $root = XCube_Root::getSingleton();
12: $this->act = $root->mContext->mRequest->getRequest('action');
13: if ( $this->act == "" ) {
14: $this->act = 'index';
15: }
16: if (!preg_match("/^\w+$/", $this->act)) {
17: exit('bad action name');
18: }
19: }
20:
21: public function execute($controller)
22: {
23: $className = $this->act.'Action';
24: $fileName = _MY_MODULE_PATH.'actions/'.$className.'.class.php';
25: if (!is_file($fileName)) {
26: exit('file not found');
27: }
28: require $fileName;
29:
30: $Action = new $className($controller);
31: $Action->execute();
32:
33: if ( $Action->getisError() ) {
34: $controller->executeRedirect($Action->getUrl(), 2, $Action->geterrMsg());
35: } else {
36: $Action->executeView($controller->mRoot->mContext->mModule->getRenderTarget());
37: }
38: }
39: }
40: ?>