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

Zurück zum Archiv-Index

Minahito minah****@users*****
2006年 5月 12日 (金) 19:13:36 JST


Index: xoops2jp/html/modules/base/admin/actions/PreferenceEditAction.class.php
diff -u /dev/null xoops2jp/html/modules/base/admin/actions/PreferenceEditAction.class.php:1.1.2.1
--- /dev/null	Fri May 12 19:13:36 2006
+++ xoops2jp/html/modules/base/admin/actions/PreferenceEditAction.class.php	Fri May 12 19:13:36 2006
@@ -0,0 +1,198 @@
+<?php
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+require_once XOOPS_MODULE_PATH . "/base/admin/forms/PreferenceEditForm.class.php";
+
+class Legacy_PreferenceEditAction extends Legacy_Action
+{
+	var $mPreparedFlag = false;
+
+	var $mObjects = array();
+	var $mActionForm = null;
+
+	function prepare(&$controller, &$xoopsUser)
+	{
+		$state = (xoops_getrequest('confmod_id') > 0) ? new Legacy_ModulePreferenceEditState($this) : new Legacy_PreferenceEditState($this);
+		$state->prepare($controller, $xoopsUser);
+		
+		if ($this->mPreparedFlag) {
+			$handler =& xoops_gethandler('config');
+			
+			$criteria =& new CriteriaCompo();
+			$criteria->add(new Criteria('conf_modid', $this->mActionForm->getModuleId()));
+			$criteria->add(new Criteria('conf_catid', $this->mActionForm->getCategoryId()));
+			
+			$this->mObjects =& $handler->getConfigs($criteria);
+			$this->mActionForm->prepare($this->mObjects);
+		}
+	}
+	
+	function getDefaultView(&$controller, &$xoopsUser)
+	{
+		if (!$this->mPreparedFlag) {
+			return LEGACY_FRAME_VIEW_ERROR;
+		}
+		
+		return LEGACY_FRAME_VIEW_INPUT;
+	}
+	
+	function execute(&$controller, &$xoopsUser)
+	{
+		if (!$this->mPreparedFlag) {
+			return LEGACY_FRAME_VIEW_ERROR;
+		}
+		
+		$this->mActionForm->fetch();
+		$this->mActionForm->validate();
+		
+		if ($this->mActionForm->hasError()) {
+			return $this->getDefaultView($controller, $xoopsUser);
+		}
+		
+		$this->mActionForm->update($this->mObjects);
+		$handler =& xoops_gethandler('config');
+		
+		foreach (array_keys($this->mObjects) as $key) {
+			if (!$handler->insertConfig($this->mObjects[$key])) {
+				die("ERROR" . $this->mObjects[$key]->get('conf_name'));
+			}
+		}
+		
+		return LEGACY_FRAME_VIEW_SUCCESS;
+	}
+
+	function executeViewInput(&$controller, &$xoopsUser, &$render)
+	{
+		$render->setTemplateName("preference_edit.html");
+		$render->setAttribute('actionForm', $this->mActionForm);
+		$render->setAttribute('objectArr', $this->mObjects);
+		
+		$handler =& xoops_gethandler('timezone');
+		$timezoneArr =& $handler->getObjects();
+		$render->setAttribute('timezoneArr', $timezoneArr);
+		
+		$handler =& xoops_gethandler('group');
+		$groupArr =& $handler->getObjects();
+		$render->setAttribute('groupArr', $groupArr);
+
+		//
+		// Make the array of tplset object
+		//
+		$handler =& xoops_gethandler('tplset');
+		$tplsetArr =& $handler->getObjects();
+		$render->setAttribute('tplsetArr', $tplsetArr);
+		
+		//
+		// Make the list of installed languages.
+		//
+		$languageArr = array();
+		$dirHandler = opendir(XOOPS_ROOT_PATH . "/language/");
+		while ($file = readdir($dirHandler)) {
+			if (is_dir(XOOPS_ROOT_PATH . "/language/" . $file) && preg_match("/^[a-z_]+$/", $file)) {
+				$languageArr[$file] = $file;
+			}
+		}
+		closedir($dirHandler);
+		$render->setAttribute('languageArr', $languageArr);
+		
+		
+		//
+		// Make the array of module object for selecting startpage.
+		//
+		$handler =& xoops_gethandler('module');
+		$criteria =& new CriteriaCompo();
+		$criteria->add(new Criteria('hasmain', 1));
+		$criteria->add(new Criteria('isactive', 1));
+		$moduleArr = $handler->getObjects($criteria);
+		$render->setAttribute('moduleArr', $moduleArr);
+		
+		
+		//
+		// Make the list of theme.
+		//
+		$themeArr = array();
+		$dirHandler = opendir(XOOPS_THEME_PATH . "/");
+		while ($file = readdir($dirHandler)) {
+			if (is_dir(XOOPS_THEME_PATH . "/" . $file) && preg_match("/^[a-z_]+$/", $file) && file_exists(XOOPS_THEME_PATH . "/${file}/theme.html")) {
+				$themeArr[$file] = $file;
+			}
+		}
+		closedir($dirHandler);
+		$render->setAttribute('themeArr', $themeArr);
+		
+		//
+		// Make the array of cachetime.
+		//
+		$handler =& xoops_gethandler('cachetime');
+		$cachetimeArr = $handler->getObjects();
+		$render->setAttribute('cachetimeArr', $cachetimeArr);
+		
+		//
+		// Make the list of user
+		//
+		$handler =& xoops_gethandler('member');
+		$userArr = $handler->getUserList();
+		$render->setAttribute('userArr', $userArr);
+	}
+
+	function executeViewSuccess(&$controller, &$xoopsUser, &$render)
+	{
+		$controller->executeForward("./index.php?action=PreferenceList");
+	}
+
+	function executeViewError(&$controller, &$xoopsUser, &$render)
+	{
+		redirect_header("./index.php?action=PreferenceList", 1, _AD_BASE_ERROR_DBUPDATE_FAILED);
+	}
+}
+
+class Legacy_AbstractPreferenceEditState
+{
+	var $mMaster = null;
+
+	function Legacy_AbstractPreferenceEditState(&$master)
+	{
+		$this->mMaster =& $master;
+	}
+	
+	function prepare(&$controller, &$xoopsUser)
+	{
+	}
+}
+
+class Legacy_PreferenceEditState extends Legacy_AbstractPreferenceEditState
+{
+	function prepare(&$controller, &$xoopsUser)
+	{
+		$handler =& xoops_gethandler('configcategory');
+		$category =& $handler->get(intval(xoops_getrequest('confcat_id')));
+		
+		if (!is_object($category)) {
+			return;
+		}
+
+		$this->mMaster->mActionForm =& new Legacy_PreferenceEditForm($category);
+		
+		$this->mMaster->mPreparedFlag = true;
+	}
+}
+
+class Legacy_ModulePreferenceEditState extends Legacy_AbstractPreferenceEditState
+{
+	function prepare(&$controller, &$xoopsUser)
+	{
+		$handler =& xoops_gethandler('module');
+		$module =& $handler->get(intval(xoops_getrequest('confmod_id')));
+
+		if (!is_object($module)) {
+			return;
+		}
+
+		$this->mMaster->mActionForm =& new Legacy_ModulePreferenceEditForm($module);
+		
+		$this->mMaster->mPreparedFlag = true;
+	}
+}
+
+?>
Index: xoops2jp/html/modules/base/admin/actions/PreferenceListAction.class.php
diff -u /dev/null xoops2jp/html/modules/base/admin/actions/PreferenceListAction.class.php:1.1.2.1
--- /dev/null	Fri May 12 19:13:36 2006
+++ xoops2jp/html/modules/base/admin/actions/PreferenceListAction.class.php	Fri May 12 19:13:36 2006
@@ -0,0 +1,35 @@
+<?php
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+require_once XOOPS_MODULE_PATH . "/base/admin/forms/PreferenceEditForm.class.php";
+
+class Legacy_PreferenceListAction extends Legacy_Action
+{
+	var $mObjects = array();
+	
+	function prepare(&$controller, &$xoopsUser)
+	{
+	}
+	
+	function getDefaultView(&$controller, &$xoopsUser)
+	{
+		$handler =& xoops_gethandler('configcategory');
+		$this->mObjects =& $handler->getObjects();
+		
+		return LEGACY_FRAME_VIEW_INDEX;
+	}
+	
+	function execute(&$controller, &$xoopsUser)
+	{
+		return $this->getDefaultView($controller, $xoopsUser);
+	}
+
+	function executeViewIndex(&$controller, &$xoopsUser, &$render)
+	{
+		$render->setTemplateName("preference_list.html");
+		$render->setAttribute('objects', $this->mObjects);
+	}
+}
+
+?>


xoops-cvslog メーリングリストの案内
Zurück zum Archiv-Index