[!!!][BUGFIX] *_user table password field is to short
[Packages/TYPO3.CMS.git] / typo3 / sysext / wizard_crpages / class.tx_wizardcrpages_webfunc_2.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 * Contains class for "Create pages" wizard
29 *
30 * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
31 * XHTML compliant
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35
36 /**
37 * Creates the "Create pages" wizard
38 *
39 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
40 * @package TYPO3
41 * @subpackage tx_wizardcrpages
42 */
43 class tx_wizardcrpages_webfunc_2 extends t3lib_extobjbase {
44
45 /**
46 * Holds reference of lorem ipsum class
47 *
48 * @var tx_loremipsum_wiz
49 */
50 protected $loremIpsumObject = NULL;
51
52 /**
53 * Complete tsConfig
54 *
55 * @var array
56 */
57 protected $tsConfig = array();
58
59 /**
60 * Part of tsConfig with TCEFORM.pages. settings
61 *
62 * @var array
63 */
64 protected $pagesTsConfig = array();
65
66
67 /**
68 * Adds menu items... but I think this is not used at all. Looks very much like some testing code. If anyone cares to check it we can remove it some day...
69 *
70 * @return array
71 * @ignore
72 */
73 function modMenu() {
74 global $LANG;
75
76 $modMenuAdd = array(
77 'cr_333' => array(
78 '0' => 'nul',
79 '1' => 'et'
80 )
81 );
82 return $modMenuAdd;
83 }
84
85 /**
86 * Main function creating the content for the module.
87 *
88 * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj
89 */
90 function main() {
91 global $SOBE, $LANG;
92
93 $theCode = '';
94
95 $this->tsConfig = t3lib_BEfunc::getPagesTSconfig($this->pObj->id);
96 $this->pagesTsConfig = isset($this->tsConfig['TCEFORM.']['pages.']) ? $this->tsConfig['TCEFORM.']['pages.'] : array();
97
98 // Create loremIpsum code:
99 if (t3lib_extMgm::isLoaded('lorem_ipsum')) {
100 $this->loremIpsumObject = t3lib_div::getUserObj('EXT:lorem_ipsum/class.tx_loremipsum_wiz.php:tx_loremipsum_wiz');
101 }
102 // Create new pages here?
103 $m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(8);
104 $pRec = t3lib_BEfunc::getRecord('pages', $this->pObj->id, 'uid', ' AND ' . $m_perms_clause);
105 $sys_pages = t3lib_div::makeInstance('t3lib_pageSelect');
106 $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', 0);
107 if (is_array($pRec)) {
108 $data = t3lib_div::_GP('data');
109 if (is_array($data['pages'])) {
110 if (t3lib_div::_GP('createInListEnd')) {
111 $endI = end($menuItems);
112 $thePid = -intval($endI['uid']);
113 if (!$thePid) {
114 $thePid = $this->pObj->id;
115 }
116 } else {
117 $thePid = $this->pObj->id;
118 }
119
120 $firstRecord = TRUE;
121 $previousIdentifier = '';
122
123 foreach ($data['pages'] as $identifier => $dat) {
124 if (!trim($dat['title'])) {
125 unset($data['pages'][$identifier]);
126 } else {
127 $data['pages'][$identifier]['hidden'] = t3lib_div::_GP('hidePages') ? 1 : 0;
128 if ($firstRecord) {
129 $firstRecord = FALSE;
130 $data['pages'][$identifier]['pid'] = $thePid;
131 } else {
132 $data['pages'][$identifier]['pid'] = '-' . $previousIdentifier;
133 }
134 $previousIdentifier = $identifier;
135 }
136 }
137
138 if (count($data['pages'])) {
139 reset($data);
140 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
141 $tce->stripslashes_values=0;
142
143 // set default TCA values specific for the user
144 $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
145 if (is_array($TCAdefaultOverride)) {
146 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
147 }
148
149 $tce->start($data, array());
150 $tce->process_datamap();
151 t3lib_BEfunc::setUpdateSignal('updatePageTree');
152
153 $flashMessage = t3lib_div::makeInstance(
154 't3lib_FlashMessage',
155 '',
156 $GLOBALS['LANG']->getLL('wiz_newPages_create')
157 );
158 } else {
159 $flashMessage = t3lib_div::makeInstance(
160 't3lib_FlashMessage',
161 '',
162 $GLOBALS['LANG']->getLL('wiz_newPages_noCreate'),
163 t3lib_FlashMessage::ERROR
164 );
165 }
166
167 $theCode.= $flashMessage->render();
168
169 // Display result:
170 $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', 0);
171 $lines=array();
172 foreach ($menuItems as $rec) {
173 t3lib_BEfunc::workspaceOL('pages', $rec);
174 if (is_array($rec)) {
175 $lines[] = '<nobr>' . t3lib_iconWorks::getSpriteIconForRecord('pages', $rec, array('title' => t3lib_BEfunc::titleAttribForPages($rec, '', FALSE))) .
176 htmlspecialchars(t3lib_div::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . '</nobr>';
177 }
178 }
179 $theCode.= '<h4>' . $LANG->getLL('wiz_newPages_currentMenu') . '</h4>' . implode('<br />', $lines);
180 } else {
181
182 // Display create form
183 $lines = array();
184 for ($a = 0; $a < 9; $a++) {
185 $lines[] = $this->getFormLine($a);
186 }
187
188 $theCode .= '<h4>' . $LANG->getLL('wiz_newPages') . ':</h4>' .
189 '<div id="formFieldContainer">' . implode('', $lines) . '</div>' .
190 '<br class="clearLeft" />' .
191 '<input type="button" id="createNewFormFields" value="' . $LANG->getLL('wiz_newPages_addMoreLines') . '" />' .
192
193 '<br /><br />
194 <input type="checkbox" name="createInListEnd" id="createInListEnd" value="1" /> <label for="createInListEnd">'.$LANG->getLL('wiz_newPages_listEnd').'</label><br />
195 <input type="checkbox" name="hidePages" id="hidePages" value="1" /> <label for="hidePages">'.$LANG->getLL('wiz_newPages_hidePages').'</label><br /><br />
196 <input type="submit" name="create" value="' . $LANG->getLL('wiz_newPages_lCreate') . '" />&nbsp;<input type="reset" value="' . $LANG->getLL('wiz_newPages_lReset') . '" /><br />';
197
198 // Add ExtJS inline code
199 $extCode = '
200 var tpl = "' . addslashes(str_replace(
201 array(LF, TAB),
202 array('', ''),
203 $this->getFormLine('#')
204 )) . '", i, line, div, bg, label;
205 var lineCounter = 9;
206 Ext.get("createNewFormFields").on("click", function() {
207 div = Ext.get("formFieldContainer");
208 for (i = 0; i < 5; i++) {
209 label = lineCounter + i + 1;
210 bg = label % 2 === 0 ? 6 : 4;
211 line = String.format(tpl, (lineCounter + i), label, bg);
212 div.insertHtml("beforeEnd", line);
213 }
214 lineCounter += 5;
215 });
216 ';
217
218 /** @var t3lib_pageRenderer **/
219 $pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
220
221 $pageRenderer->loadExtJS();
222 $pageRenderer->addExtOnReadyCode($extCode);
223 $pageRenderer->addCssInlineBlock('tx_wizardcrpages_webfunc_2', '
224 #formFieldContainer {float: left; margin: 0 0 10px 0;}
225 .clearLeft {clear: left;}
226 #formFieldContainer label {width: 70px; display: inline-block;}
227 #formFieldContainer input {margin:4px 2px; padding:1px; vertical-align:middle}
228 #formFieldContainer span {padding: 0 3px;}
229 ');
230 }
231 } else {
232 $theCode.=$GLOBALS['TBE_TEMPLATE']->rfw($LANG->getLL('wiz_newPages_errorMsg1'));
233 }
234
235 // CSH
236 $theCode.= t3lib_BEfunc::cshItem('_MOD_web_func', 'tx_wizardcrpages', $GLOBALS['BACK_PATH'], '<br />|');
237
238 $out = $this->pObj->doc->header($LANG->getLL('wiz_crMany'));
239 $out .= $this->pObj->doc->section('', $theCode, 0, 1);
240 return $out;
241 }
242
243 /**
244 * Return the helpbubble image tag.
245 *
246 * @return string HTML code for a help-bubble image.
247 */
248 function helpBubble() {
249 return '<img src="' . $GLOBALS['BACK_PATH'] . 'gfx/helpbubble.gif" width="14" height="14" hspace="2" align="top" alt="" />';
250 }
251
252 /**
253 * Return one line in the form
254 *
255 * @param mixed $index An integer: the line counter for which to create the line. Use "#" to create an template for javascript (used by ExtJS)
256 * @return string HTML code for one input line for one new page
257 */
258 protected function getFormLine($index) {
259 $backPath = $GLOBALS['BACK_PATH'];
260
261 if (is_numeric(($index))) {
262 $backgroundClass = ($index % 2 === 0 ? 'bgColor4' : 'bgColor6');
263 $label = $index + 1;
264 } else {
265 // used as template for ExtJS
266 $index = '{0}';
267 $backgroundClass = 'bgColor{2}';
268 $label = '{1}';
269 }
270
271 $content = '<label for="page_new_' . $index . '"> ' . $GLOBALS['LANG']->getLL('wiz_newPages_page') .' '. $label;
272 $content .= ':&nbsp;</label>';
273
274 // Title
275 $content .= '<input type="text" id="page_new_' . $index . '" name="data[pages][NEW' . $index . '][title]"' . $this->pObj->doc->formWidth(35) . ' />&nbsp';
276
277 // Lorem ipsum link, if available
278 $content .= (is_object($this->loremIpsumObject) ?
279 '<a href="#" onclick="' . htmlspecialchars($this->loremIpsumObject->getHeaderTitleJS('document.forms[0][\'data[pages][NEW' .
280 $index . '][title]\'].value', 'title')) . '">' . $this->loremIpsumObject->getIcon('', $this->pObj->doc->backPath) . '</a>'
281 : '');
282
283 // type selector
284 $content .= '<span>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.php:LGL.type') . '</span>';
285 $content .= '<select onchange="this.style.backgroundImage=this.options[this.selectedIndex].style.backgroundImage;if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex=1;}" ';
286 $content .= 'class="select icon-select" name="data[pages][NEW' . $index . '][doktype]" style="background: url(&quot;' . $backPath . 'sysext/t3skin/icons/gfx/i/pages.gif&quot;) no-repeat scroll 0% 50% rgb(255, 255, 255); padding: 1px 1px 1px 24px;">';
287
288 // dokType
289 $types = $GLOBALS['PAGES_TYPES'];
290 unset($types['default']);
291 $types = array_keys($types);
292 $types[] = 1;
293 if (!$GLOBALS['BE_USER']->isAdmin() && isset($GLOBALS['BE_USER']->groupData['pagetypes_select'])) {
294 $types = t3lib_div::trimExplode(',', $GLOBALS['BE_USER']->groupData['pagetypes_select'], TRUE);
295 }
296
297 $removeItems = isset($this->pagesTsConfig['doktype.']['removeItems']) ? t3lib_div::trimExplode(',', $this->pagesTsConfig['doktype.']['removeItems'], TRUE) : array();
298
299 $group = '';
300 if (in_array(1, $types) && !in_array(1, $removeItems)) {
301 $group .= '<option style="background: url(&quot;' . $backPath . 'sysext/t3skin/icons/gfx/i/pages.gif&quot;) no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" selected="selected" value="1">Standard</option>';
302 }
303 if (in_array(6, $types) && !in_array(6, $removeItems)) {
304 $group .= '<option style="background: url(&quot;' . $backPath . 'gfx/i/be_users_section.gif&quot;) no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="6">Backend User Section</option>';
305 }
306 $content .= $group ? '<optgroup class="c-divider" label="Page">' . $group . '</optgroup>' : '';
307
308 $group = '';
309 if (in_array(4, $types) && !in_array(4, $removeItems)) {
310 $group .= '<option style="background: url(&quot;' . $backPath . 'sysext/t3skin/icons/gfx/i/pages_shortcut.gif&quot;) no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="4">Shortcut</option>';
311 }
312 if (in_array(7, $types) && !in_array(7, $removeItems)) {
313 $group .= '<option style="background: url(&quot;' . $backPath . 'gfx/i/pages_mountpoint.gif&quot;) no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="7">Mount Point</option>';
314 }
315 if (in_array(3, $types) && !in_array(3, $removeItems)) {
316 $group .= '<option style="background: url(&quot;' . $backPath . 'sysext/t3skin/icons/gfx/i/pages_link.gif&quot;) no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="3">Link to external URL</option>';
317 }
318 $content .= $group ? '<optgroup class="c-divider" label="Link">' . $group . '</optgroup>' : '';
319
320 $group = '';
321 if (in_array(254, $types) && !in_array(254, $removeItems)) {
322 $group .= '<option style="background: url(&quot;' . $backPath . 'sysext/t3skin/icons/gfx/i/sysf.gif&quot;) no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="254">Folder</option>';
323 }
324 if (in_array(255, $types) && !in_array(255, $removeItems)) {
325 $group .= '<option style="background: url(&quot;' . $backPath . 'sysext/t3skin/icons/gfx/i/recycler.gif&quot;) no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="255">Recycler</option>';
326 }
327 if (in_array(199, $types) && !in_array(199, $removeItems)) {
328 $group .= '<option style="background: url(&quot;' . $backPath . 'sysext/t3skin/icons/gfx/i/spacer_icon.gif&quot;) no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="199">Visual menu separator</option>';
329 }
330 $content .= $group ? '<optgroup class="c-divider" label="Special">' . $group . '</optgroup>' : '';
331 $content .= '</select>';
332
333 return '<div id="form-line-' . $index . '" class="' . $backgroundClass . '">' . $content . '</div>';
334 }
335 }
336 ?>