Documentation TYPO3 par Ameos

move_el.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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 ***************************************************************/
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 
00096 class localPageTree extends t3lib_pageTree {
00097 
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 
00127 class ext_posMap_pages extends t3lib_positionMap {
00128         var $l_insertNewPageHere = 'movePageToHere';
00129 
00137         function onClickEvent($pid,$newPagePID) {
00138                 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;';
00139         }
00140 
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 
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 
00184 class ext_posMap_tt_content extends t3lib_positionMap {
00185         var $dontPrintPageInsertIcons = 1;
00186 
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 
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 
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         var $doc;                               // Backend template object.
00239         var $perms_clause;              // Pages-select clause
00240 
00241                 // Internal, dynamic:
00242         var $content;                   // Content for module accumulated here.
00243 
00244 
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::_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('mediumDoc');
00268                 $this->doc->docType= 'xhtml_trans';
00269                 $this->doc->backPath = $BACK_PATH;
00270                 $this->doc->JScode='';
00271 
00272                         // Starting document content (header):
00273                 $this->content='';
00274                 $this->content.=$this->doc->startPage($LANG->getLL('movingElement'));
00275                 $this->content.=$this->doc->header($LANG->getLL('movingElement'));
00276                 $this->content.=$this->doc->spacer(5);
00277         }
00278 
00284         function main() {
00285                 global $LANG,$BACK_PATH,$BE_USER;
00286 
00287                 if ($this->page_id)     {
00288 
00289                                 // Get record for element:
00290                         $elRow = t3lib_BEfunc::getRecord($this->table,$this->moveUid);
00291 
00292                                 // Headerline: Icon, record title:
00293                         $hline = t3lib_iconWorks::getIconImage($this->table,$elRow,$BACK_PATH,' id="c-recIcon" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($elRow,$this->table)).'"');
00294                         $hline.= t3lib_BEfunc::getRecordTitle($this->table,$elRow,1);
00295 
00296                                 // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently):
00297                         $onClick = 'document.location=\''.t3lib_div::linkThisScript(array('makeCopy'=>!$this->makeCopy)).'\';';
00298                         $hline.= '<br /><input type="hidden" name="makeCopy" value="0" /><input type="checkbox" name="makeCopy" value="1"'.($this->makeCopy?' checked="checked"':'').' onclick="'.htmlspecialchars($onClick).'" />'.
00299                                 $LANG->getLL('makeCopy',1);
00300 
00301                                 // Add the header-content to the module content:
00302                         $this->content.=$this->doc->section($LANG->getLL('moveElement').':',$hline,0,1);
00303                         $this->content.=$this->doc->spacer(20);
00304 
00305                                 // Reset variable to pick up the module content in:
00306                         $code='';
00307 
00308                                 // IF the table is "pages":
00309                         if ((string)$this->table=='pages')      {
00310                                         // Get page record (if accessible):
00311                                 $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id,$this->perms_clause);
00312                                 if (is_array($pageinfo) && $BE_USER->isInWebMount($pageinfo['pid'],$this->perms_clause))        {
00313 
00314                                                 // Initialize the position map:
00315                                         $posMap = t3lib_div::makeInstance('ext_posMap_pages');
00316                                         $posMap->moveOrCopy = $this->makeCopy?'copy':'move';
00317 
00318                                                 // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
00319                                         if ($pageinfo['pid'])   {
00320                                                 $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'],$this->perms_clause);
00321                                                 if (is_array($pidPageInfo))     {
00322                                                         if ($BE_USER->isInWebMount($pidPageInfo['pid'],$this->perms_clause))    {
00323                                                                 $code.= '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('uid'=>intval($pageinfo['pid']),'moveUid'=>$this->moveUid))).'">'.
00324                                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/i/pages_up.gif','width="18" height="16"').' alt="" />'.
00325                                                                         t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,1).
00326                                                                         '</a><br />';
00327                                                         } else {
00328                                                                 $code.= t3lib_iconWorks::getIconImage('pages',$pidPageInfo,$BACK_PATH,'').
00329                                                                         t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,1).
00330                                                                         '<br />';
00331                                                         }
00332                                                 }
00333                                         }
00334 
00335                                                 // Create the position tree:
00336                                         $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI);
00337 
00338                                                 // CSH for move-pages:
00339                                         $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_pages', $GLOBALS['BACK_PATH'],'<br/>|');
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::getIconImage('pages',$pageinfo,$BACK_PATH,' title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($pageinfo,'pages')).'"');
00363                                         $hline.= t3lib_BEfunc::getRecordTitle('pages',$pageinfo,1);
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                                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/i/pages_up.gif','width="18" height="16"').' alt="" />'.
00383                                                                         t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,1).
00384                                                                         '</a><br />';
00385                                                         } else {
00386                                                                 $code.= t3lib_iconWorks::getIconImage('pages',$pidPageInfo,$BACK_PATH,'').
00387                                                                         t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,1).
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                                                 // CSH for move-content-elements:
00397                                         $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_cs', $GLOBALS['BACK_PATH'],'<br/>|');
00398                                 }
00399                         }
00400 
00401                                 // IF a return-url is given, print the go-back link:
00402                         if ($this->R_URI)       {
00403                                 $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>';
00404                         }
00405 
00406                                 // Add the $code content as a new section to the module:
00407                         $this->content.=$this->doc->section($LANG->getLL('selectPositionOfElement').':',$code,0,1);
00408                 }
00409         }
00410 
00416         function printContent() {
00417                 global $SOBE;
00418 
00419                 $this->content.= $this->doc->endPage();
00420                 echo $this->content;
00421         }
00422 }
00423 
00424 // Include extension?
00425 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/move_el.php'])       {
00426         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/move_el.php']);
00427 }
00428 
00429 
00430 
00431 
00432 
00433 
00434 
00435 
00436 
00437 
00438 
00439 
00440 // Make instance:
00441 $SOBE = t3lib_div::makeInstance('SC_move_el');
00442 $SOBE->init();
00443 $SOBE->main();
00444 $SOBE->printContent();
00445 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6