1: <?php
2: 3: 4: 5:
6:
7: if (!defined('XOOPS_ROOT_PATH')) exit();
8:
9: require_once XOOPS_MODULE_PATH . "/legacyRender/admin/forms/TplfileEditForm.class.php";
10:
11: class LegacyRender_TplsetDownloadAction extends LegacyRender_Action
12: {
13: var $mPreparedFlag = false;
14:
15: var $mTplset = null;
16:
17: var $mDownloader = null;
18:
19: function &_createDownloader($method)
20: {
21: $ret = null;
22:
23: switch ($method) {
24: case 'tar':
25: if (@function_exists('gzencode')) {
26: require_once XOOPS_ROOT_PATH . "/class/tardownloader.php";
27: $ret =new XoopsTarDownloader();
28: }
29: break;
30: case 'zip':
31: if (@function_exists('gzcompress')) {
32: require_once XOOPS_ROOT_PATH . "/class/zipdownloader.php";
33: $ret =new XoopsZipDownloader();
34: }
35: break;
36: }
37:
38: return $ret;
39: }
40:
41:
42: function getDefaultView(&$controller, &$xoopsUser)
43: {
44: $method = xoops_getrequest('method') == 'tar' ? 'tar' : 'zip';
45: $this->mDownloader =& $this->_createDownloader($method);
46:
47: if ($this->mDownloader == null) {
48: return LEGACYRENDER_FRAME_VIEW_ERROR;
49: }
50:
51: $id = xoops_getrequest('tplset_id');
52:
53: $handler =& xoops_getmodulehandler('tplset');
54: $this->mTplset =& $handler->get($id);
55:
56: if ($this->mTplset == null) {
57: return LEGACYRENDER_FRAME_VIEW_ERROR;
58: }
59:
60: $xml = "<?xml version=\"1.0\"?>" . "\n" .
61: "<tplset>" . "\n" .
62: " <name>" . $this->mTplset->getShow('tplset_name') . "</name>" . "\n" .
63: " <dateCreated>" . $this->mTplset->getShow('tplset_created') . "</dateCreated>" . "\n" .
64: " <credits>" . $this->mTplset->getShow('tplset_credits') . "</credits>" . "\n" .
65: " <generator>" . XOOPS_VERSION. "</generator>" . "\n";
66:
67: $handler =& xoops_getmodulehandler('tplfile');
68: $files =& $handler->getObjects(new Criteria('tpl_tplset', $this->mTplset->get('tplset_name')));
69:
70: $count = count($files);
71:
72: if ($count > 0) {
73: $xml .= " <templates>" . "\n";
74: for ($i = 0; $i < $count; $i++) {
75: $files[$i]->loadSource();
76: if ($files[$i]->Source != null) {
77: $type = null;
78: if ($files[$i]->get('tpl_type') == 'block') {
79: $path = $this->mTplset->getShow('tplset_name') . '/templates/' . $files[$i]->getShow('tpl_module') . "/blocks/" . $files[$i]->getShow('tpl_file');
80: $type = "block";
81: }
82: elseif ($files[$i]->get('tpl_type') == 'module') {
83: $path = $this->mTplset->getShow('tplset_name') . '/templates/' . $files[$i]->getShow('tpl_module') . "/" . $files[$i]->getShow('tpl_file');
84: $type = "module";
85: }
86: $xml .= ' <template name="' . $files[$i]->getShow('tpl_file') . '">' . "\n" .
87: " <module>" . $files[$i]->getShow('tpl_module') . "</module>" . "\n" .
88: " <type>module</type>" . "\n" .
89: " <lastModified>" . $files[$i]->getShow('tpl_lastmodified') . "</lastModified>" . "\n" .
90: " </template>" . "\n";
91:
92: $this->mDownloader->addFileData($files[$i]->Source->get('tpl_source'), $path, $files[$i]->getShow('tpl_lastmodified'));
93: }
94: }
95:
96: $xml .= " </templates>" . "\n";
97: }
98:
99: $xml .= "</tplset>";
100:
101: $this->mDownloader->addFileData($xml, $this->mTplset->getShow('tplset_name') . '/tplset.xml', time());
102:
103: return LEGACYRENDER_FRAME_VIEW_SUCCESS;
104: }
105:
106: function executeViewSuccess(&$controller, &$xoopsUser, &$render)
107: {
108: print $this->mDownloader->download($this->mTplset->getShow('tplset_name'), true);
109: exit(0);
110: }
111:
112: function executeViewError(&$controller, &$xoopsUser, &$render)
113: {
114: $controller->executeRedirect("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED);
115: }
116: }
117:
118: ?>
119: