Provides HTML-related methods
This class is implemented to use the UTF-8 character encoding. Please see http://flourishlib.com/docs/UTF-8 for more information.
1.0.0b8 | Changed encode() and prepare() to handle arrays of strings 5/19/10 |
---|---|
1.0.0b7 | Fixed a bug where some conditional comments were causing the regex in prepare() to break 11/4/09 |
1.0.0b6 | Updated showChecked() to require strict equality if one parameter is NULL 6/2/09 |
1.0.0b5 | Fixed prepare() so it does not encode multi-line HTML comments 5/9/09 |
1.0.0b4 | Added methods printOption() and showChecked() that were in fCRUD 5/8/09 |
1.0.0b3 | Fixed a bug where makeLinks() would double-link some URLs 1/8/09 |
1.0.0b2 | Fixed a bug where makeLinks() would create links out of URLs in HTML tags 12/5/08 |
1.0.0b | The initial implementation 9/25/07 |
Checks a string of HTML for block level elements
boolean containsBlockLevelHTML( string $content )
string | $content | The HTML content to check |
If the content contains a block level tag
Converts newlines into br tags as long as there aren't any block-level HTML tags present
void convertNewlines( string $content )
string | $content | The content to display |
Converts all HTML entities to normal characters, using UTF-8
string decode( string $content )
string | $content | The content to decode |
The decoded content
Converts all special characters to entites, using UTF-8.
string encode( string|array $content )
string|array | $content | The content to encode |
The encoded content
Takes a block of text and converts all URLs into HTML links
string makeLinks( string $content, integer $link_text_length=0 )
string | $content | The content to parse for links |
integer | $link_text_length | If non-zero, all link text will be truncated to this many characters |
The content with all URLs converted to HTML link
Prepares content for display in UTF-8 encoded HTML - allows HTML tags
string prepare( string|array $content )
string|array | $content | The content to prepare |
The encoded html
Prints an option tag with the provided value, using the selected value to determine if the option should be marked as selected
void printOption( string $text, string $value, string $selected_value=NULL )
string | $text | The text to display in the option tag |
string | $value | The value for the option |
string | $selected_value | If the value is the same as this, the option will be marked as selected |
Sets the proper Content-Type header for a UTF-8 HTML (or pseudo-XHTML) page
void sendHeader( )
Prints a p (or div if the content has block-level HTML) tag with the contents and the class specified - will not print if no content
boolean show( string $content, string $css_class='' )
string | $content | The content to display |
string | $css_class | The CSS class to apply |
If the content was shown
Prints a checked="checked" HTML input attribute if $value equals $checked_value, or if $value is in $checked_value
Please note that if either $value or $checked_value is NULL, a strict comparison will be performed, whereas normally a non-strict comparison is made. Thus 0 and FALSE will cause the checked attribute to be printed, but 0 and NULL will not.
boolean showChecked( string $value, string|array $checked_value )
string | $value | The value for the current HTML input tag |
string|array | $checked_value | The value (or array of values) that has been checked |
If the checked attribute was printed