TYPO3 CMS  TYPO3_6-2
SoftReferenceIndex.php
Go to the documentation of this file.
1 <?php
3 
18 
75 
76  // External configuration
80  public $fileAdminDir = '';
81 
82  // Internal:
86  public $tokenID_basePrefix = '';
87 
92  public function __construct() {
93  $this->fileAdminDir = !empty($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']) ? rtrim($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') : 'fileadmin';
94  }
95 
109  public function findRef($table, $field, $uid, $content, $spKey, $spParams, $structurePath = '') {
110  $retVal = FALSE;
111  $this->tokenID_basePrefix = $table . ':' . $uid . ':' . $field . ':' . $structurePath . ':' . $spKey;
112  switch ($spKey) {
113  case 'notify':
114  // Simple notification
115  $resultArray = array(
116  'elements' => array(
117  array(
118  'matchString' => $content
119  )
120  )
121  );
122  $retVal = $resultArray;
123  break;
124  case 'substitute':
125  $tokenID = $this->makeTokenID();
126  $resultArray = array(
127  'content' => '{softref:' . $tokenID . '}',
128  'elements' => array(
129  array(
130  'matchString' => $content,
131  'subst' => array(
132  'type' => 'string',
133  'tokenID' => $tokenID,
134  'tokenValue' => $content
135  )
136  )
137  )
138  );
139  $retVal = $resultArray;
140  break;
141  case 'images':
142  $retVal = $this->findRef_images($content, $spParams);
143  break;
144  case 'typolink':
145  $retVal = $this->findRef_typolink($content, $spParams);
146  break;
147  case 'typolink_tag':
148  $retVal = $this->findRef_typolink_tag($content, $spParams);
149  break;
150  case 'ext_fileref':
151  $retVal = $this->findRef_extension_fileref($content, $spParams);
152  break;
153  case 'TStemplate':
154  $retVal = $this->findRef_TStemplate($content, $spParams);
155  break;
156  case 'TSconfig':
157  $retVal = $this->findRef_TSconfig($content, $spParams);
158  break;
159  case 'email':
160  $retVal = $this->findRef_email($content, $spParams);
161  break;
162  case 'url':
163  $retVal = $this->findRef_url($content, $spParams);
164  break;
165  default:
166  $retVal = FALSE;
167  }
168  return $retVal;
169  }
170 
182  public function findRef_images($content, $spParams) {
183  // Start HTML parser and split content by image tag:
184  $htmlParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\HtmlParser');
185  $splitContent = $htmlParser->splitTags('img', $content);
186  $elements = array();
187  // Traverse splitted parts:
188  foreach ($splitContent as $k => $v) {
189  if ($k % 2) {
190  // Get file reference:
191  $attribs = $htmlParser->get_tag_attributes($v);
192  $srcRef = htmlspecialchars_decode($attribs[0]['src']);
193  $pI = pathinfo($srcRef);
194  // If it looks like a local image, continue. Otherwise ignore it.
195  $absPath = GeneralUtility::getFileAbsFileName(PATH_site . $srcRef);
196  if (!$pI['scheme'] && !$pI['query'] && $absPath && $srcRef !== 'clear.gif') {
197  // Initialize the element entry with info text here:
198  $tokenID = $this->makeTokenID($k);
199  $elements[$k] = array();
200  $elements[$k]['matchString'] = $v;
201  // If the image seems to be from fileadmin/ folder or an RTE image, then proceed to set up substitution token:
202  if (GeneralUtility::isFirstPartOfStr($srcRef, $this->fileAdminDir . '/') || GeneralUtility::isFirstPartOfStr($srcRef, 'uploads/') && preg_match('/^RTEmagicC_/', basename($srcRef))) {
203  // Token and substitute value:
204  // 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)
205  if (strstr($splitContent[$k], $attribs[0]['src'])) {
206  // Substitute value with token (this is not be an exact method if the value is in there twice, but we assume it will not)
207  $splitContent[$k] = str_replace($attribs[0]['src'], '{softref:' . $tokenID . '}', $splitContent[$k]);
208  $elements[$k]['subst'] = array(
209  'type' => 'file',
210  'relFileName' => $srcRef,
211  'tokenID' => $tokenID,
212  'tokenValue' => $attribs[0]['src']
213  );
214  // Finally, notice if the file does not exist.
215  if (!@is_file($absPath)) {
216  $elements[$k]['error'] = 'File does not exist!';
217  }
218  } else {
219  $elements[$k]['error'] = 'Could not substitute image source with token!';
220  }
221  }
222  }
223  }
224  }
225  // Return result:
226  if (count($elements)) {
227  $resultArray = array(
228  'content' => implode('', $splitContent),
229  'elements' => $elements
230  );
231  return $resultArray;
232  }
233  }
234 
245  public function findRef_typolink($content, $spParams) {
246  // First, split the input string by a comma if the "linkList" parameter is set.
247  // 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.
248  if (is_array($spParams) && in_array('linkList', $spParams)) {
249  // Preserving whitespace on purpose.
250  $linkElement = explode(',', $content);
251  } else {
252  // If only one element, just set in this array to make it easy below.
253  $linkElement = array($content);
254  }
255  // Traverse the links now:
256  $elements = array();
257  foreach ($linkElement as $k => $typolinkValue) {
258  $tLP = $this->getTypoLinkParts($typolinkValue);
259  $linkElement[$k] = $this->setTypoLinkPartsElement($tLP, $elements, $typolinkValue, $k);
260  }
261  // Return output:
262  if (count($elements)) {
263  $resultArray = array(
264  'content' => implode(',', $linkElement),
265  'elements' => $elements
266  );
267  return $resultArray;
268  }
269  }
270 
281  public function findRef_typolink_tag($content, $spParams) {
282  // Parse string for special TYPO3 <link> tag:
283  $htmlParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\HtmlParser');
284  $linkTags = $htmlParser->splitTags('link', $content);
285  // Traverse result:
286  $elements = array();
287  foreach ($linkTags as $k => $foundValue) {
288  if ($k % 2) {
289  $typolinkValue = preg_replace('/<LINK[[:space:]]+/i', '', substr($foundValue, 0, -1));
290  $tLP = $this->getTypoLinkParts($typolinkValue);
291  $linkTags[$k] = '<LINK ' . $this->setTypoLinkPartsElement($tLP, $elements, $typolinkValue, $k) . '>';
292  }
293  }
294  // Return output:
295  if (count($elements)) {
296  $resultArray = array(
297  'content' => implode('', $linkTags),
298  'elements' => $elements
299  );
300  return $resultArray;
301  }
302  }
303 
313  public function findRef_TStemplate($content, $spParams) {
314  $elements = array();
315  // First, try to find images and links:
316  $htmlParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\HtmlParser');
317  $splitContent = $htmlParser->splitTags('img,a,form', $content);
318  // Traverse splitted parts:
319  foreach ($splitContent as $k => $v) {
320  if ($k % 2) {
321  $attribs = $htmlParser->get_tag_attributes($v);
322  $attributeName = '';
323  switch ($htmlParser->getFirstTagName($v)) {
324  case 'img':
325  $attributeName = 'src';
326  break;
327  case 'a':
328  $attributeName = 'href';
329  break;
330  case 'form':
331  $attributeName = 'action';
332  break;
333  }
334  // Get file reference:
335  if (isset($attribs[0][$attributeName])) {
336  $srcRef = htmlspecialchars_decode($attribs[0][$attributeName]);
337  // Set entry:
338  $tokenID = $this->makeTokenID($k);
339  $elements[$k] = array();
340  $elements[$k]['matchString'] = $v;
341  // OK, if it looks like a local file from fileadmin/, include it:
342  $pI = pathinfo($srcRef);
343  $absPath = GeneralUtility::getFileAbsFileName(PATH_site . $srcRef);
344  if (GeneralUtility::isFirstPartOfStr($srcRef, $this->fileAdminDir . '/') && !$pI['query'] && $absPath) {
345  // Token and substitute value:
346  // Very important that the src-value is not DeHSC'ed
347  if (strstr($splitContent[$k], $attribs[0][$attributeName])) {
348  $splitContent[$k] = str_replace($attribs[0][$attributeName], '{softref:' . $tokenID . '}', $splitContent[$k]);
349  $elements[$k]['subst'] = array(
350  'type' => 'file',
351  'relFileName' => $srcRef,
352  'tokenID' => $tokenID,
353  'tokenValue' => $attribs[0][$attributeName]
354  );
355  if (!@is_file($absPath)) {
356  $elements[$k]['error'] = 'File does not exist!';
357  }
358  } else {
359  $elements[$k]['error'] = 'Could not substitute attribute (' . $attributeName . ') value with token!';
360  }
361  }
362  }
363  }
364  }
365  $content = implode('', $splitContent);
366  // Process free fileadmin/ references as well:
367  $content = $this->fileadminReferences($content, $elements);
368  // Return output:
369  if (count($elements)) {
370  $resultArray = array(
371  'content' => $content,
372  'elements' => $elements
373  );
374  return $resultArray;
375  }
376  }
377 
387  public function findRef_TSconfig($content, $spParams) {
388  $elements = array();
389  // Process free fileadmin/ references from TSconfig
390  $content = $this->fileadminReferences($content, $elements);
391  // Return output:
392  if (count($elements)) {
393  $resultArray = array(
394  'content' => $content,
395  'elements' => $elements
396  );
397  return $resultArray;
398  }
399  }
400 
409  public function findRef_email($content, $spParams) {
410  $resultArray = array();
411  // Email:
412  $parts = preg_split('/([^[:alnum:]]+)([A-Za-z0-9\\._-]+[@][A-Za-z0-9\\._-]+[\\.].[A-Za-z0-9]+)/', ' ' . $content . ' ', 10000, PREG_SPLIT_DELIM_CAPTURE);
413  foreach ($parts as $idx => $value) {
414  if ($idx % 3 == 2) {
415  $tokenID = $this->makeTokenID($idx);
416  $elements[$idx] = array();
417  $elements[$idx]['matchString'] = $value;
418  if (is_array($spParams) && in_array('subst', $spParams)) {
419  $parts[$idx] = '{softref:' . $tokenID . '}';
420  $elements[$idx]['subst'] = array(
421  'type' => 'string',
422  'tokenID' => $tokenID,
423  'tokenValue' => $value
424  );
425  }
426  }
427  }
428  // Return output:
429  if (count($elements)) {
430  $resultArray = array(
431  'content' => substr(implode('', $parts), 1, -1),
432  'elements' => $elements
433  );
434  return $resultArray;
435  }
436  }
437 
446  public function findRef_url($content, $spParams) {
447  $resultArray = array();
448  // Fileadmin files:
449  $parts = preg_split('/([^[:alnum:]"\']+)((http|ftp):\\/\\/[^[:space:]"\'<>]*)([[:space:]])/', ' ' . $content . ' ', 10000, PREG_SPLIT_DELIM_CAPTURE);
450  foreach ($parts as $idx => $value) {
451  if ($idx % 5 == 3) {
452  unset($parts[$idx]);
453  }
454  if ($idx % 5 == 2) {
455  $tokenID = $this->makeTokenID($idx);
456  $elements[$idx] = array();
457  $elements[$idx]['matchString'] = $value;
458  if (is_array($spParams) && in_array('subst', $spParams)) {
459  $parts[$idx] = '{softref:' . $tokenID . '}';
460  $elements[$idx]['subst'] = array(
461  'type' => 'string',
462  'tokenID' => $tokenID,
463  'tokenValue' => $value
464  );
465  }
466  }
467  }
468  // Return output:
469  if (count($elements)) {
470  $resultArray = array(
471  'content' => substr(implode('', $parts), 1, -1),
472  'elements' => $elements
473  );
474  return $resultArray;
475  }
476  }
477 
486  public function findRef_extension_fileref($content, $spParams) {
487  $resultArray = array();
488  // Fileadmin files:
489  $parts = preg_split('/([^[:alnum:]"\']+)(EXT:[[:alnum:]_]+\\/[^[:space:]"\',]*)/', ' ' . $content . ' ', 10000, PREG_SPLIT_DELIM_CAPTURE);
490  foreach ($parts as $idx => $value) {
491  if ($idx % 3 == 2) {
492  $tokenID = $this->makeTokenID($idx);
493  $elements[$idx] = array();
494  $elements[$idx]['matchString'] = $value;
495  }
496  }
497  // Return output:
498  if (count($elements)) {
499  $resultArray = array(
500  'content' => substr(implode('', $parts), 1, -1),
501  'elements' => $elements
502  );
503  return $resultArray;
504  }
505  }
506 
507  /*************************
508  *
509  * Helper functions
510  *
511  *************************/
521  public function fileadminReferences($content, &$elements) {
522  // Fileadmin files are found
523  $parts = preg_split('/([^[:alnum:]]+)(' . preg_quote($this->fileAdminDir, '/') . '\\/[^[:space:]"\'<>]*)/', ' ' . $content . ' ', 10000, PREG_SPLIT_DELIM_CAPTURE);
524  // Traverse files:
525  foreach ($parts as $idx => $value) {
526  if ($idx % 3 == 2) {
527  // when file is found, set up an entry for the element:
528  $tokenID = $this->makeTokenID('fileadminReferences:' . $idx);
529  $elements['fileadminReferences.' . $idx] = array();
530  $elements['fileadminReferences.' . $idx]['matchString'] = $value;
531  $elements['fileadminReferences.' . $idx]['subst'] = array(
532  'type' => 'file',
533  'relFileName' => $value,
534  'tokenID' => $tokenID,
535  'tokenValue' => $value
536  );
537  $parts[$idx] = '{softref:' . $tokenID . '}';
538  // Check if the file actually exists:
539  $absPath = GeneralUtility::getFileAbsFileName(PATH_site . $value);
540  if (!@is_file($absPath)) {
541  $elements['fileadminReferences.' . $idx]['error'] = 'File does not exist!';
542  }
543  }
544  }
545  // Implode the content again, removing prefixed and trailing white space:
546  return substr(implode('', $parts), 1, -1);
547  }
548 
561  public function getTypoLinkParts($typolinkValue) {
562  $finalTagParts = array();
563  $browserTarget = '';
564  $cssClass = '';
565  $titleAttribute = '';
566  $additionalParams = '';
567  // Split into link / target / class / title / additionalParams
568  $linkParameter = GeneralUtility::unQuoteFilenames($typolinkValue, TRUE);
569  // Link parameter value
570  $link_param = trim($linkParameter[0]);
571  // Target value
572  if (isset($linkParameter[1])) {
573  $browserTarget = trim($linkParameter[1]);
574  }
575  // Link class
576  if (isset($linkParameter[2])) {
577  $cssClass = trim($linkParameter[2]);
578  }
579  // Title value
580  if (isset($linkParameter[3])) {
581  $titleAttribute = trim($linkParameter[3]);
582  }
583  if (isset($linkParameter[4]) && trim($linkParameter[4]) !== '') {
584  $additionalParams = trim($linkParameter[4]);
585  }
586  // set all tag parts because setTypoLinkPartsElement() rely on them
587  $finalTagParts['target'] = $browserTarget;
588  $finalTagParts['class'] = $cssClass;
589  $finalTagParts['title'] = $titleAttribute;
590  $finalTagParts['additionalParams'] = $additionalParams;
591 
592  // Parse URL:
593  $pU = @parse_url($link_param);
594 
595  // If it's a mail address:
596  if (strstr($link_param, '@') && !$pU['scheme']) {
597  $link_param = preg_replace('/^mailto:/i', '', $link_param);
598  $finalTagParts['LINK_TYPE'] = 'mailto';
599  $finalTagParts['url'] = trim($link_param);
600  return $finalTagParts;
601  }
602 
603  list ($linkHandlerKeyword, $linkHandlerValue) = explode(':', trim($link_param), 2);
604 
605  // Dispatch available signal slots.
606  $linkHandlerFound = FALSE;
607  list($linkHandlerFound, $finalTagParts) = $this->emitGetTypoLinkParts($linkHandlerFound, $finalTagParts, $linkHandlerKeyword, $linkHandlerValue);
608  if ($linkHandlerFound) {
609  return $finalTagParts;
610  }
611 
612  // Check for FAL link-handler keyword
613  if ($linkHandlerKeyword === 'file') {
614  $finalTagParts['LINK_TYPE'] = 'file';
615  $finalTagParts['identifier'] = trim($link_param);
616  return $finalTagParts;
617  }
618 
619  $isLocalFile = 0;
620  $fileChar = (int)strpos($link_param, '/');
621  $urlChar = (int)strpos($link_param, '.');
622 
623  // Detects if a file is found in site-root and if so it will be treated like a normal file.
624  list($rootFileDat) = explode('?', rawurldecode($link_param));
625  $containsSlash = strstr($rootFileDat, '/');
626  $rFD_fI = pathinfo($rootFileDat);
627  if (trim($rootFileDat) && !$containsSlash && (@is_file(PATH_site . $rootFileDat) || GeneralUtility::inList('php,html,htm', strtolower($rFD_fI['extension'])))) {
628  $isLocalFile = 1;
629  } elseif ($containsSlash) {
630  // Adding this so realurl directories are linked right (non-existing).
631  $isLocalFile = 2;
632  }
633  if ($pU['scheme'] || ($isLocalFile != 1 && $urlChar && (!$containsSlash || $urlChar < $fileChar))) { // url (external): If doubleSlash or if a '.' comes before a '/'.
634  $finalTagParts['LINK_TYPE'] = 'url';
635  $finalTagParts['url'] = $link_param;
636  } elseif ($containsSlash || $isLocalFile) { // file (internal)
637  $splitLinkParam = explode('?', $link_param);
638  if (file_exists(rawurldecode($splitLinkParam[0])) || $isLocalFile) {
639  $finalTagParts['LINK_TYPE'] = 'file';
640  $finalTagParts['filepath'] = rawurldecode($splitLinkParam[0]);
641  $finalTagParts['query'] = $splitLinkParam[1];
642  }
643  } else {
644  // integer or alias (alias is without slashes or periods or commas, that is
645  // 'nospace,alphanum_x,lower,unique' according to definition in $GLOBALS['TCA']!)
646  $finalTagParts['LINK_TYPE'] = 'page';
647 
648  $link_params_parts = explode('#', $link_param);
649  // Link-data del
650  $link_param = trim($link_params_parts[0]);
651 
652  if (strlen($link_params_parts[1])) {
653  $finalTagParts['anchor'] = trim($link_params_parts[1]);
654  }
655 
656  // Splitting the parameter by ',' and if the array counts more than 1 element it's a id/type/? pair
657  $pairParts = GeneralUtility::trimExplode(',', $link_param);
658  if (count($pairParts) > 1) {
659  $link_param = $pairParts[0];
660  $finalTagParts['type'] = $pairParts[1]; // Overruling 'type'
661  }
662 
663  // Checking if the id-parameter is an alias.
664  if (strlen($link_param)) {
665  if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($link_param)) {
666  $finalTagParts['alias'] = $link_param;
667  $link_param = $this->getPageIdFromAlias($link_param);
668  }
669 
670  $finalTagParts['page_id'] = (int)$link_param;
671  }
672  }
673 
674  return $finalTagParts;
675  }
676 
688  public function setTypoLinkPartsElement($tLP, &$elements, $content, $idx) {
689  // Initialize, set basic values. In any case a link will be shown
690  $tokenID = $this->makeTokenID('setTypoLinkPartsElement:' . $idx);
691  $elements[$tokenID . ':' . $idx] = array();
692  $elements[$tokenID . ':' . $idx]['matchString'] = $content;
693  // Based on link type, maybe do more:
694  switch ((string) $tLP['LINK_TYPE']) {
695  case 'mailto':
696 
697  case 'url':
698  // Mail addresses and URLs can be substituted manually:
699  $elements[$tokenID . ':' . $idx]['subst'] = array(
700  'type' => 'string',
701  'tokenID' => $tokenID,
702  'tokenValue' => $tLP['url']
703  );
704  // Output content will be the token instead:
705  $content = '{softref:' . $tokenID . '}';
706  break;
707  case 'file':
708  // Process files referenced by their FAL uid
709  if ($tLP['identifier']) {
710  list ($linkHandlerKeyword, $linkHandlerValue) = explode(':', trim($tLP['identifier']), 2);
711  if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($linkHandlerValue)) {
712  // Token and substitute value
713  $elements[$tokenID . ':' . $idx]['subst'] = array(
714  'type' => 'db',
715  'recordRef' => 'sys_file:' . $linkHandlerValue,
716  'tokenID' => $tokenID,
717  'tokenValue' => $tLP['identifier'],
718  );
719  // Output content will be the token instead:
720  $content = '{softref:' . $tokenID . '}';
721  } else {
722  // This is a link to a folder...
723  return $content;
724  }
725 
726  // Process files found in fileadmin directory:
727  } elseif (!$tLP['query']) {
728  // We will not process files which has a query added to it. That will look like a script we don't want to move.
729  // File must be inside fileadmin/
730  if (GeneralUtility::isFirstPartOfStr($tLP['filepath'], $this->fileAdminDir . '/')) {
731  // Set up the basic token and token value for the relative file:
732  $elements[$tokenID . ':' . $idx]['subst'] = array(
733  'type' => 'file',
734  'relFileName' => $tLP['filepath'],
735  'tokenID' => $tokenID,
736  'tokenValue' => $tLP['filepath']
737  );
738  // Depending on whether the file exists or not we will set the
739  $absPath = GeneralUtility::getFileAbsFileName(PATH_site . $tLP['filepath']);
740  if (!@is_file($absPath)) {
741  $elements[$tokenID . ':' . $idx]['error'] = 'File does not exist!';
742  }
743  // Output content will be the token instead
744  $content = '{softref:' . $tokenID . '}';
745  } else {
746  return $content;
747  }
748  } else {
749  return $content;
750  }
751  break;
752  case 'page':
753  // Rebuild page reference typolink part:
754  $content = '';
755  // Set page id:
756  if ($tLP['page_id']) {
757  $content .= '{softref:' . $tokenID . '}';
758  $elements[$tokenID . ':' . $idx]['subst'] = array(
759  'type' => 'db',
760  'recordRef' => 'pages:' . $tLP['page_id'],
761  'tokenID' => $tokenID,
762  'tokenValue' => $tLP['alias'] ? $tLP['alias'] : $tLP['page_id']
763  );
764  }
765  // Add type if applicable
766  if (strlen($tLP['type'])) {
767  $content .= ',' . $tLP['type'];
768  }
769  // Add anchor if applicable
770  if (strlen($tLP['anchor'])) {
771  // Anchor is assumed to point to a content elements:
772  if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($tLP['anchor'])) {
773  // Initialize a new entry because we have a new relation:
774  $newTokenID = $this->makeTokenID('setTypoLinkPartsElement:anchor:' . $idx);
775  $elements[$newTokenID . ':' . $idx] = array();
776  $elements[$newTokenID . ':' . $idx]['matchString'] = 'Anchor Content Element: ' . $tLP['anchor'];
777  $content .= '#{softref:' . $newTokenID . '}';
778  $elements[$newTokenID . ':' . $idx]['subst'] = array(
779  'type' => 'db',
780  'recordRef' => 'tt_content:' . $tLP['anchor'],
781  'tokenID' => $newTokenID,
782  'tokenValue' => $tLP['anchor']
783  );
784  } else {
785  // Anchor is a hardcoded string
786  $content .= '#' . $tLP['type'];
787  }
788  }
789  break;
790  default:
791  $linkHandlerFound = FALSE;
792  list($linkHandlerFound, $tLP, $content, $newElements) = $this->emitSetTypoLinkPartsElement($linkHandlerFound, $tLP, $content, $elements, $idx, $tokenID);
793  // We need to merge the array, otherwise we would loose the reference.
795 
796  if (!$linkHandlerFound) {
797  $elements[$tokenID . ':' . $idx]['error'] = 'Couldn\'t decide typolink mode.';
798  return $content;
799  }
800  }
801  // Finally, for all entries that was rebuild with tokens, add target, class, title and additionalParams in the end:
802  if (strlen($content) && isset($tLP['target']) && $tLP['target'] !== '') {
803  $content .= ' ' . $tLP['target'];
804  if (isset($tLP['class']) && $tLP['class'] !== '') {
805  $content .= ' "' . $tLP['class'] . '"';
806  if (isset($tLP['title']) && $tLP['title'] !== '') {
807  $content .= ' "' . $tLP['title'] . '"';
808  if (isset($tLP['additionalParams']) && $tLP['additionalParams'] !== '') {
809  $content .= ' ' . $tLP['additionalParams'];
810  }
811  }
812  }
813  }
814  // Return rebuilt typolink value:
815  return $content;
816  }
817 
825  public function getPageIdFromAlias($link_param) {
826  $pRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('pages', 'alias', $link_param);
827  return $pRec[0]['uid'];
828  }
829 
837  public function makeTokenID($index = '') {
838  return md5($this->tokenID_basePrefix . ':' . $index);
839  }
840 
844  protected function getSignalSlotDispatcher() {
845  return GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\Dispatcher');
846  }
847 
855  protected function emitGetTypoLinkParts($linkHandlerFound, $finalTagParts, $linkHandlerKeyword, $linkHandlerValue) {
856  return $this->getSignalSlotDispatcher()->dispatch(get_class($this), 'getTypoLinkParts', array($linkHandlerFound, $finalTagParts, $linkHandlerKeyword, $linkHandlerValue));
857  }
858 
868  protected function emitSetTypoLinkPartsElement($linkHandlerFound, $tLP, $content, $elements, $idx, $tokenID) {
869  return $this->getSignalSlotDispatcher()->dispatch(get_class($this), 'setTypoLinkPartsElement', array($linkHandlerFound, $tLP, $content, $elements, $idx, $tokenID, $this));
870  }
871 
872 }
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
static getRecordsByField($theTable, $theField, $theValue, $whereClause='', $groupBy='', $orderBy='', $limit='', $useDeleteClause=TRUE)
static isFirstPartOfStr($str, $partStr)
$uid
Definition: server.php:36
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static unQuoteFilenames($parameters, $unQuote=FALSE)
emitSetTypoLinkPartsElement($linkHandlerFound, $tLP, $content, $elements, $idx, $tokenID)
emitGetTypoLinkParts($linkHandlerFound, $finalTagParts, $linkHandlerKeyword, $linkHandlerValue)
findRef($table, $field, $uid, $content, $spKey, $spParams, $structurePath='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
setTypoLinkPartsElement($tLP, &$elements, $content, $idx)
static getFileAbsFileName($filename, $onlyRelative=TRUE, $relToTYPO3_mainDir=FALSE)