15 public $mPreparedFlag =
false;
17 public $mTplset =
null;
19 public $mDownloader =
null;
21 public function &_createDownloader($method)
27 if (@function_exists(
'gzencode')) {
28 require_once XOOPS_ROOT_PATH .
'/class/tardownloader.php';
33 if (@function_exists(
'gzcompress')) {
34 require_once XOOPS_ROOT_PATH .
'/class/zipdownloader.php';
44 public function getDefaultView(&$controller, &$xoopsUser)
47 $method =
'tar' == xoops_getrequest(
'method') ?
'tar' :
'zip';
48 $this->mDownloader =& $this->_createDownloader($method);
50 if (
null == $this->mDownloader) {
51 return LEGACYRENDER_FRAME_VIEW_ERROR;
54 $id = xoops_getrequest(
'tplset_id');
56 $handler =& xoops_getmodulehandler(
'tplset');
57 $this->mTplset =& $handler->get($id);
59 if (
null == $this->mTplset) {
60 return LEGACYRENDER_FRAME_VIEW_ERROR;
63 $xml =
'<?xml version="1.0"?>'
66 . $this->mTplset->getShow(
'tplset_name') .
'</name>'
67 .
"\n" .
' <dateCreated>'
68 . $this->mTplset->getShow(
'tplset_created') .
'</dateCreated>'
70 . $this->mTplset->getShow(
'tplset_credits') .
'</credits>'
71 .
"\n" .
' <generator>'
72 . XOOPS_VERSION .
'</generator>'
75 $handler =& xoops_getmodulehandler(
'tplfile');
76 $files =& $handler->getObjects(
new Criteria(
'tpl_tplset', $this->mTplset->get(
'tplset_name')));
78 $count = is_countable($files) ? count($files) : 0;
81 $xml .=
' <templates>' .
"\n";
82 for ($i = 0; $i < $count; $i++) {
83 $files[$i]->loadSource();
84 if (
null != $files[$i]->Source) {
86 if (
'block' == $files[$i]->
get(
'tpl_type')) {
87 $path = $this->mTplset->getShow(
'tplset_name') .
'/templates/' . $files[$i]->getShow(
'tpl_module') .
'/blocks/' . $files[$i]->getShow(
'tpl_file');
89 } elseif (
'module' == $files[$i]->
get(
'tpl_type')) {
90 $path = $this->mTplset->getShow(
'tplset_name') .
'/templates/' . $files[$i]->getShow(
'tpl_module') .
'/' . $files[$i]->getShow(
'tpl_file');
93 $xml .=
' <template name="' . $files[$i]->getShow(
'tpl_file') .
'">' .
"\n" .
' <module>'
94 . $files[$i]->getShow(
'tpl_module') .
'</module>'
95 .
"\n" .
' <type>module</type>'
96 .
"\n" .
' <lastModified>'
97 . $files[$i]->getShow(
'tpl_lastmodified') .
'</lastModified>'
98 .
"\n" .
' </template>'
101 $this->mDownloader->addFileData($files[$i]->Source->get(
'tpl_source'), $path, $files[$i]->getShow(
'tpl_lastmodified'));
105 $xml .=
' </templates>' .
"\n";
110 $this->mDownloader->addFileData($xml, $this->mTplset->getShow(
'tplset_name') .
'/tplset.xml', time());
112 return LEGACYRENDER_FRAME_VIEW_SUCCESS;
115 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
117 print $this->mDownloader->download($this->mTplset->getShow(
'tplset_name'),
true);
121 public function executeViewError(&$controller, &$xoopsUser, &$render)
123 $controller->executeRedirect(
'./index.php?action=TplsetList', 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED);