-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoduleController.php
81 lines (76 loc) · 1.73 KB
/
moduleController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
require_once './inc/moduleTemplate.php';
/**
* Controller helper.
*
* @author Maciej Nux Jaros
*/
class ModuleController
{
/**
* Action within module received from user.
*
* If empty then default sub-controller for the module should be used.
*
* @readonly
* @var string
*/
public $action;
/**
* @readonly
* @var string
*/
public $moduleDir;
/**
* Path to public directory of the module.
* @readonly
* @var string
*/
public $modulePublicDir;
/**
* Main controller file path.
* @readonly
* @var string
*/
public $controllerPath;
/**
* @readonly
* @var string
*/
public $moduleName;
/**
* @var ModuleTemplate
*/
public $tpl;
/**
* Get URL for this module for given action.
* @param string $action
* @param array $extraParams
*/
public function getActionUrl($action, $extraParams=array())
{
return MainMenu::getModuleUrl($this->moduleName, $action, $extraParams);
}
/**
* Get raw (non-html encoded) URL for this module for given action.
* @param string $action
* @param array $extraParams
*/
public function getRawActionUrl($action, $extraParams=array())
{
return MainMenu::getRawModuleUrl($this->moduleName, $action, $extraParams);
}
/**
* @param string $moduleName Module name.
* @param string $action Action within module.
*/
public function __construct($moduleName, $action)
{
$this->moduleName = $moduleName;
$this->moduleDir = './modules/'.$moduleName.'/';
$this->controllerPath = './modules/'.$moduleName.'/controller.php';
$this->modulePublicDir = './modules_public/'.$moduleName.'/';
$this->action = $action;
$this->tpl = new ModuleTemplate($this->moduleDir);
}
}