.

DBFieldTextHtml Class Reference

A DB Text field holding HTML that automatically gets converted on storage. More...

Inheritance diagram for DBFieldTextHtml:
DBFieldText DBField IDBField IPolicyHolder

List of all members.

Public Member Functions

  __construct ($name, $length=self::BLOB_LENGTH_SMALL, $default_value=null, $policy=self::NONE)
  Constructor.
  validate ($value)
  Returns true, if the value passed fits the fields restrictions.

Protected Member Functions

  convert_value ($value)
  Apply storage conversion.
  do_format_not_null ($value)
  Format values that are not NULL.

Detailed Description

A DB Text field holding HTML that automatically gets converted on storage.

Definition at line 5 of file dbfield.text.html.cls.php.


Constructor & Destructor Documentation

DBFieldTextHtml::__construct ( name,
length = self::BLOB_LENGTH_SMALL,
default_value = null,
policy = self::NONE  
)

Constructor.

Since TEXT is more likely than varchar, default length is TEXT

Reimplemented from DBFieldText.

Definition at line 11 of file dbfield.text.html.cls.php.


Member Function Documentation

DBFieldTextHtml::convert_value ( value  )  [protected]

Apply storage conversion.

Definition at line 61 of file dbfield.text.html.cls.php.

00061                                                  {
00062                 return HtmlText::apply_conversion(HtmlText::STORAGE, $value, $this->get_table()->get_table_name());
00063         }
DBFieldTextHtml::do_format_not_null ( value  )  [protected]

Format values that are not NULL.

Parameters:
mixed  $value
Returns:
string

Reimplemented from DBField.

Definition at line 52 of file dbfield.text.html.cls.php.

00052                                                       {
00053                 return parent::do_format_not_null(
00054                         $this->convert_value($value)
00055                 );
00056         }
DBFieldTextHtml::validate ( value  ) 

Returns true, if the value passed fits the fields restrictions.

Parameters:
string  $value
Returns:
Status

Reimplemented from DBFieldText.

Definition at line 21 of file dbfield.text.html.cls.php.

00021                                          {
00022                 $ret = new Status();
00023                 if (!$this->is_null($value)) {
00024                         $value = $this->convert_value($value);
00025                 }
00026                 if ($value !== '') {
00027                         // This test for empty HTML, like <p><span></span></p>, which will not be allowed
00028                         // @TODO what about <img />?
00029                         $test = String::preg_replace('|\W|ms', '', strip_tags($value)); 
00030                         if ($test === '' && !$this->get_null_allowed()) {
00031                                 $ret->append(tr(
00032                                         '%field may not be empty', 
00033                                         'core', 
00034                                         array(
00035                                                 '%field' => $this->get_field_name_translation(),
00036                                         )
00037                                 ));
00038                         }
00039                 }
00040                 if($ret->is_ok()) {
00041                         $ret->merge(parent::validate($value));
00042                 }
00043                 return $ret;
00044         }

The documentation for this class was generated from the following file: