[xoops-cvslog 3416] CVS update: xoops2jp/html/modules/pm/class

Back to archive index

Minahito minah****@users*****
2006年 7月 4日 (火) 18:48:35 JST


Index: xoops2jp/html/modules/pm/class/AbstractEditAction.class.php
diff -u /dev/null xoops2jp/html/modules/pm/class/AbstractEditAction.class.php:1.1.2.1
--- /dev/null	Tue Jul  4 18:48:34 2006
+++ xoops2jp/html/modules/pm/class/AbstractEditAction.class.php	Tue Jul  4 18:48:34 2006
@@ -0,0 +1,89 @@
+<?php
+/**
+ * @package Pm
+ * @version $Id: AbstractEditAction.class.php,v 1.1.2.1 2006/07/04 09:48:34 minahito Exp $
+ */
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+class Pm_AbstractEditAction extends Pm_AbstractAction
+{
+	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, &$moduleConfig)
+	{
+		$this->_setupObject();
+		$this->_setupActionForm();
+	}
+
+	function getDefaultView(&$controller, &$xoopsUser)
+	{
+		if ($this->mObject == null) {
+			return PM_FRAME_VIEW_ERROR;
+		}
+	
+		$this->mActionForm->load($this->mObject);
+	
+		return PM_FRAME_VIEW_INPUT;
+	}
+
+	function execute(&$controller, &$xoopsUser)
+	{
+		if ($this->mObject == null) {
+			return PM2_FRAME_VIEW_ERROR;
+		}
+	
+		$this->mActionForm->load($this->mObject);
+		
+		$this->mActionForm->fetch();
+		$this->mActionForm->validate();
+	
+		if($this->mActionForm->hasError()) {
+			return PM_FRAME_VIEW_INPUT;
+		}
+	
+		$this->mActionForm->update($this->mObject);
+		
+		return $this->_doExecute($this->mObject) ? PM_FRAME_VIEW_SUCCESS
+		                                         : PM_FRAME_VIEW_ERROR;
+	}
+
+	function _doExecute()
+	{
+		return $this->mObjectHandler->insert($this->mObject);
+	}
+}
+
+?>
Index: xoops2jp/html/modules/pm/class/ActionFrame.class.php
diff -u /dev/null xoops2jp/html/modules/pm/class/ActionFrame.class.php:1.1.2.1
--- /dev/null	Tue Jul  4 18:48:34 2006
+++ xoops2jp/html/modules/pm/class/ActionFrame.class.php	Tue Jul  4 18:48:34 2006
@@ -0,0 +1,165 @@
+<?php
+/**
+ * @package Pm
+ * @version $Id: ActionFrame.class.php,v 1.1.2.1 2006/07/04 09:48:34 minahito Exp $
+ */
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+require_once XOOPS_ROOT_PATH . "/class/XCube_ActionStrategy.class.php";
+
+define ("PM_FRAME_PERFORM_SUCCESS", 1);
+define ("PM_FRAME_PERFORM_FAIL", 2);
+define ("PM_FRAME_INIT_SUCCESS", 3);
+
+define ("PM_FRAME_VIEW_NONE", 1);
+define ("PM_FRAME_VIEW_SUCCESS", 2);
+define ("PM_FRAME_VIEW_ERROR", 3);
+define ("PM_FRAME_VIEW_INDEX", 4);
+define ("PM_FRAME_VIEW_INPUT", 5);
+
+class Pm_ActionFrame extends XCube_ActionStrategy
+{
+	var $mActionName = null;
+	var $mAction = null;
+	var $mAdminFlag = null;
+
+	function Pm_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 = "Pm_" . ucfirst($this->mActionName) . "Action";
+		$fileName = ucfirst($this->mActionName) . "Action";
+		if ($this->mAdminFlag) {
+			$fileName = XOOPS_MODULE_PATH . "/pm/admin/actions/${fileName}.class.php";
+		}
+		else {
+			$fileName = XOOPS_MODULE_PATH . "/pm/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)) {
+			$this->doActionNotFoundError($controller);
+			return;
+		}
+	
+		$handler =& xoops_gethandler('config');
+		$moduleConfig =& $handler->getConfigsByDirname('pm');
+	
+		$this->mAction->prepare($controller, $controller->getXoopsUser(), $moduleConfig);
+	
+		if (!$this->mAction->hasPermission($controller, $controller->getXoopsUser(), $moduleConfig)) {
+			$this->doPermissionError();
+			return;
+		}
+	
+		if (xoops_getenv("REQUEST_METHOD") == "POST") {
+			$viewStatus = $this->mAction->execute($controller, $controller->getXoopsUser());
+		}
+		else {
+			$viewStatus = $this->mAction->getDefaultView($controller, $controller->getXoopsUser());
+		}
+	
+		switch($viewStatus) {
+			case PM_FRAME_VIEW_SUCCESS:
+				$this->mAction->executeViewSuccess($controller, $controller->getXoopsUser(), $controller->mRenderSystem);
+				break;
+		
+			case PM_FRAME_VIEW_ERROR:
+				$this->mAction->executeViewError($controller, $controller->getXoopsUser(), $controller->mRenderSystem);
+				break;
+		
+			case PM_FRAME_VIEW_INDEX:
+				$this->mAction->executeViewIndex($controller, $controller->getXoopsUser(), $controller->mRenderSystem);
+				break;
+		
+			case PM_FRAME_VIEW_INPUT:
+				$this->mAction->executeViewInput($controller, $controller->getXoopsUser(), $controller->mRenderSystem);
+				break;
+		}
+	}
+
+	function doPermissionError()
+	{
+		$errorMessages = array(_PM_SORRY, _PM_PLZREG);
+		XCube_Utils::redirectHeader(XOOPS_URL, 2, $errorMessages);
+	}
+
+	function doActionNotFoundError($controller)
+	{
+		$controller->executeForward(XOOPS_URL);
+		return;
+	}
+
+	function checkPermission($name, $itemIds)
+	{
+	}
+}
+
+class Pm_AbstractAction
+{
+	function Pm_AbstractAction()
+	{
+	}
+
+	function prepare(&$controller, &$xoopsUser)
+	{
+	}
+
+	function hasPermission(&$controller, &$xoopsUser, &$moduleConfig)
+	{
+		return is_object($xoopsUser);
+	}
+
+	function getDefaultView(&$controller, &$xoopsUser)
+	{
+		return PM_FRAME_VIEW_NONE;
+	}
+
+	function execute(&$controller, &$xoopsUser)
+	{
+		return PM_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/pm/class/AbstractDeleteAction.class.php
diff -u /dev/null xoops2jp/html/modules/pm/class/AbstractDeleteAction.class.php:1.1.2.1
--- /dev/null	Tue Jul  4 18:48:34 2006
+++ xoops2jp/html/modules/pm/class/AbstractDeleteAction.class.php	Tue Jul  4 18:48:34 2006
@@ -0,0 +1,24 @@
+<?php
+/**
+ * @package Pm
+ * @version $Id: AbstractDeleteAction.class.php,v 1.1.2.1 2006/07/04 09:48:34 minahito Exp $
+ */
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+require_once XOOPS_MODULE_PATH . "/pm/class/AbstractEditAction.class.php";
+
+class Pm_AbstractDeleteAction extends Pm_AbstractEditAction
+{
+	function isEnableCreate()
+	{
+		return false;
+	}
+
+	function _doExecute()
+	{
+		return $this->mObjectHandler->delete($this->mObject);
+	}
+}
+
+?>


xoops-cvslog メーリングリストの案内
Back to archive index