.

DBFieldTextUrl Class Reference
[TextFields]

A field to hold an URL. More...

Inheritance diagram for DBFieldTextUrl:
DBFieldText DBField IDBField IPolicyHolder

List of all members.

Public Member Functions

  __construct ($name, $default_value=null, $policy=self::NOT_NULL)
  format ($value)
  Reformat passed value to DB format.
  validate ($value)
  Returns true, if the value passed fits the fields restrictions.

Detailed Description

A field to hold an URL.

Value gets validated and prefixed with http://, if it hasn't a scheme already.

Field in DB should be defined as VARCHAR(255)

URLs of course can be much longer than 255 chars, up to 4000 e.g. is Apache default. This however hardly makes sense.

Since:
0.5.1
Author:
Gerd Riesselmann

Definition at line 17 of file dbfield.text.url.cls.php.


Constructor & Destructor Documentation

DBFieldTextUrl::__construct ( name,
default_value = null,
policy = self::NOT_NULL  
)

Definition at line 18 of file dbfield.text.url.cls.php.

00018                                                                                           {
00019                 parent::__construct($name, 255, $default_value, $policy);
00020         }

Member Function Documentation

DBFieldTextUrl::format ( value  ) 

Reformat passed value to DB format.

Parameters:
mixed  $value
Returns:
string

Reimplemented from DBField.

Definition at line 50 of file dbfield.text.url.cls.php.

00050                                        {
00051                 if (Cast::string($value) === '') {
00052                         return 'NULL';
00053                 }
00054                 else {
00055                         return $this->quote(Url::create($value)->build(Url::ABSOLUTE, Url::NO_ENCODE_PARAMS));
00056                 }
00057         }
DBFieldTextUrl::validate ( value  ) 

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

Parameters:
string  $value
Returns:
Status

Reimplemented from DBFieldText.

Definition at line 28 of file dbfield.text.url.cls.php.

00028                                          {
00029                 $ret = parent::validate($value);
00030                 if ($ret->is_ok() && Cast::string($value) !== '') {
00031                         if (!Validation::is_url($value)) {
00032                                 $ret->append(tr(
00033                                         '%field must be an URL', 
00034                                         'textfields', 
00035                                         array(
00036                                                 '%field' => tr($this->get_field_name()),
00037                                         )
00038                                 ));
00039                         }
00040                 }
00041                 return $ret;
00042         }       

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