Uri.php

Go to the documentation of this file.
00001 <?php
00002 
00032 class Robo47_Validate_Uri extends Zend_Validate_Abstract
00033 {
00037     const NO_VALID_URI = 'noValidUri';
00038 
00044     protected $_messageTemplates = array(
00045         self::NO_VALID_URI => "URI '%value%' is not valid: '%message%'"
00046     );
00052     protected $_messageVariables = array(
00053         'message' => '_message',
00054         'value' => '_value'
00055     );
00059     protected $_message = '';
00060 
00064     public function isValid($value)
00065     {
00066         $this->_setValue($value);
00067         try {
00068             $uri = Zend_Uri::factory($value);
00069         } catch (Exception $e) {
00070             $this->_message = $e->getMessage();
00071             $this->_error(self::NO_VALID_URI, $value);
00072             return false;
00073         }
00074         return $uri->valid();
00075     }
00076 }