Class HtmlUtils

Description

Collection of utility methods to build and handle HTML code

Located in /core/util/HtmlUtils.class.php (line 38)

PHP2Go
   |
   --HtmlUtils
Method Summary
static void alert (string $msg)
static string anchor (string $url, string $text, [string $statusBarText = ''], [string $cssClass = ''], [array $jsEvents = array()], [string $target = ''], [string $name = ''], [string $id = ''], [string $rel = ''], [string $accessKey = ''])
static string button ([string $type = 'SUBMIT'], [string $id = ''], [string $value = ''], [string $script = ''], [string $alt = ''], [string $cssClass = ''], [string $accessKey = ''])
static void closeWindow ()
static string colorize (string $text, string $color, [string $tagName = 'span'])
static void confirm (string $msg, [string $trueAction = ''], [string $falseAction = ''])
static string definitionList (array $values, [string $listAttr = ''], [string $termAttr = ''], [string $defAttr = ''])
static string flashMovie (string $src, [int $wid = 0], [int $hei = 0], [array $vars = array()], [bool $transparent = FALSE])
static mixed focus (string $form, string $field, [string $object = ''], [bool $return = FALSE])
static void goBackN ([int $n = 1])
static string image (string $src, [string $alt = ''], [int $wid = 0], [int $hei = 0], [int $hspace = -1], [int $vspace = -1], [string $align = ''], [string $id = ''], [string $swpImage = ''], [string $cssClass = ''])
static string itemList (array $values, [bool $ordered = FALSE], [string $listAttr = ''], [string $itemAttr = ''])
static string mailtoAnchor (string $email, [string $text = ''], [string $statusBarText = ''], [string $cssClass = ''], [string $id = ''], [bool $obfuscate = TRUE])
static string mediaPlayerMovie (string $src, [int $wid = 0], [int $hei = 0], [array $flags = array()])
static string newLineToBr (string $str)
static string noBreakSpace ([int $n = 1])
static string overPopup (Document &$_Document, string $caption, [string $argumentList = ''])
static string parseLinks (string $str)
static string quickTimeMovie (string $src, [int $wid = 0], [int $hei = 0], [array $flags = array()])
static string realPlayerMovie (string $src, [int $wid = 0], [int $hei = 0], array $flags)
static void redirect (string $url, [string $object = "document"])
static void refresh (string $url, [int $time = 1])
static void replace (string $url)
static string scrollableArea (string $content, int $width, int $height, [string $overflow = 'auto'], [string $cssClass = ''], [string $id = ''])
static mixed statusBar (string $str, [bool $return = TRUE])
static string table (array $table, [bool $headers = TRUE], [string $tableAttr = ''], [string $cellAttr = ''], [string $alternateCellAttr = ''], [string $headerAttr = ''])
static string tagRepeat (string $tag, string $content, [int $n = 1])
static string window (string $url, [int $windowType = 255], [int $windowWidth = 640], [int $windowHeight = 480], [int $windowX = 0], [int $windowY = 0], [string $windowTitle = ''], [bool $windowReturn = FALSE])
Methods
static method alert (line 700)

Prints a Javascript alert command

static void alert (string $msg)
  • string $msg: Alert message
static method anchor (line 63)

Builds an anchor tag

Examples:

  1.  HtmlUtils::anchor('another_page.php');
  2.  HtmlUtils::anchor('http://www.website.com''Website''Website');
  3.  HtmlUtils::anchor('javascript:;''Link''Link'''array('onclick'=>'doSomething();'));

static string anchor (string $url, string $text, [string $statusBarText = ''], [string $cssClass = ''], [array $jsEvents = array()], [string $target = ''], [string $name = ''], [string $id = ''], [string $rel = ''], [string $accessKey = ''])
  • string $url: Target URL
  • string $text: Caption text
  • string $statusBarText: Status bar text (appears upon onmouseover)
  • string $cssClass: CSS class
  • array $jsEvents: Hashmap of JS event listeners
  • string $target: Target frame or window
  • string $name: Anchor name
  • string $id: Anchor ID
  • string $rel: Relathionship between the current document and the target document
  • string $accessKey: Access key
static method button (line 190)

Builds a BUTTON tag

Examples:

  1.  HtmlUtils::button('BUTTON''btnGo''Go'"onclick='go();'");
  2.  HtmlUtils::button('SUBMIT''btnSubmit''Send');
  3.  HtmlUtils::button('BUTTON''btnBack''Back'"onclick='history.back();'");

static string button ([string $type = 'SUBMIT'], [string $id = ''], [string $value = ''], [string $script = ''], [string $alt = ''], [string $cssClass = ''], [string $accessKey = ''])
  • string $type: Button type
  • string $id: Button ID
  • string $value: Button value
  • string $script: JS event listeners
  • string $alt: Alternate text
  • string $cssClass: CSS class
  • string $accessKey: Access key
static method closeWindow (line 788)

Prints JS code to close the current browser window

static void closeWindow ()
static method colorize (line 395)

Surrounds a given text with an HTML tag with color specification

Examples:

  1.  HtmlUtils::colorize($myText'red''span');
  2.  HtmlUtils::colorize($myText'#0000ff''div');

static string colorize (string $text, string $color, [string $tagName = 'span'])
  • string $text: Text
  • string $color: Color specification (name or RGB string)
  • string $tagName: Tag name
static method confirm (line 712)

Prints a Javascript confirm command

static void confirm (string $msg, [string $trueAction = ''], [string $falseAction = ''])
  • string $msg: Dialog message
  • string $trueAction: Ok action
  • string $falseAction: Cancel action
static method definitionList (line 300)

Builds the HTML code a list of terms and definitions

  • return: Generated HTML code
static string definitionList (array $values, [string $listAttr = ''], [string $termAttr = ''], [string $defAttr = ''])
  • array $values: Hash array of terms and definitions
  • string $listAttr: Attributes of the list
  • string $termAttr: Attributes for all terms
  • string $defAttr: Attributes for all definitions
static method flashMovie (line 472)

Builds the HTML code of an embedded flash movie

  • return: Generated HTML code
static string flashMovie (string $src, [int $wid = 0], [int $hei = 0], [array $vars = array()], [bool $transparent = FALSE])
  • string $src: SWF path
  • int $wid: Movie width
  • int $hei: Movie height
  • array $vars: Movie variables
  • bool $transparent: Transparent flag
static method focus (line 803)

Builds JS code that requests focus to a given form or form input

static mixed focus (string $form, string $field, [string $object = ''], [bool $return = FALSE])
  • string $form: Form name
  • string $field: Field name
  • string $object: Base document
  • bool $return: Whether the code should be returned or printed
static method goBackN (line 777)

Prints JS code to go back N positions based on browser history

static void goBackN ([int $n = 1])
  • int $n: Number of positions
static method image (line 155)

Builds an IMG tag

Examples:

  1.  // image path only
  2.  HtmlUtils::image('images/picture.gif');
  3.  // inline dimensions
  4.  HtmlUtils::image('images/photo.gif'''50100);
  5.  // id and swap image
  6.  HtmlUtils::image('images/button_off.gif'''00-1-1'''btnId''images/button_on.gif');

static string image (string $src, [string $alt = ''], [int $wid = 0], [int $hei = 0], [int $hspace = -1], [int $vspace = -1], [string $align = ''], [string $id = ''], [string $swpImage = ''], [string $cssClass = ''])
  • string $src: Image path
  • string $alt: Alternate text
  • int $wid: Image width
  • int $hei: Image height
  • int $hspace: Horizontal spacing
  • int $vspace: Vertical spacing
  • string $align: Image align
  • string $id: Image ID
  • string $swpImage: Swap image path
  • string $cssClass: CSS class
static method itemList (line 270)

Builds the HTML code of a list of items, using OL or UL tags

  • return: Generated HTML code
static string itemList (array $values, [bool $ordered = FALSE], [string $listAttr = ''], [string $itemAttr = ''])
  • array $values: List elements
  • bool $ordered: Whether to render an ordered (OL) or an unordered (UL) list
  • string $listAttr: Attributes of the list
  • string $itemAttr: Attributes for all list items
static method mailtoAnchor (line 109)

Builds a "mailto:" anchor

Optionally, the email address can be obfuscated to prevent against spammers.

Examples:

  1.  HtmlUtils::mailtoAnchor('foo@bar.org');
  2.  HtmlUtils::mailtoAnchor('foo@bar.org''Send me an e-mail''Send me an-email');

static string mailtoAnchor (string $email, [string $text = ''], [string $statusBarText = ''], [string $cssClass = ''], [string $id = ''], [bool $obfuscate = TRUE])
  • string $email: E-mail address
  • string $text: Caption text
  • string $statusBarText: Status bar text (appears upon onmouseover)
  • string $cssClass: CSS class
  • string $id: Anchor ID
  • bool $obfuscate: Whether email address should be obfuscated
static method mediaPlayerMovie (line 559)

Builds the HTML code of an embedded Windows Media Player movie

The supported flags are: CLIP_INFO, CLIP_STATUS, CONTROLS, AUTO_SIZE and AUTO_START.

  • return: Generated HTML code
static string mediaPlayerMovie (string $src, [int $wid = 0], [int $hei = 0], [array $flags = array()])
  • string $src: Movie path
  • int $wid: Movie width
  • int $hei: Movie height
  • array $flags: Flags
static method newLineToBr (line 440)

Transforms new lines into
tags

  • return: Processed text
static string newLineToBr (string $str)
  • string $str: Input text
static method noBreakSpace (line 408)

Render a sequence of no-break space chars

static string noBreakSpace ([int $n = 1])
  • int $n: Amount of chars
static method overPopup (line 684)

Builds the HTML code of a DHTML tooltip

The tooltip is based on the overlib library. The first argument must be a valid instance of Document class.

static string overPopup (Document &$_Document, string $caption, [string $argumentList = ''])
  • Document &$_Document: HTML document that will contain the tooltip
  • string $caption: Tooltip message
  • string $argumentList: Overlib arguments
static method parseLinks (line 453)

Transforms URLs found in a given text into links

Parses the following protocols: http, https, ftp, mailto and news.

  • return: Processed text
static string parseLinks (string $str)
  • string $str: Input text
static method quickTimeMovie (line 623)

Builds the HTML code of an embedded QuickTime movie

The supported flags are: CACHE, CONTROLS, LOOP, AUTO_START and AUTO_SIZE.

  • return: Generated HTML code
static string quickTimeMovie (string $src, [int $wid = 0], [int $hei = 0], [array $flags = array()])
  • string $src: Movie path
  • int $wid: Movie width
  • int $hei: Movie height
  • array $flags: Flags
static method realPlayerMovie (line 511)

Builds the HTML code of an embedded RealPlayer movie

Supported flags: CLIP_INFO, CLIP_STATUS, CONTROLS, AUTO_START and LOOP. Flag names are case-sensitive.

  • return: Generated HTML code
static string realPlayerMovie (string $src, [int $wid = 0], [int $hei = 0], array $flags)
  • string $src: Movie path
  • int $wid: Movie width
  • int $hei: Movie height
  • array $flags: Flags
static method redirect (line 742)

Prints JS code that redirects to another URL

static void redirect (string $url, [string $object = "document"])
  • string $url: Target URL
  • string $object: Source document
static method refresh (line 767)

Prints a META refresh tag

static void refresh (string $url, [int $time = 1])
  • string $url: Target URL
  • int $time: Seconds to wait before redirection
static method replace (line 755)

Prints JS code that replaces the current URL by another

static void replace (string $url)
  • string $url: Target URL
static method scrollableArea (line 252)

Builds the HTML code of a DIV with overflow handling

  • return: Generated HTML code
static string scrollableArea (string $content, int $width, int $height, [string $overflow = 'auto'], [string $cssClass = ''], [string $id = ''])
  • string $content: Contents
  • int $width: Width
  • int $height: Height
  • string $overflow: Overflow handling type
  • string $cssClass: CSS class
  • string $id: ID
static method statusBar (line 659)

Renders code that shows a message in the browser's status bar

static mixed statusBar (string $str, [bool $return = TRUE])
  • string $str: Message
  • bool $return: Whether the generated code should be returned or printed
static method table (line 340)

Builds the HTML code of a table, based on a given array

Example:

  1.  $table array(array('Name' => 'Foo')array('Name' => 'Bar')array('Name' => 'Baz'));
  2.  print HtmlUtils::table($tableTRUE""" class='odd_row'"" class='even_row'");

  • return: Generated HTML code
static string table (array $table, [bool $headers = TRUE], [string $tableAttr = ''], [string $cellAttr = ''], [string $alternateCellAttr = ''], [string $headerAttr = ''])
  • array $table: Table data
  • bool $headers: Whether table headers should be rendered
  • string $tableAttr: Attributes of the TABLE element
  • string $cellAttr: Attributes for all TD elements
  • string $alternateCellAttr: Alternating style (even/odd rows)
  • string $headerAttr: Attributes for all TH elements
static method tagRepeat (line 427)

Surrounds a text with a given tag N times

Example:

  1.  // prints <big><big>Hello World!</big></big>
  2.  print HtmlUtils::tagRepeat('big''Hello World!'2);

static string tagRepeat (string $tag, string $content, [int $n = 1])
  • string $tag: Tag name
  • string $content: Tag contents
  • int $n: How many times $tag must be rendered
static method window (line 231)

Builds a call to the Window.open JS function

Example:

  1.  $window HtmlUtils::window('page.php'48600400);
  2.  $link HtmlUtils::anchor('javascript:;''Open me''Open me'''array('onclick'=>$window));

static string window (string $url, [int $windowType = 255], [int $windowWidth = 640], [int $windowHeight = 480], [int $windowX = 0], [int $windowY = 0], [string $windowTitle = ''], [bool $windowReturn = FALSE])
  • string $url: Window URL
  • int $windowType: Window type (bitmap of chrome properties)
  • int $windowWidth: Window width
  • int $windowHeight: Window height
  • int $windowX: Window X position
  • int $windowY: Window Y position
  • string $windowTitle: Window title
  • bool $windowReturn: Whether to return the window object

Inherited Methods

Inherited From PHP2Go

PHP2Go::PHP2Go()
PHP2Go::equals()
PHP2Go::generateUniqueId()
PHP2Go::getClassName()
PHP2Go::getConfigVal()
PHP2Go::getLangVal()
PHP2Go::getObjectName()
PHP2Go::getParentName()
PHP2Go::hasDestructor()
PHP2Go::hashCode()
PHP2Go::isA()
PHP2Go::isSubclassOf()
PHP2Go::logError()
PHP2Go::raiseError()
PHP2Go::registerDestructor()
PHP2Go::registerShutdownFunc()
PHP2Go::retrieve()
PHP2Go::store()
PHP2Go::__toString()

Documentation generated on Sun, 07 Oct 2007 19:25:59 -0300 by phpDocumentor 1.3.2