Documentation TYPO3 par Ameos

class.t3lib_positionmap.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 ***************************************************************/
00085 class t3lib_positionMap {
00086 
00087                 // EXTERNAL, static:
00088         var $moveOrCopy='move';
00089         var $dontPrintPageInsertIcons=0;
00090         var $backPath='';
00091         var $depth=2;           // How deep the position page tree will go.
00092         var $cur_sys_language;  // Can be set to the sys_language uid to select content elements for.
00093 
00094 
00095                 // INTERNAL, dynamic:
00096         var $R_URI='';                  // Request uri
00097         var $elUid='';                  // Element id.
00098         var $moveUid='';                // tt_content element uid to move.
00099 
00100                 // Caching arrays:
00101         var $getModConfigCache=array();
00102         var $checkNewPageCache=Array();
00103 
00104                 // Label keys:
00105         var $l_insertNewPageHere = 'insertNewPageHere';
00106         var $l_insertNewRecordHere = 'insertNewRecordHere';
00107 
00108         var $modConfigStr='mod.web_list.newPageWiz';
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116         /*************************************
00117          *
00118          * Page position map:
00119          *
00120          **************************************/
00121 
00132         function positionTree($id,$pageinfo,$perms_clause,$R_URI)       {
00133                 global $LANG, $BE_USER;
00134 
00135                         // Make page tree object:
00136                 $t3lib_pageTree = t3lib_div::makeInstance('localPageTree');
00137                 $t3lib_pageTree->init(' AND '.$perms_clause);
00138                 $t3lib_pageTree->addField('pid');
00139 
00140                         // Initialize variables:
00141                 $this->R_URI = $R_URI;
00142                 $this->elUid = $id;
00143 
00144                         // Create page tree, in $this->depth levels.
00145                 $t3lib_pageTree->getTree($pageinfo['pid'], $this->depth);
00146                 if (!$this->dontPrintPageInsertIcons)   $code.=$this->JSimgFunc();
00147 
00148                         // Initialize variables:
00149                 $saveBlankLineState=array();
00150                 $saveLatestUid=array();
00151                 $latestInvDepth=$this->depth;
00152 
00153                         // Traverse the tree:
00154                 foreach($t3lib_pageTree->tree as $cc => $dat)   {
00155 
00156                                 // Make link + parameters.
00157                         $latestInvDepth=$dat['invertedDepth'];
00158                         $saveLatestUid[$latestInvDepth]=$dat;
00159                         if (isset($t3lib_pageTree->tree[$cc-1]))        {
00160                                 $prev_dat = $t3lib_pageTree->tree[$cc-1];
00161 
00162                                         // If current page, subpage?
00163                                 if ($prev_dat['row']['uid']==$id)       {
00164                                         if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id) && !($prev_dat['invertedDepth']>$t3lib_pageTree->tree[$cc]['invertedDepth']))     {       // 1) It must be allowed to create a new page and 2) If there are subpages there is no need to render a subpage icon here - it'll be done over the subpages...
00165                                                 $code.='<span class="nobr">'.
00166                                                         $this->insertQuadLines($dat['blankLineCode']).
00167                                                         '<img src="clear.gif" width="18" height="8" align="top" alt="" />'.
00168                                                         '<a href="#" onclick="'.htmlspecialchars($this->onClickEvent($id,$id,1)).'" onmouseover="'.htmlspecialchars('changeImg(\'mImgSubpage'.$cc.'\',0);').'" onmouseout="'.htmlspecialchars('changeImg(\'mImgSubpage'.$cc.'\',1);').'">'.
00169                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord_marker_d.gif','width="281" height="8"').' name="mImgSubpage'.$cc.'" border="0" align="top" title="'.$this->insertlabel().'" alt="" />'.
00170                                                         '</a></span><br />';
00171                                         }
00172                                 }
00173 
00174                                 if ($prev_dat['invertedDepth']>$t3lib_pageTree->tree[$cc]['invertedDepth'])     {       // If going down
00175                                         $prevPid = $t3lib_pageTree->tree[$cc]['row']['pid'];
00176                                 } elseif ($prev_dat['invertedDepth']<$t3lib_pageTree->tree[$cc]['invertedDepth'])       {               // If going up
00177                                         // First of all the previous level should have an icon:
00178                                         if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($prev_dat['row']['pid']))      {
00179                                                 $prevPid = (-$prev_dat['row']['uid']);
00180                                                 $code.='<span class="nobr">'.
00181                                                         $this->insertQuadLines($dat['blankLineCode']).
00182                                                         '<img src="clear.gif" width="18" height="1" align="top" alt="" />'.
00183                                                         '<a href="#" onclick="'.htmlspecialchars($this->onClickEvent($prevPid,$prev_dat['row']['pid'],2)).'" onmouseover="'.htmlspecialchars('changeImg(\'mImgAfter'.$cc.'\',0);').'" onmouseout="'.htmlspecialchars('changeImg(\'mImgAfter'.$cc.'\',1);').'">'.
00184                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord_marker_d.gif','width="281" height="8"').' name="mImgAfter'.$cc.'" border="0" align="top" title="'.$this->insertlabel().'" alt="" />'.
00185                                                         '</a></span><br />';
00186                                         }
00187 
00188                                         // Then set the current prevPid
00189                                         $prevPid = -$prev_dat['row']['pid'];
00190                                 } else {
00191                                         $prevPid = -$prev_dat['row']['uid'];    // In on the same level
00192                                 }
00193                         } else {
00194                                 $prevPid = $dat['row']['pid'];  // First in the tree
00195                         }
00196                         if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid']))   {
00197                                 $code.='<span class="nobr">'.
00198                                         $this->insertQuadLines($dat['blankLineCode']).
00199                                         '<a href="#" onclick="'.htmlspecialchars($this->onClickEvent($prevPid,$dat['row']['pid'],3)).'" onmouseover="'.htmlspecialchars('changeImg(\'mImg'.$cc.'\',0);').'" onmouseout="'.htmlspecialchars('changeImg(\'mImg'.$cc.'\',1);').'">'.
00200                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord_marker_d.gif','width="281" height="8"').' name="mImg'.$cc.'" border="0" align="top" title="'.$this->insertlabel().'" alt="" />'.
00201                                         '</a></span><br />';
00202                         }
00203 
00204                                 // The line with the icon and title:
00205                         $t_code='<span class="nobr">'.
00206                                 $dat['HTML'].
00207                                 $this->linkPageTitle($this->boldTitle(htmlspecialchars(t3lib_div::fixed_lgd_cs($dat['row']['title'],$BE_USER->uc['titleLen'])),$dat,$id),$dat['row']).
00208                                 '</span><br />';
00209                         $code.=$t_code;
00210                 }
00211 
00212                         // If the current page was the last in the tree:
00213                 $prev_dat = end($t3lib_pageTree->tree);
00214                 if ($prev_dat['row']['uid']==$id)       {
00215                         if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id))  {
00216                                 $code.='<span class="nobr">'.
00217                                         $this->insertQuadLines($saveLatestUid[$latestInvDepth]['blankLineCode'],1).
00218                                         '<img src="clear.gif" width="18" height="8" align="top" alt="" />'.
00219                                         '<a href="#" onclick="'.$this->onClickEvent($id,$id,4).'" onmouseover="'.htmlspecialchars('changeImg(\'mImgSubpage'.$cc.'\',0);').'" onmouseout="'.htmlspecialchars('changeImg(\'mImgSubpage'.$cc.'\',1);').'">'.
00220                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord_marker_d.gif','width="281" height="8"').' name="mImgSubpage'.$cc.'" border="0" align="top" title="'.$this->insertlabel().'" alt="" />'.
00221                                         '</a></span><br />';
00222                         }
00223                 }
00224 
00225                 for ($a=$latestInvDepth;$a<=$this->depth;$a++)  {
00226                         $dat = $saveLatestUid[$a];
00227                         $prevPid = (-$dat['row']['uid']);
00228                         if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid']))   {
00229                                 $code.='<span class="nobr">'.
00230                                         $this->insertQuadLines($dat['blankLineCode'],1).
00231                                         '<a href="#" onclick="'.htmlspecialchars($this->onClickEvent($prevPid,$dat['row']['pid'],5)).'" onmouseover="'.htmlspecialchars('changeImg(\'mImgEnd'.$a.'\',0);').'" onmouseout="'.htmlspecialchars('changeImg(\'mImgEnd'.$a.'\',1);').'">'.
00232                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord_marker_d.gif','width="281" height="8"').' name="mImgEnd'.$a.'" border="0" align="top" title="'.$this->insertlabel().'" alt="" />'.
00233                                         '</a></span><br />';
00234                         }
00235                 }
00236 
00237                 return $code;
00238         }
00239 
00246         function JSimgFunc($prefix='')  {
00247                 $code.=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
00248 
00249                         var img_newrecord_marker=new Image();
00250                         img_newrecord_marker.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord'.$prefix.'_marker.gif','',1).'";
00251 
00252                         var img_newrecord_marker_d=new Image();
00253                         img_newrecord_marker_d.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord'.$prefix.'_marker_d.gif','',1).'";
00254 
00255                         function changeImg(name,d)      {       //
00256                                 if (document[name]) {
00257                                         if (d)  {
00258                                                 document[name].src = img_newrecord_marker_d.src;
00259                                         } else {
00260                                                 document[name].src = img_newrecord_marker.src;
00261                                         }
00262                                 }
00263                         }
00264                 ');
00265                 return $code;
00266         }
00267 
00276         function boldTitle($t_code,$dat,$id)    {
00277                 if ($dat['row']['uid']==$id)    {
00278                         $t_code='<strong>'.$t_code.'</strong>';
00279                 }
00280                 return $t_code;
00281         }
00282 
00293         function onClickEvent($pid,$newPagePID) {
00294                 $TSconfigProp = $this->getModConfig($newPagePID);
00295 
00296                 if ($TSconfigProp['overrideWithExtension'])     {
00297                         if (t3lib_extMgm::isLoaded($TSconfigProp['overrideWithExtension']))     {
00298                                 $onclick = "document.location='".t3lib_extMgm::extRelPath($TSconfigProp['overrideWithExtension']).'mod1/index.php?cmd=crPage&positionPid='.$pid."';";
00299                                 return $onclick;
00300                         }
00301                 }
00302 
00303                 $params='&edit[pages]['.$pid.']=new&returnNewPageId=1';
00304                 return t3lib_BEfunc::editOnClick($params,'',$this->R_URI);
00305         }
00306 
00312         function insertlabel()  {
00313                 global $LANG;
00314                 return $LANG->getLL($this->l_insertNewPageHere,1);
00315         }
00316 
00324         function linkPageTitle($str,$rec)       {
00325                 return $str;
00326         }
00327 
00335         function checkNewPageInPid($pid)        {
00336                 global $BE_USER;
00337                 if (!isset($this->checkNewPageCache[$pid]))     {
00338                         $pidInfo = t3lib_BEfunc::getRecord('pages',$pid);
00339                         $this->checkNewPageCache[$pid] = ($BE_USER->isAdmin() || $BE_USER->doesUserHaveAccess($pidInfo,8));
00340                 }
00341                 return $this->checkNewPageCache[$pid];
00342         }
00343 
00351         function getModConfig($pid)     {
00352                 if (!isset($this->getModConfigCache[$pid]))     {
00353                                 // Acquiring TSconfig for this PID:
00354                         $this->getModConfigCache[$pid] = t3lib_BEfunc::getModTSconfig($pid,$this->modConfigStr);
00355                 }
00356                 return $this->getModConfigCache[$pid]['properties'];
00357         }
00358 
00366         function insertQuadLines($codes,$allBlank=0)    {
00367                 $codeA = t3lib_div::trimExplode(',',$codes.",line",1);
00368 
00369                 $lines=array();
00370                 while(list(,$code)=each($codeA))        {
00371                         if ($code=="blank" || $allBlank)        {
00372                                 $lines[]='<img src="clear.gif" width="18" height="8" align="top" alt="" />';
00373                         } else {
00374                                 $lines[]='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/halfline.gif','width="18" height="8"').' align="top" alt="" />';
00375                         }
00376                 }
00377                 return implode('',$lines);
00378         }
00379 
00380 
00381 
00382 
00383 
00384 
00385 
00386 
00387 
00388         /*************************************
00389          *
00390          * Content element positioning:
00391          *
00392          **************************************/
00393 
00404         function printContentElementColumns($pid,$moveUid,$colPosList,$showHidden,$R_URI)       {
00405                 $this->R_URI = $R_URI;
00406                 $this->moveUid = $moveUid;
00407                 $colPosArray = t3lib_div::trimExplode(',',$colPosList,1);
00408 
00409                 $lines=array();
00410                 while(list($kk,$vv)=each($colPosArray)) {
00411                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00412                                                         '*',
00413                                                         'tt_content',
00414                                                         'pid='.intval($pid).
00415                                                                 ($showHidden ? '' : t3lib_BEfunc::BEenableFields('tt_content')).
00416                                                                 ' AND colPos='.intval($vv).
00417                                                                 (strcmp($this->cur_sys_language,'') ? ' AND sys_language_uid='.intval($this->cur_sys_language) : '').
00418                                                                 t3lib_BEfunc::deleteClause('tt_content'),
00419                                                         '',
00420                                                         'sorting'
00421                                                 );
00422                         $lines[$kk]=array();
00423                         $lines[$kk][]=$this->insertPositionIcon('',$vv,$kk,$moveUid,$pid);
00424                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))               {
00425                                 $lines[$kk][]=$this->wrapRecordHeader($this->getRecordHeader($row),$row);
00426                                 $lines[$kk][]=$this->insertPositionIcon($row,$vv,$kk,$moveUid,$pid);
00427                         }
00428                         $GLOBALS['TYPO3_DB']->sql_free_result($res);
00429                 }
00430                 return $this->printRecordMap($lines,$colPosArray);
00431         }
00432 
00440         function printRecordMap($lines,$colPosArray)    {
00441                 $row1='';
00442                 $row2='';
00443                 $count = t3lib_div::intInRange(count($colPosArray),1);
00444 
00445                         // Traverse the columns here:
00446                 foreach($colPosArray as $kk => $vv)     {
00447                         $row1.='<td align="center" width="'.round(100/$count).'%"><span class="uppercase"><strong>'.
00448                                         $this->wrapColumnHeader($GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','colPos',$vv),1),$vv).
00449                                         '</strong></span></td>';
00450                         $row2.='<td valign="top" nowrap="nowrap">'.
00451                                         implode('<br />',$lines[$kk]).
00452                                         '</td>';
00453                 }
00454 
00455                 $table = '
00456 
00457                 <!--
00458                         Map of records in columns:
00459                 -->
00460                 <table border="0" cellpadding="0" cellspacing="1" id="typo3-ttContentList">
00461                         <tr class="bgColor5">'.$row1.'</tr>
00462                         <tr>'.$row2.'</tr>
00463                 </table>
00464 
00465                 ';
00466 
00467                 return $this->JSimgFunc('2').$table;
00468         }
00469 
00478         function wrapColumnHeader($str,$vv)     {
00479                 return $str;
00480         }
00481 
00492         function insertPositionIcon($row,$vv,$kk,$moveUid,$pid) {
00493                 $cc = hexdec(substr(md5($row['uid'].'-'.$vv.'-'.$kk),0,4));
00494                 return '<a href="#" onclick="'.htmlspecialchars($this->onClickInsertRecord($row,$vv,$moveUid,$pid,$this->cur_sys_language)).'" onmouseover="'.htmlspecialchars('changeImg(\'mImg'.$cc.'\',0);').'" onmouseout="'.htmlspecialchars('changeImg(\'mImg'.$cc.'\',1);').'">'.
00495                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord2_marker_d.gif','width="100" height="8"').' name="mImg'.$cc.'" border="0" align="top" title="'.$GLOBALS['LANG']->getLL($this->l_insertNewRecordHere,1).'" alt="" />'.
00496                         '</a>';
00497         }
00498 
00509         function onClickInsertRecord($row,$vv,$moveUid,$pid,$sys_lang=0) {
00510                 $table='tt_content';
00511                 if (is_array($row))     {
00512                         $location='tce_db.php?cmd['.$table.']['.$moveUid.']['.$this->moveOrCopy.']=-'.$row['uid'].'&prErr=1&uPT=1&vC='.$GLOBALS['BE_USER']->veriCode();
00513                 } else {
00514                         $location='tce_db.php?cmd['.$table.']['.$moveUid.']['.$this->moveOrCopy.']='.$pid.'&data['.$table.']['.$moveUid.'][colPos]='.$vv.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode();
00515                 }
00516 //              $location.='&redirect='.rawurlencode($this->R_URI);             // returns to prev. page
00517                 $location.='&uPT=1&redirect='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));               // This redraws screen
00518 
00519                 return 'document.location=\''.$location.'\';return false;';
00520         }
00521 
00529         function wrapRecordHeader($str,$row)    {
00530                 return $str;
00531         }
00532 
00539         function getRecordHeader($row)  {
00540                 $line = t3lib_iconWorks::getIconImage('tt_content',$row,$this->backPath,' align="top" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($row,'tt_content')).'"');
00541                 $line.= t3lib_BEfunc::getRecordTitle('tt_content',$row,1);
00542                 return $this->wrapRecordTitle($line,$row);
00543         }
00544 
00552         function wrapRecordTitle($str,$row)     {
00553                 return '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('uid'=>intval($row['uid']),'moveUid'=>''))).'">'.$str.'</a>';
00554         }
00555 }
00556 
00557 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_positionmap.php'])       {
00558         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_positionmap.php']);
00559 }
00560 ?>


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