[ Index ]
 

Code source de Typo3 4.1.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/t3lib/ -> class.t3lib_tceforms_inline.php (sommaire)

The Inline-Relational-Record-Editing (IRRE) functions as part of the TCEforms. $Id: class.t3lib_tceforms_inline.php 2482 2007-09-03 08:48:42Z ohader $

Author: Oliver Hader <oh@inpublica.de>
Poids: 1784 lignes (75 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

t3lib_TCEforms_inline:: (44 méthodes):
  init()
  getSingleField_typeInline()
  renderForeignRecord()
  renderForeignRecordHeader()
  renderForeignRecordHeaderControl()
  renderCombinationTable()
  renderPossibleRecordsSelector()
  renderPossibleRecordsSelectorTypeSelect()
  renderPossibleRecordsSelectorTypeGroupDB()
  getNewRecordLink()
  addJavaScriptSortable()
  initForAJAX()
  createNewRecord()
  setExpandedCollapsedState()
  getRelatedRecords()
  getPossibleRecords()
  getUniqueIds()
  getRecord()
  getNewRecord()
  pushStructure()
  popStructure()
  updateStructureNames()
  getStructureItemName()
  getStructureLevel()
  getStructurePath()
  parseStructureString()
  checkConfiguration()
  checkAccess()
  compareStructureConfiguration()
  normalizeUid()
  wrapFormsSection()
  isInlineChildAndLabelField()
  getStructureDepth()
  arrayCompareComplex()
  isAssociativeArray()
  removeFromArray()
  getPossibleRecordsFlat()
  getPossibleRecordsSelectorConfig()
  getPossibleRecordsSelectorType()
  skipField()
  getJSON()
  getExpandedCollapsedState()
  updateInlineView()
  getLevelMargin()


Classe: t3lib_TCEforms_inline  - X-Ref

[CLASS/FUNCTION INDEX of SCRIPT]

88: class t3lib_TCEforms_inline
109:     function init(&$tceForms)
127:     function getSingleField_typeInline($table,$field,$row,&$PA)

SECTION: Regular rendering of forms, fields, etc.
263:     function renderForeignRecord($parentUid, $rec, $config = array())
319:     function renderForeignRecordHeader($parentUid, $foreign_table,$rec,$config = array())
375:     function renderForeignRecordHeaderControl($table,$row,$config = array())
506:     function renderCombinationTable(&$rec, $appendFormFieldNames, $config = array())
560:     function renderPossibleRecordsSelector($selItems, $conf, $uniqueIds=array())
627:     function addJavaScript()
643:     function addJavaScriptSortable($objectId)

SECTION: Handling of AJAX calls
665:     function createNewRecord($domObjectId, $foreignUid = 0)
755:     function getJSON($jsonArray)
770:     function getNewRecordLink($objectPrefix, $conf = array())

SECTION: Get data from database and handle relations
807:     function getRelatedRecords($table,$field,$row,&$PA,$config)
839:     function getPossibleRecords($table,$field,$row,$conf,$checkForConfField='foreign_selector')
885:     function getUniqueIds($records, $conf=array())
905:     function getRecord($pid, $table, $uid, $cmd='')
929:     function getNewRecord($pid, $table)

SECTION: Structure stack for handling inline objects/levels
951:     function pushStructure($table, $uid, $field = '', $config = array())
967:     function popStructure()
984:     function updateStructureNames()
1000:     function getStructureItemName($levelData)
1015:     function getStructureLevel($level)
1032:     function getStructurePath($structureDepth = -1)
1057:     function parseStructureString($string, $loadConfig = false)

SECTION: Helper functions
1098:     function checkConfiguration(&$config)
1123:     function checkAccess($cmd, $table, $theUid)
1185:     function compareStructureConfiguration($compare)
1199:     function normalizeUid($string)
1213:     function wrapFormsSection($section, $styleAttrs = array(), $tableAttrs = array())
1242:     function isInlineChildAndLabelField($table, $field)
1258:     function getStructureDepth()
1295:     function arrayCompareComplex($subjectArray, $searchArray, $type = '')
1349:     function isAssociativeArray($object)
1364:     function getPossibleRecordsFlat($possibleRecords)
1383:     function skipField($table, $field, $row, $config)

TOTAL FUNCTIONS: 35
(This index is automatically created/updated by the extension "extdeveval")

init(&$tceForms)   X-Ref
Intialize an instance of t3lib_TCEforms_inline

param: object        $tceForms: Reference to an TCEforms instance
return: void

getSingleField_typeInline($table,$field,$row,&$PA)   X-Ref
Generation of TCEform elements of the type "inline"
This will render inline-relational-record sets. Relations.

param: string        $table: The table name of the record
param: string        $field: The field name which this element is supposed to edit
param: array        $row: The record data array where the value(s) for the field can be found
param: array        $PA: An array with additional configuration options.
return: string        The HTML code for the TCEform field

renderForeignRecord($parentUid, $rec, $config = array()   X-Ref
Render the form-fields of a related (foreign) record.

param: string        $parentUid: The uid of the parent (embedding) record (uid or NEW...)
param: array        $rec: The table record of the child/embedded table (normaly post-processed by t3lib_transferData)
param: array        $config: content of $PA['fieldConf']['config']
return: string        The HTML code for this "foreign record"

renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config = array()   X-Ref
Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
Later on the command-icons are inserted here.

param: string        $parentUid: The uid of the parent (embedding) record (uid or NEW...)
param: string        $foreign_table: The foreign_table we create a header for
param: array        $rec: The current record of that foreign_table
param: array        $config: content of $PA['fieldConf']['config']
return: string        The HTML code of the header

renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config = array()   X-Ref
Render the control-icons for a record header (create new, sorting, delete, disable/enable).
Most of the parts are copy&paste from class.db_list_extra.inc and modified for the JavaScript calls here

param: string        $parentUid: The uid of the parent (embedding) record (uid or NEW...)
param: string        $foreign_table: The table (foreign_table) we create control-icons for
param: array        $rec: The current record of that foreign_table
param: array        $config: (modified) TCA configuration of the field
return: string        The HTML code with the control-icons

renderCombinationTable(&$rec, $appendFormFieldNames, $config = array()   X-Ref
Render a table with TCEforms, that occurs on a intermediate table but should be editable directly,
so two tables are combined (the intermediate table with attributes and the sub-embedded table).
-> This is a direct embedding over two levels!

param: array        $rec: The table record of the child/embedded table (normaly post-processed by t3lib_transferData)
param: string        $appendFormFieldNames: The [<table>][<uid>] of the parent record (the intermediate table)
param: array        $config: content of $PA['fieldConf']['config']
return: string        A HTML string with <table> tag around.

renderPossibleRecordsSelector($selItems, $conf, $uniqueIds=array()   X-Ref
Get a selector as used for the select type, to select from all available
records and to create a relation to the embedding record (e.g. like MM).

param: array        $selItems: Array of all possible records
param: array        $conf: TCA configuration of the parent(!) field
param: array        $uniqueIds: The uids that have already been used and should be unique
return: string        A HTML <select> box with all possible records

renderPossibleRecordsSelectorTypeSelect($selItems, $conf, &$PA, $uniqueIds=array()   X-Ref
Get a selector as used for the select type, to select from all available
records and to create a relation to the embedding record (e.g. like MM).

param: array        $selItems: Array of all possible records
param: array        $conf: TCA configuration of the parent(!) field
param: array        $PA: An array with additional configuration options
param: array        $uniqueIds: The uids that have already been used and should be unique
return: string        A HTML <select> box with all possible records

renderPossibleRecordsSelectorTypeGroupDB($conf, &$PA)   X-Ref
Generate a link that opens an element browser in a new window.
For group/db there is no way o use a "selector" like a <select>|</select>-box.

param: array        $conf: TCA configuration of the parent(!) field
param: array        $PA: An array with additional configuration options
return: string        A HTML link that opens an element browser in a new window

getNewRecordLink($objectPrefix, $conf = array()   X-Ref
Creates a link/button to create new records

param: string        $objectPrefix: The "path" to the child record to create (e.g. '[parten_table][parent_uid][parent_field][child_table]')
param: array        $conf: TCA configuration of the parent(!) field
return: string        The HTML code for the new record link

addJavaScriptSortable($objectId)   X-Ref
Add Sortable functionality using script.acolo.us "Sortable".

param: string        $objectId: The container id of the object - elements inside will be sortable
return: void

initForAJAX($method, &$arguments)   X-Ref
Initialize environment for AJAX calls

param: string        $method: Name of the method to be called
param: array        $arguments: Arguments to be delivered to the method
return: void

createNewRecord($domObjectId, $foreignUid = 0)   X-Ref
Handle AJAX calls to show a new inline-record of the given table.
Normally this method is never called from inside TYPO3. Always from outside by AJAX.

param: string        $domObjectId: The calling object in hierarchy, that requested a new record.
param: string        $foreignUid: If set, the new record should be inserted after that one.
return: string        A JSON string

setExpandedCollapsedState($domObjectId, $expand, $collapse)   X-Ref
Save the expanded/collapsed state of a child record in the BE_USER->uc.

param: string        $domObjectId: The calling object in hierarchy, that requested a new record.
param: string        $expand: Whether this record is expanded.
param: string        $collapse: Whether this record is collapsed.
return: void

getRelatedRecords($table,$field,$row,&$PA,$config)   X-Ref
Get the related records of the embedding item, this could be 1:n, m:n.

param: string        $table: The table name of the record
param: string        $field: The field name which this element is supposed to edit
param: array        $row: The record data array where the value(s) for the field can be found
param: array        $PA: An array with additional configuration options.
param: array        $config: (Redundant) content of $PA['fieldConf']['config'] (for convenience)
return: array        The records related to the parent item

getPossibleRecords($table,$field,$row,$conf,$checkForConfField='foreign_selector')   X-Ref
Get possible records.
Copied from TCEform and modified.

param: string        The table name of the record
param: string        The field name which this element is supposed to edit
param: array        The record data array where the value(s) for the field can be found
param: array        An array with additional configuration options.
param: string        $checkForConfField: For which field in the foreign_table the possible records should be fetched
return: mixed        Array of possible record items; false if type is "group/db", then everything could be "possible"

getUniqueIds($records, $conf=array()   X-Ref
Gets the uids of a select/selector that should be unique an have already been used.

param: array        $records: All inline records on this level
param: array        $conf: The TCA field configuration of the inline field to be rendered
param: boolean        $splitValue: for usage with group/db, values come like "tx_table_123|Title%20abc", but we need "tx_table" and "123"
return: array        The uids, that have been used already and should be used unique

getRecord($pid, $table, $uid, $cmd='')   X-Ref
Get a single record row for a TCA table from the database.
t3lib_transferData is used for "upgrading" the values, especially the relations.

param: integer        $pid: The pid of the page the record should be stored (only relevant for NEW records)
param: string        $table: The table to fetch data from (= foreign_table)
param: string        $uid: The uid of the record to fetch, or the pid if a new record should be created
param: string        $cmd: The command to perform, empty or 'new'
return: array        A record row from the database post-processed by t3lib_transferData

getNewRecord($pid, $table)   X-Ref
Wrapper. Calls getRecord in case of a new record should be created.

param: integer        $pid: The pid of the page the record should be stored (only relevant for NEW records)
param: string        $table: The table to fetch data from (= foreign_table)
return: array        A record row from the database post-processed by t3lib_transferData

pushStructure($table, $uid, $field = '', $config = array()   X-Ref
Add a new level on top of the structure stack. Other functions can access the
stack and determine, if there's possibly a endless loop.

param: string        $table: The table name of the record
param: string        $uid: The uid of the record that embeds the inline data
param: string        $field: The field name which this element is supposed to edit
param: array        $config: The TCA-configuration of the inline field
return: void

popStructure()   X-Ref
Remove the item on top of the structure stack and return it.

return: array        The top item of the structure stack - array(<table>,<uid>,<field>,<config>)

updateStructureNames()   X-Ref
For common use of DOM object-ids and form field names of a several inline-level,
these names/identifiers are preprocessed and set to $this->inlineNames.
This function is automatically called if a level is pushed to or removed from the
inline structure stack.

return: void

getStructureItemName($levelData)   X-Ref
Create a name/id for usage in HTML output of a level of the structure stack.

param: array        $levelData: Array of a level of the structure stack (containing the keys table, uid and field)
return: string        The name/id of that level, to be used for HTML output

getStructureLevel($level)   X-Ref
Get a level from the stack and return the data.
If the $level value is negative, this function works top-down,
if the $level value is positive, this function works bottom-up.

param: integer        $level: Which level to return
return: array        The item of the stack at the requested level

getStructurePath($structureDepth = -1)   X-Ref
Get the identifiers of a given depth of level, from the top of the stack to the bottom.
An identifier consists looks like [<table>][<uid>][<field>].

param: integer        $structureDepth: How much levels to output, beginning from the top of the stack
return: string        The path of identifiers

parseStructureString($string, $loadConfig = false)   X-Ref
Convert the DOM object-id of an inline container to an array.
The object-id could look like 'data[inline][tx_mmftest_company][1][employees]'.
The result is written to $this->inlineStructure.
There are two keys:
- 'stable': Containing full qualified identifiers (table, uid and field)
- 'unstable': Containting partly filled data (e.g. only table and possibly field)

param: string        $domObjectId: The DOM object-id
param: boolean        $loadConfig: Load the TCA configuration for that level
return: void

checkConfiguration(&$config)   X-Ref
Does some checks on the TCA configuration of the inline field to render.

param: array        $config: Reference to the TCA field configuration
return: boolean        If critical configuration errors were found, false is returned

checkAccess($cmd, $table, $theUid)   X-Ref
Checks the page access rights (Code for access check mostly taken from alt_doc.php)
as well as the table access rights of the user.

param: string        $cmd: The command that sould be performed ('new' or 'edit')
param: string        $table: The table to check access for
param: string        $theUid: The record uid of the table
return: boolean        Returns true is the user has access, or false if not

compareStructureConfiguration($compare)   X-Ref
Check the keys and values in the $compare array against the ['config'] part of the top level of the stack.
A boolean value is return depending on how the comparison was successful.

param: array        $compare: keys and values to compare to the ['config'] part of the top level of the stack
return: boolean        Whether the comparison was successful

normalizeUid($string)   X-Ref
Normalize a relation "uid" published by transferData, like "1|Company%201"

param: string        $string: A transferData reference string, containing the uid
return: string        The normalized uid

wrapFormsSection($section, $styleAttrs = array()   X-Ref
Wrap the HTML code of a section with a table tag.

param: string        $section: The HTML code to be wrapped
param: array        $styleAttrs: Attributes for the style argument in the table tag
param: array        $tableAttrs: Attributes for the table tag (like width, border, etc.)
return: string        The wrapped HTML code

isInlineChildAndLabelField($table, $field)   X-Ref
Checks if the $table is the child of a inline type AND the $field is the label field of this table.
This function is used to dynamically update the label while editing. This has no effect on labels,
that were processed by a TCEmain-hook on saving.

param: string        $table: The table to check
param: string        $field: The field on this table to check
return: boolean        is inline child and field is responsible for the label

getStructureDepth()   X-Ref
Get the depth of the stable structure stack.
(count($this->inlineStructure['stable'])

return: integer        The depth of the structure stack

arrayCompareComplex($subjectArray, $searchArray, $type = '')   X-Ref
Handles complex comparison requests on an array.
A request could look like the following:

$searchArray = array(
'%AND'    => array(
'key1'    => 'value1',
'key2'    => 'value2',
'%OR'    => array(
'subarray' => array(
'subkey' => 'subvalue'
),
'key3'    => 'value3',
'key4'    => 'value4'
)
)
);

It is possible to use the array keys '%AND.1', '%AND.2', etc. to prevent
overwriting the sub-array. It could be neccessary, if you use complex comparisons.

The example above means, key1 *AND* key2 (and their values) have to match with
the $subjectArray and additional one *OR* key3 or key4 have to meet the same
condition.
It is also possible to compare parts of a sub-array (e.g. "subarray"), so this
function recurses down one level in that sub-array.

param: array        $subjectArray: The array to search in
param: array        $searchArray: The array with keys and values to search for
param: string        $type: Use '%AND' or '%OR' for comparision
return: boolean        The result of the comparison

isAssociativeArray($object)   X-Ref
Checks whether an object is an associative array.

param: mixed        $object: The object to be checked
return: boolean        Returns true, if the object is an associative array

removeFromArray($needle, $haystack, $strict=null)   X-Ref
Remove an element from an array.

param: mixed        $needle: The element to be removed.
param: array        $haystack: The array the element should be removed from.
param: mixed        $strict: Search elements strictly.
return: array        The array $haystack without the $needle

getPossibleRecordsFlat($possibleRecords)   X-Ref
Makes a flat array from the $possibleRecords array.
The key of the flat array is the value of the record,
the value of the flat array is the label of the record.

param: array        $possibleRecords: The possibleRecords array (for select fields)
return: mixed        A flat array with key=uid, value=label; if $possibleRecords isn't an array, false is returned.

getPossibleRecordsSelectorConfig($conf, $field = '')   X-Ref
Determine the configuration and the type of a record selector.

param: array        $conf: TCA configuration of the parent(!) field
return: array        Associative array with the keys 'PA' and 'type', both are false if the selector was not valid.

getPossibleRecordsSelectorType($config)   X-Ref
Determine the type of a record selector, e.g. select or group/db.

param: array        $config: TCE configuration of the selector
return: mixed        The type of the selector, 'select' or 'groupdb' - false not valid

skipField($table, $field, $row, $config)   X-Ref
Check, if a field should be skipped, that was defined to be handled as foreign_field or foreign_sortby of
the parent record of the "inline"-type - if so, we have to skip this field - the rendering is done via "inline" as hidden field

param: string        $table: The table name
param: string        $field: The field name
param: array        $row: The record row from the database
param: array        $config: TCA configuration of the field
return: boolean        Determines whether the field should be skipped.

getJSON($jsonArray)   X-Ref
Creates recursively a JSON literal from a mulidimensional associative array.
Uses Services_JSON (http://mike.teczno.com/JSON/doc/)

param: array        $jsonArray: The array (or part of) to be transformed to JSON
return: string        If $level>0: part of JSON literal; if $level==0: whole JSON literal wrapped with <script> tags

getExpandedCollapsedState($table, $uid)   X-Ref
Checks if a uid of a child table is in the inline view settings.

param: string        $table: Name of the child table
param: integer        $uid: uid of the the child record
return: boolean        true=expand, false=collapse

updateInlineView(&$uc, &$tce)   X-Ref
Update expanded/collapsed states on new inline records if any.

param: array        $uc: The uc array to be processed and saved (by reference)
param: object        $tce: Instance of TCEmain that saved data before (by reference)
return: void

getLevelMargin()   X-Ref
Returns the the margin in pixels, that is used for each new inline level.

return: integer        A pixel value for the margin of each new inline level.



Généré le : Sun Nov 25 17:13:16 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics