TYPO3  7.6
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
SoftReferenceIndex Class Reference
Inheritance diagram for SoftReferenceIndex:
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:

Definition at line 70 of file SoftReferenceIndex.php.

Constructor & Destructor Documentation

__construct ( )

Class construct to set global variable

Definition at line 85 of file SoftReferenceIndex.php.

References $GLOBALS.

Member Function Documentation

emitGetTypoLinkParts (   $linkHandlerFound,
  $finalTagParts,
  $linkHandlerKeyword,
  $linkHandlerValue 
)
protected
Parameters
bool$linkHandlerFound
array$finalTagParts
string$linkHandlerKeyword
string$linkHandlerValue
Returns
array

Definition at line 817 of file SoftReferenceIndex.php.

References SoftReferenceIndex\getSignalSlotDispatcher().

Referenced by SoftReferenceIndex\getTypoLinkParts().

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

References SoftReferenceIndex\getSignalSlotDispatcher().

Referenced by SoftReferenceIndex\setTypoLinkPartsElement().

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 GeneralUtility\getFileAbsFileName(), and SoftReferenceIndex\makeTokenID().

Referenced by SoftReferenceIndex\findRef_TSconfig(), and SoftReferenceIndex\findRef_TStemplate().

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 SoftReferenceIndex\findRef_email(), SoftReferenceIndex\findRef_extension_fileref(), SoftReferenceIndex\findRef_images(), SoftReferenceIndex\findRef_TSconfig(), SoftReferenceIndex\findRef_TStemplate(), SoftReferenceIndex\findRef_typolink(), SoftReferenceIndex\findRef_typolink_tag(), SoftReferenceIndex\findRef_url(), and SoftReferenceIndex\makeTokenID().

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 SoftReferenceIndex\makeTokenID().

Referenced by SoftReferenceIndex\findRef().

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 SoftReferenceIndex\makeTokenID().

Referenced by SoftReferenceIndex\findRef().

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 GeneralUtility\getFileAbsFileName(), GeneralUtility\isFirstPartOfStr(), GeneralUtility\makeInstance(), and SoftReferenceIndex\makeTokenID().

Referenced by SoftReferenceIndex\findRef().

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 SoftReferenceIndex\fileadminReferences().

Referenced by SoftReferenceIndex\findRef().

findRef_TStemplate (   $content,
  $spParams 
)
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 SoftReferenceIndex\getTypoLinkParts(), and SoftReferenceIndex\setTypoLinkPartsElement().

Referenced by SoftReferenceIndex\findRef().

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 SoftReferenceIndex\getTypoLinkParts(), GeneralUtility\makeInstance(), and SoftReferenceIndex\setTypoLinkPartsElement().

Referenced by SoftReferenceIndex\findRef().

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 SoftReferenceIndex\makeTokenID().

Referenced by SoftReferenceIndex\findRef().

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

Referenced by SoftReferenceIndex\getTypoLinkParts().

getSignalSlotDispatcher ( )
protected
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 MathUtility\canBeInterpretedAsInteger(), elseif, SoftReferenceIndex\emitGetTypoLinkParts(), SoftReferenceIndex\getPageIdFromAlias(), GeneralUtility\inList(), GeneralUtility\makeInstance(), and GeneralUtility\trimExplode().

Referenced by SoftReferenceIndex\findRef_typolink(), and SoftReferenceIndex\findRef_typolink_tag().

makeTokenID (   $index = '')
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 657 of file SoftReferenceIndex.php.

References MathUtility\canBeInterpretedAsInteger(), elseif, SoftReferenceIndex\emitSetTypoLinkPartsElement(), GeneralUtility\getFileAbsFileName(), GeneralUtility\isFirstPartOfStr(), GeneralUtility\makeInstance(), and SoftReferenceIndex\makeTokenID().

Referenced by SoftReferenceIndex\findRef_typolink(), and SoftReferenceIndex\findRef_typolink_tag().

Member Data Documentation

$fileAdminDir = ''

Definition at line 75 of file SoftReferenceIndex.php.

$tokenID_basePrefix = ''

Definition at line 80 of file SoftReferenceIndex.php.