template.php

Contains class with layout/output function for TYPO3 Backend Scripts

$Id: template.php,v 1.51.2.7 2006/03/17 17:04:18 typo3 Exp $
Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
XHTML-trans compliant

 

Files: 1
Total filesizes: 79 Kbytes
Functions and classes: 62

template.php

Contains class with layout/output function for TYPO3 Backend Scripts

$Id: template.php,v 1.51.2.7 2006/03/17 17:04:18 typo3 Exp $
Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
XHTML-trans compliant

function fw($str)

class template

@package: TYPO3

@subpackage: core

function template()

EVALUATION FUNCTIONS
Various centralized processing

function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE)

function viewPageIcon($id,$backPath,$addParams='hspace="3"')

function issueCommand($params,$rUrl='')

function isCMlayers()

function thisBlur()

function helpStyle()

function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))

function getFileheader($title,$path,$iconfile)

function makeShortcutIcon($gvList,$setList,$modName,$motherModName="")

function makeShortcutUrl($gvList,$setList)

function formWidth($size=48,$textarea=0,$styleOverride='')

function formWidthText($size=48,$styleOverride='',$wrap='')

function redirectUrls($thisLocation='')

function formatTime($tstamp,$type)

function parseTime()

PAGE BUILDING FUNCTIONS.
Use this to build the HTML of your backend modules

function startPage($title)

function endPage()

function header($text)

function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE)

function divider($dist)

function spacer($dist)

function sectionHeader($label,$sH=FALSE,$addAttrib='')

function sectionBegin()

function sectionEnd()

function middle()

function endPageJS()

function docBodyTagBegin()

function docStyle()

function insertStylesAndJS($content)

function initCharset()

function generator()

OTHER ELEMENTS
Tables, buttons, formatting dimmed/red strings

function icons($type, $styleAttribValue='')

function t3Button($onClick,$label)

function dfw($string)

function rfw($string)

function wrapInCData($string)

function wrapScriptTags($string, $linebreak=TRUE)

function table($arr, $layout='')

function menuTable($arr1,$arr2=array(), $arr3=array())

function funcMenu($content,$menu)

function clearCacheMenu($id,$addSaveOptions=0)

function getContextMenuCode()

function showClickmenu(table, uid, listFr, enDisItems, backPath, addParams)

function showClickmenu_noajax(url)

function showClickmenu_ajax(t3ajax)

function getDragDropCode($table)

function cancelDragEvent(event)

function mouseMoveEvent (event)

function dragElement(id,elementID)

function dropElement(id)

function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='')

function getTabMenuRaw($menuItems)

function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1)

function getDynTabMenuJScode()

function getVersionSelector($id,$noAction=FALSE)

class bigDoc extends template

class noDoc extends template

class smallDoc extends template

class mediumDoc extends template

Detailed descriptions:

template.php

Contains class with layout/output function for TYPO3 Backend Scripts

$Id: template.php,v 1.51.2.7 2006/03/17 17:04:18 typo3 Exp $
Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
XHTML-trans compliant

Filesize: 79 K
Func/Classes: 62
Tags: @author Kasper Skaarhoj <kasperYYYY@typo3.com>

function fw($str)

Deprecated fontwrap function. Is just transparent now.

$str string Input string
Returns: string Output string (in the old days this was wrapped in <font> tags)
  @deprecated

class template

TYPO3 Backend Template Class

This class contains functions for starting and ending the HTML of backend modules
It also contains methods for outputting sections of content.
Further there are functions for making icons, links, setting form-field widths etc.
Color scheme and stylesheet definitions are also available here.
Finally this file includes the language class for TYPO3's backend.

After this file $LANG and $TBE_TEMPLATE are global variables / instances of their respective classes.
This file is typically included right after the init.php file,
if language and layout is needed.

Please refer to Inside TYPO3 for a discussion of how to use this API.

Returns: [type] ...
  @author Kasper Skaarhoj <kasperYYYY@typo3.com>
  @package TYPO3
  @subpackage core

function template()

Constructor
Imports relevant parts from global $TBE_STYLES (colorscheme)

Returns: void

function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE)

Makes click menu link (context sensitive menu)
Returns $str (possibly an <|img> tag/icon) wrapped in a link which will activate the context sensitive menu for the record ($table/$uid) or file ($table = file)
The link will load the top frame with the parameter "&item" which is the table,uid and listFr arguments imploded by "|": rawurlencode($table.'|'.$uid.'|'.$listFr)

$str string String to be wrapped in link, typ. image tag.
$table string Table name/File path. If the icon is for a database record, enter the tablename from $TCA. If a file then enter the absolute filepath
$uid='' integer If icon is for database record this is the UID for the record from $table
$listFr=1 boolean Tells the top frame script that the link is coming from a "list" frame which means a frame from within the backend content frame.
$addParams='' string Additional GET parameters for the link to alt_clickmenu.php
$enDisItems='' string Enable / Disable click menu items. Example: "+new,view" will display ONLY these two items (and any spacers in between), "new,view" will display all BUT these two items.
$returnOnClick=FALSE boolean If set, will return only the onclick JavaScript, not the whole link.
Returns: string The link-wrapped input string.

function viewPageIcon($id,$backPath,$addParams='hspace="3"')

Makes link to page $id in frontend (view page)
Returns an magnifier-glass icon which links to the frontend index.php document for viewing the page with id $id
$id must be a page-uid
If the BE_USER has access to Web>List then a link to that module is shown as well (with return-url)

$id integer The page id
$backPath string The current "BACK_PATH" (the back relative to the typo3/ directory)
$addParams='hspace="3"' string Additional parameters for the image tag(s)
Returns: string HTML string with linked icon(s)

function issueCommand($params,$rUrl='')

Returns a URL with a command to TYPO3 Core Engine (tce_db.php)
See description of the API elsewhere.

$params string $params is a set of GET params to send to tce_db.php. Example: "&cmd[tt_content][123][move]=456" or "&data[tt_content][123][hidden]=1&data[tt_content][123][title]=Hello%20World"
$rUrl='' string Redirect URL if any other that t3lib_div::getIndpEnv('REQUEST_URI') is wished
Returns: string URL to tce_db.php + parameters (backpath is taken from $this->backPath)
  @see t3lib_BEfunc::editOnClick()

function isCMlayers()

Returns true if click-menu layers can be displayed for the current user/browser
Use this to test if click-menus (context sensitive menus) can and should be displayed in the backend.

Returns: boolean

function thisBlur()

Returns 'this.blur();' if the client supports CSS styles
Use this in links to remove the underlining after being clicked

Returns: string

function helpStyle()

Returns ' style='cursor:help;'' if the client supports CSS styles
Use for <a>-links to help texts

Returns: string

function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))

Makes the header (icon+title) for a page (or other record). Used in most modules under Web>*
$table and $row must be a tablename/record from that table
$path will be shown as alt-text for the icon.
The title will be truncated to 45 chars.

$table string Table name
$row array Record row
$path string Alt text
$noViewPageIcon=0 boolean Set $noViewPageIcon true if you don't want a magnifier-icon for viewing the page in the frontend
$tWrap=array('','') array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title
Returns: string HTML content

function getFileheader($title,$path,$iconfile)

Like ->getHeader() but for files in the File>* main module/submodules
Returns the file-icon with the path of the file set in the alt/title attribute. Shows the file-name after the icon.

$title string Title string, expected to be the filepath
$path string Alt text
$iconfile string The icon file (relative to TYPO3 dir)
Returns: string HTML content

function makeShortcutIcon($gvList,$setList,$modName,$motherModName="")

Returns a linked shortcut-icon which will call the shortcut frame and set a shortcut there back to the calling page/module

$gvList string Is the list of GET variables to store (if any)
$setList string Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
$modName string Module name string
$motherModName="" string Is used to enter the "parent module name" if the module is a submodule under eg. Web>* or File>*. You can also set this value to "1" in which case the currentLoadedModule is sent to the shortcut script (so - not a fixed value!) - that is used in file_edit.php and wizard_rte.php scripts where those scripts are really running as a part of another module.
Returns: string HTML content

function makeShortcutUrl($gvList,$setList)

MAKE url for storing
Internal func

$gvList string Is the list of GET variables to store (if any)
$setList string Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
Returns: string
  @see makeShortcutIcon()

function formWidth($size=48,$textarea=0,$styleOverride='')

Returns <input> attributes to set the width of an text-type input field.
For client browsers with no CSS support the cols/size attribute is returned.
For CSS compliant browsers (recommended) a ' style="width: ...px;"' is returned.

$size=48 integer A relative number which multiplied with approx. 10 will lead to the width in pixels
$textarea=0 boolean A flag you can set for textareas - DEPRECATED, use ->formWidthText() for textareas!!!
$styleOverride='' string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
Returns: string Tag attributes for an <input> tag (regarding width)
  @see formWidthText()

function formWidthText($size=48,$styleOverride='',$wrap='')

This function is dedicated to textareas, which has the wrapping on/off option to observe.
EXAMPLE:
<textarea rows="10" wrap="off" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","off").'>
or
<textarea rows="10" wrap="virtual" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","virtual").'>

$size=48 integer A relative number which multiplied with approx. 10 will lead to the width in pixels
$styleOverride='' string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
$wrap='' string Pass on the wrap-attribute value you use in your <textarea>! This will be used to make sure that some browsers will detect wrapping alright.
Returns: string Tag attributes for an <input> tag (regarding width)
  @see formWidth()

function redirectUrls($thisLocation='')

Returns JavaScript variables setting the returnUrl and thisScript location for use by JavaScript on the page.
Used in fx. db_list.php (Web>List)

$thisLocation='' string URL to "this location" / current script
Returns: string
  @see typo3/db_list.php

function formatTime($tstamp,$type)

Returns a formatted string of $tstamp
Uses $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] and $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] to format date and time

$tstamp integer UNIX timestamp, seconds since 1970
$type integer How much data to show: $type = 1: hhmm, $type = 10: ddmmmyy
Returns: string Formatted timestamp

function parseTime()

Returns script parsetime IF ->parseTimeFlag is set and user is "admin"
Automatically outputted in page end

Returns: string

function startPage($title)

Returns page start
This includes the proper header with charset, title, meta tag and beginning body-tag.

$title string HTML Page title for the header
Returns: string Returns the whole header section of a HTML-document based on settings in internal variables (like styles, javascript code, charset, generator and docType)
  @see endPage()

function endPage()

Returns page end; This includes finishing form, div, body and html tags.

Returns: string The HTML end of a page
  @see startPage()

function header($text)

Returns the header-bar in the top of most backend modules
Closes section if open.

$text string The text string for the header
Returns: string HTML content

function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE)

Begins an output section and sets header and content

$label string The header
$text string The HTML-content
$nostrtoupper=FALSE boolean A flag that will prevent the header from being converted to uppercase
$sH=FALSE boolean Defines the type of header (if set, "<h3>" rather than the default "h4")
$type=0 integer The number of an icon to show with the header (see the icon-function). -1,1,2,3
$allowHTMLinHeader=FALSE boolean If set, HTML tags are allowed in $label (otherwise this value is by default htmlspecialchars()'ed)
Returns: string HTML content
  @see icons(), sectionHeader()

function divider($dist)

Inserts a divider image
Ends a section (if open) before inserting the image

$dist integer The margin-top/-bottom of the <hr> ruler.
Returns: string HTML content

function spacer($dist)

Returns a blank <div>-section with a height

$dist integer Padding-top for the div-section (should be margin-top but konqueror (3.1) doesn't like it :-(
Returns: string HTML content

function sectionHeader($label,$sH=FALSE,$addAttrib='')

Make a section header.
Begins a section if not already open.

$label string The label between the <h3> or <h4> tags. (Allows HTML)
$sH=FALSE boolean If set, <h3> is used, otherwise <h4>
$addAttrib='' string Additional attributes to h-tag, eg. ' class=""'
Returns: string HTML content

function sectionBegin()

Begins an output section.
Returns the <div>-begin tag AND sets the ->sectionFlag true (if the ->sectionFlag is not already set!)
You can call this function even if a section is already begun since the function will only return something if the sectionFlag is not already set!

Returns: string HTML content

function sectionEnd()

Ends and output section
Returns the </div>-end tag AND clears the ->sectionFlag (but does so only IF the sectionFlag is set - that is a section is 'open')
See sectionBegin() also.

Returns: string HTML content

function middle()

Originally it printed a kind of divider.
Deprecated. Just remove function calls to it or call the divider() function instead.

Returns: void
  @internal
  @deprecated

function endPageJS()

If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to false)

Returns: string HTML content (<script> tag section)

function docBodyTagBegin()

Creates the bodyTag.
You can add to the bodyTag by $this->bodyTagAdditions

Returns: string HTML body tag

function docStyle()

Outputting document style

Returns: string HTML style section/link tags

function insertStylesAndJS($content)

Insert post rendering document style into already rendered content
This is needed for extobjbase

$content string style-content to insert.
Returns: string content with inserted styles

function initCharset()

Initialize the charset.
Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class)
Returns the meta-tag for the document header

Returns: string <meta> tag with charset from $this->charset or $GLOBALS['LANG']->charSet

function generator()

Returns generator meta tag

Returns: string <meta> tag with name "generator"

function icons($type, $styleAttribValue='')

Returns an image-tag with an 18x16 icon of the following types:

$type:
-1: OK icon (Check-mark)
1: Notice (Speach-bubble)
2: Warning (Yellow triangle)
3: Fatal error (Red stop sign)

$type integer See description
$styleAttribValue='' string Value for style attribute
Returns: string HTML image tag (if applicable)

function t3Button($onClick,$label)

Returns an <input> button with the $onClick action and $label

$onClick string The value of the onclick attribute of the input tag (submit type)
$label string The label for the button (which will be htmlspecialchar'ed)
Returns: string A <input> tag of the type "submit"

function dfw($string)

dimmed-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be gray/dimmed

$string string Input string
Returns: string Output string

function rfw($string)

red-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be red

$string string Input string
Returns: string Output string

function wrapInCData($string)

Returns string wrapped in CDATA "tags" for XML / XHTML (wrap content of <script> and <style> sections in those!)

$string string Input string
Returns: string Output string

function wrapScriptTags($string, $linebreak=TRUE)

Wraps the input string in script tags.
Automatic re-identing of the JS code is done by using the first line as ident reference.
This is nice for identing JS code with PHP code on the same level.

$string string Input string
$linebreak=TRUE boolean Wrap script element in linebreaks? Default is TRUE.
Returns: string Output string

function table($arr, $layout='')

Returns a table based on the input $arr

$arr array Multidim array with first levels = rows, second levels = cells
$layout='' array If set, then this provides an alternative layout array instead of $this->tableLayout
Returns: string The HTML table.
  @internal

function menuTable($arr1,$arr2=array(), $arr3=array())

Constructs a table with content from the $arr1, $arr2 and $arr3.
Used in eg. ext/belog/mod/index.php - refer to that for examples

$arr1 array Menu elements on first level
$arr2=array() array Secondary items
$arr3=array() array Third-level items
Returns: string HTML content, <table>...</table>

function funcMenu($content,$menu)

Returns a one-row/two-celled table with $content and $menu side by side.
The table is a 100% width table and each cell is aligned left / right

$content string Content cell content (left)
$menu string Menu cell content (right)
Returns: string HTML output

function clearCacheMenu($id,$addSaveOptions=0)

Creates a selector box with clear-cache items.
Rather specialized functions - at least don't use it with $addSaveOptions unless you know what you do...

$id integer The page uid of the "current page" - the one that will be cleared as "clear cache for this page".
$addSaveOptions=0 boolean If $addSaveOptions is set, then also the array of save-options for TCE_FORMS will appear.
Returns: string <select> tag with content - a selector box for clearing the cache

function getContextMenuCode()

Returns an array with parts (JavaScript, init-functions, <div>-layers) for use on pages which displays the clickmenu layers (context sensitive menus)

Returns: array If values are present: [0] = A <script> section for the HTML page header, [1] = onmousemove/onload handler for HTML tag or alike, [2] = Two empty <div> layers for the context menu

function showClickmenu_noajax(url)

[Describe function...]

url [type] $url: ...
Returns: [type] ...

function getDragDropCode($table)

Returns an array with parts (JavaScript, init-functions, <div>-layers) for use on pages which have the drag and drop functionality (usually pages and folder display trees)

$table string indicator of which table the drag and drop function should work on (pages or folders)
Returns: array If values are present: [0] = A <script> section for the HTML page header, [1] = onmousemove/onload handler for HTML tag or alike, [2] = One empty <div> layer for the follow-mouse drag element

function mouseMoveEvent (event)

[Describe function...]

event [type] $event: ...
Returns: [type] ...

function dragElement(id,elementID)

[Describe function...]

id,elementID [type] $id,elementID: ...
Returns: [type] ...

function dropElement(id)

[Describe function...]

id [type] $id: ...
Returns: [type] ...

function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='')

Creates a tab menu from an array definition

Returns a tab menu for a module
Requires the JS function jumpToUrl() to be available

$mainParams mixed $id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
$elementName string $elementName it the form elements name, probably something like "SET[...]"
$currentValue string $currentValue is the value to be selected currently.
$menuItems array $menuItems is an array with the menu items for the selector box
$script='' string $script is the script to send the &id to, if empty it's automatically found
$addparams='' string $addParams is additional parameters to pass to the script.
Returns: string HTML code for tab menu
  @author RenĂ© Fritz <r.fritz@colorcube.de>

function getTabMenuRaw($menuItems)

Creates the HTML content for the tab menu

$menuItems array Menu items for tabs
Returns: string Table HTML

function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1)

Creates a DYNAMIC tab-menu where the tabs are switched between with DHTML.
Should work in MSIE, Mozilla, Opera and Konqueror. On Konqueror I did find a serious problem: <textarea> fields loose their content when you switch tabs!

$menuItems array Numeric array where each entry is an array in itself with associative keys: "label" contains the label for the TAB, "content" contains the HTML content that goes into the div-layer of the tabs content. "description" contains description text to be shown in the layer. "linkTitle" is short text for the title attribute of the tab-menu link (mouse-over text of tab). "stateIcon" indicates a standard status icon (see ->icon(), values: -1, 1, 2, 3). "icon" is an image tag placed before the text.
$identString string Identification string. This should be unique for every instance of a dynamic menu!
$toggle=0 integer If "1", then enabling one tab does not hide the others - they simply toggles each sheet on/off. This makes most sense together with the $foldout option. If "-1" then it acts normally where only one tab can be active at a time BUT you can click a tab and it will close so you have no active tabs.
$foldout=FALSE boolean If set, the tabs are rendered as headers instead over each sheet. Effectively this means there is no tab menu, but rather a foldout/foldin menu. Make sure to set $toggle as well for this option.
$newRowCharLimit=50 integer Character limit for a new row.
$noWrap=1 boolean If set, tab table cells are not allowed to wrap their content
$fullWidth=FALSE boolean If set, the tabs will span the full width of their position
$defaultTabIndex=1 integer Default tab to open (for toggle <=0). Value corresponds to integer-array index + 1 (index zero is "1", index "1" is 2 etc.). A value of zero (or something non-existing) will result in no default tab open.
Returns: string JavaScript section for the HTML header.

function getDynTabMenuJScode()

Returns dynamic tab menu header JS code.

Returns: string JavaScript section for the HTML header.

function getVersionSelector($id,$noAction=FALSE)

Creates the version selector for the page id inputted.
Requires the core version management extension, "version" to be loaded.

$id integer Page id to create selector for.
$noAction=FALSE boolean If set, there will be no button for swapping page.
Returns: void

class bigDoc extends template

Extension class for "template" - used for backend pages which are wide. Typically modules taking up all the space in the "content" frame of the backend
The class were more significant in the past than today.

Returns: [type] ...

class noDoc extends template

Extension class for "template" - used for backend pages without the "document" background image
The class were more significant in the past than today.

Returns: [type] ...

class smallDoc extends template

Extension class for "template" - used for backend pages which were narrow (like the Web>List modules list frame. Or the "Show details" pop up box)
The class were more significant in the past than today.

Returns: [type] ...

class mediumDoc extends template

Extension class for "template" - used for backend pages which were medium wide. Typically submodules to Web or File which were presented in the list-frame when the content frame were divided into a navigation and list frame.
The class were more significant in the past than today. But probably you should use this one for most modules you make.

Returns: [type] ...