Fixed bug #983.
[Packages/TYPO3.CMS.git] / typo3 / sysext / viewpage / view / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 Kasper Skaarhoj (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 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 *
38 *
39 * 65: class SC_mod_web_view_index
40 * 80: function init()
41 * 97: function main()
42 * 122: function printContent()
43 *
44 * TOTAL FUNCTIONS: 3
45 * (This index is automatically created/updated by the extension "extdeveval")
46 *
47 */
48
49 unset($MCONF);
50 require ("conf.php");
51 require ($BACK_PATH."init.php");
52 //require ($BACK_PATH."template.php");
53 require_once (PATH_t3lib."class.t3lib_page.php");
54 $BE_USER->modAccess($MCONF,1);
55
56
57
58 /**
59 * Script Class for the Web > View
60 *
61 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
62 * @package TYPO3
63 * @subpackage core
64 */
65 class SC_mod_web_view_index {
66 var $MCONF=array();
67 var $MOD_MENU=array();
68 var $MOD_SETTINGS=array();
69
70 var $perms_clause;
71 var $modTSconfig;
72 var $type;
73 var $pageinfo;
74 var $url;
75 var $id;
76
77 /**
78 * @return [type] ...
79 */
80 function init() {
81 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
82 $this->MCONF = $GLOBALS["MCONF"];
83 $this->id = intval(t3lib_div::_GP("id"));
84
85 $this->perms_clause = $BE_USER->getPagePermsClause(1);
86
87 // page/be_user TSconfig settings and blinding of menu-items
88 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id,"mod.".$this->MCONF["name"]);
89 $this->type = intval($this->modTSconfig["properties"]["type"]);
90 }
91
92 /**
93 * [Describe function...]
94 *
95 * @return [type] ...
96 */
97 function main() {
98 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
99 // Access check...
100 // The page will show only if there is a valid page and if this page may be viewed by the user
101 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
102 $access = is_array($this->pageinfo) ? 1 : 0;
103 $addCmd="";
104 if ($this->id && $access) {
105 $addCmd = "&ADMCMD_view=1&ADMCMD_editIcons=1".t3lib_BEfunc::ADMCMD_previewCmds($this->pageinfo);
106 }
107
108 $parts = parse_url(t3lib_div::getIndpEnv("TYPO3_SITE_URL"));
109 $dName = t3lib_BEfunc::getDomainStartPage($parts["host"],$parts["path"]) ?
110 t3lib_BEfunc::firstDomainRecord(t3lib_BEfunc::BEgetRootLine($this->id)):
111 "";
112
113 $this->url.= ($dName?(t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://').$dName:$BACK_PATH."..")."/index.php?id=".$this->id.($this->type?"&type=".$this->type:"").$addCmd;
114 //debug($this->url);
115 }
116
117 /**
118 * [Describe function...]
119 *
120 * @return [type] ...
121 */
122 function printContent() {
123 Header("Location: ".t3lib_div::locationHeaderUrl($this->url));
124 }
125 }
126
127 // Include extension?
128 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/viewpage/view/index.php"]) {
129 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/viewpage/view/index.php"]);
130 }
131
132
133
134
135
136
137
138
139
140
141
142
143 // Make instance:
144 $SOBE = t3lib_div::makeInstance("SC_mod_web_view_index");
145 $SOBE->init();
146 $SOBE->main();
147 $SOBE->printContent();
148 ?>