[xoops-cvslog 4726] CVS update: xoops2jp/html/modules/base/admin/actions

Back to archive index

Minahito minah****@users*****
2006年 10月 2日 (月) 19:21:10 JST


Index: xoops2jp/html/modules/base/admin/actions/ImageCreateAction.class.php
diff -u /dev/null xoops2jp/html/modules/base/admin/actions/ImageCreateAction.class.php:1.1.2.1
--- /dev/null	Mon Oct  2 19:21:10 2006
+++ xoops2jp/html/modules/base/admin/actions/ImageCreateAction.class.php	Mon Oct  2 19:21:10 2006
@@ -0,0 +1,116 @@
+<?php
+/**
+ * @package Legacy
+ * @version $Id: ImageCreateAction.class.php,v 1.1.2.1 2006/10/02 10:21:10 minahito Exp $
+ */
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+require_once XOOPS_MODULE_PATH . "/base/class/AbstractEditAction.class.php";
+require_once XOOPS_MODULE_PATH . "/base/admin/forms/ImageAdminEditForm.class.php";
+
+class Legacy_ImageCreateAction extends Legacy_AbstractEditAction
+{
+	function _getId()
+	{
+		return 0;
+	}
+
+	function &_getHandler()
+	{
+		$handler =& xoops_getmodulehandler('image', 'base');
+		return $handler;
+	}
+
+	function _setupActionForm()
+	{
+		$this->mActionForm =& new Legacy_ImageAdminCreateForm();
+		$this->mActionForm->prepare();
+	}
+	
+	function getDefaultView(&$controller, &$xoopsUser)
+	{
+		$flag = parent::getDefaultView($controller, $xoopsUser);
+		
+		if ($flag == LEGACY_FRAME_VIEW_INPUT && $this->_enableCatchImgcat()) {
+			$this->mActionForm->set('imgcat_id', xoops_getrequest('imgcat_id'));
+		}
+		
+		return $flag;
+	}
+	
+	function _enableCatchImgcat()
+	{
+		return true;
+	}
+
+	function _doExecute()
+	{
+		$handler =& xoops_getmodulehandler('imagecategory', 'base');
+		$category =& $handler->get($this->mActionForm->get('imgcat_id'));
+		
+		//
+		// [TODO]
+		// Should the following procedure be after parent::_doExecute()?
+		//
+		if ($category->get('imgcat_storetype') == 'file') {
+			$this->_storeFile();
+		}
+		else {
+			$this->_storeDB();
+		}
+	
+		return parent::_doExecute();
+	}
+	
+	function _storeFile()
+	{
+		if ($this->mActionForm->mFormFile != null) {
+			if (!$this->mActionForm->mFormFile->saveAs(XOOPS_UPLOAD_PATH)) {
+				return false;
+			}
+		}
+		
+		//
+		// If there is a old file, delete it
+		//
+		if ($this->mActionForm->mOldFilename != null) {
+			@unlink(XOOPS_UPLOAD_PATH . "/" . $this->mActionForm->mOldFilename);
+		}
+	}
+	
+	function _storeDB()
+	{
+		
+	}
+
+	function executeViewInput(&$controller, &$xoopsUser, &$render)
+	{
+		$this->mObject->loadImagecategory();
+
+		$render->setTemplateName("image_edit.html");
+		$render->setAttribute('actionForm', $this->mActionForm);
+		$render->setAttribute('object', $this->mObject);
+		
+		$handler =& xoops_getmodulehandler('imagecategory', 'base');
+		$categoryArr =& $handler->getObjects();
+		$render->setAttribute('categoryArr', $categoryArr);
+	}
+
+	function executeViewSuccess(&$controller, &$xoopsUser, &$render)
+	{
+		$controller->executeForward("./index.php?action=ImageList&imgcat_id=" . $this->mActionForm->get('imgcat_id'));
+	}
+
+	function executeViewError(&$controller, &$xoopsUser, &$render)
+	{
+		$controller->executeRedirect("./index.php?action=ImagecategoryList", 1, _MD_BASE_ERROR_DBUPDATE_FAILED);
+	}
+	
+	function executeViewCancel(&$controller, &$xoopsUser, &$render)
+	{
+		$controller->executeForward("./index.php?action=ImageList&imgcat_id=" . $this->mActionForm->get('imgcat_id'));
+	}
+}
+
+?>


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