DEPRECATION WARNING
This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.
Developer API¶
Author: | Kasper Skårhøj |
---|---|
Created: | 2002-11-01T00:32:00 |
Changed: | 2008-09-24T18:34:15 |
Email: | info@macmade.net |
Info 2: | |
Info 3: | |
Info 4: |
Developer API¶
Extension Key: api_macmade
Copyright 2000-2002, Jean-David Gadina, <info@macmade.net>
This document is published under the Open Content License
available from http://www.opencontent.org/opl.shtml
The content of this document is related to TYPO3
- a GNU/GPL CMS/Framework available from www.typo3.com
Table of Contents¶
Developer API 1
Introduction 2
About this API 2
Why another API? 2
How to use this API 2
PHP 5 classes 2
Introduction 2
tx_apimacmade_flexform 2
JavaScript 4
Introduction 4
Section 1 - Internal 5
About this section 5
tx_apimacmade 5
versionError 6
errorMsg 6
getPhp5Class 6
newInstance 6
Section 2 - FrontEnd 8
About this section 8
fe_mergeTSconfFlex 8
fe_initTemplate 9
fe_renderTemplate 9
fe_makeStyledContent 10
fe_setInternalVars 10
fe_buildSwapClassesJSCode 10
fe_makeSwapClassesJSLink 11
fe_createImageObjects 11
fe_linkTP 11
fe_linkTP_keepPIvars 12
fe_linkTP_keepPIvars_url 12
fe_linkTP_unsetPIvars 12
fe_linkTP_unsetPIvars_url 13
fe_typoLinkParams 13
fe_initFeAdmin 13
fe_createInput 14
fe_createTextArea 14
fe_createSelect 15
fe_createSelectFromTable 15
fe_buildFormElementHeader 16
fe_buildLoginBox 16
fe_buildSearchBox 17
fe_buildBrowseBox 17
fe_includePrototypeJs 18
fe_includeMootoolsJs 18
fe_includeScriptaculousJs 18
fe_includeLightBoxJs 18
fe_includeUfo 18
fe_includeSwfObject 19
fe_includeWebToolKitJs 19
Section 3 - BackEnd 20
About this section 20
be_buildRecordIcons 20
be_buildPageTreeSelect 20
be_getSelectStyleRecordIcon 20
be_initCSM 21
be_getRecordCSMIcon 21
be_includePrototypeJs 21
be_includeMootoolsJs 21
be_includeScriptaculousJs 21
be_includeLightBoxJs 21
be_includeUfo 22
be_includeSwfObject 22
be_includeWebToolKitJs 22
Section 4 - Database 23
About this section 23
db_table2text 23
db_table2xml 23
Section 5 - Miscellaneous 25
About this section 25
div_utf8ToIso 25
div_getAge 25
div_writeTagParams 25
div_checkVarType 25
div_cleanArray 26
div_baseURL 26
div_vCardCreate 26
div_vCardFileParse 27
div_str2list 28
div_array2list 28
div_output 28
div_xml2array 29
div_array2xml 29
div_crop 30
div_week2date 30
div_numberInRange 30
div_rgb2hsl 31
div_hsl2rgb 31
div_rgb2hsv 31
div_hsv2rgb 32
div_hsl2hsv 32
div_hsv2hsl 33
div_createHexColor 33
div_modifyHexColor 33
div_formatXHTML 34
div_convertLineBreaks 34
div_checkArrayKeys 34
div_rmdir 35
div_isType 36
Section 6 - Debug 37
About this section 37
viewArray 37
debug 37
Known problems 38
To-Do list 38
Changelog 39
Introduction¶
About this API¶
The goal of this API is to provide to the Typo3 developers community some useful functions, to help in the process of extension development. It includes functions, for frontend, backend, databases and miscellaneous development. It's not here to replace any of the existing Typo3 core class or function. It just try to complete them by providing a quick way to develop extensions, and to produce code.
Why another API?¶
Typo3 comes with a bunch of wonderful functions. But for new developers, it may be hard to get the whole picture with extensions, classes hierarchy, etc. That was the case for me when I begun working with Typo3, and it's still the case now for a lot of things.
However, when I begun to develop extensions, I quickly realized that I often had to use the same functions inside my classes, or adapt previously build functions for a specific need. So I decided, for all of my extensions, to build another one, containing all the generic functions I use very frequently, and to make a dependencies to that big one. So now I can access my own functions from everywhere, without having to include them. It's just a gain of time to me, and it help me to keep my code clean and upgradeable easily.
In the logic of OpenSource, I also decided to make this API public, as it may help some people. I really hope it will.
How to use this API¶
The API is divided into six main sections. The first one is for the internal class processing, the second one for frontend development (all the functions are prefixed with fe_), the third one for backend development (prefix be_), the fourth for database queries (prefix db_), the fifth for miscellaneous development (prefix div_), and the last one for debugging (no prefix).
You'll find in this manual a complete reference of the class. Be sure to read carefully the description of the class constructor, just below. It will teach you how to use this API in your own extensions. Without this step, you won't be able to use most of the functions, as the class needs, except for some cases, to be instantiated in a special way, to ensure to usability of the API functions.
PHP 5 classes¶
Introduction¶
Since version 4.0, this API contains classes that can be used only with PHP5. You can instantiate them «by hand», or use the recommended getPhp5Class method of the API, which will make sure that PHP5 is available.
Each class is for a specific purpose, and is described below.
tx_apimacmade_flexform¶
About¶
The goal of this class is to simplify the use of flexform fields. It will allows you to easily access to every field contained in a flexform, without having to use the xml2array method from the t3lib_div class, which produces an huge multidimensionnal array which is hard to work with.
Usage¶
The only thing you have to do is the creates a new instance of the class, and pass the XML data of the flexform to the constructor.
Here's an example:
::¶
a
// Gets the flexform helper with some flexform data from a database record
$flexHelper = tx_apimacmade::getPhp5Class( 'flexform', array( $row[ 'flexform_field' ] ) );
Then you can access any flexform field directly:
::¶
a
$myFieldValue = $flexHelper->myFieldName;
You can also do a loop on the object to get each flexform field
::¶
a
foreach( $flexHelper as $fieldName => $fieldValue ) {
// ... do something ...
}
If you are working with multiple sheets or languages in your flexform, you can set which sheet or language will be used when getting a field value:
::¶
a
$flexHelper->setDefaultSheet( 'sDEF' );
$flexHelper->setDefaultLang( 'lDEF' );
$flexHelper->setDefaultValue( 'vDEF' );
Or you can use the getFieldValue() method (note that the three last arguments are optional):
::¶
a
$myFieldValue = $flexHelper->getFieldValue( 'myFieldName', 'sDEF', 'lDEF', 'vDEF' );
This class also works if you use sections in your flexforms. The only difference is that the return of a section field is an array containing sub-objects, that you will be able to use as the first one. Also note that if you cast a section item object as a string, you will get the item type:
::¶
a
// Process each base field of the flexform
foreach( $flexHelper as $fieldName => $fieldValue ) {
// Checks if we have a section field
if( is_array( $fieldValue ) ) {
// Process each section item
foreach( $fieldValue as $sectionItem ) {
// Gets the item type
$itemType = ( string )$sectionItem;
// Gets each sub-field of the current item
foreach( $sectionItem as $sectionItemFieldName => $sectionItemFieldValue ) {
// ... do something ...
}
}
} else {
// ... processing for normal fields ...
}
}
JavaScript¶
Introduction¶
This API provides several JavaScript files that can be included either in the TYPO3 frontend, or in the backend.
Available scripts includes:
Prototype
Mootools
Scriptaculous
LightBox
UFO (Universal Flash Object)
SWF Object
WebToolKit Base64
WebToolKit CRC32
WebToolKit MD5
WebToolKit SHA1
WebToolKit SHA256
WebToolKit URL Encode
WebToolKit UTF-8
Each one has a method to include the script, that you can use in your extensions. Of course, if one script is already included, a second call to the include method won't include it another time.But as many other TYPO3 extensions uses and includes the same scripts, you also have to possibility to avoid loading a particular script from this API.For instance, imagine that you have on the same page two extensions that use the Prototype JS script. The first one includes Prototype from this API, and the second one uses a local version. Then, the Prototype script will be loaded twice.In such a case, you can deactivate the inclusion of Prototype for that page, as it's already included by the other extension.
This is done through the constant editor. Each script can be deactivated separately:
Section 1 - Internal¶
About this section¶
Functions for the initialization of the class.¶
Those functions are the core of this API. Except the class constructor, they are all reserved for internal use.
tx_apimacmade¶
Class constructor.¶
This function can't be called by t3lib_div::makeInstance, since it needs the parent object to be passed as an argument. Sorry about that.
When you call the constructor, do not forget to set the $apimacmade_version class variable, as it will be used for version checking. Read the example below to find out more.
Return¶
Void.
Example¶
Heres how to use this API in your own extensions. First, you'll need to include the API class in your extension (line 5). This is done like this (all of following example are in a frontend plugin context, but the procedure is the same for every development context):
a
1:
2:
3:
4:
5:
6:
7:
b
// Typo3 FE plugin class
require_once(PATH_tslib.'class.tslib_pibase.php');
// API class
require_once(t3lib_extMgm::extPath('api_macmade').'class.tx_apimacmade.php');
class tx_myextension_pi1 extends tslib_pibase {
Then you need to define a class variable (line 13):
a
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
b
class tx_myextension_pi1 extends tslib_pibase {
// Same as class name
var $prefixId = 'tx_myextension_pi1';
// Path to this script relative to the extension dir
var $scriptRelPath = 'pi1/class.tx_myextension_pi1.php';
// The extension key
var $extKey = 'myextension';
// API version
var $apimacmade_version = 1.0;
It's used to check the version of the API. Let's say you have made an extension which uses the version 1.1 of this API, and that you have set the version variable consequently. If a user try to use your extension with an older version of the API, he may get some problems, as some functions may not be present. So with this variable, the user will just get a page saying he should upgrade to the required version (1.1 in that case). It's a way to protect your work from errors dues to an old version.
The last step is to instantiate the API class. You can't do that by calling t3lib_div::makeInstance, as the class constructor needs an argument to be passed. So here's how we do this (line 4):
a
1:
2:
3:
4:
b
function main($content,$conf) {
// New instance of the API
$this->api = new tx_apimacmade($this);
Most often, it's a good idea to set the API object as a class variable, like in this example, to allow you to use API function from any of your functions. The parameter of the constructor must be always be $this. It will allow the API to reach your own variables by itself, and to use all of the Typo3 core functions available in your context.
Then, you're done. You can use the function you need, just like that, for example:
a
1:
b
$this->api->debug('Hello World!');
In this manual, we are going to use $this->api for the API object, in the examples. You're of course free to name that object as you want.
versionError¶
errorMsg¶
Produce an error message.¶
This function is used to produce an error message, if another function report a problem, often caused by bad argument types.
Parameters¶
Parameter
$method
Default value
Description
The name of the method
Parameter
$message
Default value
Description
The error message to display
Parameter
$line
Default value
Description
The line number
Return¶
Void.
getPhp5Class¶
Gets a PHP 5 class.¶
This function is used to load an PHP5 class contained in this API.
Parameters¶
Parameter
$name
Default value
Description
The name of the component to load
Parameter
$args
Default value
array()
Description
An array with the arguments to pass to the constructor (5 maximum)
Return¶
An instance of the requested class.
newInstance¶
Returns a new instance of a class.¶
This method does basically the same stuff as the makeInstance method from t3lib_div, except the fact that this one can take arguments that will be passed to the class constructor.
Parameters¶
Parameter
$className
Default value
Description
The name of the class
Parameter
$args
Default value
array()
Description
An array with the arguments to pass to the constructor (5 maximum)
Return¶
An instance of the requested class.
Section 2 - FrontEnd¶
About this section¶
Functions for frontend development.¶
All of those functions are only available in a frontend context. They also all need the API class to be instantiated, as they will use the internal variable $pObj.
Do not try to use them out of a frontend context, and without the API class instantiated.
fe_mergeTSconfFlex¶
Merge plugin TS configuration with flexform configuration.¶
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.
Parameters¶
Parameter
$mapArray
Default value
Description
The mapping array with informations about values to replace
Parameter
$tsArray
Default value
Description
The initial TS configuration array
Parameter
$flexRes
Default value
Description
The flexform object (usually $this->pObj->cObj->data['pi_flexform'])
Return¶
The merged configuration array.
Examples¶
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:
a
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
b
// 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:
a
1:
2:
3:
4:
5:
6:
7:
8:
b
// 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.
fe_initTemplate¶
fe_renderTemplate¶
Template rendering.¶
This function analyzes the template C-Object, previously set by $this->fe_initTemplate and substitute the specified section with the specified subsections.
Parameters¶
Parameter
$templateMarkers
Default value
Description
The markers array
Parameter
$templateSection
Default value
Description
The section to substitute
Return¶
The processed template section.
Examples¶
Here's an example HTML template:
a
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
b
<!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:
a
1:
2:
3:
4:
5:
6:
7:
8:
b
// Template markers
$templateMarkers = array(
'###WORLD###' => 'Hello World!',
'###UNIVERSE###' => 'Hello Universe!',
);
// Render template
$content = $this->api->fe_renderTemplate($templateMarkers,'###HELLO###');
fe_makeStyledContent¶
Returns the content with CSS.¶
This function is used to output the requested content wrapped in an HTML element, containing a CSS class.
Parameters¶
Parameter
$element
Default value
Description
The HTML element to produce.
Parameter
$className
Default value
Description
The CSS class name to link.
Parameter
$content
Default value
false
Description
The content to wrap.
Parameter
$piClass
Default value
1
Description
Prepends class name with plugin name (using pi_classParam).
Parameter
$htmlSpecialChars
Default value
false
Description
Pass the content through htmlspecialchars().
Parameter
$startTagOnly
Default value
false
Description
Generate only the starting tag (without content!).
Parameter
$params
Default value
array()
Description
The parameters of the HTML element as key/value pairs.
Return¶
The CSS styled content.
fe_setInternalVars¶
Sets internals variables.¶
This function is used to set the internal variables array ($this->pObj->internal) needed to execute a MySQL query.
Parameters¶
Parameter
$results_at_a_time
Default value
false
Description
The maximum number of records to display in a list view.
Parameter
$maxPages
Default value
false
Description
The maximum number of pages to display in the browsebox.
Parameter
$searchFieldList
Default value
false
Description
The fields available for searching.
Parameter
$orderByList
Default value
false
Description
The fields available to use as ORDER BY parameter.
Return¶
Void.
fe_buildSwapClassesJSCode¶
fe_makeSwapClassesJSLink¶
Returns a swapClasses link.¶
This function is used to output the requested content wrapped in an HTML link element calling the swapClasses JS function.
Parameters¶
Parameter
$elementId
Default value
Description
The ID of the HTML element to change.
Parameter
$content
Default value
false
Description
The content to wrap.
Parameter
$htmlSpecialChars
Default value
false
Description
Pass the content through htmlspecialchars().
Parameter
$startTagOnly
Default value
false
Description
Generate only the starting tag (without content!).
Parameter
$params
Default value
array()
Description
The attributes of the HTML element as key/value pairs.
Return¶
The swap classes link.
fe_createImageObjects¶
Create IMAGE cObjects.¶
This function creates an IMAGE cObject for each given filename.
This function is particularly useful with image references stored in a database field.
Parameters¶
Parameter
$imgRefs
Default value
Description
A comma list of picture names.
Parameter
$conf
Default value
Description
The TS setup for the images.
Parameter
$imgPath
Default value
false
Description
The path of the images (will be prepended to each picture name).
Return¶
An IMAGE cObject for each picture.
fe_linkTP¶
Link a string to some page.¶
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, and that it will always returns a correct cHash.
Parameters¶
Parameter
$str
Default value
Description
The content string to wrap in <a> tags.
Parameter
$urlParameters
Default value
array()
Description
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.
Parameter
$cache
Default value
0
Description
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.
Parameter
$altPageId
Default value
0
Description
Alternative page ID for the link (by default this function links to the SAME page!).
Parameter
$conf
Default value
array()
Description
An optionnal array for the typolink configuration.
Return¶
The input string wrapped in <a> tags.
fe_linkTP_keepPIvars¶
Link a string to some page.¶
This method is the same as method fe_linkTP_keepPIvars of tslib_piBase, except the fact that it will always return a correct cHash.
Parameters¶
Parameter
$str
Default value
Description
The content string to wrap in <a> tags.
Parameter
$overrulePIvars
Default value
array()
Description
Array of values to override or add in the current piVars.
Parameter
$cache
Default value
0
Description
Ask the page to be cached by a &cHash value.
Parameter
$clearAnyway
Default value
0
Description
Do not preserve current piVars.
Parameter
$altPageId
Default value
0
Description
Alternative page ID for the link.
Return¶
The input string wrapped in <a> tags.
See also¶
fe_linkTP
fe_linkTP_keepPIvars_url¶
Returns an URL to some page.¶
This method is the same as method pi_fe_linkTP_keepPIvars_url of tslib_piBase, except the fact that it will always return a correct cHash.
Parameters¶
Parameter
$overrulePIvars
Default value
array()
Description
Array of values to override or add in the current piVars.
Parameter
$cache
Default value
0
Description
Ask the page to be cached by a &cHash value.
Parameter
$clearAnyway
Default value
0
Description
Do not preserve current piVars.
Parameter
$altPageId
Default value
0
Description
Alternative page ID for the link.
Return¶
The complete URL.
See also¶
fe_linkTP_keepPIvars
fe_linkTP_unsetPIvars¶
Link a string to some page.¶
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.
Parameters¶
Parameter
$str
Default value
Description
The content string to wrap in <a> tags.
Parameter
$overrulePIvars
Default value
array()
Description
Array of values to override or add in the current piVars.
Parameter
$unsetPIvars
Default value
array()
Description
Array of values not to include in the current piVars.
Parameter
$cache
Default value
0
Description
Ask the page to be cached by a &cHash value.
Parameter
$clearAnyway
Default value
0
Description
Do not preserve current piVars.
Parameter
$altPageId
Default value
0
Description
Alternative page ID for the link.
Return¶
The input string wrapped in <a> tags.
See also¶
fe_linkTP_keepPIvars
fe_linkTP_unsetPIvars_url¶
Returns an URL to some page.¶
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.
Parameters¶
Parameter
$overrulePIvars
Default value
array()
Description
Array of values to override or add in the current piVars.
Parameter
$unsetPIvars
Default value
array()
Description
Array of values not to include in the current piVars.
Parameter
$cache
Default value
0
Description
Ask the page to be cached by a &cHash value.
Parameter
$clearAnyway
Default value
0
Description
Do not preserve current piVars.
Parameter
$altPageId
Default value
0
Description
Alternative page ID for the link.
Return¶
The complete URL.
See also¶
fe_linkTP_keepPIvars_url
fe_typoLinkParams¶
Builds parameters for a typoLink.¶
This method is used to build the 'additionalParams' TypoScript option. Each parameter of the array will be formed as a piVar (prefixed with pObj->prefixId).
Parameters¶
Parameter
$params
Default value
array()
Description
An associative array with the URL parameters.
Parameter
$keepPiVars
Default value
true
Description
If this is true, the piVars will be kept
Return¶
The additional parameters ready for a typoLink.
fe_initFeAdmin¶
Init the FE-Admin script for frontend input.¶
This function adds all the configuration necessary to use fe_adminLib to the plugin configuration array.
Parameters¶
Parameter
$conf
Default value
Description
The plugin configuration array.
Parameter
$table
Default value
Description
The table to use.
Parameter
$pid
Default value
Description
The pid for the records.
Parameter
$feAdminConf
Default value
Description
The configuration array for fe_adminLib subparts.
Parameter
$create
Default value
1
Description
Create capabilities (Boolean).
Parameter
$edit
Default value
0
Description
Edit capabilities (Boolean).
Parameter
$delete
Default value
0
Description
Delete capabilities (Boolean).
Parameter
$infomail
Default value
0
Description
Infomail capabilities (Boolean).
Parameter
$fe_userOwnSelf
Default value
0
Description
FE-Users own themselves (Boolean).
Parameter
$fe_userEditSelf
Default value
0
Description
FE-Users can edit themselves (Boolean).
Parameter
$debug
Default value
0
Description
Output debug informations (Boolean).
Parameter
$defaultCmd
Default value
'create'
Description
The default command to use if none is found.
Parameter
$confKey
Default value
'fe_adminLib'
Description
The key to use for fe_adminLib in the plugin configuration array.
Return¶
The complete plugin configuration array with a valid fe_adminLib configuration.
fe_createInput¶
Creates an input.¶
This function creates an HTML input tag, ready for a usage with fe_adminLib.
Parameters¶
Parameter
$type
Default value
Description
The type of the input.
Parameter
$name
Default value
Description
The name of the input (field).
Parameter
$feAdminConf
Default value
Description
The fe_adminLib configuration array.
Parameter
$feAdminSection
Default value
Description
The fe_adminLib section (usually create or edit) - Used to check for required fields.
Parameter
$number
Default value
1
Description
The number of imput to create.
Parameter
$params
Default value
array()
Description
The input tag parameters (depending of context) as an array with key/value pairs.
Parameter
$defaultValue
Default value
0
Description
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.).
Parameter
$defaultChecked
Default value
0
Description
For checkboxes or radios, if the input must be checked by default. Can be a comma list for multiple checkboxes.
Parameter
$keepSentValues
Default value
1
Description
Keep element value if the form is redrawn (will override default value or default checked).
Parameter
$langPrefix
Default value
'pi_feadmin_'
Description
The prefix for the plugin locallangfile. Used to fetch the title of the input and the warning message, if applicable.
Parameter
$headerSeparation
Default value
'<br />'
Description
The separation between the title and the input.
Return¶
A complete form element, with title, warning, and the input itself.
fe_createTextArea¶
Creates a text area.¶
This function creates an HTML <textarea> tag for use with the fe_adminLib script.
Parameters¶
Parameter
$name
Default value
Description
The name of the textarea (field).
Parameter
$feAdminConf
Default value
Description
The fe_adminLib configuration array.
Parameter
$feAdminSection
Default value
Description
The fe_adminLib section (usually create or edit) - Used to check for required fields.
Parameter
$params
Default value
array()
Description
The textarea tag parametersas an array with key/value pairs.
Parameter
$defaultValue
Default value
0
Description
The default value for the textarea.
Parameter
$keepSentValues
Default value
1
Description
Keep element value if the form is redrawn (will override default value).
Parameter
$langPrefix
Default value
'pi_feadmin_'
Description
The prefix for the plugin locallangfile. Used to fetch the title of the textarea and the warning message, if applicable.
Parameter
$headerSeparation
Default value
'<br />'
Description
The separation between the title and the textarea.
Return¶
A complete textarea zone, with title and warning.
fe_createSelect¶
Creates a select.¶
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).
Parameters¶
Parameter
$name
Default value
Description
The name of the select (field).
Parameter
$feAdminConf
Default value
Description
The fe_adminLib configuration array.
Parameter
$feAdminSection
Default value
Description
The fe_adminLib section (usually create or edit) - Used to check for required fields.
Parameter
$options
Default value
Description
The options to create.
Parameter
$htmlspecialchars
Default value
1
Description
Pass the option labels through htmlspecialchars().
Parameter
$params
Default value
array()
Description
The select tag parameters as an array with key/value pairs.
Parameter
$keepSentValues
Default value
1
Description
Keep element value if the form is redrawn.
Parameter
$langPrefix
Default value
'pi_feadmin_'
Description
The prefix for the plugin locallangfile. Used to fetch the title of the select and the warning message, if applicable.
Parameter
$headerSeparation
Default value
'<br />'
Description
The separation between the title and the select.
Return¶
A complete select, with title and warning.
fe_createSelectFromTable¶
Creates a select from a table.¶
This function creates an HTML select tag for use with the fe_adminLib script. Values and labels are taken from an external table.
Parameters¶
Parameter
$name
Default value
Description
The name of the select (field).
Parameter
$feAdminConf
Default value
Description
The fe_adminLib configuration array.
Parameter
$feAdminSection
Default value
Description
The fe_adminLib section (usually create or edit) - Used to check for required fields.
Parameter
$table
Default value
Description
The table containing the records (must be a valid Typo3 table).
Parameter
$pidList
Default value
Description
The pages from where to select the records (as a comma list).
Parameter
$labelField
Default value
Description
The field in the database to use as option label.
Parameter
$valueField
Default value
'uid'
Description
The field in the database to use as option value (usually UID).
Parameter
$htmlspecialchars
Default value
1
Description
Pass the option labels through htmlspecialchars().
Parameter
$addWhere
Default value
''
Description
Optional additional WHERE clauses put in the end of the query.
DO NOT PUT IN GROUP BY, ORDER BY or LIMIT!
Parameter
$groupBy
Default value
''
Description
Optional GROUP BY field(s), if none, supply blank string.
Parameter
$orderBy
Default value
''
Description
Optional ORDER BY field(s), if none, supply blank string.
Parameter
$limit
Default value
''
Description
Optional LIMIT value ([begin,]max), if none, supply blank string.
Parameter
$params
Default value
array()
Description
The select tag parameters as an array with key/value pairs.
Parameter
$keepSentValues
Default value
1
Description
Keep element value if the form is redrawn.
Parameter
$langPrefix
Default value
'pi_feadmin'
Description
The prefix for the plugin locallangfile. Used to fetch the title of the select and the warning message, if applicable.
Parameter
$headerSeparation
Default value
'<br />'
Description
The separation between the title and the select.
Return¶
A complete select, with title and warning.
fe_buildFormElementHeader¶
Returns a form element header.¶
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.
Parameters¶
Parameter
$name
Default value
Description
The name of the field.
Parameter
$langPrefix
Default value
Description
The prefix to use to get the field title in the locallang file.
Parameter
$headerSeparation
Default value
Description
The separation to use between the header and the form element.
Parameter
$requiredFieldList
Default value
false
Description
A comma list of the required fields of the feAdmin section.
Parameter
$evalValues
Default value
array()
Description
The evalValues array from the feAdmin configuration array.
Return¶
The header zone.
fe_buildLoginBox¶
Build a login box.¶
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.
Parameters¶
Parameter
$pid
Default value
Description
The PID of the sysfolder containing the frontend users allowed to login.
Parameter
$inputSize
Default value
30
Description
The size of the inputs to generate.
Parameter
$method
Default value
'POST'
Description
The method of the form object used for sending variables.
Parameter
$target
Default value
'_self'
Description
The target of the form object.
Parameter
$wrap
Default value
false
Description
Wrap the whole object.
Parameter
$layout
Default value
false
Description
The layout of the form object.
Parameter
$langPrefix
Default value
'pi_loginbox_'
Description
The prefix to use to get the field title in the locallang file.
Parameter
$permaLogin
Default value
false
Description
Show permalogin option (needs extension 'core_permalogin').
Parameter
$asTsArray
Default value
false
Description
Returns the TS array, not the HTML code.
Return¶
A login box.
See also¶
fe_makeStyledContent
fe_buildSearchBox¶
Build a search box.¶
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.
Parameters¶
Parameter
$method
Default value
post
Description
The method for the search form (get or post).
Parameter
$nocache
Default value
true
Description
Add a no cache flag.
Parameter
$sword
Default value
'sword'
Description
The sword variable in piVars.
Parameter
$pointer
Default value
'pointer'
Description
The pointer variable in piVars.
Return¶
A search box.
See also¶
fe_makeStyledContent
fe_buildBrowseBox¶
Build a browse box.¶
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.
Parameters¶
Parameter
$pointer
Default value
post
Description
The pointer variable in piVars.
Parameter
$count
Default value
true
Description
The SQL count ressource in PI internal variables.
Parameter
$maxResults
Default value
'sword'
Description
The max results number in PI internal variables.
Parameter
$maxPages
Default value
'pointer'
Description
The max pages number in PI internal variables.
Return¶
A browse box.
See also¶
fe_makeStyledContent
fe_includePrototypeJs¶
fe_includeMootoolsJs¶
fe_includeScriptaculousJs¶
fe_includeLightBoxJs¶
Includes the lightbox script.¶
This function includes the lightbox JavaScript by adding a script tag to the TYPO3 page headers. This method can only be used in a frontend context.
Parameters¶
Parameter
$includeCss
Default value
true
Description
If set, the default lightbox CSS styles will be included.
Return¶
Boolean.
See also¶
fe_includeScriptaculousJs
fe_includeUfo¶
fe_includeSwfObject¶
fe_includeWebToolKitJs¶
Section 3 - BackEnd¶
About this section¶
Functions for backend development.¶
All of those functions are only available in a backend context. They also all need the API class to be instantiated, as they will use the internal variable $pObj.
Do not try to use them out of a backend context, and without the API class instantiated.
be_buildRecordIcons¶
Build action icons.¶
This function creates the icon(s) associated with an action to do on a record. Compatible with Typo3 skinning functions.
Parameters¶
Parameter
$actions
Default value
Description
The action(s) to produce, as a comma list (can be 'show', 'edit' or 'delete' at the moment).
Parameter
$table
Default value
Description
The table of the record.
Parameter
$uid
Default value
Description
The record uid.
Return¶
The record icons
be_buildPageTreeSelect¶
be_getSelectStyleRecordIcon¶
be_initCSM¶
be_getRecordCSMIcon¶
be_includePrototypeJs¶
be_includeMootoolsJs¶
be_includeScriptaculousJs¶
be_includeLightBoxJs¶
Includes the lightbox script.¶
This function includes the lightbox JavaScript by adding a script tag to the TYPO3 page headers. This method can only be used in a backend context.
Parameters¶
Parameter
$includeCss
Default value
true
Description
If set, the default lightbox CSS styles will be included.
Return¶
Boolean.
See also¶
fe_includeScriptaculousJs
be_includeUfo¶
be_includeSwfObject¶
be_includeWebToolKitJs¶
Section 4 - Database¶
About this section¶
db_table2text¶
Export a database table to text format.¶
This function returns a database table contents as a formatted text variable. By default, it generates a tabulated text file.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$table
Default value
Description
The table to export.
Parameter
$fieldList
Default value
'*'
Description
The list of fields to select from the table.
Parameter
$whereClause
Default value
''
Description
Optional WHERE clauses put in the end of the query, if none, supply blank string.
Parameter
$groupBy
Default value
''
Description
Optional GROUP BY field(s), if none, supply blank string.
Parameter
$orderBy
Default value
''
Description
Optional ORDER BY field(s), if none, supply blank string.
Parameter
$limit
Default value
''
Description
Optional LIMIT value ([begin,]max), if none, supply blank string.
Parameter
$sepField
Default value
9
Description
The ASCII separator character for each field.
Parameter
$sepRow
Default value
10
Description
The ASCII separator character for each row.
Parameter
$directOut
Default value
0
Description
Output the generated file directly as a text file.
Parameter
$directOutCharset
Default value
'iso-8859-1'
Description
The charset for the output file.
Return¶
The formatted database table contents.
See also¶
div_output
db_table2xml¶
Export a database table to XML format.¶
This function returns a database table contents as an XML object.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$table
Default value
Description
The table to export.
Parameter
$fieldList
Default value
'*'
Description
The list of fields to select from the table.
Parameter
$whereClause
Default value
''
Description
Optional WHERE clauses put in the end of the query, if none, supply blank string.
Parameter
$groupBy
Default value
''
Description
Optional GROUP BY field(s), if none, supply blank string.
Parameter
$orderBy
Default value
''
Description
Optional ORDER BY field(s), if none, supply blank string.
Parameter
$limit
Default value
''
Description
Optional LIMIT value ([begin,]max), if none, supply blank string.
Parameter
$uppercase
Default value
0
Description
Use uppercase for XML tags.
Parameter
$xmlDeclaration
Default value
1
Description
Insert XML declaration.
Parameter
$xmlVersion
Default value
'1.0'
Description
The XML version.
Parameter
$xmlEncoding
Default value
'iso-8859-1'
Description
The XML encoding.
Parameter
$directOut
Default value
1
Description
Output the generated file directly as an XML file.
Parameter
$ns
Default value
false
Description
The XML namespace.
Parameter
$nsPrefix
Default value
'ns'
Description
The prefix used in the XML to link elements to the namespace.
Return¶
The database table contents as XML nodes.
See also¶
div_output
Examples¶
Here's the kind of output you will get:
a
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
b
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
- Typo3 XML Export
-
- Generation Time: Thu, 25 Nov 2004 23:00:00 +0100
-
- Host: localhost
- Database: typo3_db
- Table: fe_users
-->
<typo3_db>
<fe_users>
<uid>1</uid>
<username>admin</username>
</fe_users>
<fe_users>
<uid>2</uid>
<username>macmade</username>
</fe_users>
<typo3_db>
This example has been generated with the following command:
a
1:
2:
b
// Export fe_users
$this->api->table2xml('fe_users','uid,username');
Section 5 - Miscellaneous¶
About this section¶
General purposes functions for miscellaneous development.¶
Those functions are available in any context. You also don't need the instantiate the API class to use them, as they don't need a parent object.
div_utf8ToIso¶
div_getAge¶
Returns an age.¶
This function returns an age, calculated from a timestamp. By default, the function takes the current time as reference, but another timestamp can be specified. The function also returns by default the age in days, but it can also returns it in seconds, minutes or hours.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$tstamp
Default value
Description
The base timestamp.
Parameter
$currentTime
Default value
false
Description
The time from which to calculate the age (timestamp). Will use current time if none supplied.
Parameter
$ageType
Default value
false
Description
The type of age to return (seconds, minutes, hours, or days).
Return¶
An age, as a numeric value.
div_writeTagParams¶
Write tag parameters.¶
This function write, from an array, every given key, with it's value, as an HTML tag parameter.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parametes¶
Parameter
$params
Default value
Description
An array with the tag parameters as key/value pairs.
Return¶
A string with all tag parameters formatted as HTML
div_checkVarType¶
Check for valid variables.¶
This function checks for the type of multiples variables, passed in an array. It's used to check with one function call multiple variable which should be of the same type.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$vars
Default value
Description
An array with the variables to check.
Parameter
$type
Default value
'array'
Description
The type of the variables to check for.
Return¶
True if every variable in the input array correspond to the given type.
div_cleanArray¶
Clean an array¶
This function process an array and removes all the keys given as second parameter. It can also keep only the given keys if the $inverse parameter is set.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$input
Default value
Description
The array to process.
Parameter
$keys
Default value
Description
A comma list of the keys to remove or keep in the input array.
Parameter
$inverse
Default value
0
Description
If reverse is set, the function will keep only the keys supplied in the array. Otherwise, it will remove them.
Return¶
A cleaned array.
div_baseURL¶
Returns a base URL.¶
This function is used to get only the host part of an URL.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$url
Default value
Description
The URL to process.
Parameter
$trailingSlash
Default value
1
Description
If set, add a slash after the base URL.
Return¶
A base URL.
div_vCardCreate¶
Create a vCard.¶
This function produces a vCard (.vcf format) from an array.
Here's an example input array:
::¶
a
array(
'firstname' => string // First name
'name' => string // Last name
'username' => string // Nick name
'company' => string // Company
'department' => string // Department
'title' => string // Job title
'www' => string // Home page
'note' => string // Notes
'birthday' => tstamp // Birtday
'email' => array(
array(
'mail' => string // Email address
'type' => string // Type (WORK - HOME – Other)
)
)
'phone' => array(
array(
'number' => string // Number
'type' => string // Type (WORK - HOME - CELL - MAIN - HOMEFAX - WORKFAX – Other)
)
)
'messenger' => array(
array(
'name' => string // Account name
'service' => string // Service (AIM - JABBER - MSN - YAHOO – ICQ)
'type' => string // Type (WORK - HOME – Other)
)
)
'address' => array(
array(
'street' => string // Street
'city' => string // City
'state' => string // State
'zip' => string // ZIP code
'country' => string // Country
'type' => string // Type (WORK - HOME – Other)
)
)
'image' => string // Picture reference
'iscompany' => boolean // Define as company
)
The image must be a valid path to an image. It will be read and encoded in base64 chunks.
To create a pack of vCards, just call this function the number of time necessary, and concatenate the results.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$user
Default value
Description
The user array.
Parameter
$version
Default value
'3.0'
Description
The vCard version.
Parameter
$charset
Default value
false
Description
An optionnal charset to use for the properties.
Return¶
The vCard content, ready for output.
div_vCardFileParse¶
Parse avCard (or a pack of vCards).¶
This function produis used to parse a vCard, or a pack of vCard, and to produce a multi-dimensionnal array with all the vCard informations. The array produced is exactly the same kind of array that must be passed to the div_vCardCreate function of this API. So the two functions are compatible.
If a vCard has an embed base65 encoded image, it's decoded, and a temporary image file is created in typo3temp/. The file reference is then included in the output array.
SPECIAL NOTE: This function can be called without the API class instantiated.
Return¶
An array containing all the vCard(s) informations.
div_str2list¶
Create an HTML list from a string.¶
This function produces an HTML list element (UL or OL) from a string, using a separator to get each list item.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$string
Default value
Description
The string to convert.
Parameter
$sep
Default value
','
Description
The separator used to get list items.
Parameter
$htmlspecialchars
Default value
1
Description
Pass the item through htmlspecialchars().
Parameter
$listType
Default value
'ul'
Description
The type of list to produce (UL, OL).
Parameter
$listParams
Default value
array()
Description
The parameters of the list tag as key/value pairs.
Parameter
$itemsParams
Default value
array()
Description
The parameters of the list items tag as key/value pairs.
Return¶
An HTML list.
See also¶
div_writeTagParams
div_array2list¶
Create an HTML list from an array.¶
This function produces an HTML list element (UL or OL) from an array.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$inputArray
Default value
Description
The array to convert.
Parameter
$htmlspecialchars
Default value
1
Description
Pass the item through htmlspecialchars().
Parameter
$listType
Default value
'ul'
Description
The type of list to produce (UL, OL).
Parameter
$listParams
Default value
array()
Description
The parameters of the list tag as key/value pairs.
Parameter
$itemsParams
Default value
array()
Description
The parameters of the list items tag as key/value pairs.
Return¶
An HTML list.
See also¶
div_writeTagParams
div_output¶
Output some content.¶
This function is used to output content with a specified type, as attachment for example. You can get a list of all the available type at the following address:
http://www.openmobilealliance.org/tech/omna/omna-wsp-content-type.htm
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$out
Default value
Description
The content to output.
Parameter
$cType
Default value
Description
The content type.
Parameter
$fName
Default value
Description
The name of the file to output.
Parameter
$cDisp
Default value
'attachment'
Description
The content disposition.
Parameter
$charset
Default value
'utf-8'
Description
The charset to use for the output.
Return¶
Void.
div_xml2array¶
Convert XML data to an array.¶
This function is used to convert an XML data to a multi-dimensionnal array, representing the structure of the data.
This function is based on the Typo3 array2xml function, in t3lib_div. It basically does the same, but has a few more options, like the inclusion of the xml tags arguments in the output array. This function also has support for same multiple tag names inside the same XML element, which is not the case with the core Typo3 function. In that specific case, the array keys are suffixed with '-N', where N is a numeric value.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$data
Default value
Description
The XML data to process.
Parameter
$keepAttribs
Default value
1
Description
If set, also includes the tag attributes in the array (with key 'xml- attribs').
Parameter
$caseFolding
Default value
0
Description
XML parser option: case management.
Parameter
$skipWhite
Default value
0
Description
XML parser option: white space management.
Parameter
$prefix
Default value
false
Description
A tag prefix to remove.
Parameter
$numeric
Default value
'n'
Description
Keep only the numeric value for a tag prefixed with this argument (default is 'n').
Parameter
$index
Default value
'index'
Description
Set the tag name to an alternate value found in the tag arguments (default is 'index').
Parameter
$type
Default value
'type'
Description
Force the tag value to a special type, found in the tag arguments (default is 'type').
Parameter
$base64
Default value
'base64'
Description
Decode the tag value from base64 if the specified tag argument is present (default is 'base64').
Parameter
$php5defCharset
Default value
'iso-8859-1'
Description
The default charset to use with PHP5.
Return¶
An array with the XML structure, or an XML error message if the data is not valid.
div_array2xml¶
Convert an array to XML.¶
This function is used to convert a multi-dimensionnal array to XML code.
This is the reverse function of div_xml2array().
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$input
Default value
Description
The array to process.
Parameter
$xmlRoot
Default value
'phpArray'
Description
The name of the XML root element.
Parameter
$prefix
Default value
''
Description
A prefix for the tag names.
Parameter
$numeric
Default value
'item'
Description
The prefix for numeric keys.
Parameter
$numericAsAttribute
Default value
index
Description
Use an XML attribute to store numeric keys.
Parameter
$addArrayAttribute
Default value
type
Description
Add an XML attribute if the array value is an array.
Parameter
$xmlDeclaration
Default value
1
Description
Include XML declaration.
Parameter
$encoding
Default value
'iso-8859-1'
Description
XML declaration parameter: encoding.
Parameter
$version
Default value
'1.0'
Description
XML declaration parameter: version.
Parameter
$standalone
Default value
'yes'
Description
XML declaration parameter: standalone.
Parameter
$doctype
Default value
false
Description
The URL of the doctype.
Parameter
$newLine
Default value
10
Description
The new line character to use (through chr()).
Parameter
$indent
Default value
9
Description
The indentation character to use (through chr()).
Parameter
$level
Default value
0
Description
The level processed. Don't touch this, as it's used for the correct code indentation.
Return¶
An XML string.
div_crop¶
Crops a string.¶
This function is used to crop a string to a specified number of characters. By default, it crops the string after an entire word, and not in the middle of a word. It also strips by default all HTML tags before cropping, to avoid display problems.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$str
Default value
Description
The string to crop.
Parameter
$chars
Default value
Description
Number of characters.
Parameter
$endString
Default value
'...'
Description
The string to add after the cropped string.
Parameter
$crop2space
Default value
1
Description
Don't crop in a middle of a word.
Parameter
$stripTags
Default value
1
Description
Remove all HTML tags from the string.
Return¶
The cropped string.
div_week2date¶
Returns a timestamp.¶
This function returns a timestamp for a given year (XXXX), week number, and day number (0 is sunday, 6 is saturday).
Thanx to Nicolas Miroz (nmiroz@free.fr) for the informations about date computing.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$day
Default value
Description
The day number.
Parameter
$week
Default value
Description
The week number.
Parameter
$year
Default value
Description
The year.
Return¶
A timestamp.
div_numberInRange¶
Ensure a number is in a specified range.¶
This function forces the specified number into the boundaries of a minimum and maximum number.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$number
Default value
Description
The number to check.
Parameter
$min
Default value
Description
The minimum value.
Parameter
$max
Default value
Description
The maximum value.
Parameter
$int
Default value
false
Description
Evaluate value as an integer.
Return¶
A number in the specified range.
div_rgb2hsl¶
Converts RGB color values into HSL.¶
This function takes RGB (Red-Green-Blue) color values and converts them into HSL (Hue-Saturation-Luminance) color values. RGB values are from 0 to 255, and HSL values are returned in an array with associative keys. Note that the returned hue value is an angle (0-360), and the saturation and luminance are percentage (0-100).
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$R
Default value
Description
The red value (0-255).
Parameter
$G
Default value
Description
The green value(0-255).
Parameter
$B
Default value
Description
The blue value (0-255).
Parameter
$round
Default value
1
Description
Round final values.
Return¶
An array with HSL color values.
See also¶
div_numberInRange
div_hsl2rgb¶
Converts HSL color values into RGB.¶
This function takes HSL (Hue-Saturation-Luminance) color values and converts them into RGB (Red-Green-Blue) color values. This is the reverse function of div_rgb2hsl().
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$H
Default value
Description
The hue value (0-360).
Parameter
$S
Default value
Description
The saturation value(0-100).
Parameter
$L
Default value
Description
The luminance value (0-100).
Parameter
$round
Default value
1
Description
Round final values.
Return¶
An array with RGB color values.
See also¶
div_numberInRange
div_rgb2hsv¶
Converts RGB color values into HSV.¶
This function takes RGB (Red-Green-Blue) color values and converts them into HSv (Hue-Saturation-Value) color values. RGB values are from 0 to 255, and HSV values are returned in an array with associative keys. Note that the returned hue value is an angle (0-360), and the saturation and value are percentage (0-100).
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$R
Default value
Description
The red value (0-255).
Parameter
$G
Default value
Description
The green value(0-255).
Parameter
$B
Default value
Description
The blue value (0-255).
Parameter
$round
Default value
1
Description
Round final values.
Return¶
An array with HSV color values.
See also¶
div_numberInRange
div_hsv2rgb¶
Converts HSV color values into RGB.¶
This function takes HSV (Hue-Saturation-Value) color values and converts them into RGB (Red-Green-Blue) color values. This is the reverse function of div_rgb2hsv().
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$H
Default value
Description
The hue value (0-360).
Parameter
$S
Default value
Description
The saturation value(0-100).
Parameter
$V
Default value
Description
The value value (0-100).
Parameter
$round
Default value
1
Description
Round final values.
Return¶
An array with RGB color values.
See also¶
div_numberInRange
div_hsl2hsv¶
Converts HSL color values into HSV.¶
This function takes HSL (Hue-Saturation-Luminance) color values and converts them into HSV (Hue-Saturation-Value) color values.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$H
Default value
Description
The hue value (0-360).
Parameter
$S
Default value
Description
The saturation value(0-100).
Parameter
$L
Default value
Description
The luminance value (0-100).
Parameter
$round
Default value
1
Description
Round final values.
Return¶
An array with HSV color values.
div_hsv2hsl¶
Converts HSV color values into HSL.¶
This function takes HSV (Hue-Saturation-Value) color values and converts them into HSL (Hue-Saturation-Luminance) color values.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$H
Default value
Description
The hue value (0-360).
Parameter
$S
Default value
Description
The saturation value(0-100).
Parameter
$V
Default value
Description
The value value (0-100).
Parameter
$round
Default value
1
Description
Round final values.
Return¶
An array with HSL color values.
div_createHexColor¶
Create an hexadecimal color.¶
This function is used to create an hexadecimal color representation from RGB (Red-Green-Blue), HSL (Hue-Saturation-Luminance) or HSV (Hue- Saturation-Value) values.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$v1
Default value
Description
The first value (red or hue, depending of the method).
Parameter
$v2
Default value
Description
The second value (green or saturation, depending of the method).
Parameter
$v3
Default value
Description
The third value (blue, luminosity or value, depending of the method).
Parameter
$method
Default value
'RGB'
Description
The method to use for the color creation. Can be 'RGB', 'HSL' or 'HSV'.
Parameter
$uppercase
Default value
1
Description
Return value in uppercase.
Return¶
The hexadecimal value of the color.
div_modifyHexColor¶
Modify an hexadecimal color.¶
This function is used to modify an hexadecimal color representation by adding RGB (Red-Green-Blue), HSL (Hue-Saturation-Luminance) or HSV (Hue-Saturation-Value) values.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$color
Default value
Description
The original color (hexadecimal).
Parameter
$v1
Default value
Description
The first value (red or hue, depending of the method).
Parameter
$v2
Default value
Description
The second value (green or saturation, depending of the method).
Parameter
$v3
Default value
Description
The third value (blue, luminosity or value, depending of the method).
Parameter
$method
Default value
'RGB'
Description
The method to use for the color modification. Can be 'RGB', 'HSL' or 'HSV'.
Parameter
$uppercase
Default value
1
Description
Return value in uppercase.
Return¶
The hexadecimal value of the modified color.
div_formatXHTML¶
Reformat XHTML code.¶
This function is used to reformat XHTML code, with linebreaks and indentations. The code passed to this function MUST be XHTML compliant in order to be reformatted, as it will be parsed as XML! If this is not the case, the original code is return. Also note that if you have mixed content inside a tag (eg. cData & tags), the cData won't be preserved, as it will be interpreted as junk data by the XML parser!
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$xhtml
Default value
Description
The original XHTML code.
Parameter
$uppercase
Default value
0
Description
Render XHTML tags in uppercase.
Parameter
$newLine
Default value
10
Description
The new line character to use (through chr()).
Parameter
$indent
Default value
9
Description
The indentation character to use (through chr()),
Parameter
$level
Default value
0
Description
The level processed. Don't touch this, as it's used for the correct code indentation.
Return¶
The reformatted HTML code.
div_convertLineBreaks¶
Convert line breaks.¶
This function converts Macintosh & DOS line breaks to standard Unix line breaks. This means replacing CR (u000D / chr(13)) and CR + LF (u000D + u000A / chr(13) + chr(10)) by LF (u000A / chr(10)). It also replace LF + CR (u000A + u000D / chr(10) + chr(13)) sequences. By default, the function erases all ASCII null characters (u0000 / chr(0)).
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$text
Default value
Description
The text to process.
Parameter
$stripNull
Default value
1
Description
Erase ASCII null characters.
Return¶
The text with standard Unix line breaks.
div_checkArrayKeys¶
Check keys in a multidimensionnal array.¶
This function is used to check for specific keys in a multidimensionnal array.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$array
Default value
Description
The input array.
Parameter
$keys
Default value
Description
The keys to check for, as a commalist representing the array hierarchy.
Parameter
$allowEmpty
Default value
false
Description
If this is set, the function returns true even if the final array item has an empty value.
Parameter
$checkType
Default value
false
Description
The variable type to check for in the final array (array,bool,double,f inite,float,int,long,nan,null,numeric,object,real,scalar,string)
Return¶
Boolean.
div_rmdir¶
Remove a directory.¶
This function is used to delete a complete directory. If the permissions are OK, every file (which can be on subdirectories) is deleted. Then, all the subdirectories are deleted. This function is equivalent to a 'rm -rf' command, but in a more elegant way.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$path
Default value
Description
The path of the directory (absolute).
Parameter
$relative
Default value
0
Description
Path is relative to the Typo3 site, otherwise absolute.
Parameter
$cleaned
Default value
0
Description
Internal only! File cleaning has been processed.
Return¶
Boolean.
div_isType¶
Remove a directory.¶
This function is used to check the type of a variable, without using the PHP gettype() function, which should never be used to check a variable type.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$var
Default value
Description
The variable to check.
Parameter
$type
Default value
Description
The type to check for (array,bool,double,finite,float,int,long,nan,nul l,numeric,object,real,scalar,string).
Return¶
Boolean.
Section 6 - Debug¶
About this section¶
Debug functions.¶
Those functions are used to output debug informations. They are very similar to the debug functions of the core Typo3 class t3lib_div, except in the fact that they may produce a "smarter" output. So it's just a question of tastes.
Those functions are available in any context. You also don't need the instantiate the API class to use them, as they don't need a parent object.
viewArray¶
Display an array as an HTML table.¶
This function display an HTML table representing the given array. Each item goes in a row, and keys/values in cols. If the array has sub array, they are processed as well.
This function does the same stuff as the original Typo3 viewArray function, in t3lib_div, except that this one produce a table with some nice CSS syling, which should be useful to differentiate variable type at a glance.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$array
Default value
Description
The array to display.
Parameter
$indent
Default value
0
Description
The indentation level (used for indenting the HTML code).
Return¶
An HTML representation of the array.
debug¶
Writes an PHP variable HTML representation.¶
This function produces an HTML representation of a PHP variable. If the variable is an array, the function tx_apimacmade::viewArray is called. Otherwise, the object is printed.
This function does the same stuff as the original Typo3 debug function, in t3lib_div, except that this one produce a div with some nice CSS syling, which should be useful to differentiate variable type at a glance.
SPECIAL NOTE: This function can be called without the API class instantiated.
Parameters¶
Parameter
$variable
Default value
Description
The variable to display.
Parameter
$header
Default value
'DEBUG'
Description
The header of the debug zone.
Return¶
Void.
See also¶
viewArray
Known problems¶
Please contact me if you find any problem with this API.
To-Do list¶
- PHP 5.2 version for TYPO3 4.2.
- Please contact me if you have any suggestion about this extension.
Changelog¶
((generated))¶
0.4.7: 31 st public release¶
Fixed a bug with the FlexForm helper class on some PHP5 versions.
0.4.6: 30 th public release¶
Fixed a bug in the be_includeLightBoxJs method.
0.4.5: 29 th public release¶
- Fixed a bug in the constructor of class tx_apimacmade_flexform. Thanx to Nux for the report.
- Fixed a bug with the JS functions.
- Fixed a bug with the fe_createSelectFromTable function.
0.4.4: 28 th public release¶
- Added two new functions:
- fe_includeWebToolKitJs
- be_includeWebToolKitJs
- Added a parameter in function fe_buildLoginBox to get the TS configuration array instead of the HTML code.
0.4.3: 27 th public release¶
- Added two new functions:
- fe_includeMootoolsJs
- be_includeMootoolsJs
- Added the Mootools JS framework
- Added TS setup and constants
- Added the possibility not to load the JS scripts.
0.4.2: 26 th public release¶
Fixed a bug in the backend JS functions.
0.4.1: 25 th public release¶
Added 1 new function:
newInstance
Fixed a bug with the TYPO3 site path in the JavaScript methods.
0.4.0: 24 th public release¶
Added 1 new class:
tx_apimacmade_flexform
Added 7 new functions:
- fe_includeLightBoxJs
- be_includeLightBoxJs
- fe_includeUfo
- be_includeUfo
- fe_includeSwfObject
- be_includeSwfObject
- getPhp5Class
Fixed a bug in the function fe_linkTP_keepPIvars.
Added clearer error messages.
0.3.3: 23 rd public release¶
Added an option to keep existing piVars in function fe_typoLinkParams.
0.3.2: 22 nd public release¶
Fixed a bug in method fe_linkTP_keepPIvars.
0.3.1: 21 st public release¶
- Added 3 new functions:
- fe_typoLinkParams
- fe_linkTP_keepPIvars
- fe_linkTP_keepPIvars_url
- Fixed the fe_buildLoginBox method (cHash related problem)
- Fixed a bug in method fe_linkTP related to the cHash.
0.3.0: 20 th public release¶
- Added 4 new functions:
- fe_includePrototypeJs
- fe_includeScriptaculousJs
- be_includePrototypeJs
- be_includeScriptaculousJs
- Fixed a bug in function fe_makeStyledContent.
- Changed coding style. Class tx_apimacmade now follows the Zend FrameWork coding rules.
- Miscellaneous enhancements.
0.2.8: 19 th public release¶
Added CSS classes for inputs in function fe_buildLoginBox
0.2.7: 18 th public release¶
- Added 2 new functions:
- fe_buildSearchBox
- fe_buildBrowseBox
- Added parameter 'permaLogin' to function fe_buildLoginBox
0.2.6: 17 th public release¶
Added 1 new function:
div_isType
Added parameter 'checkType' to function div_checkArrayKeys
0.2.5: 16 th public release¶
Fixed typos in the function div_vCardCreate. Thanx to Stephan Struckmann for the feedback.
0.2.1: 12 th public release¶
Added 3 new functions:
- div_vCardFileParse
- div_convertLineBreaks
- fe_linkTP
Fixed a bug with the function div_array2xml.
Numeric tags are now processed correctly.
Modified the div_vCardCreate function to allow other charset than US- ASCII in the vCard elements.
Improved the function div_vCardCreate for a full vCard compatibility.
Fixed a bug with the function fe_buildLoginBox.
The action parameter of the form tag is now correct on all configurations.
0.2.0: 11 th public release¶
Fixed a bug with the db_table2text & db_table2xml functions. Thanx to Florian Hengartner for the report.
The MySQL query parts are no longer ignored.
Fixed a bug with the db_table2xml function. Thanx to Onno Schuit for the report.
The XML namespace is now correctly displayed.
0.1.9: 10 th public release¶
Added support for XML namespacing in the db_table2xml function. Thanx to Onno Schuit for the feedback.
0.1.8: 9 th public release¶
Fixed a bug with the fe_mergeTSconfFlex function.
Zero values are now preserved if present in the flexform data.
0.1.7: 8 th public release¶
Added 2 new functions:
- be_buildPageTreeSelect
- be_getSelectStyleRecordIcon
0.1.6: 7 th public release¶
Fixed a bug with the div_crop function.
0.1.5: 6 th public release¶
Fixed some issues with the div_xml2array function:
- Multiple same tag names are now allowed.
- Tag attributes are now also preserved for tags with no data.
Added 1 new function:
div_formatXHTML
0.1.4: 5 th public release¶
Fixed a bug with the db_table2xml function:
The function is now compatible with div_xml2array.
Added 10 new functions:
- div_week2date
- div_numberInRange
- div_rgb2hsl
- div_hsl2rgb
- div_rgb2hsv
- div_hsv2rgb
- div_hsl2hsv
- div_hsv2hsl
- div_createHexColor
- div_modifyHexColor
0.1.3: 4 th public release¶
Fixed a bug with the div_xml2array function.
Added 1 new function:
div_crop
0.1.2: 3 rd public release¶
Added 4 new functions:
- fe_linkTP_unsetPIvars_url
- be_buildRecordIcons
- div_xml2array
- div_array2xml
0.1.1: 2 nd public release¶
Fixed a bug with the div_str2list function.
0.1.0: 1 st public release¶
Developer API - 42