[BUGFIX] "Show page" does not use a proper URL scheme
[Packages/TYPO3.CMS.git] / typo3 / sysext / viewpage / view / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Module: View
29 *
30 * Views the webpage
31 *
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 */
34
35 unset($MCONF);
36 require ('conf.php');
37 require ($BACK_PATH.'init.php');
38 //require ($BACK_PATH.'template.php');
39 $BE_USER->modAccess($MCONF,1);
40
41
42
43 /**
44 * Script Class for the Web > View
45 *
46 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
47 * @package TYPO3
48 * @subpackage core
49 */
50 class SC_mod_web_view_index {
51 var $MCONF=array();
52 var $MOD_MENU=array();
53 var $MOD_SETTINGS=array();
54
55 var $perms_clause;
56 var $modTSconfig;
57 var $type;
58 var $pageinfo;
59 var $url;
60 var $id;
61 var $wsInstruction='';
62
63 /**
64 * Initialization of module
65 *
66 * @return void
67 */
68 function init() {
69 $this->MCONF = $GLOBALS['MCONF'];
70 $this->id = intval(t3lib_div::_GP('id'));
71
72 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
73
74 // page/be_user TSconfig settings and blinding of menu-items
75 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id,'mod.'.$this->MCONF['name']);
76 $this->type = intval($this->modTSconfig['properties']['type']);
77 }
78
79 /**
80 * Main function
81 *
82 * @return void
83 */
84 function main() {
85
86 // Access check...
87 // The page will show only if there is a valid page and if this page may be viewed by the user
88 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
89 $access = is_array($this->pageinfo) ? 1 : 0;
90 $addCmd='';
91 if ($this->id && $access) {
92 $addCmd = '&ADMCMD_view=1&ADMCMD_editIcons=1'.t3lib_BEfunc::ADMCMD_previewCmds($this->pageinfo);
93 }
94
95 $parts = parse_url(t3lib_div::getIndpEnv('TYPO3_SITE_URL'));
96 $dName = t3lib_BEfunc::getDomainStartPage($parts['host'],$parts['path']) ?
97 t3lib_BEfunc::firstDomainRecord(t3lib_BEfunc::BEgetRootLine($this->id)):
98 '';
99
100 // preview of mount pages
101 $sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
102 /** @var t3lib_pageSelect $sys_page */
103 $sys_page->init(FALSE);
104 $mountPointInfo = $sys_page->getMountPointInfo($this->id);
105 if ($mountPointInfo && $mountPointInfo['overlay']) {
106 $this->id = $mountPointInfo['mount_pid'];
107 $addCmd .= '&MP=' . $mountPointInfo['MPvar'];
108 }
109
110 $page = (array)$sys_page->getPage($this->id);
111
112 $urlScheme = 'http';
113 if ($page['url_scheme'] == 2 || $page['url_scheme'] == 0 && t3lib_div::getIndpEnv('TYPO3_SSL')) {
114 $urlScheme = 'https';
115 }
116
117 $this->url .= ($dName
118 ? $urlScheme . '://' . $dName
119 : $GLOBALS['BACK_PATH'] . '..') . '/index.php?id=' . $this->id .
120 ($this->type ? '&type='.$this->type : '') . $addCmd;
121 }
122
123 /**
124 * Redirect URL
125 *
126 * @return void
127 */
128 function printContent() {
129 t3lib_utility_Http::redirect($this->url);
130 }
131 }
132
133
134 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/viewpage/view/index.php'])) {
135 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/viewpage/view/index.php']);
136 }
137
138
139
140 // Make instance:
141 $SOBE = t3lib_div::makeInstance('SC_mod_web_view_index');
142 $SOBE->init();
143 $SOBE->main();
144 $SOBE->printContent();
145
146 ?>