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_TplfileDownloadAction extends LegacyRender_Action
12: {
13: var $mObject = null;
14:
15: function getDefaultView(&$controller, &$xoopsUser)
16: {
17: $id = xoops_getrequest('tpl_id');
18:
19: $handler =& xoops_getmodulehandler('tplfile');
20: $this->mObject =& $handler->get($id);
21:
22: return $this->mObject != null ? LEGACYRENDER_FRAME_VIEW_SUCCESS : LEGACYRENDER_FRAME_VIEW_ERROR;
23: }
24:
25: function executeViewSuccess(&$controller, &$xoopsUser, &$render)
26: {
27: $this->mObject->loadSource();
28: if ($this->mObject->Source == null) {
29: return LEGACYRENDER_FRAME_VIEW_ERROR;
30: }
31:
32: $source = $this->mObject->Source->get('tpl_source');
33:
34: header('Cache-Control: no-cache, must-revalidate');
35: header('Pragma: no-cache');
36: header('Content-Type: application/force-download');
37:
38: if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
39: header('Content-Disposition: filename=' . $this->mObject->getShow('tpl_file'));
40: } else {
41: header('Content-Disposition: attachment; filename=' . $this->mObject->getShow('tpl_file'));
42: }
43:
44: header('Content-length: ' . strlen($source));
45: print $source;
46:
47: exit(0);
48: }
49:
50: function executeViewError(&$controller, &$xoopsUser, &$render)
51: {
52: $controller->executeRedirect("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED);
53: }
54: }
55:
56: ?>
57: