Fixed bug #16050: htmlArea RTE: Backspacing in empty editing area may raise js error
[Packages/TYPO3.CMS.git] / typo3 / move_el.php
old mode 100755 (executable)
new mode 100644 (file)
index 426678c..5c81ea5
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  * Moving pages or content elements (tt_content) around in the system via a page tree navigation.
  *
  * $Id$
- * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
+ * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
  * XHTML compatible.
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
@@ -72,11 +72,6 @@ require('template.php');
        // Include local language labels:
 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
 
-       // Include libraries:
-require_once(PATH_t3lib.'class.t3lib_page.php');
-require_once(PATH_t3lib.'class.t3lib_positionmap.php');
-require_once(PATH_t3lib.'class.t3lib_pagetree.php');
-
 
 
 
@@ -89,7 +84,7 @@ require_once(PATH_t3lib.'class.t3lib_pagetree.php');
 /**
  * Local extension of the page tree class
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -120,7 +115,7 @@ class localPageTree extends t3lib_pageTree {
 /**
  * Extension of position map for pages
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -135,7 +130,7 @@ class ext_posMap_pages extends t3lib_positionMap {
         * @return      string          Onclick attribute content
         */
        function onClickEvent($pid,$newPagePID) {
-               return 'document.location=\'tce_db.php?cmd[pages]['.$GLOBALS['SOBE']->moveUid.']['.$this->moveOrCopy.']='.$pid.'&redirect='.rawurlencode($this->R_URI).'&prErr=1&uPT=1&vC='.$GLOBALS['BE_USER']->veriCode().'\';return false;';
+               return 'window.location.href=\'tce_db.php?cmd[pages]['.$GLOBALS['SOBE']->moveUid.']['.$this->moveOrCopy.']='.$pid.'&redirect='.rawurlencode($this->R_URI).'&prErr=1&uPT=1&vC='.$GLOBALS['BE_USER']->veriCode().'\';return false;';
        }
 
        /**
@@ -177,7 +172,7 @@ class ext_posMap_pages extends t3lib_positionMap {
 /**
  * Extension of position map for content elements
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -204,7 +199,7 @@ class ext_posMap_tt_content extends t3lib_positionMap {
         * @return      string          Wrapped title string.
         */
        function wrapRecordTitle($str,$row)     {
-               if ($GLOBALS['SOBE']->moveUid==$row['uid'])     $str = '<b>'.$str.'</b>';
+               if ($GLOBALS['SOBE']->moveUid==$row['uid'])     $str = '<strong>'.$str.'</strong>';
                return parent::wrapRecordTitle($str,$row);
        }
 }
@@ -220,7 +215,7 @@ class ext_posMap_tt_content extends t3lib_positionMap {
 /**
  * Script Class for rendering the move-element wizard display
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -235,7 +230,12 @@ class SC_move_el {
        var $moveUid;
        var $makeCopy;
 
-       var $doc;                               // Backend template object.
+       /**
+        * Document template object
+        *
+        * @var mediumDoc
+        */
+       var $doc;
        var $perms_clause;              // Pages-select clause
 
                // Internal, dynamic:
@@ -255,7 +255,7 @@ class SC_move_el {
                $this->sys_language = intval(t3lib_div::_GP('sys_language'));
                $this->page_id=intval(t3lib_div::_GP('uid'));
                $this->table=t3lib_div::_GP('table');
-               $this->R_URI=t3lib_div::_GP('returnUrl');
+               $this->R_URI=t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
                $this->input_moveUid = t3lib_div::_GP('moveUid');
                $this->moveUid = $this->input_moveUid ? $this->input_moveUid : $this->page_id;
                $this->makeCopy = t3lib_div::_GP('makeCopy');
@@ -264,14 +264,13 @@ class SC_move_el {
                $this->perms_clause = $BE_USER->getPagePermsClause(1);
 
                        // Starting the document template object:
-               $this->doc = t3lib_div::makeInstance('mediumDoc');
-               $this->doc->docType= 'xhtml_trans';
+               $this->doc = t3lib_div::makeInstance('template');
                $this->doc->backPath = $BACK_PATH;
+               $this->doc->setModuleTemplate('templates/move_el.html');
                $this->doc->JScode='';
 
                        // Starting document content (header):
                $this->content='';
-               $this->content.=$this->doc->startPage($LANG->getLL('movingElement'));
                $this->content.=$this->doc->header($LANG->getLL('movingElement'));
                $this->content.=$this->doc->spacer(5);
        }
@@ -290,13 +289,13 @@ class SC_move_el {
                        $elRow = t3lib_BEfunc::getRecordWSOL($this->table,$this->moveUid);
 
                                // Headerline: Icon, record title:
-                       $hline = t3lib_iconWorks::getIconImage($this->table,$elRow,$BACK_PATH,' id="c-recIcon" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($elRow,$this->table)).'"');
-                       $hline.= t3lib_BEfunc::getRecordTitle($this->table,$elRow,1);
+                       $hline = t3lib_iconWorks::getSpriteIconForRecord($this->table, $elRow, array('id' => "c-recIcon", 'title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($elRow,$this->table))));
+                       $hline.= t3lib_BEfunc::getRecordTitle($this->table,$elRow,TRUE);
 
                                // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently):
-                       $onClick = 'document.location=\''.t3lib_div::linkThisScript(array('makeCopy'=>!$this->makeCopy)).'\';';
-                       $hline.= '<br /><input type="hidden" name="makeCopy" value="0" /><input type="checkbox" name="makeCopy" value="1"'.($this->makeCopy?' checked="checked"':'').' onclick="'.htmlspecialchars($onClick).'" />'.
-                               $LANG->getLL('makeCopy',1);
+                       $onClick = 'window.location.href=\''.t3lib_div::linkThisScript(array('makeCopy'=>!$this->makeCopy)).'\';';
+                       $hline.= '<br /><input type="hidden" name="makeCopy" value="0" /><input type="checkbox" name="makeCopy" id="makeCopy" value="1"'.($this->makeCopy?' checked="checked"':'').' onclick="'.htmlspecialchars($onClick).'" /> <label for="makeCopy">'.
+                               $LANG->getLL('makeCopy',1).'</label>';
 
                                // Add the header-content to the module content:
                        $this->content.=$this->doc->section($LANG->getLL('moveElement').':',$hline,0,1);
@@ -321,12 +320,12 @@ class SC_move_el {
                                                if (is_array($pidPageInfo))     {
                                                        if ($BE_USER->isInWebMount($pidPageInfo['pid'],$this->perms_clause))    {
                                                                $code.= '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('uid'=>intval($pageinfo['pid']),'moveUid'=>$this->moveUid))).'">'.
-                                                                       '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/i/pages_up.gif','width="18" height="16"').' alt="" />'.
-                                                                       t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,1).
+                                                                       t3lib_iconWorks::getSpriteIcon('actions-view-go-up') .
+                                                                       t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
                                                                        '</a><br />';
                                                        } else {
-                                                               $code.= t3lib_iconWorks::getIconImage('pages',$pidPageInfo,$BACK_PATH,'').
-                                                                       t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,1).
+                                                               $code.= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo) .
+                                                                       t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
                                                                        '<br />';
                                                        }
                                                }
@@ -334,9 +333,6 @@ class SC_move_el {
 
                                                // Create the position tree:
                                        $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI);
-
-                                               // CSH for move-pages:
-                                       $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_pages', $GLOBALS['BACK_PATH'],'<br/>|');
                                }
                        }
 
@@ -359,8 +355,8 @@ class SC_move_el {
                                        $posMap->cur_sys_language = $this->sys_language;
 
                                                // Headerline for the parent page: Icon, record title:
-                                       $hline = t3lib_iconWorks::getIconImage('pages',$pageinfo,$BACK_PATH,' title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($pageinfo,'pages')).'"');
-                                       $hline.= t3lib_BEfunc::getRecordTitle('pages',$pageinfo,1);
+                                       $hline = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageinfo, array('title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($pageinfo, 'pages'))));
+                                       $hline.= t3lib_BEfunc::getRecordTitle('pages',$pageinfo,TRUE);
 
                                                // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable:
                                        $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->page_id,'mod.SHARED');                // SHARED page-TSconfig settings.
@@ -379,12 +375,12 @@ class SC_move_el {
                                                if (is_array($pidPageInfo))     {
                                                        if ($BE_USER->isInWebMount($pidPageInfo['pid'],$this->perms_clause))    {
                                                                $code.= '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('uid'=>intval($pageinfo['pid']),'moveUid'=>$this->moveUid))).'">'.
-                                                                       '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/i/pages_up.gif','width="18" height="16"').' alt="" />'.
-                                                                       t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,1).
+                                                                       t3lib_iconWorks::getSpriteIcon('actions-view-go-up') .
+                                                                       t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
                                                                        '</a><br />';
                                                        } else {
-                                                               $code.= t3lib_iconWorks::getIconImage('pages',$pidPageInfo,$BACK_PATH,'').
-                                                                       t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,1).
+                                                               $code.= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo).
+                                                                       t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
                                                                        '<br />';
                                                        }
                                                }
@@ -392,20 +388,23 @@ class SC_move_el {
 
                                                // Create the position tree (for pages):
                                        $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI);
-
-                                               // CSH for move-content-elements:
-                                       $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_cs', $GLOBALS['BACK_PATH'],'<br/>|');
                                }
                        }
 
-                               // IF a return-url is given, print the go-back link:
-                       if ($this->R_URI)       {
-                               $code.='<br /><br /><a href="'.htmlspecialchars($this->R_URI).'" class="typo3-goBack"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/goback.gif','width="14" height="14"').' alt="" />'.$LANG->getLL('goBack',1).'</a>';
-                       }
-
                                // Add the $code content as a new section to the module:
                        $this->content.=$this->doc->section($LANG->getLL('selectPositionOfElement').':',$code,0,1);
                }
+
+                       // Setting up the buttons and markers for docheader
+               $docHeaderButtons = $this->getButtons();
+               $markers['CSH'] = $docHeaderButtons['csh'];
+               $markers['CONTENT'] = $this->content;
+
+                       // Build the <body> for the module
+               $this->content = $this->doc->startPage($LANG->getLL('movingElement'));
+               $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
+               $this->content.= $this->doc->endPage();
+               $this->content = $this->doc->insertStylesAndJS($this->content);
        }
 
        /**
@@ -414,26 +413,47 @@ class SC_move_el {
         * @return      void
         */
        function printContent() {
-               global $SOBE;
-
-               $this->content.= $this->doc->endPage();
                echo $this->content;
        }
-}
-
-// Include extension?
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/move_el.php'])      {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/move_el.php']);
-}
-
-
 
+       /**
+        * Create the panel of buttons for submitting the form or otherwise perform operations.
+        *
+        * @return      array   all available buttons as an assoc. array
+        */
+       protected function getButtons() {
+               global $LANG, $BACK_PATH;
 
+               $buttons = array(
+                       'csh' => '',
+                       'back' => ''
+               );
 
+               if ($this->page_id)     {
+                       if ((string)$this->table == 'pages') {
+                                       // CSH
+                               $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_pages', $GLOBALS['BACK_PATH'], '', TRUE);
+                       } elseif((string)$this->table == 'tt_content') {
+                                       // CSH
+                               $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_cs', $GLOBALS['BACK_PATH'], '', TRUE);
+                       }
 
+                       if ($this->R_URI) {
+                                       // Back
+                               $buttons['back'] ='<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack" title="' . $LANG->getLL('goBack', TRUE) .'">' .
+                                               t3lib_iconWorks::getSpriteIcon('actions-view-go-back') .
+                                       '</a>';
+                       }
+               }
 
+               return $buttons;
+       }
+}
 
 
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/move_el.php'])      {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/move_el.php']);
+}
 
 
 
@@ -442,4 +462,5 @@ $SOBE = t3lib_div::makeInstance('SC_move_el');
 $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
+
 ?>
\ No newline at end of file