NobuNobu
nobun****@users*****
2007年 4月 30日 (月) 16:35:09 JST
Index: xoops2jp/html/modules/legacyRender/admin/actions/BannerDeleteAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/BannerDeleteAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/BannerDeleteAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,55 @@ +<?php +/** + * @package legacyRender + * @version $Id: BannerDeleteAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractDeleteAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/BannerAdminDeleteForm.class.php"; + +class LegacyRender_BannerDeleteAction extends LegacyRender_AbstractDeleteAction +{ + function _getId() + { + return xoops_getrequest('bid'); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('banner'); + return $handler; + } + + function _setupActionForm() + { + $this->mActionForm =& new LegacyRender_BannerAdminDeleteForm(); + $this->mActionForm->prepare(); + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("banner_delete.html"); + $render->setAttribute('actionForm', $this->mActionForm); + $this->mObject->loadBannerclient(); + $render->setAttribute('object', $this->mObject); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=BannerList"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=BannerList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=BannerList"); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/BannerEditAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/BannerEditAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/BannerEditAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,70 @@ +<?php +/** + * @package legacyRender + * @version $Id: BannerEditAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractEditAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/BannerAdminEditForm.class.php"; + +class LegacyRender_BannerEditAction extends LegacyRender_AbstractEditAction +{ + function _getId() + { + return xoops_getrequest('bid'); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('banner'); + return $handler; + } + + function _setupObject() + { + parent::_setupObject(); + if (is_object($this->mObject) && $this->mObject->isNew()) { + $this->mObject->set('cid', xoops_getrequest('cid')); + } + } + + function _setupActionForm() + { + $this->mActionForm =& new LegacyRender_BannerAdminEditForm(); + $this->mActionForm->prepare(); + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("banner_edit.html"); + $render->setAttribute('actionForm', $this->mActionForm); + $this->mObject->loadBannerclient(); + $render->setAttribute('object', $this->mObject); + + $bannerclientHandler =& xoops_getmodulehandler('bannerclient'); + $bannerclientArr =& $bannerclientHandler->getObjects(); + foreach (array_keys($bannerclientArr) as $key) { + $bannerclientArr[$key]->loadBanner(); + } + $render->setAttribute('bannerclientArr', $bannerclientArr); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=BannerList"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=BannerList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=BannerList"); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/BannerListAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/BannerListAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/BannerListAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,50 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractListAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/BannerFilterForm.class.php"; + +class LegacyRender_BannerListAction extends LegacyRender_AbstractListAction +{ + function &_getHandler() + { + $handler =& xoops_getmodulehandler('banner'); + return $handler; + } + + function &_getFilterForm() + { + $filter =& new LegacyRender_BannerFilterForm($this->_getPageNavi(), $this->_getHandler()); + return $filter; + } + + function _getBaseUrl() + { + return "./index.php?action=BannerList"; + } + + function executeViewIndex(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("banner_list.html"); + foreach (array_keys($this->mObjects) as $key) { + $this->mObjects[$key]->loadBannerclient(); + } + $render->setAttribute("objects", $this->mObjects); + $render->setAttribute("pageNavi", $this->mFilter->mNavi); + + // + // If cid is specified, load client object and assign it. + // + $cid = xoops_getrequest('cid'); + if ($cid > 0) { + $handler =& xoops_getmodulehandler('bannerclient'); + $client =& $handler->get($cid); + if (is_object($client)) { + $render->setAttribute("currentClient", $client); + } + } + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/BannerclientDeleteAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/BannerclientDeleteAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/BannerclientDeleteAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,56 @@ +<?php +/** + * @package legacyRender + * @version $Id: BannerclientDeleteAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractDeleteAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/BannerclientAdminDeleteForm.class.php"; + +class LegacyRender_BannerclientDeleteAction extends LegacyRender_AbstractDeleteAction +{ + function _getId() + { + return xoops_getrequest('cid'); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('bannerclient'); + return $handler; + } + + function _setupActionForm() + { + $this->mActionForm =& new LegacyRender_BannerclientAdminDeleteForm(); + $this->mActionForm->prepare(); + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("bannerclient_delete.html"); + $render->setAttribute('actionForm', $this->mActionForm); + $this->mObject->loadBanner(); + $this->mObject->loadBannerfinish(); + $render->setAttribute('object', $this->mObject); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=BannerclientList"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=BannerclientList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=BannerclientList"); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/BannerclientEditAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/BannerclientEditAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/BannerclientEditAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,56 @@ +<?php +/** + * @package legacyRender + * @version $Id: BannerclientEditAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractEditAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/BannerclientAdminEditForm.class.php"; + +class LegacyRender_BannerclientEditAction extends LegacyRender_AbstractEditAction +{ + function _getId() + { + return xoops_getrequest('cid'); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('bannerclient'); + return $handler; + } + + function _setupActionForm() + { + $this->mActionForm =& new LegacyRender_BannerclientAdminEditForm(); + $this->mActionForm->prepare(); + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("bannerclient_edit.html"); + $render->setAttribute('actionForm', $this->mActionForm); + $this->mObject->loadBanner(); + $this->mObject->loadBannerfinish(); + $render->setAttribute('object', $this->mObject); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=BannerclientList"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=BannerclientList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=BannerclientList"); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/BannerclientListAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/BannerclientListAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/BannerclientListAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,43 @@ +<?php +/** + * @package legacyRender + * @version $Id: BannerclientListAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractListAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/BannerclientFilterForm.class.php"; + +class LegacyRender_BannerclientListAction extends LegacyRender_AbstractListAction +{ + function &_getHandler() + { + $handler =& xoops_getmodulehandler('bannerclient'); + return $handler; + } + + function &_getFilterForm() + { + $filter =& new LegacyRender_BannerclientFilterForm($this->_getPageNavi(), $this->_getHandler()); + return $filter; + } + + function _getBaseUrl() + { + return "./index.php?action=BannerclientList"; + } + + function executeViewIndex(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("bannerclient_list.html"); + foreach (array_keys($this->mObjects) as $key) { + $this->mObjects[$key]->loadBannerCount(); + $this->mObjects[$key]->loadFinishBannerCount(); + } + $render->setAttribute("objects", $this->mObjects); + $render->setAttribute("pageNavi", $this->mFilter->mNavi); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/BannerfinishDeleteAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/BannerfinishDeleteAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/BannerfinishDeleteAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,55 @@ +<?php +/** + * @package legacyRender + * @version $Id: BannerfinishDeleteAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractDeleteAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/BannerfinishAdminDeleteForm.class.php"; + +class LegacyRender_BannerfinishDeleteAction extends LegacyRender_AbstractDeleteAction +{ + function _getId() + { + return xoops_getrequest('bid'); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('bannerfinish'); + return $handler; + } + + function _setupActionForm() + { + $this->mActionForm =& new LegacyRender_BannerfinishAdminDeleteForm(); + $this->mActionForm->prepare(); + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("bannerfinish_delete.html"); + $render->setAttribute('actionForm', $this->mActionForm); + $this->mObject->loadBannerclient(); + $render->setAttribute('object', $this->mObject); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=BannerfinishList"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=BannerfinishList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=BannerfinishList"); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/BannerfinishListAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/BannerfinishListAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/BannerfinishListAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,50 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractListAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/BannerfinishFilterForm.class.php"; + +class LegacyRender_BannerfinishListAction extends LegacyRender_AbstractListAction +{ + function &_getHandler() + { + $handler =& xoops_getmodulehandler('bannerfinish'); + return $handler; + } + + function &_getFilterForm() + { + $filter =& new LegacyRender_BannerfinishFilterForm($this->_getPageNavi(), $this->_getHandler()); + return $filter; + } + + function _getBaseUrl() + { + return "./index.php?action=BannerfinishList"; + } + + function executeViewIndex(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("bannerfinish_list.html"); + foreach (array_keys($this->mObjects) as $key) { + $this->mObjects[$key]->loadBannerclient(); + } + $render->setAttribute("objects", $this->mObjects); + $render->setAttribute("pageNavi", $this->mFilter->mNavi); + + // + // If cid is specified, load client object and assign it. + // + $cid = xoops_getrequest('cid'); + if ($cid > 0) { + $handler =& xoops_getmodulehandler('bannerclient'); + $client =& $handler->get($cid); + if (is_object($client)) { + $render->setAttribute("currentClient", $client); + } + } + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/TplfileCloneAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplfileCloneAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplfileCloneAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,75 @@ +<?php +/** + * @package legacyRender + * @version $Id: TplfileCloneAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractEditAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplfileCloneForm.class.php"; + +class LegacyRender_TplfileCloneAction extends LegacyRender_AbstractEditAction +{ + var $mTargetObject = null; + + function _getId() + { + return xoops_getrequest('tpl_id'); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('tplfile'); + return $handler; + } + + function _setupObject() + { + $id = $this->_getId(); + + $this->mObjectHandler =& $this->_getHandler(); + $obj =& $this->mObjectHandler->get($id); + + // + // The following code uses 'tpl_tplset' directly. This input value will + // be checked by ActionForm. + // + if (is_object($obj) && $obj->get('tpl_tplset') == 'default') { + $this->mObject =& $obj->createClone(xoops_getrequest('tpl_tplset')); + } + } + + function isEnableCreate() + { + return false; + } + + function _setupActionForm() + { + $this->mActionForm =& new LegacyRender_TplfileCloneForm(); + $this->mActionForm->prepare(); + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("tplfile_clone.html"); + $render->setAttribute('actionForm', $this->mActionForm); + $render->setAttribute('object', $this->mObject); + $render->setAttribute('tpl_id', xoops_getrequest('tpl_id')); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $tplset = $this->mObject->get('tpl_tplset'); + $module = $this->mObject->get('tpl_module'); + $controller->executeForward("./index.php?action=TplfileList&tpl_tplset=${tplset}&tpl_module=${module}"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/TplfileDeleteAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplfileDeleteAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplfileDeleteAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,69 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractDeleteAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplfileAdminDeleteForm.class.php"; + +class LegacyRender_TplfileDeleteAction extends LegacyRender_AbstractDeleteAction +{ + function _getId() + { + return xoops_getrequest('tpl_id'); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('tplfile'); + return $handler; + } + + function _setupObject() + { + parent::_setupObject(); + if ($this->mObject != null && $this->mObject->get('tpl_tplset') == 'default') { + $this->mObject = null; + } + } + + function _setupActionForm() + { + $this->mActionForm =& new LegacyRender_TplfileAdminDeleteForm(); + $this->mActionForm->prepare(); + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("tplfile_delete.html"); + $render->setAttribute('actionForm', $this->mActionForm); + $this->mObject->loadSource(); + $render->setAttribute('object', $this->mObject); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + require_once XOOPS_ROOT_PATH . "/class/template.php"; + + $xoopsTpl =& new XoopsTpl(); + $xoopsTpl->clear_cache('db:' . $this->mObject->get('tpl_file')); + $xoopsTpl->clear_compiled_tpl('db:' . $this->mObject->get('tpl_file')); + + $tplset = $this->mObject->get('tpl_tplset'); + $module = $this->mObject->get('tpl_module'); + $controller->executeForward("./index.php?action=TplfileList&tpl_tplset=${tplset}&tpl_module=${module}"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=TplfileList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + $tplset = $this->mObject->get('tpl_tplset'); + $module = $this->mObject->get('tpl_module'); + $controller->executeForward("./index.php?action=TplfileList&tpl_tplset=${tplset}&tpl_module=${module}"); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/TplfileDownloadAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplfileDownloadAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplfileDownloadAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,56 @@ +<?php +/** + * @package legacyRender + * @version $Id: TplfileDownloadAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplfileEditForm.class.php"; + +class LegacyRender_TplfileDownloadAction extends LegacyRender_Action +{ + var $mObject = null; + + function getDefaultView(&$controller, &$xoopsUser) + { + $id = xoops_getrequest('tpl_id'); + + $handler =& xoops_getmodulehandler('tplfile'); + $this->mObject =& $handler->get($id); + + return $this->mObject != null ? LEGACYRENDER_FRAME_VIEW_SUCCESS : LEGACYRENDER_FRAME_VIEW_ERROR; + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $this->mObject->loadSource(); + if ($this->mObject->Source == null) { + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + $source = $this->mObject->Source->get('tpl_source'); + + header('Cache-Control: no-cache, must-revalidate'); + header('Pragma: no-cache'); + header('Content-Type: application/force-download'); + + if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { + header('Content-Disposition: filename=' . $this->mObject->getShow('tpl_file')); + } else { + header('Content-Disposition: attachment; filename=' . $this->mObject->getShow('tpl_file')); + } + + header('Content-length: ' . strlen($source)); + print $source; + + exit(0); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/TplfileEditAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplfileEditAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplfileEditAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,82 @@ +<?php +/** + * @package legacyRender + * @version $Id: TplfileEditAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractEditAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplfileEditForm.class.php"; + +class LegacyRender_TplfileEditAction extends LegacyRender_AbstractEditAction +{ + function _getId() + { + return xoops_getrequest('tpl_id'); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('tplfile'); + return $handler; + } + + function _setupObject() + { + parent::_setupObject(); + + if (is_object($this->mObject) && $this->mObject->get('tpl_tplset') == 'default') { + $this->mObject = null; + } + } + + function _setupActionForm() + { + $this->mActionForm =& new LegacyRender_TplfileEditForm(); + $this->mActionForm->prepare(); + } + + function isEnableCreate() + { + return false; + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("tplfile_edit.html"); + $render->setAttribute('actionForm', $this->mActionForm); + $render->setAttribute('object', $this->mObject); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + // + // This class knows the db template mechanism, because this is in + // LegacyRender. + // + require_once XOOPS_ROOT_PATH . "/class/template.php"; + + $xoopsTpl =& new XoopsTpl(); + $xoopsTpl->clear_cache('db:' . $this->mObject->get('tpl_file')); + $xoopsTpl->clear_compiled_tpl('db:' . $this->mObject->get('tpl_file')); + + $tplset = $this->mObject->get('tpl_tplset'); + $module = $this->mObject->get('tpl_module'); + $controller->executeForward("./index.php?action=TplfileList&tpl_tplset=${tplset}&tpl_module=${module}"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + $tplset = $this->mObject->get('tpl_tplset'); + $module = $this->mObject->get('tpl_module'); + $controller->executeForward("./index.php?action=TplfileList&tpl_tplset=${tplset}&tpl_module=${module}"); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/TplfileListAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplfileListAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplfileListAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,197 @@ +<?php +/** + * @package legacyRender + * @version $Id: TplfileListAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractListAction.class.php"; +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 +{ + /** + * A instance of action form for uploading. + * @var LegacyRender_TplfileUploadForm + */ + var $mActionForm = null; + + function prepare(&$controller, &$xoopsUser, $moduleConfig) + { + LegacyRender_AbstractListAction::prepare($controller, $xoopsUser, $moduleConfig); + $this->mActionForm =& new LegacyRender_TplfileUploadForm(); + $this->mActionForm->prepare(); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('tplfile'); + return $handler; + } + + function &_getFilterForm() + { + $filter = isset($_REQUEST['tpl_tplset']) ? new LegacyRender_TplfileSetFilterForm($this->_getPageNavi(), $this->_getHandler()) + : new LegacyRender_TplfileFilterForm($this->_getPageNavi(), $this->_getHandler()); + return $filter; + } + + function _getBaseUrl() + { + return "./index.php?action=TplfileList"; + } + + function getDefaultView(&$controller, &$xoopsUser) + { + $this->mFilter =& $this->_getFilterForm(); + $this->mFilter->fetch(); + + $handler =& $this->_getHandler(); + + $criteria = $this->mFilter->getCriteria(); + + if (isset($_REQUEST['tpl_tplset'])) { + $this->mObjects =& $handler->getObjectsWithOverride($criteria, xoops_getrequest('tpl_tplset')); + } + else { + $this->mObjects =& $handler->getObjects($criteria); + } + + return LEGACYRENDER_FRAME_VIEW_INDEX; + } + + /** + * This member function processes the uploaded file. + */ + function execute(&$controller, &$xoopsUser) + { + require_once XOOPS_ROOT_PATH . "/class/template.php"; + + $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->get('tpl_tplset'); + $last_module = $obj->get('tpl_module'); + + // + // [Warning] Access to a private property of XCube_FormFile. + // + if ($formFile != null) { + $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); + + $xoopsTpl =& new XoopsTpl(); + $xoopsTpl->clear_cache('db:' . $obj->get('tpl_file')); + $xoopsTpl->clear_compiled_tpl('db:' . $obj->get('tpl_file')); + } + + unset($obj); + unset($formFile); + } + + $errorMessage = $successFlag ? _AD_LEGACYRENDER_MESSAGE_UPLOAD_TEMPLATE_SUCCESS : _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED; + + // + // No good exmaple ;) + // Because some local variables are used, jump directly without the return value of view status. + // + $controller->executeRedirect("index.php?action=TplfileList&tpl_tplset=${last_tplset}&tpl_module=${last_module}", 1, $errorMessage); + } + + function executeViewIndex(&$controller, &$xoopsUser, &$render) + { + $controller->mRoot->mDelegateManager->add('Legacy.Event.Explaceholder.Get.LegacyRenderPagenaviHidden', 'LegacyRender_TplfileListAction::renderHiddenControl'); + + $render->setTemplateName("tplfile_list.html"); + + // + // Load override file. + // + if ($this->mFilter->mTplset != null && $this->mFilter->mTplset->get('tplset_name') != 'default') { + foreach (array_keys($this->mObjects) as $key) { + $this->mObjects[$key]->loadOverride($this->mFilter->mTplset->get('tplset_name')); + } + } + + $render->setAttribute('objects', $this->mObjects); + $render->setAttribute('pageNavi', $this->mFilter->mNavi); + $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. + // + // fetch module objects, assign to template for pull-down menu. + // + $moduleHandler =& xoops_gethandler('module'); + $modules =& $moduleHandler->getObjects(); + $render->setAttribute('modules', $modules); + + $handler =& xoops_getmodulehandler('tplset'); + $tplsets =& $handler->getObjects(); + $render->setAttribute('tplsets', $tplsets); + } + + function renderHiddenControl(&$buf, $params) + { + if (isset($params['pagenavi']) && is_object($params['pagenavi'])) { + $navi =& $params['pagenavi']; + $mask = isset($params['mask']) ? $params['mask'] : null; + + foreach ($navi->mExtra as $key => $value) { + if ($key != $mask) { + $value = htmlspecialchars($value, ENT_QUOTES); + $buf .= "<input type=\"hidden\" name=\"${key}\" value=\"${value}\" />"; + } + } + } + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/TplfileViewAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplfileViewAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplfileViewAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,41 @@ +<?php +/** + * @package legacyRender + * @version $Id: TplfileViewAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyRender_TplfileViewAction extends LegacyRender_Action +{ + var $mObject = null; + + function getDefaultView(&$controller, &$xoopsUser) + { + $id = xoops_getrequest('tpl_id'); + + $handler =& xoops_getmodulehandler('tplfile'); + $this->mObject =& $handler->get($id); + + if (!is_object($this->mObject)) { + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + return LEGACYRENDER_FRAME_VIEW_SUCCESS; + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $this->mObject->loadSource(); + + $render->setTemplateName("tplfile_view.html"); + $render->setAttribute('object', $this->mObject); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_OBJECT_IS_NOT_EXIST); + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/legacyRender/admin/actions/TplsetCloneAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplsetCloneAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplsetCloneAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,84 @@ +<?php +/** + * @package legacyRender + * @version $Id: TplsetCloneAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/actions/TplsetEditAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplsetCloneForm.class.php"; + +class LegacyRender_TplsetCloneAction extends LegacyRender_TplsetEditAction +{ + var $mCloneObject = null; + + function _setupObject() + { + parent::_setupObject(); + $this->mCloneObject =& $this->mObjectHandler->create(); + } + + function _setupActionForm() + { + $this->mActionForm =& new LegacyRender_TplsetCloneForm(); + $this->mActionForm->prepare(); + } + + function isAllowDefault() + { + return true; + } + + function execute(&$controller, &$xoopsUser) + { + if ($this->mObject == null) { + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + if (xoops_getrequest('_form_control_cancel') != null) { + return LEGACYRENDER_FRAME_VIEW_CANCEL; + } + + // + // If image is no, the data has to continue to keep his value. + // + $this->mActionForm->load($this->mCloneObject); + + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + + if($this->mActionForm->hasError()) { + return LEGACYRENDER_FRAME_VIEW_INPUT; + } + + $this->mActionForm->update($this->mCloneObject); + + return $this->mObjectHandler->insertClone($this->mObject, $this->mCloneObject) ? LEGACYRENDER_FRAME_VIEW_SUCCESS + : LEGACYRENDER_FRAME_VIEW_ERROR; + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("tplset_clone.html"); + $render->setAttribute('actionForm', $this->mActionForm); + $render->setAttribute('object', $this->mObject); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=TplsetList"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=TplsetList"); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/TplsetDeleteAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplsetDeleteAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplsetDeleteAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,66 @@ +<?php +/** + * @package legacyRender + * @version $Id: TplsetDeleteAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractDeleteAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplsetDeleteForm.class.php"; + +class LegacyRender_TplsetDeleteAction extends LegacyRender_AbstractDeleteAction +{ + function _getId() + { + return xoops_getrequest('tplset_id'); + } + + function &_getHandler() + { + $handler = xoops_getmodulehandler('tplset'); + return $handler; + } + + function _setupObject() + { + $id = $this->_getId(); + + $this->mObjectHandler = $this->_getHandler(); + + $this->mObject =& $this->mObjectHandler->get($id); + if (is_object($this->mObject) && $this->mObject->get('tplset_name') == 'default') { + $this->mObject = null; + } + } + + function _setupActionForm() + { + $this->mActionForm =& new LegacyRender_TplsetDeleteForm(); + $this->mActionForm->prepare(); + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("tplset_delete.html"); + $render->setAttribute('actionForm', $this->mActionForm); + $render->setAttribute('object', $this->mObject); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=TplsetList"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=TplsetList"); + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/legacyRender/admin/actions/TplsetDownloadAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplsetDownloadAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplsetDownloadAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,118 @@ +<?php +/** + * @package legacyRender + * @version $Id: TplsetDownloadAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplfileEditForm.class.php"; + +class LegacyRender_TplsetDownloadAction extends LegacyRender_Action +{ + var $mPreparedFlag = false; + + var $mTplset = null; + + var $mDownloader = null; + + function &_createDownloader($method) + { + $ret = null; + + switch ($method) { + case 'tar': + if (@function_exists('gzencode')) { + require_once XOOPS_ROOT_PATH . "/class/tardownloader.php"; + $ret =& new XoopsTarDownloader(); + } + break; + case 'zip': + if (@function_exists('gzcompress')) { + require_once XOOPS_ROOT_PATH . "/class/zipdownloader.php"; + $ret =& new XoopsZipDownloader(); + } + break; + } + + return $ret; + } + + + function getDefaultView(&$controller, &$xoopsUser) + { + $method = xoops_getrequest('method') == 'tar' ? 'tar' : 'zip'; + $this->mDownloader =& $this->_createDownloader($method); + + if ($this->mDownloader == null) { + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + $id = xoops_getrequest('tplset_id'); + + $handler =& xoops_getmodulehandler('tplset'); + $this->mTplset =& $handler->get($id); + + if ($this->mTplset == null) { + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + $xml = "<?xml version=\"1.0\"?>" . "\n" . + "<tplset>" . "\n" . + " <name>" . $this->mTplset->getShow('tplset_name') . "</name>" . "\n" . + " <dateCreated>" . $this->mTplset->getShow('tplset_created') . "</dateCreated>" . "\n" . + " <credits>" . $this->mTplset->getShow('tplset_credits') . "</credits>" . "\n" . + " <generator>" . XOOPS_VERSION. "</generator>" . "\n"; + + $handler =& xoops_getmodulehandler('tplfile'); + $files =& $handler->getObjects(new Criteria('tpl_tplset', $this->mTplset->get('tplset_name'))); + + $count = count($files); + + if ($count > 0) { + $xml .= " <templates>" . "\n"; + for ($i = 0; $i < $count; $i++) { + $files[$i]->loadSource(); + if ($files[$i]->Source != null) { + $type = null; + if ($files[$i]->get('tpl_type') == 'block') { + $path = $this->mTplset->getShow('tplset_name') . '/templates/' . $files[$i]->getShow('tpl_module') . "/blocks/" . $files[$i]->getShow('tpl_file'); + $type = "block"; + } + elseif ($files[$i]->get('tpl_type') == 'module') { + $path = $this->mTplset->getShow('tplset_name') . '/templates/' . $files[$i]->getShow('tpl_module') . "/" . $files[$i]->getShow('tpl_file'); + $type = "module"; + } + $xml .= ' <template name="' . $files[$i]->getShow('tpl_file') . '">' . "\n" . + " <module>" . $files[$i]->getShow('tpl_module') . "</module>" . "\n" . + " <type>module</type>" . "\n" . + " <lastModified>" . $files[$i]->getShow('tpl_lastmodified') . "</lastModified>" . "\n" . + " </template>" . "\n"; + + $this->mDownloader->addFileData($files[$i]->Source->get('tpl_source'), $path, $files[$i]->getShow('tpl_lastmodified')); + } + } + + $xml .= " </templates>" . "\n"; + } + + $xml .= "</tplset>"; + + $this->mDownloader->addFileData($xml, $this->mTplset->getShow('tplset_name') . '/tplset.xml', time()); + + return LEGACYRENDER_FRAME_VIEW_SUCCESS; + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + print $this->mDownloader->download($this->mTplset->getShow('tplset_name'), true); + exit(0); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/TplsetEditAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplsetEditAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplsetEditAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,75 @@ +<?php +/** + * @version legacyRender + * @version $Id: TplsetEditAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractEditAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplsetEditForm.class.php"; + +class LegacyRender_TplsetEditAction extends LegacyRender_AbstractEditAction +{ + function _getId() + { + return xoops_getrequest('tplset_id'); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('tplset'); + return $handler; + } + + function _setupObject() + { + parent::_setupObject(); + + if ($this->isAllowDefault() == false) { + if (is_object($this->mObject) && $this->mObject->get('tplset_name') == 'default') { + $this->mObject = null; + } + } + } + + function _setupActionForm() + { + $this->mActionForm =& new LegacyRender_TplsetEditForm(); + $this->mActionForm->prepare(); + } + + function isEnableCreate() + { + return false; + } + + function isAllowDefault() + { + return false; + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("tplset_edit.html"); + $render->setAttribute('actionForm', $this->mActionForm); + $render->setAttribute('object', $this->mObject); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=TplsetList"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=TplsetList"); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/TplsetListAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplsetListAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplsetListAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,89 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractListAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplsetFilterForm.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplsetSelectForm.class.php"; + +class LegacyRender_TplsetListAction extends LegacyRender_AbstractListAction +{ + var $mActionForm = null; + var $mActiveTemplateSet = null; + + function prepare(&$controller, &$xoopsUser, $moduleConfig) + { + LegacyRender_AbstractListAction::prepare($controller, $xoopsUser, $moduleConfig); + $this->mActionForm =& new LegacyRender_TplsetSelectForm(); + $this->mActionForm->prepare(); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('tplset'); + return $handler; + } + + function &_getFilterForm() + { + $filter =& new LegacyRender_TplsetFilterForm($this->_getPageNavi(), $this->_getHandler()); + return $filter; + } + + function _getBaseUrl() + { + return "./index.php?action=TplsetList"; + } + + function execute(&$controller, &$xoopsUser) + { + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + if (!$this->mActionForm->hasError()) { + $configHandler =& xoops_gethandler('config'); + + $criteria =& new CriteriaCompo(); + $criteria->add(new Criteria('conf_name', 'template_set')); + $criteria->add(new Criteria('conf_catid', XOOPS_CONF)); + + $configs =& $configHandler->getConfigs($criteria); + if (count($configs) > 0) { + $configs[0]->set('conf_value', $this->mActionForm->get('tplset_name')); + $configHandler->insertConfig($configs[0]); + $this->mActiveTemplateSet = $this->mActionForm->get('tplset_name'); + } + } + + return $this->getDefaultView($controller, $xoopsUser); + } + + function executeViewIndex(&$controller, &$xoopsUser, &$render) + { + // + // Load the list of module templates. + // + foreach (array_keys($this->mObjects) as $key) { + $this->mObjects[$key]->loadModuletpl(); + } + + if ($this->mActiveTemplateSet == null) { + $this->mActiveTemplateSet = $controller->mRoot->mContext->getXoopsConfig('template_set'); + } + + $render->setTemplateName("tplset_list.html"); + $render->setAttribute('objects', $this->mObjects); + $render->setAttribute('pageNavi', $this->mFilter->mNavi); + $render->setAttribute('activeTemplateSet', $this->mActiveTemplateSet); + $render->setAttribute('actionForm', $this->mActionForm); + + // + // Assign recent modified tplfile objects + // + $handler =& xoops_getmodulehandler('tplfile'); + $recentObjects =& $handler->getRecentModifyFile(); + + $render->setAttribute('recentObjects', $recentObjects); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/TplsetUploadAction.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/TplsetUploadAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/TplsetUploadAction.class.php Mon Apr 30 16:35:09 2007 @@ -0,0 +1,205 @@ +<?php +/** + * @package legacyRender + * @version $Id: TplsetUploadAction.class.php,v 1.1.4.1 2007/04/30 07:35:09 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacyRender/class/AbstractEditAction.class.php"; +require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplsetUploadForm.class.php"; + +class LegacyRender_TplsetUploadAction extends LegacyRender_Action +{ + var $mActionForm = null; + var $mErrorMessages = array(); + + function prepare(&$controller, &$xoopsUser) + { + $this->mActionForm =& new LegacyRender_TplsetUploadForm(); + $this->mActionForm->prepare(); + } + + function getDefaultView(&$controller, &$xoopsUser) + { + return LEGACYRENDER_FRAME_VIEW_INPUT; + } + + function _addErrorMessage($msg) + { + $this->mErrorMessages[] = $msg; + } + + function execute(&$controller, &$xoopsUser) + { + if (xoops_getrequest('_form_control_cancel') != null) { + return LEGACYRENDER_FRAME_VIEW_CANCEL; + } + + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + + if ($this->mActionForm->hasError()) { + return $this->getDefaultView($controller, $xoopsUser); + } + + require_once XOOPS_ROOT_PATH . "/class/class.tar.php"; + $tar =& new tar(); + + $formFile = $this->mActionForm->get('upload'); + + // + // [Warn] access private member directly + // TODO We should define the access method because we oftern + // access private member of XCube_FormFile. + // + $tar->openTar($formFile->_mTmpFileName); + + if (!is_array($tar->files)) { + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + $tplsetName = null; + foreach ($tar->files as $id => $info) { + $infoArr = explode('/', str_replace("\\", '/', $info['name'])); + $tplsetName = $this->mActionForm->get('tplset_name'); + if ($tplsetName == null) { + $tplsetName = trim($infoArr[0]); + } + + if ($tplsetName != null) { + break; + } + } + + // + // Check tplset name. + // + if ($tplsetName == null || preg_match('/[' . preg_quote('\/:*?"<>|','/') . ']/', $tplsetName)) { + $this->_addErrorMessage(_AD_LEGACYRENDER_ERROR_TPLSET_NAME_WRONG); + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + $handler =& xoops_getmodulehandler('tplset'); + if ($handler->getCount(new Criteria('tplset_name', $tplsetName)) != 0) { + $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_TPLSET_ALREADY_EXISTS, $tplsetName)); + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + $tplset =& $handler->create(); + $tplset->set('tplset_name', $tplsetName); + if (!$handler->insert($tplset)) { + $this->_addErrorMessage(_AD_LEGACYRENDER_ERROR_COULD_NOT_SAVE_TPLSET); + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + $themeimages = array(); + if (!$this->_fetchTemplateFiles($tar, $tplset, $themeimages)) { + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + if (!$this->_fetchImageset($tar, $tplset, $themeimages)) { + return LEGACYRENDER_FRAME_VIEW_ERROR; + } + + return LEGACYRENDER_FRAME_VIEW_SUCCESS; + } + + function _fetchTemplateFiles(&$tar, &$tplset, &$themeimages) + { + $handler =& xoops_getmodulehandler('tplfile'); + foreach ($tar->files as $id => $info) { + $infoArr = explode('/', str_replace("\\", '/', $info['name'])); + if (isset($infoArr[3]) && trim($infoArr[3]) == 'blocks') { + $default =& $handler->find('default', 'block', null, trim($infoArr[2]), trim($infoArr[4])); + } elseif ((!isset($infoArr[4]) || trim($infoArr[4]) == '') && $infoArr[1] == 'templates') { + $default =& $handler->find('default', 'module', null, trim($infoArr[2]), trim($infoArr[3])); + } elseif (isset($infoArr[3]) && trim($infoArr[3]) == 'images') { + $infoArr[2] = trim($infoArr[2]); + if (preg_match("/(.*)\.(gif|jpg|jpeg|png)$/i", $infoArr[2], $match)) { + $themeimages[] = array('name' => $infoArr[2], 'content' => $info['file']); + } + } + if (count($default) > 0) { + $tplfile =& $default[0]->createClone($tplset->get('tplset_name')); + $tplfile->Source->set('tpl_source', $info['file']); + $tplfile->set('tpl_lastimported', time()); + + if (!$handler->insert($tplfile)) { + $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_COULD_NOT_SAVE_TPLFILE, $tplfile->get('tpl_file'))); + } + unset($default); + } + unset($info); + } + + return true; + } + + function _fetchImageset(&$tar, &$tplset, &$themeimages) + { + if (count($themeimages) == 0) { + return true; + } + + $handler =& xoops_gethandler('imageset'); + $imgset =& $handler->create(); + $imgset->set('imgset_name', $tplset->get('tplset_name')); + $imgset->set('imgset_refid', 0); + + if (!$handler->insert($imgset)) { + $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_COULD_NOT_SAVE_IMAGESET, $tplset->get('tplset_name'))); + return false; + } + + if (!$handler->linktplset($imgset->get('imgset_id'), $tplset->get('tplset_name'))) { + $this->_addErrorMessage(_AD_LEGACYRENDER_ERROR_COULD_NOT_SAVE_LINKTPLSET); + return false; + } + + $handler =& xoops_gethandler('imagesetimg'); + for ($i = 0; $i < count($themeimages); $i++) { + if (isset($themeimages[$i]['name']) && $themeimages[$i]['name'] != '') { + $image =& $handler->create(); + $image->set('imgsetimg_file', $themeimages[$i]['name']); + $image->set('imgsetimg_imgset', $imgset->get('imgset_id')); + $image->set('imgsetimg_body', $themeimages[$i]['content'], true); + if (!$handler->insert($image)) { + $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_COULD_NOT_SAVE_IMAGE_FILE, $image->get('imgsetimg_file'))); + } + unset($image); + } + } + + return true; + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("tplset_upload.html"); + $render->setAttribute('actionForm', $this->mActionForm); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=TplsetList"); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + if (count($this->mErrorMessages) == 0) { + $controller->executeRedirect("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED); + } + else { + $render->setTemplateName("tplset_upload_error.html"); + $render->setAttribute('errorMessages', $this->mErrorMessages); + } + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("./index.php?action=TplsetList"); + } +} + +?> Index: xoops2jp/html/modules/legacyRender/admin/actions/index.html diff -u /dev/null xoops2jp/html/modules/legacyRender/admin/actions/index.html:1.1.4.1 --- /dev/null Mon Apr 30 16:35:09 2007 +++ xoops2jp/html/modules/legacyRender/admin/actions/index.html Mon Apr 30 16:35:09 2007 @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file