‪TYPO3CMS  9.5
TYPO3\CMS\Core\Database\SoftReferenceIndex Class Reference
Inheritance diagram for TYPO3\CMS\Core\Database\SoftReferenceIndex:
TYPO3\CMS\Form\Hooks\SoftReferenceParserHook

Public Member Functions

array bool findRef ($table, $field, $uid, $content, $spKey, $spParams, $structurePath='')
 
array findRef_images ($content)
 
array findRef_typolink ($content, $spParams)
 
array findRef_typolink_tag ($content)
 
array findRef_email ($content, $spParams)
 
array findRef_url ($content, $spParams)
 
array findRef_extension_fileref ($content)
 
array getTypoLinkParts ($typolinkValue)
 
string setTypoLinkPartsElement ($tLP, &$elements, $content, $idx)
 
int getPageIdFromAlias ($link_param)
 
string makeTokenID ($index='')
 

Public Attributes

string $tokenID_basePrefix = ''
 

Protected Member Functions

TYPO3 CMS Extbase SignalSlot Dispatcher getSignalSlotDispatcher ()
 
array 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 = \TYPO3\CMS\Backend\Utility\BackendUtility::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 = \TYPO3\CMS\Backend\Utility\BackendUtility::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
  • ‪'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.
  • ‪'email' : Email highlight
  • ‪'url' : URL highlights (with a scheme)

Definition at line 79 of file SoftReferenceIndex.php.

Member Function Documentation

◆ emitSetTypoLinkPartsElement()

array 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 721 of file SoftReferenceIndex.php.

References TYPO3\CMS\Extbase\SignalSlot\Dispatcher\dispatch(), and TYPO3\CMS\Core\Database\SoftReferenceIndex\getSignalSlotDispatcher().

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

◆ findRef()

array bool 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$field‪Field name for which processing occurs
int$uid‪UID of the record
string$content‪The content/value of the field
string$spKey‪The 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$spParams‪Parameters of the softlink parser. Basically this is the content inside optional []-brackets after the softref keys. Parameters are exploded by ";
string$structurePath‪If running from inside a FlexForm structure, this is the path of the tag.
Returns
‪array|bool Result array on positive matches, see description above. Otherwise FALSE

Reimplemented in TYPO3\CMS\Form\Hooks\SoftReferenceParserHook.

Definition at line 97 of file SoftReferenceIndex.php.

References 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_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()

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

Finding email addresses in content and making them substitutable.

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

Definition at line 357 of file SoftReferenceIndex.php.

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

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

◆ findRef_extension_fileref()

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

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

Parameters
string$content‪The input content to analyze
Returns
‪array Result array on positive matches, see description above. Otherwise FALSE

Definition at line 431 of file SoftReferenceIndex.php.

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

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

◆ findRef_images()

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

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 uploads/ folders which are prefixed with "RTEmagic[C|P]_" for substitution Any "clear.gif" images are ignored.

Parameters
string$content‪The input content to analyze
Returns
‪array Result array on positive matches, see description above. Otherwise FALSE

Definition at line 163 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Utility\PathUtility\basename(), TYPO3\CMS\Core\Core\Environment\getPublicPath(), and TYPO3\CMS\Core\Database\SoftReferenceIndex\makeTokenID().

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

◆ findRef_typolink()

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

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

Parameters
string$content‪The input content to analyze
array$spParams‪Parameters 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
‪\TYPO3\CMS\Frontend\ContentObject::typolink(), getTypoLinkParts()

Definition at line 227 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()

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

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

Parameters
string$content‪The input content to analyze
Returns
‪array Result array on positive matches, see description above. Otherwise FALSE
See also
‪\TYPO3\CMS\Frontend\ContentObject::typolink(), getTypoLinkParts()

Definition at line 262 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Resource\AbstractFile\getUid(), TYPO3\CMS\Core\Database\SoftReferenceIndex\makeTokenID(), TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_EMAIL, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_FILE, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_PAGE, and TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_URL.

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

◆ findRef_url()

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

Finding URLs in content

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

Definition at line 393 of file SoftReferenceIndex.php.

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

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

◆ getPageIdFromAlias()

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

Look up and return page uid for alias

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

Definition at line 673 of file SoftReferenceIndex.php.

◆ getSignalSlotDispatcher()

TYPO3 CMS Extbase SignalSlot Dispatcher TYPO3\CMS\Core\Database\SoftReferenceIndex::getSignalSlotDispatcher ( )
protected
Returns
‪\TYPO3\CMS\Extbase\SignalSlot\Dispatcher

Definition at line 707 of file SoftReferenceIndex.php.

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

◆ getTypoLinkParts()

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

Analyze 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\CMS\Frontend\ContentObject\ContentObjectRenderer::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 \TYPO3\CMS\Frontend\ContentObject::typolink() behaves.

Parameters
string$typolinkValue‪TypoLink value.
Returns
‪array Array with the properties of the input link specified. The key "type" will reveal the type. If that is blank it could not be determined.
See also
‪\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::typolink()
setTypoLinkPartsElement()

Definition at line 470 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_FILE, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_PAGE, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_RECORD, and TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_UNKNOWN.

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

◆ makeTokenID()

◆ setTypoLinkPartsElement()

string 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$tLP‪TypoLink properties
array$elements‪Array of elements to be modified with substitution / information entries.
string$content‪The content to process.
int$idx‪Index 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 535 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Database\SoftReferenceIndex\emitSetTypoLinkPartsElement(), TYPO3\CMS\Core\Database\SoftReferenceIndex\makeTokenID(), TYPO3\CMS\Core\Utility\ArrayUtility\mergeRecursiveWithOverrule(), TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_EMAIL, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_FILE, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_FOLDER, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_PAGE, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_RECORD, and TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_URL.

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

Member Data Documentation

◆ $tokenID_basePrefix

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

Definition at line 83 of file SoftReferenceIndex.php.