139 public $mModuleObject =
null;
140 public $mContents =
null;
142 public $mErrorMessage =
null;
152 public $mCreateHelpSmarty =
null;
154 public function __construct($flag)
156 parent::__construct($flag);
159 $this->mCreateHelpSmarty->add([&$this,
'_createHelpSmarty']);
160 $this->mCreateHelpSmarty->register(
'Legacy_HelpAction.CreateHelpSmarty');
163 public function prepare(&$controller, &$xoopsUser)
165 parent::prepare($controller, $xoopsUser);
166 $this->_mDirname = xoops_getrequest(
'dirname');
169 public function hasPermission(&$controller, &$xoopsUser)
171 $dirname = xoops_getrequest(
'dirname');
172 $controller->mRoot->mRoleManager->loadRolesByDirname($this->_mDirname);
173 return $controller->mRoot->mContext->mUser->isInRole(
'Module.' . $dirname .
'.Admin');
176 public function getDefaultView(&$controller, &$xoopsUser)
178 $moduleHandler =& xoops_gethandler(
'module');
179 $this->mModuleObject =& $moduleHandler->getByDirname($this->_mDirname);
180 $language = $controller->mRoot->mContext->getXoopsConfig(
'language');
185 $helpfile = xoops_getrequest(
'file') ?: $this->mModuleObject->getHelp();
191 $this->mCreateHelpSmarty->call(
new XCube_Ref($smarty));
192 $smarty->setDirname($this->_mDirname);
199 $template_dir = XOOPS_MODULE_PATH .
'/' . $this->_mDirname .
"/language/{$language}/help";
210 if (!file_exists($template_dir .
'/' . $helpfile)) {
212 $trust_dir = XOOPS_TRUST_PATH .
'/modules/' . $this->_mDirname .
'/language/english/help';
213 if (!file_exists($trust_dir .
'/' . $helpfile)) {
214 $this->mErrorMessage = _AD_LEGACY_ERROR_NO_HELP_FILE;
215 return LEGACY_FRAME_VIEW_ERROR;
217 $template_dir = $trust_dir;
220 $controller->mRoot->mContext->setAttribute(
'legacy_help_dirname', $this->_mDirname);
226 $mHelp = XOOPS_MODULE_URL .
"/legacy/admin/index.php?action=Help&dirname";
227 $smarty->assign(
'help',$mHelp);
228 $smarty->template_dir = $template_dir;
229 $this->mContents = $smarty->fetch(
'file:' . $helpfile);
231 return LEGACY_FRAME_VIEW_SUCCESS;
235 public function _createHelpSmarty(&$smarty)
237 if (!is_object($smarty)) {
238 $smarty =
new Legacy_HelpSmarty();
242 public function executeViewSuccess(&$controller, &$xoopsUser, &$renderer)
244 $renderer->setTemplateName(
'help.html');
246 $module =& Legacy_Utils::createModule($this->mModuleObject);
248 $renderer->setAttribute(
'module', $module);
249 $renderer->setAttribute(
'contents', $this->mContents);
252 public function executeViewError(&$controller, &$xoopsUser, &$renderer)
254 $controller->executeRedirect(
'./index.php?action=ModuleList', 1, $this->mErrorMessage);