23 public $mActionForm =
null;
25 public function prepare(&$controller, &$xoopsUser, $moduleConfig)
27 LegacyRender_AbstractListAction::prepare($controller, $xoopsUser, $moduleConfig);
29 $this->mActionForm->prepare();
32 public function &_getHandler()
34 $handler =& xoops_getmodulehandler(
'tplfile');
38 public function &_getFilterForm()
45 public function _getBaseUrl()
47 return './index.php?action=TplfileList';
50 public function getDefaultView(&$controller, &$xoopsUser)
52 $this->mFilter =& $this->_getFilterForm();
53 $this->mFilter->fetch();
55 $handler =& $this->_getHandler();
57 $criteria = $this->mFilter->getCriteria();
59 if (isset($_REQUEST[
'tpl_tplset'])) {
60 $this->mObjects =& $handler->getObjectsWithOverride($criteria, xoops_getrequest(
'tpl_tplset'));
62 $this->mObjects =& $handler->getObjects($criteria);
65 return LEGACYRENDER_FRAME_VIEW_INDEX;
74 public function execute(&$controller, &$xoopsUser)
76 require_once XOOPS_ROOT_PATH .
'/class/template.php';
78 $this->mActionForm->fetch();
79 $this->mActionForm->validate();
81 if ($this->mActionForm->hasError()) {
82 return $this->getDefaultView($controller, $xoopsUser);
85 $formFileArr = $this->mActionForm->get(
'upload');
93 $handler =& xoops_getmodulehandler(
'tplfile');
97 foreach (array_keys($formFileArr) as $key) {
98 $formFile =& $formFileArr[$key];
100 $obj =& $handler->get($key);
108 if ($obj->get(
'tpl_tplset') ==
'default') {
114 $last_tplset = $obj->get(
'tpl_tplset');
115 $last_module = $obj->get(
'tpl_module');
120 if (
null != $formFile) {
121 $source = file_get_contents($formFile->_mTmpFileName);
122 $obj->Source->set(
'tpl_source', $source);
123 $obj->set(
'tpl_lastmodified', time());
124 $obj->set(
'tpl_lastimported', time());
126 $successFlag &= $handler->insert($obj);
129 $xoopsTpl->clear_cache(
'db:' . $obj->get(
'tpl_file'));
130 $xoopsTpl->clear_compiled_tpl(
'db:' . $obj->get(
'tpl_file'));
137 $errorMessage = $successFlag ? _AD_LEGACYRENDER_MESSAGE_UPLOAD_TEMPLATE_SUCCESS : _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED;
143 $controller->executeRedirect(
"index.php?action=TplfileList&tpl_tplset={$last_tplset}&tpl_module={$last_module}", 1, $errorMessage);
146 public function executeViewIndex(&$controller, &$xoopsUser, &$render)
148 $controller->mRoot->mDelegateManager->add(
'Legacy.Event.Explaceholder.Get.LegacyRenderPagenaviHidden',
'LegacyRender_TplfileListAction::renderHiddenControl');
150 $render->setTemplateName(
'tplfile_list.html');
155 if ($this->mFilter->mTplset !=
null && $this->mFilter->mTplset->get(
'tplset_name') !=
'default') {
156 foreach (array_keys($this->mObjects) as $key) {
157 $this->mObjects[$key]->loadOverride($this->mFilter->mTplset->get(
'tplset_name'));
161 $render->setAttribute(
'objects', $this->mObjects);
162 $render->setAttribute(
'pageNavi', $this->mFilter->mNavi);
163 $render->setAttribute(
'filterForm', $this->mFilter);
164 $render->setAttribute(
'actionForm', $this->mActionForm);
166 if ($this->mFilter->mTplset !=
null) {
167 $render->setAttribute(
'targetTplset', $this->mFilter->mTplset->get(
'tplset_name'));
169 $render->setAttribute(
'targetTplset',
'default');
172 $render->setAttribute(
'targetModule', xoops_getrequest(
'tpl_module'));
179 $moduleHandler =& xoops_gethandler(
'module');
180 $modules =& $moduleHandler->getObjects();
181 $render->setAttribute(
'modules', $modules);
183 $handler =& xoops_getmodulehandler(
'tplset');
184 $tplsets =& $handler->getObjects();
185 $render->setAttribute(
'tplsets', $tplsets);
188 public static function renderHiddenControl(&$buf, $params)
190 if (isset($params[
'pagenavi']) && is_object($params[
'pagenavi'])) {
191 $navi =& $params[
'pagenavi'];
193 $mask = $params[
'mask'] ??
null;
195 foreach ($navi->mExtra as $key => $value) {
197 $value = htmlspecialchars($value, ENT_QUOTES);
198 $buf .=
"<input type=\"hidden\" name=\"{$key}\" value=\"{$value}\" />";