Cleanup: Updated copyright notices
[Packages/TYPO3.CMS.git] / typo3 / mod / web / func / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 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: Advanced functions
29 * Advanced Functions related to pages
30 *
31 * $Id$
32 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
33 * XHTML compliant
34 *
35 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
36 */
37 /**
38 * [CLASS/FUNCTION INDEX of SCRIPT]
39 *
40 *
41 *
42 * 71: class SC_mod_web_func_index extends t3lib_SCbase
43 * 84: function main()
44 * 172: function printContent()
45 *
46 * TOTAL FUNCTIONS: 2
47 * (This index is automatically created/updated by the extension "extdeveval")
48 *
49 */
50
51
52 unset($MCONF);
53 require('conf.php');
54 require($BACK_PATH.'init.php');
55 require($BACK_PATH.'template.php');
56 $LANG->includeLLFile('EXT:lang/locallang_mod_web_func.xml');
57 require_once(PATH_t3lib.'class.t3lib_scbase.php');
58 require_once (PATH_t3lib.'class.t3lib_parsehtml.php');
59
60 $BE_USER->modAccess($MCONF,1);
61
62
63
64 /**
65 * Script Class for the Web > Functions module
66 * This class creates the framework to which other extensions can connect their sub-modules
67 *
68 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
69 * @package TYPO3
70 * @subpackage core
71 */
72 class SC_mod_web_func_index extends t3lib_SCbase {
73
74 // Internal, dynamic:
75 var $pageinfo;
76 var $fileProcessor;
77
78 /**
79 * Document Template Object
80 *
81 * @var mediumDoc
82 */
83 var $doc;
84
85
86
87 /**
88 * Initialize module header etc and call extObjContent function
89 *
90 * @return void
91 */
92 function main() {
93 global $BE_USER,$LANG,$BACK_PATH;
94
95 // Access check...
96 // The page will show only if there is a valid page and if this page may be viewed by the user
97 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
98 $access = is_array($this->pageinfo) ? 1 : 0;
99
100 // Template markers
101 $markers = array(
102 'CSH' => '',
103 'FUNC_MENU' => '',
104 'CONTENT' => ''
105 );
106
107 $this->doc = t3lib_div::makeInstance('template');
108 $this->doc->backPath = $BACK_PATH;
109 $this->doc->setModuleTemplate('templates/func.html');
110
111 // **************************
112 // Main
113 // **************************
114 if ($this->id && $access) {
115 // JavaScript
116 $this->doc->JScode = $this->doc->wrapScriptTags('
117 script_ended = 0;
118 function jumpToUrl(URL) { //
119 window.location.href = URL;
120 }
121 ');
122 $this->doc->postCode=$this->doc->wrapScriptTags('
123 script_ended = 1;
124 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
125 ');
126
127
128 // Setting up the context sensitive menu:
129 $this->doc->getContextMenuCode();
130
131 $this->doc->form='<form action="index.php" method="post"><input type="hidden" name="id" value="'.$this->id.'" />';
132
133 $vContent = $this->doc->getVersionSelector($this->id,1);
134 if ($vContent) {
135 $this->content.=$this->doc->section('',$vContent);
136 }
137
138
139 $this->extObjContent();
140
141 // Setting up the buttons and markers for docheader
142 $docHeaderButtons = $this->getButtons();
143 $markers['CSH'] = $docHeaderButtons['csh'];
144 $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
145 $markers['CONTENT'] = $this->content;
146 } else {
147 // If no access or if ID == zero
148 $this->content = $this->doc->section($LANG->getLL('title'), $LANG->getLL('clickAPage_content'), 0, 1);
149
150 // Setting up the buttons and markers for docheader
151 $docHeaderButtons = $this->getButtons();
152 $markers['CSH'] = $docHeaderButtons['csh'];
153 $markers['CONTENT'] = $this->content;
154 }
155 // Build the <body> for the module
156 $this->content = $this->doc->startPage($LANG->getLL('title'));
157 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
158 $this->content.= $this->doc->endPage();
159 $this->content = $this->doc->insertStylesAndJS($this->content);
160 }
161
162 /**
163 * Print module content (from $this->content)
164 *
165 * @return void
166 */
167 function printContent() {
168 echo $this->content;
169 }
170
171 /**
172 * Create the panel of buttons for submitting the form or otherwise perform operations.
173 *
174 * @return array all available buttons as an assoc. array
175 */
176 protected function getButtons() {
177 global $TCA, $LANG, $BACK_PATH, $BE_USER;
178
179 $buttons = array(
180 'csh' => '',
181 'view' => '',
182 'record_list' => '',
183 'shortcut' => '',
184 );
185 // CSH
186 $buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH'], '', TRUE);
187
188 if($this->id && is_array($this->pageinfo)) {
189
190 // View page
191 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $BACK_PATH, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '">' .
192 '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/zoom.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '" hspace="3" alt="" />' .
193 '</a>';
194
195 // Shortcut
196 if ($BE_USER->mayMakeShortcut()) {
197 $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
198 }
199
200 // If access to Web>List for user, then link to that module.
201 if ($BE_USER->check('modules','web_list')) {
202 $href = $BACK_PATH . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
203 $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '">' .
204 '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/list.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', 1) . '" alt="" />' .
205 '</a>';
206 }
207 }
208
209 return $buttons;
210 }
211 }
212
213
214 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/web/func/index.php']) {
215 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/web/func/index.php']);
216 }
217
218
219
220 // Make instance:
221 $SOBE = t3lib_div::makeInstance('SC_mod_web_func_index');
222 $SOBE->init();
223
224 // Include files?
225 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
226 $SOBE->checkExtObj(); // Checking for first level external objects
227
228 // Repeat Include files! - if any files has been added by second-level extensions
229 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
230 $SOBE->checkSubExtObj(); // Checking second level external objects
231
232 $SOBE->main();
233 $SOBE->printContent();
234
235 ?>