move_el.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2010 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  * Move element wizard:
00029  * Moving pages or content elements (tt_content) around in the system via a page tree navigation.
00030  *
00031  * $Id: move_el.php 8742 2010-08-30 18:55:32Z baschny $
00032  * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
00033  * XHTML compatible.
00034  *
00035  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00036  */
00037 /**
00038  * [CLASS/FUNCTION INDEX of SCRIPT]
00039  *
00040  *
00041  *
00042  *   96: class localPageTree extends t3lib_pageTree
00043  *  105:     function wrapIcon($icon,$row)
00044  *
00045  *
00046  *  127: class ext_posMap_pages extends t3lib_positionMap
00047  *  137:     function onClickEvent($pid,$newPagePID)
00048  *  148:     function linkPageTitle($str,$rec)
00049  *  161:     function boldTitle($t_code,$dat,$id)
00050  *
00051  *
00052  *  184: class ext_posMap_tt_content extends t3lib_positionMap
00053  *  194:     function linkPageTitle($str,$rec)
00054  *  206:     function wrapRecordTitle($str,$row)
00055  *
00056  *
00057  *  227: class SC_move_el
00058  *  250:     function init()
00059  *  284:     function main()
00060  *  416:     function printContent()
00061  *
00062  * TOTAL FUNCTIONS: 9
00063  * (This index is automatically created/updated by the extension "extdeveval")
00064  *
00065  */
00066 
00067 
00068 $BACK_PATH='';
00069 require('init.php');
00070 require('template.php');
00071 
00072     // Include local language labels:
00073 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 /**
00085  * Local extension of the page tree class
00086  *
00087  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00088  * @package TYPO3
00089  * @subpackage core
00090  */
00091 class localPageTree extends t3lib_pageTree {
00092 
00093     /**
00094      * Inserting uid-information in title-text for an icon
00095      *
00096      * @param   string      Icon image
00097      * @param   array       Item row
00098      * @return  string      Wrapping icon image.
00099      */
00100     function wrapIcon($icon,$row)   {
00101         return $this->addTagAttributes($icon,' title="id='.htmlspecialchars($row['uid']).'"');
00102     }
00103 }
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 /**
00116  * Extension of position map for pages
00117  *
00118  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00119  * @package TYPO3
00120  * @subpackage core
00121  */
00122 class ext_posMap_pages extends t3lib_positionMap {
00123     var $l_insertNewPageHere = 'movePageToHere';
00124 
00125     /**
00126      * Creates the onclick event for the insert-icons.
00127      *
00128      * @param   integer     The pid.
00129      * @param   integer     New page id.
00130      * @return  string      Onclick attribute content
00131      */
00132     function onClickEvent($pid,$newPagePID) {
00133         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;';
00134     }
00135 
00136     /**
00137      * Wrapping page title.
00138      *
00139      * @param   string      Page title.
00140      * @param   array       Page record (?)
00141      * @return  string      Wrapped title.
00142      */
00143     function linkPageTitle($str,$rec)   {
00144         $url = t3lib_div::linkThisScript(array('uid'=>intval($rec['uid']),'moveUid'=>$GLOBALS['SOBE']->moveUid));
00145         return '<a href="'.htmlspecialchars($url).'">'.$str.'</a>';
00146     }
00147 
00148     /**
00149      * Wrap $t_code in bold IF the $dat uid matches $id
00150      *
00151      * @param   string      Title string
00152      * @param   array       Infomation array with record array inside.
00153      * @param   integer     The current id.
00154      * @return  string      The title string.
00155      */
00156     function boldTitle($t_code,$dat,$id)    {
00157         return parent::boldTitle($t_code,$dat,$GLOBALS['SOBE']->moveUid);
00158     }
00159 }
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 /**
00173  * Extension of position map for content elements
00174  *
00175  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00176  * @package TYPO3
00177  * @subpackage core
00178  */
00179 class ext_posMap_tt_content extends t3lib_positionMap {
00180     var $dontPrintPageInsertIcons = 1;
00181 
00182     /**
00183      * Wrapping page title.
00184      *
00185      * @param   string      Page title.
00186      * @param   array       Page record (?)
00187      * @return  string      Wrapped title.
00188      */
00189     function linkPageTitle($str,$rec)   {
00190         $url = t3lib_div::linkThisScript(array('uid'=>intval($rec['uid']),'moveUid'=>$GLOBALS['SOBE']->moveUid));
00191         return '<a href="'.htmlspecialchars($url).'">'.$str.'</a>';
00192     }
00193 
00194     /**
00195      * Wrapping the title of the record.
00196      *
00197      * @param   string      The title value.
00198      * @param   array       The record row.
00199      * @return  string      Wrapped title string.
00200      */
00201     function wrapRecordTitle($str,$row) {
00202         if ($GLOBALS['SOBE']->moveUid==$row['uid']) $str = '<strong>'.$str.'</strong>';
00203         return parent::wrapRecordTitle($str,$row);
00204     }
00205 }
00206 
00207 
00208 
00209 
00210 
00211 
00212 
00213 
00214 
00215 /**
00216  * Script Class for rendering the move-element wizard display
00217  *
00218  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00219  * @package TYPO3
00220  * @subpackage core
00221  */
00222 class SC_move_el {
00223 
00224         // Internal, static (eg. from GPvars):
00225     var $sys_language=0;
00226     var $page_id;
00227     var $table;
00228     var $R_URI;
00229     var $input_moveUid;
00230     var $moveUid;
00231     var $makeCopy;
00232 
00233     /**
00234      * Document template object
00235      *
00236      * @var mediumDoc
00237      */
00238     var $doc;
00239     var $perms_clause;      // Pages-select clause
00240 
00241         // Internal, dynamic:
00242     var $content;           // Content for module accumulated here.
00243 
00244 
00245     /**
00246      * Constructor, initializing internal variables.
00247      *
00248      * @return  void
00249      */
00250     function init() {
00251         global $BE_USER,$LANG,$BACK_PATH;
00252 
00253 
00254             // Setting internal vars:
00255         $this->sys_language = intval(t3lib_div::_GP('sys_language'));
00256         $this->page_id=intval(t3lib_div::_GP('uid'));
00257         $this->table=t3lib_div::_GP('table');
00258         $this->R_URI=t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
00259         $this->input_moveUid = t3lib_div::_GP('moveUid');
00260         $this->moveUid = $this->input_moveUid ? $this->input_moveUid : $this->page_id;
00261         $this->makeCopy = t3lib_div::_GP('makeCopy');
00262 
00263             // Select-pages where clause for read-access:
00264         $this->perms_clause = $BE_USER->getPagePermsClause(1);
00265 
00266             // Starting the document template object:
00267         $this->doc = t3lib_div::makeInstance('template');
00268         $this->doc->backPath = $BACK_PATH;
00269         $this->doc->setModuleTemplate('templates/move_el.html');
00270         $this->doc->JScode='';
00271 
00272             // Starting document content (header):
00273         $this->content='';
00274         $this->content.=$this->doc->header($LANG->getLL('movingElement'));
00275         $this->content.=$this->doc->spacer(5);
00276     }
00277 
00278     /**
00279      * Creating the module output.
00280      *
00281      * @return  void
00282      */
00283     function main() {
00284         global $LANG,$BACK_PATH,$BE_USER;
00285 
00286         if ($this->page_id) {
00287 
00288                 // Get record for element:
00289             $elRow = t3lib_BEfunc::getRecordWSOL($this->table,$this->moveUid);
00290 
00291                 // Headerline: Icon, record title:
00292             $hline = t3lib_iconWorks::getSpriteIconForRecord($this->table, $elRow, array('id' => "c-recIcon", 'title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($elRow,$this->table))));
00293             $hline.= t3lib_BEfunc::getRecordTitle($this->table,$elRow,TRUE);
00294 
00295                 // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently):
00296             $onClick = 'window.location.href=\''.t3lib_div::linkThisScript(array('makeCopy'=>!$this->makeCopy)).'\';';
00297             $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">'.
00298                 $LANG->getLL('makeCopy',1).'</label>';
00299 
00300                 // Add the header-content to the module content:
00301             $this->content.=$this->doc->section($LANG->getLL('moveElement').':',$hline,0,1);
00302             $this->content.=$this->doc->spacer(20);
00303 
00304                 // Reset variable to pick up the module content in:
00305             $code='';
00306 
00307                 // IF the table is "pages":
00308             if ((string)$this->table=='pages')  {
00309                     // Get page record (if accessible):
00310                 $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id,$this->perms_clause);
00311                 if (is_array($pageinfo) && $BE_USER->isInWebMount($pageinfo['pid'],$this->perms_clause))    {
00312 
00313                         // Initialize the position map:
00314                     $posMap = t3lib_div::makeInstance('ext_posMap_pages');
00315                     $posMap->moveOrCopy = $this->makeCopy?'copy':'move';
00316 
00317                         // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
00318                     if ($pageinfo['pid'])   {
00319                         $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'],$this->perms_clause);
00320                         if (is_array($pidPageInfo)) {
00321                             if ($BE_USER->isInWebMount($pidPageInfo['pid'],$this->perms_clause))    {
00322                                 $code.= '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('uid'=>intval($pageinfo['pid']),'moveUid'=>$this->moveUid))).'">'.
00323                                     t3lib_iconWorks::getSpriteIcon('actions-view-go-up') .
00324                                     t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
00325                                     '</a><br />';
00326                             } else {
00327                                 $code.= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo) .
00328                                     t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
00329                                     '<br />';
00330                             }
00331                         }
00332                     }
00333 
00334                         // Create the position tree:
00335                     $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI);
00336                 }
00337             }
00338 
00339                 // IF the table is "tt_content":
00340             if ((string)$this->table=='tt_content') {
00341 
00342                     // First, get the record:
00343                 $tt_content_rec = t3lib_BEfunc::getRecord('tt_content',$this->moveUid);
00344 
00345                     // ?
00346                 if (!$this->input_moveUid)  $this->page_id = $tt_content_rec['pid'];
00347 
00348                     // Checking if the parent page is readable:
00349                 $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id,$this->perms_clause);
00350                 if (is_array($pageinfo) && $BE_USER->isInWebMount($pageinfo['pid'],$this->perms_clause))    {
00351 
00352                         // Initialize the position map:
00353                     $posMap = t3lib_div::makeInstance('ext_posMap_tt_content');
00354                     $posMap->moveOrCopy = $this->makeCopy?'copy':'move';
00355                     $posMap->cur_sys_language = $this->sys_language;
00356 
00357                         // Headerline for the parent page: Icon, record title:
00358                     $hline = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageinfo, array('title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($pageinfo, 'pages'))));
00359                     $hline.= t3lib_BEfunc::getRecordTitle('pages',$pageinfo,TRUE);
00360 
00361                         // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable:
00362                     $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->page_id,'mod.SHARED');        // SHARED page-TSconfig settings.
00363                     $colPosList = strcmp(trim($modTSconfig_SHARED['properties']['colPos_list']),'') ? trim($modTSconfig_SHARED['properties']['colPos_list']) : '1,0,2,3';
00364                     $colPosList = implode(',',array_unique(t3lib_div::intExplode(',',$colPosList)));        // Removing duplicates, if any
00365 
00366                         // Adding parent page-header and the content element columns from position-map:
00367                     $code=$hline.'<br />';
00368                     $code.=$posMap->printContentElementColumns($this->page_id,$this->moveUid,$colPosList,1,$this->R_URI);
00369 
00370                         // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
00371                     $code.= '<br />';
00372                     $code.= '<br />';
00373                     if ($pageinfo['pid'])   {
00374                         $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'],$this->perms_clause);
00375                         if (is_array($pidPageInfo)) {
00376                             if ($BE_USER->isInWebMount($pidPageInfo['pid'],$this->perms_clause))    {
00377                                 $code.= '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('uid'=>intval($pageinfo['pid']),'moveUid'=>$this->moveUid))).'">'.
00378                                     t3lib_iconWorks::getSpriteIcon('actions-view-go-up') .
00379                                     t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
00380                                     '</a><br />';
00381                             } else {
00382                                 $code.= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo).
00383                                     t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
00384                                     '<br />';
00385                             }
00386                         }
00387                     }
00388 
00389                         // Create the position tree (for pages):
00390                     $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI);
00391                 }
00392             }
00393 
00394                 // Add the $code content as a new section to the module:
00395             $this->content.=$this->doc->section($LANG->getLL('selectPositionOfElement').':',$code,0,1);
00396         }
00397 
00398             // Setting up the buttons and markers for docheader
00399         $docHeaderButtons = $this->getButtons();
00400         $markers['CSH'] = $docHeaderButtons['csh'];
00401         $markers['CONTENT'] = $this->content;
00402 
00403             // Build the <body> for the module
00404         $this->content = $this->doc->startPage($LANG->getLL('movingElement'));
00405         $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00406         $this->content.= $this->doc->endPage();
00407         $this->content = $this->doc->insertStylesAndJS($this->content);
00408     }
00409 
00410     /**
00411      * Print out the accumulated content:
00412      *
00413      * @return  void
00414      */
00415     function printContent() {
00416         echo $this->content;
00417     }
00418 
00419     /**
00420      * Create the panel of buttons for submitting the form or otherwise perform operations.
00421      *
00422      * @return  array   all available buttons as an assoc. array
00423      */
00424     protected function getButtons() {
00425         global $LANG, $BACK_PATH;
00426 
00427         $buttons = array(
00428             'csh' => '',
00429             'back' => ''
00430         );
00431 
00432         if ($this->page_id) {
00433             if ((string)$this->table == 'pages') {
00434                     // CSH
00435                 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_pages', $GLOBALS['BACK_PATH'], '', TRUE);
00436             } elseif((string)$this->table == 'tt_content') {
00437                     // CSH
00438                 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_cs', $GLOBALS['BACK_PATH'], '', TRUE);
00439             }
00440 
00441             if ($this->R_URI) {
00442                     // Back
00443                 $buttons['back'] ='<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack" title="' . $LANG->getLL('goBack', TRUE) .'">' .
00444                         t3lib_iconWorks::getSpriteIcon('actions-view-go-back') .
00445                     '</a>';
00446             }
00447         }
00448 
00449         return $buttons;
00450     }
00451 }
00452 
00453 
00454 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/move_el.php'])   {
00455     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/move_el.php']);
00456 }
00457 
00458 
00459 
00460 // Make instance:
00461 $SOBE = t3lib_div::makeInstance('SC_move_el');
00462 $SOBE->init();
00463 $SOBE->main();
00464 $SOBE->printContent();
00465 
00466 ?>

Generated on Sat Sep 4 04:17:13 2010 for TYPO3 API by  doxygen 1.4.7