Added new system extensions (some of the safe ones...)
[Packages/TYPO3.CMS.git] / typo3 / sysext / wizard_sortpages / class.tx_wizardsortpages_webfunc_2.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@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 "Sort 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 <kasper@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 67: class tx_wizardsortpages_webfunc_2 extends t3lib_extobjbase
41 * 77: function modMenu()
42 * 94: function main()
43 * 173: function wiz_linkOrder($title,$order)
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 * Creates the "Sort pages" wizard
62 *
63 * @author Kasper Skaarhoj <kasper@typo3.com>
64 * @package TYPO3
65 * @subpackage tx_wizardsortpages
66 */
67 class tx_wizardsortpages_webfunc_2 extends t3lib_extobjbase {
68
69 /**
70 * 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...
71 *
72 * @return array
73 * @ignore
74 */
75 function modMenu() {
76 global $LANG;
77
78 $modMenuAdd = array(
79 'sort_blablabla' => array(
80 '2' => 'TO',
81 '1' => 'et'
82 )
83 );
84 return $modMenuAdd;
85 }
86
87 /**
88 * Main function creating the content for the module.
89 *
90 * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj
91 */
92 function main() {
93 global $SOBE,$LANG;
94
95 $theCode='';
96
97 // check if user has modify permissions to
98 $sys_pages = t3lib_div::makeInstance('t3lib_pageSelect');
99 $sortByField = t3lib_div::_GP('sortByField');
100 if ($sortByField) {
101 $menuItems=array();
102 if (t3lib_div::inList('title,subtitle,crdate,tstamp',$sortByField)) {
103 $menuItems = $sys_pages->getMenu($this->pObj->id,'uid,pid,title',$sortByField);
104 } elseif ($sortByField=='REV') {
105 $menuItems = $sys_pages->getMenu($this->pObj->id,'uid,pid,title');
106 $menuItems = array_reverse($menuItems);
107 }
108 if (count($menuItems)) {
109 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
110 $tce->stripslashes_values=0;
111 $menuItems = array_reverse($menuItems);
112 $cmd=array();
113 reset($menuItems);
114 while(list(,$r)=each($menuItems)) {
115 $cmd['pages'][$r['uid']]['move']=$this->pObj->id;
116 }
117 $tce->start(array(),$cmd);
118 $tce->process_cmdmap();
119 t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
120 }
121 }
122
123 //
124 $menuItems = $sys_pages->getMenu($this->pObj->id);
125 reset($menuItems);
126 $lines=array();
127 $lines[]= '<tr>
128 <td class="bgColor5"><b>'.$this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'),'title').'</b></td>
129 '.(t3lib_extMgm::isLoaded('cms')?'<td class="bgColor5"><b>'.$this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'),'subtitle').'</b></td>':'').'
130 <td class="bgColor5"><b>'.$this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'),'tstamp').'</b></td>
131 <td class="bgColor5"><b>'.$this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'),'crdate').'</b></td>
132 </tr>';
133 while(list(,$rec)=each($menuItems)) {
134 $m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(2); // edit permissions for that page!
135 $pRec = t3lib_BEfunc::getRecord ('pages',$rec['uid'],'uid',' AND '.$m_perms_clause);
136 $lines[]= '<tr><td nowrap="nowrap">'.t3lib_iconWorks::getIconImage('pages',$rec,$GLOBALS['BACK_PATH'],'align="top" '.t3lib_BEfunc::titleAttribForPages($rec)).
137 (!is_array($pRec)?$GLOBALS['TBE_TEMPLATE']->rfw('<b>'.$LANG->getLL('wiz_W',1).'</b> '):'').
138 htmlspecialchars(t3lib_div::fixed_lgd_cs($rec['title'],$GLOBALS['BE_USER']->uc['titleLen'])).'&nbsp;</td>
139 '.(t3lib_extMgm::isLoaded('cms')?'<td nowrap="nowrap">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($rec['subtitle'],$GLOBALS['BE_USER']->uc['titleLen'])).'&nbsp;</td>':'').'
140 <td nowrap="nowrap">'.t3lib_Befunc::datetime($rec['tstamp']).'&nbsp;&nbsp;</td>
141 <td nowrap="nowrap">'.t3lib_Befunc::datetime($rec['crdate']).'&nbsp;&nbsp;</td>
142 </tr>';
143 }
144
145 $theCode.= '<b>'.$LANG->getLL('wiz_currentPageOrder',1).':</b><br /><br />
146 <table border="0" cellpadding="0" cellspacing="0">'.implode('',$lines).'</table><br />';
147
148 if (count($menuItems)) {
149 // Menu:
150 $lines=array();
151 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'),'title');
152 if (t3lib_extMgm::isLoaded('cms')) $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'),'subtitle');
153 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'),'tstamp');
154 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'),'crdate');
155 $lines[] = '';
156 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_REVERSE'),'REV');
157 $theCode.= '<b>'.$LANG->getLL('wiz_changeOrder').':</b><br /><br />'.implode('<br />',$lines);
158 }
159
160 // CSH:
161 $theCode.= t3lib_BEfunc::cshItem('_MOD_web_func', 'tx_wizardsortpages', $GLOBALS['BACK_PATH'],'<br/>|');
162
163 $out=$this->pObj->doc->section($LANG->getLL('wiz_sort'),$theCode,0,1);
164 return $out;
165 }
166
167 /**
168 * Creates a link for the sorting order
169 *
170 * @param string Title of the link
171 * @param string Field to sort by
172 * @return string HTML string
173 */
174 function wiz_linkOrder($title,$order) {
175 return '&nbsp; &nbsp;<a href="'.htmlspecialchars('index.php?id='.$GLOBALS['SOBE']->id.'&sortByField='.$order).'" onclick="return confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('wiz_changeOrder_msg1')).')">'.htmlspecialchars($title).'</a>';
176 }
177 }
178
179 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/wizard_sortpages/class.tx_wizardsortpages_webfunc_2.php']) {
180 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/wizard_sortpages/class.tx_wizardsortpages_webfunc_2.php']);
181 }
182 ?>