[BUGFIX] reference to OpenID lib to wrong directory
[Packages/TYPO3.CMS.git] / typo3 / sysext / wizard_create_pages / Classes / Controller / CreatePagesWizardModuleFunctionController.php
1 <?php
2 namespace TYPO3\CMS\WizardCreatePages\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Contains class for "Create pages" wizard
31 *
32 * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
33 * XHTML compliant
34 *
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
36 */
37 /**
38 * Creates the "Create pages" wizard
39 *
40 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
41 * @package TYPO3
42 * @subpackage tx_wizardcrpages
43 */
44 class CreatePagesWizardModuleFunctionController extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
45
46 /**
47 * Holds reference of lorem ipsum class
48 *
49 * @var tx_loremipsum_wiz
50 */
51 protected $loremIpsumObject = NULL;
52
53 /**
54 * Complete tsConfig
55 *
56 * @var array
57 */
58 protected $tsConfig = array();
59
60 /**
61 * Part of tsConfig with TCEFORM.pages. settings
62 *
63 * @var array
64 */
65 protected $pagesTsConfig = array();
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 * @todo Define visibility
73 */
74 public function modMenu() {
75 global $LANG;
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 * @todo Define visibility
90 */
91 public function main() {
92 global $SOBE, $LANG;
93 $theCode = '';
94 $this->tsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($this->pObj->id);
95 $this->pagesTsConfig = isset($this->tsConfig['TCEFORM.']['pages.']) ? $this->tsConfig['TCEFORM.']['pages.'] : array();
96 // Create loremIpsum code:
97 if (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('lorem_ipsum')) {
98 $this->loremIpsumObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj('EXT:lorem_ipsum/class.tx_loremipsum_wiz.php:tx_loremipsum_wiz');
99 }
100 // Create new pages here?
101 $m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(8);
102 $pRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $this->pObj->id, 'uid', ' AND ' . $m_perms_clause);
103 $sys_pages = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
104 $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', 0);
105 if (is_array($pRec)) {
106 $data = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('data');
107 if (is_array($data['pages'])) {
108 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('createInListEnd')) {
109 $endI = end($menuItems);
110 $thePid = -intval($endI['uid']);
111 if (!$thePid) {
112 $thePid = $this->pObj->id;
113 }
114 } else {
115 $thePid = $this->pObj->id;
116 }
117 $firstRecord = TRUE;
118 $previousIdentifier = '';
119 foreach ($data['pages'] as $identifier => $dat) {
120 if (!trim($dat['title'])) {
121 unset($data['pages'][$identifier]);
122 } else {
123 $data['pages'][$identifier]['hidden'] = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('hidePages') ? 1 : 0;
124 if ($firstRecord) {
125 $firstRecord = FALSE;
126 $data['pages'][$identifier]['pid'] = $thePid;
127 } else {
128 $data['pages'][$identifier]['pid'] = '-' . $previousIdentifier;
129 }
130 $previousIdentifier = $identifier;
131 }
132 }
133 if (count($data['pages'])) {
134 reset($data);
135 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandler\\DataHandler');
136 $tce->stripslashes_values = 0;
137 // set default TCA values specific for the user
138 $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
139 if (is_array($TCAdefaultOverride)) {
140 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
141 }
142 $tce->start($data, array());
143 $tce->process_datamap();
144 \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree');
145 $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', $GLOBALS['LANG']->getLL('wiz_newPages_create'));
146 } else {
147 $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', $GLOBALS['LANG']->getLL('wiz_newPages_noCreate'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
148 }
149 $theCode .= $flashMessage->render();
150 // Display result:
151 $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', 0);
152 $lines = array();
153 foreach ($menuItems as $rec) {
154 \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL('pages', $rec);
155 if (is_array($rec)) {
156 $lines[] = (('<nobr>' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rec, array('title' => \TYPO3\CMS\Backend\Utility\BackendUtility::titleAttribForPages($rec, '', FALSE)))) . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen']))) . '</nobr>';
157 }
158 }
159 $theCode .= (('<h4>' . $LANG->getLL('wiz_newPages_currentMenu')) . '</h4>') . implode('<br />', $lines);
160 } else {
161 // Display create form
162 $lines = array();
163 for ($a = 0; $a < 9; $a++) {
164 $lines[] = $this->getFormLine($a);
165 }
166 $theCode .= ((((((((((((((((('<h4>' . $LANG->getLL('wiz_newPages')) . ':</h4>') . '<div id="formFieldContainer">') . implode('', $lines)) . '</div>') . '<br class="clearLeft" />') . '<input type="button" id="createNewFormFields" value="') . $LANG->getLL('wiz_newPages_addMoreLines')) . '" />') . '<br /><br />
167 <input type="checkbox" name="createInListEnd" id="createInListEnd" value="1" /> <label for="createInListEnd">') . $LANG->getLL('wiz_newPages_listEnd')) . '</label><br />
168 <input type="checkbox" name="hidePages" id="hidePages" value="1" /> <label for="hidePages">') . $LANG->getLL('wiz_newPages_hidePages')) . '</label><br /><br />
169 <input type="submit" name="create" value="') . $LANG->getLL('wiz_newPages_lCreate')) . '" />&nbsp;<input type="reset" value="') . $LANG->getLL('wiz_newPages_lReset')) . '" /><br />';
170 // Add ExtJS inline code
171 $extCode = ('
172 var tpl = "' . addslashes(str_replace(array(LF, TAB), array('', ''), $this->getFormLine('#')))) . '", i, line, div, bg, label;
173 var lineCounter = 9;
174 Ext.get("createNewFormFields").on("click", function() {
175 div = Ext.get("formFieldContainer");
176 for (i = 0; i < 5; i++) {
177 label = lineCounter + i + 1;
178 bg = label % 2 === 0 ? 6 : 4;
179 line = String.format(tpl, (lineCounter + i), label, bg);
180 div.insertHtml("beforeEnd", line);
181 }
182 lineCounter += 5;
183 });
184 ';
185 /** @var t3lib_pageRenderer * */
186 $pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
187 $pageRenderer->loadExtJS();
188 $pageRenderer->addExtOnReadyCode($extCode);
189 $pageRenderer->addCssInlineBlock('TYPO3\\CMS\\WizardCreatePages\\Controller\\CreatePagesWizardModuleFunctionController', '
190 #formFieldContainer {float: left; margin: 0 0 10px 0;}
191 .clearLeft {clear: left;}
192 #formFieldContainer label {width: 70px; display: inline-block;}
193 #formFieldContainer input {margin:4px 2px; padding:1px; vertical-align:middle}
194 #formFieldContainer span {padding: 0 3px;}
195 ');
196 }
197 } else {
198 $theCode .= $GLOBALS['TBE_TEMPLATE']->rfw($LANG->getLL('wiz_newPages_errorMsg1'));
199 }
200 // CSH
201 $theCode .= \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('_MOD_web_func', 'tx_wizardcrpages', $GLOBALS['BACK_PATH'], '<br />|');
202 $out = $this->pObj->doc->header($LANG->getLL('wiz_crMany'));
203 $out .= $this->pObj->doc->section('', $theCode, 0, 1);
204 return $out;
205 }
206
207 /**
208 * Return the helpbubble image tag.
209 *
210 * @return string HTML code for a help-bubble image.
211 * @todo Define visibility
212 */
213 public function helpBubble() {
214 return ('<img src="' . $GLOBALS['BACK_PATH']) . 'gfx/helpbubble.gif" width="14" height="14" hspace="2" align="top" alt="" />';
215 }
216
217 /**
218 * Return one line in the form
219 *
220 * @param mixed $index An integer: the line counter for which to create the line. Use "#" to create an template for javascript (used by ExtJS)
221 * @return string HTML code for one input line for one new page
222 */
223 protected function getFormLine($index) {
224 $backPath = $GLOBALS['BACK_PATH'];
225 if (is_numeric($index)) {
226 $backgroundClass = $index % 2 === 0 ? 'bgColor4' : 'bgColor6';
227 $label = $index + 1;
228 } else {
229 // used as template for ExtJS
230 $index = '{0}';
231 $backgroundClass = 'bgColor{2}';
232 $label = '{1}';
233 }
234 $content = (((('<label for="page_new_' . $index) . '"> ') . $GLOBALS['LANG']->getLL('wiz_newPages_page')) . ' ') . $label;
235 $content .= ':&nbsp;</label>';
236 // Title
237 $content .= ((((('<input type="text" id="page_new_' . $index) . '" name="data[pages][NEW') . $index) . '][title]"') . $this->pObj->doc->formWidth(35)) . ' />&nbsp';
238 // Lorem ipsum link, if available
239 $content .= is_object($this->loremIpsumObject) ? ((('<a href="#" onclick="' . htmlspecialchars($this->loremIpsumObject->getHeaderTitleJS((('document.forms[0][\'data[pages][NEW' . $index) . '][title]\'].value'), 'title'))) . '">') . $this->loremIpsumObject->getIcon('', $this->pObj->doc->backPath)) . '</a>' : '';
240 // type selector
241 $content .= ('<span>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.php:LGL.type')) . '</span>';
242 $content .= '<select onchange="this.style.backgroundImage=this.options[this.selectedIndex].style.backgroundImage;if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex=1;}" ';
243 $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;">';
244 // dokType
245 $types = $GLOBALS['PAGES_TYPES'];
246 unset($types['default']);
247 $types = array_keys($types);
248 $types[] = 1;
249 if (!$GLOBALS['BE_USER']->isAdmin() && isset($GLOBALS['BE_USER']->groupData['pagetypes_select'])) {
250 $types = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['BE_USER']->groupData['pagetypes_select'], TRUE);
251 }
252 $removeItems = isset($this->pagesTsConfig['doktype.']['removeItems']) ? \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->pagesTsConfig['doktype.']['removeItems'], TRUE) : array();
253 $group = '';
254 if (in_array(1, $types) && !in_array(1, $removeItems)) {
255 $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>';
256 }
257 if (in_array(6, $types) && !in_array(6, $removeItems)) {
258 $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>';
259 }
260 $content .= $group ? ('<optgroup class="c-divider" label="Page">' . $group) . '</optgroup>' : '';
261 $group = '';
262 if (in_array(4, $types) && !in_array(4, $removeItems)) {
263 $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>';
264 }
265 if (in_array(7, $types) && !in_array(7, $removeItems)) {
266 $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>';
267 }
268 if (in_array(3, $types) && !in_array(3, $removeItems)) {
269 $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>';
270 }
271 $content .= $group ? ('<optgroup class="c-divider" label="Link">' . $group) . '</optgroup>' : '';
272 $group = '';
273 if (in_array(254, $types) && !in_array(254, $removeItems)) {
274 $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>';
275 }
276 if (in_array(255, $types) && !in_array(255, $removeItems)) {
277 $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>';
278 }
279 if (in_array(199, $types) && !in_array(199, $removeItems)) {
280 $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>';
281 }
282 $content .= $group ? ('<optgroup class="c-divider" label="Special">' . $group) . '</optgroup>' : '';
283 $content .= '</select>';
284 return ((((('<div id="form-line-' . $index) . '" class="') . $backgroundClass) . '">') . $content) . '</div>';
285 }
286
287 }
288
289
290 ?>