Section A.12. HTML

A.12. HTML

A.12.1. HTML_BBCodeParser

Repository: PEAR - License: PHP License - By Stijn de Reede (lead)

This is a parser to replace UBB style tags with their html equivalents.

A.12.1.1 Description

This is a parser to replace UBB style tags with their html equivalents. It does not simply do some regex calls, but is complete stack based parse engine. This ensures that all tags are properly nested, if not, extra tags are added to maintain the nesting. This parser should only produce xhtml 1.0 compliant code. All tags are validated and so are all their attributes. It should be easy to extend this parser with your own tags.

A.12.2. HTML_Common

Repository: PEAR - License: PHP License - By Adam Daniel (lead) - Bertrand Mansion (lead)

PEAR::HTML_Common is a base class for other HTML classes.

A.12.2.1 Description

The PEAR::HTML_Common package provides methods for html code display and attributes handling.

  • Methods to set, remove, update html attributes.

  • Handles comments in HTML code.

  • Handles layout, tabs, line endings for nicer HTML code.

A.12.3. HTML_Crypt

Repository: - License: PHP License -

Encrypts text which is later decoded using javascript on the client side

A.12.3.1 Description

The PEAR::HTML_Crypt provides methods to encrypt text, which can be later be decrypted using JavaScript on the client side This is very useful to prevent spam robots collecting email addresses from your site, included is a method to add mailto links to the text being generated.

A.12.4. HTML_CSS

Repository: PEAR - License: PHP License 3.0 - By Klaus Guenther (lead) - Laurent Laville (developer)

HTML_CSS is a class for generating CSS declarations.

A.12.4.1 Description

HTML_CSS provides a simple interface for generating a stylesheet declaration. It is completely standards compliant, and has some great features:

  • Simple OO interface to CSS definitions

  • Can parse existing CSS (string or file)

  • Output to

    • Inline stylesheet declarations

    • Document internal stylesheet declarations

    • Standalone stylesheet declarations

    • Array of definitions

    • File

In addition, it shares the following with HTML_Common based classes:

  • Indent style support

  • Line ending style

A.12.5. HTML_Form

Repository: PEAR - License: PHP License - By Stig Sæther Bakken (lead)

Simple HTML form package

A.12.5.1 Description

This is a simple HTML form generator. It supports all the HTML form element types including file uploads, may return or print the form, just individual form elements or the full form in "table mode" with a fixed layout.

A.12.6. HTML_Javascript

Repository: PEAR - License: PHP 3.0 - By Tal Peer (lead) - Pierre-Alain Joye (lead)

Provides an interface for creating simple JS scripts.

A.12.6.1 Description

Provides two classes:

  • HTML_Javascript for performing basic JS operations.

  • HTML_Javascript_Convert for converting variables

Allow output data to a file, to the standart output(print), or return

A.12.7. HTML_Menu

Repository: PEAR - License: PHP License - By Ulf Wendel (lead) - Alexey Borzov (lead)

Generates HTML menus from multidimensional hashes.

A.12.7.1 Description

With the HTML_Menu class one can easily create and maintain a navigation structure for websites, configuring it via a multidimensional hash structure. Different modes for the HTML output are supported.

A.12.8. HTML_Page

Repository: PEAR - License: PHP License 3.0 - By Klaus Guenther (lead) - Adam Daniel (lead)

PEAR::HTML_Page is a base class for XHTML page generation.

A.12.8.1 Description

The PEAR::HTML_Page package provides a simple interface for generating an XHTML compliant page.

  • supports virtually all HTML doctypes, from HTML 2.0 through XHTML 1.1 and XHTML Basic 1.0

plus preliminary support for XHTML 2.0

  • namespace support

  • global language declaration for the document

  • line ending styles

  • full META tag support

  • support for stylesheet declaration in the head section

  • support for linked stylesheets and scripts

  • body can be a string, object with toHtml or toString methods or an array (can be combined)

A.12.9. html_parse

Repository: PECL - License: PHP License - By Hartmut Holzgraefe (lead)

HTML parser extenion

A.12.9.1 Description

HTML parser extension based on the ekhtml library (

A.12.10. HTML_Progress

Repository: PEAR - License: PHP License 3.0 - By Laurent Laville (lead) - Stefan Neufeind (contributor) - Christian Wenz (helper)

How to include a loading bar in your XHTML documents quickly and easily.

A.12.10.1 Description

This package provides a way to add a loading bar fully customizable in existing XHTML documents.

Your browser should accept DHTML feature.


  • create horizontal, vertival bar and also circle, ellipse and polygons (square, rectangle)

  • allows usage of an existing external StyleSheet and/or JavaScript

  • all elements (progress, cells, string) are customizable by their html properties

  • percent/string is floating all around the progress bar

  • compliant with all CSS/XHMTL standards

  • integration with all template engines is very easy

  • implements a Observer design pattern. It is possible to add Listeners.

  • adds a customizable UI monitor pattern to display a progress bar.

  • User-end can abort progress at any time.

  • Look and feel can be sets by internal API or external config file.

  • Allows many progress bar on same page without uses of iframe solution.

  • Since release 1.1 you may upload your files with ftp and display an indeterminate progress bar during operation.

A.12.11. HTML_QuickForm

Repository: PEAR - License: PHP License - By Bertrand Mansion (lead) - Adam Daniel (lead) - Alexey Borzov (lead) - Jason Rust (developer) - Thomas Schulz (developer)

The PEAR::HTML_QuickForm package provides methods for creating, validating, processing HTML forms.

A.12.11.1 Description

The HTML_QuickForm package provides methods for dynamically create, validate and render HTML forms.


  • More than 20 ready-to-use form elements.

  • XHTML compliant generated code.

  • Numerous mixable and extendable validation rules.

  • Automatic server-side validation and filtering.

  • On request javascript code generation for client-side validation.

  • File uploads support.

  • Total customization of form rendering.

  • Support for external template engines (ITX, Sigma, Flexy, Smarty).

  • Pluggable elements, rules and renderers extensions.

A.12.12. HTML_QuickForm_Controller

Repository: PEAR - License: PHP License - By Alexey Borzov (lead) - Bertrand Mansion (developer)

The add-on to HTML_QuickForm package that allows building of multipage forms

A.12.12.1 Description

The package is essentially an implementation of a PageController pattern.


  • Controller class that examines HTTP requests and manages form values persistence across requests.

  • Page class (subclass of QuickForm) representing a single page of the form.

  • Business logic is contained in subclasses of Action class.

Cool features:

  • Includes several default Actions that allow easy building of multipage forms.

  • Includes usage examples for common usage cases (single-page form, wizard, tabbed form).

A.12.13. HTML_Select

Repository: PEAR - License: PHP License - By Klaus Guenther (lead) - Adam Daniel (lead)

HTML_Select is a class for generating HTML form select elements.

A.12.13.1 Description

HTML_Select provides an OOP way of generating HTML form select elements.

A.12.14. HTML_Select_Common

Repository: PEAR - License: BSD - By Derick Rethans (lead) - Richard Heyes (lead)

Some small classes to handle common <select> lists

A.12.14.1 Description

Provides &lt;select&gt; lists for:

  • Country

  • UK counties

  • US States

  • FR Departements

A.12.15. HTML_Table

Repository: PEAR - License: PHP License - By Bertrand Mansion (lead) - Adam Daniel (lead)

PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and efficient.

A.12.15.1 Description

The PEAR::HTML_Table package provides methods for easy and efficient design of HTML tables.

  • Lots of customization options.

  • Tables can be modified at any time.

  • The logic is the same as standard HTML editors.

  • Handles col and rowspans.

  • PHP code is shorter, easier to read and to maintain.

  • Tables options can be reused.

A.12.16. HTML_Table_Matrix

Repository: PEAR - License: PHP License v3.0 - By Ian Eure (lead)

Autofill a table with data

A.12.16.1 Description

HTML_Table_Matrix is an extension to HTML_Table which allows you to easily fill up a table with data.


  • It uses Filler classes to determine how the data gets filled in the table. With a custom Filler, you can fill data in up, down, forwards, backwards, diagonally, randomly or any other way you like.

  • Comes with Fillers to fill left-to-right-top-to-bottom and right-to-left-top-to-bottom.

  • Abstract Filler methods keep the code clean & easy to understand.

  • Table height or width may be omitted, and it will figure out the correct table size based on the data you provide.

  • It integrates handily with Pager to create pleasant pageable table layouts, such as for an image gallery. Just specify a height or width, Filler, and feed it the data returned from Pager.

  • Table may be constrained to a specific height or width, and excess data will be ignored.

  • Fill offset may be specified, to leave room for a table header, or other elements in the table.

  • Fully documented with PHPDoc.

  • Includes fully functional example code.

A.12.17. HTML_Table_Sortable

Repository: - License: PHP License -

A class to build sortable tables.

A.12.17.1 Description

For the JavaScript-enabled clients it uses Javascript as the frontend and for the other clients it will be sortable thru clicking on the heading and refreshing the page.

There are 4 built in supported sort types:

  • String

  • Case insensitive string

  • Number

  • Date

A.12.18. HTML_Template_Flexy

Repository: PEAR - License: PHP License - By Alan Knowles (lead)

An extremely powerful Tokenizer driven Template engine

A.12.18.1 Description

HTML_Template_Flexy started it's life as a simplification of HTML_Template_Xipe, however in Version 0.2, It became one of the first template engine to use a real Lexer, rather than regex'es, making it possible to do things like or Cold Fusion tags.

However, it still has a very simple set of goals.

  • Very Simple API,

    • easy to learn...

    • prevents to much logic going in templates

  • Easy to write document'able code

    • By using object vars for a template rather than 'assign', you can use phpdoc comments to list what variable you use.

  • Editable in WYSIWYG editors

    • you can create full featured templates, that doesnt get broken every time you edit with Dreamweaver(tm) or Mozzila editor

    • Uses namespaced attributes to add looping/conditionals

  • Extremely Fast,

    • runtime is at least 4 time smaller than most other template engines (eg. Smarty)

    • uses compiled templates, as a result it is many times faster on blocks and loops than than Regex templates (eg. IT/phplib)

  • Safer (for cross site scripting attacks)

    • All variables default to be output as HTML escaped (overridden with the :h modifier)

  • Multilanguage support

    • Parses strings out of template, so you can build translation tools

    • Compiles language specific templates (so translation is only done once, not on every request)

  • Full dynamic element support (like ASP.NET), so you can pick elements to replace at runtime


  • {variable} to echo $object->variable

  • {method()} to echo $object->method();

  • {foreach:var,key,value} to PHP foreach loops

  • tag attributes FLEXY:FOREACH, FLEXY:IF for looping and conditional HTML inclusion

  • {if:variable} to PHP If statement

  • {if:method()} to PHP If statement

  • {else:} and {end:} to close or alternate If statements

  • FORM to HTML_Template_Flexy_Element's

  • replacement of INPUT, TEXTAREA and SELECT tags with HTML_Template_Flexy_Element code use FLEXY:IGNORE (inherited) and FLEXY:IGNOREONLY (single) to prevent replacements

  • FLEXY:START/FLEXY:STARTCHILDREN tags to define where template starts/finishes

  • support for urlencoded braces {} in HTML attributes.

  • documentation in the pear manual

  • examples at

A.12.19. HTML_Template_IT

Repository: PEAR - License: PHP License - By Ulf Wendel (lead) - Pierre-Alain Joye (lead)

Integrated Templates

A.12.19.1 Description


Simple template API.

The Isotemplate API is somewhat tricky for a beginner although it is the best one you can build. template::parse() [phplib template = Isotemplate] requests you to name a source and a target where the current block gets parsed into. Source and target can be block names or even handler names. This API gives you a maximum of fexibility but you always have to know what you do which is quite unusual for php skripter like me.

I noticed that I do not any control on which block gets parsed into which one. If all blocks are within one file, the script knows how they are nested and in which way you have to parse them. IT knows that inner1 is a child of block2, there's no need to tell him about this.

Features :

  • Nested blocks

  • Include external file

  • Custom tags format (default {mytag})

HTML_Template_ITX :

With this class you get the full power of the phplib template class. You may have one file with blocks in it but you have as well one main file and multiple files one for each block. This is quite usefull when you have user configurable websites. Using blocks not in the main template allows you to modify some parts of your layout easily.

A.12.20. HTML_Template_PHPLIB

Repository: PEAR - License: LGPL - By Björn Schotte (lead)

preg_* based template system.

A.12.20.1 Description

The popular Template system from PHPLIB ported to PEAR. It has some features that can't be found currently in the original version like fallback paths. It has minor improvements and cleanup in the code as well as some speed improvements.

A.12.21. HTML_Template_Sigma

Repository: PEAR - License: PHP License - By Alexey Borzov (lead)

An implementation of Integrated Templates API with template 'compilation' added

A.12.21.1 Description

HTML_Template_Sigma implements Integrated Templates API designed by Ulf Wendel.


  • Nested blocks. Nesting is controlled by the engine.

  • Ability to include files from within template: &lt;!-- INCLUDE --&gt;

  • Automatic removal of empty blocks and unknown variables (methods to manually tweak/override this are also available)

  • Methods for runtime addition and replacement of blocks in templates

  • Ability to insert simple function calls into templates: func_uppercase('Hello world!') and to define callback functions for these

  • 'Compiled' templates: the engine has to parse a template file using regular expressions to find all the blocks and variable placeholders. This is a very "expensive" operation and is an overkill to do on every page request: templates seldom change on production websites. Thus this feature: an internal representation of the template structure is saved into a file and this file gets loaded instead of the source one on subsequent requests (unless the source changes)

  • PHPUnit-based tests to define correct behaviour

  • Usage examples for most of the features are available, look in the docs/ directory

A.12.22. HTML_Template_Xipe

Repository: PEAR - License: PHP License - By Wolfram Kriesing (lead)

A simple, fast and powerful template engine.

A.12.22.1 Description

The template engine is a compiling engine, all templates are compiled into PHP-files. This will make the delivery of the files faster on the next request, since the template doesn't need to be compiled again. If the template changes it will be recompiled.

There is no new template language to learn. Beside the default mode, there is a set of constructs since version 1.6 which allow you to edit your templates with WYSIWYG editors.

By default the template engine uses indention for building blocks (you can turn that off). This feature was inspired by Python and by the need I felt to force myself to write proper HTML-code, using proper indentions, to make the code better readable.

Every template is customizable in multiple ways. You can configure each template or an entire directory to use different delimiters, caching parameters, etc. via either an XML-file or a XML-chunk which you simply write anywhere inside the tpl-code.

Using the Cache the final file can also be cached (i.e. a resulting HTML-file). The caching options can be customized as needed. The cache can reduce the server load by very much, since the entire php-file doesn't need to be processed again, the resulting client-readable data are simply delivered right from the cache (the data are saved using php's output buffering).

The template engine is prepared to be used for multi-language applications too. If you i.e. use the PEAR::I18N for translating the template, the compiled templates need to be saved under a different name for each language. The template engine is prepared for that too, it saves the compiled template including the language code if required (i.e. a compiled index.tpl which is saved for english gets the filename index.tpl.en.php).

A.12.23. HTML_TreeMenu

Repository: PEAR - License: BSD - By Richard Heyes (lead)

Provides an api to create a HTML tree

A.12.23.1 Description

PHP Based api creates a tree structure using a couple of small PHP classes. This can then be converted to javascript using the printMenu() method. The tree is dynamic in IE 4 or higher, NN6/Mozilla and Opera 7, and maintains state (the collapsed/expanded status of the branches) by using cookies. Other browsers display the tree fully expanded. Each node can have an optional link and icon. New API in 1.1 with many changes (see CVS for changelog) and new features, of which most came from Chip Chapin (

A.12.24. Pager

Repository: PEAR - License: PHP License - By Lorenzo Alberton (lead) - Richard Heyes (lead)

Data paging class

A.12.24.1 Description

It takes an array of data as input and page it according to various parameters. It also builds links within a specified range, and allows complete customization of the output (it even works with mod_rewrite). Two modes available: "Jumping" and "Sliding" window style.

A.12.25. Pager_Sliding

Repository: PEAR - License: PHP License - By Lorenzo Alberton (lead)

Sliding Window Pager.

A.12.25.1 Description

It takes an array of data as input and page it according to various parameters. It also builds links within a specified range, and allows complete customization of the output (it even works with mod_rewrite). It is compatible with PEAR::Pager's API.

[Deprecated]Use PEAR::Pager v2.x with $mode = 'Sliding' instead

A.12.26. tidy

Repository: PECL - License: PHP - By John Coggeshall (lead) - Ilia Alshanetsky (developer)

Tidy HTML Repairing and Parsing

A.12.26.1 Description

Tidy is a binding for the Tidy HTML clean and repair utility which allows you to not only clean and otherwise manipluate HTML documents, but also traverse the document tree using the Zend Engine 2 OO semantics.

    PHP 5 Power Programming
    PHP 5 Power Programming
    ISBN: 013147149X
    EAN: 2147483647
    Year: 2003
    Pages: 240

    Similar book on Amazon © 2008-2017.
    If you may any questions please contact us: