Fixed bug #11985: Optimize disposal of t3lib_PageRenderer
[Packages/TYPO3.CMS.git] / typo3 / sysext / taskcenter / task / 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 * User Task Center
29 *
30 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
31 * @author Christian Jul Jensen <christian(at)jul(dot)net>
32 * Revision for TYPO3 3.8.0 / Native Workflow System
33 */
34
35 unset($MCONF);
36 require ('conf.php');
37 require ($BACK_PATH.'init.php');
38 require ($BACK_PATH.'template.php');
39 $LANG->includeLLFile('EXT:taskcenter/task/locallang.php');
40 require_once('class.mod_user_task.php');
41
42 $BE_USER->modAccess($MCONF, 1);
43
44
45 // ***************************
46 // Script Classes
47 // ***************************
48 class SC_mod_user_task_index extends t3lib_SCbase {
49 var $allExtClassConf = array();
50 var $backPath;
51
52 /**
53 * BE user
54 *
55 * @var t3lib_beUserAuth
56 */
57 var $BE_USER;
58
59 /**
60 * document template object
61 *
62 * @var noDoc
63 */
64 var $doc;
65
66 /**
67 * This makes sure that all classes of task-center related extensions are included
68 * Further it registers the classes in the variable $this->allExtClassConf
69 *
70 * @return void
71 */
72 function includeAllClasses() {
73 foreach($this->MOD_MENU['function'] as $key => $name) {
74 $curExtClassConf = $this->getExternalItemConfig($this->MCONF['name'], 'function', $key);
75 if (is_array($curExtClassConf) && $curExtClassConf['path']) {
76 $this->allExtClassConf[] = $curExtClassConf;
77 $this->include_once[] = $curExtClassConf['path'];
78 }
79 }
80 }
81
82 /**
83 * This is the main function called by the TYPO3 framework
84 *
85 * @return string The conntent of the module (HTML)
86 */
87 function main() {
88 global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
89
90 /* Setup document template */
91 $this->doc = t3lib_div::makeInstance('noDoc');
92 $this->doc->divClass = '';
93 $this->doc->form = '<form action="index.php" method="post" name="editform">';
94 $this->backPath = $this->doc->backPath = $BACK_PATH;
95 $this->doc->getPageRenderer()->loadPrototype();
96 $this->doc->JScode = ' <script language="javascript" type="text/javascript">
97 script_ended = 0;
98 function jumpToUrl(URL) {
99 window.location.href = URL;
100 }
101 '.(is_object($this->extObj)?$this->extObj->JScode():"").'
102 </script>
103 ';
104 $this->doc->JScode .= $this->doc->getDynTabMenuJScode();
105 $this->doc->JScode .= '<script language="javascript" type="text/javascript">
106 function resizeIframe(frame,max) {
107 var parent = $("list_frame").up("body");
108 var parentHeight = $(parent).getHeight();
109 $("list_frame").setStyle({height: parentHeight+"px"});
110
111 }
112 // event crashes IE6 so he is excluded first
113 //TODO: use a central handler instead of multiple single ones
114 var version = parseFloat(navigator.appVersion.split(\';\')[1].strip().split(\' \')[1]);
115 if (!(Prototype.Browser.IE && version == 6)) {
116 Event.observe(window, "resize", resizeIframe, false);
117 }
118 </script>';
119
120 /* call getMainContent first, because what happens here might affect leftContent */
121 $mainContent = $this->getMainContent();
122
123 /* content... */
124 $this->content = '';
125 $this->content .= $this->doc->startPage($this->MOD_MENU['function'][$this->MOD_SETTINGS['function']]);
126 $this->content .= '<table style="width: 98%;"><tr>';
127 $this->content .= '<td valign="top" style="width: 20%;">'.$this->getleftHeader().$this->getDynTabMenu().'</td>';
128 $this->content .= '<td valign="top" style="height:100%">'.$mainContent.'</td>';
129 $this->content .= '</tr></table>';
130 }
131
132 /** Generate the dynamic tab menu in the left side by iterating
133 * over all submodules and creating configurations.
134 *
135 * @return string the code for the dynamic tab menu (HTML)
136 */
137 function getDynTabMenu() {
138 //walk through registered submodules and generate configuration
139 //for tabmenu
140 $parts = Array();
141 foreach($this->allExtClassConf as $conf) {
142 $extObj = t3lib_div::makeInstance($conf['name']);
143 /* call init to make sure the LOCAL_LANG is included for all listed
144 * extensions. If they OVERRIDE each other there is trouble! */
145 $extObj->init($this, $conf);
146 $extObj->backPath = $this->backPath;
147 $extObj->mod_user_task_init($GLOBALS['BE_USER']);
148 $part = $extObj->overview_main();
149 if (is_array($part)) {
150 $parts[] = $part;
151 }
152 }
153 return $this->doc->getDynTabMenu($parts, 'tx_taskcenter', 1, true);
154 }
155
156 /**
157 * Generate the header of the left column
158 *
159 * @return string header in the left side (HTML)
160 */
161 function getleftHeader() {
162 $name = $GLOBALS['BE_USER']->user['realName']?$GLOBALS['BE_USER']->user['realName']:
163 $GLOBALS['BE_USER']->user['username'];
164 return '<h1>TYPO3 taskcenter <br />'.$name.'</h1>';
165 }
166
167 /**
168 * Get the main content for the module by initiating the external object (if any) and calling it's main function.
169 *
170 * @return string main content (HTML)
171 */
172 function getMainContent() {
173 if (is_object($this->extObj)) {
174 $this->extObj->backPath = $this->backPath;
175 $this->extObj->mod_user_task_init($GLOBALS['BE_USER']);
176 return $this->extObj->main();
177 }
178 }
179
180 /**
181 * Output the content of the object to the browser
182 *
183 * @return void
184 */
185 function printContent() {
186 $this->content .= $this->doc->endPage();
187 echo $this->content;
188 }
189
190 }
191
192
193 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/taskcenter/task/index.php']) {
194 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/taskcenter/task/index.php']);
195 }
196
197
198
199 // Make instance:
200 $SOBE = t3lib_div::makeInstance('SC_mod_user_task_index');
201 $SOBE->init();
202 $SOBE->includeAllClasses();
203
204 // Include files?
205 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
206 $SOBE->checkExtObj(); // Checking for first level external objects
207
208 $SOBE->main();
209 $SOBE->printContent();
210
211 ?>