Minahito
minah****@users*****
2006年 1月 26日 (木) 01:18:03 JST
Index: xoops2jp/html/modules/base/class/ActionFrame.class.php diff -u /dev/null xoops2jp/html/modules/base/class/ActionFrame.class.php:1.1.2.1 --- /dev/null Thu Jan 26 01:18:03 2006 +++ xoops2jp/html/modules/base/class/ActionFrame.class.php Thu Jan 26 01:18:03 2006 @@ -0,0 +1,129 @@ +<?php + +require_once XOOPS_ROOT_PATH . "/class/XCube_ActionStrategy.class.php"; + +define ("LEGACY_FRAME_PERFORM_SUCCESS", 1); +define ("LEGACY_FRAME_PERFORM_FAIL", 2); +define ("LEGACY_FRAME_INIT_SUCCESS", 3); + +define ("LEGACY_FRAME_VIEW_NONE", 1); +define ("LEGACY_FRAME_VIEW_SUCCESS", 2); +define ("LEGACY_FRAME_VIEW_ERROR", 3); +define ("LEGACY_FRAME_VIEW_INDEX", 4); +define ("LEGACY_FRAME_VIEW_INPUT", 5); + +class Legacy_ActionFrame extends XCube_ActionStrategy +{ + var $mActionName = null; + var $mAction = null; + var $mAdminFlag = null; + + function Legacy_ActionFrame($admin) + { + $this->mAdminFlag = $admin; + } + + function setActionName($name) + { + $this->mActionName = $name; + } + + function &execute(&$controller) + { + if (!preg_match("/^\w+$/", $this->mActionName)) { + die(); + } + + // + // Create action object by mActionName + // + $className = "Legacy_" . ucfirst($this->mActionName) . "Action"; + $fileName = ucfirst($this->mActionName) . "Action"; + if ($this->mAdminFlag) { + $fileName = XOOPS_MODULE_PATH . "/base/admin/actions/${fileName}.class.php"; + } + else { + $fileName = XOOPS_MODULE_PATH . "/base/actions/${fileName}.class.php"; + } + + if (!file_exists($fileName)) { + die(); + } + + require_once $fileName; + + if (class_exists($className)) { + $this->mAction =& new $className(); + } + + if (!is_object($this->mAction)) { + die(); + } + + $this->mAction->prepare($controller, $controller->getXoopsUser()); + + if (xoops_getenv("REQUEST_METHOD") == "POST") { + $viewStatus = $this->mAction->execute($controller, $controller->getXoopsUser()); + } + else { + $viewStatus = $this->mAction->getDefaultView($controller, $controller->getXoopsUser()); + } + + switch($viewStatus) { + case LEGACY_FRAME_VIEW_SUCCESS: + $this->mAction->executeViewSuccess($controller, $controller->getXoopsUser(), $controller->mRenderSystem); + break; + + case LEGACY_FRAME_VIEW_ERROR: + $this->mAction->executeViewError($controller, $controller->getXoopsUser(), $controller->mRenderSystem); + break; + + case LEGACY_FRAME_VIEW_INDEX: + $this->mAction->executeViewIndex($controller, $controller->getXoopsUser(), $controller->mRenderSystem); + break; + + case LEGACY_FRAME_VIEW_INPUT: + $this->mAction->executeViewInput($controller, $controller->getXoopsUser(), $controller->mRenderSystem); + break; + } + } +} + +class Legacy_Action +{ + function Legacy_Action() + { + } + + function prepare(&$controller, &$xoopsUser) + { + } + + function getDefaultView(&$controller, &$xoopsUser) + { + return LEGACY_FRAME_VIEW_NONE; + } + + function execute(&$controller, &$xoopsUser) + { + return LEGACY_FRAME_VIEW_NONE; + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewIndex(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + } +} + +?> Index: xoops2jp/html/modules/base/class/AbstractEditAction.class.php diff -u /dev/null xoops2jp/html/modules/base/class/AbstractEditAction.class.php:1.1.2.1 --- /dev/null Thu Jan 26 01:18:03 2006 +++ xoops2jp/html/modules/base/class/AbstractEditAction.class.php Thu Jan 26 01:18:03 2006 @@ -0,0 +1,83 @@ +<?php + +class Legacy_AbstractEditAction extends Legacy_Action +{ + var $mObject = null; + var $mObjectHandler = null; + var $mActionForm = null; + + function _getId() + { + } + + function &_getHandler() + { + } + + function _setupActionForm() + { + } + + function _setupObject() + { + $id = $this->_getId(); + + $this->mObjectHandler = $this->_getHandler(); + + $this->mObject =& $this->mObjectHandler->get($id); + + if ($this->mObject == null && $this->isEnableCreate()) { + $this->mObject =& $this->mObjectHandler->create(); + } + } + + function isEnableCreate() + { + return true; + } + + function prepare(&$controller, &$xoopsUser) + { + $this->_setupActionForm(); + $this->_setupObject(); + } + + function getDefaultView(&$controller, &$xoopsUser) + { + if ($this->mObject == null) { + return LEGACY_FRAME_VIEW_ERROR; + } + + $this->mActionForm->load($this->mObject); + + return LEGACY_FRAME_VIEW_INPUT; + } + + function execute(&$controller, &$xoopsUser) + { + if ($this->mObject == null) { + return LEGACY_FRAME_VIEW_ERROR; + } + + $this->mActionForm->load($this->mObject); + + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + + if($this->mActionForm->hasError()) { + return LEGACY_FRAME_VIEW_INPUT; + } + + $this->mActionForm->update($this->mObject); + + return $this->_doExecute($this->mObject) ? LEGACY_FRAME_VIEW_SUCCESS + : LEGACY_FRAME_VIEW_ERROR; + } + + function _doExecute() + { + return $this->mObjectHandler->insert($this->mObject); + } +} + +?> Index: xoops2jp/html/modules/base/class/AbstractDeleteAction.class.php diff -u /dev/null xoops2jp/html/modules/base/class/AbstractDeleteAction.class.php:1.1.2.1 --- /dev/null Thu Jan 26 01:18:03 2006 +++ xoops2jp/html/modules/base/class/AbstractDeleteAction.class.php Thu Jan 26 01:18:03 2006 @@ -0,0 +1,18 @@ +<?php + +require_once XOOPS_MODULE_PATH . "/base/class/AbstractEditAction.class.php"; + +class Legacy_AbstractDeleteAction extends Legacy_AbstractEditAction +{ + function isEnableCreate() + { + return false; + } + + function _doExecute() + { + return $this->mObjectHandler->delete($this->mObject); + } +} + +?> Index: xoops2jp/html/modules/base/class/AbstractFilterForm.class.php diff -u /dev/null xoops2jp/html/modules/base/class/AbstractFilterForm.class.php:1.1.2.1 --- /dev/null Thu Jan 26 01:18:03 2006 +++ xoops2jp/html/modules/base/class/AbstractFilterForm.class.php Thu Jan 26 01:18:03 2006 @@ -0,0 +1,45 @@ +<?php + +class Legacy_AbstractFilterForm +{ + var $mSort = 0; + var $mSortKeys = array(); + var $_mCriteria = null; + var $_mNavi = null; + + function Legacy_AbstractFilterForm(&$navi) + { + $this->mNavi =& $navi; + $this->_mCriteria =& new CriteriaCompo(); + } + + function fetch() + { + } + + function getSort() + { + $sortkey = abs($this->mSort); + return $this->_mSortKeys[$sortkey]; + } + + function getOrder() + { + return ($this->mSort < 0) ? "DESC" : "ASC"; + } + + function getCriteria($start = 0, $limit = 0) + { + $criteria = $this->_mCriteria; + + $criteria->setStart($start); + $criteria->setLimit($limit); + + $criteria->setSort($this->getSort()); + $criteria->setOrder($this->getOrder()); + + return $criteria; + } +} + +?> Index: xoops2jp/html/modules/base/class/AbstractListAction.class.php diff -u /dev/null xoops2jp/html/modules/base/class/AbstractListAction.class.php:1.1.2.1 --- /dev/null Thu Jan 26 01:18:03 2006 +++ xoops2jp/html/modules/base/class/AbstractListAction.class.php Thu Jan 26 01:18:03 2006 @@ -0,0 +1,43 @@ +<?php + +require_once XOOPS_MODULE_PATH . "/base/class/PageNavigator.class.php"; + +class Legacy_AbstractListAction extends Legacy_Action +{ + var $mObjects = array(); + var $mFilter = null; + var $mNavi = null; + + function &_getHandler() + { + } + + function &_getFilterForm(&$navi) + { + } + + function _getBaseUrl() + { + } + + function getDefaultView(&$controller, &$xoopsUser) + { + $this->mNavi =& new Legacy_PageNavigator($this->_getBaseUrl(), 0, XCUBE_PAGENAVI_START | XCUBE_PAGENAVI_PERPAGE); + + $this->mFilter =& $this->_getFilterForm($this->mNavi); + $this->mFilter->fetch(); + $handler =& $this->_getHandler(); + + $total = $handler->getCount($this->mFilter->getCriteria()); + + $this->mNavi->setTotal($total); + $this->mNavi->fetch(); + + $criteria = $this->mFilter->getCriteria($this->mNavi->getStart(), $this->mNavi->getPerpage()); + $this->mObjects =& $handler->getObjects($criteria); + + return LEGACY_FRAME_VIEW_INDEX; + } +} + +?>