|
TYPO3 API
SVNRelease
|
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 * 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 10295 2011-01-25 09:33:06Z 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 . 00134 '&redirect=' . rawurlencode($this->R_URI) . 00135 '&prErr=1&uPT=1&vC=' . $GLOBALS['BE_USER']->veriCode() . 00136 t3lib_BEfunc::getUrlToken('tceAction') . 00137 '\';return false;'; 00138 } 00139 00140 /** 00141 * Wrapping page title. 00142 * 00143 * @param string Page title. 00144 * @param array Page record (?) 00145 * @return string Wrapped title. 00146 */ 00147 function linkPageTitle($str,$rec) { 00148 $url = t3lib_div::linkThisScript(array('uid'=>intval($rec['uid']),'moveUid'=>$GLOBALS['SOBE']->moveUid)); 00149 return '<a href="'.htmlspecialchars($url).'">'.$str.'</a>'; 00150 } 00151 00152 /** 00153 * Wrap $t_code in bold IF the $dat uid matches $id 00154 * 00155 * @param string Title string 00156 * @param array Infomation array with record array inside. 00157 * @param integer The current id. 00158 * @return string The title string. 00159 */ 00160 function boldTitle($t_code,$dat,$id) { 00161 return parent::boldTitle($t_code,$dat,$GLOBALS['SOBE']->moveUid); 00162 } 00163 } 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 /** 00177 * Extension of position map for content elements 00178 * 00179 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00180 * @package TYPO3 00181 * @subpackage core 00182 */ 00183 class ext_posMap_tt_content extends t3lib_positionMap { 00184 var $dontPrintPageInsertIcons = 1; 00185 00186 /** 00187 * Wrapping page title. 00188 * 00189 * @param string Page title. 00190 * @param array Page record (?) 00191 * @return string Wrapped title. 00192 */ 00193 function linkPageTitle($str,$rec) { 00194 $url = t3lib_div::linkThisScript(array('uid'=>intval($rec['uid']),'moveUid'=>$GLOBALS['SOBE']->moveUid)); 00195 return '<a href="'.htmlspecialchars($url).'">'.$str.'</a>'; 00196 } 00197 00198 /** 00199 * Wrapping the title of the record. 00200 * 00201 * @param string The title value. 00202 * @param array The record row. 00203 * @return string Wrapped title string. 00204 */ 00205 function wrapRecordTitle($str,$row) { 00206 if ($GLOBALS['SOBE']->moveUid==$row['uid']) $str = '<strong>'.$str.'</strong>'; 00207 return parent::wrapRecordTitle($str,$row); 00208 } 00209 } 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 /** 00220 * Script Class for rendering the move-element wizard display 00221 * 00222 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00223 * @package TYPO3 00224 * @subpackage core 00225 */ 00226 class SC_move_el { 00227 00228 // Internal, static (eg. from GPvars): 00229 var $sys_language=0; 00230 var $page_id; 00231 var $table; 00232 var $R_URI; 00233 var $input_moveUid; 00234 var $moveUid; 00235 var $makeCopy; 00236 00237 /** 00238 * Document template object 00239 * 00240 * @var mediumDoc 00241 */ 00242 var $doc; 00243 var $perms_clause; // Pages-select clause 00244 00245 // Internal, dynamic: 00246 var $content; // Content for module accumulated here. 00247 00248 00249 /** 00250 * Constructor, initializing internal variables. 00251 * 00252 * @return void 00253 */ 00254 function init() { 00255 global $BE_USER,$LANG,$BACK_PATH; 00256 00257 00258 // Setting internal vars: 00259 $this->sys_language = intval(t3lib_div::_GP('sys_language')); 00260 $this->page_id=intval(t3lib_div::_GP('uid')); 00261 $this->table=t3lib_div::_GP('table'); 00262 $this->R_URI=t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl')); 00263 $this->input_moveUid = t3lib_div::_GP('moveUid'); 00264 $this->moveUid = $this->input_moveUid ? $this->input_moveUid : $this->page_id; 00265 $this->makeCopy = t3lib_div::_GP('makeCopy'); 00266 00267 // Select-pages where clause for read-access: 00268 $this->perms_clause = $BE_USER->getPagePermsClause(1); 00269 00270 // Starting the document template object: 00271 $this->doc = t3lib_div::makeInstance('template'); 00272 $this->doc->backPath = $BACK_PATH; 00273 $this->doc->setModuleTemplate('templates/move_el.html'); 00274 $this->doc->JScode=''; 00275 00276 // Starting document content (header): 00277 $this->content=''; 00278 $this->content.=$this->doc->header($LANG->getLL('movingElement')); 00279 $this->content.=$this->doc->spacer(5); 00280 } 00281 00282 /** 00283 * Creating the module output. 00284 * 00285 * @return void 00286 */ 00287 function main() { 00288 global $LANG,$BACK_PATH,$BE_USER; 00289 00290 if ($this->page_id) { 00291 00292 // Get record for element: 00293 $elRow = t3lib_BEfunc::getRecordWSOL($this->table,$this->moveUid); 00294 00295 // Headerline: Icon, record title: 00296 $hline = t3lib_iconWorks::getSpriteIconForRecord($this->table, $elRow, array('id' => "c-recIcon", 'title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($elRow,$this->table)))); 00297 $hline.= t3lib_BEfunc::getRecordTitle($this->table,$elRow,TRUE); 00298 00299 // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently): 00300 $onClick = 'window.location.href=\''.t3lib_div::linkThisScript(array('makeCopy'=>!$this->makeCopy)).'\';'; 00301 $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">'. 00302 $LANG->getLL('makeCopy',1).'</label>'; 00303 00304 // Add the header-content to the module content: 00305 $this->content.=$this->doc->section($LANG->getLL('moveElement').':',$hline,0,1); 00306 $this->content.=$this->doc->spacer(20); 00307 00308 // Reset variable to pick up the module content in: 00309 $code=''; 00310 00311 // IF the table is "pages": 00312 if ((string)$this->table=='pages') { 00313 // Get page record (if accessible): 00314 $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id,$this->perms_clause); 00315 if (is_array($pageinfo) && $BE_USER->isInWebMount($pageinfo['pid'],$this->perms_clause)) { 00316 00317 // Initialize the position map: 00318 $posMap = t3lib_div::makeInstance('ext_posMap_pages'); 00319 $posMap->moveOrCopy = $this->makeCopy?'copy':'move'; 00320 00321 // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page). 00322 if ($pageinfo['pid']) { 00323 $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'],$this->perms_clause); 00324 if (is_array($pidPageInfo)) { 00325 if ($BE_USER->isInWebMount($pidPageInfo['pid'],$this->perms_clause)) { 00326 $code.= '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('uid'=>intval($pageinfo['pid']),'moveUid'=>$this->moveUid))).'">'. 00327 t3lib_iconWorks::getSpriteIcon('actions-view-go-up') . 00328 t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE). 00329 '</a><br />'; 00330 } else { 00331 $code.= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo) . 00332 t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE). 00333 '<br />'; 00334 } 00335 } 00336 } 00337 00338 // Create the position tree: 00339 $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI); 00340 } 00341 } 00342 00343 // IF the table is "tt_content": 00344 if ((string)$this->table=='tt_content') { 00345 00346 // First, get the record: 00347 $tt_content_rec = t3lib_BEfunc::getRecord('tt_content',$this->moveUid); 00348 00349 // ? 00350 if (!$this->input_moveUid) $this->page_id = $tt_content_rec['pid']; 00351 00352 // Checking if the parent page is readable: 00353 $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id,$this->perms_clause); 00354 if (is_array($pageinfo) && $BE_USER->isInWebMount($pageinfo['pid'],$this->perms_clause)) { 00355 00356 // Initialize the position map: 00357 $posMap = t3lib_div::makeInstance('ext_posMap_tt_content'); 00358 $posMap->moveOrCopy = $this->makeCopy?'copy':'move'; 00359 $posMap->cur_sys_language = $this->sys_language; 00360 00361 // Headerline for the parent page: Icon, record title: 00362 $hline = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageinfo, array('title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($pageinfo, 'pages')))); 00363 $hline.= t3lib_BEfunc::getRecordTitle('pages',$pageinfo,TRUE); 00364 00365 // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable: 00366 $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->page_id,'mod.SHARED'); // SHARED page-TSconfig settings. 00367 $colPosList = strcmp(trim($modTSconfig_SHARED['properties']['colPos_list']),'') ? trim($modTSconfig_SHARED['properties']['colPos_list']) : '1,0,2,3'; 00368 $colPosList = implode(',',array_unique(t3lib_div::intExplode(',',$colPosList))); // Removing duplicates, if any 00369 00370 // Adding parent page-header and the content element columns from position-map: 00371 $code=$hline.'<br />'; 00372 $code.=$posMap->printContentElementColumns($this->page_id,$this->moveUid,$colPosList,1,$this->R_URI); 00373 00374 // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page). 00375 $code.= '<br />'; 00376 $code.= '<br />'; 00377 if ($pageinfo['pid']) { 00378 $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'],$this->perms_clause); 00379 if (is_array($pidPageInfo)) { 00380 if ($BE_USER->isInWebMount($pidPageInfo['pid'],$this->perms_clause)) { 00381 $code.= '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('uid'=>intval($pageinfo['pid']),'moveUid'=>$this->moveUid))).'">'. 00382 t3lib_iconWorks::getSpriteIcon('actions-view-go-up') . 00383 t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE). 00384 '</a><br />'; 00385 } else { 00386 $code.= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo). 00387 t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE). 00388 '<br />'; 00389 } 00390 } 00391 } 00392 00393 // Create the position tree (for pages): 00394 $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI); 00395 } 00396 } 00397 00398 // Add the $code content as a new section to the module: 00399 $this->content.=$this->doc->section($LANG->getLL('selectPositionOfElement').':',$code,0,1); 00400 } 00401 00402 // Setting up the buttons and markers for docheader 00403 $docHeaderButtons = $this->getButtons(); 00404 $markers['CSH'] = $docHeaderButtons['csh']; 00405 $markers['CONTENT'] = $this->content; 00406 00407 // Build the <body> for the module 00408 $this->content = $this->doc->startPage($LANG->getLL('movingElement')); 00409 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); 00410 $this->content.= $this->doc->endPage(); 00411 $this->content = $this->doc->insertStylesAndJS($this->content); 00412 } 00413 00414 /** 00415 * Print out the accumulated content: 00416 * 00417 * @return void 00418 */ 00419 function printContent() { 00420 echo $this->content; 00421 } 00422 00423 /** 00424 * Create the panel of buttons for submitting the form or otherwise perform operations. 00425 * 00426 * @return array all available buttons as an assoc. array 00427 */ 00428 protected function getButtons() { 00429 global $LANG, $BACK_PATH; 00430 00431 $buttons = array( 00432 'csh' => '', 00433 'back' => '' 00434 ); 00435 00436 if ($this->page_id) { 00437 if ((string)$this->table == 'pages') { 00438 // CSH 00439 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_pages', $GLOBALS['BACK_PATH'], '', TRUE); 00440 } elseif((string)$this->table == 'tt_content') { 00441 // CSH 00442 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_cs', $GLOBALS['BACK_PATH'], '', TRUE); 00443 } 00444 00445 if ($this->R_URI) { 00446 // Back 00447 $buttons['back'] ='<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack" title="' . $LANG->getLL('goBack', TRUE) .'">' . 00448 t3lib_iconWorks::getSpriteIcon('actions-view-go-back') . 00449 '</a>'; 00450 } 00451 } 00452 00453 return $buttons; 00454 } 00455 } 00456 00457 00458 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/move_el.php'])) { 00459 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/move_el.php']); 00460 } 00461 00462 00463 00464 // Make instance: 00465 $SOBE = t3lib_div::makeInstance('SC_move_el'); 00466 $SOBE->init(); 00467 $SOBE->main(); 00468 $SOBE->printContent(); 00469 00470 ?>
1.8.0