32 public $mActionName =
null;
33 public $mAction =
null;
34 public $mAdminFlag =
null;
39 public $mCreateAction =
null;
41 public function __construct($admin)
43 $this->mAdminFlag = $admin;
45 $this->mCreateAction->register(
'Profile_ActionFrame.CreateAction');
46 $this->mCreateAction->add([&$this,
'_createAction']);
49 public function setActionName($name)
51 $this->mActionName = $name;
56 $root =& XCube_Root::getSingleton();
57 $root->mContext->setAttribute(
'actionName', $name);
58 $root->mContext->mModule->setAttribute(
'actionName', $name);
61 public function _createAction(&$actionFrame)
63 if (is_object($this->mAction)) {
70 $className =
'Profile_' . ucfirst($actionFrame->mActionName) .
'Action';
71 $fileName = ucfirst($actionFrame->mActionName) .
'Action';
72 if ($actionFrame->mAdminFlag) {
73 $fileName = XOOPS_MODULE_PATH .
"/profile/admin/actions/{$fileName}.class.php";
75 $fileName = XOOPS_MODULE_PATH .
"/profile/actions/{$fileName}.class.php";
78 if (!file_exists($fileName)) {
79 die(
'file_exists on _createAction');
82 require_once $fileName;
84 if (XC_CLASS_EXISTS($className)) {
85 $actionFrame->mAction =
new $className($actionFrame->mAdminFlag);
89 public function execute(&$controller)
91 if (!preg_match(
"/^\w+$/", $this->mActionName)) {
98 $this->mCreateAction->call(
new XCube_Ref($this));
100 if (!(is_object($this->mAction) && $this->mAction instanceof \
Profile_Action)) {
104 if ($this->mAction->isSecure() && !is_object($controller->mRoot->mContext->mXoopsUser)) {
109 $controller->executeForward(XOOPS_URL .
'/');
112 $this->mAction->prepare($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModuleConfig);
114 if (!$this->mAction->hasPermission($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModuleConfig)) {
119 $controller->executeForward(XOOPS_URL .
'/');
122 if (
'POST' == xoops_getenv(
'REQUEST_METHOD')) {
123 $viewStatus = $this->mAction->execute($controller, $controller->mRoot->mContext->mXoopsUser);
125 $viewStatus = $this->mAction->getDefaultView($controller, $controller->mRoot->mContext->mXoopsUser);
128 $render = $controller->mRoot->mContext->mModule->getRenderTarget();
129 $render->setAttribute(
'xoops_pagetitle', $this->mAction->getPagetitle());
132 switch ($viewStatus) {
133 case PROFILE_FRAME_VIEW_SUCCESS:
134 $this->mAction->executeViewSuccess($render);
137 case PROFILE_FRAME_VIEW_ERROR:
138 $this->mAction->executeViewError($controller);
141 case PROFILE_FRAME_VIEW_INDEX:
142 $this->mAction->executeViewIndex($controller, $controller->mRoot->mContext->mXoopsUser, $render);
145 case PROFILE_FRAME_VIEW_INPUT:
146 $this->mAction->executeViewInput($controller);
149 case PROFILE_FRAME_VIEW_PREVIEW:
150 $this->mAction->executeViewPreview($controller);
153 case PROFILE_FRAME_VIEW_CANCEL:
154 $this->mAction->executeViewCancel($controller);
162 public function __construct()
166 public function isSecure()
195 public function getPageTitle()
197 return Legacy_Utils::formatPagetitle(XCube_Root::getSingleton()->mContext->mModule->mXoopsModule->get(
'name'), $this->_getPagetitle(), $this->_getPageAction());
200 public function hasPermission(&$controller, &$xoopsUser, $moduleConfig)
205 public function prepare(&$controller, &$xoopsUser, &$moduleConfig)
209 public function getDefaultView(&$controller, &$xoopsUser)
211 return PROFILE_FRAME_VIEW_NONE;
214 public function execute(&$controller, &$xoopsUser)
216 return PROFILE_FRAME_VIEW_NONE;
219 public function executeViewSuccess(&$render)
223 public function executeViewError(&$render)
227 public function executeViewInde(&$render)
231 public function executeViewInput(&$render)
235 public function executeViewPreview(&$render)
239 public function executeViewCancel(&$render)