TYPO3
7.6
|
Public Member Functions | |
__construct () | |
setWorkspaceId ($workspaceId) | |
getWorkspaceId () | |
updateRefIndexTable ($tableName, $uid, $testOnly=false) | |
generateRefIndexData ($tableName, $uid) | |
createEntryData ($table, $uid, $field, $flexPointer, $deleted, $ref_table, $ref_uid, $ref_string= '', $sort=-1, $softref_key= '', $softref_id= '') | |
createEntryData_dbRels ($table, $uid, $fieldName, $flexPointer, $deleted, $items) | |
createEntryData_fileRels ($table, $uid, $fieldName, $flexPointer, $deleted, $items) | |
createEntryData_softreferences ($table, $uid, $fieldName, $flexPointer, $deleted, $keys) | |
getRelations ($table, $row, $onlyField= '') | |
getRelations_flexFormCallBack ($dsArr, $dataValue, $PA, $structurePath, $parentObject) | |
getRelations_procFiles ($value, $conf, $uid) | |
getRelations_procDB ($value, $conf, $uid, $table= '', $field= '') | |
setReferenceValue ($hash, $newValue, $returnDataArray=false, $bypassWorkspaceAdminCheck=false) | |
setReferenceValue_dbRels ($refRec, $itemArray, $newValue, &$dataArray, $flexPointer= '') | |
setReferenceValue_fileRels ($refRec, $itemArray, $newValue, &$dataArray, $flexPointer= '') | |
setReferenceValue_softreferences ($refRec, $softref, $newValue, &$dataArray, $flexPointer= '') | |
isReferenceField (array $configuration) | |
destPathFromUploadFolder ($folder) | |
error ($msg) | |
Public Attributes | |
$temp_flexRelations = array() | |
$errorLog = array() | |
$WSOL = false | |
$relations = array() | |
$hashVersion = 1 | |
Protected Member Functions | |
isDbReferenceField (array $configuration) | |
fetchTableRelationFields ($tableName) | |
getDatabaseConnection () | |
getBackendUser () | |
Protected Attributes | |
$workspaceId = 0 | |
$runtimeCache = null | |
Static Protected Attributes | |
static | $nonRelationTables |
static | $nonRelationFields |
static | $cachePrefixTableRelationFields = 'core-refidx-tblRelFields-' |
Reference index processing and relation extraction
NOTICE: When the reference index is updated for an offline version the results may not be correct. First, lets assumed that the reference update happens in LIVE workspace (ALWAYS update from Live workspace if you analyse whole database!) Secondly, lets assume that in a Draft workspace you have changed the data structure of a parent page record - this is (in TemplaVoila) inherited by subpages. When in the LIVE workspace the data structure for the records/pages in the offline workspace will not be evaluated to the right one simply because the data structure is taken from a rootline traversal and in the Live workspace that will NOT include the changed DataStructure! Thus the evaluation will be based on the Data Structure set in the Live workspace! Somehow this scenario is rarely going to happen. Yet, it is an inconsistency and I see now practical way to handle it - other than simply ignoring maintaining the index for workspace records. Or we can say that the index is precise for all Live elements while glitches might happen in an offline workspace? Anyway, I just wanted to document this finding - I don't think we can find a solution for it. And its very TemplaVoila specific.
Definition at line 42 of file ReferenceIndex.php.
__construct | ( | ) |
Constructor
Definition at line 152 of file ReferenceIndex.php.
References GeneralUtility\makeInstance().
createEntryData | ( | $table, | |
$uid, | |||
$field, | |||
$flexPointer, | |||
$deleted, | |||
$ref_table, | |||
$ref_uid, | |||
$ref_string = '' , |
|||
$sort = -1 , |
|||
$softref_key = '' , |
|||
$softref_id = '' |
|||
) |
Create array with field/value pairs ready to insert in database. The "hash" field is a fingerprint value across this table.
string | $table | Tablename of source record (where reference is located) |
int | $uid | UID of source record (where reference is located) |
string | $field | Fieldname of source record (where reference is located) |
string | $flexPointer | Pointer to location inside FlexForm structure where reference is located in [field] |
int | $deleted | Whether record is deleted-flagged or not |
string | $ref_table | For database references; the tablename the reference points to. Special keyword "_FILE" indicates that "ref_string" is a file reference either absolute or relative to PATH_site. Special keyword "_STRING" indicates some special usage (typ. softreference) where "ref_string" is used for the value. |
int | $ref_uid | For database references; The UID of the record (zero "ref_table" is "_FILE" or "_STRING") |
string | $ref_string | For "_FILE" or "_STRING" references: The filepath (relative to PATH_site or absolute) or other string. |
int | $sort | The sorting order of references if many (the "group" or "select" TCA types). -1 if no sorting order is specified. |
string | $softref_key | If the reference is a soft reference, this is the soft reference parser key. Otherwise empty. |
string | $softref_id | Soft reference ID for key. Might be useful for replace operations. |
Definition at line 389 of file ReferenceIndex.php.
Referenced by ReferenceIndex\createEntryData_dbRels(), ReferenceIndex\createEntryData_fileRels(), and ReferenceIndex\createEntryData_softreferences().
createEntryData_dbRels | ( | $table, | |
$uid, | |||
$fieldName, | |||
$flexPointer, | |||
$deleted, | |||
$items | |||
) |
Enter database references to ->relations array
string | $table | Tablename of source record (where reference is located) |
int | $uid | UID of source record (where reference is located) |
string | $fieldName | Fieldname of source record (where reference is located) |
string | $flexPointer | Pointer to location inside FlexForm structure where reference is located in [field] |
int | $deleted | Whether record is deleted-flagged or not |
array | $items | Data array with database relations (table/id) |
Definition at line 426 of file ReferenceIndex.php.
References ReferenceIndex\createEntryData().
createEntryData_fileRels | ( | $table, | |
$uid, | |||
$fieldName, | |||
$flexPointer, | |||
$deleted, | |||
$items | |||
) |
Enter file references to ->relations array
string | $table | Tablename of source record (where reference is located) |
int | $uid | UID of source record (where reference is located) |
string | $fieldName | Fieldname of source record (where reference is located) |
string | $flexPointer | Pointer to location inside FlexForm structure where reference is located in [field] |
int | $deleted | Whether record is deleted-flagged or not |
array | $items | Data array with file relations |
Definition at line 444 of file ReferenceIndex.php.
References ReferenceIndex\createEntryData(), GeneralUtility\isFirstPartOfStr(), and PathUtility\stripPathSitePrefix().
createEntryData_softreferences | ( | $table, | |
$uid, | |||
$fieldName, | |||
$flexPointer, | |||
$deleted, | |||
$keys | |||
) |
Enter softref references to ->relations array
string | $table | Tablename of source record (where reference is located) |
int | $uid | UID of source record (where reference is located) |
string | $fieldName | Fieldname of source record (where reference is located) |
string | $flexPointer | Pointer to location inside FlexForm structure |
int | $deleted | |
array | $keys | Data array with soft reference keys |
Definition at line 466 of file ReferenceIndex.php.
References ReferenceIndex\createEntryData().
destPathFromUploadFolder | ( | $folder | ) |
Returns destination path to an upload folder given by $folder
string | $folder | Folder relative to PATH_site |
Definition at line 1135 of file ReferenceIndex.php.
Referenced by ReferenceIndex\getRelations_procFiles().
error | ( | $msg | ) |
Sets error message in the internal error log
string | $msg | Error message |
Definition at line 1150 of file ReferenceIndex.php.
|
protected |
Returns all fields of a table which could contain a relation
string | $tableName | Name of the table |
Definition at line 1103 of file ReferenceIndex.php.
Referenced by ReferenceIndex\updateRefIndexTable().
generateRefIndexData | ( | $tableName, | |
$uid | |||
) |
Returns array of arrays with an index of all references found in record from table/uid If the result is used to update the sys_refindex table then ->WSOL must NOT be TRUE (no workspace overlay anywhere!)
string | $tableName | Table name from $GLOBALS['TCA'] |
int | $uid | Record UID |
Definition at line 285 of file ReferenceIndex.php.
Referenced by ReferenceIndex\updateRefIndexTable().
|
protected |
|
protected |
Return DatabaseConnection
Definition at line 1262 of file ReferenceIndex.php.
Referenced by ReferenceIndex\getRelations_procDB(), and ReferenceIndex\updateRefIndexTable().
getRelations | ( | $table, | |
$row, | |||
$onlyField = '' |
|||
) |
Returns relation information for a $table/$row-array Traverses all fields in input row which are configured in TCA/columns It looks for hard relations to files and records in the TCA types "select" and "group"
string | $table | Table name |
array | $row | Row from table |
string | $onlyField | Specific field to fetch for. |
Definition at line 511 of file ReferenceIndex.php.
References $GLOBALS, BackendUtility\explodeSoftRefParserList(), ReferenceIndex\getRelations_procDB(), ReferenceIndex\getRelations_procFiles(), GeneralUtility\makeInstance(), BackendUtility\softRefParserObj(), and GeneralUtility\xml2array().
getRelations_flexFormCallBack | ( | $dsArr, | |
$dataValue, | |||
$PA, | |||
$structurePath, | |||
$parentObject | |||
) |
Callback function for traversing the FlexForm structure in relation to finding file and DB references!
array | $dsArr | Data structure for the current value |
mixed | $dataValue | Current value |
array | $PA | Additional configuration used in calling function |
string | $structurePath | Path of value in DS structure |
object | $parentObject | Object reference to caller (unused) |
Definition at line 622 of file ReferenceIndex.php.
References BackendUtility\explodeSoftRefParserList(), ReferenceIndex\getRelations_procDB(), ReferenceIndex\getRelations_procFiles(), and BackendUtility\softRefParserObj().
getRelations_procDB | ( | $value, | |
$conf, | |||
$uid, | |||
$table = '' , |
|||
$field = '' |
|||
) |
Check field configuration if it is a DB relation field and extract DB relations if any
string | $value | Field value |
array | $conf | Field configuration array of type "TCA/columns |
int | $uid | Field uid |
string | $table | Table name |
string | $field | Field name |
Definition at line 760 of file ReferenceIndex.php.
References elseif, ReferenceIndex\getDatabaseConnection(), ReferenceIndex\isDbReferenceField(), and GeneralUtility\makeInstance().
Referenced by ReferenceIndex\getRelations(), and ReferenceIndex\getRelations_flexFormCallBack().
getRelations_procFiles | ( | $value, | |
$conf, | |||
$uid | |||
) |
Check field configuration if it is a file relation field and extract file relations if any
string | $value | Field value |
array | $conf | Field configuration array of type "TCA/columns |
int | $uid | Field uid |
Definition at line 698 of file ReferenceIndex.php.
References ReferenceIndex\destPathFromUploadFolder(), ResourceFactory\getInstance(), and GeneralUtility\makeInstance().
Referenced by ReferenceIndex\getRelations(), and ReferenceIndex\getRelations_flexFormCallBack().
getWorkspaceId | ( | ) |
Gets the current workspace id
Definition at line 174 of file ReferenceIndex.php.
References ReferenceIndex\$workspaceId.
Referenced by ReferenceIndex\updateRefIndexTable().
|
protected |
Returns TRUE if the TCA/columns field type is a DB reference field
array | $configuration | Config array for TCA/columns field |
Definition at line 1059 of file ReferenceIndex.php.
Referenced by ReferenceIndex\getRelations_procDB().
isReferenceField | ( | array | $configuration | ) |
Returns TRUE if the TCA/columns field type is a reference field
array | $configuration | Config array for TCA/columns field |
Definition at line 1076 of file ReferenceIndex.php.
setReferenceValue | ( | $hash, | |
$newValue, | |||
$returnDataArray = false , |
|||
$bypassWorkspaceAdminCheck = false |
|||
) |
Setting the value of a reference or removing it completely. Usage: For lowlevel clean up operations! WARNING: With this you can set values that are not allowed in the database since it will bypass all checks for validity! Hence it is targeted at clean-up operations. Please use DataHandler in the usual ways if you wish to manipulate references. Since this interface allows updates to soft reference values (which DataHandler does not directly) you may like to use it for that as an exception to the warning above. Notice; If you want to remove multiple references from the same field, you MUST start with the one having the highest sorting number. If you don't the removal of a reference with a lower number will recreate an index in which the remaining references in that field has new hash-keys due to new sorting numbers - and you will get errors for the remaining operations which cannot find the hash you feed it! To ensure proper working only admin-BE_USERS in live workspace should use this function
string | $hash | 32-byte hash string identifying the record from sys_refindex which you wish to change the value for |
mixed | $newValue | Value you wish to set for reference. If NULL, the reference is removed (unless a soft-reference in which case it can only be set to a blank string). If you wish to set a database reference, use the format "[table]:[uid]". Any other case, the input value is set as-is |
bool | $returnDataArray | Return $dataArray only, do not submit it to database. |
bool | $bypassWorkspaceAdminCheck | If set, it will bypass check for workspace-zero and admin user |
Definition at line 825 of file ReferenceIndex.php.
setReferenceValue_dbRels | ( | $refRec, | |
$itemArray, | |||
$newValue, | |||
& | $dataArray, | ||
$flexPointer = '' |
|||
) |
Setting a value for a reference for a DB field:
array | $refRec | sys_refindex record |
array | $itemArray | Array of references from that field |
string | $newValue | Value to substitute current value with (or NULL to unset it) |
array | $dataArray | Data array in which the new value is set (passed by reference) |
string | $flexPointer | Flexform pointer, if in a flex form field. |
Definition at line 936 of file ReferenceIndex.php.
setReferenceValue_fileRels | ( | $refRec, | |
$itemArray, | |||
$newValue, | |||
& | $dataArray, | ||
$flexPointer = '' |
|||
) |
Setting a value for a reference for a FILE field:
array | $refRec | sys_refindex record |
array | $itemArray | Array of references from that field |
string | $newValue | Value to substitute current value with (or NULL to unset it) |
array | $dataArray | Data array in which the new value is set (passed by reference) |
string | $flexPointer | Flexform pointer, if in a flex form field. |
Definition at line 976 of file ReferenceIndex.php.
setReferenceValue_softreferences | ( | $refRec, | |
$softref, | |||
$newValue, | |||
& | $dataArray, | ||
$flexPointer = '' |
|||
) |
Setting a value for a soft reference token
array | $refRec | sys_refindex record |
array | $softref | Array of soft reference occurencies |
string | $newValue | Value to substitute current value with |
array | $dataArray | Data array in which the new value is set (passed by reference) |
string | $flexPointer | Flexform pointer, if in a flex form field. |
Definition at line 1017 of file ReferenceIndex.php.
setWorkspaceId | ( | $workspaceId | ) |
Sets the current workspace id
int | $workspaceId |
Definition at line 163 of file ReferenceIndex.php.
References ReferenceIndex\$workspaceId.
updateRefIndexTable | ( | $tableName, | |
$uid, | |||
$testOnly = false |
|||
) |
Call this function to update the sys_refindex table for a record (even one just deleted) NOTICE: Currently, references updated for a deleted-flagged record will not include those from within FlexForm fields in some cases where the data structure is defined by another record since the resolving process ignores deleted records! This will also result in bad cleaning up in DataHandler I think... Anyway, that's the story of FlexForms; as long as the DS can change, lots of references can get lost in no time.
string | $tableName | Table name |
int | $uid | UID of record |
bool | $testOnly | If set, nothing will be written to the index but the result value will still report statistics on what is added, deleted and kept. Can be used for mere analysis. |
Definition at line 191 of file ReferenceIndex.php.
References ReferenceIndex\$relations, ReferenceIndex\fetchTableRelationFields(), ReferenceIndex\generateRefIndexData(), ReferenceIndex\getDatabaseConnection(), BackendUtility\getRecordRaw(), and ReferenceIndex\getWorkspaceId().
|
staticprotected |
Definition at line 91 of file ReferenceIndex.php.
$errorLog = array() |
Definition at line 108 of file ReferenceIndex.php.
$hashVersion = 1 |
Definition at line 133 of file ReferenceIndex.php.
|
staticprotected |
Definition at line 75 of file ReferenceIndex.php.
|
staticprotected |
Definition at line 58 of file ReferenceIndex.php.
$relations = array() |
Definition at line 125 of file ReferenceIndex.php.
Referenced by ReferenceIndex\updateRefIndexTable().
|
protected |
Definition at line 147 of file ReferenceIndex.php.
$temp_flexRelations = array() |
Definition at line 99 of file ReferenceIndex.php.
|
protected |
Definition at line 140 of file ReferenceIndex.php.
Referenced by ReferenceIndex\getWorkspaceId(), and ReferenceIndex\setWorkspaceId().
$WSOL = false |
Definition at line 117 of file ReferenceIndex.php.