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