ZenMagick 0.9.6


org.zenmagick.rp.toolbox.defaults.ZMToolboxHtml

Class ZMToolboxHtml

ZMObject
|
+--ZMToolboxHtml

public class ZMToolboxHtml
extends ZMObject

HTML utilities.

Author:
DerManoMann
Version:
$Id: ZMToolboxHtml.php 2167 2009-04-17 04:52:43Z dermanomann $

Fields inherited from org.zenmagick.ZMObject
properties_
Method Summary
string

backLink(string text, array attr, boolean echo)

Create a full back link.

string

encode(string s, boolean echo)

Encode a given string to valid HTML.

string

ezpageLink(integer id, string text, array attr, boolean echo)

Create a full HTML <a> tag pointig to an ezpage.

string

fieldMessages(string name, boolean echo)

Show form field specific error messages.

string

hrefTarget(boolean newWin, boolean echo)

Create a HTML target or onclick attribute for a HTML <a> tag.

string

image(ZMImageInfo imageInfo, string format, mixed parameter, boolean echo)

Creates a HTML <img> tag for the given ZMImageInfo.

string

more(string s, int max, string more, boolean echo)

Truncate text.

string

onload(string page, boolean echo)

Get optional onload handler attribute for the current page.

string

productImageLink(ZMProduct product, int categoryId, array attr, string format, boolean echo)

Create a HTML <a> tag with the product image of the given product.

string

strip(string text, boolean echo)

Strip HTML tags from the given text.

string

text2html(string s)

Convert text based user input into HTML.

Methods inherited from org.zenmagick.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Method Detail

backLink

public string backLink(string text, array attr, boolean echo)

Create a full back link.

Return a full HTML <a> tag.

Since the link text may be HTML, no HTML escaping is done in this method.

Parameters:
text - The link text (can be plain text or HTML).
attr - Optional HTML attribute map; default is an empty array().
echo - If true, the URI will be echo'ed as well as returned.
Returns:
A fully formated HTML <a> tag.

encode

public string encode(string s, boolean echo)

Encode a given string to valid HTML.

Parameters:
s - The string to encode.
echo - If true, the escaped string will be echo'ed as well as returned.
Returns:
The encoded HTML.

ezpageLink

public string ezpageLink(integer id, string text, array attr, boolean echo)

Create a full HTML <a> tag pointig to an ezpage.

Since the link text may be HTML, no HTML escaping is done on the $text parameter.

Parameters:
id - The EZ page id.
text - Optional link text; default is null to use the ezpage title as link text.
attr - Optional HTML attribute map; default is an empty array().
echo - If true, the link will be echo'ed as well as returned.
Returns:
A full HTML link.

fieldMessages

public string fieldMessages(string name, boolean echo)

Show form field specific error messages.

The generated ul tag will have the value [$name]Info as id, and a class of fieldMsg. Each li will have the type as class assigned.

Messages are HTML escaped/encoded but no further localization is done.

Parameters:
name - The field name.
echo - If true, the URI will be echo'ed as well as returned.
Returns:
HTML unordered list of messages or null.

hrefTarget

public string hrefTarget(boolean newWin, boolean echo)

Create a HTML target or onclick attribute for a HTML <a> tag.

Behaviour is controlled with the ZenMagick setting isJSTarget.

Parameters:
newWin - If true, HTML for opening in a new window will be created.
echo - If true, the formatted text will be echo'ed as well as returned.
Returns:
A preformatted attribute in the form ' name="value"'

image

public string image(ZMImageInfo imageInfo, string format, mixed parameter, boolean echo)

Creates a HTML <img> tag for the given ZMImageInfo.

Parameters:
imageInfo - The image info.
format - Can be either of ZMProducts::IMAGE_SMALL, ZMProducts::IMAGE_MEDIUM * or ZMProducts::IMAGE_LARGE; default is >ZMProducts::IMAGE_SMALL.
parameter - Additional parameter for the <mg> tag; can be either * a query string style list of name/value pairs or a map.
echo - If true, the URI will be echo'ed as well as returned.
Returns:
A fully formated HTML <img> tag.

more

public string more(string s, int max, string more, boolean echo)

Truncate text.

Parameters:
s - The text.
max - The number of allowed characters; default is 0 for all.
more - Optional string that will be appended to indicate that the text was truncated; default is ....
echo - If true, the URI will be echo'ed as well as returned.
Returns:
The (possibly) truncated text.

onload

public string onload(string page, boolean echo)

Get optional onload handler attribute for the current page.

The generated HTML is in the form onload="SOME JAVASCRIPT".

Parameters:
page - The page name; default is null for the current page.
echo - If true, the URI will be echo'ed as well as returned.
Returns:
A complete onload attribute incl. value or an empty string.
Deprecated.

productImageLink

public string productImageLink(ZMProduct product, int categoryId, array attr, string format, boolean echo)

Create a HTML <a> tag with the product image of the given product.

This one will return a fully encoded HTML <img> tag.

Parameters:
product - A product.
categoryId - Optional category id.
attr - Optional HTML attribute map; default is null.
format - Can be either of ZMProducts::IMAGE_SMALL, ZMProducts::IMAGE_MEDIUM * or ZMProducts::IMAGE_LARGE; default is ZMProducts::IMAGE_SMALL.
echo - If true, the URI will be echo'ed as well as returned.
Returns:
A fully formated HTML <a> tag.

strip

public string strip(string text, boolean echo)

Strip HTML tags from the given text.

Parameters:
text - The text to clean up.
echo - If true, the stripped text will be echo'ed as well as returned.
Returns:
The stripped text.

text2html

public string text2html(string s)

Convert text based user input into HTML.

Parameters:
s - The input string.
Returns:
HTML formatted text.

ZenMagick 0.9.6