Documentation TYPO3 par Ameos

class.t3lib_softrefproc.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2003-2006 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 *
00017 *  This script is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00097 require_once(PATH_t3lib.'class.t3lib_parsehtml.php');
00098 
00116 class t3lib_softrefproc {
00117 
00118                 // external configuration
00119         var $fileAdminDir = 'fileadmin';
00120 
00121 
00122                 // Internal:
00123         var $tokenID_basePrefix = '';
00124 
00137         function findRef($table, $field, $uid, $content, $spKey, $spParams, $structurePath='')  {
00138 
00139                 $retVal = FALSE;
00140 
00141                 $this->tokenID_basePrefix = $table.':'.$uid.':'.$field.':'.$structurePath.':'.$spKey;
00142 
00143                 switch($spKey)  {
00144                         case 'notify':  // Simple notification
00145                                 $resultArray = array(
00146                                         'elements' => array(
00147                                                 array(
00148                                                         'matchString' => $content
00149                                                 )
00150                                         )
00151                                 );
00152                                 $retVal = $resultArray;
00153                         break;
00154                         case 'substitute':
00155                                 $tokenID = $this->makeTokenID();
00156                                 $resultArray = array(
00157                                         'content' => '{softref:'.$tokenID.'}',
00158                                         'elements' => array(
00159                                                 array(
00160                                                         'matchString' => $content,
00161                                                         'subst' => array(
00162                                                                 'type' => 'string',
00163                                                                 'tokenID' => $tokenID,
00164                                                                 'tokenValue' => $content
00165                                                         )
00166                                                 )
00167                                         )
00168                                 );
00169                                 $retVal = $resultArray;
00170                         break;
00171                         case 'images':
00172                                 $retVal = $this->findRef_images($content, $spParams);
00173                         break;
00174                         case 'typolink':
00175                                 $retVal = $this->findRef_typolink($content, $spParams);
00176                         break;
00177                         case 'typolink_tag':
00178                                 $retVal = $this->findRef_typolink_tag($content, $spParams);
00179                         break;
00180                         case 'ext_fileref':
00181                                 $retVal = $this->findRef_extension_fileref($content, $spParams);
00182                         break;
00183                         case 'TStemplate':
00184                                 $retVal = $this->findRef_TStemplate($content, $spParams);
00185                         break;
00186                         case 'TSconfig':
00187                                 $retVal = $this->findRef_TSconfig($content, $spParams);
00188                         break;
00189                         case 'email':
00190                                 $retVal = $this->findRef_email($content, $spParams);
00191                         break;
00192                         case 'url':
00193                                 $retVal = $this->findRef_url($content, $spParams);
00194                         break;
00195                         default:
00196                                 $retVal = FALSE;
00197                         break;
00198                 }
00199 
00200                 return $retVal;
00201         }
00202 
00213         function findRef_images($content, $spParams)    {
00214 
00215                         // Start HTML parser and split content by image tag:
00216                 $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
00217                 $splitContent = $htmlParser->splitTags('img',$content);
00218                 $elements = array();
00219 
00220                         // Traverse splitted parts:
00221                 foreach($splitContent as $k => $v)      {
00222                         if ($k%2)       {
00223 
00224                                         // Get file reference:
00225                                 $attribs = $htmlParser->get_tag_attributes($v);
00226                                 $srcRef = t3lib_div::htmlspecialchars_decode($attribs[0]['src']);
00227                                 $pI = pathinfo($srcRef);
00228 
00229                                         // If it looks like a local image, continue. Otherwise ignore it.
00230                                 $absPath = t3lib_div::getFileAbsFileName(PATH_site.$srcRef);
00231                                 if (!$pI['scheme'] && !$pI['query'] && $absPath && $srcRef!=='clear.gif')       {
00232 
00233                                                 // Initialize the element entry with info text here:
00234                                         $tokenID = $this->makeTokenID($k);
00235                                         $elements[$k] = array();
00236                                         $elements[$k]['matchString'] = $v;
00237 
00238                                                 // If the image seems to be from fileadmin/ folder or an RTE image, then proceed to set up substitution token:
00239                                         if (t3lib_div::isFirstPartOfStr($srcRef,$this->fileAdminDir.'/') || (t3lib_div::isFirstPartOfStr($srcRef,'uploads/') && ereg('^RTEmagicC_',basename($srcRef)))) {
00240                                                         // Token and substitute value:
00241                                                 if (strstr($splitContent[$k], $attribs[0]['src']))      {       // Make sure the value we work on is found and will get substituted in the content (Very important that the src-value is not DeHSC'ed)
00242                                                         $splitContent[$k] = str_replace($attribs[0]['src'], '{softref:'.$tokenID.'}', $splitContent[$k]);       // Substitute value with token (this is not be an exact method if the value is in there twice, but we assume it will not)
00243                                                         $elements[$k]['subst'] = array(
00244                                                                 'type' => 'file',
00245                                                                 'relFileName' => $srcRef,
00246                                                                 'tokenID' => $tokenID,
00247                                                                 'tokenValue' => $attribs[0]['src'],
00248                                                         );
00249                                                         if (!@is_file($absPath))        {       // Finally, notice if the file does not exist.
00250                                                                 $elements[$k]['error'] = 'File does not exist!';
00251                                                         }
00252                                                 } else {
00253                                                         $elements[$k]['error'] = 'Could not substitute image source with token!';
00254                                                 }
00255                                         }
00256                                 }
00257                         }
00258                 }
00259 
00260                         // Return result:
00261                 if (count($elements))   {
00262                         $resultArray = array(
00263                                 'content' => implode('', $splitContent),
00264                                 'elements' => $elements
00265                         );
00266 
00267                         return $resultArray;
00268                 }
00269         }
00270 
00280         function findRef_typolink($content, $spParams)  {
00281 
00282                         // First, split the input string by a comma if the "linkList" parameter is set.
00283                         // An example: the link field for images in content elements of type "textpic" or "image". This field CAN be configured to define a link per image, separated by comma.
00284                 if (is_array($spParams) && in_array('linkList',$spParams))      {
00285                         $linkElement = explode(',', $content);  // Preserving whitespace on purpose.
00286                 } else {
00287                         $linkElement = array($content); // If only one element, just set in this array to make it easy below.
00288                 }
00289 
00290                         // Traverse the links now:
00291                 $elements = array();
00292                 foreach($linkElement as $k => $typolinkValue)   {
00293                         $tLP = $this->getTypoLinkParts($typolinkValue);
00294                         $linkElement[$k] = $this->setTypoLinkPartsElement($tLP, $elements, $typolinkValue, $k);
00295                 }
00296 
00297                         // Return output:
00298                 if (count($elements))   {
00299                         $resultArray = array(
00300                                 'content' => implode(',', $linkElement),
00301                                 'elements' => $elements
00302                         );
00303 
00304                         return $resultArray;
00305                 }
00306         }
00307 
00317         function findRef_typolink_tag($content, $spParams)      {
00318 
00319                         // Parse string for special TYPO3 <link> tag:
00320                 $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
00321                 $linkTags = $htmlParser->splitTags('link',$content);
00322 
00323                         // Traverse result:
00324                 $elements = array();
00325                 foreach($linkTags as $k => $foundValue) {
00326                         if ($k%2)       {
00327                                 $typolinkValue = eregi_replace('<LINK[[:space:]]+','',substr($foundValue,0,-1));
00328                                 $tLP = $this->getTypoLinkParts($typolinkValue);
00329                                 $linkTags[$k] = '<LINK '.$this->setTypoLinkPartsElement($tLP, $elements, $typolinkValue, $k).'>';
00330                         }
00331                 }
00332 
00333                         // Return output:
00334                 if (count($elements))   {
00335                         $resultArray = array(
00336                                 'content' => implode('', $linkTags),
00337                                 'elements' => $elements
00338                         );
00339 
00340                         return $resultArray;
00341                 }
00342         }
00343 
00352         function findRef_TStemplate($content, $spParams)        {
00353                 $elements = array();
00354 
00355                         // First, try to find images and links:
00356                 $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
00357                 $splitContent = $htmlParser->splitTags('img,a,form', $content);
00358 
00359                         // Traverse splitted parts:
00360                 foreach($splitContent as $k => $v)      {
00361                         if ($k%2)       {
00362 
00363                                 $attribs = $htmlParser->get_tag_attributes($v);
00364 
00365                                 $attributeName = '';
00366                                 switch($htmlParser->getFirstTagName($v))        {
00367                                         case 'img':
00368                                                 $attributeName = 'src';
00369                                         break;
00370                                         case 'a':
00371                                                 $attributeName = 'href';
00372                                         break;
00373                                         case 'form':
00374                                                 $attributeName = 'action';
00375                                         break;
00376                                 }
00377 
00378                                         // Get file reference:
00379                                 if (isset($attribs[0][$attributeName])) {
00380                                         $srcRef = t3lib_div::htmlspecialchars_decode($attribs[0][$attributeName]);
00381 
00382                                                 // Set entry:
00383                                         $tokenID = $this->makeTokenID($k);
00384                                         $elements[$k] = array();
00385                                         $elements[$k]['matchString'] = $v;
00386 
00387                                                 // OK, if it looks like a local file from fileadmin/, include it:
00388                                         $pI = pathinfo($srcRef);
00389                                         $absPath = t3lib_div::getFileAbsFileName(PATH_site.$srcRef);
00390                                         if (t3lib_div::isFirstPartOfStr($srcRef,$this->fileAdminDir.'/') && !$pI['query'] && $absPath)  {
00391 
00392                                                         // Token and substitute value:
00393                                                 if (strstr($splitContent[$k], $attribs[0][$attributeName]))     {       // Very important that the src-value is not DeHSC'ed
00394                                                         $splitContent[$k] = str_replace($attribs[0][$attributeName], '{softref:'.$tokenID.'}', $splitContent[$k]);
00395                                                         $elements[$k]['subst'] = array(
00396                                                                 'type' => 'file',
00397                                                                 'relFileName' => $srcRef,
00398                                                                 'tokenID' => $tokenID,
00399                                                                 'tokenValue' => $attribs[0][$attributeName],
00400                                                         );
00401                                                         if (!@is_file($absPath))        {
00402                                                                 $elements[$k]['error'] = 'File does not exist!';
00403                                                         }
00404                                                 } else {
00405                                                         $elements[$k]['error'] = 'Could not substitute attribute ('.$attributeName.') value with token!';
00406                                                 }
00407                                         }
00408                                 }
00409                         }
00410                 }
00411                 $content = implode('', $splitContent);
00412 
00413                         // Process free fileadmin/ references as well:
00414                 $content = $this->fileadminReferences($content, $elements);
00415 
00416                         // Return output:
00417                 if (count($elements))   {
00418                         $resultArray = array(
00419                                 'content' => $content,
00420                                 'elements' => $elements
00421                         );
00422                         return $resultArray;
00423                 }
00424         }
00425 
00434         function findRef_TSconfig($content, $spParams)  {
00435                 $elements = array();
00436 
00437                         // Process free fileadmin/ references from TSconfig
00438                 $content = $this->fileadminReferences($content, $elements);
00439 
00440                         // Return output:
00441                 if (count($elements))   {
00442                         $resultArray = array(
00443                                 'content' => $content,
00444                                 'elements' => $elements
00445                         );
00446                         return $resultArray;
00447                 }
00448         }
00449 
00457         function findRef_email($content, $spParams)     {
00458                 $resultArray = array();
00459 
00460                         // email:
00461                 $parts = preg_split("/([^[:alnum:]]+)([A-Za-z0-9\._-]+[@][A-Za-z0-9\._-]+[\.].[A-Za-z0-9]+)/", ' '.$content.' ',10000, PREG_SPLIT_DELIM_CAPTURE);
00462                 foreach($parts as $idx => $value)       {
00463                         if ($idx%3 == 2)        {
00464 
00465                                 $tokenID = $this->makeTokenID($idx);
00466                                 $elements[$idx] = array();
00467                                 $elements[$idx]['matchString'] = $value;
00468 
00469                                 if (is_array($spParams) && in_array('subst',$spParams)) {
00470                                         $parts[$idx] = '{softref:'.$tokenID.'}';
00471                                         $elements[$idx]['subst'] = array(
00472                                                 'type' => 'string',
00473                                                 'tokenID' => $tokenID,
00474                                                 'tokenValue' => $value,
00475                                         );
00476                                 }
00477                         }
00478                 }
00479 
00480                         // Return output:
00481                 if (count($elements))   {
00482                         $resultArray = array(
00483                                 'content' => substr(implode('',$parts),1,-1),
00484                                 'elements' => $elements
00485                         );
00486                         return $resultArray;
00487                 }
00488         }
00489 
00497         function findRef_url($content, $spParams)       {
00498                 $resultArray = array();
00499 
00500                         // Fileadmin files:
00501                 $parts = preg_split("/([^[:alnum:]\"']+)((http|ftp):\/\/[^[:space:]\"'<>]*)([[:space:]])/", ' '.$content.' ',10000, PREG_SPLIT_DELIM_CAPTURE);
00502 
00503                 foreach($parts as $idx => $value)       {
00504                         if ($idx%5 == 3)        { unset($parts[$idx]); }
00505                         if ($idx%5 == 2)        {
00506 
00507                                 $tokenID = $this->makeTokenID($idx);
00508                                 $elements[$idx] = array();
00509                                 $elements[$idx]['matchString'] = $value;
00510 
00511                                 if (is_array($spParams) && in_array('subst',$spParams)) {
00512                                         $parts[$idx] = '{softref:'.$tokenID.'}';
00513                                         $elements[$idx]['subst'] = array(
00514                                                 'type' => 'string',
00515                                                 'tokenID' => $tokenID,
00516                                                 'tokenValue' => $value,
00517                                         );
00518                                 }
00519                         }
00520                 }
00521 
00522                         // Return output:
00523                 if (count($elements))   {
00524                         $resultArray = array(
00525                                 'content' => substr(implode('',$parts),1,-1),
00526                                 'elements' => $elements
00527                         );
00528                         return $resultArray;
00529                 }
00530         }
00531 
00539         function findRef_extension_fileref($content, $spParams) {
00540                 $resultArray = array();
00541 
00542                         // Fileadmin files:
00543                 $parts = preg_split("/([^[:alnum:]\"']+)(EXT:[[:alnum:]_]+\/[^[:space:]\"',]*)/", ' '.$content.' ',10000, PREG_SPLIT_DELIM_CAPTURE);
00544 
00545                 foreach($parts as $idx => $value)       {
00546                         if ($idx%3 == 2)        {
00547 
00548                                 $tokenID = $this->makeTokenID($idx);
00549                                 $elements[$idx] = array();
00550                                 $elements[$idx]['matchString'] = $value;
00551                         }
00552                 }
00553 
00554                         // Return output:
00555                 if (count($elements))   {
00556                         $resultArray = array(
00557                                 'content' => substr(implode('',$parts),1,-1),
00558                                 'elements' => $elements
00559                         );
00560                         return $resultArray;
00561                 }
00562         }
00563 
00564 
00565 
00566 
00567 
00568 
00569 
00570 
00571 
00572 
00573 
00574 
00575 
00576 
00577         /*************************
00578          *
00579          * Helper functions
00580          *
00581          *************************/
00582 
00591         function fileadminReferences($content, &$elements)      {
00592 
00593                         // Fileadmin files are found
00594                 $parts = preg_split("/([^[:alnum:]]+)(".$this->fileAdminDir."\/[^[:space:]\"'<>]*)/", ' '.$content.' ',10000, PREG_SPLIT_DELIM_CAPTURE);
00595 
00596                         // Traverse files:
00597                 foreach($parts as $idx => $value)       {
00598                         if ($idx%3 == 2)        {
00599 
00600                                         // when file is found, set up an entry for the element:
00601                                 $tokenID = $this->makeTokenID('fileadminReferences:'.$idx);
00602                                 $elements['fileadminReferences.'.$idx] = array();
00603                                 $elements['fileadminReferences.'.$idx]['matchString'] = $value;
00604                                 $elements['fileadminReferences.'.$idx]['subst'] = array(
00605                                         'type' => 'file',
00606                                         'relFileName' => $value,
00607                                         'tokenID' => $tokenID,
00608                                         'tokenValue' => $value,
00609                                 );
00610                                 $parts[$idx] = '{softref:'.$tokenID.'}';
00611 
00612                                         // Check if the file actually exists:
00613                                 $absPath = t3lib_div::getFileAbsFileName(PATH_site.$value);
00614                                 if (!@is_file($absPath))        {
00615                                         $elements['fileadminReferences.'.$idx]['error'] = 'File does not exist!';
00616                                 }
00617                         }
00618                 }
00619 #debug($parts);
00620                         // Implode the content again, removing prefixed and trailing white space:
00621                 return substr(implode('',$parts),1,-1);
00622         }
00623 
00634         function getTypoLinkParts($typolinkValue)       {
00635                 $finalTagParts = array();
00636 
00637                         // Split by space into link / target / class
00638                 list($link_param, $browserTarget, $cssClass) = t3lib_div::trimExplode(' ',$typolinkValue,1);
00639                 if (strlen($browserTarget))     $finalTagParts['target'] = $browserTarget;
00640                 if (strlen($cssClass))  $finalTagParts['class'] = $cssClass;
00641 
00642                         // Parse URL:
00643                 $pU = parse_url($link_param);
00644 
00645                         // Detecting the kind of reference:
00646                 if(strstr($link_param,'@') && !$pU['scheme'])   {               // If it's a mail address:
00647                         $link_param = eregi_replace('^mailto:','',$link_param);
00648 
00649                         $finalTagParts['LINK_TYPE'] = 'mailto';
00650                         $finalTagParts['url'] = trim($link_param);
00651                 } else {
00652                         $isLocalFile = 0;
00653                         $fileChar = intval(strpos($link_param, '/'));
00654                         $urlChar = intval(strpos($link_param, '.'));
00655 
00656                                 // Detects if a file is found in site-root (or is a 'virtual' simulateStaticDocument file!) and if so it will be treated like a normal file.
00657                         list($rootFileDat) = explode('?',rawurldecode($link_param));
00658                         $containsSlash = strstr($rootFileDat,'/');
00659                         $rFD_fI = pathinfo($rootFileDat);
00660                         if (trim($rootFileDat) && !$containsSlash && (@is_file(PATH_site.$rootFileDat) || t3lib_div::inList('php,html,htm',strtolower($rFD_fI['extension']))))  {
00661                                 $isLocalFile = 1;
00662                         } elseif ($containsSlash)       {
00663                                 $isLocalFile = 2;               // Adding this so realurl directories are linked right (non-existing).
00664                         }
00665 
00666                         if($pU['scheme'] || ($isLocalFile!=1 && $urlChar && (!$containsSlash || $urlChar<$fileChar)))   {       // url (external): If doubleSlash or if a '.' comes before a '/'.
00667                                 $finalTagParts['LINK_TYPE'] = 'url';
00668                                 $finalTagParts['url'] = $link_param;
00669                         } elseif ($containsSlash || $isLocalFile)       {       // file (internal)
00670                                 $splitLinkParam = explode('?', $link_param);
00671                                 if (@file_exists(rawurldecode($splitLinkParam[0])) || $isLocalFile)     {
00672                                         $finalTagParts['LINK_TYPE'] = 'file';
00673                                         $finalTagParts['filepath'] = rawurldecode($splitLinkParam[0]);
00674                                         $finalTagParts['query'] = $splitLinkParam[1];
00675                                 }
00676                         } else {        // integer or alias (alias is without slashes or periods or commas, that is 'nospace,alphanum_x,lower,unique' according to definition in $TCA!)
00677                                 $finalTagParts['LINK_TYPE'] = 'page';
00678 
00679                                 $link_params_parts = explode('#',$link_param);
00680                                 $link_param = trim($link_params_parts[0]);              // Link-data del
00681 
00682                                 if (strlen($link_params_parts[1]))      {
00683                                         $finalTagParts['anchor'] = trim($link_params_parts[1]);
00684                                 }
00685 
00686                                         // Splitting the parameter by ',' and if the array counts more than 1 element it's a id/type/? pair
00687                                 $pairParts = t3lib_div::trimExplode(',',$link_param);
00688                                 if (count($pairParts)>1)        {
00689                                         $link_param = $pairParts[0];
00690                                         $finalTagParts['type'] = $pairParts[1];         // Overruling 'type'
00691                                 }
00692 
00693                                         // Checking if the id-parameter is an alias.
00694                                 if (strlen($link_param))        {
00695                                         if (!t3lib_div::testInt($link_param))   {
00696                                                 $finalTagParts['alias'] = $link_param;
00697                                                 $link_param = $this->getPageIdFromAlias($link_param);
00698                                         }
00699 
00700                                         $finalTagParts['page_id'] = intval($link_param);
00701                                 }
00702                         }
00703                 }
00704 
00705                 return $finalTagParts;
00706         }
00707 
00718         function setTypoLinkPartsElement($tLP, &$elements, $content, $idx)      {
00719 
00720                         // Initialize, set basic values. In any case a link will be shown
00721                 $tokenID = $this->makeTokenID('setTypoLinkPartsElement:'.$idx);
00722                 $elements[$tokenID.':'.$idx] = array();
00723                 $elements[$tokenID.':'.$idx]['matchString'] = $content;
00724 
00725                         // Based on link type, maybe do more:
00726                 switch ((string)$tLP['LINK_TYPE'])      {
00727                         case 'mailto':
00728                                         // Mail addresses can be substituted manually:
00729                                 $elements[$tokenID.':'.$idx]['subst'] = array(
00730                                         'type' => 'string',
00731                                         'tokenID' => $tokenID,
00732                                         'tokenValue' => $tLP['url'],
00733                                 );
00734                                         // Output content will be the token instead:
00735                                 $content = '{softref:'.$tokenID.'}';
00736                         break;
00737                         case 'url':
00738                                         // Nothing done, only for informational purposes. So return content right away:
00739                                 {
00740                                         return $content;
00741                                 }
00742                         break;
00743                         case 'file':
00744                                         // Process files found in fileadmin directory:
00745                                 if (!$tLP['query'])     {       // We will not process files which has a query added to it. That will look like a script we don't want to move.
00746                                         if (t3lib_div::isFirstPartOfStr($tLP['filepath'],$this->fileAdminDir.'/'))      {       // File must be inside fileadmin/
00747 
00748                                                         // Set up the basic token and token value for the relative file:
00749                                                 $elements[$tokenID.':'.$idx]['subst'] = array(
00750                                                         'type' => 'file',
00751                                                         'relFileName' => $tLP['filepath'],
00752                                                         'tokenID' => $tokenID,
00753                                                         'tokenValue' => $tLP['filepath'],
00754                                                 );
00755 
00756                                                         // Depending on whether the file exists or not we will set the
00757                                                 $absPath = t3lib_div::getFileAbsFileName(PATH_site.$tLP['filepath']);
00758                                                 if (!@is_file($absPath))        {
00759                                                         $elements[$tokenID.':'.$idx]['error'] = 'File does not exist!';
00760                                                 }
00761 
00762                                                         // Output content will be the token instead
00763                                                 $content = '{softref:'.$tokenID.'}';
00764                                         } else return $content;
00765                                 } else return $content;
00766                         break;
00767                         case 'page':
00768                                         // Rebuild page reference typolink part:
00769                                 $content = '';
00770 
00771                                         // Set page id:
00772                                 if ($tLP['page_id'])    {
00773                                         $content.= '{softref:'.$tokenID.'}';
00774                                         $elements[$tokenID.':'.$idx]['subst'] = array(
00775                                                 'type' => 'db',
00776                                                 'recordRef' => 'pages:'.$tLP['page_id'],
00777                                                 'tokenID' => $tokenID,
00778                                                 'tokenValue' => $tLP['alias'] ? $tLP['alias'] : $tLP['page_id'],        // Set page alias if that was used.
00779                                         );
00780                                 }
00781 
00782                                         // Add type if applicable
00783                                 if (strlen($tLP['type']))       {
00784                                         $content.= ','.$tLP['type'];
00785                                 }
00786 
00787                                         // Add anchor if applicable
00788                                 if (strlen($tLP['anchor']))     {
00789                                         if (t3lib_div::testInt($tLP['anchor'])) {       // Anchor is assumed to point to a content elements:
00790                                                         // Initialize a new entry because we have a new relation:
00791                                                 $newTokenID = $this->makeTokenID('setTypoLinkPartsElement:anchor:'.$idx);
00792                                                 $elements[$newTokenID.':'.$idx] = array();
00793                                                 $elements[$newTokenID.':'.$idx]['matchString'] = 'Anchor Content Element: '.$tLP['anchor'];
00794 
00795                                                 $content.= '#{softref:'.$newTokenID.'}';
00796                                                 $elements[$newTokenID.':'.$idx]['subst'] = array(
00797                                                         'type' => 'db',
00798                                                         'recordRef' => 'tt_content:'.$tLP['anchor'],
00799                                                         'tokenID' => $newTokenID,
00800                                                         'tokenValue' => $tLP['anchor'],
00801                                                 );
00802                                         } else {        // Anchor is a hardcoded string
00803                                                 $content.= '#'.$tLP['type'];
00804                                         }
00805                                 }
00806                         break;
00807                         default:
00808                                 {
00809                                         $elements[$tokenID.':'.$idx]['error'] = 'Couldn\t decide typolink mode.';
00810                                         return $content;
00811                                 }
00812                         break;
00813                 }
00814 
00815                         // Finally, for all entries that was rebuild with tokens, add target and class in the end:
00816                 if (strlen($content) && strlen($tLP['target'])) {
00817                         $content.= ' '.$tLP['target'];
00818                         if (strlen($tLP['class']))      {
00819                                 $content.= ' '.$tLP['class'];
00820                         }
00821                 }
00822 
00823                         // Return rebuilt typolink value:
00824                 return $content;
00825         }
00826 
00833         function getPageIdFromAlias($link_param)        {
00834                 $pRec = t3lib_BEfunc::getRecordsByField('pages','alias',$link_param);
00835 
00836                 return $pRec[0]['uid'];
00837         }
00838 
00845         function makeTokenID($index='') {
00846                 return md5($this->tokenID_basePrefix.':'.$index);
00847         }
00848 }
00849 
00850 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_softrefproc.php'])       {
00851         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_softrefproc.php']);
00852 }
00853 ?>


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