TYPO3 API  SVNRelease
class.tx_wizardsortpages_webfunc_2.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Contains class for "Sort pages" wizard
00029  *
00030  * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
00031  * XHTML compliant
00032  *
00033  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00034  */
00035 /**
00036  * [CLASS/FUNCTION INDEX of SCRIPT]
00037  *
00038  *
00039  *
00040  *   67: class tx_wizardsortpages_webfunc_2 extends t3lib_extobjbase
00041  *   75:     function modMenu()
00042  *   88:     function main()
00043  *  175:     function wiz_linkOrder($title,$order)
00044  *
00045  * TOTAL FUNCTIONS: 3
00046  * (This index is automatically created/updated by the extension "extdeveval")
00047  *
00048  */
00049 /**
00050  * Creates the "Sort pages" wizard
00051  *
00052  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00053  * @package TYPO3
00054  * @subpackage tx_wizardsortpages
00055  */
00056 class tx_wizardsortpages_webfunc_2 extends t3lib_extobjbase {
00057 
00058     /**
00059      * 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...
00060      *
00061      * @return  array
00062      * @ignore
00063      */
00064     function modMenu()  {
00065         global $LANG;
00066 
00067         $modMenuAdd = array(
00068         );
00069         return $modMenuAdd;
00070     }
00071 
00072     /**
00073      * Main function creating the content for the module.
00074      *
00075      * @return  string      HTML content for the module, actually a "section" made through the parent object in $this->pObj
00076      */
00077     function main() {
00078         global $SOBE,$LANG;
00079 
00080         if ($GLOBALS['BE_USER']->workspace===0) {
00081 
00082             $theCode='';
00083 
00084                 // check if user has modify permissions to
00085             $sys_pages = t3lib_div::makeInstance('t3lib_pageSelect');
00086             $sortByField = t3lib_div::_GP('sortByField');
00087             if ($sortByField)   {
00088                 $menuItems=array();
00089                 if (t3lib_div::inList('title,subtitle,crdate,tstamp',$sortByField)) {
00090                     $menuItems = $sys_pages->getMenu($this->pObj->id,'uid,pid,title',$sortByField,'',0);
00091                 } elseif ($sortByField=='REV') {
00092                     $menuItems = $sys_pages->getMenu($this->pObj->id,'uid,pid,title','sorting','',0);
00093                     $menuItems = array_reverse($menuItems);
00094                 }
00095                 if (count($menuItems))  {
00096                     $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00097                     $tce->stripslashes_values=0;
00098                     $menuItems = array_reverse($menuItems);
00099                     $cmd=array();
00100                     foreach ($menuItems as $r) {
00101                         $cmd['pages'][$r['uid']]['move']=$this->pObj->id;
00102                     }
00103                     $tce->start(array(),$cmd);
00104                     $tce->process_cmdmap();
00105                     t3lib_BEfunc::setUpdateSignal('updatePageTree');
00106                 }
00107             }
00108 
00109                 //
00110             $menuItems = $sys_pages->getMenu($this->pObj->id,'*','sorting','',0);
00111             $lines=array();
00112                 $lines[]= '<tr class="t3-row-header">
00113                     <td>' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'), 'title') . '</td>
00114                     ' . (t3lib_extMgm::isLoaded('cms') ? '<td> ' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'), 'subtitle') . '</td>' : '').'
00115                     <td>' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'), 'tstamp') . '</td>
00116                     <td>' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'), 'crdate') . '</td>
00117                     </tr>';
00118             foreach ($menuItems as $rec) {
00119                 $m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(2);   // edit permissions for that page!
00120                 $pRec = t3lib_BEfunc::getRecord ('pages',$rec['uid'],'uid',' AND '.$m_perms_clause);
00121                 $lines[]= '<tr><td nowrap="nowrap">'.t3lib_iconWorks::getSpriteIconForRecord('pages',$rec).
00122                     (!is_array($pRec)?$GLOBALS['TBE_TEMPLATE']->rfw('<strong>'.$LANG->getLL('wiz_W',1).'</strong> '):'').
00123                     htmlspecialchars(t3lib_div::fixed_lgd_cs($rec['title'],$GLOBALS['BE_USER']->uc['titleLen'])).'&nbsp;</td>
00124                     '.(t3lib_extMgm::isLoaded('cms')?'<td nowrap="nowrap">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($rec['subtitle'],$GLOBALS['BE_USER']->uc['titleLen'])).'&nbsp;</td>':'').'
00125                     <td nowrap="nowrap">'.t3lib_Befunc::datetime($rec['tstamp']).'&nbsp;&nbsp;</td>
00126                     <td nowrap="nowrap">'.t3lib_Befunc::datetime($rec['crdate']).'&nbsp;&nbsp;</td>
00127                     </tr>';
00128             }
00129 
00130             $theCode .= '<h4>' . $LANG->getLL('wiz_currentPageOrder', TRUE) . '</h4>
00131             <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $lines) . '</table><br />';
00132 
00133             if (count($menuItems))  {
00134                     // Menu:
00135                 $lines=array();
00136                 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'),'title');
00137                 if (t3lib_extMgm::isLoaded('cms')) $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'),'subtitle');
00138                 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'),'tstamp');
00139                 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'),'crdate');
00140                 $lines[] = '';
00141                 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_REVERSE'),'REV');
00142                 $theCode.= '<h4>' . $LANG->getLL('wiz_changeOrder') . '</h4>' . implode('<br />', $lines);
00143             }
00144 
00145                 // CSH:
00146             $theCode.= t3lib_BEfunc::cshItem('_MOD_web_func', 'tx_wizardsortpages', $GLOBALS['BACK_PATH'], '<br />|');
00147 
00148             $out=$this->pObj->doc->section($LANG->getLL('wiz_sort'),$theCode,0,1);
00149         } else {
00150             $out=$this->pObj->doc->section($LANG->getLL('wiz_sort'),'Sorry, this function is not available in the current draft workspace!',0,1,1);
00151         }
00152         return $out;
00153     }
00154 
00155     /**
00156      * Creates a link for the sorting order
00157      *
00158      * @param   string      Title of the link
00159      * @param   string      Field to sort by
00160      * @return  string      HTML string
00161      */
00162     function wiz_linkOrder($title,$order)   {
00163         return '&nbsp; &nbsp;<a class="t3-link" 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>';
00164     }
00165 }
00166 
00167 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/wizard_sortpages/class.tx_wizardsortpages_webfunc_2.php'])) {
00168     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/wizard_sortpages/class.tx_wizardsortpages_webfunc_2.php']);
00169 }
00170 ?>