[xoops-cvslog 3097] CVS update: xoops2jp/html/modules/legacyRender/admin/actions

アーカイブの一覧に戻る

Minahito minah****@users*****
2006年 5月 18日 (木) 12:04:08 JST


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.2.1
--- /dev/null	Thu May 18 12:04:07 2006
+++ xoops2jp/html/modules/legacyRender/admin/actions/TplsetDownloadAction.class.php	Thu May 18 12:04:07 2006
@@ -0,0 +1,114 @@
+<?php
+
+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->getVar('tplset_name') . "</name>" . "\n" .
+		       "  <dateCreated>" . $this->mTplset->getVar('tplset_created') . "</dateCreated>" . "\n" .
+		       "  <credits>" . $this->mTplset->getVar('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->getVar('tplset_name') . '/templates/' . $files[$i]->getVar('tpl_module') . "/blocks/" . $files[$i]->getVar('tpl_file');
+						$type = "block";
+					}
+					elseif ($files[$i]->get('tpl_type') == 'module') {
+						$path = $this->mTplset->getVar('tplset_name') . '/templates/' . $files[$i]->getVar('tpl_module') . "/" . $files[$i]->getVar('tpl_file');
+						$type = "module";
+					}
+					$xml .= '    <template name="' . $files[$i]->getVar('tpl_file') . '">' . "\n" .
+					        "      <module>" . $files[$i]->getVar('tpl_module') . "</module>" . "\n" .
+					        "      <type>module</type>" . $files[$i]->getVar('tpl_module') . "</module>" . "\n" .
+					        "      <lastModified>" . $files[$i]->getVar('tpl_lastmodified') . "</lastModified>" . "\n" .
+					        "    </template>" . "\n";
+					
+					$this->mDownloader->addFileData($files[$i]->Source->get('tpl_source'), $path, $files[$i]->getVar('tpl_lastmodified'));
+				}
+			}
+			
+			$xml .= "  </templates>" . "\n";
+		}
+		
+		$xml .= "</tplset>";
+		
+		$this->mDownloader->addFileData($xml, $this->mTplset->getVar('tplset_name') . '/tplset.xml', time());
+		
+		return LEGACYRENDER_FRAME_VIEW_SUCCESS;
+	}
+
+	function executeViewSuccess(&$controller, &$xoopsUser, &$render)
+	{
+		print $this->mDownloader->download($this->mTplset->getVar('tplset_name'), true);
+		exit(0);
+	}
+
+	function executeViewError(&$controller, &$xoopsUser, &$render)
+	{
+		redirect_header("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED);
+	}
+}
+
+?>


xoops-cvslog メーリングリストの案内
アーカイブの一覧に戻る