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