move_el.php

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

Generated on Sat Jan 3 04:23:29 2009 for TYPO3 API by  doxygen 1.4.7