Minahito
minah****@users*****
2006年 5月 17日 (水) 20:15:51 JST
Index: xoops2jp/html/modules/legacyRender/admin/actions/TplfileListAction.class.php diff -u xoops2jp/html/modules/legacyRender/admin/actions/TplfileListAction.class.php:1.1.2.9 xoops2jp/html/modules/legacyRender/admin/actions/TplfileListAction.class.php:1.1.2.10 --- xoops2jp/html/modules/legacyRender/admin/actions/TplfileListAction.class.php:1.1.2.9 Wed May 17 18:37:02 2006 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplfileListAction.class.php Wed May 17 20:15:51 2006 @@ -6,8 +6,18 @@ require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplfileFilterForm.class.php"; require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplfileSetFilterForm.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplfileUploadForm.class.php"; + class LegacyRender_TplfileListAction extends LegacyRender_AbstractListAction { + var $mActionForm = null; + + function prepare(&$controller, &$xoopsUser) + { + $this->mActionForm =& new LegacyRender_TplfileUploadForm(); + $this->mActionForm->prepare(); + } + function &_getHandler() { $handler =& xoops_getmodulehandler('tplfile'); @@ -51,6 +61,66 @@ return LEGACYRENDER_FRAME_VIEW_INDEX; } + function execute(&$controller, &$xoopsUser) + { + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + + if ($this->mActionForm->hasError()) { + return $this->getDefaultView($controller, $xoopsUser); + } + + $formFileArr = $this->mActionForm->get('upload'); + + // + // Set tpl_module and tpl_tplset of the last object to the following variable for redirect. + // + $last_tplset = null; + $last_module = null; + + $handler =& xoops_getmodulehandler('tplfile'); + + $successFlag = true; + + foreach (array_keys($formFileArr) as $key) { + $formFile =& $formFileArr[$key]; + + $obj =& $handler->get($key); + if ($obj == null) { + continue; + } + + // + // If $obj belongs to 'default' template-set, kick! + // + if ($obj->get('tpl_tplset') == 'default') { + continue; + } + + $obj->loadSource(); + + $last_tplset = $obj->getVar('tpl_tplset'); + $last_module = $obj->getVar('tpl_module'); + + // + // [Warning] Access to a private property of XCube_FormFile. + // + $source = file_get_contents($formFile->_mTmpFileName); + $obj->Source->set('tpl_source', $source); + $obj->set('tpl_lastmodified', time()); + $obj->set('tpl_lastimported', time()); + + $successFlag &= $handler->insert($obj); + + unset($obj); + unset($formFile); + } + + $errorMessage = $successFlag ? _AD_LEGACYRENDER_MESSAGE_UPLOAD_TEMPLATE_SUCCESS : _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED; + + XCube_Utils::redirectHeader("index.php?action=TplfileList&tpl_tplset=${last_tplset}&tpl_module=${last_module}", 1, $errorMessage); + } + function executeViewIndex(&$controller, &$xoopsUser, &$render) { $render->setTemplateName("tplfile_list.html"); @@ -67,11 +137,14 @@ $render->setAttribute('objects', $this->mObjects); $render->setAttribute('pageNavi', $this->mPageNavi); $render->setAttribute('filterForm', $this->mFilter); + $render->setAttribute('actionForm', $this->mActionForm); if ($this->mFilter->mTplset != null) { $render->setAttribute('targetTplset', $this->mFilter->mTplset->get('tplset_name')); } + $render->setAttribute('targetModule', xoops_getrequest('tpl_module')); + // // TODO We must fetch only module objects that has templates. //