This function merge the plugin TS configuration array with the flexform configuration (priority is given to flexform). Everything is done automatically with a mapping array containing the path of the TS elements to replace, and the path of the flexform fields in the XML.
Parameter: | Default value: | Description: |
|---|---|---|
$mapArray | The mapping array with informations about values to replace | |
$tsArray | The initial TS configuration array | |
$flexRes | The flexform object (usually $this->pObj->cObj->data['pi_flexform']) |
When you use flexforms for the configuration of a plugin, the values you set are most often defined by default in the ext_typoscript_setup.txt files, as default values. Those TypoScript values are passed to your plugin class as an array ($conf). So with flexforms, you need to check for an existing value in the XML, and to replace the value in the $conf array if necessary.
This function will handle that process automatically. It will check for flexform values, and replace the corresponding values in the $conf array. All you have to do is to provide a mapping array, with informations about where the values are located. Look at the example below:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: | // Mapping array for PI flexform $flex2conf = array( 'pidList' => 'sDEF:pages', 'recursive' => 'sDEF:recursive', 'allowHTML' => 'sDEF:allow_html', 'templateFile' => 'sTEMPLATE:template_file', 'dateFormat' => 'sDEF:date_format', 'list.' => array( 'defaultMode' => 'sLIST:default_mode', 'maxRecords' => 'sLIST:max_records', 'maxPages' => 'sLIST:max_pages', 'displayFields' => 'sLIST:display_fields', 'pictures.' => array( 'file.' => array( 'maxW' => 'sLIST:image_maxw', 'maxH' => 'sLIST:image_maxh', ), 'params' => 'sLIST:image_params', ), ); |
The keys of the array are the TypoScript objects names in the $conf array. You can add as many levels as you want, just by adding sub-arrays. The values of the array must be path to the corresponding value in the flexform. For example:
sDEF:pages
It will tell the function to look for the pages field of the sDEF sheet.
When you have your mapping array, you need to get the flexform values, and to launch the function. This is done like this:
1: 2: 3: 4: 5: 6: 7: 8: | // Init flexform configuration of the plugin $this->pi_initPIflexForm(); // Get flexform informations $piFlexForm = $this->cObj->data['pi_flexform']; // Ovverride TS setup with flexform $conf = $this->api->fe_mergeTSconfFlex($flex2conf,$conf,$piFlexForm); |
Then every TypoScript object of your $conf array will be replaced by the corresponding flexform value, if there is one. Otherwise, the TypoScript value will remain untouched.
This function reads a template file and store it as a C-Object in the API class.
This function analyzes the template C-Object, previously set by $this->fe_initTemplate and substitute the specified section with the specified subsections.
Parameter: | Default value: | Description: |
|---|---|---|
$templateMarkers | The markers array | |
$templateSection | The section to substitute |
Here's an example HTML template:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Template File</title> </head> <body> <!-- ###HELLO### --> <p>###WORLD###</p> <p>###UNIVERSE###</p> <!-- ###HELLO### --> </body> </html> |
And here's the PHP code to render it:
1: 2: 3: 4: 5: 6: 7: 8: | // Template markers $templateMarkers = array( '###WORLD###' => 'Hello World!', '###UNIVERSE###' => 'Hello Universe!', ); // Render template $content = $this->api->fe_renderTemplate($templateMarkers,'###HELLO###'); |
This function is used to output the requested content wrapped in an HTML element, containing a CSS class.
Parameter: | Default value: | Description: |
|---|---|---|
$element | The HTML element to produce. | |
$className | The CSS class name to link. | |
$content | false | The content to wrap. |
$piClass | 1 | Prepends class name with plugin name (using pi_classParam). |
$htmlSpecialChars | false | Pass the content through htmlspecialchars(). |
$startTagOnly | false | Generate only the starting tag (without content!). |
$params | array() | The parameters of the HTML element as key/value pairs. |
This function is used to set the internal variables array ($this->pObj->internal) needed to execute a MySQL query.
Parameter: | Default value: | Description: |
|---|---|---|
$results_at_a_time | false | The maximum number of records to display in a list view. |
$maxPages | false | The maximum number of pages to display in the browsebox. |
$searchFieldList | false | The fields available for searching. |
$orderByList | false | The fields available to use as ORDER BY parameter. |
This function is used to output the requested content wrapped in an HTML link element calling the swapClasses JS function.
Parameter: | Default value: | Description: |
|---|---|---|
$elementId | The ID of the HTML element to change. | |
$content | false | The content to wrap. |
$htmlSpecialChars | false | Pass the content through htmlspecialchars(). |
$startTagOnly | false | Generate only the starting tag (without content!). |
$params | array() | The attributes of the HTML element as key/value pairs. |
This function creates an IMAGE cObject for each given filename.
This function is particularly useful with image references stored in a database field.
Parameter: | Default value: | Description: |
|---|---|---|
$imgRefs | A comma list of picture names. | |
$conf | The TS setup for the images. | |
$imgPath | false | The path of the images (will be prepended to each picture name). |
This function links a string to a page (the active one by default).
It's the same function as tslib_pibase::pi_linkTP(), except that a configuration array for the typolink can be passed directly as argument.
Parameter: | Default value: | Description: |
|---|---|---|
$str | The content string to wrap in <a> tags. | |
$uréParameters | array() | Array with URL parameters as key/value pairs. They will be "imploded" and added to the list of parameters defined in the plugins TypoScript property "parent.addParams" plus $this->pi_moreParams. |
$cache | 0 | If $cache is set (0/1), the page is asked to be cached by a &cHash value (unless the current plugin using this class is a USER_INT). Otherwise the no_cache-parameter will be a part of the link. |
$altPageId | 0 | Alternative page ID for the link (by default this function links to the SAME page!). |
$conf | array() | An optionnal array for the typolink configuration. |
This function links a string to a page (the active one by default), while keeping current piVars.
Additionnal piVars can be added or overlaid in the overrulePIvars array. All piVars found in the unsetPIvars array won't be preserved.
Please see the pi_linkTP_keepPIvars function of tslib_pibase for more details.
Parameter: | Default value: | Description: |
|---|---|---|
$str | The content string to wrap in <a> tags. | |
$overrulePIvars | array() | Array of values to override or add in the current piVars. |
$unsetPIvars | array() | Array of values not to include in the current piVars. |
$cache | 0 | Ask the page to be cached by a &cHash value. |
$clearAnyway | 0 | Do not preserve current piVars. |
$altPageId | 0 | Alternative page ID for the link. |
This function returns the URL to a page (the active one by default), while keeping current piVars.
Additionnal piVars can be added or overlaid in the overrulePIvars array. All piVars found in the unsetPIvars array won't be preserved.
Same as fe_linkTP_unsetPIvars, but it returns only the URL.
Please see the pi_linkTP_keepPIvars_url function of tslib_pibase for more details.
Parameter: | Default value: | Description: |
|---|---|---|
$overrulePIvars | array() | Array of values to override or add in the current piVars. |
$unsetPIvars | array() | Array of values not to include in the current piVars. |
$cache | 0 | Ask the page to be cached by a &cHash value. |
$clearAnyway | 0 | Do not preserve current piVars. |
$altPageId | 0 | Alternative page ID for the link. |
This function adds all the configuration necessary to use fe_adminLib to the plugin configuration array.
Parameter: | Default value: | Description: |
|---|---|---|
$conf | The plugin configuration array. | |
$table | The table to use. | |
$pid | The pid for the records. | |
$feAdminConf | The configuration array for fe_adminLib subparts. | |
$create | 1 | Create capabilities (Boolean). |
$edit | 0 | Edit capabilities (Boolean). |
$delete | 0 | Delete capabilities (Boolean). |
$infomail | 0 | Infomail capabilities (Boolean). |
$fe_userOwnSelf | 0 | FE-Users own themselves (Boolean). |
$fe_userEditSelf | 0 | FE-Users can edit themselves (Boolean). |
$debug | 0 | Output debug informations (Boolean). |
$defaultCmd | 'create' | The default command to use if none is found. |
$confKey | 'fe_adminLib' | The key to use for fe_adminLib in the plugin configuration array. |
This function creates an HTML input tag, ready for a usage with fe_adminLib.
Parameter: | Default value: | Description: |
|---|---|---|
$type | The type of the input. | |
$name | The name of the input (field). | |
$feAdminConf | The fe_adminLib configuration array. | |
$feAdminSection | The fe_adminLib section (usually create or edit) - Used to check for required fields. | |
$number | 1 | The number of imput to create. |
$params | array() | The input tag parameters (depending of context) as an array with key/value pairs. |
$defaultValue | 0 | The default value for the input. Can be an array for multiple inputs, or 'unix' for checkboxes/radios with unix-perms like values (eg. 1 -2 - 4 - 8, etc.), or 'increment' for incrementing values (eg. 0 - 1 -2 - 3, etc.). |
$defaultChecked | 0 | For checkboxes or radios, if the input must be checked by default. Can be a comma list for multiple checkboxes. |
$keepSentValues | 1 | Keep element value if the form is redrawn (will override default value or default checked). |
$langPrefix | 'pi_feadmin_' | The prefix for the plugin locallangfile. Used to fetch the title of the input and the warning message, if applicable. |
$headerSeparation | '<br />' | The separation between the title and the input. |
This function creates an HTML <textarea> tag for use with the fe_adminLib script.
Parameter: | Default value: | Description: |
|---|---|---|
$name | The name of the textarea (field). | |
$feAdminConf | The fe_adminLib configuration array. | |
$feAdminSection | The fe_adminLib section (usually create or edit) - Used to check for required fields. | |
$params | array() | The textarea tag parametersas an array with key/value pairs. |
$defaultValue | 0 | The default value for the textarea. |
$keepSentValues | 1 | Keep element value if the form is redrawn (will override default value). |
$langPrefix | 'pi_feadmin_' | The prefix for the plugin locallangfile. Used to fetch the title of the textarea and the warning message, if applicable. |
$headerSeparation | '<br />' | The separation between the title and the textarea. |
This function creates an HTML select tag for use with the fe_adminLib script.
The $option parameter can be an array or a number. If it's an array, the options will get the keys as values, and the values as label. If it's a number, it will create x options (x representing that number). The values will be incremented from zero, and the labels taken from the locallang file, according to the standard Typo3 syntax (eg.: lang_prefix_fieldname.I.value).
Parameter: | Default value: | Description: |
|---|---|---|
$name | The name of the select (field). | |
$feAdminConf | The fe_adminLib configuration array. | |
$feAdminSection | The fe_adminLib section (usually create or edit) - Used to check for required fields. | |
$options | The options to create. | |
$htmlspecialchars | 1 | Pass the option labels through htmlspecialchars(). |
$params | array() | The select tag parameters as an array with key/value pairs. |
$keepSentValues | 1 | Keep element value if the form is redrawn. |
$langPrefix | 'pi_feadmin_' | The prefix for the plugin locallangfile. Used to fetch the title of the select and the warning message, if applicable. |
$headerSeparation | '<br />' | The separation between the title and the select. |
This function creates an HTML select tag for use with the fe_adminLib script. Values and labels are taken from an external table.
Parameter: | Default value: | Description: |
|---|---|---|
$name | The name of the select (field). | |
$feAdminConf | The fe_adminLib configuration array. | |
$feAdminSection | The fe_adminLib section (usually create or edit) - Used to check for required fields. | |
$table | The table containing the records (must be a valid Typo3 table). | |
$pidList | The pages from where to select the records (as a comma list). | |
$labelField | The field in the database to use as option label. | |
$valueField | 'uid' | The field in the database to use as option value (usually UID). |
$htmlspecialchars | 1 | Pass the option labels through htmlspecialchars(). |
$addWhere | '' | Optional additional WHERE clauses put in the end of the query. DO NOT PUT IN GROUP BY, ORDER BY or LIMIT! |
$groupBy | '' | Optional GROUP BY field(s), if none, supply blank string. |
$orderBy | '' | Optional ORDER BY field(s), if none, supply blank string. |
$limit | '' | Optional LIMIT value ([begin,]max), if none, supply blank string. |
$params | array() | The select tag parameters as an array with key/value pairs. |
$keepSentValues | 1 | Keep element value if the form is redrawn. |
$langPrefix | 'pi_feadmin' | The prefix for the plugin locallangfile. Used to fetch the title of the select and the warning message, if applicable. |
$headerSeparation | '<br />' | The separation between the title and the select. |
This function creates the header of a form element for use with the fe_adminLib script. It also checks if the field is required in the plugin configuration array, and adds warning markers.
Parameter: | Default value: | Description: |
|---|---|---|
$name | The name of the field. | |
$langPrefix | The prefix to use to get the field title in the locallang file. | |
$headerSeparation | The separation to use between the header and the form element. | |
$requiredFieldList | false | A comma list of the required fields of the feAdmin section. |
$evalValues | array() | The evalValues array from the feAdmin configuration array. |
This function constructs a standard Typo3 login box. All the setup is done by the function. You only have to specify the PID of the sysfolder where you store your website users records, and it will handle everything. If the user is already logged, it display a logout form.
Parameter: | Default value: | Description: |
|---|---|---|
$pid | The PID of the sysfolder containing the frontend users allowed to login. | |
$inputSize | 30 | The size of the inputs to generate. |
$method | 'POST' | The method of the form object used for sending variables. |
$target | '_self' | The target of the form object. |
$wrap | false | Wrap the whole object. |
$layout | false | The layout of the form object. |
$langPrefix | 'pi_loginbox_' | The prefix to use to get the field title in the locallang file. |
$permaLogin | false | Show permalogin option (needs extension 'core_permalogin') |
This function constructs a standard Typo3 search box for use in plugins. The result is basically the same as tslib_piBase::pi_list_searchBox, but the output is valid XHTML, without tables.
Parameter: | Default value: | Description: |
|---|---|---|
$method | post | The method for the search form (get or post). |
$nocache | true | Add a no cache flag. |
$sword | 'sword' | The sword variable in piVars. |
$pointer | 'pointer' | The pointer variable in piVars. |
This function constructs a standard Typo3 browse box for use in plugins. The result is basically the same as tslib_piBase::pi_list_browseresults, but the output is valid XHTML, without tables.
Parameter: | Default value: | Description: |
|---|---|---|
$pointer | post | The pointer variable in piVars. |
$count | true | The SQL count ressource in PI internal variables. |
$maxResults | 'sword' | The max results number in PI internal variables. |
$maxPages | 'pointer' | The max pages number in PI internal variables. |