TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Database\SoftReferenceIndex Class Reference
Inheritance diagram for TYPO3\CMS\Core\Database\SoftReferenceIndex:
TYPO3\CMS\Rtehtmlarea\Hook\SoftReferenceHook

Public Member Functions

 __construct ()
 
 findRef ($table, $field, $uid, $content, $spKey, $spParams, $structurePath='')
 
 findRef_images ($content, $spParams)
 
 findRef_typolink ($content, $spParams)
 
 findRef_typolink_tag ($content, $spParams)
 
 findRef_TStemplate ($content, $spParams)
 
 findRef_TSconfig ($content, $spParams)
 
 findRef_email ($content, $spParams)
 
 findRef_url ($content, $spParams)
 
 findRef_extension_fileref ($content, $spParams)
 
 fileadminReferences ($content, &$elements)
 
 getTypoLinkParts ($typolinkValue)
 
 setTypoLinkPartsElement ($tLP, &$elements, $content, $idx)
 
 getPageIdFromAlias ($link_param)
 
 makeTokenID ($index='')
 

Public Attributes

 $fileAdminDir = ''
 
 $tokenID_basePrefix = ''
 

Protected Member Functions

 getSignalSlotDispatcher ()
 
 emitGetTypoLinkParts ($linkHandlerFound, $finalTagParts, $linkHandlerKeyword, $linkHandlerValue)
 
 emitSetTypoLinkPartsElement ($linkHandlerFound, $tLP, $content, $elements, $idx, $tokenID)
 

Detailed Description

Soft Reference processing class "Soft References" are references to database elements, files, email addresses, URls etc. which are found in-text in content. The <link [page_id]> tag from typical bodytext fields are an example of this. This class contains generic parsers for the most well-known types which are default for most TYPO3 installations. Soft References can also be userdefined. The Soft Reference parsers are used by the system to find these references and process them accordingly in import/export actions and copy operations.

Example of usage Soft References: if ($conf['softref'] && (strong)$value !== '')) { // Check if a TCA configured field has softreferences defined (see TYPO3 Core API document) $softRefs = ::explodeSoftRefParserList($conf['softref']); // Explode the list of softreferences/parameters if ($softRefs !== FALSE) { // If there are soft references foreach($softRefs as $spKey => $spParams) { // Traverse soft references $softRefObj = ::softRefParserObj($spKey); // create / get object if (is_object($softRefObj)) { // If there was an object returned...: $resultArray = $softRefObj->findRef($table, $field, $uid, $softRefValue, $spKey, $spParams); // Do processing

Result Array: The Result array should contain two keys: "content" and "elements". "content" is a string containing the input content but possibly with tokens inside. Tokens are strings like {softref:[tokenID]} which is a placeholder for a value extracted by a softref parser For each token there MUST be an entry in the "elements" key which has a "subst" key defining the tokenID and the tokenValue. See below. "elements" is an array where the keys are insignificant, but the values are arrays with these keys: "matchString" => The value of the match. This is only for informational purposes to show what was found. "error" => An error message can be set here, like "file not found" etc. "subst" => array( // If this array is found there MUST be a token in the output content as well! "tokenID" => The tokenID string corresponding to the token in output content, {softref:[tokenID]}. This is typically an md5 hash of a string defining uniquely the position of the element. "tokenValue" => The value that the token substitutes in the text. Basically, if this value is inserted instead of the token the content should match what was inputted originally. "type" => file / db / string = the type of substitution. "file" means it is a relative file [automatically mapped], "db" means a database record reference [automatically mapped], "string" means it is manually modified string content (eg. an email address) "relFileName" => (for "file" type): Relative filename. May not necessarily exist. This could be noticed in the error key. "recordRef" => (for "db" type) : Reference to DB record on the form [table]:[uid]. May not necessarily exist. "title" => Title of element (for backend information) "description" => Description of element (for backend information) ) Class for processing of the default soft reference types for CMS:

  • 'substitute' : A full field value targeted for manual substitution (for import /export features)
  • 'notify' : Just report if a value is found, nothing more.
  • 'images' : HTML tags for RTE images / images from fileadmin/
  • 'typolink' : references to page id or file, possibly with anchor/target, possibly commaseparated list.
  • 'typolink_tag' : As typolink, but searching for <link> tag to encapsulate it.
  • 'TSconfig' processing (filerefs? Domains? what do we know...)
  • 'TStemplate' : freetext references to "fileadmin/" files.
  • 'email' : Email highlight
  • 'url' : URL highlights (with a scheme)

Definition at line 70 of file SoftReferenceIndex.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Database\SoftReferenceIndex::__construct ( )

Class construct to set global variable

Definition at line 85 of file SoftReferenceIndex.php.

References $GLOBALS.

Member Function Documentation

◆ emitGetTypoLinkParts()

TYPO3\CMS\Core\Database\SoftReferenceIndex::emitGetTypoLinkParts (   $linkHandlerFound,
  $finalTagParts,
  $linkHandlerKeyword,
  $linkHandlerValue 
)
protected
Parameters
bool$linkHandlerFound
array$finalTagParts
string$linkHandlerKeyword
string$linkHandlerValue
Returns
array

Definition at line 825 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Database\SoftReferenceIndex\getSignalSlotDispatcher().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\getTypoLinkParts().

◆ emitSetTypoLinkPartsElement()

TYPO3\CMS\Core\Database\SoftReferenceIndex::emitSetTypoLinkPartsElement (   $linkHandlerFound,
  $tLP,
  $content,
  $elements,
  $idx,
  $tokenID 
)
protected
Parameters
bool$linkHandlerFound
array$tLP
string$content
array$elements
int$idx
string$tokenID
Returns
array

Definition at line 839 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Database\SoftReferenceIndex\getSignalSlotDispatcher().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\setTypoLinkPartsElement().

◆ fileadminReferences()

TYPO3\CMS\Core\Database\SoftReferenceIndex::fileadminReferences (   $content,
$elements 
)

Searches the content for a reference to a file in "fileadmin/". When a match is found it will get substituted with a token.

Parameters
string$contentInput content to analyse
array$elementsElement array to be modified with new entries. Passed by reference.
Returns
string Output content, possibly with tokens inserted.

Definition at line 514 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\getFileAbsFileName(), and TYPO3\CMS\Core\Database\SoftReferenceIndex\makeTokenID().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_TSconfig(), and TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_TStemplate().

◆ findRef()

TYPO3\CMS\Core\Database\SoftReferenceIndex::findRef (   $table,
  $field,
  $uid,
  $content,
  $spKey,
  $spParams,
  $structurePath = '' 
)

Main function through which all processing happens

Parameters
string$tableDatabase table name
string$fieldField name for which processing occurs
int$uidUID of the record
string$contentThe content/value of the field
string$spKeyThe softlink parser key. This is only interesting if more than one parser is grouped in the same class. That is the case with this parser.
array$spParamsParameters of the softlink parser. Basically this is the content inside optional []-brackets after the softref keys. Parameters are exploded by ";
string$structurePathIf running from inside a FlexForm structure, this is the path of the tag.
Returns
array Result array on positive matches, see description above. Otherwise FALSE

Definition at line 102 of file SoftReferenceIndex.php.

References $uid, TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_email(), TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_extension_fileref(), TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_images(), TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_TSconfig(), TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_TStemplate(), TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_typolink(), TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_typolink_tag(), TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_url(), and TYPO3\CMS\Core\Database\SoftReferenceIndex\makeTokenID().

◆ findRef_email()

TYPO3\CMS\Core\Database\SoftReferenceIndex::findRef_email (   $content,
  $spParams 
)

Finding email addresses in content and making them substitutable.

Parameters
string$contentThe input content to analyse
array$spParamsParameters set for the softref parser key in TCA/columns
Returns
array Result array on positive matches, see description above. Otherwise FALSE

Definition at line 402 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Database\SoftReferenceIndex\makeTokenID().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef().

◆ findRef_extension_fileref()

TYPO3\CMS\Core\Database\SoftReferenceIndex::findRef_extension_fileref (   $content,
  $spParams 
)

Finding reference to files from extensions in content, but only to notify about their existence. No substitution

Parameters
string$contentThe input content to analyse
array$spParamsParameters set for the softref parser key in TCA/columns
Returns
array Result array on positive matches, see description above. Otherwise FALSE

Definition at line 479 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Database\SoftReferenceIndex\makeTokenID().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef().

◆ findRef_images()

TYPO3\CMS\Core\Database\SoftReferenceIndex::findRef_images (   $content,
  $spParams 
)

Finding image tags in the content. All images that are not from external URLs will be returned with an info text Will only return files in fileadmin/ and files in uploads/ folders which are prefixed with "RTEmagic[C|P]_" for substitution Any "clear.gif" images are ignored.

Parameters
string$contentThe input content to analyse
array$spParamsParameters set for the softref parser key in TCA/columns
Returns
array Result array on positive matches, see description above. Otherwise FALSE

Definition at line 175 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\getFileAbsFileName(), TYPO3\CMS\Core\Utility\GeneralUtility\isFirstPartOfStr(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), and TYPO3\CMS\Core\Database\SoftReferenceIndex\makeTokenID().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef().

◆ findRef_TSconfig()

TYPO3\CMS\Core\Database\SoftReferenceIndex::findRef_TSconfig (   $content,
  $spParams 
)

Processes possible references inside of Page and User TSconfig fields. Currently this only includes file references to fileadmin/ but in fact there are currently no properties that supports such references.

Parameters
string$contentThe input content to analyse
array$spParamsParameters set for the softref parser key in TCA/columns
Returns
array Result array on positive matches, see description above. Otherwise FALSE

Definition at line 380 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Database\SoftReferenceIndex\fileadminReferences().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef().

◆ findRef_TStemplate()

◆ findRef_typolink()

TYPO3\CMS\Core\Database\SoftReferenceIndex::findRef_typolink (   $content,
  $spParams 
)

TypoLink value processing. Will process input value as a TypoLink value.

Parameters
string$contentThe input content to analyse
array$spParamsParameters set for the softref parser key in TCA/columns. value "linkList" will split the string by comma before processing.
Returns
array Result array on positive matches, see description above. Otherwise FALSE
See also
::typolink(), getTypoLinkParts()

Definition at line 238 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Database\SoftReferenceIndex\getTypoLinkParts(), and TYPO3\CMS\Core\Database\SoftReferenceIndex\setTypoLinkPartsElement().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef().

◆ findRef_typolink_tag()

TYPO3\CMS\Core\Database\SoftReferenceIndex::findRef_typolink_tag (   $content,
  $spParams 
)

TypoLink tag processing. Will search for <link ...> tags in the content string and process any found.

Parameters
string$contentThe input content to analyse
array$spParamsParameters set for the softref parser key in TCA/columns
Returns
array Result array on positive matches, see description above. Otherwise FALSE
See also
::typolink(), getTypoLinkParts()

Definition at line 274 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Database\SoftReferenceIndex\getTypoLinkParts(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), and TYPO3\CMS\Core\Database\SoftReferenceIndex\setTypoLinkPartsElement().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef().

◆ findRef_url()

TYPO3\CMS\Core\Database\SoftReferenceIndex::findRef_url (   $content,
  $spParams 
)

Finding URLs in content

Parameters
string$contentThe input content to analyse
array$spParamsParameters set for the softref parser key in TCA/columns
Returns
array Result array on positive matches, see description above. Otherwise FALSE

Definition at line 439 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Database\SoftReferenceIndex\makeTokenID().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef().

◆ getPageIdFromAlias()

TYPO3\CMS\Core\Database\SoftReferenceIndex::getPageIdFromAlias (   $link_param)

Look up and return page uid for alias

Parameters
int$link_paramPage alias string value
Returns
int Page uid corresponding to alias value.

Definition at line 793 of file SoftReferenceIndex.php.

References TYPO3\CMS\Backend\Utility\BackendUtility\getRecordsByField().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\getTypoLinkParts().

◆ getSignalSlotDispatcher()

TYPO3\CMS\Core\Database\SoftReferenceIndex::getSignalSlotDispatcher ( )
protected

◆ getTypoLinkParts()

TYPO3\CMS\Core\Database\SoftReferenceIndex::getTypoLinkParts (   $typolinkValue)

Analyse content as a TypoLink value and return an array with properties. TypoLinks format is: <link [typolink] [browser target] [css class] [title attribute] [additionalParams]>. See TYPO3::typolink() The syntax of the [typolink] part is: [typolink] = [page id or alias][,[type value]][#[anchor, if integer = tt_content uid]] The extraction is based on how ::typolink() behaves.

Parameters
string$typolinkValueTypoLink value.
Returns
array Array with the properties of the input link specified. The key "LINK_TYPE" will reveal the type. If that is blank it could not be determined.
See also
::typolink(), setTypoLinkPartsElement()

Definition at line 554 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Database\SoftReferenceIndex\emitGetTypoLinkParts(), TYPO3\CMS\Core\Database\SoftReferenceIndex\getPageIdFromAlias(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_typolink(), and TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_typolink_tag().

◆ makeTokenID()

◆ setTypoLinkPartsElement()

TYPO3\CMS\Core\Database\SoftReferenceIndex::setTypoLinkPartsElement (   $tLP,
$elements,
  $content,
  $idx 
)

Recompile a TypoLink value from the array of properties made with getTypoLinkParts() into an elements array

Parameters
array$tLPTypoLink properties
array$elementsArray of elements to be modified with substitution / information entries.
string$contentThe content to process.
int$idxIndex value of the found element - user to make unique but stable tokenID
Returns
string The input content, possibly containing tokens now according to the added substitution entries in $elements
See also
getTypoLinkParts()

Definition at line 665 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Database\SoftReferenceIndex\emitSetTypoLinkPartsElement(), TYPO3\CMS\Core\Utility\GeneralUtility\getFileAbsFileName(), TYPO3\CMS\Core\Utility\GeneralUtility\isFirstPartOfStr(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), TYPO3\CMS\Core\Database\SoftReferenceIndex\makeTokenID(), and TYPO3\CMS\Core\Utility\ArrayUtility\mergeRecursiveWithOverrule().

Referenced by TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_typolink(), and TYPO3\CMS\Core\Database\SoftReferenceIndex\findRef_typolink_tag().

Member Data Documentation

◆ $fileAdminDir

TYPO3\CMS\Core\Database\SoftReferenceIndex::$fileAdminDir = ''

Definition at line 75 of file SoftReferenceIndex.php.

◆ $tokenID_basePrefix

TYPO3\CMS\Core\Database\SoftReferenceIndex::$tokenID_basePrefix = ''

Definition at line 80 of file SoftReferenceIndex.php.