Documentation

Html
in package

HTML class

Provides some commonly used HTML elements

Tags
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Reto Kohli reto.kohli@comvation.com

deprecated

This class is deprecated in favor of using Sigma or \Cx\Core\Html\Model\Entity...

version
3.0.0
subpackage

core

Table of Contents

Constants

ATTRIBUTE_CHECKED  = ' checked="checked"'
Some basic and often used (and frequently misspelt) HTML attributes
ATTRIBUTE_DISABLED  = ' disabled="disabled"'
ATTRIBUTE_MULTIPLE  = ' multiple="multiple"'
ATTRIBUTE_READONLY  = ' readonly="readonly"'
ATTRIBUTE_SELECTED  = ' selected="selected"'
CSS_DISPLAY_BLOCK  = 'display:block;'
CSS_DISPLAY_INLINE  = 'display:inline;'
CSS_DISPLAY_NONE  = 'display:none;'
Some basic and frequently used (and often misspelt) CSS properties
ICON_BLANK  = '/core/Core/View/Media/icons/blank.gif'
Icon used for omitted icons (for aligning/formatting)
ICON_COMMENT  = '/core/Core/View/Media/icons/comment.gif'
Icon used for Comments (with tooltip containing the text)
ICON_DETAILS  = '/core/Core/View/Media/icons/details.gif'
Icon used to indicate a link to details for the object.
ICON_ELEMENT_ADD  = '/core/Core/View/Media/icons/check.gif'
Icon used on the link for adding an HTML element
ICON_ELEMENT_REMOVE  = '/core/Core/View/Media/icons/delete.gif'
Icon used on the link for removing an HTML element
ICON_FUNCTION_BLANK  = '/core/Core/View/Media/icons/pixel.gif'
Icon used for omitted functions
ICON_FUNCTION_CLEAR_IMAGE  = '/core/Core/View/Media/icons/delete.gif'
Icon used on the link for removing an image
ICON_FUNCTION_COPY  = '/core/Core/View/Media/icons/copy.gif'
Icon used on the link for copying any entry
ICON_FUNCTION_DELETE  = '/core/Core/View/Media/icons/delete.gif'
Icon used on the link for deleting any entry
ICON_FUNCTION_DOWNLOAD_PDF  = '/core/Core/View/Media/icons/pdf.gif'
Icon used on the link for downloading a PDF document
ICON_FUNCTION_EDIT  = '/core/Core/View/Media/icons/edit.gif'
Icon used on the link for editing any entry
ICON_FUNCTION_MARK_DELETED  = '/core/Core/View/Media/icons/empty.gif'
Icon used on the link for marking as deleted
ICON_FUNCTION_MARK_UNDELETED  = '/core/Core/View/Media/icons/restore.gif'
Icon used on the link for marking as not deleted
ICON_FUNCTION_SPECIAL_OFF  = '/core/Core/View/Media/icons/special_off.png'
Icon used on the link for marking as not special
ICON_FUNCTION_SPECIAL_ON  = '/core/Core/View/Media/icons/special_on.png'
Icon used on the link for marking as special
ICON_FUNCTION_VIEW  = '/core/Core/View/Media/icons/viewmag.png'
Icon used on the link for viewing any entry
ICON_GIFT  = '/core/Core/View/Media/icons/gift.gif'
Icon used for gift text (with tooltip containing the text) Only for the hotelcard module
ICON_STATUS_CHECKED  = '/core/Core/View/Media/icons/check.gif'
Icon used for the checked status
ICON_STATUS_GREEN  = '/core/Core/View/Media/icons/status_green.gif'
Icon used for green status
ICON_STATUS_RED  = '/core/Core/View/Media/icons/status_red.gif'
Icon used for red status
ICON_STATUS_UNCHECKED  = '/core/Core/View/Media/icons/pixel.gif'
Icon used for the unchecked status
ICON_STATUS_YELLOW  = '/core/Core/View/Media/icons/status_yellow.gif'
Icon used for yellow status
STATUS_GREEN  = 'green'
STATUS_RED  = 'red'
Class constants defining the names of various (LED) status
STATUS_YELLOW  = 'yellow'
TOGGLE_CLASS_NOP  = 'room_nop'
TOGGLE_CLASS_OFF  = 'room_off'
TOGGLE_CLASS_ON  = 'room_on'
TOGGLE_ID_BASE  = 'toggle'
The base name for the elements created by {@see getToggle()}
TOGGLE_KEY_NOP  = '-1'
TOGGLE_KEY_OFF  = '0'
These are the default values for the global (default) values for the Toggle Javascript class handling the toggle element events.
TOGGLE_KEY_ON  = '1'
TOGGLE_TITLE_NOP  = '/'
TOGGLE_TITLE_OFF  = '-'
TOGGLE_TITLE_ON  = '0'

Properties

$index_tab  : int
Index counter for all form elements
$index_toggle  : int
Index counter for all toggle elements

Methods

getBackendFunctions()  : string
Returns HTML code for the functions available in many list views
getCheckbox()  : string
Returns HTML code for a checkbox
getCheckboxGroup()  : string
Returns HTML code for a checkbox group
getCheckmark()  : string
Returns HTML code for either a checked or unchecked icon for indicating yes/no status
getClearImageCode()  : mixed
getDatepicker()  : string
Returns a datepicker element
getDatetimepicker()  : string
Returns a datetimepicker element
getForm()  : string
Returns HTML code for a form
getHidden()  : string
Returns HTML code for a hidden imput field
getHidden_activetab()  : type
Returns HTML code for the hidden active tab field
getImage()  : string
Returns an image tag for the given Image object in the size specified by the corresponding Imagetype
getImageByPath()  : string
Returns an image tag for the given Image path
getImageChooserBrowser()  : string
Returns HTML code for an image element that links to the filebrowser for choosing an image file on the server
getImageChooserUpload()  : string
Returns HTML code for an image element with form elements for uploading an image file.
getImageOriginal()  : string
Returns an image tag for the given Image object in its original size
getInputButton()  : string
Returns HTML code for a button
getInputFileupload()  : string
Returns HTML code for a file upload input field
getInputNumber()  : string
Returns HTML code for a number imput field
getInputPassword()  : string
Returns HTML code for a password text imput field
getInputRange()  : string
Returns HTML code for a range imput field
getInputText()  : string
Returns HTML code for a text imput field
getInputTextGroup()  : mixed
Returns HMTL code for displaying a group of Text fields
getJavascript_Element()  : string
A few JS scripts used by the Html class
getJavascript_Image()  : string
A few JS scripts used by the Html and Image classes
getJavascript_Text()  : string
A few JS scripts used by the Html class
getJavascript_Toggle()  : string
Returns the javascript needed to make elements returned by {@see getToggle()} work
getLabel()  : string
Wraps the content in a label
getLanguageIcon()  : string
Returns a single language icon
getLanguageIcons()  : string
Generates code for ContentManager style language state icons
getLed()  : string
Returns HTML code to represent some status with a colored LED image
getLink()  : string
Returns HTML code for a link
getOptions()  : string
Returns HTML code for selection options
getRadio()  : string
Returns HTML code for a radio button
getRadioGroup()  : string
Returns HTML code for a radio button group
getRelativeUri()  : string
Returns the page URI
getRelativeUri_entities()  : string
Returns the page URI with all special characters substituted by their corresponding HTML entities
getRemoveAddLinks()  : mixed
getSelect()  : string
Returns HTML code for a dropdown menu
getSelectCustom()  : string
Returns HTML code for a custom dropdown menu
getTextarea()  : string
Returns HTML code for a text area
getThumbnail()  : string
Returns an image tag for the given Image object in the thumbnail size specified by the corresponding Imagetype
getToggle()  : string
Returns a clickable element that toggles its color and value
getTwinmenu()  : mixed
Returns HMTL code for displaying two adjacent menus
makeRating()  : bool
Builds a raty element
replaceUriParameter()  : void
Replaces the URI parameters given in the URI, by reference
shortenText()  : string
Shortens text and appends an optional link to "more...".
stripUriParam()  : string
Remove the parameter and its value from the URI string, by reference
getJavascript_Twinmenu()  : string
Returns the Javascript code required by the Twinmenu

Constants

ATTRIBUTE_CHECKED

Some basic and often used (and frequently misspelt) HTML attributes

public mixed ATTRIBUTE_CHECKED = ' checked="checked"'

Note the leading space that allows you to add the placeholder right after the preceeding attribute without wasting whitespace when it's unused

ATTRIBUTE_DISABLED

public mixed ATTRIBUTE_DISABLED = ' disabled="disabled"'

ATTRIBUTE_MULTIPLE

public mixed ATTRIBUTE_MULTIPLE = ' multiple="multiple"'

ATTRIBUTE_READONLY

public mixed ATTRIBUTE_READONLY = ' readonly="readonly"'

ATTRIBUTE_SELECTED

public mixed ATTRIBUTE_SELECTED = ' selected="selected"'

CSS_DISPLAY_BLOCK

public mixed CSS_DISPLAY_BLOCK = 'display:block;'

CSS_DISPLAY_INLINE

public mixed CSS_DISPLAY_INLINE = 'display:inline;'

CSS_DISPLAY_NONE

Some basic and frequently used (and often misspelt) CSS properties

public mixed CSS_DISPLAY_NONE = 'display:none;'

ICON_BLANK

Icon used for omitted icons (for aligning/formatting)

public mixed ICON_BLANK = '/core/Core/View/Media/icons/blank.gif'

ICON_COMMENT

Icon used for Comments (with tooltip containing the text)

public mixed ICON_COMMENT = '/core/Core/View/Media/icons/comment.gif'

ICON_DETAILS

Icon used to indicate a link to details for the object.

public mixed ICON_DETAILS = '/core/Core/View/Media/icons/details.gif'

Only for the hotelcard module

ICON_ELEMENT_ADD

Icon used on the link for adding an HTML element

public mixed ICON_ELEMENT_ADD = '/core/Core/View/Media/icons/check.gif'
Tags
todo

Find a better icon for this

ICON_ELEMENT_REMOVE

Icon used on the link for removing an HTML element

public mixed ICON_ELEMENT_REMOVE = '/core/Core/View/Media/icons/delete.gif'

ICON_FUNCTION_BLANK

Icon used for omitted functions

public mixed ICON_FUNCTION_BLANK = '/core/Core/View/Media/icons/pixel.gif'

ICON_FUNCTION_CLEAR_IMAGE

Icon used on the link for removing an image

public mixed ICON_FUNCTION_CLEAR_IMAGE = '/core/Core/View/Media/icons/delete.gif'

ICON_FUNCTION_COPY

Icon used on the link for copying any entry

public mixed ICON_FUNCTION_COPY = '/core/Core/View/Media/icons/copy.gif'

ICON_FUNCTION_DELETE

Icon used on the link for deleting any entry

public mixed ICON_FUNCTION_DELETE = '/core/Core/View/Media/icons/delete.gif'

ICON_FUNCTION_DOWNLOAD_PDF

Icon used on the link for downloading a PDF document

public mixed ICON_FUNCTION_DOWNLOAD_PDF = '/core/Core/View/Media/icons/pdf.gif'

ICON_FUNCTION_EDIT

Icon used on the link for editing any entry

public mixed ICON_FUNCTION_EDIT = '/core/Core/View/Media/icons/edit.gif'

ICON_FUNCTION_MARK_DELETED

Icon used on the link for marking as deleted

public mixed ICON_FUNCTION_MARK_DELETED = '/core/Core/View/Media/icons/empty.gif'

ICON_FUNCTION_MARK_UNDELETED

Icon used on the link for marking as not deleted

public mixed ICON_FUNCTION_MARK_UNDELETED = '/core/Core/View/Media/icons/restore.gif'

ICON_FUNCTION_SPECIAL_OFF

Icon used on the link for marking as not special

public mixed ICON_FUNCTION_SPECIAL_OFF = '/core/Core/View/Media/icons/special_off.png'

ICON_FUNCTION_SPECIAL_ON

Icon used on the link for marking as special

public mixed ICON_FUNCTION_SPECIAL_ON = '/core/Core/View/Media/icons/special_on.png'

ICON_FUNCTION_VIEW

Icon used on the link for viewing any entry

public mixed ICON_FUNCTION_VIEW = '/core/Core/View/Media/icons/viewmag.png'

ICON_GIFT

Icon used for gift text (with tooltip containing the text) Only for the hotelcard module

public mixed ICON_GIFT = '/core/Core/View/Media/icons/gift.gif'

ICON_STATUS_CHECKED

Icon used for the checked status

public mixed ICON_STATUS_CHECKED = '/core/Core/View/Media/icons/check.gif'

ICON_STATUS_GREEN

Icon used for green status

public mixed ICON_STATUS_GREEN = '/core/Core/View/Media/icons/status_green.gif'

ICON_STATUS_RED

Icon used for red status

public mixed ICON_STATUS_RED = '/core/Core/View/Media/icons/status_red.gif'

ICON_STATUS_UNCHECKED

Icon used for the unchecked status

public mixed ICON_STATUS_UNCHECKED = '/core/Core/View/Media/icons/pixel.gif'

ICON_STATUS_YELLOW

Icon used for yellow status

public mixed ICON_STATUS_YELLOW = '/core/Core/View/Media/icons/status_yellow.gif'

STATUS_GREEN

public mixed STATUS_GREEN = 'green'

STATUS_RED

Class constants defining the names of various (LED) status

public mixed STATUS_RED = 'red'

See Html::getLed()

STATUS_YELLOW

public mixed STATUS_YELLOW = 'yellow'

TOGGLE_CLASS_NOP

public mixed TOGGLE_CLASS_NOP = 'room_nop'

TOGGLE_CLASS_OFF

public mixed TOGGLE_CLASS_OFF = 'room_off'

TOGGLE_CLASS_ON

public mixed TOGGLE_CLASS_ON = 'room_on'

TOGGLE_ID_BASE

The base name for the elements created by {@see getToggle()}

public mixed TOGGLE_ID_BASE = 'toggle'

The current value of $index_toggle is appended for each such element, starting from one. The current status is stored in a hidden input, its id being the same but prepended with "hidden-".

TOGGLE_KEY_NOP

public mixed TOGGLE_KEY_NOP = '-1'

TOGGLE_KEY_OFF

These are the default values for the global (default) values for the Toggle Javascript class handling the toggle element events.

public mixed TOGGLE_KEY_OFF = '0'

See getToggle(), getJavascript_Toggle()

TOGGLE_TITLE_NOP

public mixed TOGGLE_TITLE_NOP = '/'

TOGGLE_TITLE_OFF

public mixed TOGGLE_TITLE_OFF = '-'

TOGGLE_TITLE_ON

public mixed TOGGLE_TITLE_ON = '0'

Properties

$index_tab

Index counter for all form elements

private static int $index_tab = 0

Incremented and added to the tabindex attribute for each element in the order they are created

$index_toggle

Index counter for all toggle elements

private static int $index_toggle = 0

Incremented and added to the id attribute for each toggle element in the order they are created

Methods

getBackendFunctions()

Returns HTML code for the functions available in many list views

public static getBackendFunctions(array<string|int, mixed> $arrFunction[, array<string|int, mixed> $arrConfirmation = false ][, bool $align_right = true ][, array<string|int, mixed> $arrText = null ]) : string

The $arrFunction array must look something like: array( 'view' => The view action parameter, 'copy' => The copy action parameter, 'edit' => The edit action parameter, 'delete' => The delete action parameter, ) You may omit any indices that do not apply, those icons will not be included. The action parameter may be a full absolute or relative URI, or just a partial query string, like "act=what_to_do". In the first case, it is used unchanged. In the second case, the parameters in the string replace those of the same name or are added to the current page URI. You may also specify javascript code, this MUST start with "javascript:" and will replace the page URI. Empty actions will usually lead back to the module start page. Mind that you MUST use single quotes (') in all of those action strings ONLY. The optional $arrConfirmation array may contain any of the same indices, plus some text. If present, these texts are shown in a confirmation box, and action is only taken if it is confirmed. Note that in that case, the action parameter MUST be a valid URI, NOT some javascript statement! Any icon's alt and title tag is fitted with the default core language entry whose index is formed like "TXT_CORE_HTML_" plus the function name in upper case, e.g. "TXT_CORE_HTML_DELETE". This text may be overridden by entries in the $arrText array, indexed like $arrFunction. //Also, the current CSRF key and value pair is added to any URI processed.

Parameters
$arrFunction : array<string|int, mixed>

The array of functions and actions

$arrConfirmation : array<string|int, mixed> = false

The optional array with confirmation texts

$align_right : bool = true

Align the function icons to the right using an enclosing

if true. Defaults to true

$arrText : array<string|int, mixed> = null

Alternative/title text for the icons. Defaults to null, in which case the core language entry is used, if present

Return values
string

The HTML code for the function column

getCheckbox()

Returns HTML code for a checkbox

public static getCheckbox(string $name[, string $value = 1 ][, string $id = false ][, bool $checked = false ][, string $onchange = '' ][, string $attribute = '' ]) : string

If the name is empty, the empty string is returned. The $value is contrexx_raw2xhtml()d to prevent side effects. If the $id parameter is false, the id attribute is not set. If it's empty (but not false), the name is used instead.

Parameters
$name : string

The element name

$value : string = 1

The element value, defaults to 1 (one)

$id : string = false

The optional element id

$checked : bool = false

If true, the checkbox is checked

$onchange : string = ''

The optional onchange event script

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getCheckboxGroup()

Returns HTML code for a checkbox group

public static getCheckboxGroup(string $name, array<string|int, mixed> $arrOptions[, array<string|int, mixed> $arrLabel = null ][, array<string|int, mixed> $arrChecked = null ][, string $id = false ][, string $onchange = '' ][, string $separator = '' ][, mixed $attributeCheckbox = '' ][, string $attributeLabel = '' ]) : string

If the name is empty, the empty string is returned. The $name parameter is both used for the name and id parameter in the element. For the id, a dash and an additional index are appended, like '$name-$index'. That index is increased accordingly on each call to this method. Mind that thus, it MUST be unique on your page. The $arrOptions array must contain the key-value pairs in the order to be added. The keys are used to index the name attribute in the checkboxes, the value is put into the value attribute. The $arrLabel should use the same keys, its values are appended as label text to the respective checkboxes, if present. The $arrChecked array may contain the values to be preselected as array values. It's keys are ignored.

Parameters
$name : string

The element name

$arrOptions : array<string|int, mixed>

The options array

$arrLabel : array<string|int, mixed> = null

The optional label text array

$arrChecked : array<string|int, mixed> = null

The optional preselected option keys

$id : string = false

The optional element id

$onchange : string = ''

The optional onchange event script

$separator : string = ''

The optional separator between checkboxes

$attributeCheckbox : mixed = ''
$attributeLabel : string = ''

Additional optional attributes for the labels

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the elements

getCheckmark()

Returns HTML code for either a checked or unchecked icon for indicating yes/no status

public static getCheckmark([bool $status = '' ]) : string

For the time being, the unchecked status is represented by an empty space, aka pixel.gif

Parameters
$status : bool = ''

If true, the checked box is returned, the unchecked otherwise

Tags
todo

There should be an unchecked icon other than "pixel.gif"

Return values
string

The HTML code with the checkbox icon

getClearImageCode()

public static getClearImageCode(mixed $id) : mixed
Parameters
$id : mixed

getDatepicker()

Returns a datepicker element

public static getDatepicker(string $name[, array<string|int, mixed> $options = null ][, string $attribute = null ][, string &$id = null ]) : string

Uses and activates jQueryUI (see DateTimeTools::addDatepickerJs()). If the $id parameter is empty, uses the $name parameter value to create an id attribute. The ID attribute created for the element is returned in the $id parameter. The options array may contain any keys that are valid datepicker options, and their respective values. See http://jqueryui.com/demos/datepicker/#options for details. As of writing this (20101125), valid options are: altField altFormat appendText autoSize buttonImage buttonImageOnly buttonText calculateWeek changeMonth changeYear closeText constrainInput currentText dateFormat dayNames dayNamesMin dayNamesShort defaultDate disabled duration firstDay gotoCurrent hideIfNoPrevNext isRTL maxDate minDate monthNames monthNamesShort navigationAsDateFormat nextText numberOfMonths prevText selectOtherMonths shortYearCutoff showAnim showButtonPanel showCurrentAtPos showMonthAfterYear showOn showOptions showOtherMonths showWeek stepMonths weekHeader yearRange yearSuffix Note that you MUST specify boolean option values as true or false, NOT as string literals "true" or "false". The latter will not work.

Parameters
$name : string

The element name

$options : array<string|int, mixed> = null

The optional datepicker options, including the value (defaultDate)

$attribute : string = null

The optional attributes

$id : string = null

The optional ID, by reference.

Tags
link
http://jqueryui.com/demos/datepicker/
link
http://jqueryui.com/demos/datepicker/#options
internal

Ignore the code analyzer warning about $id

Return values
string

The datepicker element HTML code

getDatetimepicker()

Returns a datetimepicker element

public static getDatetimepicker(string $name[, array<string|int, mixed> $options = null ][, string $attribute = null ][, string &$id = null ]) : string
Parameters
$name : string

textbox name for datetimepicker

$options : array<string|int, mixed> = null

datetimepicker options Ex.dateFormat

$attribute : string = null
$id : string = null

To initialize the datatime picker

Tags
staticvar

integer $index integer value

Return values
string

The datetimepicker element HTML code

getForm()

Returns HTML code for a form

public static getForm(string $name, string $action, string $content[, string $id = false ][, string $method = 'post' ][, string $attribute = '' ]) : string

If the $id parameter is false, the id attribute is not set. If it's empty (but not false), the name is used instead.

Parameters
$name : string

The element name

$action : string

The action URI

$content : string

The form content

$id : string = false

The optional element id

$method : string = 'post'

The optional request method. Defaults to 'post'

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getHidden()

Returns HTML code for a hidden imput field

public static getHidden(string $name, string $value[, string $id = false ][, string $attribute = '' ]) : string

If the $id parameter is false, the id attribute is not set. If it's empty (but not false), the name is used instead.

Parameters
$name : string

The element name

$value : string

The element value

$id : string = false

The element id, if non-empty

$attribute : string = ''

Additional optional attributes

Tags
todo

Maybe the optional attributes will never be used and can be removed?

author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getHidden_activetab()

Returns HTML code for the hidden active tab field

public static getHidden_activetab() : type

Includes Javascript setting the corresponding variable

Return values
type

getImage()

Returns an image tag for the given Image object in the size specified by the corresponding Imagetype

public static getImage(Image $objImage[, string $attribute = '' ]) : string

This adds alt, width, and height attributes with the values returned by Image::getPath(), and ImageType::getInfoArray() methods repectively. If the $attribute parameter contains one of the alt, width, or height attributes (or corresponding style information), these will override the data from the Image or Imagetype.

Parameters
$objImage : Image

The Image object

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the image tag

getImageByPath()

Returns an image tag for the given Image path

public static getImageByPath(mixed $image_path[, string $attribute = '' ]) : string

This adds alt, width, and height attributes with the values returned by Image::getPath(), Image::getWidth(), and Image::getHeight() methods repectively. If the $attribute parameter contains one of the alt, width, or height attributes (or corresponding style information), these will override the data from the Image object.

Parameters
$image_path : mixed
$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the image tag

getImageChooserBrowser()

Returns HTML code for an image element that links to the filebrowser for choosing an image file on the server

public static getImageChooserBrowser(Image $objImage, string $id[, mixed $imagetype_key = false ][, mixed $type = null ][, mixed $path = null ]) : string

If the optional $imagetype_key is missing (defaults to false), no image type can be selected. If it's a string, the type of the Image is set to this key. If it's an array of keys, the Image type can be selected from these. Uses the $id parameter as prefix for both the name and id attributes of all HTML elements. The names and respective suffixes are:

  • id+'img' for the name and id of the tag
  • id+'_src' for the name and id of the hidden tag for the image URI
  • id+'_width' for the name and id of the hidden tag for the width
  • id+'_height' for the name and id of the hidden tag for the height All of the elements with a suffix will provide the current selected image information when the form is posted. See Image::updatePostImages() and Image::uploadAndStore() for more information and examples.
Parameters
$objImage : Image

The image object

$id : string

The base name for the elements IDs

$imagetype_key : mixed = false

The optional Image type key

$type : mixed = null
$path : mixed = null
Return values
string

The HTML code for all the elements

getImageChooserUpload()

Returns HTML code for an image element with form elements for uploading an image file.

public static getImageChooserUpload(Image $objImage, string $id[, mixed $imagetype_key = '' ][, string $path_default = '' ][, bool $replace_only = false ]) : string

Uses the $id parameter as prefix for both the name and id attributes of all HTML elements. The names and respective suffixes are:

  • id+'_img' for the name and id of the tag
  • id+'_src' for the name and id of the hidden tag for the image path
  • id+'_type' for the name and id of the hidden tag or tag for the width
  • id+'_height' for the name and id of the hidden tag for the height
  • id+'_file' for the name and id of the file upload element The file upload element will provide the new image chosen by the user when the form is posted, while the hidden fields represent the previous state when the page was generated. The $path_default will replace the path of the image shown if that is empty, but the path posted back will remain empty so the default image is not accidentally stored. If the optional $imagetype_key is empty or not an array, no image type can be selected. If it's false, the image type field is omitted. If it's empty but not false, the current Image's type is used. If it's a string, the type is set to that value, overriding the Image's current type. If it's an array, the Image type can be selected from its values, and the current Image's key is preselected. The array keys SHOULD contain the Imagetype key, its values the Imagetype names in the current language. See Image::updatePostImages() and Image::uploadAndStore() for more information and examples.
Parameters
$objImage : Image

The image object

$id : string

The base name for the elements IDs

$imagetype_key : mixed = ''

The optional Image type key or Imagetype array. Defaults to the empty string

$path_default : string = ''

The optional path of a default image. Defaults to the empty string

$replace_only : bool = false

If true, the image cannot be deleted, but there's always a file upload input to replace the current image. Defaults to false

Return values
string

The HTML code for all the elements

getImageOriginal()

Returns an image tag for the given Image object in its original size

public static getImageOriginal(Image $objImage[, string $attribute = '' ]) : string

This adds alt, width, and height attributes with the values returned by Image::getPath(), Image::getWidth(), and Image::getHeight() methods repectively. If the $attribute parameter contains one of the alt, width, or height attributes (or corresponding style information), these will override the data from the Image object.

Parameters
$objImage : Image

The Image object

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the image tag

getInputButton()

Returns HTML code for a button

public static getInputButton(string $name, string $value[, string $type = 'submit' ][, string $id = false ][, string $attribute = '' ][, string $label = '' ][, string $label_attribute = '' ]) : string

If the $id parameter is false, the id attribute is not set. If it's empty (but not false), the name is used instead.

Parameters
$name : string

The element name

$value : string

The element value

$type : string = 'submit'

The button type, defaults to 'submit'

$id : string = false

The element id, if non-empty

$attribute : string = ''

Additional optional attributes

$label : string = ''

The optional label text

$label_attribute : string = ''

The optional label attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getInputFileupload()

Returns HTML code for a file upload input field

public static getInputFileupload(string $name[, string $id = false ][, string $maxlength = '' ][, string $mimetype = '' ][, string $attribute = '' ][, bool $visible = true ][, string $path = false ]) : string

If the $id parameter is false, the id attribute is not set. If it's empty (but not false), the name is used instead.

Parameters
$name : string

The element name

$id : string = false

The optional element id. You can only get the target path and delete functionality if this is not false.

$maxlength : string = ''

The optional maximum accepted size

$mimetype : string = ''

The optional accepted MIME type

$attribute : string = ''

Additional optional attributes

$visible : bool = true

If true, the input element is set visible. Defaults to true

$path : string = false

Optional path. If not empty, and the $id is non-empty, the file path is shown on top of the upload element, with a clickable delete icon to the right. Defaults to false

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getInputNumber()

Returns HTML code for a number imput field

public static getInputNumber(string $name[, string $value = '' ][, string $id = false ][, string $attribute = '' ]) : string

Note: This requires an HTML5 capable browser. If the $id parameter is false, the id attribute is not set. If it's empty (but not false), the name is used instead. Use the $attribute parameter to specify additional attributes, like min, max, or step.

Parameters
$name : string

The element name

$value : string = ''

The element value, defaults to the empty string

$id : string = false

The optional element id, defaults to false for none

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getInputPassword()

Returns HTML code for a password text imput field

public static getInputPassword(string $name, string $value[, string $attribute = '' ]) : string

The $name parameter is used for both the element name and id attributes.

Parameters
$name : string

The element name

$value : string

The element value

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getInputRange()

Returns HTML code for a range imput field

public static getInputRange(string $name[, string $value = '' ][, string $id = false ][, string $attribute = '' ]) : string

Note: This requires an HTML5 capable browser. If the $id parameter is false, the id attribute is not set. If it's empty (but not false), the name is used instead. Use the $attribute parameter to specify additional attributes, like min, max, or step.

Parameters
$name : string

The element name

$value : string = ''

The element value, defaults to the empty string

$id : string = false

The optional element id, defaults to false for none

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getInputText()

Returns HTML code for a text imput field

public static getInputText(string $name[, string $value = '' ][, string $id = false ][, string $attribute = '' ]) : string

If the $id parameter is false, the id attribute is not set. If it's empty (but not false), the name is used instead. If the custom attributes parameter $attribute is empty, and is_numeric($value) evaluates to true, the text is right aligned within the input element.

Parameters
$name : string

The element name

$value : string = ''

The element value, defaults to the empty string

$id : string = false

The optional element id, defaults to false for none

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getInputTextGroup()

Returns HMTL code for displaying a group of Text fields

public static getInputTextGroup([array<string|int, mixed> &$options = null ]) : mixed
Parameters
$options : array<string|int, mixed> = null

The options array, by reference

getJavascript_Element()

A few JS scripts used by the Html class

public static getJavascript_Element() : string

Includes the following methods for manipulating HTML elements: toggleDisplay(button_element, target_id) Toggles the visibility (style.display) of the element with id attribute target_id and updates the .innerHTML property of the button_element with the appropriate text ("open" or "close"). showTab(tab_id_base, div_id_base, active_suffix, min_suffix, max_suffix) Activate a tab and show the corresponding content. Displays the element with id "div_id_base"+"active_suffix", and hides all other such elements within the "min_suffix" to "max_suffix" range (inclusive). Sets the class of the element with id "tab_id_base"+ "active_suffix" to "active", any other suffix to "". removeElement(id) -- UNTESTED! Remove the element with id "id". cloneElement(id) -- UNTESTED! Adds a clone of the element with id "id" as its next sibling.

Return values
string

The Javascript code

getJavascript_Image()

A few JS scripts used by the Html and Image classes

public static getJavascript_Image([string $path = '' ]) : string

The functions included are required to show the file browser and file upload components defined in the self::getImageChooserBrowser() and self::getImageChooserUpload() methods, respectively.

Parameters
$path : string = ''

The optional path to a default image. Defaults to the Image::PATH_NO_IMAGE class constant if empty.

Return values
string

The Javascript code

getJavascript_Text()

A few JS scripts used by the Html class

public static getJavascript_Text() : string

Includes the following methods: lengthLimit(textarea, count_min, count_max, limit_min, limit_max) Limit the length of the element "textarea" to the range of "limit_min" to "limit_max" characters (inclusive). Updates the minimum and maximum required characters in the elements "count_min" and "count_max" values.

Return values
string

The Javascript code

getJavascript_Toggle()

Returns the javascript needed to make elements returned by {@see getToggle()} work

public static getJavascript_Toggle(string $toggle_id_base, string $hidden_id_base[, array<string|int, mixed> $arrValues = array() ][, array<string|int, mixed> $arrTypeIds = array() ]) : string

The $hidden_id_base MUST be letters and dash (-) ONLY. Everything else is considered to be part of the internal element index, including digits and underscore.

Parameters
$toggle_id_base : string

The base name of the toggle elements

$hidden_id_base : string

The base name of the (hidden) value elements

$arrValues : array<string|int, mixed> = array()

The array of individual toggle

$arrTypeIds : array<string|int, mixed> = array()

The array of type IDs

Return values
string

The javascript code

getLabel()

Wraps the content in a label

public static getLabel(string $for, string $text[, string $attribute = '' ]) : string

The $text is contrexx_raw2xhtml()d to prevent side effects. Mind that the $for parameter must match the id attribute of the contained element in $content.

Parameters
$for : string

The for attribute of the label

$text : string

The text of the label

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the label with the text

getLanguageIcon()

Returns a single language icon

public static getLanguageIcon(int $languageId, string $state, mixed $link[, string $languageLabel = '' ]) : string
Parameters
$languageId : int

Language ID

$state : string

One of active,inactive,inexistent

$link : mixed
$languageLabel : string = ''

(optional) Label for the icon, default is uppercase language code

Return values
string

The HTML code for the elements

getLanguageIcons()

Generates code for ContentManager style language state icons

public static getLanguageIcons(array<string|int, mixed> &$languageStates, string $link) : string

For $languageStates you may supply an array in one of these to forms:

$languageStates = array( {language id} => 'active','inactive','inexistent', )

$languageStates = array( {language id} => array( 'active' => {bool}, 'page' => {page id or object}, ), )

The latter will be resolved to the first form. The two forms can be mixed.

For $link, supply a hyperlink, that may contain %1$d and %2$s which will be replaced with the language ID and code.

Parameters
$languageStates : array<string|int, mixed>

Language states to get icons for

$link : string

Hyperlink for language icons

Return values
string

The HTML code for the elements

getLed()

Returns HTML code to represent some status with a colored LED image

public static getLed([mixed $status = '' ][, string $alt = '' ][, string $action = '' ]) : string

Colors currently available include green, yellow, and red. For unknown colors, the empty string is returned. The $alt parameter value is added as the images' alt attribute value, if non-empty. The $action parameter may include URI parameters to be inserted in the href attribute of a link, which is added if $action is non-empty.

Parameters
$status : mixed = ''
$alt : string = ''

The optional alt attribute for the image

$action : string = ''

The optional action URI parameters

Return values
string

The LED HTML code on success, the empty string otherwise

Returns HTML code for a link

public static getLink(string $uri, array<string|int, mixed> $text[, string $target = null ][, string $attribute = null ]) : string

If either $uri or $text is empty, returns the empty string.

Parameters
$uri : string

The target address

$text : array<string|int, mixed>

The link text

$target : string = null

The optional target window

$attribute : string = null

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getOptions()

Returns HTML code for selection options

public static getOptions(array<string|int, mixed> $arrOptions[, mixed $selected = '' ][, string $attribute = null ]) : string

The optional $selected parameter may be an array, in which case all IDs found in the array keys are selected. The arrays' values are ignored.

Parameters
$arrOptions : array<string|int, mixed>

The options array

$selected : mixed = ''

The optional preselected option key or array of keys

$attribute : string = null

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The menu options HTML code

getRadio()

Returns HTML code for a radio button

public static getRadio(string $name, array<string|int, mixed> $value[, string $id = false ][, bool $checked = false ][, string $onchange = '' ][, string $attribute = '' ]) : string

If the name is empty, the empty string is returned. If the $id parameter is false, the id attribute is not set. If it's empty (but not false), the name is used instead.

Parameters
$name : string

The element name

$value : array<string|int, mixed>

The element value

$id : string = false

The optional element id

$checked : bool = false

If true, the radio button is preselected. Defaults to false

$onchange : string = ''

The optional onchange event script

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getRadioGroup()

Returns HTML code for a radio button group

public static getRadioGroup(string $name, array<string|int, mixed> $arrOptions[, string $checked = '' ][, string $onchange = '' ][, string $attributeRadio = '' ][, string $attributeLabel = '' ]) : string

If the name is empty, the empty string is returned. The $name parameter is both used for the name and id parameter in the element. For the id, a dash and an additional index are appended, like '$name-$index'. That index is increased accordingly on each call to this method. Mind that thus, it MUST be unique on your page. The $arrOptions array must contain the value-text pairs in the order to be added. The values are used in the radio button, and the text for the label appended.

Parameters
$name : string

The element name

$arrOptions : array<string|int, mixed>

The options array

$checked : string = ''

The optional preselected option key

$onchange : string = ''

The optional onchange event script

$attributeRadio : string = ''

Additional optional attributes for the radio button elements

$attributeLabel : string = ''

Additional optional attributes for the labels

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getRelativeUri()

Returns the page URI

public static getRelativeUri() : string

The URI contains neither the host nor the directory, but only the script file name and query string. //including the current CSRF parameter. This is ready for use with javascript. Apply contrexx_raw2xhtml() before using it in any href or action attribute.

Tags
see
getRelativeUri_entities()
Return values
string

The URI

getRelativeUri_entities()

Returns the page URI with all special characters substituted by their corresponding HTML entities

public static getRelativeUri_entities() : string

The URI contains neither the host nor the directory, but only the script file name and query string. //including the current CSRF parameter. This is ready for use in any href or action attribute. Apply html_entity_decode() before using it with javascript.

Tags
see
getRelativeUri()
Return values
string

The URI with entities

public static getRemoveAddLinks(mixed $id) : mixed
Parameters
$id : mixed

getSelect()

Returns HTML code for a dropdown menu

public static getSelect(string $name[, array<string|int, mixed> $arrOptions = array() ][, string $selected = '' ][, string $id = false ][, string $onchange = '' ][, string $attribute = '' ]) : string

If the name is empty, the empty string is returned. If the $id parameter is false, the id attribute is not set. If it's empty (but not false), the name is used instead.

Parameters
$name : string

The element name

$arrOptions : array<string|int, mixed> = array()

The options array

$selected : string = ''

The optional preselected option key

$id : string = false

The optional element id

$onchange : string = ''

The optional onchange event script

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getSelectCustom()

Returns HTML code for a custom dropdown menu

public static getSelectCustom(string $name[, string $strOptions = '' ][, string $id = false ][, string $onchange = '' ][, string $attribute = '' ]) : string

Similar to getSelect(), but takes a preproduced string for its options instead of an array and selected key. If the name is empty, the empty string is returned. If the $id parameter is false, the id attribute is not set. If it's empty (but not false), the name is used instead.

Parameters
$name : string

The element name

$strOptions : string = ''

The options string

$id : string = false

The optional element id

$onchange : string = ''

The optional onchange event script

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getTextarea()

Returns HTML code for a text area

public static getTextarea(string $name, string $value[, string $cols = '' ][, string $rows = '' ][, string $attribute = '' ]) : string

The $name parameter is used for both the element name and id attributes.

Parameters
$name : string

The element name

$value : string

The element value

$cols : string = ''

The optional number of columns

$rows : string = ''

The optional number of rows

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the element

getThumbnail()

Returns an image tag for the given Image object in the thumbnail size specified by the corresponding Imagetype

public static getThumbnail(Image $objImage[, string $attribute = '' ]) : string

This adds alt, width, and height attributes with the values returned by Image::getPath(), and ImageType::getInfoArrayWidth() methods repectively. If the $attribute parameter contains one of the alt, width, or height attributes (or corresponding style information), these will override the data from the Image or Imagetype.

Parameters
$objImage : Image

The Image object

$attribute : string = ''

Additional optional attributes

Tags
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML code for the image tag

getToggle()

Returns a clickable element that toggles its color and value

public static getToggle(string $name, array<string|int, mixed> $arrStatus[, string $id = '' ][, string $hidden_id = '' ][, bool $init = false ][, array<string|int, mixed> $arrTitle = false ]) : string

The $arrStatus array contains two key-value pairs. The key is the element's value, the value the corresponding HTML color. The first pair is used for off, the second for on. The initial value of the element is determined by $init; if it is true, the element starts on. The optional $arrTitle array may contain values for the title attribute to be used for the two states, in the same order as $arrStatus. If the $id parameter is empty, the class constant TOGGLE_ID_BASE is used for the id attribute base name. If the optional $hidden_id is empty, an additional hidden input element with the id attribute "hidden-" plus $id is created. Otherwise, this element must exist on the page and may be any kind of element with a value. Either one of the ids are also suffixed with the current $index_toggle number if they are empty and thus autocreated. You can style the element by defining a CSS class with the name "toggle" plus your $id; this defaults to "toggletoggle"... - sorry. :)

Parameters
$name : string

The element name

$arrStatus : array<string|int, mixed>

The status array

$id : string = ''

The optional id attribute name

$hidden_id : string = ''

The optional id attribute name of the element carrying the value

$init : bool = false

The optional initial status. Defaults to false

$arrTitle : array<string|int, mixed> = false

The optional title array

Return values
string

The element code

getTwinmenu()

Returns HMTL code for displaying two adjacent menus

public static getTwinmenu([array<string|int, mixed> &$options = null ]) : mixed

Options can be moved between the menus. The index "onsubmit" is added to the options array; insert this string into the onsubmit attribute of your form in order to have all options selected before submitting the form.

Parameters
$options : array<string|int, mixed> = null

The options array, by reference

makeRating()

Builds a raty element

public static makeRating(string $selector[, array<string|int, mixed> $options = null ]) : bool

This element lets you display a customizable star rating. Uses and activates jQuery. The selector will be passed to jQuery to select the element(s) to which the rating is applied (some

or similar will do, but that element must exist). The options array may contain any keys that are valid raty options, and their respective values. See http://plugins.jquery.com/project/raty for details. As of writing this (20110228), valid options and their respective defaults are: cancelHint: 'cancel this rating!' cancelOff: 'cancel-off.png' cancelOn: 'cancel-on.png' cancelPlace: 'left' click: null half: false hintList: ['bad', 'poor', 'regular', 'good', 'gorgeous'] iconRange: [] noRatedMsg: 'not rated yet' number: 5 path: 'img/' readOnly: false scoreName: 'score' showCancel: false starHalf: 'star-half.png' starOff: 'star-off.png' starOn: 'star-on.png' start: 0 Note that you MUST specify boolean option values as true or false, NOT as string literals "true" or "false". The latter will not work.

Parameters
$selector : string

The element selector

$options : array<string|int, mixed> = null

The optional raty options

Tags
link
http://plugins.jquery.com/project/raty
Return values
bool

True on success, false otherwise

replaceUriParameter()

Replaces the URI parameters given in the URI, by reference

public static replaceUriParameter(string &$uri, string $parameter) : void

Parameters whose names are present in the URI already are replaced with the new values from the $parameter string. Parameters from $parameter that are not already present in the URI are appended. The replaced/added parameters are separated by '&'. Note that this expects and produces URIs in the form as returned by getRelativeUri_entities(). It operates on a URI without entities, too, but the result will probably not be correct.

Parameters
$uri : string

The full URI, by reference

$parameter : string

The parameters to be replaced or added

shortenText()

Shortens text and appends an optional link to "more...".

public static shortenText(string $text[, int $max_length = 30 ][, string $more_uri = null ][, mixed $more_target = null ]) : string

Mind: the returned string is contrexx_raw2xhtml()d for the current charset!

Parameters
$text : string

The text

$max_length : int = 30

The maximum length

$more_uri : string = null

The optional target window

$more_target : mixed = null
Return values
string

The shortened text, with the optional link appended

stripUriParam()

Remove the parameter and its value from the URI string, by reference

public static stripUriParam(string &$uri, string $parameter_name) : string

If the parameter cannot be found, the URI is left unchanged. Note that this expects and produces URIs in the form as returned by getRelativeUri_entities(). It operates on a URI without entities, too, but the result will probably not be correct.

Parameters
$uri : string

The URI, by reference

$parameter_name : string

The name of the parameter

Return values
string

The former parameter value, or the empty string

getJavascript_Twinmenu()

Returns the Javascript code required by the Twinmenu

private static getJavascript_Twinmenu() : string

This method is called by getTwinmenu() and SHOULD NOT be used otherwise.

Tags
static
access

private

Return values
string

The Javascript code


        
On this page

Search results