NAME

Labyrinth::MLUtils - Markup Language Utilities for Labyrinth.

SYNOPSIS

use Labyrinth::MLUtils;

FUNCTIONS

HTML Tag handling

LegalTag

Returns TRUE or FALSE as to whether the given HTML tag is accepted by the system.

LegalTags

Returns the list of HTML tags that are accepted by the system.

CleanTags

For a given text string, attempts to clean the use of any HTML tags. Any HTML tags found that are not accepted by the system are encoded into HTML entities.

CleanHTML

For a given text string, removes all existence of any HTML tag. Mostly used in input text box cleaning.

SafeHTML

For a given text string, encodes all HTML tags to HTML entities. Mostly used in input textarea edit preparation.

Attempts to remove known spam style links.

CleanWords

Attempts to remove known profanity words.

LinkTitles

Given a XHTML snippet, will look for basic links and add title attributes. Titles are of rhe format 'External Site: $domain', where $domain is the domain used in the link.

Returns a dropdown selection box given a list of numbers. Can optionally pass a option value to be pre-selected. The name of the form element is used as both the element name and id.

Returns a dropdown selection box given a list of strings. Can optionally pass a option value to be pre-selected. The name of the form element is used as both the element name and id.

Returns a dropdown selection box given a list of rows. Can optionally pass a option value to be pre-selected. The name of the form element is used as both the element name and id. The 'index' and 'value' refence the field names within each row hash.

Returns a dropdown selection box given a list of strings. Can optionally pass a option value to be pre-selected. The name of the form element is used as both the element name and id. The 'index' and 'value' refence the field names within each row hash.

Returns a dropdown multi-selection box given a list of strings. The name of the form element is used as both the element name and id. The default number of rows visible is 5, but this can be changed by providing a value for 'count'.

Can optionally pass an option value to be pre-selected. The option can be a comma separated list (as a single string) of values or an arrayref to a list of values.

Returns a dropdown multi-selection box given a list of rows. The name of the form element is used as both the element name and id. The default number of rows visible is 5, but this can be changed by providing a value for 'count'. The 'index' and 'value' refence the field names within each row hash.

Can optionally pass an option value to be pre-selected. The option can be a comma separated list (as a single string) of values or an arrayref to a list of values.

Error Functions

ErrorText

Returns the given error string in a HTML span tag, with the configured error class, which by default is called "alert". In your CSS sytle sheet you will need to specify an appropriate class declaration, such as:

.alert { color: red; font-weight: bold; }

Set the value of 'errorclass' in your site config file to change the class name used.

ErrorSymbol

Flags to the system that an error has occured and returns the configured error symbol, which by is the 'empty' symbol '∅', which can then be used as the error field indicator.

Set the value of 'errorsymbol' in your site config file to change the symbol used.

Protection Functions

LinkSpam

Checks whether any links exist in the given text that could indicate comment spam.

CSS Handling Code

create_inline_styles ( HASHREF )

Create inline CSS style sheet block. Key value pairs should match the label (tag, identifier or class patterns) and its contents. For example:

my %css = ( '#label p' => 'font-weight: normal; color: #fff;' );

or

my %css = ( '#label p' => { 'font-weight' => 'normal', 'color' => '#fff' } );

The exception to this is the label 'media', which can be used to specify the medium for which the CSS will be used. Typically these are 'screen' or 'print'.

HTML Demoroniser Code

demoroniser ( INPUT )

Given a string, will replace the Microsoft "smart" characters with sensible ACSII versions.

HTML Handling Code

The following functions disassemble and reassemble the HTML code snippets, validating and cleaning the code to fix any errors that may exist between the template and content of the database.

process_html ( INPUT [,LINE_BREAKS [,ALLOW]] )
escape_html ( INPUT )
unescape_html ( INPUT )
cleanup_attr_style
cleanup_attr_number
cleanup_attr_multilength
cleanup_attr_text
cleanup_attr_length
cleanup_attr_color
cleanup_attr_uri
cleanup_attr_tframe
cleanup_attr_trules
cleanup_html
cleanup_tag
cleanup_close
cleanup_cdata
cleanup_no_number
check_url_valid
cleanup_attr_inputtype
cleanup_attr_method
cleanup_attr_scriptlang
cleanup_attr_scripttype
strip_nonprintable

SEE ALSO

Labyrinth

AUTHOR

Barbie, <barbie@missbarbell.co.uk> for Miss Barbell Productions, http://www.missbarbell.co.uk/

COPYRIGHT & LICENSE

Copyright (C) 2002-2015 Barbie for Miss Barbell Productions
All Rights Reserved.

This module is free software; you can redistribute it and/or
modify it under the Artistic License 2.0.