|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00033 class Zend_Service_Technorati_Utils 00034 { 00044 public static function normalizeUriHttp($input) 00045 { 00046 // allow null as value 00047 if ($input === null) { 00048 return null; 00049 } 00050 00054 require_once 'Zend/Uri.php'; 00055 if ($input instanceof Zend_Uri_Http) { 00056 $uri = $input; 00057 } else { 00058 try { 00059 $uri = Zend_Uri::factory((string) $input); 00060 } 00061 // wrap exception under Zend_Service_Technorati_Exception object 00062 catch (Exception $e) { 00066 require_once 'Zend/Service/Technorati/Exception.php'; 00067 throw new Zend_Service_Technorati_Exception($e->getMessage(), 0, $e); 00068 } 00069 } 00070 00071 // allow inly Zend_Uri_Http objects or child classes 00072 if (!($uri instanceof Zend_Uri_Http)) { 00076 require_once 'Zend/Service/Technorati/Exception.php'; 00077 throw new Zend_Service_Technorati_Exception( 00078 "Invalid URL $uri, only HTTP(S) protocols can be used"); 00079 } 00080 00081 return $uri; 00082 } 00096 public static function normalizeDate($input) 00097 { 00101 require_once 'Zend/Date.php'; 00105 require_once 'Zend/Locale.php'; 00106 00107 // allow null as value and return valid Zend_Date objects 00108 if (($input === null) || ($input instanceof Zend_Date)) { 00109 return $input; 00110 } 00111 00112 // due to a BC break as of ZF 1.5 it's not safe to use Zend_Date::isDate() here 00113 // see ZF-2524, ZF-2334 00114 if (@strtotime($input) !== FALSE) { 00115 return new Zend_Date($input); 00116 } else { 00120 require_once 'Zend/Service/Technorati/Exception.php'; 00121 throw new Zend_Service_Technorati_Exception("'$input' is not a valid Date/Time"); 00122 } 00123 } 00124 00136 }