Cleanup: Updated copyright notices
[Packages/TYPO3.CMS.git] / typo3 / sysext / wizard_crpages / class.tx_wizardcrpages_webfunc_2.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 * 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 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 70: class tx_wizardcrpages_webfunc_2 extends t3lib_extobjbase
41 * 78: function modMenu()
42 * 95: function main()
43 * 179: function helpBubble()
44 *
45 * TOTAL FUNCTIONS: 3
46 * (This index is automatically created/updated by the extension "extdeveval")
47 *
48 */
49
50 require_once(PATH_t3lib.'class.t3lib_page.php');
51 require_once(PATH_t3lib.'class.t3lib_tcemain.php');
52 require_once(PATH_t3lib.'class.t3lib_extobjbase.php');
53
54
55
56
57
58
59
60
61
62
63 /**
64 * Creates the "Create pages" wizard
65 *
66 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
67 * @package TYPO3
68 * @subpackage tx_wizardcrpages
69 */
70 class tx_wizardcrpages_webfunc_2 extends t3lib_extobjbase {
71
72 /**
73 * 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...
74 *
75 * @return array
76 * @ignore
77 */
78 function modMenu() {
79 global $LANG;
80
81 $modMenuAdd = array(
82 'cr_333' => array(
83 '0' => 'nul',
84 '1' => 'et'
85 )
86 );
87 return $modMenuAdd;
88 }
89
90 /**
91 * Main function creating the content for the module.
92 *
93 * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj
94 */
95 function main() {
96 global $SOBE,$LANG;
97
98 $theCode='';
99
100 $m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(8); // create new pages here?
101 $pRec = t3lib_BEfunc::getRecord('pages',$this->pObj->id,'uid',' AND '.$m_perms_clause);
102 $sys_pages = t3lib_div::makeInstance('t3lib_pageSelect');
103 $menuItems = $sys_pages->getMenu($this->pObj->id,'*','sorting','',0);
104 if (is_array($pRec)) {
105 $data = t3lib_div::_GP('data');
106 if (is_array($data['pages'])) {
107 if (t3lib_div::_GP('createInListEnd')) {
108 $endI = end($menuItems);
109 $thePid = -intval($endI['uid']);
110 if (!$thePid) $thePid = $this->pObj->id;
111 } else {
112 $thePid = $this->pObj->id;
113 }
114
115 while(list($k,$dat)=each($data['pages'])) {
116 if (!trim($dat['title'])) {
117 unset($data['pages'][$k]);
118 } else {
119 $data['pages'][$k]['pid']=$thePid;
120 $data['pages'][$k]['hidden'] = t3lib_div::_GP('hidePages') ? 1 : 0;
121 }
122 }
123 if (count($data['pages'])) {
124 reset($data);
125 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
126 $tce->stripslashes_values=0;
127 $tce->reverseOrder=1;
128
129 // set default TCA values specific for the user
130 $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
131 if (is_array($TCAdefaultOverride)) {
132 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
133 }
134
135 $tce->start($data,array());
136 $tce->process_datamap();
137 t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
138 } else {
139 $theCode.=$GLOBALS['TBE_TEMPLATE']->rfw($LANG->getLL('wiz_newPages_noCreate').'<br /><br />');
140 }
141
142 // Display result:
143 $menuItems = $sys_pages->getMenu($this->pObj->id,'*','sorting','',0);
144 reset($menuItems);
145 $lines=array();
146 while(list(,$rec)=each($menuItems)) {
147 t3lib_BEfunc::workspaceOL('pages',$rec);
148 if (is_array($rec)) {
149 $lines[]= '<nobr>'.t3lib_iconWorks::getIconImage('pages',$rec,$GLOBALS['BACK_PATH'],'align="top" '.t3lib_BEfunc::titleAttribForPages($rec)).
150 htmlspecialchars(t3lib_div::fixed_lgd_cs($rec['title'],$GLOBALS['BE_USER']->uc['titleLen'])).'</nobr>';
151 }
152 }
153 $theCode.= '<b>'.$LANG->getLL('wiz_newPages_currentMenu').':</b><br /><br />'.implode('<br />',$lines);
154 } else {
155 // Create loremIpsum code:
156 if (t3lib_extMgm::isLoaded('lorem_ipsum')) {
157 $loremIpsumObj = t3lib_div::getUserObj('EXT:lorem_ipsum/class.tx_loremipsum_wiz.php:tx_loremipsum_wiz');
158 }
159 // Display create form
160 $lines = array();
161 for ($a=0;$a<9;$a++) {
162 $lines[] = $LANG->getLL('wiz_newPages_page').' '.($a+1).
163 ': <input type="text" name="data[pages][NEW'.$a.'][title]"'.$this->pObj->doc->formWidth(35).' />'.
164 (is_object($loremIpsumObj) ? '<a href="#" onclick="'.htmlspecialchars($loremIpsumObj->getHeaderTitleJS('document.forms[0][\'data[pages][NEW'.$a.'][title]\'].value', 'title')).'">'.$loremIpsumObj->getIcon('',$this->pObj->doc->backPath).'</a>' : '');
165 }
166
167 $theCode.= '<b>'.$LANG->getLL('wiz_newPages').':</b><br /><br />'.implode('<br />',$lines).
168 '<br /><br />
169 <input type="checkbox" name="createInListEnd" id="createInListEnd" value="1" /> <label for="createInListEnd">'.$LANG->getLL('wiz_newPages_listEnd').'</label><br />
170 <input type="checkbox" name="hidePages" id="hidePages" value="1" /> <label for="hidePages">'.$LANG->getLL('wiz_newPages_hidePages').'</label><br /><br />
171 <input type="submit" name="create" value="'.$LANG->getLL('wiz_newPages_lCreate').'" onclick="return confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('wiz_newPages_lCreate_msg1')).')"> <input type="reset" value="'.$LANG->getLL('wiz_newPages_lReset').'" /><br />';
172 }
173 } else {
174 $theCode.=$GLOBALS['TBE_TEMPLATE']->rfw($LANG->getLL('wiz_newPages_errorMsg1'));
175 }
176
177 // CSH
178 $theCode.= t3lib_BEfunc::cshItem('_MOD_web_func', 'tx_wizardcrpages', $GLOBALS['BACK_PATH'],'<br/>|');
179
180 $out=$this->pObj->doc->section($LANG->getLL('wiz_crMany'),$theCode,0,1);
181 return $out;
182 }
183
184 /**
185 * Return the helpbubble image tag.
186 *
187 * @return string HTML code for a help-bubble image.
188 */
189 function helpBubble() {
190 return '<img src="'.$GLOBALS['BACK_PATH'].'gfx/helpbubble.gif" width="14" height="14" hspace="2" align="top"'.$this->pObj->doc->helpStyle().' alt="" />';
191 }
192 }
193
194 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/wizard_crpages/class.tx_wizardcrpages_webfunc_2.php']) {
195 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/wizard_crpages/class.tx_wizardcrpages_webfunc_2.php']);
196 }
197 ?>