XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
TplfileDownloadAction.class.php
1<?php
6
7if (!defined('XOOPS_ROOT_PATH')) {
8 exit();
9}
10
11require_once XOOPS_MODULE_PATH . '/legacyRender/admin/forms/TplfileEditForm.class.php';
12
14{
15 public $mObject = null;
16
17 public function getDefaultView(&$controller, &$xoopsUser)
18 {
19 $id = xoops_getrequest('tpl_id');
20
21 $handler =& xoops_getmodulehandler('tplfile');
22 $this->mObject =& $handler->get($id);
23
24 return null != $this->mObject ? LEGACYRENDER_FRAME_VIEW_SUCCESS : LEGACYRENDER_FRAME_VIEW_ERROR;
25 }
26
27 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
28 {
29 $this->mObject->loadSource();
30 if (null == $this->mObject->Source) {
31 return LEGACYRENDER_FRAME_VIEW_ERROR;
32 }
33
34 $source = $this->mObject->Source->get('tpl_source');
35
36 header('Cache-Control: no-cache, must-revalidate');
37 header('Pragma: no-cache');
38 header('Content-Type: application/force-download');
39
40 if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT'])) {
41 header('Content-Disposition: filename=' . $this->mObject->getShow('tpl_file'));
42 } else {
43 header('Content-Disposition: attachment; filename=' . $this->mObject->getShow('tpl_file'));
44 }
45
46 header('Content-length: ' . strlen($source));
47 print $source;
48
49 exit(0);
50 }
51
52 public function executeViewError(&$controller, &$xoopsUser, &$render)
53 {
54 $controller->executeRedirect('./index.php?action=TplsetList', 1, _AD_LEGACYRENDER_ERROR_DBUPDATE_FAILED);
55 }
56}