XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
ModController.class.php
1<?php
12
13if (!defined('XOOPS_ROOT_PATH')) {
14 exit();
15}
16require_once _MY_MODULE_PATH.'class/AbstractAction.class.php';
17
19{
20 private $act;
21
22 public function __construct()
23 {
24 $root = XCube_Root::getSingleton();
25 $this->act = $root->mContext->mRequest->getRequest('action');
26 if ('' == $this->act) {
27 $this->act = 'index';
28 }
29 if (!preg_match("/^\w+$/", $this->act)) {
30 exit('bad action name');
31 }
32 }
33
34 public function execute($controller)
35 {
36 $className = $this->act.'Action';
37 $fileName = _MY_MODULE_PATH.'actions/'.$className.'.class.php';
38 if (!is_file($fileName)) {
39 exit('file not found');
40 }
41 require $fileName;
42
43 $Action = new $className($controller);
44 $Action->execute();
45
46 if ($Action->getisError()) {
47 $controller->executeRedirect($Action->getUrl(), 2, $Action->geterrMsg());
48 } else {
49 $Action->executeView($controller->mRoot->mContext->mModule->getRenderTarget());
50 }
51 }
52}