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

Public Member Functions

 __construct (EventDispatcherInterface $eventDispatcher)
 
array bool null findRef ($table, $field, $uid, $content, $spKey, $spParams, $structurePath='')
 
array null findRef_typolink ($content, $spParams)
 
array null findRef_typolink_tag ($content)
 
array null findRef_email ($content, $spParams)
 
array null findRef_url ($content, $spParams)
 
array null findRef_extension_fileref ($content)
 
array getTypoLinkParts ($typolinkValue)
 
string setTypoLinkPartsElement ($tLP, &$elements, $content, $idx)
 
string makeTokenID ($index='')
 

Public Attributes

string $tokenID_basePrefix = ''
 

Protected Attributes

EventDispatcherInterface $eventDispatcher
 

Private Attributes

int $referenceUid = 0
 
string $referenceTable = ''
 

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.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Database\SoftReferenceIndex::__construct ( EventDispatcherInterface  $eventDispatcher)

Member Function Documentation

◆ findRef()

array bool null 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|null Result array on positive matches, see description above. Otherwise FALSE or null

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

Definition at line 114 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_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 null 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|null Result array on positive matches, see description above. Otherwise null

Definition at line 325 of file SoftReferenceIndex.php.

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

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

◆ findRef_extension_fileref()

array null 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|null Result array on positive matches, see description above. Otherwise null

Definition at line 405 of file SoftReferenceIndex.php.

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

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

◆ findRef_typolink()

array null 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|null Result array on positive matches, see description above. Otherwise null
See also
‪\TYPO3\CMS\Frontend\ContentObject::typolink()
getTypoLinkParts()

Definition at line 181 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 null 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|null Result array on positive matches, see description above. Otherwise null
See also
‪\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::typolink()
getTypoLinkParts()

Definition at line 219 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, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_TELEPHONE, and TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_URL.

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

◆ findRef_url()

array null 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|null Result array on positive matches, see description above. Otherwise null

Definition at line 364 of file SoftReferenceIndex.php.

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

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

◆ 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][,[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 447 of file SoftReferenceIndex.php.

References TYPO3\CMS\Backend\Utility\BackendUtility\getPagesTSconfig(), TYPO3\CMS\Backend\Utility\BackendUtility\getRecord(), 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 521 of file SoftReferenceIndex.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), 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_FOLDER, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_PAGE, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_RECORD, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_TELEPHONE, and TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_URL.

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

Member Data Documentation

◆ $eventDispatcher

EventDispatcherInterface TYPO3\CMS\Core\Database\SoftReferenceIndex::$eventDispatcher
protected

◆ $referenceTable

string TYPO3\CMS\Core\Database\SoftReferenceIndex::$referenceTable = ''
private

Definition at line 95 of file SoftReferenceIndex.php.

◆ $referenceUid

int TYPO3\CMS\Core\Database\SoftReferenceIndex::$referenceUid = 0
private

Definition at line 91 of file SoftReferenceIndex.php.

◆ $tokenID_basePrefix

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

Definition at line 83 of file SoftReferenceIndex.php.