Datamanager 2 Simple text datatype.

The text value encapsulated by this type is passed as-is to the storage layers, no specialties done, just a string.

Available configuration options:

  • int maxlength: The maximum length of the string allowed for this field. This includes any newlines, which account as at most two characters, depending on the OS. Set this to 0 (the default) to have unlimited input.
  • string output_mode: This option controls how convert_to_html operates. The default 'specialchars' will just pass the data entered in the field through htmlspecialchars(). See below for a full option listing.

Available output modes:

  • 'html': No conversion is done.
  • 'specialchars': The value is run through htmlspecialchars() (the default).
  • 'nl2br': The value is run through htmlspecialchars() and nl2br()
  • 'midgard_f': Uses the Midgard :f formatter.
  • 'midgard_F': Uses the Midgard :F formatter.
  • 'markdown': Uses net.nehmer.markdown.
package midcom.helper.datamanager2

 Methods

_on_initialize ()

_on_validate ()

The validation callback ensures that we don't have an array or an object as a value, which would be wrong.

Returns

booleanIndicating validity.

convert_from_csv ($source)

Parameters

$source

convert_from_storage ($source)

Parameters

$source

convert_to_csv ()

convert_to_html ()

convert_to_storage ()

purify_content ()

purify_string ($content)

Parameters

$content

validate_allowed_patterns ($fields)

Parameters

$fields

validate_forbidden_patterns ($fields)

Parameters

$fields

 Properties

 

mixed $allowed_patterns

Define array of forbidden patterns in this field

Example:

'type_config' => Array
(
    'allowed_patterns' => array
    (
        array
        (
            'type' => 'regex',
            'pattern' => '%^http://(mydomain|othernicedomain)\.(org|net)%i',
            'explanation' => 'Domains other than mydomain.net/org and othernicedomain.net/org are forbidden',
        ),
    ),
),
 

mixed $forbidden_patterns

Define array of forbidden patterns in this field

Example:

'type_config' => Array
(
    'output_mode' => 'markdown',
    'forbidden_patterns' => array
    (
        array
        (
            'type' => 'regex',
            'pattern' => '%(]*>[^<]*)%i',
            'explanation' => 'HTML-links are disallowed to combat spam',
        ),
    ),
),
 

int $maxlength

Maximum length of the string encapsulated by this type.

0 means no limit. This is checked during validation.

param
 

string $output_mode

Sets output formatting.

See class introduction.

 

mixed $purify

Run HTML contents through the HTML Purifier library to ensure safe XHTML compatibility.

If left undefined global config according to output_mode is used.

 

mixed $purify_config

Configuration values for HTML Purifier
 

mixed $purify_markdown_on_output

Whether Markdown fields should be purified when converted to HTML for output to remove disallowed tags

If left undefined global config is used.

 

mixed $specialchars_charset

Define the charset to use when htmlspecialchars() is called
 

mixed $specialchars_quotes

Define the quotes behavior when htmlspecialchars() is called
 

string $value

The current string encapsulated by this type.