Index: /branches/version-2_13-dev/data/class/pages/upgrade/LC_Page_Upgrade_ProductsList.php
===================================================================
--- /branches/version-2_13-dev/data/class/pages/upgrade/LC_Page_Upgrade_ProductsList.php	(revision 23128)
+++ /branches/version-2_13-dev/data/class/pages/upgrade/LC_Page_Upgrade_ProductsList.php	(revision 23141)
@@ -87,5 +87,4 @@
         );
         $objReq = $this->request('products_list', $arrPostData);
-        $response = $objReq->send();
 
         // リクエストチェック
@@ -101,6 +100,5 @@
         // レスポンスチェック
         $objLog->log('* http response check start');
-
-        if ( $response->getStatus() !== 200) {
+        if ($objReq->getResponseCode() !== 200) {
             $objJson->setError(OSTORE_E_C_HTTP_RESP);
             $objJson->display();
@@ -110,5 +108,5 @@
         }
 
-        $body = $response->getBody();
+        $body = $objReq->getResponseBody();
         $objRet = $objJson->decode($body);
 
Index: /branches/version-2_13-dev/data/class/pages/upgrade/LC_Page_Upgrade_Download.php
===================================================================
--- /branches/version-2_13-dev/data/class/pages/upgrade/LC_Page_Upgrade_Download.php	(revision 23133)
+++ /branches/version-2_13-dev/data/class/pages/upgrade/LC_Page_Upgrade_Download.php	(revision 23141)
@@ -130,5 +130,4 @@
 
         $objReq = $this->request($mode, $arrPostData);
-        $response = $objReq->send();
 
         // リクエストチェック
@@ -144,5 +143,5 @@
         // レスポンスチェック
         $objLog->log('* http response check start');
-        if ($response->getStatus() !== 200) {
+        if ($objReq->getResponseCode() !== 200) {
             $objJson->setError(OSTORE_E_C_HTTP_RESP);
             $objJson->display();
@@ -152,5 +151,5 @@
         }
 
-        $body = $response->getBody();
+        $body = $objReq->getResponseBody();
         $objRet = $objJson->decode($body);
 
@@ -231,5 +230,5 @@
             // 配信サーバーへ通知
             $objLog->log('* notify to lockon server start');
-            $objReq = $this->notifyDownload($mode, $response->getCookies());
+            $objReq = $this->notifyDownload($mode, $objReq->getResponseCookies());
 
             $objLog->log('* dl commit result:' . serialize($objReq));
Index: /branches/version-2_13-dev/data/class/pages/upgrade/LC_Page_Upgrade_Base.php
===================================================================
--- /branches/version-2_13-dev/data/class/pages/upgrade/LC_Page_Upgrade_Base.php	(revision 23125)
+++ /branches/version-2_13-dev/data/class/pages/upgrade/LC_Page_Upgrade_Base.php	(revision 23141)
@@ -71,10 +71,10 @@
     public function request($mode, $arrParams = array(), $arrCookies = array())
     {
-        $objReq = new HTTP_Request2();
+        $objReq = new HTTP_Request();
         $objReq->setUrl(OSTORE_URL . 'upgrade/index.php');
         $objReq->setMethod('POST');
-        $objReq->addPostParameter('mode', $mode);
+        $objReq->addPostData('mode', $mode);
         foreach ($arrParams as $key => $val) {
-            $objReq->addPostParameter($key, $val);
+            $objReq->addPostData($key, $val);
         }
 
@@ -83,5 +83,5 @@
         }
 
-        $e = $objReq->send();
+        $e = $objReq->sendRequest();
         if (PEAR::isError($e)) {
             return $e;
Index: /branches/version-2_13-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php
===================================================================
--- /branches/version-2_13-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php	(revision 23125)
+++ /branches/version-2_13-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php	(revision 23141)
@@ -354,10 +354,10 @@
         // Proxy経由を可能とする。
         // TODO Proxyの設定は「data/module/HTTP/Request.php」内の「function HTTP_Request」へ記述する。いずれは、外部設定としたい。
-        $req = new HTTP_Request2();
+        $req = new HTTP_Request();
 
         $req->setURL(ZIP_DOWNLOAD_URL);
 
         // 郵便番号CSVをdownloadする。
-        $res = $req->send();
+        $res = $req->sendRequest();
         if (!$res || strlen($res) > 1) {
             trigger_error(ZIP_DOWNLOAD_URL . ' の取得に失敗しました。', E_USER_ERROR);
@@ -369,5 +369,5 @@
             trigger_error($this->zip_csv_temp_realfile . ' を開けません。', E_USER_ERROR);
         }
-        $res = fwrite($fp, $res->getBody());
+        $res = fwrite($fp, $req->getResponseBody());
         if (!$res) {
             trigger_error($this->zip_csv_temp_realfile . ' への書き込みに失敗しました。', E_USER_ERROR);
Index: /branches/version-2_13-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Calendar.php
===================================================================
--- /branches/version-2_13-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Calendar.php	(revision 23125)
+++ /branches/version-2_13-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Calendar.php	(revision 23141)
@@ -22,4 +22,5 @@
  */
 
+define('CALENDAR_ROOT', DATA_REALDIR.'module/Calendar'.DIRECTORY_SEPARATOR);
 require_once CLASS_EX_REALDIR . 'page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_Ex.php';
 
Index: /branches/version-2_13-dev/data/class/SC_Cache.php
===================================================================
--- /branches/version-2_13-dev/data/class/SC_Cache.php	(revision 23125)
+++ /branches/version-2_13-dev/data/class/SC_Cache.php	(revision 23141)
@@ -21,4 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
+
+require DATA_REALDIR . 'module/Cache/Lite.php';
 
 /**
Index: /branches/version-2_13-dev/data/module/Mail/null.php
===================================================================
--- /branches/version-2_13-dev/data/module/Mail/null.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Mail/null.php	(revision 23141)
@@ -40,5 +40,5 @@
  * @copyright   2010 Phil Kernick
  * @license     http://opensource.org/licenses/bsd-license.php New BSD License
- * @version     CVS: $Id: null.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @version     CVS: $Id$
  * @link        http://pear.php.net/package/Mail/
  */
@@ -48,5 +48,5 @@
  * @access public
  * @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
  */
 class Mail_null extends Mail {
Index: /branches/version-2_13-dev/data/module/Mail/sendmail.php
===================================================================
--- /branches/version-2_13-dev/data/module/Mail/sendmail.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Mail/sendmail.php	(revision 23141)
@@ -21,5 +21,5 @@
  * @access public
  * @package Mail
- * @version $Revision: 294744 $
+ * @version $Revision$
  */
 class Mail_sendmail extends Mail {
Index: /branches/version-2_13-dev/data/module/Mail/mail.php
===================================================================
--- /branches/version-2_13-dev/data/module/Mail/mail.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Mail/mail.php	(revision 23141)
@@ -40,5 +40,5 @@
  * @copyright   2010 Chuck Hagenbuch
  * @license     http://opensource.org/licenses/bsd-license.php New BSD License
- * @version     CVS: $Id: mail.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @version     CVS: $Id$
  * @link        http://pear.php.net/package/Mail/
  */
@@ -47,5 +47,5 @@
  * internal PHP-mail() implementation of the PEAR Mail:: interface.
  * @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
  */
 class Mail_mail extends Mail {
Index: /branches/version-2_13-dev/data/module/Services/JSON.php
===================================================================
--- /branches/version-2_13-dev/data/module/Services/JSON.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Services/JSON.php	(revision 23141)
@@ -1,4 +1,5 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
 /**
  * Converts to and from JSON format.
@@ -51,5 +52,5 @@
  * @author      Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
  * @copyright   2005 Michal Migurski
- * @version     CVS: $Id: JSON.php 305040 2010-11-02 23:19:03Z alan_k $
+ * @version     CVS: $Id$
  * @license     http://www.opensource.org/licenses/bsd-license.php
  * @link        http://pear.php.net/pepr/pepr-proposal-show.php?id=198
@@ -90,9 +91,4 @@
  */
 define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
-
-/**
- * Behavior switch for Services_JSON::decode()
- */
-define('SERVICES_JSON_USE_TO_JSON', 64);
 
 /**
@@ -134,22 +130,10 @@
     *                                   bubble up with an error, so all return values
     *                                   from encode() should be checked with isError()
-    *                           - SERVICES_JSON_USE_TO_JSON:  call toJSON when serializing objects
-    *                                   It serializes the return value from the toJSON call rather 
-    *                                   than the object it'self,  toJSON can return associative arrays, 
-    *                                   strings or numbers, if you return an object, make sure it does
-    *                                   not have a toJSON method, otherwise an error will occur.
     */
     function Services_JSON($use = 0)
     {
         $this->use = $use;
-        $this->_mb_strlen            = function_exists('mb_strlen');
-        $this->_mb_convert_encoding  = function_exists('mb_convert_encoding');
-        $this->_mb_substr            = function_exists('mb_substr');
-    }
-    // private - cache the mbstring lookup results..
-    var $_mb_strlen = false;
-    var $_mb_substr = false;
-    var $_mb_convert_encoding = false;
-    
+    }
+
    /**
     * convert a string from one UTF-16 char to one UTF-8 char
@@ -166,5 +150,5 @@
     {
         // oh please oh please oh please oh please oh please
-        if($this->_mb_convert_encoding) {
+        if(function_exists('mb_convert_encoding')) {
             return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
         }
@@ -210,9 +194,9 @@
     {
         // oh please oh please oh please oh please oh please
-        if($this->_mb_convert_encoding) {
+        if(function_exists('mb_convert_encoding')) {
             return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
         }
 
-        switch($this->strlen8($utf8)) {
+        switch(strlen($utf8)) {
             case 1:
                 // this case should never be reached, because we are in ASCII range
@@ -241,5 +225,5 @@
 
    /**
-    * encodes an arbitrary variable into JSON format (and sends JSON Header)
+    * encodes an arbitrary variable into JSON format
     *
     * @param    mixed   $var    any number, boolean, string, array, or object to be encoded.
@@ -253,42 +237,4 @@
     function encode($var)
     {
-        header('Content-type: application/json');
-        return $this->encodeUnsafe($var);
-    }
-    /**
-    * encodes an arbitrary variable into JSON format without JSON Header - warning - may allow XSS!!!!)
-    *
-    * @param    mixed   $var    any number, boolean, string, array, or object to be encoded.
-    *                           see argument 1 to Services_JSON() above for array-parsing behavior.
-    *                           if var is a strng, note that encode() always expects it
-    *                           to be in ASCII or UTF-8 format!
-    *
-    * @return   mixed   JSON string representation of input var or an error if a problem occurs
-    * @access   public
-    */
-    function encodeUnsafe($var)
-    {
-        // see bug #16908 - regarding numeric locale printing
-        $lc = setlocale(LC_NUMERIC, 0);
-        setlocale(LC_NUMERIC, 'C');
-        $ret = $this->_encode($var);
-        setlocale(LC_NUMERIC, $lc);
-        return $ret;
-        
-    }
-    /**
-    * PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format 
-    *
-    * @param    mixed   $var    any number, boolean, string, array, or object to be encoded.
-    *                           see argument 1 to Services_JSON() above for array-parsing behavior.
-    *                           if var is a strng, note that encode() always expects it
-    *                           to be in ASCII or UTF-8 format!
-    *
-    * @return   mixed   JSON string representation of input var or an error if a problem occurs
-    * @access   public
-    */
-    function _encode($var) 
-    {
-         
         switch (gettype($var)) {
             case 'boolean':
@@ -303,10 +249,10 @@
             case 'double':
             case 'float':
-                return  (float) $var;
+                return (float) $var;
 
             case 'string':
                 // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
                 $ascii = '';
-                $strlen_var = $this->strlen8($var);
+                $strlen_var = strlen($var);
 
                /*
@@ -350,10 +296,4 @@
                             // characters U-00000080 - U-000007FF, mask 110XXXXX
                             // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
-                            if ($c+1 >= $strlen_var) {
-                                $c += 1;
-                                $ascii .= '?';
-                                break;
-                            }
-                            
                             $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
                             $c += 1;
@@ -363,14 +303,9 @@
 
                         case (($ord_var_c & 0xF0) == 0xE0):
-                            if ($c+2 >= $strlen_var) {
-                                $c += 2;
-                                $ascii .= '?';
-                                break;
-                            }
                             // characters U-00000800 - U-0000FFFF, mask 1110XXXX
                             // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
                             $char = pack('C*', $ord_var_c,
-                                         @ord($var{$c + 1}),
-                                         @ord($var{$c + 2}));
+                                         ord($var{$c + 1}),
+                                         ord($var{$c + 2}));
                             $c += 2;
                             $utf16 = $this->utf82utf16($char);
@@ -379,9 +314,4 @@
 
                         case (($ord_var_c & 0xF8) == 0xF0):
-                            if ($c+3 >= $strlen_var) {
-                                $c += 3;
-                                $ascii .= '?';
-                                break;
-                            }
                             // characters U-00010000 - U-001FFFFF, mask 11110XXX
                             // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
@@ -398,9 +328,4 @@
                             // characters U-00200000 - U-03FFFFFF, mask 111110XX
                             // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
-                            if ($c+4 >= $strlen_var) {
-                                $c += 4;
-                                $ascii .= '?';
-                                break;
-                            }
                             $char = pack('C*', $ord_var_c,
                                          ord($var{$c + 1}),
@@ -414,9 +339,4 @@
 
                         case (($ord_var_c & 0xFE) == 0xFC):
-                        if ($c+5 >= $strlen_var) {
-                                $c += 5;
-                                $ascii .= '?';
-                                break;
-                            }
                             // characters U-04000000 - U-7FFFFFFF, mask 1111110X
                             // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
@@ -433,5 +353,6 @@
                     }
                 }
-                return  '"'.$ascii.'"';
+
+                return '"'.$ascii.'"';
 
             case 'array':
@@ -470,5 +391,5 @@
 
                 // treat it like a regular array
-                $elements = array_map(array($this, '_encode'), $var);
+                $elements = array_map(array($this, 'encode'), $var);
 
                 foreach($elements as $element) {
@@ -481,25 +402,6 @@
 
             case 'object':
-            
-                // support toJSON methods.
-                if (($this->use & SERVICES_JSON_USE_TO_JSON) && method_exists($var, 'toJSON')) {
-                    // this may end up allowing unlimited recursion
-                    // so we check the return value to make sure it's not got the same method.
-                    $recode = $var->toJSON();
-                    
-                    if (method_exists($recode, 'toJSON')) {
-                        
-                        return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
-                        ? 'null'
-                        : new Services_JSON_Error(class_name($var).
-                            " toJSON returned an object with a toJSON method.");
-                            
-                    }
-                    
-                    return $this->_encode( $recode );
-                } 
-                
                 $vars = get_object_vars($var);
-                
+
                 $properties = array_map(array($this, 'name_value'),
                                         array_keys($vars),
@@ -532,5 +434,5 @@
     function name_value($name, $value)
     {
-        $encoded_value = $this->_encode($value);
+        $encoded_value = $this->encode($value);
 
         if(Services_JSON::isError($encoded_value)) {
@@ -538,5 +440,5 @@
         }
 
-        return $this->_encode(strval($name)) . ':' . $encoded_value;
+        return $this->encode(strval($name)) . ':' . $encoded_value;
     }
 
@@ -611,12 +513,12 @@
                 } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
                     // STRINGS RETURNED IN UTF-8 FORMAT
-                    $delim = $this->substr8($str, 0, 1);
-                    $chrs = $this->substr8($str, 1, -1);
+                    $delim = substr($str, 0, 1);
+                    $chrs = substr($str, 1, -1);
                     $utf8 = '';
-                    $strlen_chrs = $this->strlen8($chrs);
+                    $strlen_chrs = strlen($chrs);
 
                     for ($c = 0; $c < $strlen_chrs; ++$c) {
 
-                        $substr_chrs_c_2 = $this->substr8($chrs, $c, 2);
+                        $substr_chrs_c_2 = substr($chrs, $c, 2);
                         $ord_chrs_c = ord($chrs{$c});
 
@@ -653,8 +555,8 @@
                                 break;
 
-                            case preg_match('/\\\u[0-9A-F]{4}/i', $this->substr8($chrs, $c, 6)):
+                            case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
                                 // single, escaped unicode character
-                                $utf16 = chr(hexdec($this->substr8($chrs, ($c + 2), 2)))
-                                       . chr(hexdec($this->substr8($chrs, ($c + 4), 2)));
+                                $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
+                                       . chr(hexdec(substr($chrs, ($c + 4), 2)));
                                 $utf8 .= $this->utf162utf8($utf16);
                                 $c += 5;
@@ -668,5 +570,5 @@
                                 // characters U-00000080 - U-000007FF, mask 110XXXXX
                                 //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
-                                $utf8 .= $this->substr8($chrs, $c, 2);
+                                $utf8 .= substr($chrs, $c, 2);
                                 ++$c;
                                 break;
@@ -675,5 +577,5 @@
                                 // characters U-00000800 - U-0000FFFF, mask 1110XXXX
                                 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
-                                $utf8 .= $this->substr8($chrs, $c, 3);
+                                $utf8 .= substr($chrs, $c, 3);
                                 $c += 2;
                                 break;
@@ -682,5 +584,5 @@
                                 // characters U-00010000 - U-001FFFFF, mask 11110XXX
                                 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
-                                $utf8 .= $this->substr8($chrs, $c, 4);
+                                $utf8 .= substr($chrs, $c, 4);
                                 $c += 3;
                                 break;
@@ -689,5 +591,5 @@
                                 // characters U-00200000 - U-03FFFFFF, mask 111110XX
                                 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
-                                $utf8 .= $this->substr8($chrs, $c, 5);
+                                $utf8 .= substr($chrs, $c, 5);
                                 $c += 4;
                                 break;
@@ -696,5 +598,5 @@
                                 // characters U-04000000 - U-7FFFFFFF, mask 1111110X
                                 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
-                                $utf8 .= $this->substr8($chrs, $c, 6);
+                                $utf8 .= substr($chrs, $c, 6);
                                 $c += 5;
                                 break;
@@ -726,5 +628,5 @@
                                            'delim' => false));
 
-                    $chrs = $this->substr8($str, 1, -1);
+                    $chrs = substr($str, 1, -1);
                     $chrs = $this->reduce_string($chrs);
 
@@ -741,17 +643,17 @@
                     //print("\nparsing {$chrs}\n");
 
-                    $strlen_chrs = $this->strlen8($chrs);
+                    $strlen_chrs = strlen($chrs);
 
                     for ($c = 0; $c <= $strlen_chrs; ++$c) {
 
                         $top = end($stk);
-                        $substr_chrs_c_2 = $this->substr8($chrs, $c, 2);
+                        $substr_chrs_c_2 = substr($chrs, $c, 2);
 
                         if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
                             // found a comma that is not inside a string, array, etc.,
                             // OR we've reached the end of the character list
-                            $slice = $this->substr8($chrs, $top['where'], ($c - $top['where']));
+                            $slice = substr($chrs, $top['where'], ($c - $top['where']));
                             array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
-                            //print("Found split at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+                            //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
                             if (reset($stk) == SERVICES_JSON_IN_ARR) {
@@ -766,8 +668,9 @@
                                 $parts = array();
                                 
-                               if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:/Uis', $slice, $parts)) {
- 	                              // "name":value pair
+                                if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
+                                    // "name":value pair
                                     $key = $this->decode($parts[1]);
-                                    $val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B"));
+                                    $val = $this->decode($parts[2]);
+
                                     if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
                                         $obj[$key] = $val;
@@ -775,8 +678,8 @@
                                         $obj->$key = $val;
                                     }
-                                } elseif (preg_match('/^\s*(\w+)\s*:/Uis', $slice, $parts)) {
+                                } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
                                     // name:value pair, where name is unquoted
                                     $key = $parts[1];
-                                    $val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B"));
+                                    $val = $this->decode($parts[2]);
 
                                     if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
@@ -796,10 +699,10 @@
                         } elseif (($chrs{$c} == $top['delim']) &&
                                  ($top['what'] == SERVICES_JSON_IN_STR) &&
-                                 (($this->strlen8($this->substr8($chrs, 0, $c)) - $this->strlen8(rtrim($this->substr8($chrs, 0, $c), '\\'))) % 2 != 1)) {
+                                 ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
                             // found a quote, we're in a string, and it's not escaped
                             // we know that it's not escaped becase there is _not_ an
                             // odd number of backslashes at the end of the string so far
                             array_pop($stk);
-                            //print("Found end of string at {$c}: ".$this->substr8($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
+                            //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
 
                         } elseif (($chrs{$c} == '[') &&
@@ -812,5 +715,5 @@
                             // found a right-bracket, and we're in an array
                             array_pop($stk);
-                            //print("Found end of array at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+                            //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
                         } elseif (($chrs{$c} == '{') &&
@@ -823,5 +726,5 @@
                             // found a right-brace, and we're in an object
                             array_pop($stk);
-                            //print("Found end of object at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+                            //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
                         } elseif (($substr_chrs_c_2 == '/*') &&
@@ -840,5 +743,5 @@
                                 $chrs = substr_replace($chrs, ' ', $i, 1);
 
-                            //print("Found end of comment at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+                            //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
                         }
@@ -872,36 +775,4 @@
         return false;
     }
-    
-    /**
-    * Calculates length of string in bytes
-    * @param string 
-    * @return integer length
-    */
-    function strlen8( $str ) 
-    {
-        if ( $this->_mb_strlen ) {
-            return mb_strlen( $str, "8bit" );
-        }
-        return strlen( $str );
-    }
-    
-    /**
-    * Returns part of a string, interpreting $start and $length as number of bytes.
-    * @param string 
-    * @param integer start 
-    * @param integer length 
-    * @return integer length
-    */
-    function substr8( $string, $start, $length=false ) 
-    {
-        if ( $length === false ) {
-            $length = $this->strlen8( $string ) - $start;
-        }
-        if ( $this->_mb_substr ) {
-            return mb_substr( $string, $start, $length, "8bit" );
-        }
-        return substr( $string, $start, $length );
-    }
-
 }
 
@@ -930,4 +801,6 @@
         }
     }
+
+}
     
-}
+?>
Index: /branches/version-2_13-dev/data/module/Net/URL.php
===================================================================
--- /branches/version-2_13-dev/data/module/Net/URL.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Net/URL.php	(revision 23141)
@@ -33,5 +33,5 @@
 // +-----------------------------------------------------------------------+
 //
-// $Id: URL.php,v 1.49 2007/06/28 14:43:07 davidc Exp $
+// $Id$
 //
 // Net_URL Class
Index: /branches/version-2_13-dev/data/module/Net/Socket.php
===================================================================
--- /branches/version-2_13-dev/data/module/Net/Socket.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Net/Socket.php	(revision 23141)
@@ -5,5 +5,5 @@
  * PHP Version 4
  *
- * Copyright (c) 1997-2013 The PHP Group
+ * Copyright (c) 1997-2003 The PHP Group
  *
  * This source file is subject to version 2.0 of the PHP license,
@@ -24,4 +24,5 @@
  * @copyright 1997-2003 The PHP Group
  * @license   http://www.php.net/license/2_02.txt PHP 2.02
+ * @version   CVS: $Id$
  * @link      http://pear.php.net/packages/Net_Socket
  */
@@ -77,9 +78,9 @@
 
     /**
-     * Number of seconds to wait on socket operations before assuming
+     * Number of seconds to wait on socket connections before assuming
      * there's no more data. Defaults to no timeout.
-     * @var integer|float $timeout
-     */
-    var $timeout = null;
+     * @var integer $timeout
+     */
+    var $timeout = false;
 
     /**
@@ -100,15 +101,15 @@
      * already connected, it disconnects and connects again.
      *
-     * @param string  $addr       IP address or host name (may be with protocol prefix).
+     * @param string  $addr       IP address or host name.
      * @param integer $port       TCP port number.
      * @param boolean $persistent (optional) Whether the connection is
      *                            persistent (kept open between requests
      *                            by the web server).
-     * @param integer $timeout    (optional) Connection socket timeout.
+     * @param integer $timeout    (optional) How long to wait for data.
      * @param array   $options    See options for stream_context_create.
      *
      * @access public
      *
-     * @return boolean|PEAR_Error  True on success or a PEAR_Error on failure.
+     * @return boolean | PEAR_Error  True on success or a PEAR_Error on failure.
      */
     function connect($addr, $port = 0, $persistent = null,
@@ -122,8 +123,9 @@
         if (!$addr) {
             return $this->raiseError('$addr cannot be empty');
-        } else if (strspn($addr, ':.0123456789') == strlen($addr)) {
-            $this->addr = strpos($addr, ':') !== false ? '['.$addr.']' : $addr;
+        } elseif (strspn($addr, '.0123456789') == strlen($addr) ||
+                  strstr($addr, '/') !== false) {
+            $this->addr = $addr;
         } else {
-            $this->addr = $addr;
+            $this->addr = @gethostbyname($addr);
         }
 
@@ -132,4 +134,8 @@
         if ($persistent !== null) {
             $this->persistent = $persistent;
+        }
+
+        if ($timeout !== null) {
+            $this->timeout = $timeout;
         }
 
@@ -140,9 +146,10 @@
         $old_track_errors = @ini_set('track_errors', 1);
 
-        if ($timeout <= 0) {
-            $timeout = @ini_get('default_socket_timeout');
-        }
-
         if ($options && function_exists('stream_context_create')) {
+            if ($this->timeout) {
+                $timeout = $this->timeout;
+            } else {
+                $timeout = 0;
+            }
             $context = stream_context_create($options);
 
@@ -163,5 +170,10 @@
             }
         } else {
-            $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout);
+            if ($this->timeout) {
+                $fp = @$openfunc($this->addr, $this->port, $errno,
+                                 $errstr, $this->timeout);
+            } else {
+                $fp = @$openfunc($this->addr, $this->port, $errno, $errstr);
+            }
         }
 
@@ -176,5 +188,5 @@
         @ini_set('track_errors', $old_track_errors);
         $this->fp = $fp;
-        $this->setTimeout();
+
         return $this->setBlocking($this->blocking);
     }
@@ -247,29 +259,16 @@
      *
      * @param integer $seconds      Seconds.
-     * @param integer $microseconds Microseconds, optional.
-     *
-     * @access public
-     * @return mixed True on success or false on failure or
-     *               a PEAR_Error instance when not connected
-     */
-    function setTimeout($seconds = null, $microseconds = null)
-    {
-        if (!is_resource($this->fp)) {
-            return $this->raiseError('not connected');
-        }
-
-        if ($seconds === null && $microseconds === null) {
-            $seconds      = (int) $this->timeout;
-            $microseconds = (int) (($this->timeout - $seconds) * 1000000);
-        } else {
-            $this->timeout = $seconds + $microseconds/1000000;
-        }
-
-        if ($this->timeout > 0) {
-            return stream_set_timeout($this->fp, (int) $seconds, (int) $microseconds);
-        }
-        else {
-            return false;
-        }
+     * @param integer $microseconds Microseconds.
+     *
+     * @access public
+     * @return mixed true on success or a PEAR_Error instance otherwise
+     */
+    function setTimeout($seconds, $microseconds)
+    {
+        if (!is_resource($this->fp)) {
+            return $this->raiseError('not connected');
+        }
+
+        return socket_set_timeout($this->fp, $seconds, $microseconds);
     }
 
@@ -317,5 +316,5 @@
         }
 
-        return stream_get_meta_data($this->fp);
+        return socket_get_status($this->fp);
     }
 
@@ -323,12 +322,9 @@
      * Get a specified line of data
      *
-     * @param int $size Reading ends when size - 1 bytes have been read,
-     *                  or a newline or an EOF (whichever comes first).
-     *                  If no size is specified, it will keep reading from
-     *                  the stream until it reaches the end of the line.
-     *
-     * @access public
-     * @return mixed $size bytes of data from the socket, or a PEAR_Error if
-     *         not connected. If an error occurs, FALSE is returned.
+     * @param int $size ??
+     *
+     * @access public
+     * @return $size bytes of data from the socket, or a PEAR_Error if
+     *         not connected.
      */
     function gets($size = null)
@@ -375,8 +371,7 @@
      * @access public
      * @return mixed If the socket is not connected, returns an instance of
-     *               PEAR_Error.
-     *               If the write succeeds, returns the number of bytes written.
+     *               PEAR_Error
+     *               If the write succeeds, returns the number of bytes written
      *               If the write fails, returns false.
-     *               If the socket times out, returns an instance of PEAR_Error.
      */
     function write($data, $blocksize = null)
@@ -387,20 +382,5 @@
 
         if (is_null($blocksize) && !OS_WINDOWS) {
-            $written = @fwrite($this->fp, $data);
-
-            // Check for timeout or lost connection
-            if (!$written) {
-                $meta_data = $this->getStatus();
-
-                if (!is_array($meta_data)) {
-                    return $meta_data; // PEAR_Error
-                }
-
-                if (!empty($meta_data['timed_out'])) {
-                    return $this->raiseError('timed out');
-                }
-            }
-
-            return $written;
+            return @fwrite($this->fp, $data);
         } else {
             if (is_null($blocksize)) {
@@ -412,20 +392,7 @@
             while ($pos < $size) {
                 $written = @fwrite($this->fp, substr($data, $pos, $blocksize));
-
-                // Check for timeout or lost connection
                 if (!$written) {
-                    $meta_data = $this->getStatus();
-
-                    if (!is_array($meta_data)) {
-                        return $meta_data; // PEAR_Error
-                    }
-
-                    if (!empty($meta_data['timed_out'])) {
-                        return $this->raiseError('timed out');
-                    }
-
                     return $written;
                 }
-
                 $pos += $written;
             }
@@ -441,5 +408,5 @@
      *
      * @access public
-     * @return mixed fwrite() result, or PEAR_Error when not connected
+     * @return mixed fputs result, or an error
      */
     function writeLine($data)
Index: anches/version-2_13-dev/data/module/Net/URL2.php
===================================================================
--- /branches/version-2_13-dev/data/module/Net/URL2.php	(revision 23125)
+++ 	(revision )
@@ -1,942 +1,0 @@
-<?php
-/**
- * Net_URL2, a class representing a URL as per RFC 3986.
- *
- * PHP version 5
- *
- * LICENSE:
- *
- * Copyright (c) 2007-2009, Peytz & Co. A/S
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in
- *     the documentation and/or other materials provided with the distribution.
- *   * Neither the name of the Net_URL2 nor the names of its contributors may
- *     be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Networking
- * @package   Net_URL2
- * @author    Christian Schmidt <schmidt@php.net>
- * @copyright 2007-2009 Peytz & Co. A/S
- * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
- * @version   CVS: $Id: URL2.php 309223 2011-03-14 14:26:32Z till $
- * @link      http://www.rfc-editor.org/rfc/rfc3986.txt
- */
-
-/**
- * Represents a URL as per RFC 3986.
- *
- * @category  Networking
- * @package   Net_URL2
- * @author    Christian Schmidt <schmidt@php.net>
- * @copyright 2007-2009 Peytz & Co. A/S
- * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
- * @version   Release: @package_version@
- * @link      http://pear.php.net/package/Net_URL2
- */
-class Net_URL2
-{
-    /**
-     * Do strict parsing in resolve() (see RFC 3986, section 5.2.2). Default
-     * is true.
-     */
-    const OPTION_STRICT = 'strict';
-
-    /**
-     * Represent arrays in query using PHP's [] notation. Default is true.
-     */
-    const OPTION_USE_BRACKETS = 'use_brackets';
-
-    /**
-     * URL-encode query variable keys. Default is true.
-     */
-    const OPTION_ENCODE_KEYS = 'encode_keys';
-
-    /**
-     * Query variable separators when parsing the query string. Every character
-     * is considered a separator. Default is "&".
-     */
-    const OPTION_SEPARATOR_INPUT = 'input_separator';
-
-    /**
-     * Query variable separator used when generating the query string. Default
-     * is "&".
-     */
-    const OPTION_SEPARATOR_OUTPUT = 'output_separator';
-
-    /**
-     * Default options corresponds to how PHP handles $_GET.
-     */
-    private $_options = array(
-        self::OPTION_STRICT           => true,
-        self::OPTION_USE_BRACKETS     => true,
-        self::OPTION_ENCODE_KEYS      => true,
-        self::OPTION_SEPARATOR_INPUT  => '&',
-        self::OPTION_SEPARATOR_OUTPUT => '&',
-        );
-
-    /**
-     * @var  string|bool
-     */
-    private $_scheme = false;
-
-    /**
-     * @var  string|bool
-     */
-    private $_userinfo = false;
-
-    /**
-     * @var  string|bool
-     */
-    private $_host = false;
-
-    /**
-     * @var  string|bool
-     */
-    private $_port = false;
-
-    /**
-     * @var  string
-     */
-    private $_path = '';
-
-    /**
-     * @var  string|bool
-     */
-    private $_query = false;
-
-    /**
-     * @var  string|bool
-     */
-    private $_fragment = false;
-
-    /**
-     * Constructor.
-     *
-     * @param string $url     an absolute or relative URL
-     * @param array  $options an array of OPTION_xxx constants
-     *
-     * @return $this
-     * @uses   self::parseUrl()
-     */
-    public function __construct($url, array $options = array())
-    {
-        foreach ($options as $optionName => $value) {
-            if (array_key_exists($optionName, $this->_options)) {
-                $this->_options[$optionName] = $value;
-            }
-        }
-
-        $this->parseUrl($url);
-    }
-
-    /**
-     * Magic Setter.
-     *
-     * This method will magically set the value of a private variable ($var)
-     * with the value passed as the args
-     *
-     * @param  string $var      The private variable to set.
-     * @param  mixed  $arg      An argument of any type.
-     * @return void
-     */
-    public function __set($var, $arg)
-    {
-        $method = 'set' . $var;
-        if (method_exists($this, $method)) {
-            $this->$method($arg);
-        }
-    }
-
-    /**
-     * Magic Getter.
-     *
-     * This is the magic get method to retrieve the private variable
-     * that was set by either __set() or it's setter...
-     *
-     * @param  string $var         The property name to retrieve.
-     * @return mixed  $this->$var  Either a boolean false if the
-     *                             property is not set or the value
-     *                             of the private property.
-     */
-    public function __get($var)
-    {
-        $method = 'get' . $var;
-        if (method_exists($this, $method)) {
-            return $this->$method();
-        }
-
-        return false;
-    }
-
-    /**
-     * Returns the scheme, e.g. "http" or "urn", or false if there is no
-     * scheme specified, i.e. if this is a relative URL.
-     *
-     * @return  string|bool
-     */
-    public function getScheme()
-    {
-        return $this->_scheme;
-    }
-
-    /**
-     * Sets the scheme, e.g. "http" or "urn". Specify false if there is no
-     * scheme specified, i.e. if this is a relative URL.
-     *
-     * @param string|bool $scheme e.g. "http" or "urn", or false if there is no
-     *                            scheme specified, i.e. if this is a relative
-     *                            URL
-     *
-     * @return $this
-     * @see    getScheme()
-     */
-    public function setScheme($scheme)
-    {
-        $this->_scheme = $scheme;
-        return $this;
-    }
-
-    /**
-     * Returns the user part of the userinfo part (the part preceding the first
-     *  ":"), or false if there is no userinfo part.
-     *
-     * @return  string|bool
-     */
-    public function getUser()
-    {
-        return $this->_userinfo !== false
-            ? preg_replace('@:.*$@', '', $this->_userinfo)
-            : false;
-    }
-
-    /**
-     * Returns the password part of the userinfo part (the part after the first
-     *  ":"), or false if there is no userinfo part (i.e. the URL does not
-     * contain "@" in front of the hostname) or the userinfo part does not
-     * contain ":".
-     *
-     * @return  string|bool
-     */
-    public function getPassword()
-    {
-        return $this->_userinfo !== false
-            ? substr(strstr($this->_userinfo, ':'), 1)
-            : false;
-    }
-
-    /**
-     * Returns the userinfo part, or false if there is none, i.e. if the
-     * authority part does not contain "@".
-     *
-     * @return  string|bool
-     */
-    public function getUserinfo()
-    {
-        return $this->_userinfo;
-    }
-
-    /**
-     * Sets the userinfo part. If two arguments are passed, they are combined
-     * in the userinfo part as username ":" password.
-     *
-     * @param string|bool $userinfo userinfo or username
-     * @param string|bool $password optional password, or false
-     *
-     * @return $this
-     */
-    public function setUserinfo($userinfo, $password = false)
-    {
-        $this->_userinfo = $userinfo;
-        if ($password !== false) {
-            $this->_userinfo .= ':' . $password;
-        }
-        return $this;
-    }
-
-    /**
-     * Returns the host part, or false if there is no authority part, e.g.
-     * relative URLs.
-     *
-     * @return  string|bool a hostname, an IP address, or false
-     */
-    public function getHost()
-    {
-        return $this->_host;
-    }
-
-    /**
-     * Sets the host part. Specify false if there is no authority part, e.g.
-     * relative URLs.
-     *
-     * @param string|bool $host a hostname, an IP address, or false
-     *
-     * @return $this
-     */
-    public function setHost($host)
-    {
-        $this->_host = $host;
-        return $this;
-    }
-
-    /**
-     * Returns the port number, or false if there is no port number specified,
-     * i.e. if the default port is to be used.
-     *
-     * @return  string|bool
-     */
-    public function getPort()
-    {
-        return $this->_port;
-    }
-
-    /**
-     * Sets the port number. Specify false if there is no port number specified,
-     * i.e. if the default port is to be used.
-     *
-     * @param string|bool $port a port number, or false
-     *
-     * @return $this
-     */
-    public function setPort($port)
-    {
-        $this->_port = $port;
-        return $this;
-    }
-
-    /**
-     * Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or
-     * false if there is no authority.
-     *
-     * @return string|bool
-     */
-    public function getAuthority()
-    {
-        if (!$this->_host) {
-            return false;
-        }
-
-        $authority = '';
-
-        if ($this->_userinfo !== false) {
-            $authority .= $this->_userinfo . '@';
-        }
-
-        $authority .= $this->_host;
-
-        if ($this->_port !== false) {
-            $authority .= ':' . $this->_port;
-        }
-
-        return $authority;
-    }
-
-    /**
-     * Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify
-     * false if there is no authority.
-     *
-     * @param string|false $authority a hostname or an IP addresse, possibly
-     *                                with userinfo prefixed and port number
-     *                                appended, e.g. "foo:bar@example.org:81".
-     *
-     * @return $this
-     */
-    public function setAuthority($authority)
-    {
-        $this->_userinfo = false;
-        $this->_host     = false;
-        $this->_port     = false;
-        if (preg_match('@^(([^\@]*)\@)?([^:]+)(:(\d*))?$@', $authority, $reg)) {
-            if ($reg[1]) {
-                $this->_userinfo = $reg[2];
-            }
-
-            $this->_host = $reg[3];
-            if (isset($reg[5])) {
-                $this->_port = $reg[5];
-            }
-        }
-        return $this;
-    }
-
-    /**
-     * Returns the path part (possibly an empty string).
-     *
-     * @return string
-     */
-    public function getPath()
-    {
-        return $this->_path;
-    }
-
-    /**
-     * Sets the path part (possibly an empty string).
-     *
-     * @param string $path a path
-     *
-     * @return $this
-     */
-    public function setPath($path)
-    {
-        $this->_path = $path;
-        return $this;
-    }
-
-    /**
-     * Returns the query string (excluding the leading "?"), or false if "?"
-     * is not present in the URL.
-     *
-     * @return  string|bool
-     * @see     self::getQueryVariables()
-     */
-    public function getQuery()
-    {
-        return $this->_query;
-    }
-
-    /**
-     * Sets the query string (excluding the leading "?"). Specify false if "?"
-     * is not present in the URL.
-     *
-     * @param string|bool $query a query string, e.g. "foo=1&bar=2"
-     *
-     * @return $this
-     * @see    self::setQueryVariables()
-     */
-    public function setQuery($query)
-    {
-        $this->_query = $query;
-        return $this;
-    }
-
-    /**
-     * Returns the fragment name, or false if "#" is not present in the URL.
-     *
-     * @return  string|bool
-     */
-    public function getFragment()
-    {
-        return $this->_fragment;
-    }
-
-    /**
-     * Sets the fragment name. Specify false if "#" is not present in the URL.
-     *
-     * @param string|bool $fragment a fragment excluding the leading "#", or
-     *                              false
-     *
-     * @return $this
-     */
-    public function setFragment($fragment)
-    {
-        $this->_fragment = $fragment;
-        return $this;
-    }
-
-    /**
-     * Returns the query string like an array as the variables would appear in
-     * $_GET in a PHP script. If the URL does not contain a "?", an empty array
-     * is returned.
-     *
-     * @return  array
-     */
-    public function getQueryVariables()
-    {
-        $pattern = '/[' .
-                   preg_quote($this->getOption(self::OPTION_SEPARATOR_INPUT), '/') .
-                   ']/';
-        $parts   = preg_split($pattern, $this->_query, -1, PREG_SPLIT_NO_EMPTY);
-        $return  = array();
-
-        foreach ($parts as $part) {
-            if (strpos($part, '=') !== false) {
-                list($key, $value) = explode('=', $part, 2);
-            } else {
-                $key   = $part;
-                $value = null;
-            }
-
-            if ($this->getOption(self::OPTION_ENCODE_KEYS)) {
-                $key = rawurldecode($key);
-            }
-            $value = rawurldecode($value);
-
-            if ($this->getOption(self::OPTION_USE_BRACKETS) &&
-                preg_match('#^(.*)\[([0-9a-z_-]*)\]#i', $key, $matches)) {
-
-                $key = $matches[1];
-                $idx = $matches[2];
-
-                // Ensure is an array
-                if (empty($return[$key]) || !is_array($return[$key])) {
-                    $return[$key] = array();
-                }
-
-                // Add data
-                if ($idx === '') {
-                    $return[$key][] = $value;
-                } else {
-                    $return[$key][$idx] = $value;
-                }
-            } elseif (!$this->getOption(self::OPTION_USE_BRACKETS)
-                      && !empty($return[$key])
-            ) {
-                $return[$key]   = (array) $return[$key];
-                $return[$key][] = $value;
-            } else {
-                $return[$key] = $value;
-            }
-        }
-
-        return $return;
-    }
-
-    /**
-     * Sets the query string to the specified variable in the query string.
-     *
-     * @param array $array (name => value) array
-     *
-     * @return $this
-     */
-    public function setQueryVariables(array $array)
-    {
-        if (!$array) {
-            $this->_query = false;
-        } else {
-            $this->_query = $this->buildQuery(
-                $array,
-                $this->getOption(self::OPTION_SEPARATOR_OUTPUT)
-            );
-        }
-        return $this;
-    }
-
-    /**
-     * Sets the specified variable in the query string.
-     *
-     * @param string $name  variable name
-     * @param mixed  $value variable value
-     *
-     * @return $this
-     */
-    public function setQueryVariable($name, $value)
-    {
-        $array = $this->getQueryVariables();
-        $array[$name] = $value;
-        $this->setQueryVariables($array);
-        return $this;
-    }
-
-    /**
-     * Removes the specifed variable from the query string.
-     *
-     * @param string $name a query string variable, e.g. "foo" in "?foo=1"
-     *
-     * @return void
-     */
-    public function unsetQueryVariable($name)
-    {
-        $array = $this->getQueryVariables();
-        unset($array[$name]);
-        $this->setQueryVariables($array);
-    }
-
-    /**
-     * Returns a string representation of this URL.
-     *
-     * @return  string
-     */
-    public function getURL()
-    {
-        // See RFC 3986, section 5.3
-        $url = "";
-
-        if ($this->_scheme !== false) {
-            $url .= $this->_scheme . ':';
-        }
-
-        $authority = $this->getAuthority();
-        if ($authority !== false) {
-            $url .= '//' . $authority;
-        }
-        $url .= $this->_path;
-
-        if ($this->_query !== false) {
-            $url .= '?' . $this->_query;
-        }
-
-        if ($this->_fragment !== false) {
-            $url .= '#' . $this->_fragment;
-        }
-    
-        return $url;
-    }
-
-    /**
-     * Returns a string representation of this URL.
-     *
-     * @return  string
-     * @see toString()
-     */
-    public function __toString()
-    {
-        return $this->getURL();
-    }
-
-    /** 
-     * Returns a normalized string representation of this URL. This is useful
-     * for comparison of URLs.
-     *
-     * @return  string
-     */
-    public function getNormalizedURL()
-    {
-        $url = clone $this;
-        $url->normalize();
-        return $url->getUrl();
-    }
-
-    /** 
-     * Returns a normalized Net_URL2 instance.
-     *
-     * @return  Net_URL2
-     */
-    public function normalize()
-    {
-        // See RFC 3886, section 6
-
-        // Schemes are case-insensitive
-        if ($this->_scheme) {
-            $this->_scheme = strtolower($this->_scheme);
-        }
-
-        // Hostnames are case-insensitive
-        if ($this->_host) {
-            $this->_host = strtolower($this->_host);
-        }
-
-        // Remove default port number for known schemes (RFC 3986, section 6.2.3)
-        if ($this->_port &&
-            $this->_scheme &&
-            $this->_port == getservbyname($this->_scheme, 'tcp')) {
-
-            $this->_port = false;
-        }
-
-        // Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1)
-        foreach (array('_userinfo', '_host', '_path') as $part) {
-            if ($this->$part) {
-                $this->$part = preg_replace('/%[0-9a-f]{2}/ie',
-                                            'strtoupper("\0")',
-                                            $this->$part);
-            }
-        }
-
-        // Path segment normalization (RFC 3986, section 6.2.2.3)
-        $this->_path = self::removeDotSegments($this->_path);
-
-        // Scheme based normalization (RFC 3986, section 6.2.3)
-        if ($this->_host && !$this->_path) {
-            $this->_path = '/';
-        }
-    }
-
-    /**
-     * Returns whether this instance represents an absolute URL.
-     *
-     * @return  bool
-     */
-    public function isAbsolute()
-    {
-        return (bool) $this->_scheme;
-    }
-
-    /**
-     * Returns an Net_URL2 instance representing an absolute URL relative to
-     * this URL.
-     *
-     * @param Net_URL2|string $reference relative URL
-     *
-     * @return Net_URL2
-     */
-    public function resolve($reference)
-    {
-        if (!$reference instanceof Net_URL2) {
-            $reference = new self($reference);
-        }
-        if (!$this->isAbsolute()) {
-            throw new Exception('Base-URL must be absolute');
-        }
-
-        // A non-strict parser may ignore a scheme in the reference if it is
-        // identical to the base URI's scheme.
-        if (!$this->getOption(self::OPTION_STRICT) && $reference->_scheme == $this->_scheme) {
-            $reference->_scheme = false;
-        }
-
-        $target = new self('');
-        if ($reference->_scheme !== false) {
-            $target->_scheme = $reference->_scheme;
-            $target->setAuthority($reference->getAuthority());
-            $target->_path  = self::removeDotSegments($reference->_path);
-            $target->_query = $reference->_query;
-        } else {
-            $authority = $reference->getAuthority();
-            if ($authority !== false) {
-                $target->setAuthority($authority);
-                $target->_path  = self::removeDotSegments($reference->_path);
-                $target->_query = $reference->_query;
-            } else {
-                if ($reference->_path == '') {
-                    $target->_path = $this->_path;
-                    if ($reference->_query !== false) {
-                        $target->_query = $reference->_query;
-                    } else {
-                        $target->_query = $this->_query;
-                    }
-                } else {
-                    if (substr($reference->_path, 0, 1) == '/') {
-                        $target->_path = self::removeDotSegments($reference->_path);
-                    } else {
-                        // Merge paths (RFC 3986, section 5.2.3)
-                        if ($this->_host !== false && $this->_path == '') {
-                            $target->_path = '/' . $this->_path;
-                        } else {
-                            $i = strrpos($this->_path, '/');
-                            if ($i !== false) {
-                                $target->_path = substr($this->_path, 0, $i + 1);
-                            }
-                            $target->_path .= $reference->_path;
-                        }
-                        $target->_path = self::removeDotSegments($target->_path);
-                    }
-                    $target->_query = $reference->_query;
-                }
-                $target->setAuthority($this->getAuthority());
-            }
-            $target->_scheme = $this->_scheme;
-        }
-
-        $target->_fragment = $reference->_fragment;
-
-        return $target;
-    }
-
-    /**
-     * Removes dots as described in RFC 3986, section 5.2.4, e.g.
-     * "/foo/../bar/baz" => "/bar/baz"
-     *
-     * @param string $path a path
-     *
-     * @return string a path
-     */
-    public static function removeDotSegments($path)
-    {
-        $output = '';
-
-        // Make sure not to be trapped in an infinite loop due to a bug in this
-        // method
-        $j = 0;
-        while ($path && $j++ < 100) {
-            if (substr($path, 0, 2) == './') {
-                // Step 2.A
-                $path = substr($path, 2);
-            } elseif (substr($path, 0, 3) == '../') {
-                // Step 2.A
-                $path = substr($path, 3);
-            } elseif (substr($path, 0, 3) == '/./' || $path == '/.') {
-                // Step 2.B
-                $path = '/' . substr($path, 3);
-            } elseif (substr($path, 0, 4) == '/../' || $path == '/..') {
-                // Step 2.C
-                $path   = '/' . substr($path, 4);
-                $i      = strrpos($output, '/');
-                $output = $i === false ? '' : substr($output, 0, $i);
-            } elseif ($path == '.' || $path == '..') {
-                // Step 2.D
-                $path = '';
-            } else {
-                // Step 2.E
-                $i = strpos($path, '/');
-                if ($i === 0) {
-                    $i = strpos($path, '/', 1);
-                }
-                if ($i === false) {
-                    $i = strlen($path);
-                }
-                $output .= substr($path, 0, $i);
-                $path = substr($path, $i);
-            }
-        }
-
-        return $output;
-    }
-
-    /**
-     * Percent-encodes all non-alphanumeric characters except these: _ . - ~
-     * Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP
-     * 5.2.x and earlier.
-     *
-     * @param  $raw the string to encode
-     * @return string
-     */
-    public static function urlencode($string)
-    {
-    	$encoded = rawurlencode($string);
-
-        // This is only necessary in PHP < 5.3.
-        $encoded = str_replace('%7E', '~', $encoded);
-        return $encoded;
-    }
-
-    /**
-     * Returns a Net_URL2 instance representing the canonical URL of the
-     * currently executing PHP script.
-     *
-     * @return  string
-     */
-    public static function getCanonical()
-    {
-        if (!isset($_SERVER['REQUEST_METHOD'])) {
-            // ALERT - no current URL
-            throw new Exception('Script was not called through a webserver');
-        }
-
-        // Begin with a relative URL
-        $url = new self($_SERVER['PHP_SELF']);
-        $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http';
-        $url->_host   = $_SERVER['SERVER_NAME'];
-        $port = $_SERVER['SERVER_PORT'];
-        if ($url->_scheme == 'http' && $port != 80 ||
-            $url->_scheme == 'https' && $port != 443) {
-
-            $url->_port = $port;
-        }
-        return $url;
-    }
-
-    /**
-     * Returns the URL used to retrieve the current request.
-     *
-     * @return  string
-     */
-    public static function getRequestedURL()
-    {
-        return self::getRequested()->getUrl();
-    }
-
-    /**
-     * Returns a Net_URL2 instance representing the URL used to retrieve the
-     * current request.
-     *
-     * @return  Net_URL2
-     */
-    public static function getRequested()
-    {
-        if (!isset($_SERVER['REQUEST_METHOD'])) {
-            // ALERT - no current URL
-            throw new Exception('Script was not called through a webserver');
-        }
-
-        // Begin with a relative URL
-        $url = new self($_SERVER['REQUEST_URI']);
-        $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http';
-        // Set host and possibly port
-        $url->setAuthority($_SERVER['HTTP_HOST']);
-        return $url;
-    }
-
-    /**
-     * Returns the value of the specified option.
-     *
-     * @param string $optionName The name of the option to retrieve
-     *
-     * @return  mixed
-     */
-    public function getOption($optionName)
-    {
-        return isset($this->_options[$optionName])
-            ? $this->_options[$optionName] : false;
-    }
-
-    /**
-     * A simple version of http_build_query in userland. The encoded string is
-     * percentage encoded according to RFC 3986.
-     *
-     * @param array  $data      An array, which has to be converted into
-     *                          QUERY_STRING. Anything is possible.
-     * @param string $seperator See {@link self::OPTION_SEPARATOR_OUTPUT}
-     * @param string $key       For stacked values (arrays in an array).
-     *
-     * @return string
-     */
-    protected function buildQuery(array $data, $separator, $key = null)
-    {
-        $query = array();
-        foreach ($data as $name => $value) {
-            if ($this->getOption(self::OPTION_ENCODE_KEYS) === true) {
-                $name = rawurlencode($name);
-            }
-            if ($key !== null) {
-                if ($this->getOption(self::OPTION_USE_BRACKETS) === true) {
-                    $name = $key . '[' . $name . ']';
-                } else {
-                    $name = $key;
-                }
-            }
-            if (is_array($value)) {
-                $query[] = $this->buildQuery($value, $separator, $name);
-            } else {
-                $query[] = $name . '=' . rawurlencode($value);
-            }
-        }
-        return implode($separator, $query);
-    }
-
-    /**
-     * This method uses a funky regex to parse the url into the designated parts.
-     *
-     * @param string $url
-     *
-     * @return void
-     * @uses   self::$_scheme, self::setAuthority(), self::$_path, self::$_query,
-     *         self::$_fragment
-     * @see    self::__construct()
-     */
-    protected function parseUrl($url)
-    {
-        // The regular expression is copied verbatim from RFC 3986, appendix B.
-        // The expression does not validate the URL but matches any string.
-        preg_match('!^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?!',
-                   $url,
-                   $matches);
-
-        // "path" is always present (possibly as an empty string); the rest
-        // are optional.
-        $this->_scheme   = !empty($matches[1]) ? $matches[2] : false;
-        $this->setAuthority(!empty($matches[3]) ? $matches[4] : false);
-        $this->_path     = $matches[5];
-        $this->_query    = !empty($matches[6]) ? $matches[7] : false;
-        $this->_fragment = !empty($matches[8]) ? $matches[9] : false;
-    }
-}
Index: /branches/version-2_13-dev/data/module/SearchReplace.php
===================================================================
--- /branches/version-2_13-dev/data/module/SearchReplace.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/SearchReplace.php	(revision 23141)
@@ -1,30 +1,547 @@
 <?php
-/*
- * This file is part of EC-CUBE
+// +-----------------------------------------------------------------------+
+// | Copyright (c) 2002-2005, Richard Heyes                                |
+// | All rights reserved.                                                  |
+// |                                                                       |
+// | Redistribution and use in source and binary forms, with or without    |
+// | modification, are permitted provided that the following conditions    |
+// | are met:                                                              |
+// |                                                                       |
+// | o Redistributions of source code must retain the above copyright      |
+// |   notice, this list of conditions and the following disclaimer.       |
+// | o Redistributions in binary form must reproduce the above copyright   |
+// |   notice, this list of conditions and the following disclaimer in the |
+// |   documentation and/or other materials provided with the distribution.|
+// | o The names of the authors may not be used to endorse or promote      |
+// |   products derived from this software without specific prior written  |
+// |   permission.                                                         |
+// |                                                                       |
+// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
+// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
+// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
+// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
+// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
+// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
+// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
+// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
+// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
+// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
+// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
+// |                                                                       |
+// +-----------------------------------------------------------------------+
+// | Author: Richard Heyes <richard@phpguru.org>                           |
+// +-----------------------------------------------------------------------+
+//
+// $Id$
+//
+// Search and Replace Utility
+//
+
+/**
+ * Search and Replace Utility
  *
- * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
  *
- * http://www.lockon.co.jp/
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * @author  Richard Heyes <richard@phpguru.org>
+ * @version 1.0
+ * @package File
  */
-
-/*
- * r21237 より前の誤ったファイル配置を前提とした決済モジュールでのエラーを抑制する役割。
- * 本来のファイルはオートローダーが読み込みを行う。
- * @deprecated
- */
-
-trigger_error('従来互換用の HTTP_Request が読み込まれました。', E_USER_WARNING);
+class File_SearchReplace
+{
+    
+    // {{{ Properties (All private)
+
+    var $find;
+    var $replace;
+    var $files;
+    var $directories;
+    var $include_subdir;
+    var $ignore_lines;
+    var $ignore_sep;
+    var $occurences;
+    var $search_function;
+    var $php5;
+    var $last_error;
+
+    // }}}
+    // {{{ Constructor
+
+    /**
+     * Sets up the object
+     *
+     * @access public
+     * @param string $find                      The string/regex to find.
+     * @param string $replace                   The string/regex to replace $find with.
+     * @param array  $files                     The file(s) to perform this operation on.
+     * @param array  $directories    (optional) The directories to perform this operation on.
+     * @param bool   $include_subdir            If performing on directories, whether to traverse subdirectories.
+     * @param array  $ignore_lines              Ignore lines beginning with any of the strings in this array. This
+     *                                          feature only works with the "normal" search.
+     */
+    function File_SearchReplace($find, $replace, $files, $directories = '', $include_subdir = TRUE, $ignore_lines = array())
+    {
+
+        $this->find            = $find;
+        $this->replace         = $replace;
+        $this->files           = $files;
+        $this->directories     = $directories;
+        $this->include_subdir  = $include_subdir;
+        $this->ignore_lines    = (array) $ignore_lines;
+
+        $this->occurences      = 0;
+        $this->search_function = 'search';
+        $this->php5            = (substr(PHP_VERSION, 0, 1) == 5) ? TRUE : FALSE;
+        $this->last_error      = '';
+
+    }
+
+    // }}}
+    // {{{ getNumOccurences()
+
+    /**
+     * Accessor to return the number of occurences found.
+     *
+     * @access public
+     * @return int Number of occurences found.
+     */
+    function getNumOccurences()
+    {
+        return $this->occurences;
+    }
+
+    // }}}
+    // {{{ getLastError()
+
+    /**
+     * Accessor for retrieving last error.
+     *
+     * @access public
+     * @return string The last error that occurred, if any.
+     */
+    function getLastError()
+    {
+        return $this->last_error;
+    }
+
+    // }}}
+    // {{{ setFind()
+
+    /**
+     * Accessor for setting find variable.
+     *
+     * @access public
+     * @param string $find The string/regex to find.
+     */
+    function setFind($find)
+    {
+        $this->find = $find;
+    }
+
+    // }}}
+    // {{{ setReplace()
+
+    /**
+     * Accessor for setting replace variable.
+     *
+     * @access public
+     * @param string $replace The string/regex to replace the find string/regex with.
+     */
+    function setReplace($replace)
+    {
+        $this->replace = $replace;
+    }
+
+    // }}}
+    // {{{ setFiles()
+
+    /**
+     * Accessor for setting files variable.
+     *
+     * @access public
+     * @param array $files The file(s) to perform this operation on.
+     */
+    function setFiles($files)
+    {
+        $this->files = $files;
+    }
+
+    // }}}
+    // {{{ setDirectories()
+
+    /**
+     * Accessor for setting directories variable.
+     *
+     * @access public
+     * @param array $directories The directories to perform this operation on.
+     */
+    function setDirectories($directories)
+    {
+        $this->directories = $directories;
+    }
+
+    // }}}
+    // {{{ setIncludeSubdir
+
+    /**
+     * Accessor for setting include_subdir variable.
+     *
+     * @access public
+     * @param bool $include_subdir Whether to traverse subdirectories or not.
+     */
+    function setIncludeSubdir($include_subdir)
+    {
+        $this->include_subdir = $include_subdir;
+    }
+
+    // }}}
+    // {{{ setIgnoreLines()
+
+    /**
+     * Accessor for setting ignore_lines variable.
+     *
+     * @access public
+     * @param array $ignore_lines Ignore lines beginning with any of the strings in this array. This
+     *                            feature only works with the "normal" search.
+     */
+    function setIgnoreLines($ignore_lines)
+    {
+        $this->ignore_lines = $ignore_lines;
+    }
+
+    // }}}
+    // {{{ setSearchFunction()
+
+    /**
+     * Function to determine which search function is used.
+     *
+     * @access public
+     * @param string The search function that should be used. Can be any one of:
+     *               normal - Default search. Goes line by line. Ignore lines feature only works with this type.
+     *               quick  - Uses str_replace for straight replacement throughout file. Quickest of the lot.
+     *               preg   - Uses preg_replace(), so any regex valid with this function is valid here.
+     *               ereg   - Uses ereg_replace(), so any regex valid with this function is valid here.
+     */
+    function setSearchFunction($search_function)
+    {
+        switch($search_function) {
+        case 'normal': $this->search_function = 'search';
+            return TRUE;
+            break;
+
+        case 'quick' : $this->search_function = 'quickSearch';
+            return TRUE;
+            break;
+
+        case 'preg'  : $this->search_function = 'pregSearch';
+            return TRUE;
+            break;
+
+        case 'ereg'  : $this->search_function = 'eregSearch';
+            return TRUE;
+            break;
+
+        default      : $this->last_error      = 'Invalid search function specified';
+            return FALSE;
+            break;
+        }
+    }
+
+    // }}}
+    // {{{ search()
+
+    /**
+     * Default ("normal") search routine.
+     *
+     * @access private
+     * @param string $filename The filename to search and replace upon.
+     * @return array Will return an array containing the new file contents and the number of occurences.
+     *               Will return FALSE if there are no occurences.
+     */
+    function search($filename)
+    {
+        $occurences = 0;
+        $file_array = file($filename);
+
+        if (empty($this->ignore_lines) && $this->php5) { // PHP5 acceleration
+            $file_array = str_replace($this->find, $this->replace, $file_array, $occurences);
+
+        } else { // str_replace() doesn't return number of occurences in PHP4
+                 // so we need to count them manually and/or filter strings
+            $ignore_lines_num = count($this->ignore_lines);
+
+            // just for the sake of catching occurences
+            $local_find    = array_values((array) $this->find);
+            $local_replace = (is_array($this->replace)) ? array_values($this->replace) : $this->replace;
+
+            for ($i=0; $i < count($file_array); $i++) {
+
+                if ($ignore_lines_num > 0) {
+                    for ($j=0; $j < $ignore_lines_num; $j++) {
+                        if (substr($file_array[$i],0,strlen($this->ignore_lines[$j])) == $this->ignore_lines[$j]) continue 2;
+                    }
+                }
+
+                if ($this->php5) {
+                    $file_array[$i] = str_replace($this->find, $this->replace, $file_array[$i], $counted);
+                    $occurences += $counted;
+                } else {
+                    foreach ($local_find as $fk => $ff) {
+                        $occurences += substr_count($file_array[$i], $ff);
+                        if (!is_array($local_replace)) {
+                            $fr = $local_replace;
+                        } else {
+                            $fr = (isset($local_replace[$fk])) ? $local_replace[$fk] : "";
+                        }
+                        $file_array[$i] = str_replace($ff, $fr, $file_array[$i]);
+                    }
+                }
+            }
+
+        }
+        if ($occurences > 0) $return = array($occurences, implode('', $file_array)); else $return = FALSE;
+        return $return;
+
+    }
+
+    // }}}
+    // {{{ quickSearch()
+
+    /**
+     * Quick search routine.
+     *
+     * @access private
+     * @param string $filename The filename to search and replace upon.
+     * @return array Will return an array containing the new file contents and the number of occurences.
+     *               Will return FALSE if there are no occurences.
+     */
+    function quickSearch($filename)
+    {
+
+        clearstatcache();
+
+        $file          = fread($fp = fopen($filename, 'r'), max(1, filesize($filename))); fclose($fp);
+        $local_find    = array_values((array) $this->find);
+        $local_replace = (is_array($this->replace)) ? array_values($this->replace) : $this->replace;
+
+        $occurences    = 0;
+
+        // logic is the same as in str_replace function with one exception:
+        //   if <search> is a string and <replacement> is an array - substitution
+        //   is done from the first element of array. str_replace in this case
+        //   usualy fails with notice and returns "ArrayArrayArray..." string
+        // (this exclusive logic of SearchReplace will not work for php5, though,
+        // because I haven't decided yet whether it is bug or feature)
+
+        if ($this->php5) {
+            $file_array[$i] = str_replace($this->find, $this->replace, $file_array[$i], $counted);
+            $occurences += $counted;
+        } else {
+            foreach ($local_find as $fk => $ff) {
+                $occurences += substr_count($file, $ff);
+                if (!is_array($local_replace)) {
+                    $fr = $local_replace;
+                } else {
+                    $fr = (isset($local_replace[$fk])) ? $local_replace[$fk] : "";
+                }
+                $file = str_replace($ff, $fr, $file);
+            }
+        }
+
+        if ($occurences > 0) $return = array($occurences, $file); else $return = FALSE;
+        return $return;
+
+    }
+
+    // }}}
+    // {{{ pregSearch()
+
+    /**
+     * Preg search routine.
+     *
+     * @access private
+     * @param string $filename The filename to search and replace upon.
+     * @return array Will return an array containing the new file contents and the number of occurences.
+     *               Will return FALSE if there are no occurences.
+     */
+    function pregSearch($filename)
+    {
+
+        clearstatcache();
+
+        $file       = fread($fp = fopen($filename, 'r'), max(1, filesize($filename))); fclose($fp);
+        $local_find    = array_values((array) $this->find);
+        $local_replace = (is_array($this->replace)) ? array_values($this->replace) : $this->replace;
+
+        $occurences = 0;
+
+        foreach($local_find as $fk => $ff) {
+            $occurences += preg_match_all($ff, $file, $matches);
+            if (!is_array($local_replace)) {
+                $fr = $local_replace;
+            } else {
+                $fr = (isset($local_replace[$fk])) ? $local_replace[$fk] : "";
+            }
+            $file = preg_replace($ff, $fr, $file);
+        }
+
+        if ($occurences > 0) $return = array($occurences, $file); else $return = FALSE;
+        return $return;
+
+    }
+
+    // }}}
+    // {{{ eregSearch()
+
+    /**
+     * Ereg search routine.
+     *
+     * @access private
+     * @param string $filename The filename to search and replace upon.
+     * @return array Will return an array containing the new file contents and the number of occurences.
+     *               Will return FALSE if there are no occurences.
+     */
+    function eregSearch($filename)
+    {
+
+        clearstatcache();
+
+        $file = fread($fp = fopen($filename, 'r'), max(1, filesize($filename))); fclose($fp);
+        $local_find    = array_values((array) $this->find);
+        $local_replace = (is_array($this->replace)) ? array_values($this->replace) : $this->replace;
+
+        $occurences = 0;
+
+        foreach($local_find as $fk => $ff) {
+            $occurences += count(split($ff, $file)) - 1;
+            if (!is_array($local_replace)) {
+                $fr = $local_replace;
+            } else {
+                $fr = (isset($local_replace[$fk])) ? $local_replace[$fk] : "";
+            }
+            $file = ereg_replace($ff, $fr, $file);
+        }
+
+        if ($occurences > 0) $return = array($occurences, $file); else $return = FALSE;
+        return $return;
+
+    }
+
+    // }}}
+    // {{{ writeout()
+    
+    /**
+     * Function to writeout the file contents.
+     *
+     * @access private
+     * @param string $filename The filename of the file to write.
+     * @param string $contents The contents to write to the file.
+     */
+    function writeout($filename, $contents)
+    {
+
+        if ($fp = @fopen($filename, 'w')) {
+            flock($fp,2);
+            fwrite($fp, $contents);
+            flock($fp,3);
+            fclose($fp);
+        } else {
+            $this->last_error = 'Could not open file: '.$filename;
+        }
+
+    }
+
+    // }}}
+    // {{{ doFiles()
+
+    /**
+     * Function called by doSearch() to go through any files that need searching.
+     *
+     * @access private
+     * @param string $ser_func The search function to use.
+     */
+    function doFiles($ser_func)
+    {
+        if (!is_array($this->files)) $this->files = explode(',', $this->files);
+        for ($i=0; $i<count($this->files); $i++) {
+            if ($this->files[$i] == '.' OR $this->files[$i] == '..') continue;
+            if (is_dir($this->files[$i]) == TRUE) continue;
+            $newfile = $this->$ser_func($this->files[$i]);
+            if (is_array($newfile) == TRUE){
+                $this->writeout($this->files[$i], $newfile[1]);
+                $this->occurences += $newfile[0];
+            }
+        }
+    }
+
+    // }}}
+    // {{{ doDirectories()
+
+    /**
+     * Function called by doSearch() to go through any directories that need searching.
+     *
+     * @access private
+     * @param string $ser_func The search function to use.
+     */
+    function doDirectories($ser_func)
+    {
+        if (!is_array($this->directories)) $this->directories = explode(',', $this->directories);
+        for ($i=0; $i<count($this->directories); $i++) {
+            $dh = opendir($this->directories[$i]);
+            while ($file = readdir($dh)) {
+                if ($file == '.' OR $file == '..') continue;
+
+                if (is_dir($this->directories[$i].$file) == TRUE) {
+                    if ($this->include_subdir == TRUE) {
+                        $this->directories[] = $this->directories[$i].$file.'/';
+                        continue;
+                    } else {
+                        continue;
+                    }
+                }
+
+                $newfile = $this->$ser_func($this->directories[$i].$file);
+                if (is_array($newfile) == TRUE) {
+                    $this->writeout($this->directories[$i].$file, $newfile[1]);
+                    $this->occurences += $newfile[0];
+                }
+            }
+        }
+    }
+
+    // }}}
+    // {{{ doSearch()
+    
+    /**
+     * This starts the search/replace off. The behavior of this function will likely
+     * to be changed in future versions to work in read only mode. If you want to do
+     * actual replace with writing files - use doReplace method instead. 
+     *
+     * @access public
+     */
+    function doSearch()
+    {
+        $this->doReplace();
+    }
+    
+    // }}}
+    // {{{ doReplace()
+    
+    /**
+     * This starts the search/replace off. Call this to do the replace.
+     * First do whatever files are specified, and/or if directories are specified,
+     * do those too.
+     *
+     * @access public
+     */
+    function doReplace()
+    {
+        $this->occurences = 0;
+        if ($this->find != '') {
+            if ((is_array($this->files) AND count($this->files) > 0) OR $this->files != '') $this->doFiles($this->search_function);
+            if ($this->directories != '')                                                   $this->doDirectories($this->search_function);
+        }
+    }
+    
+    // }}}
+
+}
+?>
Index: /branches/version-2_13-dev/data/module/PEAR5.php
===================================================================
--- /branches/version-2_13-dev/data/module/PEAR5.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/PEAR5.php	(revision 23141)
Index: /branches/version-2_13-dev/data/module/Calendar/Month/Weekdays.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Month/Weekdays.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Month/Weekdays.php	(revision 23141)
@@ -1,38 +1,26 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: Weekdays.php,v 1.4 2005/10/22 10:28:49 quipo Exp $
+//
 /**
- * Contains the Calendar_Month_Weekdays class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Weekdays.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Weekdays.php,v 1.4 2005/10/22 10:28:49 quipo Exp $
  */
 
@@ -59,5 +47,5 @@
  * <code>
  * require_once 'Calendar/Month/Weekdays.php';
- * $Month = new Calendar_Month_Weekdays(2003, 10); // Oct 2003
+ * $Month = & new Calendar_Month_Weekdays(2003, 10); // Oct 2003
  * $Month->build(); // Build Calendar_Day objects
  * while ($Day = & $Month->fetch()) {
@@ -75,12 +63,6 @@
  * }
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Month_Weekdays extends Calendar_Month
@@ -102,14 +84,12 @@
     /**
      * Constructs Calendar_Month_Weekdays
-     *
-     * @param int $y        year e.g. 2003
-     * @param int $m        month e.g. 5
-     * @param int $firstDay (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
-     *
+     * @param int year e.g. 2003
+     * @param int month e.g. 5
+     * @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
      * @access public
      */
     function Calendar_Month_Weekdays($y, $m, $firstDay=null)
     {
-        parent::Calendar_Month($y, $m, $firstDay);
+        Calendar_Month::Calendar_Month($y, $m, $firstDay);
     }
 
@@ -118,17 +98,15 @@
      * with empty cells if the first day of the week does not fall on the first
      * day of the month.
-     *
-     * @param array $sDates (optional) Calendar_Day objects representing selected dates
-     *
-     * @return boolean
-     * @access public
      * @see Calendar_Day::isEmpty()
      * @see Calendar_Day_Base::isFirst()
      * @see Calendar_Day_Base::isLast()
+     * @param array (optional) Calendar_Day objects representing selected dates
+     * @return boolean
+     * @access public
      */
-    function build($sDates = array())
+    function build($sDates=array())
     {
-        include_once CALENDAR_ROOT.'Table/Helper.php';
-        $this->tableHelper = new Calendar_Table_Helper($this, $this->firstDay);
+        require_once CALENDAR_ROOT.'Table/Helper.php';
+        $this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay);
         Calendar_Month::build($sDates);
         $this->buildEmptyDaysBefore();
@@ -141,5 +119,4 @@
     /**
      * Prepends empty days before the real days in the month
-     *
      * @return void
      * @access private
@@ -162,5 +139,4 @@
     /**
      * Shifts the array of children forward, if necessary
-     *
      * @return void
      * @access private
@@ -168,5 +144,5 @@
     function shiftDays()
     {
-        if (isset($this->children[0])) {
+        if (isset ($this->children[0])) {
             array_unshift($this->children, null);
             unset($this->children[0]);
@@ -176,5 +152,4 @@
     /**
      * Appends empty days after the real days in the month
-     *
      * @return void
      * @access private
@@ -183,6 +158,6 @@
     {
         $eAfter = $this->tableHelper->getEmptyDaysAfter();
-        $sDOM   = $this->tableHelper->getNumTableDaysInMonth();
-        for ($i=1; $i <= $sDOM-$eAfter; $i++) {
+        $sDOM = $this->tableHelper->getNumTableDaysInMonth();
+        for ($i = 1; $i <= $sDOM-$eAfter; $i++) {
             $Day = new Calendar_Day($this->year, $this->month+1, $i);
             $Day->setEmpty();
@@ -195,5 +170,4 @@
      * Sets the "markers" for the beginning and of a of week, in the
      * built Calendar_Day children
-     *
      * @return void
      * @access private
@@ -201,5 +175,5 @@
     function setWeekMarkers()
     {
-        $dIW = $this->cE->getDaysInWeek(
+        $dIW  = $this->cE->getDaysInWeek(
             $this->thisYear(),
             $this->thisMonth(),
Index: /branches/version-2_13-dev/data/module/Calendar/Month/Weeks.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Month/Weeks.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Month/Weeks.php	(revision 23141)
@@ -1,39 +1,27 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// |          Lorenzo Alberton <l dot alberton at quipo dot it>           |
+// +----------------------------------------------------------------------+
+//
+// $Id: Weeks.php,v 1.3 2005/10/22 10:28:49 quipo Exp $
+//
 /**
- * Contains the Calendar_Month_Weeks class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Weeks.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Weeks.php,v 1.3 2005/10/22 10:28:49 quipo Exp $
  */
 
@@ -60,5 +48,5 @@
  * <code>
  * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Month'.DIRECTORY_SEPARATOR.'Weeks.php';
- * $Month = new Calendar_Month_Weeks(2003, 10); // Oct 2003
+ * $Month = & new Calendar_Month_Weeks(2003, 10); // Oct 2003
  * $Month->build(); // Build Calendar_Day objects
  * while ($Week = & $Month->fetch()) {
@@ -66,13 +54,6 @@
  * }
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Month_Weeks extends Calendar_Month
@@ -94,14 +75,12 @@
     /**
      * Constructs Calendar_Month_Weeks
-     *
-     * @param int $y        year e.g. 2003
-     * @param int $m        month e.g. 5
-     * @param int $firstDay (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
-     *
+     * @param int year e.g. 2003
+     * @param int month e.g. 5
+     * @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
      * @access public
      */
     function Calendar_Month_Weeks($y, $m, $firstDay=null)
     {
-        parent::Calendar_Month($y, $m, $firstDay);
+        Calendar_Month::Calendar_Month($y, $m, $firstDay);
     }
 
@@ -109,15 +88,13 @@
      * Builds Calendar_Week objects for the Month. Note that Calendar_Week
      * builds Calendar_Day object in tabular form (with Calendar_Day->empty)
-     *
-     * @param array $sDates (optional) Calendar_Week objects representing selected dates
-     *
+     * @param array (optional) Calendar_Week objects representing selected dates
      * @return boolean
      * @access public
      */
-    function build($sDates = array())
+    function build($sDates=array())
     {
-        include_once CALENDAR_ROOT.'Table/Helper.php';
-        $this->tableHelper = new Calendar_Table_Helper($this, $this->firstDay);
-        include_once CALENDAR_ROOT.'Week.php';
+        require_once CALENDAR_ROOT.'Table/Helper.php';
+        $this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay);
+        require_once CALENDAR_ROOT.'Week.php';
         $numWeeks = $this->tableHelper->getNumWeeks();
         for ($i=1, $d=1; $i<=$numWeeks; $i++,
@@ -125,7 +102,5 @@
                 $this->thisYear(),
                 $this->thisMonth(),
-                $this->thisDay()
-            )
-        ) {
+                $this->thisDay()) ) {
             $this->children[$i] = new Calendar_Week(
                 $this->year, $this->month, $d, $this->tableHelper->getFirstDay());
@@ -144,7 +119,5 @@
     /**
      * Called from build()
-     *
-     * @param array $sDates Calendar_Week objects representing selected dates
-     *
+     * @param array
      * @return void
      * @access private
Index: /branches/version-2_13-dev/data/module/Calendar/Year.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Year.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Year.php	(revision 23141)
@@ -1,38 +1,26 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: Year.php,v 1.4 2005/10/22 10:25:39 quipo Exp $
+//
 /**
- * Contains the Calendar_Minute class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Year.php 300728 2010-06-24 11:43:56Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Year.php,v 1.4 2005/10/22 10:25:39 quipo Exp $
  */
 
@@ -60,12 +48,6 @@
  * }
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Year extends Calendar
@@ -73,12 +55,10 @@
     /**
      * Constructs Calendar_Year
-     *
-     * @param int $y year e.g. 2003
-     *
+     * @param int year e.g. 2003
      * @access public
      */
     function Calendar_Year($y)
     {
-        parent::Calendar($y);
+        Calendar::Calendar($y);
     }
 
@@ -94,10 +74,6 @@
      * </code>
      * It defaults to building Calendar_Month objects.
-     *
-     * @param array $sDates   (optional) array of Calendar_Month objects
-     *                        representing selected dates
-     * @param int   $firstDay (optional) first day of week
-     *                        (e.g. 0 for Sunday, 2 for Tuesday etc.)
-     *
+     * @param array (optional) array of Calendar_Month objects representing selected dates
+     * @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
      * @return boolean
      * @access public
@@ -105,7 +81,7 @@
     function build($sDates = array(), $firstDay = null)
     {
-        include_once CALENDAR_ROOT.'Factory.php';
+        require_once CALENDAR_ROOT.'Factory.php';
         $this->firstDay = $this->defineFirstDayOfWeek($firstDay);
-        $monthsInYear   = $this->cE->getMonthsInYear($this->thisYear());
+        $monthsInYear = $this->cE->getMonthsInYear($this->thisYear());
         for ($i=1; $i <= $monthsInYear; $i++) {
             $this->children[$i] = Calendar_Factory::create('Month', $this->year, $i);
@@ -119,12 +95,9 @@
     /**
      * Called from build()
-     *
-     * @param array $sDates array of Calendar_Month objects representing selected dates
-     *
+     * @param array
      * @return void
      * @access private
      */
-    function setSelection($sDates) 
-    {
+    function setSelection($sDates) {
         foreach ($sDates as $sDate) {
             if ($this->year == $sDate->thisYear()) {
Index: /branches/version-2_13-dev/data/module/Calendar/Minute.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Minute.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Minute.php	(revision 23141)
@@ -1,38 +1,26 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: Minute.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
+//
 /**
- * Contains the Calendar_Minute class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Minute.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Minute.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
  */
 
@@ -54,5 +42,5 @@
  * <code>
  * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Minute.php';
- * $Minute = new Calendar_Minute(2003, 10, 21, 15, 31); // Oct 21st 2003, 3:31pm
+ * $Minute = & new Calendar_Minute(2003, 10, 21, 15, 31); // Oct 21st 2003, 3:31pm
  * $Minute->build(); // Build Calendar_Second objects
  * while ($Second = & $Minute->fetch()) {
@@ -60,12 +48,6 @@
  * }
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Minute extends Calendar
@@ -73,29 +55,25 @@
     /**
      * Constructs Minute
-     *
-     * @param int $y year e.g. 2003
-     * @param int $m month e.g. 5
-     * @param int $d day e.g. 11
-     * @param int $h hour e.g. 13
-     * @param int $i minute e.g. 31
-     *
+     * @param int year e.g. 2003
+     * @param int month e.g. 5
+     * @param int day e.g. 11
+     * @param int hour e.g. 13
+     * @param int minute e.g. 31
      * @access public
      */
     function Calendar_Minute($y, $m, $d, $h, $i)
     {
-        parent::Calendar($y, $m, $d, $h, $i);
+        Calendar::Calendar($y, $m, $d, $h, $i);
     }
 
     /**
      * Builds the Calendar_Second objects
-     *
-     * @param array $sDates (optional) Calendar_Second objects representing selected dates
-     *
+     * @param array (optional) Calendar_Second objects representing selected dates
      * @return boolean
      * @access public
      */
-    function build($sDates = array())
+    function build($sDates=array())
     {
-        include_once CALENDAR_ROOT.'Second.php';
+        require_once CALENDAR_ROOT.'Second.php';
         $sIM = $this->cE->getSecondsInMinute($this->year, $this->month,
                 $this->day, $this->hour, $this->minute);
@@ -112,7 +90,5 @@
     /**
      * Called from build()
-     *
-     * @param array $sDates Calendar_Second objects representing selected dates
-     *
+     * @param array
      * @return void
      * @access private
Index: /branches/version-2_13-dev/data/module/Calendar/Table/Helper.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Table/Helper.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Table/Helper.php	(revision 23141)
@@ -1,38 +1,26 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: Helper.php,v 1.5 2005/10/22 09:51:53 quipo Exp $
+//
 /**
- * Contains the Calendar_Decorator_Wrapper class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Helper.php 246317 2007-11-16 20:05:32Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Helper.php,v 1.5 2005/10/22 09:51:53 quipo Exp $
  */
 
@@ -40,12 +28,6 @@
  * Used by Calendar_Month_Weekdays, Calendar_Month_Weeks and Calendar_Week to
  * help with building the calendar in tabular form
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access public
+ * @package Calendar
+ * @access protected
  */
 class Calendar_Table_Helper
@@ -109,8 +91,6 @@
     /**
      * Constructs Calendar_Table_Helper
-     *
-     * @param object &$calendar Calendar_Month_Weekdays, Calendar_Month_Weeks, Calendar_Week
-     * @param int    $firstDay  (optional) first day of the week e.g. 1 for Monday
-     *
+     * @param object Calendar_Month_Weekdays, Calendar_Month_Weeks, Calendar_Week
+     * @param int (optional) first day of the week e.g. 1 for Monday
      * @access protected
      */
@@ -133,5 +113,4 @@
     /**
      * Constructs $this->daysOfWeek based on $this->firstDay
-     *
      * @return void
      * @access private
@@ -162,5 +141,4 @@
     /**
      * Constructs $this->daysOfMonth
-     *
      * @return void
      * @access private
@@ -197,8 +175,7 @@
     /**
      * Returns the first day of the month
-     *
-     * @return int
-     * @access protected
      * @see Calendar_Engine_Interface::getFirstDayOfWeek()
+     * @return int
+     * @access protected
      */
     function getFirstDay()
@@ -209,5 +186,4 @@
     /**
      * Returns the order array of days in a week
-     *
      * @return int
      * @access protected
@@ -220,5 +196,4 @@
     /**
      * Returns the number of tabular weeks in a month
-     *
      * @return int
      * @access protected
@@ -231,5 +206,4 @@
     /**
      * Returns the number of real days + empty days
-     *
      * @return int
      * @access protected
@@ -242,5 +216,4 @@
     /**
      * Returns the number of empty days before the real days begin
-     *
      * @return int
      * @access protected
@@ -253,5 +226,4 @@
     /**
      * Returns the index of the last real day in the month
-     *
      * @todo Potential performance optimization with static
      * @return int
@@ -261,9 +233,9 @@
     {
         // Causes bug when displaying more than one month
-        //static $index;
-        //if (!isset($index)) {
+//        static $index;
+//        if (!isset($index)) {
             $index = $this->getEmptyDaysBefore() + $this->cE->getDaysInMonth(
                 $this->calendar->thisYear(), $this->calendar->thisMonth());
-        //}
+//        }
         return $index;
     }
@@ -272,5 +244,4 @@
      * Returns the index of the last real day in the month, relative to the
      * beginning of the tabular week it is part of
-     *
      * @return int
      * @access protected
@@ -284,16 +255,9 @@
                 $this->calendar->thisMonth(),
                 $this->calendar->thisDay()
-            ) * ($this->numWeeks-1));
+            ) * ($this->numWeeks-1) );
     }
 
     /**
      * Returns the timestamp of the first day of the current week
-     *
-     * @param int $y        year
-     * @param int $m        month
-     * @param int $d        day
-     * @param int $firstDay first day of the week (default 1 = Monday)
-     *
-     * @return int timestamp
      */
     function getWeekStart($y, $m, $d, $firstDay=1)
Index: /branches/version-2_13-dev/data/module/Calendar/Factory.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Factory.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Factory.php	(revision 23141)
@@ -1,39 +1,27 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// |          Lorenzo Alberton <l dot alberton at quipo dot it>           |
+// +----------------------------------------------------------------------+
+//
+// $Id: Factory.php,v 1.3 2005/10/22 10:08:47 quipo Exp $
+//
 /**
- * Contains the Calendar_Factory class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Factory.php 246404 2007-11-18 21:46:43Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Factory.php,v 1.3 2005/10/22 10:08:47 quipo Exp $
  */
 
@@ -65,12 +53,5 @@
  * Use the constract CALENDAR_FIRST_DAY_OF_WEEK to control the first day of the week
  * for Month or Week objects (e.g. 0 = Sunday, 6 = Saturday)
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
  * @access protected
  */
@@ -79,13 +60,11 @@
     /**
      * Creates a calendar object given the type and units
-     *
-     * @param string $type class of calendar object to create
-     * @param int    $y    year
-     * @param int    $m    month
-     * @param int    $d    day
-     * @param int    $h    hour
-     * @param int    $i    minute
-     * @param int    $s    second
-     *
+     * @param string class of calendar object to create
+     * @param int year
+     * @param int month
+     * @param int day
+     * @param int hour
+     * @param int minute
+     * @param int second
      * @return object subclass of Calendar
      * @access public
@@ -96,57 +75,55 @@
         $firstDay = defined('CALENDAR_FIRST_DAY_OF_WEEK') ? CALENDAR_FIRST_DAY_OF_WEEK : 1;
         switch ($type) {
-        case 'Day':
-            include_once CALENDAR_ROOT.'Day.php';
-            return new Calendar_Day($y, $m, $d);
-        case 'Month':
-            // Set default state for which month type to build
-            if (!defined('CALENDAR_MONTH_STATE')) {
-                define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH);
-            }
-            switch (CALENDAR_MONTH_STATE) {
-            case CALENDAR_USE_MONTH_WEEKDAYS:
-                include_once CALENDAR_ROOT.'Month/Weekdays.php';
-                $class = 'Calendar_Month_Weekdays';
-                break;
-            case CALENDAR_USE_MONTH_WEEKS:
-                include_once CALENDAR_ROOT.'Month/Weeks.php';
-                $class = 'Calendar_Month_Weeks';
-                break;
-            case CALENDAR_USE_MONTH:
+            case 'Day':
+                require_once CALENDAR_ROOT.'Day.php';
+                return new Calendar_Day($y,$m,$d);
+            case 'Month':
+                // Set default state for which month type to build
+                if (!defined('CALENDAR_MONTH_STATE')) {
+                    define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH);
+                }
+                switch (CALENDAR_MONTH_STATE) {
+                    case CALENDAR_USE_MONTH_WEEKDAYS:
+                        require_once CALENDAR_ROOT.'Month/Weekdays.php';
+                        $class = 'Calendar_Month_Weekdays';
+                        break;
+                    case CALENDAR_USE_MONTH_WEEKS:
+                        require_once CALENDAR_ROOT.'Month/Weeks.php';
+                        $class = 'Calendar_Month_Weeks';
+                        break;
+                    case CALENDAR_USE_MONTH:
+                    default:
+                        require_once CALENDAR_ROOT.'Month.php';
+                        $class = 'Calendar_Month';
+                        break;
+                }
+                return new $class($y, $m, $firstDay);
+            case 'Week':
+                require_once CALENDAR_ROOT.'Week.php';
+                return new Calendar_Week($y, $m, $d, $firstDay);
+            case 'Hour':
+                require_once CALENDAR_ROOT.'Hour.php';
+                return new Calendar_Hour($y, $m, $d, $h);
+            case 'Minute':
+                require_once CALENDAR_ROOT.'Minute.php';
+                return new Calendar_Minute($y, $m, $d, $h, $i);
+            case 'Second':
+                require_once CALENDAR_ROOT.'Second.php';
+                return new Calendar_Second($y,$m,$d,$h,$i,$s);
+            case 'Year':
+                require_once CALENDAR_ROOT.'Year.php';
+                return new Calendar_Year($y);
             default:
-                include_once CALENDAR_ROOT.'Month.php';
-                $class = 'Calendar_Month';
-                break;
-            }
-            return new $class($y, $m, $firstDay);
-        case 'Week':
-            include_once CALENDAR_ROOT.'Week.php';
-            return new Calendar_Week($y, $m, $d, $firstDay);
-        case 'Hour':
-            include_once CALENDAR_ROOT.'Hour.php';
-            return new Calendar_Hour($y, $m, $d, $h);
-        case 'Minute':
-            include_once CALENDAR_ROOT.'Minute.php';
-            return new Calendar_Minute($y, $m, $d, $h, $i);
-        case 'Second':
-            include_once CALENDAR_ROOT.'Second.php';
-            return new Calendar_Second($y, $m, $d, $h, $i, $s);
-        case 'Year':
-            include_once CALENDAR_ROOT.'Year.php';
-            return new Calendar_Year($y);
-        default:
-            include_once 'PEAR.php';
-            PEAR::raiseError('Calendar_Factory::create() unrecognised type: '.$type,
-                null, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar_Factory::create()');
-            return false;
+                require_once 'PEAR.php';
+                PEAR::raiseError(
+                    'Calendar_Factory::create() unrecognised type: '.$type, null, PEAR_ERROR_TRIGGER,
+                    E_USER_NOTICE, 'Calendar_Factory::create()');
+                return false;
         }
     }
-
     /**
      * Creates an instance of a calendar object, given a type and timestamp
-     *
-     * @param string $type  type of object to create
-     * @param mixed  $stamp timestamp (depending on Calendar engine being used)
-     *
+     * @param string type of object to create
+     * @param mixed timestamp (depending on Calendar engine being used)
      * @return object subclass of Calendar
      * @access public
@@ -155,11 +132,11 @@
     function & createByTimestamp($type, $stamp)
     {
-        $cE  = & Calendar_Engine_Factory::getEngine();
-        $y   = $cE->stampToYear($stamp);
-        $m   = $cE->stampToMonth($stamp);
-        $d   = $cE->stampToDay($stamp);
-        $h   = $cE->stampToHour($stamp);
-        $i   = $cE->stampToMinute($stamp);
-        $s   = $cE->stampToSecond($stamp);
+        $cE = & Calendar_Engine_Factory::getEngine();
+        $y = $cE->stampToYear($stamp);
+        $m = $cE->stampToMonth($stamp);
+        $d = $cE->stampToDay($stamp);
+        $h = $cE->stampToHour($stamp);
+        $i = $cE->stampToMinute($stamp);
+        $s = $cE->stampToSecond($stamp);
         $cal = Calendar_Factory::create($type, $y, $m, $d, $h, $i, $s);
         return $cal;
Index: /branches/version-2_13-dev/data/module/Calendar/Calendar.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Calendar.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Calendar.php	(revision 23141)
@@ -1,39 +1,27 @@
 <?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
+/* vim: set expandtab tabstop=4 shiftwidth=4: */
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// |          Lorenzo Alberton <l dot alberton at quipo dot it>           |
+// +----------------------------------------------------------------------+
+//
+// $Id: Calendar.php,v 1.3 2005/10/22 10:07:11 quipo Exp $
+//
 /**
- * Contains the Calendar and Calendar_Engine_Factory classes
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Calendar.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Calendar.php,v 1.3 2005/10/22 10:07:11 quipo Exp $
  */
 
@@ -65,14 +53,7 @@
  * Calendar_Engines. The engine used can be controlled with the constant
  * CALENDAR_ENGINE
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @see       Calendar_Engine_Interface
- * @access    protected
+ * @see Calendar_Engine_Interface
+ * @package Calendar
+ * @access protected
  */
 class Calendar_Engine_Factory
@@ -80,5 +61,4 @@
     /**
      * Returns an instance of the engine
-     *
      * @return object instance of a calendar calculation engine
      * @access protected
@@ -88,15 +68,15 @@
         static $engine = false;
         switch (CALENDAR_ENGINE) {
-        case 'PearDate':
-            $class = 'Calendar_Engine_PearDate';
-            break;
-        case 'UnixTS':
-        default:
-            $class = 'Calendar_Engine_UnixTS';
+            case 'PearDate':
+                $class = 'Calendar_Engine_PearDate';
+                break;
+            case 'UnixTS':
+            default:
+                $class = 'Calendar_Engine_UnixTS';
             break;
         }
         if (!$engine) {
             if (!class_exists($class)) {
-                include_once CALENDAR_ROOT.'Engine'.DIRECTORY_SEPARATOR.CALENDAR_ENGINE.'.php';
+                require_once CALENDAR_ROOT.'Engine'.DIRECTORY_SEPARATOR.CALENDAR_ENGINE.'.php';
             }
             $engine = new $class;
@@ -107,14 +87,8 @@
 
 /**
- * Base class for Calendar API. This class should not be instantiated directly.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
+ * Base class for Calendar API. This class should not be instantiated
+ * directly.
  * @abstract
+ * @package Calendar
  */
 class Calendar
@@ -140,5 +114,5 @@
      * @var int
      */
-    var $year;
+   var $year;
 
     /**
@@ -194,12 +168,10 @@
     /**
      * Constructs the Calendar
-     *
-     * @param int $y year
-     * @param int $m month
-     * @param int $d day
-     * @param int $h hour
-     * @param int $i minute
-     * @param int $s second
-     *
+     * @param int year
+     * @param int month
+     * @param int day
+     * @param int hour
+     * @param int minute
+     * @param int second
      * @access protected
      */
@@ -210,5 +182,5 @@
             $cE = & Calendar_Engine_Factory::getEngine();
         }
-        $this->cE     = & $cE;
+        $this->cE = & $cE;
         $this->year   = (int)$y;
         $this->month  = (int)$m;
@@ -222,7 +194,5 @@
      * Defines the calendar by a timestamp (Unix or ISO-8601), replacing values
      * passed to the constructor
-     *
-     * @param int|string $ts Unix or ISO-8601 timestamp
-     *
+     * @param int|string Unix or ISO-8601 timestamp
      * @return void
      * @access public
@@ -241,5 +211,4 @@
      * Returns a timestamp from the current date / time values. Format of
      * timestamp depends on Calendar_Engine implementation being used
-     *
      * @return int|string timestamp
      * @access public
@@ -254,7 +223,5 @@
     /**
      * Defines calendar object as selected (e.g. for today)
-     *
-     * @param boolean $state whether Calendar subclass
-     *
+     * @param boolean state whether Calendar subclass
      * @return void
      * @access public
@@ -267,5 +234,4 @@
     /**
      * True if the calendar subclass object is selected (e.g. today)
-     *
      * @return boolean
      * @access public
@@ -277,17 +243,5 @@
 
     /**
-     * Checks if the current Calendar object is today's date
-     *
-     * @return boolean
-     * @access public
-     */
-    function isToday()
-    {
-        return $this->cE->isToday($this->getTimeStamp());
-    }
-
-    /**
      * Adjusts the date (helper method)
-     *
      * @return void
      * @access public
@@ -295,5 +249,5 @@
     function adjust()
     {
-        $stamp        = $this->getTimeStamp();
+        $stamp = $this->getTimeStamp();
         $this->year   = $this->cE->stampToYear($stamp);
         $this->month  = $this->cE->stampToMonth($stamp);
@@ -306,7 +260,5 @@
     /**
      * Returns the date as an associative array (helper method)
-     *
-     * @param mixed $stamp timestamp (leave empty for current timestamp)
-     *
+     * @param mixed timestamp (leave empty for current timestamp)
      * @return array
      * @access public
@@ -329,10 +281,8 @@
     /**
      * Returns the value as an associative array (helper method)
-     *
-     * @param string $returnType type of date object that return value represents
-     * @param string $format     ['int' | 'array' | 'timestamp' | 'object']
-     * @param mixed  $stamp      timestamp (depending on Calendar engine being used)
-     * @param int    $default    default value (i.e. give me the answer quick)
-     *
+     * @param string type of date object that return value represents
+     * @param string $format ['int' | 'array' | 'timestamp' | 'object']
+     * @param mixed timestamp (depending on Calendar engine being used)
+     * @param int integer default value (i.e. give me the answer quick)
      * @return mixed
      * @access private
@@ -341,17 +291,17 @@
     {
         switch (strtolower($format)) {
-        case 'int':
-            return $default;
-        case 'array':
-            return $this->toArray($stamp);
-            break;
-        case 'object':
-            include_once CALENDAR_ROOT.'Factory.php';
-            return Calendar_Factory::createByTimestamp($returnType, $stamp);
-            break;
-        case 'timestamp':
-        default:
-            return $stamp;
-            break;
+            case 'int':
+                return $default;
+            case 'array':
+                return $this->toArray($stamp);
+                break;
+            case 'object':
+                require_once CALENDAR_ROOT.'Factory.php';
+                return Calendar_Factory::createByTimestamp($returnType,$stamp);
+                break;
+            case 'timestamp':
+            default:
+                return $stamp;
+                break;
         }
     }
@@ -360,7 +310,5 @@
      * Abstract method for building the children of a calendar object.
      * Implemented by Calendar subclasses
-     *
-     * @param array $sDates array containing Calendar objects to select (optional)
-     *
+     * @param array containing Calendar objects to select (optional)
      * @return boolean
      * @access public
@@ -369,6 +317,7 @@
     function build($sDates = array())
     {
-        include_once 'PEAR.php';
-        PEAR::raiseError('Calendar::build is abstract', null, PEAR_ERROR_TRIGGER,
+        require_once 'PEAR.php';
+        PEAR::raiseError(
+            'Calendar::build is abstract', null, PEAR_ERROR_TRIGGER,
             E_USER_NOTICE, 'Calendar::build()');
         return false;
@@ -377,7 +326,5 @@
     /**
      * Abstract method for selected data objects called from build
-     *
-     * @param array $sDates array of Calendar objects to select
-     *
+     * @param array
      * @return boolean
      * @access public
@@ -386,5 +333,5 @@
     function setSelection($sDates)
     {
-        include_once 'PEAR.php';
+        require_once 'PEAR.php';
         PEAR::raiseError(
             'Calendar::setSelection is abstract', null, PEAR_ERROR_TRIGGER,
@@ -398,5 +345,4 @@
      * the collection, returns false and resets the collection for
      * further iteratations.
-     *
      * @return mixed either an object subclass of Calendar or false
      * @access public
@@ -415,5 +361,4 @@
     /**
      * Fetches all child from the current collection of children
-     *
      * @return array
      * @access public
@@ -425,6 +370,6 @@
 
     /**
-     * Get the number Calendar subclass objects stored in the internal collection
-     *
+     * Get the number Calendar subclass objects stored in the internal
+     * collection.
      * @return int
      * @access public
@@ -437,6 +382,6 @@
     /**
      * Determine whether this date is valid, with the bounds determined by
-     * the Calendar_Engine. The call is passed on to Calendar_Validator::isValid
-     *
+     * the Calendar_Engine. The call is passed on to
+     * Calendar_Validator::isValid
      * @return boolean
      * @access public
@@ -450,5 +395,4 @@
     /**
      * Returns an instance of Calendar_Validator
-     *
      * @return Calendar_Validator
      * @access public
@@ -457,6 +401,6 @@
     {
         if (!isset($this->validator)) {
-            include_once CALENDAR_ROOT.'Validator.php';
-            $this->validator = new Calendar_Validator($this);
+            require_once CALENDAR_ROOT.'Validator.php';
+            $this->validator = & new Calendar_Validator($this);
         }
         return $this->validator;
@@ -466,5 +410,4 @@
      * Returns a reference to the current Calendar_Engine being used. Useful
      * for Calendar_Table_Helper and Calendar_Validator
-     *
      * @return object implementing Calendar_Engine_Inteface
      * @access protected
@@ -478,11 +421,9 @@
      * Set the CALENDAR_FIRST_DAY_OF_WEEK constant to the $firstDay value
      * if the constant is not set yet.
-     *
-     * @param integer $firstDay first day of the week (0=sunday, 1=monday, ...)
-     *
-     * @return integer
      * @throws E_USER_WARNING this method throws a WARNING if the
      *    CALENDAR_FIRST_DAY_OF_WEEK constant is already defined and
      *    the $firstDay parameter is set to a different value
+     * @param integer $firstDay first day of the week (0=sunday, 1=monday, ...)
+     * @return integer
      * @access protected
      */
@@ -510,7 +451,5 @@
     /**
      * Returns the value for the previous year
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 2002 or timestamp
      * @access public
@@ -524,7 +463,5 @@
     /**
      * Returns the value for this year
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 2003 or timestamp
      * @access public
@@ -538,7 +475,5 @@
     /**
      * Returns the value for next year
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 2004 or timestamp
      * @access public
@@ -552,7 +487,5 @@
     /**
      * Returns the value for the previous month
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 4 or Unix timestamp
      * @access public
@@ -566,7 +499,5 @@
     /**
      * Returns the value for this month
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 5 or timestamp
      * @access public
@@ -580,7 +511,5 @@
     /**
      * Returns the value for next month
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 6 or timestamp
      * @access public
@@ -594,7 +523,5 @@
     /**
      * Returns the value for the previous day
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 10 or timestamp
      * @access public
@@ -609,7 +536,5 @@
     /**
      * Returns the value for this day
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 11 or timestamp
      * @access public
@@ -624,7 +549,5 @@
     /**
      * Returns the value for the next day
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 12 or timestamp
      * @access public
@@ -639,7 +562,5 @@
     /**
      * Returns the value for the previous hour
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 13 or timestamp
      * @access public
@@ -654,7 +575,5 @@
     /**
      * Returns the value for this hour
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 14 or timestamp
      * @access public
@@ -669,7 +588,5 @@
     /**
      * Returns the value for the next hour
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 14 or timestamp
      * @access public
@@ -684,7 +601,5 @@
     /**
      * Returns the value for the previous minute
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 23 or timestamp
      * @access public
@@ -700,7 +615,5 @@
     /**
      * Returns the value for this minute
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 24 or timestamp
      * @access public
@@ -716,7 +629,5 @@
     /**
     * Returns the value for the next minute
-    *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 25 or timestamp
      * @access public
@@ -732,7 +643,5 @@
     /**
      * Returns the value for the previous second
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 43 or timestamp
      * @access public
@@ -748,7 +657,5 @@
     /**
      * Returns the value for this second
-     *
-    * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-    *
+    * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 44 or timestamp
      * @access public
@@ -764,7 +671,5 @@
     /**
      * Returns the value for the next second
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 45 or timestamp
      * @access public
Index: /branches/version-2_13-dev/data/module/Calendar/Second.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Second.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Second.php	(revision 23141)
@@ -1,38 +1,26 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: Second.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
+//
 /**
- * Contains the Calendar_Second class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Second.php 300728 2010-06-24 11:43:56Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Second.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
  */
 
@@ -54,12 +42,5 @@
  * <b>Note:</b> Seconds do not build other objects
  * so related methods are overridden to return NULL
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
  */
 class Calendar_Second extends Calendar
@@ -67,20 +48,18 @@
     /**
      * Constructs Second
-     *
-     * @param int $y year e.g. 2003
-     * @param int $m month e.g. 5
-     * @param int $d day e.g. 11
-     * @param int $h hour e.g. 13
-     * @param int $i minute e.g. 31
-     * @param int $s second e.g. 45
+     * @param int year e.g. 2003
+     * @param int month e.g. 5
+     * @param int day e.g. 11
+     * @param int hour e.g. 13
+     * @param int minute e.g. 31
+     * @param int second e.g. 45
      */
     function Calendar_Second($y, $m, $d, $h, $i, $s)
     {
-        parent::Calendar($y, $m, $d, $h, $i, $s);
+        Calendar::Calendar($y, $m, $d, $h, $i, $s);
     }
 
     /**
      * Overwrite build
-     *
      * @return NULL
      */
@@ -92,5 +71,4 @@
     /**
      * Overwrite fetch
-     *
      * @return NULL
      */
@@ -102,5 +80,4 @@
     /**
      * Overwrite fetchAll
-     *
      * @return NULL
      */
@@ -112,5 +89,4 @@
     /**
      * Overwrite size
-     *
      * @return NULL
      */
Index: /branches/version-2_13-dev/data/module/Calendar/Hour.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Hour.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Hour.php	(revision 23141)
@@ -1,38 +1,26 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: Hour.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
+//
 /**
- * Contains the Calendar_Hour class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Hour.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Hour.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
  */
 
@@ -54,5 +42,5 @@
  * <code>
  * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Hour.php';
- * $Hour = new Calendar_Hour(2003, 10, 21, 15); // Oct 21st 2003, 3pm
+ * $Hour = & new Calendar_Hour(2003, 10, 21, 15); // Oct 21st 2003, 3pm
  * $Hour->build(); // Build Calendar_Minute objects
  * while ($Minute = & $Hour->fetch()) {
@@ -60,12 +48,6 @@
  * }
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Hour extends Calendar
@@ -73,32 +55,28 @@
     /**
      * Constructs Calendar_Hour
-     *
-     * @param int $y year e.g. 2003
-     * @param int $m month e.g. 5
-     * @param int $d day e.g. 11
-     * @param int $h hour e.g. 13
-     *
+     * @param int year e.g. 2003
+     * @param int month e.g. 5
+     * @param int day e.g. 11
+     * @param int hour e.g. 13
      * @access public
      */
     function Calendar_Hour($y, $m, $d, $h)
     {
-        parent::Calendar($y, $m, $d, $h);
+        Calendar::Calendar($y, $m, $d, $h);
     }
 
-    /**
+   /**
      * Builds the Minutes in the Hour
-     *
-     * @param array $sDates (optional) Calendar_Minute objects representing selected dates
-     *
+     * @param array (optional) Calendar_Minute objects representing selected dates
      * @return boolean
      * @access public
      */
-    function build($sDates = array())
+    function build($sDates=array())
     {
-        include_once CALENDAR_ROOT.'Minute.php';
+        require_once CALENDAR_ROOT.'Minute.php';
         $mIH = $this->cE->getMinutesInHour($this->year, $this->month, $this->day,
                            $this->hour);
         for ($i=0; $i < $mIH; $i++) {
-            $this->children[$i] =
+            $this->children[$i]=
                 new Calendar_Minute($this->year, $this->month, $this->day,
                            $this->hour, $i);
@@ -112,7 +90,5 @@
     /**
      * Called from build()
-     *
-     * @param array $sDates Calendar_Minute objects representing selected dates
-     *
+     * @param array
      * @return void
      * @access private
Index: /branches/version-2_13-dev/data/module/Calendar/Day.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Day.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Day.php	(revision 23141)
@@ -1,38 +1,26 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: Day.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
+//
 /**
- * Contains the Calendar_Day class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Day.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Day.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
  */
 
@@ -53,18 +41,12 @@
  * Represents a Day and builds Hours.
  * <code>
- * require_once 'Calendar/Day.php';
- * $Day = new Calendar_Day(2003, 10, 21); // Oct 21st 2003
+ * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Day.php';
+ * $Day = & new Calendar_Day(2003, 10, 21); // Oct 21st 2003
  * while ($Hour = & $Day->fetch()) {
  *    echo $Hour->thisHour().'<br />';
  * }
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Day extends Calendar
@@ -79,5 +61,5 @@
     /**
      * Marks the Day at the end of a week
-     * @access private
+    * @access private
      * @var boolean
      */
@@ -94,21 +76,17 @@
     /**
      * Constructs Calendar_Day
-     *
-     * @param int $y year e.g. 2003
-     * @param int $m month e.g. 8
-     * @param int $d day e.g. 15
-     *
+     * @param int year e.g. 2003
+     * @param int month e.g. 8
+     * @param int day e.g. 15
      * @access public
      */
     function Calendar_Day($y, $m, $d)
     {
-        parent::Calendar($y, $m, $d);
+        Calendar::Calendar($y, $m, $d);
     }
 
     /**
      * Builds the Hours of the Day
-     *
-     * @param array $sDates (optional) Caledar_Hour objects representing selected dates
-     *
+     * @param array (optional) Caledar_Hour objects representing selected dates
      * @return boolean
      * @access public
@@ -116,9 +94,9 @@
     function build($sDates = array())
     {
-        include_once CALENDAR_ROOT.'Hour.php';
+        require_once CALENDAR_ROOT.'Hour.php';
 
         $hID = $this->cE->getHoursInDay($this->year, $this->month, $this->day);
         for ($i=0; $i < $hID; $i++) {
-            $this->children[$i] =
+            $this->children[$i]=
                 new Calendar_Hour($this->year, $this->month, $this->day, $i);
         }
@@ -131,7 +109,5 @@
     /**
      * Called from build()
-     *
-     * @param array $sDates dates to be selected
-     *
+     * @param array
      * @return void
      * @access private
@@ -156,11 +132,9 @@
      * Defines Day object as first in a week
      * Only used by Calendar_Month_Weekdays::build()
-     *
-     * @param boolean $state set this day as first in week
-     *
+     * @param boolean state
      * @return void
      * @access private
      */
-    function setFirst($state = true)
+    function setFirst ($state = true)
     {
         $this->first = $state;
@@ -170,7 +144,5 @@
      * Defines Day object as last in a week
      * Used only following Calendar_Month_Weekdays::build()
-     *
-     * @param boolean $state set this day as last in week
-     *
+     * @param boolean state
      * @return void
      * @access private
@@ -184,10 +156,8 @@
      * Returns true if Day object is first in a Week
      * Only relevant when Day is created by Calendar_Month_Weekdays::build()
-     *
      * @return boolean
      * @access public
      */
-    function isFirst() 
-    {
+    function isFirst() {
         return $this->first;
     }
@@ -196,5 +166,4 @@
      * Returns true if Day object is last in a Week
      * Only relevant when Day is created by Calendar_Month_Weekdays::build()
-     *
      * @return boolean
      * @access public
@@ -208,7 +177,5 @@
      * Defines Day object as empty
      * Only used by Calendar_Month_Weekdays::build()
-     *
-     * @param boolean $state set this day as empty
-     *
+     * @param boolean state
      * @return void
      * @access private
@@ -220,6 +187,4 @@
 
     /**
-     * Check if this day is empty
-     *
      * @return boolean
      * @access public
Index: /branches/version-2_13-dev/data/module/Calendar/Engine/Interface.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Engine/Interface.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Engine/Interface.php	(revision 23141)
@@ -1,52 +1,31 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: Interface.php,v 1.5 2004/08/16 12:29:18 hfuecks Exp $
+//
 /**
- * Contains the Calendar_Engine_Interface class (interface)
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Interface.php 269074 2008-11-15 21:21:42Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Interface.php,v 1.5 2004/08/16 12:29:18 hfuecks Exp $
  */
-
 /**
  * The methods the classes implementing the Calendar_Engine must implement.
  * Note this class is not used but simply to help development
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
  * @access protected
  */
@@ -58,7 +37,5 @@
      * Typically called "internally" by methods like stampToYear.
      * Return value can vary, depending on the specific implementation
-     *
-     * @param int $stamp timestamp (depending on implementation)
-     *
+     * @param int timestamp (depending on implementation)
      * @return mixed
      * @access protected
@@ -70,7 +47,5 @@
     /**
      * Returns a numeric year given a timestamp
-     *
-     * @param int $stamp timestamp (depending on implementation)
-     *
+     * @param int timestamp (depending on implementation)
      * @return int year (e.g. 2003)
      * @access protected
@@ -82,7 +57,5 @@
     /**
      * Returns a numeric month given a timestamp
-     *
-     * @param int $stamp timestamp (depending on implementation)
-     *
+     * @param int timestamp (depending on implementation)
      * @return int month (e.g. 9)
      * @access protected
@@ -94,7 +67,5 @@
     /**
      * Returns a numeric day given a timestamp
-     *
-     * @param int $stamp timestamp (depending on implementation)
-     *
+     * @param int timestamp (depending on implementation)
      * @return int day (e.g. 15)
      * @access protected
@@ -106,7 +77,5 @@
     /**
      * Returns a numeric hour given a timestamp
-     *
-     * @param int $stamp timestamp (depending on implementation)
-     *
+     * @param int timestamp (depending on implementation)
      * @return int hour (e.g. 13)
      * @access protected
@@ -118,7 +87,5 @@
     /**
      * Returns a numeric minute given a timestamp
-     *
-     * @param int $stamp timestamp (depending on implementation)
-     *
+     * @param int timestamp (depending on implementation)
      * @return int minute (e.g. 34)
      * @access protected
@@ -130,7 +97,5 @@
     /**
      * Returns a numeric second given a timestamp
-     *
-     * @param int $stamp timestamp (depending on implementation)
-     *
+     * @param int timestamp (depending on implementation)
      * @return int second (e.g. 51)
      * @access protected
@@ -141,19 +106,18 @@
 
     /**
-     * Returns a timestamp. Can be worth "caching" generated timestamps in a
-     * static variable, identified by the params this method accepts,
-     * to timestamp will only be calculated once.
-     *
-     * @param int $y year (e.g. 2003)
-     * @param int $m month (e.g. 9)
-     * @param int $d day (e.g. 13)
-     * @param int $h hour (e.g. 13)
-     * @param int $i minute (e.g. 34)
-     * @param int $s second (e.g. 53)
-     *
+     * Returns a timestamp. Can be worth "caching" generated
+     * timestamps in a static variable, identified by the
+     * params this method accepts, to timestamp will only
+     * be calculated once.
+     * @param int year (e.g. 2003)
+     * @param int month (e.g. 9)
+     * @param int day (e.g. 13)
+     * @param int hour (e.g. 13)
+     * @param int minute (e.g. 34)
+     * @param int second (e.g. 53)
      * @return int (depends on implementation)
      * @access protected
      */
-    function dateToStamp($y, $m, $d, $h, $i, $s)
+    function dateToStamp($y,$m,$d,$h,$i,$s)
     {
     }
@@ -161,5 +125,4 @@
     /**
      * The upper limit on years that the Calendar Engine can work with
-     *
      * @return int (e.g. 2037)
      * @access protected
@@ -171,5 +134,4 @@
     /**
      * The lower limit on years that the Calendar Engine can work with
-     *
      * @return int (e.g 1902)
      * @access protected
@@ -181,7 +143,5 @@
     /**
      * Returns the number of months in a year
-     *
-     * @param int $y (optional) year to get months for
-     *
+     * @param int (optional) year to get months for
      * @return int (e.g. 12)
      * @access protected
@@ -193,8 +153,6 @@
     /**
      * Returns the number of days in a month, given year and month
-     *
-     * @param int $y year (e.g. 2003)
-     * @param int $m month (e.g. 9)
-     *
+     * @param int year (e.g. 2003)
+     * @param int month (e.g. 9)
      * @return int days in month
      * @access protected
@@ -207,8 +165,6 @@
      * Returns numeric representation of the day of the week in a month,
      * given year and month
-     *
-     * @param int $y year (e.g. 2003)
-     * @param int $m month (e.g. 9)
-     *
+     * @param int year (e.g. 2003)
+     * @param int month (e.g. 9)
      * @return int
      * @access protected
@@ -220,13 +176,11 @@
     /**
      * Returns the number of days in a week
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int (e.g. 7)
      * @access protected
      */
-    function getDaysInWeek($y=null, $m=null, $d=null)
+    function getDaysInWeek($y=NULL, $m=NULL, $d=NULL)
     {
     }
@@ -234,9 +188,7 @@
     /**
      * Returns the number of the week in the year (ISO-8601), given a date
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int week number
      * @access protected
@@ -248,10 +200,8 @@
     /**
      * Returns the number of the week in the month, given a date
-     *
-     * @param int $y        year (2003)
-     * @param int $m        month (9)
-     * @param int $d        day (4)
-     * @param int $firstDay first day of the week (default: 1 - monday)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
+     * @param int first day of the week (default: 1 - monday)
      * @return int week number
      * @access protected
@@ -263,8 +213,7 @@
     /**
      * Returns the number of weeks in the month
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int first day of the week (default: 1 - monday)
      * @return int weeks number
      * @access protected
@@ -276,9 +225,7 @@
     /**
      * Returns the number of the day of the week (0=sunday, 1=monday...)
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int weekday number
      * @access protected
@@ -290,13 +237,11 @@
     /**
      * Returns the numeric values of the days of the week.
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return array list of numeric values of days in week, beginning 0
      * @access protected
      */
-    function getWeekDays($y=null, $m=null, $d=null)
+    function getWeekDays($y=NULL, $m=NULL, $d=NULL)
     {
     }
@@ -305,24 +250,18 @@
      * Returns the default first day of the week as an integer. Must be a
      * member of the array returned from getWeekDays
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int (e.g. 1 for Monday)
      * @see getWeekDays
      * @access protected
      */
-    function getFirstDayOfWeek($y=null, $m=null, $d=null)
-    {
-    }
-
-    /**
-     * Returns the number of hours in a day
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+    function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL)
+    {
+    }
+
+    /**
+     * Returns the number of hours in a day<br>
+     * @param int (optional) day to get hours for
      * @return int (e.g. 24)
      * @access protected
@@ -334,10 +273,5 @@
     /**
      * Returns the number of minutes in an hour
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     * @param int $h hour
-     *
+     * @param int (optional) hour to get minutes for
      * @return int
      * @access protected
@@ -349,27 +283,9 @@
     /**
      * Returns the number of seconds in a minutes
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     * @param int $h hour
-     * @param int $i minute
-     *
+     * @param int (optional) minute to get seconds for
      * @return int
      * @access protected
      */
     function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null)
-    {
-    }
-
-    /**
-     * Checks if the given day is the current day
-     *
-     * @param int timestamp (depending on implementation)
-     *
-     * @return boolean
-     * @access protected
-     */
-    function isToday($stamp)
     {
     }
Index: /branches/version-2_13-dev/data/module/Calendar/Engine/PearDate.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Engine/PearDate.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Engine/PearDate.php	(revision 23141)
@@ -1,40 +1,27 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Lorenzo Alberton <l dot alberton at quipo dot it>           |
+// +----------------------------------------------------------------------+
+//
+// $Id: PearDate.php,v 1.8 2004/08/20 20:00:55 quipo Exp $
+//
 /**
- * Contains the Calendar_Engine_PearDate class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: PearDate.php 269076 2008-11-15 21:41:38Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: PearDate.php,v 1.8 2004/08/20 20:00:55 quipo Exp $
  */
-
 /**
  * Load PEAR::Date class
@@ -45,11 +32,5 @@
  * Performs calendar calculations based on the PEAR::Date class
  * Timestamps are in the ISO-8601 format (YYYY-MM-DD HH:MM:SS)
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
  * @access protected
  */
@@ -60,7 +41,5 @@
      * Uses a static variable to prevent date() being used twice
      * for a date which is already known
-     *
-     * @param mixed $stamp Any timestamp format recognized by Pear::Date
-     *
+     * @param mixed Any timestamp format recognized by Pear::Date
      * @return object Pear::Date object
      * @access protected
@@ -77,7 +56,5 @@
     /**
      * Returns a numeric year given a iso-8601 datetime
-     *
-     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
-     *
+     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
      * @return int year (e.g. 2003)
      * @access protected
@@ -91,7 +68,5 @@
     /**
      * Returns a numeric month given a iso-8601 datetime
-     *
-     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
-     *
+     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
      * @return int month (e.g. 9)
      * @access protected
@@ -105,7 +80,5 @@
     /**
      * Returns a numeric day given a iso-8601 datetime
-     *
-     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
-     *
+     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
      * @return int day (e.g. 15)
      * @access protected
@@ -119,7 +92,5 @@
     /**
      * Returns a numeric hour given a iso-8601 datetime
-     *
-     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
-     *
+     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
      * @return int hour (e.g. 13)
      * @access protected
@@ -133,7 +104,5 @@
     /**
      * Returns a numeric minute given a iso-8601 datetime
-     *
-     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
-     *
+     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
      * @return int minute (e.g. 34)
      * @access protected
@@ -147,7 +116,5 @@
     /**
      * Returns a numeric second given a iso-8601 datetime
-     *
-     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
-     *
+     * @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
      * @return int second (e.g. 51)
      * @access protected
@@ -161,12 +128,10 @@
     /**
      * Returns a iso-8601 datetime
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (13)
-     * @param int $h hour (13)
-     * @param int $i minute (34)
-     * @param int $s second (53)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (13)
+     * @param int hour (13)
+     * @param int minute (34)
+     * @param int second (53)
      * @return string iso-8601 datetime
      * @access protected
@@ -186,13 +151,10 @@
     /**
      * Set the correct date values (useful for math operations on dates)
-     *
-     * @param int &$y year   (2003)
-     * @param int &$m month  (9)
-     * @param int &$d day    (13)
-     * @param int &$h hour   (13)
-     * @param int &$i minute (34)
-     * @param int &$s second (53)
-     *
-     * @return void
+     * @param int year   (2003)
+     * @param int month  (9)
+     * @param int day    (13)
+     * @param int hour   (13)
+     * @param int minute (34)
+     * @param int second (53)
      * @access protected
      */
@@ -248,5 +210,4 @@
     /**
      * The upper limit on years that the Calendar Engine can work with
-     *
      * @return int 9999
      * @access protected
@@ -259,5 +220,4 @@
     /**
      * The lower limit on years that the Calendar Engine can work with
-     *
      * @return int 0
      * @access protected
@@ -270,7 +230,4 @@
     /**
      * Returns the number of months in a year
-     *
-     * @param int $y year
-     *
      * @return int (12)
      * @access protected
@@ -283,8 +240,6 @@
     /**
      * Returns the number of days in a month, given year and month
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     *
+     * @param int year (2003)
+     * @param int month (9)
      * @return int days in month
      * @access protected
@@ -298,8 +253,6 @@
      * Returns numeric representation of the day of the week in a month,
      * given year and month
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     *
+     * @param int year (2003)
+     * @param int month (9)
      * @return int from 0 to 7
      * @access protected
@@ -312,13 +265,11 @@
     /**
      * Returns the number of days in a week
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int (7)
      * @access protected
      */
-    function getDaysInWeek($y=null, $m=null, $d=null)
+    function getDaysInWeek($y=NULL, $m=NULL, $d=NULL)
     {
         return 7;
@@ -327,9 +278,7 @@
     /**
      * Returns the number of the week in the year (ISO-8601), given a date
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int week number
      * @access protected
@@ -337,17 +286,13 @@
     function getWeekNInYear($y, $m, $d)
     {
-        //return Date_Calc::weekOfYear($d, $m, $y); //beware, Date_Calc doesn't follow ISO-8601 standard!
-        list($nYear, $nWeek) = Date_Calc::weekOfYear4th($d, $m, $y);
-        return $nWeek;
+        return Date_Calc::weekOfYear($d, $m, $y); //beware, Date_Calc doesn't follow ISO-8601 standard!
     }
 
     /**
      * Returns the number of the week in the month, given a date
-     *
-     * @param int $y        year (2003)
-     * @param int $m        month (9)
-     * @param int $d        day (4)
-     * @param int $firstDay first day of the week (default: monday)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
+     * @param int first day of the week (default: monday)
      * @return int week number
      * @access protected
@@ -367,9 +312,7 @@
     /**
      * Returns the number of weeks in the month
-     *
-     * @param int $y        year (2003)
-     * @param int $m        month (9)
-     * @param int $firstDay first day of the week (default: monday)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int first day of the week (default: monday)
      * @return int weeks number
      * @access protected
@@ -395,9 +338,7 @@
     /**
      * Returns the number of the day of the week (0=sunday, 1=monday...)
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int weekday number
      * @access protected
@@ -410,13 +351,11 @@
     /**
      * Returns a list of integer days of the week beginning 0
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return array (0, 1, 2, 3, 4, 5, 6) 1 = Monday
      * @access protected
      */
-    function getWeekDays($y=null, $m=null, $d=null)
+    function getWeekDays($y=NULL, $m=NULL, $d=NULL)
     {
         return array(0, 1, 2, 3, 4, 5, 6);
@@ -425,13 +364,11 @@
     /**
      * Returns the default first day of the week
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int (default 1 = Monday)
      * @access protected
      */
-    function getFirstDayOfWeek($y=null, $m=null, $d=null)
+    function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL)
     {
         return 1;
@@ -440,9 +377,4 @@
     /**
      * Returns the number of hours in a day
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
      * @return int (24)
      * @access protected
@@ -455,10 +387,4 @@
     /**
      * Returns the number of minutes in an hour
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     * @param int $h hour
-     *
      * @return int (60)
      * @access protected
@@ -471,11 +397,4 @@
     /**
      * Returns the number of seconds in a minutes
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     * @param int $h hour
-     * @param int $i minute
-     *
      * @return int (60)
      * @access protected
@@ -484,25 +403,4 @@
     {
         return 60;
-    }
-
-    /**
-     * Checks if the given day is the current day
-     *
-     * @param mixed $stamp Any timestamp format recognized by Pear::Date
-     *
-     * @return boolean
-     * @access protected
-     */
-    function isToday($stamp)
-    {
-        static $today = null;
-        if (is_null($today)) {
-            $today = new Date();
-        }
-        $date = Calendar_Engine_PearDate::stampCollection($stamp);
-        return (   $date->day == $today->getDay()
-                && $date->month == $today->getMonth()
-                && $date->year == $today->getYear()
-        );
     }
 }
Index: /branches/version-2_13-dev/data/module/Calendar/Engine/UnixTS.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Engine/UnixTS.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Engine/UnixTS.php	(revision 23141)
@@ -1,51 +1,32 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: UnixTS.php,v 1.9 2004/08/20 20:00:55 quipo Exp $
+//
 /**
- * Contains the Calendar_Engine_UnixTS class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: UnixTS.php 269074 2008-11-15 21:21:42Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: UnixTS.php,v 1.9 2004/08/20 20:00:55 quipo Exp $
  */
-
 /**
  * Performs calendar calculations based on the PHP date() function and
  * Unix timestamps (using PHP's mktime() function).
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    protected
+ * @package Calendar
+ * @access protected
  */
 class Calendar_Engine_UnixTS /* implements Calendar_Engine_Interface */
@@ -68,7 +49,5 @@
      * Uses a static variable to prevent date() being used twice
      * for a date which is already known
-     *
-     * @param int $stamp Unix timestamp
-     *
+     * @param int Unix timestamp
      * @return array
      * @access protected
@@ -78,5 +57,5 @@
         static $stamps = array();
         if ( !isset($stamps[$stamp]) ) {
-            $date = @date('Y n j H i s t W w', $stamp);
+            $date = @date('Y n j H i s t W w',$stamp);
             $stamps[$stamp] = sscanf($date, "%d %d %d %d %d %d %d %d %d");
         }
@@ -86,7 +65,5 @@
     /**
      * Returns a numeric year given a timestamp
-     *
-     * @param int $stamp Unix timestamp
-     *
+     * @param int Unix timestamp
      * @return int year (e.g. 2003)
      * @access protected
@@ -100,7 +77,5 @@
     /**
      * Returns a numeric month given a timestamp
-     *
-     * @param int $stamp Unix timestamp
-     *
+     * @param int Unix timestamp
      * @return int month (e.g. 9)
      * @access protected
@@ -114,7 +89,5 @@
     /**
      * Returns a numeric day given a timestamp
-     *
-     * @param int $stamp Unix timestamp
-     *
+     * @param int Unix timestamp
      * @return int day (e.g. 15)
      * @access protected
@@ -128,7 +101,5 @@
     /**
      * Returns a numeric hour given a timestamp
-     *
-     * @param int $stamp Unix timestamp
-     *
+     * @param int Unix timestamp
      * @return int hour (e.g. 13)
      * @access protected
@@ -142,7 +113,5 @@
     /**
      * Returns a numeric minute given a timestamp
-     *
-     * @param int $stamp Unix timestamp
-     *
+     * @param int Unix timestamp
      * @return int minute (e.g. 34)
      * @access protected
@@ -156,7 +125,5 @@
     /**
      * Returns a numeric second given a timestamp
-     *
-     * @param int $stamp Unix timestamp
-     *
+     * @param int Unix timestamp
      * @return int second (e.g. 51)
      * @access protected
@@ -170,12 +137,10 @@
     /**
      * Returns a timestamp
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (13)
-     * @param int $h hour (13)
-     * @param int $i minute (34)
-     * @param int $s second (53)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (13)
+     * @param int hour (13)
+     * @param int minute (34)
+     * @param int second (53)
      * @return int Unix timestamp
      * @access protected
@@ -184,5 +149,5 @@
     {
         static $dates = array();
-        if (!isset($dates[$y][$m][$d][$h][$i][$s])) {
+        if ( !isset($dates[$y][$m][$d][$h][$i][$s]) ) {
             $dates[$y][$m][$d][$h][$i][$s] = @mktime($h, $i, $s, $m, $d, $y);
         }
@@ -192,5 +157,4 @@
     /**
      * The upper limit on years that the Calendar Engine can work with
-     *
      * @return int (2037)
      * @access protected
@@ -203,5 +167,4 @@
     /**
      * The lower limit on years that the Calendar Engine can work with
-     *
      * @return int (1970 if it's Windows and 1902 for all other OSs)
      * @access protected
@@ -214,9 +177,6 @@
     /**
      * Returns the number of months in a year
-     *
-     * @param int $y year
-     *
      * @return int (12)
-     * @access protected
+    * @access protected
      */
     function getMonthsInYear($y=null)
@@ -227,8 +187,6 @@
     /**
      * Returns the number of days in a month, given year and month
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     *
+     * @param int year (2003)
+     * @param int month (9)
      * @return int days in month
      * @access protected
@@ -236,6 +194,6 @@
     function getDaysInMonth($y, $m)
     {
-        $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, 1);
-        $date  = Calendar_Engine_UnixTS::stampCollection($stamp);
+        $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,1);
+        $date = Calendar_Engine_UnixTS::stampCollection($stamp);
         return $date[6];
     }
@@ -244,8 +202,6 @@
      * Returns numeric representation of the day of the week in a month,
      * given year and month
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     *
+     * @param int year (2003)
+     * @param int month (9)
      * @return int from 0 to 6
      * @access protected
@@ -253,6 +209,6 @@
     function getFirstDayInMonth($y, $m)
     {
-        $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, 1);
-        $date  = Calendar_Engine_UnixTS::stampCollection($stamp);
+        $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,1);
+        $date = Calendar_Engine_UnixTS::stampCollection($stamp);
         return $date[8];
     }
@@ -260,13 +216,11 @@
     /**
      * Returns the number of days in a week
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int (7)
      * @access protected
      */
-    function getDaysInWeek($y=null, $m=null, $d=null)
+    function getDaysInWeek($y=NULL, $m=NULL, $d=NULL)
     {
         return 7;
@@ -275,9 +229,7 @@
     /**
      * Returns the number of the week in the year (ISO-8601), given a date
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int week number
      * @access protected
@@ -285,6 +237,6 @@
     function getWeekNInYear($y, $m, $d)
     {
-        $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, $d);
-        $date  = Calendar_Engine_UnixTS::stampCollection($stamp);
+        $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,$d);
+        $date = Calendar_Engine_UnixTS::stampCollection($stamp);
         return $date[7];
     }
@@ -292,10 +244,8 @@
     /**
      * Returns the number of the week in the month, given a date
-     *
-     * @param int $y        year (2003)
-     * @param int $m        month (9)
-     * @param int $d        day (4)
-     * @param int $firstDay first day of the week (default: monday)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
+     * @param int first day of the week (default: monday)
      * @return int week number
      * @access protected
@@ -303,5 +253,5 @@
     function getWeekNInMonth($y, $m, $d, $firstDay=1)
     {
-        $weekEnd = (0 == $firstDay) ? $this->getDaysInWeek()-1 : $firstDay-1;
+        $weekEnd = ($firstDay == 0) ? $this->getDaysInWeek()-1 : $firstDay-1;
         $end_of_week = 1;
         while (@date('w', @mktime(0, 0, 0, $m, $end_of_week, $y)) != $weekEnd) {
@@ -318,13 +268,11 @@
     /**
      * Returns the number of weeks in the month
-     *
-     * @param int $y        year (2003)
-     * @param int $m        month (9)
-     * @param int $firstDay first day of the week (default: monday)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int first day of the week (default: monday)
      * @return int weeks number
      * @access protected
      */
-    function getWeeksInMonth($y, $m, $firstDay = 1)
+    function getWeeksInMonth($y, $m, $firstDay=1)
     {
         $FDOM = $this->getFirstDayInMonth($y, $m);
@@ -346,9 +294,7 @@
     /**
      * Returns the number of the day of the week (0=sunday, 1=monday...)
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int weekday number
      * @access protected
@@ -356,5 +302,5 @@
     function getDayOfWeek($y, $m, $d)
     {
-        $stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, $d);
+        $stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,$d);
         $date = Calendar_Engine_UnixTS::stampCollection($stamp);
         return $date[8];
@@ -363,13 +309,11 @@
     /**
      * Returns a list of integer days of the week beginning 0
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return array (0,1,2,3,4,5,6) 1 = Monday
      * @access protected
      */
-    function getWeekDays($y=null, $m=null, $d=null)
+    function getWeekDays($y=NULL, $m=NULL, $d=NULL)
     {
         return array(0, 1, 2, 3, 4, 5, 6);
@@ -378,13 +322,11 @@
     /**
      * Returns the default first day of the week
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
+     * @param int year (2003)
+     * @param int month (9)
+     * @param int day (4)
      * @return int (default 1 = Monday)
      * @access protected
      */
-    function getFirstDayOfWeek($y=null, $m=null, $d=null)
+    function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL)
     {
         return 1;
@@ -393,13 +335,8 @@
     /**
      * Returns the number of hours in a day
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     *
      * @return int (24)
      * @access protected
      */
-    function getHoursInDay($y=null, $m=null, $d=null)
+    function getHoursInDay($y=null,$m=null,$d=null)
     {
         return 24;
@@ -408,14 +345,8 @@
     /**
      * Returns the number of minutes in an hour
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     * @param int $h hour
-     *
      * @return int (60)
      * @access protected
      */
-    function getMinutesInHour($y=null, $m=null, $d=null, $h=null)
+    function getMinutesInHour($y=null,$m=null,$d=null,$h=null)
     {
         return 60;
@@ -424,39 +355,10 @@
     /**
      * Returns the number of seconds in a minutes
-     *
-     * @param int $y year (2003)
-     * @param int $m month (9)
-     * @param int $d day (4)
-     * @param int $h hour
-     * @param int $i minute
-     *
      * @return int (60)
      * @access protected
      */
-    function getSecondsInMinute($y=null, $m=null, $d=null, $h=null, $i=null)
+    function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null)
     {
         return 60;
-    }
-
-    /**
-     * Checks if the given day is the current day
-     *
-     * @param mixed $stamp Any timestamp format recognized by Pear::Date
-     *
-     * @return boolean
-     * @access protected
-     */
-    function isToday($stamp)
-    {
-        static $today = null;
-        if (is_null($today)) {
-            $today_date = @date('Y n j');
-            $today = sscanf($today_date, '%d %d %d');
-        }
-        $date = Calendar_Engine_UnixTS::stampCollection($stamp);
-        return (   $date[2] == $today[2]
-                && $date[1] == $today[1]
-                && $date[0] == $today[0]
-        );
     }
 }
Index: /branches/version-2_13-dev/data/module/Calendar/Decorator.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Decorator.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Decorator.php	(revision 23141)
@@ -1,40 +1,27 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: Decorator.php,v 1.3 2005/10/22 10:29:46 quipo Exp $
+//
 /**
- * Contains the Calendar_Decorator class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Decorator.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Decorator.php,v 1.3 2005/10/22 10:29:46 quipo Exp $
  */
-
 /**
  * Decorates any calendar class.
@@ -50,16 +37,10 @@
  *     }
  * }
- * $Day = new Calendar_Day(2003, 10, 25);
- * $DayDecorator = new DayDecorator($Day);
+ * $Day = & new Calendar_Day(2003, 10, 25);
+ * $DayDecorator = & new DayDecorator($Day);
  * echo $DayDecorator->thisDay(); // Outputs "Sat"
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
  * @abstract
+ * @package Calendar
  */
 class Calendar_Decorator
@@ -74,8 +55,7 @@
     /**
      * Constructs the Calendar_Decorator
-     *
-     * @param object &$calendar subclass to Calendar to decorate
-     */
-    function Calendar_Decorator(&$calendar)
+     * @param object subclass to Calendar to decorate
+     */
+    function Calendar_Decorator(& $calendar)
     {
         $this->calendar = & $calendar;
@@ -85,7 +65,5 @@
      * Defines the calendar by a Unix timestamp, replacing values
      * passed to the constructor
-     *
-     * @param int $ts Unix timestamp
-     *
+     * @param int Unix timestamp
      * @return void
      * @access public
@@ -99,6 +77,5 @@
      * Returns a timestamp from the current date / time values. Format of
      * timestamp depends on Calendar_Engine implementation being used
-     *
-     * @return int $ts timestamp
+     * @return int timestamp
      * @access public
      */
@@ -110,7 +87,5 @@
     /**
      * Defines calendar object as selected (e.g. for today)
-     *
-     * @param boolean $state whether Calendar subclass must be selected
-     *
+     * @param boolean state whether Calendar subclass
      * @return void
      * @access public
@@ -123,5 +98,4 @@
     /**
      * True if the calendar subclass object is selected (e.g. today)
-     *
      * @return boolean
      * @access public
@@ -134,5 +108,4 @@
     /**
      * Adjusts the date (helper method)
-     *
      * @return void
      * @access public
@@ -145,11 +118,9 @@
     /**
      * Returns the date as an associative array (helper method)
-     *
-     * @param mixed $stamp timestamp (leave empty for current timestamp)
-     *
+     * @param mixed timestamp (leave empty for current timestamp)
      * @return array
      * @access public
      */
-    function toArray($stamp = null)
+    function toArray($stamp=null)
     {
         return $this->calendar->toArray($stamp);
@@ -158,10 +129,8 @@
     /**
      * Returns the value as an associative array (helper method)
-     *
-     * @param string  $returnType type of date object that return value represents
-     * @param string  $format     ['int'|'timestamp'|'object'|'array']
-     * @param mixed   $stamp      timestamp (depending on Calendar engine being used)
-     * @param integer $default    default value (i.e. give me the answer quick)
-     *
+     * @param string type of date object that return value represents
+     * @param string $format ['int' | 'array' | 'timestamp' | 'object']
+     * @param mixed timestamp (depending on Calendar engine being used)
+     * @param int integer default value (i.e. give me the answer quick)
      * @return mixed
      * @access private
@@ -175,13 +144,11 @@
      * Defines Day object as first in a week
      * Only used by Calendar_Month_Weekdays::build()
-     *
-     * @param boolean $state whether it's first or not
-     *
+     * @param boolean state
      * @return void
      * @access private
      */
-    function setFirst($state = true)
-    {
-        if (method_exists($this->calendar, 'setFirst')) {
+    function setFirst ($state = true)
+    {
+        if ( method_exists($this->calendar,'setFirst') ) {
             $this->calendar->setFirst($state);
         }
@@ -191,7 +158,5 @@
      * Defines Day object as last in a week
      * Used only following Calendar_Month_Weekdays::build()
-     *
-     * @param boolean $state whether it's last or not
-     *
+     * @param boolean state
      * @return void
      * @access private
@@ -199,5 +164,5 @@
     function setLast($state = true)
     {
-        if (method_exists($this->calendar, 'setLast')) {
+        if ( method_exists($this->calendar,'setLast') ) {
             $this->calendar->setLast($state);
         }
@@ -207,11 +172,9 @@
      * Returns true if Day object is first in a Week
      * Only relevant when Day is created by Calendar_Month_Weekdays::build()
-     *
      * @return boolean
      * @access public
      */
-    function isFirst()
-    {
-        if (method_exists($this->calendar, 'isFirst')) {
+    function isFirst() {
+        if ( method_exists($this->calendar,'isFirst') ) {
             return $this->calendar->isFirst();
         }
@@ -221,5 +184,4 @@
      * Returns true if Day object is last in a Week
      * Only relevant when Day is created by Calendar_Month_Weekdays::build()
-     *
      * @return boolean
      * @access public
@@ -227,5 +189,5 @@
     function isLast()
     {
-        if (method_exists($this->calendar, 'isLast')) {
+        if ( method_exists($this->calendar,'isLast') ) {
             return $this->calendar->isLast();
         }
@@ -235,7 +197,5 @@
      * Defines Day object as empty
      * Only used by Calendar_Month_Weekdays::build()
-     *
-     * @param boolean $state whether it's empty or not
-     *
+     * @param boolean state
      * @return void
      * @access private
@@ -243,5 +203,5 @@
     function setEmpty ($state = true)
     {
-        if (method_exists($this->calendar, 'setEmpty')) {
+        if ( method_exists($this->calendar,'setEmpty') ) {
             $this->calendar->setEmpty($state);
         }
@@ -249,6 +209,4 @@
 
     /**
-     * Check if the current object is empty
-     *
      * @return boolean
      * @access public
@@ -256,5 +214,5 @@
     function isEmpty()
     {
-        if (method_exists($this->calendar, 'isEmpty')) {
+        if ( method_exists($this->calendar,'isEmpty') ) {
             return $this->calendar->isEmpty();
         }
@@ -263,7 +221,5 @@
     /**
      * Build the children
-     *
-     * @param array $sDates array containing Calendar objects to select (optional)
-     *
+     * @param array containing Calendar objects to select (optional)
      * @return boolean
      * @access public
@@ -280,5 +236,4 @@
      * the collection, returns false and resets the collection for
      * further iteratations.
-     *
      * @return mixed either an object subclass of Calendar or false
      * @access public
@@ -291,5 +246,4 @@
     /**
      * Fetches all child from the current collection of children
-     *
      * @return array
      * @access public
@@ -301,6 +255,6 @@
 
     /**
-     * Get the number Calendar subclass objects stored in the internal collection
-     *
+     * Get the number Calendar subclass objects stored in the internal
+     * collection.
      * @return int
      * @access public
@@ -313,6 +267,6 @@
     /**
      * Determine whether this date is valid, with the bounds determined by
-     * the Calendar_Engine. The call is passed on to Calendar_Validator::isValid
-     *
+     * the Calendar_Engine. The call is passed on to
+     * Calendar_Validator::isValid
      * @return boolean
      * @access public
@@ -325,5 +279,4 @@
     /**
      * Returns an instance of Calendar_Validator
-     *
      * @return Calendar_Validator
      * @access public
@@ -338,5 +291,4 @@
      * Returns a reference to the current Calendar_Engine being used. Useful
      * for Calendar_Table_Helper and Calendar_Validator
-     *
      * @return object implementing Calendar_Engine_Inteface
      * @access private
@@ -344,13 +296,10 @@
     function & getEngine()
     {
-        $engine = $this->calendar->getEngine();
-        return $engine;
+        return $this->calendar->getEngine();
     }
 
     /**
      * Returns the value for the previous year
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 2002 or timestamp
      * @access public
@@ -363,7 +312,5 @@
     /**
      * Returns the value for this year
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 2003 or timestamp
      * @access public
@@ -376,7 +323,5 @@
     /**
      * Returns the value for next year
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 2004 or timestamp
      * @access public
@@ -389,7 +334,5 @@
     /**
      * Returns the value for the previous month
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 4 or Unix timestamp
      * @access public
@@ -402,7 +345,5 @@
     /**
      * Returns the value for this month
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 5 or timestamp
      * @access public
@@ -415,7 +356,5 @@
     /**
      * Returns the value for next month
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 6 or timestamp
      * @access public
@@ -428,7 +367,5 @@
     /**
      * Returns the value for the previous week
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 4 or Unix timestamp
      * @access public
@@ -436,8 +373,8 @@
     function prevWeek($format = 'n_in_month')
     {
-        if ( method_exists($this->calendar, 'prevWeek')) {
+        if ( method_exists($this->calendar,'prevWeek') ) {
             return $this->calendar->prevWeek($format);
         } else {
-            include_once 'PEAR.php';
+            require_once 'PEAR.php';
             PEAR::raiseError(
                 'Cannot call prevWeek on Calendar object of type: '.
@@ -450,7 +387,5 @@
     /**
      * Returns the value for this week
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 5 or timestamp
      * @access public
@@ -458,8 +393,8 @@
     function thisWeek($format = 'n_in_month')
     {
-        if ( method_exists($this->calendar, 'thisWeek')) {
+        if ( method_exists($this->calendar,'thisWeek') ) {
             return $this->calendar->thisWeek($format);
         } else {
-            include_once 'PEAR.php';
+            require_once 'PEAR.php';
             PEAR::raiseError(
                 'Cannot call thisWeek on Calendar object of type: '.
@@ -472,7 +407,5 @@
     /**
      * Returns the value for next week
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 6 or timestamp
      * @access public
@@ -480,8 +413,8 @@
     function nextWeek($format = 'n_in_month')
     {
-        if ( method_exists($this->calendar, 'nextWeek')) {
+        if ( method_exists($this->calendar,'nextWeek') ) {
             return $this->calendar->nextWeek($format);
         } else {
-            include_once 'PEAR.php';
+            require_once 'PEAR.php';
             PEAR::raiseError(
                 'Cannot call thisWeek on Calendar object of type: '.
@@ -494,12 +427,9 @@
     /**
      * Returns the value for the previous day
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 10 or timestamp
      * @access public
      */
-    function prevDay($format = 'int')
-    {
+    function prevDay($format = 'int') {
         return $this->calendar->prevDay($format);
     }
@@ -507,7 +437,5 @@
     /**
      * Returns the value for this day
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 11 or timestamp
      * @access public
@@ -520,7 +448,5 @@
     /**
      * Returns the value for the next day
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 12 or timestamp
      * @access public
@@ -533,7 +459,5 @@
     /**
      * Returns the value for the previous hour
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 13 or timestamp
      * @access public
@@ -546,7 +470,5 @@
     /**
      * Returns the value for this hour
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 14 or timestamp
      * @access public
@@ -559,7 +481,5 @@
     /**
      * Returns the value for the next hour
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 14 or timestamp
      * @access public
@@ -572,7 +492,5 @@
     /**
      * Returns the value for the previous minute
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 23 or timestamp
      * @access public
@@ -585,7 +503,5 @@
     /**
      * Returns the value for this minute
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 24 or timestamp
      * @access public
@@ -598,11 +514,9 @@
     /**
      * Returns the value for the next minute
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 25 or timestamp
      * @access public
      */
-    function nextMinute($format = 'int')
+   function nextMinute($format = 'int')
     {
         return $this->calendar->nextMinute($format);
@@ -611,7 +525,5 @@
     /**
      * Returns the value for the previous second
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 43 or timestamp
      * @access public
@@ -624,7 +536,5 @@
     /**
      * Returns the value for this second
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 44 or timestamp
      * @access public
@@ -637,7 +547,5 @@
     /**
      * Returns the value for the next second
-     *
-     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
-     *
+     * @param string return value format ['int' | 'timestamp' | 'object' | 'array']
      * @return int e.g. 45 or timestamp
      * @access public
Index: /branches/version-2_13-dev/data/module/Calendar/Month.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Month.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Month.php	(revision 23141)
@@ -1,38 +1,26 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: Month.php,v 1.3 2005/10/22 10:10:26 quipo Exp $
+//
 /**
- * Contains the Calendar_Month class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Month.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Month.php,v 1.3 2005/10/22 10:10:26 quipo Exp $
  */
 
@@ -54,5 +42,5 @@
  * <code>
  * require_once 'Calendar/Month.php';
- * $Month = new Calendar_Month(2003, 10); // Oct 2003
+ * $Month = & new Calendar_Month(2003, 10); // Oct 2003
  * $Month->build(); // Build Calendar_Day objects
  * while ($Day = & $Month->fetch()) {
@@ -60,12 +48,6 @@
  * }
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Month extends Calendar
@@ -73,14 +55,12 @@
     /**
      * Constructs Calendar_Month
-     *
-     * @param int $y        year e.g. 2003
-     * @param int $m        month e.g. 5
+     * @param int $y year e.g. 2003
+     * @param int $m month e.g. 5
      * @param int $firstDay first day of the week [optional]
-     *
      * @access public
      */
     function Calendar_Month($y, $m, $firstDay=null)
     {
-        parent::Calendar($y, $m);
+        Calendar::Calendar($y, $m);
         $this->firstDay = $this->defineFirstDayOfWeek($firstDay);
     }
@@ -89,13 +69,11 @@
      * Builds Day objects for this Month. Creates as many Calendar_Day objects
      * as there are days in the month
-     *
-     * @param array $sDates (optional) Calendar_Day objects representing selected dates
-     *
+     * @param array (optional) Calendar_Day objects representing selected dates
      * @return boolean
      * @access public
      */
-    function build($sDates = array())
+    function build($sDates=array())
     {
-        include_once CALENDAR_ROOT.'Day.php';
+        require_once CALENDAR_ROOT.'Day.php';
         $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month);
         for ($i=1; $i<=$daysInMonth; $i++) {
@@ -110,7 +88,5 @@
     /**
      * Called from build()
-     *
-     * @param array $sDates Calendar_Day objects representing selected dates
-     *
+     * @param array
      * @return void
      * @access private
Index: /branches/version-2_13-dev/data/module/Calendar/Validator.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Validator.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Validator.php	(revision 23141)
@@ -1,38 +1,26 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// +----------------------------------------------------------------------+
+//
+// $Id: Validator.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
+//
 /**
- * Contains the Calendar_Validator class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Validator.php 247251 2007-11-28 19:42:33Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Validator.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
  */
 
@@ -50,13 +38,7 @@
  * Used to validate any given Calendar date object. Instances of this class
  * can be obtained from any data object using the getValidator method
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @see       Calendar::getValidator()
- * @access    public
+ * @see Calendar::getValidator()
+ * @package Calendar
+ * @access public
  */
 class Calendar_Validator
@@ -85,18 +67,15 @@
     /**
      * Constructs Calendar_Validator
-     *
-     * @param object &$calendar subclass of Calendar
-     *
-     * @access public
-     */
-    function Calendar_Validator(&$calendar)
+     * @param object subclass of Calendar
+     * @access public
+     */
+    function Calendar_Validator(& $calendar)
     {
         $this->calendar = & $calendar;
-        $this->cE       = & $calendar->getEngine();
+        $this->cE = & $calendar->getEngine();
     }
 
     /**
      * Calls all the other isValidXXX() methods in the validator
-     *
      * @return boolean
      * @access public
@@ -106,5 +85,5 @@
         $checks = array('isValidYear', 'isValidMonth', 'isValidDay',
             'isValidHour', 'isValidMinute', 'isValidSecond');
-        $valid  = true;
+        $valid = true;
         foreach ($checks as $check) {
             if (!$this->{$check}()) {
@@ -117,5 +96,4 @@
     /**
      * Check whether this is a valid year
-     *
      * @return boolean
      * @access public
@@ -123,8 +101,8 @@
     function isValidYear()
     {
-        $y   = $this->calendar->thisYear();
+        $y = $this->calendar->thisYear();
         $min = $this->cE->getMinYears();
         if ($min > $y) {
-            $this->errors[] = new Calendar_Validation_Error(
+           $this->errors[] = new Calendar_Validation_Error(
                 'Year', $y, CALENDAR_VALUE_TOOSMALL.$min);
             return false;
@@ -141,5 +119,4 @@
     /**
      * Check whether this is a valid month
-     *
      * @return boolean
      * @access public
@@ -147,5 +124,5 @@
     function isValidMonth()
     {
-        $m   = $this->calendar->thisMonth();
+        $m = $this->calendar->thisMonth();
         $min = 1;
         if ($min > $m) {
@@ -165,5 +142,4 @@
     /**
      * Check whether this is a valid day
-     *
      * @return boolean
      * @access public
@@ -171,5 +147,5 @@
     function isValidDay()
     {
-        $d   = $this->calendar->thisDay();
+        $d = $this->calendar->thisDay();
         $min = 1;
         if ($min > $d) {
@@ -179,7 +155,5 @@
         }
         $max = $this->cE->getDaysInMonth(
-            $this->calendar->thisYear(), 
-            $this->calendar->thisMonth()
-        );
+            $this->calendar->thisYear(), $this->calendar->thisMonth());
         if ($d > $max) {
             $this->errors[] = new Calendar_Validation_Error(
@@ -192,5 +166,4 @@
     /**
      * Check whether this is a valid hour
-     *
      * @return boolean
      * @access public
@@ -198,5 +171,5 @@
     function isValidHour()
     {
-        $h   = $this->calendar->thisHour();
+        $h = $this->calendar->thisHour();
         $min = 0;
         if ($min > $h) {
@@ -216,5 +189,4 @@
     /**
      * Check whether this is a valid minute
-     *
      * @return boolean
      * @access public
@@ -222,5 +194,5 @@
     function isValidMinute()
     {
-        $i   = $this->calendar->thisMinute();
+        $i = $this->calendar->thisMinute();
         $min = 0;
         if ($min > $i) {
@@ -240,5 +212,4 @@
     /**
      * Check whether this is a valid second
-     *
      * @return boolean
      * @access public
@@ -246,5 +217,5 @@
     function isValidSecond()
     {
-        $s   = $this->calendar->thisSecond();
+        $s = $this->calendar->thisSecond();
         $min = 0;
         if ($min > $s) {
@@ -264,5 +235,4 @@
     /**
      * Iterates over any validation errors
-     *
      * @return mixed either Calendar_Validation_Error or false
      * @access public
@@ -270,5 +240,5 @@
     function fetch()
     {
-        $error = each($this->errors);
+        $error = each ($this->errors);
         if ($error) {
             return $error['value'];
@@ -282,13 +252,7 @@
 /**
  * For Validation Error messages
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @copyright 2003-2007 Harry Fuecks
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @see       Calendar::fetch()
- * @access    public
+ * @see Calendar::fetch()
+ * @package Calendar
+ * @access public
  */
 class Calendar_Validation_Error
@@ -317,12 +281,10 @@
     /**
      * Constructs Calendar_Validation_Error
-     *
-     * @param string $unit    Date unit (e.g. month,hour,second)
-     * @param int    $value   Value of unit which failed test
-     * @param string $message Validation error message
-     *
+     * @param string Date unit (e.g. month,hour,second)
+     * @param int Value of unit which failed test
+     * @param string Validation error message
      * @access protected
      */
-    function Calendar_Validation_Error($unit, $value, $message)
+    function Calendar_Validation_Error($unit,$value,$message)
     {
         $this->unit    = $unit;
@@ -333,5 +295,4 @@
     /**
      * Returns the Date unit
-     *
      * @return string
      * @access public
@@ -344,5 +305,4 @@
     /**
      * Returns the value of the unit
-     *
      * @return int
      * @access public
@@ -355,5 +315,4 @@
     /**
      * Returns the validation error message
-     *
      * @return string
      * @access public
@@ -366,5 +325,4 @@
     /**
      * Returns a string containing the unit, value and error message
-     *
      * @return string
      * @access public
Index: /branches/version-2_13-dev/data/module/Calendar/Util/Textual.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Util/Textual.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Util/Textual.php	(revision 23141)
@@ -1,44 +1,27 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
-/**
- * Contains the Calendar_Util_Textual class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Textual.php 247250 2007-11-28 19:42:01Z quipo $
- * @link      http://pear.php.net/package/Calendar
- */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// |          Lorenzo Alberton <l dot alberton at quipo dot it>           |
+// +----------------------------------------------------------------------+
+//
+// $Id: Textual.php,v 1.2 2004/08/16 13:13:09 hfuecks Exp $
+//
 /**
  * @package Calendar
- * @version $Id: Textual.php 247250 2007-11-28 19:42:01Z quipo $
+ * @version $Id: Textual.php,v 1.2 2004/08/16 13:13:09 hfuecks Exp $
  */
 
@@ -59,13 +42,6 @@
  * Static utlities to help with fetching textual representations of months and
  * days of the week.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Util_Textual
@@ -74,20 +50,13 @@
     /**
      * Returns an array of 12 month names (first index = 1)
-     *
-     * @param string $format (optional) format of returned months (one|two|short|long)
-     *
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return array
      * @access public
      * @static
      */
-    function monthNames($format = 'long')
-    {
-        $formats = array(
-            'one'   => '%b', 
-            'two'   => '%b', 
-            'short' => '%b', 
-            'long'  => '%B',
-        );
-        if (!array_key_exists($format, $formats)) {
+    function monthNames($format='long')
+    {
+        $formats = array('one'=>'%b', 'two'=>'%b', 'short'=>'%b', 'long'=>'%B');
+        if (!array_key_exists($format,$formats)) {
             $format = 'long';
         }
@@ -97,9 +66,9 @@
             $month = strftime($formats[$format], $stamp);
             switch($format) {
-            case 'one':
-                $month = substr($month, 0, 1);
-                break;
-            case 'two':
-                $month = substr($month, 0, 2);
+                case 'one':
+                    $month = substr($month, 0, 1);
+                break;
+                case 'two':
+                    $month = substr($month, 0, 2);
                 break;
             }
@@ -111,20 +80,13 @@
     /**
      * Returns an array of 7 week day names (first index = 0)
-     *
-     * @param string $format (optional) format of returned days (one,two,short or long)
-     *
+     * @param string (optional) format of returned days (one,two,short or long)
      * @return array
      * @access public
      * @static
      */
-    function weekdayNames($format = 'long')
-    {
-        $formats = array(
-            'one'   => '%a', 
-            'two'   => '%a', 
-            'short' => '%a', 
-            'long'  => '%A',
-        );
-        if (!array_key_exists($format, $formats)) {
+    function weekdayNames($format='long')
+    {
+        $formats = array('one'=>'%a', 'two'=>'%a', 'short'=>'%a', 'long'=>'%A');
+        if (!array_key_exists($format,$formats)) {
             $format = 'long';
         }
@@ -134,9 +96,9 @@
             $day = strftime($formats[$format], $stamp);
             switch($format) {
-            case 'one':
-                $day = substr($day, 0, 1);
-                break;
-            case 'two':
-                $day = substr($day, 0, 2);
+                case 'one':
+                    $day = substr($day, 0, 1);
+                break;
+                case 'two':
+                    $day = substr($day, 0, 2);
                 break;
             }
@@ -148,13 +110,11 @@
     /**
      * Returns textual representation of the previous month of the decorated calendar object
-     *
-     * @param object $Calendar subclass of Calendar e.g. Calendar_Month
-     * @param string $format   (optional) format of returned months (one,two,short or long)
-     *
-     * @return string
-     * @access public
-     * @static
-     */
-    function prevMonthName($Calendar, $format = 'long')
+     * @param object subclass of Calendar e.g. Calendar_Month
+     * @param string (optional) format of returned months (one,two,short or long)
+     * @return string
+     * @access public
+     * @static
+     */
+    function prevMonthName($Calendar, $format='long')
     {
         $months = Calendar_Util_Textual::monthNames($format);
@@ -164,13 +124,11 @@
     /**
      * Returns textual representation of the month of the decorated calendar object
-     *
-     * @param object $Calendar subclass of Calendar e.g. Calendar_Month
-     * @param string $format   (optional) format of returned months (one,two,short or long)
-     *
-     * @return string
-     * @access public
-     * @static
-     */
-    function thisMonthName($Calendar, $format = 'long')
+     * @param object subclass of Calendar e.g. Calendar_Month
+     * @param string (optional) format of returned months (one,two,short or long)
+     * @return string
+     * @access public
+     * @static
+     */
+    function thisMonthName($Calendar, $format='long')
     {
         $months = Calendar_Util_Textual::monthNames($format);
@@ -180,13 +138,11 @@
     /**
      * Returns textual representation of the next month of the decorated calendar object
-     *
-     * @param object $Calendar subclass of Calendar e.g. Calendar_Month
-     * @param string $format   (optional) format of returned months (one,two,short or long)
-     *
-     * @return string
-     * @access public
-     * @static
-     */
-    function nextMonthName($Calendar, $format = 'long')
+     * @param object subclass of Calendar e.g. Calendar_Month
+     * @param string (optional) format of returned months (one,two,short or long)
+     * @return string
+     * @access public
+     * @static
+     */
+    function nextMonthName($Calendar, $format='long')
     {
         $months = Calendar_Util_Textual::monthNames($format);
@@ -197,18 +153,16 @@
      * Returns textual representation of the previous day of week of the decorated calendar object
      * <b>Note:</b> Requires PEAR::Date
-     *
-     * @param object $Calendar subclass of Calendar e.g. Calendar_Month
-     * @param string $format   (optional) format of returned months (one,two,short or long)
-     *
-     * @return string
-     * @access public
-     * @static
-     */
-    function prevDayName($Calendar, $format = 'long')
+     * @param object subclass of Calendar e.g. Calendar_Month
+     * @param string (optional) format of returned months (one,two,short or long)
+     * @return string
+     * @access public
+     * @static
+     */
+    function prevDayName($Calendar, $format='long')
     {
         $days = Calendar_Util_Textual::weekdayNames($format);
         $stamp = $Calendar->prevDay('timestamp');
         $cE = $Calendar->getEngine();
-        include_once 'Date/Calc.php';
+        require_once 'Date/Calc.php';
         $day = Date_Calc::dayOfWeek($cE->stampToDay($stamp),
             $cE->stampToMonth($stamp), $cE->stampToYear($stamp));
@@ -219,8 +173,6 @@
      * Returns textual representation of the day of week of the decorated calendar object
      * <b>Note:</b> Requires PEAR::Date
-     *
-     * @param object $Calendar subclass of Calendar e.g. Calendar_Month
-     * @param string $format   (optional) format of returned months (one,two,short or long)
-     *
+     * @param object subclass of Calendar e.g. Calendar_Month
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return string
      * @access public
@@ -230,5 +182,5 @@
     {
         $days = Calendar_Util_Textual::weekdayNames($format);
-        include_once 'Date/Calc.php';
+        require_once 'Date/Calc.php';
         $day = Date_Calc::dayOfWeek($Calendar->thisDay(), $Calendar->thisMonth(), $Calendar->thisYear());
         return $days[$day];
@@ -237,8 +189,6 @@
     /**
      * Returns textual representation of the next day of week of the decorated calendar object
-     *
-     * @param object $Calendar subclass of Calendar e.g. Calendar_Month
-     * @param string $format   (optional) format of returned months (one,two,short or long)
-     *
+     * @param object subclass of Calendar e.g. Calendar_Month
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return string
      * @access public
@@ -250,5 +200,5 @@
         $stamp = $Calendar->nextDay('timestamp');
         $cE = $Calendar->getEngine();
-        include_once 'Date/Calc.php';
+        require_once 'Date/Calc.php';
         $day = Date_Calc::dayOfWeek($cE->stampToDay($stamp),
             $cE->stampToMonth($stamp), $cE->stampToYear($stamp));
@@ -260,34 +210,19 @@
      * calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks
      * and Calendar_Week. Otherwise the returned array will begin on Sunday
-     *
-     * @param object $Calendar subclass of Calendar e.g. Calendar_Month
-     * @param string $format   (optional) format of returned months (one,two,short or long)
-     *
+     * @param object subclass of Calendar e.g. Calendar_Month
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return array ordered array of week day names
      * @access public
      * @static
      */
-    function orderedWeekdays($Calendar, $format = 'long')
+    function orderedWeekdays($Calendar, $format='long')
     {
         $days = Calendar_Util_Textual::weekdayNames($format);
         
+        // Not so good - need methods to access this information perhaps...
         if (isset($Calendar->tableHelper)) {
-            $ordereddays = $Calendar->tableHelper->getDaysOfWeek();
+            $ordereddays = $Calendar->tableHelper->daysOfWeek;
         } else {
-            //default: start from Sunday
-            $firstDay = 0;
-            //check if defined / set
-            if (defined('CALENDAR_FIRST_DAY_OF_WEEK')) {
-                $firstDay = CALENDAR_FIRST_DAY_OF_WEEK;
-            } elseif(isset($Calendar->firstDay)) {
-                $firstDay = $Calendar->firstDay;
-            }
-            $ordereddays = array();
-            for ($i = $firstDay; $i < 7; $i++) {
-                $ordereddays[] = $i;
-            }
-            for ($i = 0; $i < $firstDay; $i++) {
-                $ordereddays[] = $i;
-            }
+            $ordereddays = array(0, 1, 2, 3, 4, 5, 6);
         }
         
Index: /branches/version-2_13-dev/data/module/Calendar/Util/Uri.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Util/Uri.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Util/Uri.php	(revision 23141)
@@ -1,39 +1,27 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP                                                                  |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// |          Lorenzo Alberton <l dot alberton at quipo dot it>           |
+// +----------------------------------------------------------------------+
+//
+// $Id: Uri.php,v 1.1 2004/08/16 09:03:55 hfuecks Exp $
+//
 /**
- * Contains the Calendar_Util_Uri class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Uri.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Uri.php,v 1.1 2004/08/16 09:03:55 hfuecks Exp $
  */
 
@@ -42,5 +30,5 @@
  * <code>
  * $Day = new Calendar_Day(2003, 10, 23);
- * $Uri = new Calendar_Util_Uri('year', 'month', 'day');
+ * $Uri = & new Calendar_Util_Uri('year', 'month', 'day');
  * echo $Uri->prev($Day,'month'); // Displays year=2003&amp;month=10
  * echo $Uri->prev($Day,'day'); // Displays year=2003&amp;month=10&amp;day=22
@@ -50,13 +38,6 @@
  * echo $Uri->prev($Day,'day'); // Displays 2003/10/22
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Util_Uri
@@ -89,12 +70,10 @@
      * Constructs Calendar_Decorator_Uri
      * The term "fragment" means <i>name</i> of a calendar GET variables in the URL
-     *
-     * @param string $y URI fragment for year
-     * @param string $m (optional) URI fragment for month
-     * @param string $d (optional) URI fragment for day
-     * @param string $h (optional) URI fragment for hour
-     * @param string $i (optional) URI fragment for minute
-     * @param string $s (optional) URI fragment for second
-     *
+     * @param string URI fragment for year
+     * @param string (optional) URI fragment for month
+     * @param string (optional) URI fragment for day
+     * @param string (optional) URI fragment for hour
+     * @param string (optional) URI fragment for minute
+     * @param string (optional) URI fragment for second
      * @access public
      */
@@ -106,17 +85,14 @@
     /**
      * Sets the URI fragment names
-     *
-     * @param string $y URI fragment for year
-     * @param string $m (optional) URI fragment for month
-     * @param string $d (optional) URI fragment for day
-     * @param string $h (optional) URI fragment for hour
-     * @param string $i (optional) URI fragment for minute
-     * @param string $s (optional) URI fragment for second
-     *
+     * @param string URI fragment for year
+     * @param string (optional) URI fragment for month
+     * @param string (optional) URI fragment for day
+     * @param string (optional) URI fragment for hour
+     * @param string (optional) URI fragment for minute
+     * @param string (optional) URI fragment for second
      * @return void
      * @access public
      */
-    function setFragments($y, $m=null, $d=null, $h=null, $i=null, $s=null) 
-    {
+    function setFragments($y, $m=null, $d=null, $h=null, $i=null, $s=null) {
         if (!is_null($y)) $this->uris['Year']   = $y;
         if (!is_null($m)) $this->uris['Month']  = $m;
@@ -129,8 +105,6 @@
     /**
      * Gets the URI string for the previous calendar unit
-     *
-     * @param object $Calendar subclassed from Calendar e.g. Calendar_Month
-     * @param string $unit     calendar  unit (year|month|week|day|hour|minute|second)
-     *
+     * @param object subclassed from Calendar e.g. Calendar_Month
+     * @param string calendar unit ( must be year, month, week, day, hour, minute or second)
      * @return string
      * @access public
@@ -145,8 +119,6 @@
     /**
      * Gets the URI string for the current calendar unit
-     *
-     * @param object $Calendar subclassed from Calendar e.g. Calendar_Month
-     * @param string $unit     calendar  unit (year|month|week|day|hour|minute|second)
-     *
+     * @param object subclassed from Calendar e.g. Calendar_Month
+     * @param string calendar unit ( must be year, month, week, day, hour, minute or second)
      * @return string
      * @access public
@@ -154,5 +126,5 @@
     function this($Calendar, $unit)
     {
-        $method = 'this'.$unit;
+       $method = 'this'.$unit;
         $stamp  = $Calendar->{$method}('timestamp');
         return $this->buildUriString($Calendar, $method, $stamp);
@@ -161,8 +133,6 @@
     /**
      * Gets the URI string for the next calendar unit
-     *
-     * @param object $Calendar subclassed from Calendar e.g. Calendar_Month
-     * @param string $unit     calendar unit (year|month|week|day|hour|minute|second)
-     *
+     * @param object subclassed from Calendar e.g. Calendar_Month
+     * @param string calendar unit ( must be year, month, week, day, hour, minute or second)
      * @return string
      * @access public
@@ -177,9 +147,6 @@
     /**
      * Build the URI string
-     *
-     * @param object $Calendar subclassed from Calendar e.g. Calendar_Month
-     * @param string $method   method substring
-     * @param int    $stamp    timestamp
-     *
+     * @param string method substring
+     * @param int timestamp
      * @return string build uri string
      * @access private
@@ -193,7 +160,5 @@
             $call = 'stampTo'.$unit;
             $uriString .= $separator;
-            if (!$this->scalar) {
-                $uriString .= $uri.'=';
-            }
+            if (!$this->scalar) $uriString .= $uri.'=';
             $uriString .= $cE->{$call}($stamp);
             $separator = $this->separator;
Index: /branches/version-2_13-dev/data/module/Calendar/Week.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Week.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Week.php	(revision 23141)
@@ -1,39 +1,27 @@
 <?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
+/* vim: set expandtab tabstop=4 shiftwidth=4: */
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// |          Lorenzo Alberton <l dot alberton at quipo dot it>           |
+// +----------------------------------------------------------------------+
+//
+// $Id: Week.php,v 1.7 2005/10/22 10:26:49 quipo Exp $
+//
 /**
- * Contains the Calendar_Week class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Week.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Week.php,v 1.7 2005/10/22 10:26:49 quipo Exp $
  */
 
@@ -54,6 +42,6 @@
  * Represents a Week and builds Days in tabular format<br>
  * <code>
- * require_once 'Calendar/Week.php';
- * $Week = new Calendar_Week(2003, 10, 1); Oct 2003, 1st tabular week
+ * require_once 'Calendar'.DIRECTORY_SEPARATOR.'Week.php';
+ * $Week = & new Calendar_Week(2003, 10, 1); Oct 2003, 1st tabular week
  * echo '<tr>';
  * while ($Day = & $Week->fetch()) {
@@ -66,12 +54,6 @@
  * echo '</tr>';
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @access public
  */
 class Calendar_Week extends Calendar
@@ -128,39 +110,25 @@
     /**
      * Constructs Week
-     *
-     * @param int $y        year e.g. 2003
-     * @param int $m        month e.g. 5
-     * @param int $d        a day of the desired week
-     * @param int $firstDay (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
-     *
-     * @access public
-     */
-    function Calendar_Week($y, $m, $d, $firstDay = null)
-    {
-        include_once CALENDAR_ROOT.'Table/Helper.php';
-        parent::Calendar($y, $m, $d);
-        $this->firstDay    = $this->defineFirstDayOfWeek($firstDay);
-        $this->tableHelper = new Calendar_Table_Helper($this, $this->firstDay);
-        $this->thisWeek    = $this->tableHelper->getWeekStart($y, $m, $d, $this->firstDay);
-        $this->prevWeek    = $this->tableHelper->getWeekStart(
-            $y, 
-            $m, 
-            $d - $this->cE->getDaysInWeek(
-                $this->thisYear(),
-                $this->thisMonth(),
-                $this->thisDay()
-            ), 
-            $this->firstDay
-        );
-        $this->nextWeek = $this->tableHelper->getWeekStart(
-            $y, 
-            $m, 
-            $d + $this->cE->getDaysInWeek(
-                $this->thisYear(),
-                $this->thisMonth(),
-                $this->thisDay()
-            ), 
-            $this->firstDay
-        );
+     * @param int year e.g. 2003
+     * @param int month e.g. 5
+     * @param int a day of the desired week
+     * @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
+     * @access public
+     */
+    function Calendar_Week($y, $m, $d, $firstDay=null)
+    {
+        require_once CALENDAR_ROOT.'Table/Helper.php';
+        Calendar::Calendar($y, $m, $d);
+        $this->firstDay = $this->defineFirstDayOfWeek($firstDay);
+        $this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay);
+        $this->thisWeek = $this->tableHelper->getWeekStart($y, $m, $d, $this->firstDay);
+        $this->prevWeek = $this->tableHelper->getWeekStart($y, $m, $d - $this->cE->getDaysInWeek(
+            $this->thisYear(),
+            $this->thisMonth(),
+            $this->thisDay()), $this->firstDay);
+        $this->nextWeek = $this->tableHelper->getWeekStart($y, $m, $d + $this->cE->getDaysInWeek(
+            $this->thisYear(),
+            $this->thisMonth(),
+            $this->thisDay()), $this->firstDay);
     }
 
@@ -168,7 +136,5 @@
      * Defines the calendar by a timestamp (Unix or ISO-8601), replacing values
      * passed to the constructor
-     *
-     * @param int|string $ts Unix or ISO-8601 timestamp
-     *
+     * @param int|string Unix or ISO-8601 timestamp
      * @return void
      * @access public
@@ -181,22 +147,14 @@
         );
         $this->prevWeek = $this->tableHelper->getWeekStart(
-            $this->year, 
-            $this->month, 
-            $this->day - $this->cE->getDaysInWeek(
+            $this->year, $this->month, $this->day - $this->cE->getDaysInWeek(
                 $this->thisYear(),
                 $this->thisMonth(),
-                $this->thisDay()
-            ), 
-            $this->firstDay
+                $this->thisDay()), $this->firstDay
         );
         $this->nextWeek = $this->tableHelper->getWeekStart(
-            $this->year, 
-            $this->month, 
-            $this->day + $this->cE->getDaysInWeek(
+            $this->year, $this->month, $this->day + $this->cE->getDaysInWeek(
                 $this->thisYear(),
                 $this->thisMonth(),
-                $this->thisDay()
-            ), 
-            $this->firstDay
+                $this->thisDay()), $this->firstDay
         );
     }
@@ -204,7 +162,5 @@
     /**
      * Builds Calendar_Day objects for this Week
-     *
-     * @param array $sDates (optional) Calendar_Day objects representing selected dates
-     *
+     * @param array (optional) Calendar_Day objects representing selected dates
      * @return boolean
      * @access public
@@ -212,5 +168,5 @@
     function build($sDates = array())
     {
-        include_once CALENDAR_ROOT.'Day.php';
+        require_once CALENDAR_ROOT.'Day.php';
         $year  = $this->cE->stampToYear($this->thisWeek);
         $month = $this->cE->stampToMonth($this->thisWeek);
@@ -225,8 +181,7 @@
             $stamp = $this->cE->dateToStamp($year, $month, $day++);
             $this->children[$i] = new Calendar_Day(
-                $this->cE->stampToYear($stamp),
-                $this->cE->stampToMonth($stamp),
-                $this->cE->stampToDay($stamp)
-            );
+                                $this->cE->stampToYear($stamp),
+                                $this->cE->stampToMonth($stamp),
+                                $this->cE->stampToDay($stamp));
         }
 
@@ -252,12 +207,9 @@
 
     /**
-     * Set as first week of the month
-     *
-     * @param boolean $state whether it's first or not
-     *
-     * @return void
-     * @access private
-     */
-    function setFirst($state = true)
+     * @param boolean
+     * @return void
+     * @access private
+     */
+    function setFirst($state=true)
     {
         $this->firstWeek = $state;
@@ -265,12 +217,9 @@
 
     /**
-     * Set as last week of the month
-     *
-     * @param boolean $state whether it's lasst or not
-     *
-     * @return void
-     * @access private
-     */
-    function setLast($state = true)
+     * @param boolean
+     * @return void
+     * @access private
+     */
+    function setLast($state=true)
     {
         $this->lastWeek = $state;
@@ -279,7 +228,5 @@
     /**
      * Called from build()
-     *
-     * @param array $sDates Calendar_Day objects representing selected dates
-     *
+     * @param array
      * @return void
      * @access private
@@ -302,41 +249,7 @@
 
     /**
-     * Returns the value for this year
-     *
-     * When a on the first/last week of the year, the year of the week is
-     * calculated according to ISO-8601
-     *
-     * @param string $format return value format ['int' | 'timestamp' | 'object' | 'array']
-     *
-     * @return int e.g. 2003 or timestamp
-     * @access public
-     */
-    function thisYear($format = 'int')
-    {
-        if (null !== $this->thisWeek) {
-            $tmp_cal = new Calendar();
-            $tmp_cal->setTimestamp($this->thisWeek);
-            $first_dow = $tmp_cal->thisDay('array');
-            $days_in_week = $tmp_cal->cE->getDaysInWeek($tmp_cal->year, $tmp_cal->month, $tmp_cal->day);
-            $tmp_cal->day += $days_in_week;
-            $last_dow  = $tmp_cal->thisDay('array');
-
-            if ($first_dow['year'] == $last_dow['year']) {
-                return $first_dow['year'];
-            }
-
-            if ($last_dow['day'] > floor($days_in_week / 2)) {
-                return $last_dow['year'];
-            }
-            return $first_dow['year'];
-        }
-        return parent::thisYear();
-    }
-
-    /**
      * Gets the value of the previous week, according to the requested format
      *
      * @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array']
-     *
      * @return mixed
      * @access public
@@ -345,20 +258,25 @@
     {
         switch (strtolower($format)) {
-        case 'int':
-        case 'n_in_month':
-            return ($this->firstWeek) ? null : $this->thisWeek('n_in_month') -1;
-        case 'n_in_year':
-            return $this->cE->getWeekNInYear(
-                $this->cE->stampToYear($this->prevWeek),
-                $this->cE->stampToMonth($this->prevWeek),
-                $this->cE->stampToDay($this->prevWeek));
-        case 'array':
-            return $this->toArray($this->prevWeek);
-        case 'object':
-            include_once CALENDAR_ROOT.'Factory.php';
-            return Calendar_Factory::createByTimestamp('Week', $this->prevWeek);
-        case 'timestamp':
-        default:
-            return $this->prevWeek;
+            case 'int':
+            case 'n_in_month':
+                return ($this->firstWeek) ? null : $this->thisWeek('n_in_month') -1;
+                break;
+            case 'n_in_year':
+                return $this->cE->getWeekNInYear(
+                    $this->cE->stampToYear($this->prevWeek),
+                    $this->cE->stampToMonth($this->prevWeek),
+                    $this->cE->stampToDay($this->prevWeek));
+                break;
+            case 'array':
+                return $this->toArray($this->prevWeek);
+                break;
+            case 'object':
+                require_once CALENDAR_ROOT.'Factory.php';
+                return Calendar_Factory::createByTimestamp('Week', $this->prevWeek);
+                break;
+            case 'timestamp':
+            default:
+                return $this->prevWeek;
+                break;
         }
     }
@@ -368,5 +286,4 @@
      *
      * @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array']
-     *
      * @return mixed
      * @access public
@@ -375,33 +292,38 @@
     {
         switch (strtolower($format)) {
-        case 'int':
-        case 'n_in_month':
-            if ($this->firstWeek) {
-                return 1;
-            }
-            if ($this->lastWeek) {
-                return $this->cE->getWeeksInMonth(
+            case 'int':
+            case 'n_in_month':
+                if ($this->firstWeek) {
+                    return 1;
+                }
+                if ($this->lastWeek) {
+                    return $this->cE->getWeeksInMonth(
+                        $this->thisYear(),
+                        $this->thisMonth(),
+                        $this->firstDay);
+                }
+                return $this->cE->getWeekNInMonth(
                     $this->thisYear(),
                     $this->thisMonth(),
+                    $this->thisDay(),
                     $this->firstDay);
-            }
-            return $this->cE->getWeekNInMonth(
-                $this->thisYear(),
-                $this->thisMonth(),
-                $this->thisDay(),
-                $this->firstDay);
-        case 'n_in_year':
-            return $this->cE->getWeekNInYear(
-                $this->cE->stampToYear($this->thisWeek),
-                $this->cE->stampToMonth($this->thisWeek),
-                $this->cE->stampToDay($this->thisWeek));
-        case 'array':
-            return $this->toArray($this->thisWeek);
-        case 'object':
-            include_once CALENDAR_ROOT.'Factory.php';
-            return Calendar_Factory::createByTimestamp('Week', $this->thisWeek);
-        case 'timestamp':
-        default:
-            return $this->thisWeek;
+                break;
+            case 'n_in_year':
+                return $this->cE->getWeekNInYear(
+                    $this->cE->stampToYear($this->thisWeek),
+                    $this->cE->stampToMonth($this->thisWeek),
+                    $this->cE->stampToDay($this->thisWeek));
+                break;
+            case 'array':
+                return $this->toArray($this->thisWeek);
+                break;
+            case 'object':
+                require_once CALENDAR_ROOT.'Factory.php';
+                return Calendar_Factory::createByTimestamp('Week', $this->thisWeek);
+                break;
+            case 'timestamp':
+            default:
+                return $this->thisWeek;
+                break;
         }
     }
@@ -411,5 +333,4 @@
      *
      * @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array']
-     *
      * @return mixed
      * @access public
@@ -418,20 +339,25 @@
     {
         switch (strtolower($format)) {
-        case 'int':
-        case 'n_in_month':
-            return ($this->lastWeek) ? null : $this->thisWeek('n_in_month') +1;
-        case 'n_in_year':
-            return $this->cE->getWeekNInYear(
-                $this->cE->stampToYear($this->nextWeek),
-                $this->cE->stampToMonth($this->nextWeek),
-                $this->cE->stampToDay($this->nextWeek));
-        case 'array':
-            return $this->toArray($this->nextWeek);
-        case 'object':
-            include_once CALENDAR_ROOT.'Factory.php';
-            return Calendar_Factory::createByTimestamp('Week', $this->nextWeek);
-        case 'timestamp':
-        default:
-            return $this->nextWeek;
+            case 'int':
+            case 'n_in_month':
+                return ($this->lastWeek) ? null : $this->thisWeek('n_in_month') +1;
+                break;
+            case 'n_in_year':
+                return $this->cE->getWeekNInYear(
+                    $this->cE->stampToYear($this->nextWeek),
+                    $this->cE->stampToMonth($this->nextWeek),
+                    $this->cE->stampToDay($this->nextWeek));
+                break;
+            case 'array':
+                return $this->toArray($this->nextWeek);
+                break;
+            case 'object':
+                require_once CALENDAR_ROOT.'Factory.php';
+                return Calendar_Factory::createByTimestamp('Week', $this->nextWeek);
+                break;
+            case 'timestamp':
+            default:
+                    return $this->nextWeek;
+                    break;
         }
     }
@@ -440,5 +366,4 @@
      * Returns the instance of Calendar_Table_Helper.
      * Called from Calendar_Validator::isValidWeek
-     *
      * @return Calendar_Table_Helper
      * @access protected
@@ -451,5 +376,4 @@
     /**
      * Makes sure theres a value for $this->day
-     *
      * @return void
      * @access private
Index: /branches/version-2_13-dev/data/module/Calendar/Decorator/Textual.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Decorator/Textual.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Decorator/Textual.php	(revision 23141)
@@ -1,39 +1,27 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// |          Lorenzo Alberton <l dot alberton at quipo dot it>           |
+// +----------------------------------------------------------------------+
+//
+// $Id: Textual.php,v 1.3 2004/08/16 13:02:44 hfuecks Exp $
+//
 /**
- * Contains the Calendar_Decorator_Wrapper class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Textual.php 246907 2007-11-24 11:04:24Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Textual.php,v 1.3 2004/08/16 13:02:44 hfuecks Exp $
  */
 
@@ -61,13 +49,6 @@
  * <b>Note:</b> for performance you should prefer Calendar_Util_Textual unless you
  * have a specific need to use a decorator
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Decorator_Textual extends Calendar_Decorator
@@ -75,7 +56,5 @@
     /**
      * Constructs Calendar_Decorator_Textual
-     *
-     * @param object &$Calendar subclass of Calendar
-     *
+     * @param object subclass of Calendar
      * @access public
      */
@@ -87,12 +66,10 @@
     /**
      * Returns an array of 12 month names (first index = 1)
-     *
-     * @param string $format (optional) format of returned months (one|two|short|long)
-     *
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return array
      * @access public
      * @static
      */
-    function monthNames($format = 'long')
+    function monthNames($format='long')
     {
         return Calendar_Util_Textual::monthNames($format);
@@ -101,12 +78,10 @@
     /**
      * Returns an array of 7 week day names (first index = 0)
-     *
-     * @param string $format (optional) format of returned days (one|two|short|long)
-     *
+     * @param string (optional) format of returned days (one,two,short or long)
      * @return array
      * @access public
      * @static
      */
-    function weekdayNames($format = 'long')
+    function weekdayNames($format='long')
     {
         return Calendar_Util_Textual::weekdayNames($format);
@@ -115,78 +90,66 @@
     /**
      * Returns textual representation of the previous month of the decorated calendar object
-     *
-     * @param string $format (optional) format of returned months (one|two|short|long)
-     *
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return string
      * @access public
      */
-    function prevMonthName($format = 'long')
+    function prevMonthName($format='long')
     {
-        return Calendar_Util_Textual::prevMonthName($this->calendar, $format);
+        return Calendar_Util_Textual::prevMonthName($this->calendar,$format);
     }
 
     /**
      * Returns textual representation of the month of the decorated calendar object
-     *
-     * @param string $format (optional) format of returned months (one|two|short|long)
-     *
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return string
      * @access public
      */
-    function thisMonthName($format = 'long')
+    function thisMonthName($format='long')
     {
-        return Calendar_Util_Textual::thisMonthName($this->calendar, $format);
+        return Calendar_Util_Textual::thisMonthName($this->calendar,$format);
     }
 
     /**
      * Returns textual representation of the next month of the decorated calendar object
-     *
-     * @param string $format (optional) format of returned months (one|two|short|long)
-     *
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return string
      * @access public
      */
-    function nextMonthName($format = 'long')
+    function nextMonthName($format='long')
     {
-        return Calendar_Util_Textual::nextMonthName($this->calendar, $format);
+        return Calendar_Util_Textual::nextMonthName($this->calendar,$format);
     }
 
     /**
      * Returns textual representation of the previous day of week of the decorated calendar object
-     *
-     * @param string $format (optional) format of returned months (one|two|short|long)
-     *
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return string
      * @access public
      */
-    function prevDayName($format = 'long')
+    function prevDayName($format='long')
     {
-        return Calendar_Util_Textual::prevDayName($this->calendar, $format);
+        return Calendar_Util_Textual::prevDayName($this->calendar,$format);
     }
 
     /**
      * Returns textual representation of the day of week of the decorated calendar object
-     *
-     * @param string $format (optional) format of returned months (one|two|short|long)
-     *
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return string
      * @access public
      */
-    function thisDayName($format = 'long')
+    function thisDayName($format='long')
     {
-        return Calendar_Util_Textual::thisDayName($this->calendar, $format);
+        return Calendar_Util_Textual::thisDayName($this->calendar,$format);
     }
 
     /**
      * Returns textual representation of the next day of week of the decorated calendar object
-     *
-     * @param string $format (optional) format of returned months (one|two|short|long)
-     *
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return string
      * @access public
      */
-    function nextDayName($format = 'long')
+    function nextDayName($format='long')
     {
-        return Calendar_Util_Textual::nextDayName($this->calendar, $format);
+        return Calendar_Util_Textual::nextDayName($this->calendar,$format);
     }
 
@@ -195,13 +158,11 @@
      * calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks
      * and Calendar_Week. Otherwise the returned array will begin on Sunday
-     *
-     * @param string $format (optional) format of returned months (one|two|short|long)
-     *
+     * @param string (optional) format of returned months (one,two,short or long)
      * @return array ordered array of week day names
      * @access public
      */
-    function orderedWeekdays($format = 'long')
+    function orderedWeekdays($format='long')
     {
-        return Calendar_Util_Textual::orderedWeekdays($this->calendar, $format);
+        return Calendar_Util_Textual::orderedWeekdays($this->calendar,$format);
     }
 }
Index: /branches/version-2_13-dev/data/module/Calendar/Decorator/Weekday.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Decorator/Weekday.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Decorator/Weekday.php	(revision 23141)
@@ -1,39 +1,27 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// |          Lorenzo Alberton <l dot alberton at quipo dot it>           |
+// +----------------------------------------------------------------------+
+//
+// $Id: Weekday.php,v 1.3 2004/08/16 12:25:15 hfuecks Exp $
+//
 /**
- * Contains the Calendar_Decorator_Weekday class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Weekday.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Weekday.php,v 1.3 2004/08/16 12:25:15 hfuecks Exp $
  */
 
@@ -59,17 +47,10 @@
  * <code>
  * $Day = new Calendar_Day(2003, 10, 23);
- * $Weekday = new Calendar_Decorator_Weekday($Day);
+ * $Weekday = & new Calendar_Decorator_Weekday($Day);
  * $Weekday->setFirstDay(0); // Set first day of week to Sunday (default Mon)
  * echo $Weekday->thisWeekDay(); // Displays 5 - fifth day of week relative to Sun
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Decorator_Weekday extends Calendar_Decorator
@@ -84,10 +65,8 @@
     /**
      * Constructs Calendar_Decorator_Weekday
-     *
-     * @param object &$Calendar subclass of Calendar
-     *
+     * @param object subclass of Calendar
      * @access public
      */
-    function Calendar_Decorator_Weekday(&$Calendar)
+    function Calendar_Decorator_Weekday(& $Calendar)
     {
         parent::Calendar_Decorator($Calendar);
@@ -96,12 +75,9 @@
     /**
      * Sets the first day of the week (0 = Sunday, 1 = Monday (default) etc)
-     *
-     * @param int $firstDay first day of week
-     *
+     * @param int first day of week
      * @return void
      * @access public
      */
-    function setFirstDay($firstDay) 
-    {
+    function setFirstDay($firstDay) {
         $this->firstDay = (int)$firstDay;
     }
@@ -109,20 +85,14 @@
     /**
      * Returns the previous weekday
-     *
-     * @param string $format (default = 'int') return value format
-     *
-     * @return int $format numeric day of week or timestamp
+     * @param string (default = 'int') return value format
+     * @return int numeric day of week or timestamp
      * @access public
      */
     function prevWeekDay($format = 'int')
     {
-        $ts  = $this->calendar->prevDay('timestamp');
-        $Day = new Calendar_Day(2000, 1, 1);
+        $ts = $this->calendar->prevDay('timestamp');
+        $Day = new Calendar_Day(2000,1,1);
         $Day->setTimeStamp($ts);
-        $day = $this->calendar->cE->getDayOfWeek(
-            $Day->thisYear(),
-            $Day->thisMonth(),
-            $Day->thisDay()
-        );
+        $day = $this->calendar->cE->getDayOfWeek($Day->thisYear(),$Day->thisMonth(),$Day->thisDay());
         $day = $this->adjustWeekScale($day);
         return $this->returnValue('Day', $format, $ts, $day);
@@ -131,7 +101,5 @@
     /**
      * Returns the current weekday
-     *
-     * @param string $format (default = 'int') return value format
-     *
+     * @param string (default = 'int') return value format
      * @return int numeric day of week or timestamp
      * @access public
@@ -139,10 +107,6 @@
     function thisWeekDay($format = 'int')
     {
-        $ts  = $this->calendar->thisDay('timestamp');
-        $day = $this->calendar->cE->getDayOfWeek(
-            $this->calendar->year,
-            $this->calendar->month,
-            $this->calendar->day
-        );
+        $ts = $this->calendar->thisDay('timestamp');
+        $day = $this->calendar->cE->getDayOfWeek($this->calendar->year,$this->calendar->month,$this->calendar->day);
         $day = $this->adjustWeekScale($day);
         return $this->returnValue('Day', $format, $ts, $day);
@@ -151,7 +115,5 @@
     /**
      * Returns the next weekday
-     *
-     * @param string $format (default = 'int') return value format
-     *
+     * @param string (default = 'int') return value format
      * @return int numeric day of week or timestamp
      * @access public
@@ -159,12 +121,8 @@
     function nextWeekDay($format = 'int')
     {
-        $ts  = $this->calendar->nextDay('timestamp');
-        $Day = new Calendar_Day(2000, 1, 1);
+        $ts = $this->calendar->nextDay('timestamp');
+        $Day = new Calendar_Day(2000,1,1);
         $Day->setTimeStamp($ts);
-        $day = $this->calendar->cE->getDayOfWeek(
-            $Day->thisYear(),
-            $Day->thisMonth(),
-            $Day->thisDay()
-        );
+        $day = $this->calendar->cE->getDayOfWeek($Day->thisYear(),$Day->thisMonth(),$Day->thisDay());
         $day = $this->adjustWeekScale($day);
         return $this->returnValue('Day', $format, $ts, $day);
@@ -173,21 +131,16 @@
     /**
      * Adjusts the day of the week relative to the first day of the week
-     *
-     * @param int $dayOfWeek day of week calendar from Calendar_Engine
-     *
+     * @param int day of week calendar from Calendar_Engine
      * @return int day of week adjusted to first day
      * @access private
      */
-    function adjustWeekScale($dayOfWeek) 
-    {
+    function adjustWeekScale($dayOfWeek) {
         $dayOfWeek = $dayOfWeek - $this->firstDay;
-        if ($dayOfWeek >= 0) {
+        if ( $dayOfWeek >= 0 ) {
             return $dayOfWeek;
         } else {
             return $this->calendar->cE->getDaysInWeek(
-                $this->calendar->year,
-                $this->calendar->month,
-                $this->calendar->day
-            ) + $dayOfWeek;
+                $this->calendar->year,$this->calendar->month,$this->calendar->day
+                ) + $dayOfWeek;
         }
     }
Index: /branches/version-2_13-dev/data/module/Calendar/Decorator/Uri.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Decorator/Uri.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Decorator/Uri.php	(revision 23141)
@@ -1,39 +1,27 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// |          Lorenzo Alberton <l dot alberton at quipo dot it>           |
+// +----------------------------------------------------------------------+
+//
+// $Id: Uri.php,v 1.3 2004/08/16 09:04:20 hfuecks Exp $
+//
 /**
- * Contains the Calendar_Decorator_Uri class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Uri.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Uri.php,v 1.3 2004/08/16 09:04:20 hfuecks Exp $
  */
 
@@ -62,18 +50,11 @@
  * <code>
  * $Day = new Calendar_Day(2003, 10, 23);
- * $Uri = new Calendar_Decorator_Uri($Day);
+ * $Uri = & new Calendar_Decorator_Uri($Day);
  * $Uri->setFragments('year', 'month', 'day');
  * echo $Uri->getPrev(); // Displays year=2003&month=10&day=22
  * </code>
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @see       Calendar_Util_Uri
- * @access    public
+ * @see Calendar_Util_Uri
+ * @package Calendar
+ * @access public
  */
 class Calendar_Decorator_Uri extends Calendar_Decorator
@@ -81,14 +62,12 @@
 
     /**
-     * @var Calendar_Util_Uri
-     * @access private
-     */
+    * @var Calendar_Util_Uri
+    * @access private
+    */
     var $Uri;
 
     /**
      * Constructs Calendar_Decorator_Uri
-     *
-     * @param object &$Calendar subclass of Calendar
-     *
+     * @param object subclass of Calendar
      * @access public
      */
@@ -100,25 +79,20 @@
     /**
      * Sets the URI fragment names
-     *
-     * @param string $y URI fragment for year
-     * @param string $m (optional) URI fragment for month
-     * @param string $d (optional) URI fragment for day
-     * @param string $h (optional) URI fragment for hour
-     * @param string $i (optional) URI fragment for minute
-     * @param string $s (optional) URI fragment for second
-     *
+     * @param string URI fragment for year
+     * @param string (optional) URI fragment for month
+     * @param string (optional) URI fragment for day
+     * @param string (optional) URI fragment for hour
+     * @param string (optional) URI fragment for minute
+     * @param string (optional) URI fragment for second
      * @return void
      * @access public
      */
-    function setFragments($y, $m = null, $d = null, $h = null, $i = null, $s = null)
-    {
-        $this->Uri = new Calendar_Util_Uri($y, $m, $d, $h, $i, $s);
+    function setFragments($y, $m=null, $d=null, $h=null, $i=null, $s=null) {
+        $this->Uri = & new Calendar_Util_Uri($y, $m, $d, $h, $i, $s);
     }
 
     /**
      * Sets the separator string between fragments
-     *
-     * @param string $separator url fragment separator e.g. /
-     *
+     * @param string separator e.g. /
      * @return void
      * @access public
@@ -130,12 +104,11 @@
 
     /**
-     * Puts Uri decorator into "scalar mode" - URI variable names are not returned
-     *
-     * @param boolean $state (optional)
-     *
+     * Puts Uri decorator into "scalar mode" - URI variable names are not
+     * returned
+     * @param boolean (optional)
      * @return void
      * @access public
      */
-    function setScalar($state = true)
+    function setScalar($state=true)
     {
         $this->Uri->scalar = $state;
@@ -144,7 +117,5 @@
     /**
      * Gets the URI string for the previous calendar unit
-     *
-     * @param string $method calendar unit to fetch uri for (year, month, week or day etc)
-     *
+     * @param string calendar unit to fetch uri for (year,month,week or day etc)
      * @return string
      * @access public
@@ -157,7 +128,5 @@
     /**
      * Gets the URI string for the current calendar unit
-     *
-     * @param string $method calendar unit to fetch uri for (year,month,week or day etc)
-     *
+     * @param string calendar unit to fetch uri for (year,month,week or day etc)
      * @return string
      * @access public
@@ -170,7 +139,5 @@
     /**
      * Gets the URI string for the next calendar unit
-     *
-     * @param string $method calendar unit to fetch uri for (year,month,week or day etc)
-     *
+     * @param string calendar unit to fetch uri for (year,month,week or day etc)
      * @return string
      * @access public
@@ -180,4 +147,5 @@
         return $this->Uri->next($this, $method);
     }
+
 }
 ?>
Index: /branches/version-2_13-dev/data/module/Calendar/Decorator/Wrapper.php
===================================================================
--- /branches/version-2_13-dev/data/module/Calendar/Decorator/Wrapper.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/Calendar/Decorator/Wrapper.php	(revision 23141)
@@ -1,39 +1,27 @@
 <?php
 /* vim: set expandtab tabstop=4 shiftwidth=4: */
-
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/3_0.txt.                                  |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      |
+// |          Lorenzo Alberton <l dot alberton at quipo dot it>           |
+// +----------------------------------------------------------------------+
+//
+// $Id: Wrapper.php,v 1.2 2005/11/03 20:35:03 quipo Exp $
+//
 /**
- * Contains the Calendar_Decorator_Wrapper class
- *
- * PHP versions 4 and 5
- *
- * LICENSE: Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @version   CVS: $Id: Wrapper.php 300729 2010-06-24 12:05:53Z quipo $
- * @link      http://pear.php.net/package/Calendar
+ * @package Calendar
+ * @version $Id: Wrapper.php,v 1.2 2005/11/03 20:35:03 quipo Exp $
  */
 
@@ -53,13 +41,6 @@
 /**
  * Decorator to help with wrapping built children in another decorator
- *
- * @category  Date and Time
- * @package   Calendar
- * @author    Harry Fuecks <hfuecks@phppatterns.com>
- * @author    Lorenzo Alberton <l.alberton@quipo.it>
- * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
- * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
- * @link      http://pear.php.net/package/Calendar
- * @access    public
+ * @package Calendar
+ * @access public
  */
 class Calendar_Decorator_Wrapper extends Calendar_Decorator
@@ -67,7 +48,5 @@
     /**
      * Constructs Calendar_Decorator_Wrapper
-     *
-     * @param object &$Calendar subclass of Calendar
-     *
+     * @param object subclass of Calendar
      * @access public
      */
@@ -79,7 +58,5 @@
     /**
      * Wraps objects returned from fetch in the named Decorator class
-     *
-     * @param string $decorator name of Decorator class to wrap with
-     *
+     * @param string name of Decorator class to wrap with
      * @return object instance of named decorator
      * @access public
@@ -89,5 +66,5 @@
         $Calendar = parent::fetch();
         if ($Calendar) {
-            $ret = new $decorator($Calendar);
+            $ret =& new $decorator($Calendar);
         } else {
             $ret = false;
@@ -98,7 +75,5 @@
     /**
      * Wraps the returned calendar objects from fetchAll in the named decorator
-     *
-     * @param string $decorator name of Decorator class to wrap with
-     *
+     * @param string name of Decorator class to wrap with
      * @return array
      * @access public
@@ -108,5 +83,5 @@
         $children = parent::fetchAll();
         foreach ($children as $key => $Calendar) {
-            $children[$key] = new $decorator($Calendar);
+            $children[$key] = & new $decorator($Calendar);
         }
         return $children;
Index: /branches/version-2_13-dev/data/module/PEAR.php
===================================================================
--- /branches/version-2_13-dev/data/module/PEAR.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/PEAR.php	(revision 23141)
@@ -15,5 +15,5 @@
  * @copyright  1997-2010 The Authors
  * @license    http://opensource.org/licenses/bsd-license.php New BSD License
- * @version    CVS: $Id: PEAR.php 313023 2011-07-06 19:17:11Z dufuz $
+ * @version    CVS: commit 01071ee7b71e4d38c4e96fdf0ae5e411841eaec7
  * @link       http://pear.php.net/package/PEAR
  * @since      File available since Release 0.1
@@ -79,5 +79,5 @@
  * @copyright  1997-2006 The PHP Group
  * @license    http://opensource.org/licenses/bsd-license.php New BSD License
- * @version    Release: 1.9.4
+ * @version    Release: @package_version@
  * @link       http://pear.php.net/package/PEAR
  * @see        PEAR_Error
@@ -250,4 +250,7 @@
     function isError($data, $code = null)
     {
+        if (!is_object($data)) {
+             return false;
+        }
         if (!is_a($data, 'PEAR_Error')) {
             return false;
@@ -485,4 +488,10 @@
             $message->error_message_prefix = '';
             $message     = $message->getMessage();
+
+            // Make sure right data gets passed.
+            $r = new ReflectionClass($error_class);
+            $c = $r->getConstructor();
+            $p = array_shift($c->getParameters());
+            $skipmsg = ($p->getName() != 'message');
         }
 
@@ -789,5 +798,5 @@
  * @copyright  1997-2006 The PHP Group
  * @license    http://opensource.org/licenses/bsd-license.php New BSD License
- * @version    Release: 1.9.4
+ * @version    Release: @package_version@
  * @link       http://pear.php.net/manual/en/core.pear.pear-error.php
  * @see        PEAR::raiseError(), PEAR::throwError()
Index: /branches/version-2_13-dev/data/module/HTTP/Request.php
===================================================================
--- /branches/version-2_13-dev/data/module/HTTP/Request.php	(revision 23125)
+++ /branches/version-2_13-dev/data/module/HTTP/Request.php	(revision 23141)
@@ -1,2 +1,3 @@
+<<<<<<< .working
 <?php
 /**
@@ -41,5 +42,5 @@
  * @copyright   2002-2007 Richard Heyes
  * @license     http://opensource.org/licenses/bsd-license.php New BSD License
- * @version     CVS: $Id: Request.php,v 1.63 2008/10/11 11:07:10 avb Exp $
+ * @version     CVS: $Id$
  * @link        http://pear.php.net/package/HTTP_Request/
  */
@@ -1520,2 +1521,1532 @@
 } // End class HTTP_Response
 ?>
+=======
+<?php
+/**
+ * Class for performing HTTP requests
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE:
+ *
+ * Copyright (c) 2002-2007, Richard Heyes
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * o Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * o Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * o The names of the authors may not be used to endorse or promote
+ *   products derived from this software without specific prior written
+ *   permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category    HTTP
+ * @package     HTTP_Request
+ * @author      Richard Heyes <richard@phpguru.org>
+ * @author      Alexey Borzov <avb@php.net>
+ * @copyright   2002-2007 Richard Heyes
+ * @license     http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version     CVS: $Id$
+ * @link        http://pear.php.net/package/HTTP_Request/
+ */
+
+/**
+ * PEAR and PEAR_Error classes (for error handling)
+ */
+require_once 'PEAR.php';
+/**
+ * Socket class
+ */
+require_once 'Net/Socket.php';
+/**
+ * URL handling class
+ */
+require_once 'Net/URL.php';
+
+/**#@+
+ * Constants for HTTP request methods
+ */
+define('HTTP_REQUEST_METHOD_GET',     'GET',     true);
+define('HTTP_REQUEST_METHOD_HEAD',    'HEAD',    true);
+define('HTTP_REQUEST_METHOD_POST',    'POST',    true);
+define('HTTP_REQUEST_METHOD_PUT',     'PUT',     true);
+define('HTTP_REQUEST_METHOD_DELETE',  'DELETE',  true);
+define('HTTP_REQUEST_METHOD_OPTIONS', 'OPTIONS', true);
+define('HTTP_REQUEST_METHOD_TRACE',   'TRACE',   true);
+/**#@-*/
+
+/**#@+
+ * Constants for HTTP request error codes
+ */
+define('HTTP_REQUEST_ERROR_FILE',             1);
+define('HTTP_REQUEST_ERROR_URL',              2);
+define('HTTP_REQUEST_ERROR_PROXY',            4);
+define('HTTP_REQUEST_ERROR_REDIRECTS',        8);
+define('HTTP_REQUEST_ERROR_RESPONSE',        16);
+define('HTTP_REQUEST_ERROR_GZIP_METHOD',     32);
+define('HTTP_REQUEST_ERROR_GZIP_READ',       64);
+define('HTTP_REQUEST_ERROR_GZIP_DATA',      128);
+define('HTTP_REQUEST_ERROR_GZIP_CRC',       256);
+/**#@-*/
+
+/**#@+
+ * Constants for HTTP protocol versions
+ */
+define('HTTP_REQUEST_HTTP_VER_1_0', '1.0', true);
+define('HTTP_REQUEST_HTTP_VER_1_1', '1.1', true);
+/**#@-*/
+
+if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) {
+   /**
+    * Whether string functions are overloaded by their mbstring equivalents
+    */
+    define('HTTP_REQUEST_MBSTRING', true);
+} else {
+   /**
+    * @ignore
+    */
+    define('HTTP_REQUEST_MBSTRING', false);
+}
+
+/**
+ * Class for performing HTTP requests
+ *
+ * Simple example (fetches yahoo.com and displays it):
+ * <code>
+ * $a = &new HTTP_Request('http://www.yahoo.com/');
+ * $a->sendRequest();
+ * echo $a->getResponseBody();
+ * </code>
+ *
+ * @category    HTTP
+ * @package     HTTP_Request
+ * @author      Richard Heyes <richard@phpguru.org>
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 1.4.4
+ */
+class HTTP_Request
+{
+   /**#@+
+    * @access private
+    */
+    /**
+    * Instance of Net_URL
+    * @var Net_URL
+    */
+    var $_url;
+
+    /**
+    * Type of request
+    * @var string
+    */
+    var $_method;
+
+    /**
+    * HTTP Version
+    * @var string
+    */
+    var $_http;
+
+    /**
+    * Request headers
+    * @var array
+    */
+    var $_requestHeaders;
+
+    /**
+    * Basic Auth Username
+    * @var string
+    */
+    var $_user;
+
+    /**
+    * Basic Auth Password
+    * @var string
+    */
+    var $_pass;
+
+    /**
+    * Socket object
+    * @var Net_Socket
+    */
+    var $_sock;
+
+    /**
+    * Proxy server
+    * @var string
+    */
+    var $_proxy_host;
+
+    /**
+    * Proxy port
+    * @var integer
+    */
+    var $_proxy_port;
+
+    /**
+    * Proxy username
+    * @var string
+    */
+    var $_proxy_user;
+
+    /**
+    * Proxy password
+    * @var string
+    */
+    var $_proxy_pass;
+
+    /**
+    * Post data
+    * @var array
+    */
+    var $_postData;
+
+   /**
+    * Request body
+    * @var string
+    */
+    var $_body;
+
+   /**
+    * A list of methods that MUST NOT have a request body, per RFC 2616
+    * @var array
+    */
+    var $_bodyDisallowed = array('TRACE');
+
+   /**
+    * Methods having defined semantics for request body
+    *
+    * Content-Length header (indicating that the body follows, section 4.3 of
+    * RFC 2616) will be sent for these methods even if no body was added
+    *
+    * @var array
+    */
+    var $_bodyRequired = array('POST', 'PUT');
+
+   /**
+    * Files to post
+    * @var array
+    */
+    var $_postFiles = array();
+
+    /**
+    * Connection timeout.
+    * @var float
+    */
+    var $_timeout;
+
+    /**
+    * HTTP_Response object
+    * @var HTTP_Response
+    */
+    var $_response;
+
+    /**
+    * Whether to allow redirects
+    * @var boolean
+    */
+    var $_allowRedirects;
+
+    /**
+    * Maximum redirects allowed
+    * @var integer
+    */
+    var $_maxRedirects;
+
+    /**
+    * Current number of redirects
+    * @var integer
+    */
+    var $_redirects;
+
+   /**
+    * Whether to append brackets [] to array variables
+    * @var bool
+    */
+    var $_useBrackets = true;
+
+   /**
+    * Attached listeners
+    * @var array
+    */
+    var $_listeners = array();
+
+   /**
+    * Whether to save response body in response object property
+    * @var bool
+    */
+    var $_saveBody = true;
+
+   /**
+    * Timeout for reading from socket (array(seconds, microseconds))
+    * @var array
+    */
+    var $_readTimeout = null;
+
+   /**
+    * Options to pass to Net_Socket::connect. See stream_context_create
+    * @var array
+    */
+    var $_socketOptions = null;
+   /**#@-*/
+
+    /**
+    * Constructor
+    *
+    * Sets up the object
+    * @param    string  The url to fetch/access
+    * @param    array   Associative array of parameters which can have the following keys:
+    * <ul>
+    *   <li>method         - Method to use, GET, POST etc (string)</li>
+    *   <li>http           - HTTP Version to use, 1.0 or 1.1 (string)</li>
+    *   <li>user           - Basic Auth username (string)</li>
+    *   <li>pass           - Basic Auth password (string)</li>
+    *   <li>proxy_host     - Proxy server host (string)</li>
+    *   <li>proxy_port     - Proxy server port (integer)</li>
+    *   <li>proxy_user     - Proxy auth username (string)</li>
+    *   <li>proxy_pass     - Proxy auth password (string)</li>
+    *   <li>timeout        - Connection timeout in seconds (float)</li>
+    *   <li>allowRedirects - Whether to follow redirects or not (bool)</li>
+    *   <li>maxRedirects   - Max number of redirects to follow (integer)</li>
+    *   <li>useBrackets    - Whether to append [] to array variable names (bool)</li>
+    *   <li>saveBody       - Whether to save response body in response object property (bool)</li>
+    *   <li>readTimeout    - Timeout for reading / writing data over the socket (array (seconds, microseconds))</li>
+    *   <li>socketOptions  - Options to pass to Net_Socket object (array)</li>
+    * </ul>
+    * @access public
+    */
+    function HTTP_Request($url = '', $params = array())
+    {
+        $this->_method         =  HTTP_REQUEST_METHOD_GET;
+        $this->_http           =  HTTP_REQUEST_HTTP_VER_1_1;
+        $this->_requestHeaders = array();
+        $this->_postData       = array();
+        $this->_body           = null;
+
+        $this->_user = null;
+        $this->_pass = null;
+
+        $this->_proxy_host = null;
+        $this->_proxy_port = null;
+        $this->_proxy_user = null;
+        $this->_proxy_pass = null;
+
+        $this->_allowRedirects = false;
+        $this->_maxRedirects   = 3;
+        $this->_redirects      = 0;
+
+        $this->_timeout  = null;
+        $this->_response = null;
+
+        foreach ($params as $key => $value) {
+            $this->{'_' . $key} = $value;
+        }
+
+        if (!empty($url)) {
+            $this->setURL($url);
+        }
+
+        // Default useragent
+        $this->addHeader('User-Agent', 'PEAR HTTP_Request class ( http://pear.php.net/ )');
+
+        // We don't do keep-alives by default
+        $this->addHeader('Connection', 'close');
+
+        // Basic authentication
+        if (!empty($this->_user)) {
+            $this->addHeader('Authorization', 'Basic ' . base64_encode($this->_user . ':' . $this->_pass));
+        }
+
+        // Proxy authentication (see bug #5913)
+        if (!empty($this->_proxy_user)) {
+            $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($this->_proxy_user . ':' . $this->_proxy_pass));
+        }
+
+        // Use gzip encoding if possible
+        if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && extension_loaded('zlib')) {
+            $this->addHeader('Accept-Encoding', 'gzip');
+        }
+    }
+
+    /**
+    * Generates a Host header for HTTP/1.1 requests
+    *
+    * @access private
+    * @return string
+    */
+    function _generateHostHeader()
+    {
+        if ($this->_url->port != 80 AND strcasecmp($this->_url->protocol, 'http') == 0) {
+            $host = $this->_url->host . ':' . $this->_url->port;
+
+        } elseif ($this->_url->port != 443 AND strcasecmp($this->_url->protocol, 'https') == 0) {
+            $host = $this->_url->host . ':' . $this->_url->port;
+
+        } elseif ($this->_url->port == 443 AND strcasecmp($this->_url->protocol, 'https') == 0 AND strpos($this->_url->url, ':443') !== false) {
+            $host = $this->_url->host . ':' . $this->_url->port;
+
+        } else {
+            $host = $this->_url->host;
+        }
+
+        return $host;
+    }
+
+    /**
+    * Resets the object to its initial state (DEPRECATED).
+    * Takes the same parameters as the constructor.
+    *
+    * @param  string $url    The url to be requested
+    * @param  array  $params Associative array of parameters
+    *                        (see constructor for details)
+    * @access public
+    * @deprecated deprecated since 1.2, call the constructor if this is necessary
+    */
+    function reset($url, $params = array())
+    {
+        $this->HTTP_Request($url, $params);
+    }
+
+    /**
+    * Sets the URL to be requested
+    *
+    * @param  string The url to be requested
+    * @access public
+    */
+    function setURL($url)
+    {
+        $this->_url = &new Net_URL($url, $this->_useBrackets);
+
+        if (!empty($this->_url->user) || !empty($this->_url->pass)) {
+            $this->setBasicAuth($this->_url->user, $this->_url->pass);
+        }
+
+        if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http) {
+            $this->addHeader('Host', $this->_generateHostHeader());
+        }
+
+        // set '/' instead of empty path rather than check later (see bug #8662)
+        if (empty($this->_url->path)) {
+            $this->_url->path = '/';
+        }
+    }
+
+   /**
+    * Returns the current request URL
+    *
+    * @return   string  Current request URL
+    * @access   public
+    */
+    function getUrl()
+    {
+        return empty($this->_url)? '': $this->_url->getUrl();
+    }
+
+    /**
+    * Sets a proxy to be used
+    *
+    * @param string     Proxy host
+    * @param int        Proxy port
+    * @param string     Proxy username
+    * @param string     Proxy password
+    * @access public
+    */
+    function setProxy($host, $port = 8080, $user = null, $pass = null)
+    {
+        $this->_proxy_host = $host;
+        $this->_proxy_port = $port;
+        $this->_proxy_user = $user;
+        $this->_proxy_pass = $pass;
+
+        if (!empty($user)) {
+            $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($user . ':' . $pass));
+        }
+    }
+
+    /**
+    * Sets basic authentication parameters
+    *
+    * @param string     Username
+    * @param string     Password
+    */
+    function setBasicAuth($user, $pass)
+    {
+        $this->_user = $user;
+        $this->_pass = $pass;
+
+        $this->addHeader('Authorization', 'Basic ' . base64_encode($user . ':' . $pass));
+    }
+
+    /**
+    * Sets the method to be used, GET, POST etc.
+    *
+    * @param string     Method to use. Use the defined constants for this
+    * @access public
+    */
+    function setMethod($method)
+    {
+        $this->_method = $method;
+    }
+
+    /**
+    * Sets the HTTP version to use, 1.0 or 1.1
+    *
+    * @param string     Version to use. Use the defined constants for this
+    * @access public
+    */
+    function setHttpVer($http)
+    {
+        $this->_http = $http;
+    }
+
+    /**
+    * Adds a request header
+    *
+    * @param string     Header name
+    * @param string     Header value
+    * @access public
+    */
+    function addHeader($name, $value)
+    {
+        $this->_requestHeaders[strtolower($name)] = $value;
+    }
+
+    /**
+    * Removes a request header
+    *
+    * @param string     Header name to remove
+    * @access public
+    */
+    function removeHeader($name)
+    {
+        if (isset($this->_requestHeaders[strtolower($name)])) {
+            unset($this->_requestHeaders[strtolower($name)]);
+        }
+    }
+
+    /**
+    * Adds a querystring parameter
+    *
+    * @param string     Querystring parameter name
+    * @param string     Querystring parameter value
+    * @param bool       Whether the value is already urlencoded or not, default = not
+    * @access public
+    */
+    function addQueryString($name, $value, $preencoded = false)
+    {
+        $this->_url->addQueryString($name, $value, $preencoded);
+    }
+
+    /**
+    * Sets the querystring to literally what you supply
+    *
+    * @param string     The querystring data. Should be of the format foo=bar&x=y etc
+    * @param bool       Whether data is already urlencoded or not, default = already encoded
+    * @access public
+    */
+    function addRawQueryString($querystring, $preencoded = true)
+    {
+        $this->_url->addRawQueryString($querystring, $preencoded);
+    }
+
+    /**
+    * Adds postdata items
+    *
+    * @param string     Post data name
+    * @param string     Post data value
+    * @param bool       Whether data is already urlencoded or not, default = not
+    * @access public
+    */
+    function addPostData($name, $value, $preencoded = false)
+    {
+        if ($preencoded) {
+            $this->_postData[$name] = $value;
+        } else {
+            $this->_postData[$name] = $this->_arrayMapRecursive('urlencode', $value);
+        }
+    }
+	
+    function addPostDataArray($array, $preencoded = false)
+    {
+		foreach($array as $key => $val){
+			$this->addPostData($key, $val, $preencoded);
+		}
+    }	
+
+   /**
+    * Recursively applies the callback function to the value
+    *
+    * @param    mixed   Callback function
+    * @param    mixed   Value to process
+    * @access   private
+    * @return   mixed   Processed value
+    */
+    function _arrayMapRecursive($callback, $value)
+    {
+        if (!is_array($value)) {
+            return call_user_func($callback, $value);
+        } else {
+            $map = array();
+            foreach ($value as $k => $v) {
+                $map[$k] = $this->_arrayMapRecursive($callback, $v);
+            }
+            return $map;
+        }
+    }
+
+   /**
+    * Adds a file to form-based file upload
+    *
+    * Used to emulate file upload via a HTML form. The method also sets
+    * Content-Type of HTTP request to 'multipart/form-data'.
+    *
+    * If you just want to send the contents of a file as the body of HTTP
+    * request you should use setBody() method.
+    *
+    * @access public
+    * @param  string    name of file-upload field
+    * @param  mixed     file name(s)
+    * @param  mixed     content-type(s) of file(s) being uploaded
+    * @return bool      true on success
+    * @throws PEAR_Error
+    */
+    function addFile($inputName, $fileName, $contentType = 'application/octet-stream')
+    {
+        if (!is_array($fileName) && !is_readable($fileName)) {
+            return PEAR::raiseError("File '{$fileName}' is not readable", HTTP_REQUEST_ERROR_FILE);
+        } elseif (is_array($fileName)) {
+            foreach ($fileName as $name) {
+                if (!is_readable($name)) {
+                    return PEAR::raiseError("File '{$name}' is not readable", HTTP_REQUEST_ERROR_FILE);
+                }
+            }
+        }
+        $this->addHeader('Content-Type', 'multipart/form-data');
+        $this->_postFiles[$inputName] = array(
+            'name' => $fileName,
+            'type' => $contentType
+        );
+        return true;
+    }
+
+    /**
+    * Adds raw postdata (DEPRECATED)
+    *
+    * @param string     The data
+    * @param bool       Whether data is preencoded or not, default = already encoded
+    * @access public
+    * @deprecated       deprecated since 1.3.0, method setBody() should be used instead
+    */
+    function addRawPostData($postdata, $preencoded = true)
+    {
+        $this->_body = $preencoded ? $postdata : urlencode($postdata);
+    }
+
+   /**
+    * Sets the request body (for POST, PUT and similar requests)
+    *
+    * @param    string  Request body
+    * @access   public
+    */
+    function setBody($body)
+    {
+        $this->_body = $body;
+    }
+
+    /**
+    * Clears any postdata that has been added (DEPRECATED).
+    *
+    * Useful for multiple request scenarios.
+    *
+    * @access public
+    * @deprecated deprecated since 1.2
+    */
+    function clearPostData()
+    {
+        $this->_postData = null;
+    }
+
+    /**
+    * Appends a cookie to "Cookie:" header
+    *
+    * @param string $name cookie name
+    * @param string $value cookie value
+    * @access public
+    */
+    function addCookie($name, $value)
+    {
+        $cookies = isset($this->_requestHeaders['cookie']) ? $this->_requestHeaders['cookie']. '; ' : '';
+        $this->addHeader('Cookie', $cookies . $name . '=' . $value);
+    }
+
+    /**
+    * Clears any cookies that have been added (DEPRECATED).
+    *
+    * Useful for multiple request scenarios
+    *
+    * @access public
+    * @deprecated deprecated since 1.2
+    */
+    function clearCookies()
+    {
+        $this->removeHeader('Cookie');
+    }
+
+    /**
+    * Sends the request
+    *
+    * @access public
+    * @param  bool   Whether to store response body in Response object property,
+    *                set this to false if downloading a LARGE file and using a Listener
+    * @return mixed  PEAR error on error, true otherwise
+    */
+    function sendRequest($saveBody = true)
+    {
+        if (!is_a($this->_url, 'Net_URL')) {
+            return PEAR::raiseError('No URL given', HTTP_REQUEST_ERROR_URL);
+        }
+
+        $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host;
+        $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port;
+
+        if (strcasecmp($this->_url->protocol, 'https') == 0) {
+            // Bug #14127, don't try connecting to HTTPS sites without OpenSSL
+            if (version_compare(PHP_VERSION, '4.3.0', '<') || !extension_loaded('openssl')) {
+                return PEAR::raiseError('Need PHP 4.3.0 or later with OpenSSL support for https:// requests',
+                                        HTTP_REQUEST_ERROR_URL);
+            } elseif (isset($this->_proxy_host)) {
+                return PEAR::raiseError('HTTPS proxies are not supported', HTTP_REQUEST_ERROR_PROXY);
+            }
+            $host = 'ssl://' . $host;
+        }
+
+        // magic quotes may fuck up file uploads and chunked response processing
+        $magicQuotes = ini_get('magic_quotes_runtime');
+        ini_set('magic_quotes_runtime', false);
+
+        // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive
+        // connection token to a proxy server...
+        if (isset($this->_proxy_host) && !empty($this->_requestHeaders['connection']) &&
+            'Keep-Alive' == $this->_requestHeaders['connection'])
+        {
+            $this->removeHeader('connection');
+        }
+
+        $keepAlive = (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && empty($this->_requestHeaders['connection'])) ||
+                     (!empty($this->_requestHeaders['connection']) && 'Keep-Alive' == $this->_requestHeaders['connection']);
+        $sockets   = &PEAR::getStaticProperty('HTTP_Request', 'sockets');
+        $sockKey   = $host . ':' . $port;
+        unset($this->_sock);
+
+        // There is a connected socket in the "static" property?
+        if ($keepAlive && !empty($sockets[$sockKey]) &&
+            !empty($sockets[$sockKey]->fp))
+        {
+            $this->_sock =& $sockets[$sockKey];
+            $err = null;
+        } else {
+            $this->_notify('connect');
+            $this->_sock =& new Net_Socket();
+            $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions);
+        }
+        PEAR::isError($err) or $err = $this->_sock->write($this->_buildRequest());
+
+        if (!PEAR::isError($err)) {
+            if (!empty($this->_readTimeout)) {
+                $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]);
+            }
+
+            $this->_notify('sentRequest');
+
+            // Read the response
+            $this->_response = &new HTTP_Response($this->_sock, $this->_listeners);
+            $err = $this->_response->process(
+                $this->_saveBody && $saveBody,
+                HTTP_REQUEST_METHOD_HEAD != $this->_method
+            );
+
+            if ($keepAlive) {
+                $keepAlive = (isset($this->_response->_headers['content-length'])
+                              || (isset($this->_response->_headers['transfer-encoding'])
+                                  && strtolower($this->_response->_headers['transfer-encoding']) == 'chunked'));
+                if ($keepAlive) {
+                    if (isset($this->_response->_headers['connection'])) {
+                        $keepAlive = strtolower($this->_response->_headers['connection']) == 'keep-alive';
+                    } else {
+                        $keepAlive = 'HTTP/'.HTTP_REQUEST_HTTP_VER_1_1 == $this->_response->_protocol;
+                    }
+                }
+            }
+        }
+
+        ini_set('magic_quotes_runtime', $magicQuotes);
+
+        if (PEAR::isError($err)) {
+            return $err;
+        }
+
+        if (!$keepAlive) {
+            $this->disconnect();
+        // Store the connected socket in "static" property
+        } elseif (empty($sockets[$sockKey]) || empty($sockets[$sockKey]->fp)) {
+            $sockets[$sockKey] =& $this->_sock;
+        }
+
+        // Check for redirection
+        if (    $this->_allowRedirects
+            AND $this->_redirects <= $this->_maxRedirects
+            AND $this->getResponseCode() > 300
+            AND $this->getResponseCode() < 399
+            AND !empty($this->_response->_headers['location'])) {
+
+
+            $redirect = $this->_response->_headers['location'];
+
+            // Absolute URL
+            if (preg_match('/^https?:\/\//i', $redirect)) {
+                $this->_url = &new Net_URL($redirect);
+                $this->addHeader('Host', $this->_generateHostHeader());
+            // Absolute path
+            } elseif ($redirect{0} == '/') {
+                $this->_url->path = $redirect;
+
+            // Relative path
+            } elseif (substr($redirect, 0, 3) == '../' OR substr($redirect, 0, 2) == './') {
+                if (substr($this->_url->path, -1) == '/') {
+                    $redirect = $this->_url->path . $redirect;
+                } else {
+                    $redirect = dirname($this->_url->path) . '/' . $redirect;
+                }
+                $redirect = Net_URL::resolvePath($redirect);
+                $this->_url->path = $redirect;
+
+            // Filename, no path
+            } else {
+                if (substr($this->_url->path, -1) == '/') {
+                    $redirect = $this->_url->path . $redirect;
+                } else {
+                    $redirect = dirname($this->_url->path) . '/' . $redirect;
+                }
+                $this->_url->path = $redirect;
+            }
+
+            $this->_redirects++;
+            return $this->sendRequest($saveBody);
+
+        // Too many redirects
+        } elseif ($this->_allowRedirects AND $this->_redirects > $this->_maxRedirects) {
+            return PEAR::raiseError('Too many redirects', HTTP_REQUEST_ERROR_REDIRECTS);
+        }
+
+        return true;
+    }
+
+    /**
+     * Disconnect the socket, if connected. Only useful if using Keep-Alive.
+     *
+     * @access public
+     */
+    function disconnect()
+    {
+        if (!empty($this->_sock) && !empty($this->_sock->fp)) {
+            $this->_notify('disconnect');
+            $this->_sock->disconnect();
+        }
+    }
+
+    /**
+    * Returns the response code
+    *
+    * @access public
+    * @return mixed     Response code, false if not set
+    */
+    function getResponseCode()
+    {
+        return isset($this->_response->_code) ? $this->_response->_code : false;
+    }
+
+    /**
+    * Returns the response reason phrase
+    *
+    * @access public
+    * @return mixed     Response reason phrase, false if not set
+    */
+    function getResponseReason()
+    {
+        return isset($this->_response->_reason) ? $this->_response->_reason : false;
+    }
+
+    /**
+    * Returns either the named header or all if no name given
+    *
+    * @access public
+    * @param string     The header name to return, do not set to get all headers
+    * @return mixed     either the value of $headername (false if header is not present)
+    *                   or an array of all headers
+    */
+    function getResponseHeader($headername = null)
+    {
+        if (!isset($headername)) {
+            return isset($this->_response->_headers)? $this->_response->_headers: array();
+        } else {
+            $headername = strtolower($headername);
+            return isset($this->_response->_headers[$headername]) ? $this->_response->_headers[$headername] : false;
+        }
+    }
+
+    /**
+    * Returns the body of the response
+    *
+    * @access public
+    * @return mixed     response body, false if not set
+    */
+    function getResponseBody()
+    {
+        return isset($this->_response->_body) ? $this->_response->_body : false;
+    }
+
+    /**
+    * Returns cookies set in response
+    *
+    * @access public
+    * @return mixed     array of response cookies, false if none are present
+    */
+    function getResponseCookies()
+    {
+        return isset($this->_response->_cookies) ? $this->_response->_cookies : false;
+    }
+
+    /**
+    * Builds the request string
+    *
+    * @access private
+    * @return string The request string
+    */
+    function _buildRequest()
+    {
+        $separator = ini_get('arg_separator.output');
+        ini_set('arg_separator.output', '&');
+        $querystring = ($querystring = $this->_url->getQueryString()) ? '?' . $querystring : '';
+        ini_set('arg_separator.output', $separator);
+
+        $host = isset($this->_proxy_host) ? $this->_url->protocol . '://' . $this->_url->host : '';
+        $port = (isset($this->_proxy_host) AND $this->_url->port != 80) ? ':' . $this->_url->port : '';
+        $path = $this->_url->path . $querystring;
+        $url  = $host . $port . $path;
+
+        if (!strlen($url)) {
+            $url = '/';
+        }
+
+        $request = $this->_method . ' ' . $url . ' HTTP/' . $this->_http . "\r\n";
+
+        if (in_array($this->_method, $this->_bodyDisallowed) ||
+            (0 == strlen($this->_body) && (HTTP_REQUEST_METHOD_POST != $this->_method ||
+             (empty($this->_postData) && empty($this->_postFiles)))))
+        {
+            $this->removeHeader('Content-Type');
+        } else {
+            if (empty($this->_requestHeaders['content-type'])) {
+                // Add default content-type
+                $this->addHeader('Content-Type', 'application/x-www-form-urlencoded');
+            } elseif ('multipart/form-data' == $this->_requestHeaders['content-type']) {
+                $boundary = 'HTTP_Request_' . md5(uniqid('request') . microtime());
+                $this->addHeader('Content-Type', 'multipart/form-data; boundary=' . $boundary);
+            }
+        }
+
+        // Request Headers
+        if (!empty($this->_requestHeaders)) {
+            foreach ($this->_requestHeaders as $name => $value) {
+                $canonicalName = implode('-', array_map('ucfirst', explode('-', $name)));
+                $request      .= $canonicalName . ': ' . $value . "\r\n";
+            }
+        }
+
+        // Method does not allow a body, simply add a final CRLF
+        if (in_array($this->_method, $this->_bodyDisallowed)) {
+
+            $request .= "\r\n";
+
+        // Post data if it's an array
+        } elseif (HTTP_REQUEST_METHOD_POST == $this->_method &&
+                  (!empty($this->_postData) || !empty($this->_postFiles))) {
+
+            // "normal" POST request
+            if (!isset($boundary)) {
+                $postdata = implode('&', array_map(
+                    create_function('$a', 'return $a[0] . \'=\' . $a[1];'),
+                    $this->_flattenArray('', $this->_postData)
+                ));
+
+            // multipart request, probably with file uploads
+            } else {
+                $postdata = '';
+                if (!empty($this->_postData)) {
+                    $flatData = $this->_flattenArray('', $this->_postData);
+                    foreach ($flatData as $item) {
+                        $postdata .= '--' . $boundary . "\r\n";
+                        $postdata .= 'Content-Disposition: form-data; name="' . $item[0] . '"';
+                        $postdata .= "\r\n\r\n" . urldecode($item[1]) . "\r\n";
+                    }
+                }
+                foreach ($this->_postFiles as $name => $value) {
+                    if (is_array($value['name'])) {
+                        $varname       = $name . ($this->_useBrackets? '[]': '');
+                    } else {
+                        $varname       = $name;
+                        $value['name'] = array($value['name']);
+                    }
+                    foreach ($value['name'] as $key => $filename) {
+                        $fp       = fopen($filename, 'r');
+                        $basename = basename($filename);
+                        $type     = is_array($value['type'])? @$value['type'][$key]: $value['type'];
+
+                        $postdata .= '--' . $boundary . "\r\n";
+                        $postdata .= 'Content-Disposition: form-data; name="' . $varname . '"; filename="' . $basename . '"';
+                        $postdata .= "\r\nContent-Type: " . $type;
+                        $postdata .= "\r\n\r\n" . fread($fp, filesize($filename)) . "\r\n";
+                        fclose($fp);
+                    }
+                }
+                $postdata .= '--' . $boundary . "--\r\n";
+            }
+            $request .= 'Content-Length: ' .
+                        (HTTP_REQUEST_MBSTRING? mb_strlen($postdata, 'iso-8859-1'): strlen($postdata)) .
+                        "\r\n\r\n";
+            $request .= $postdata;
+
+        // Explicitly set request body
+        } elseif (0 < strlen($this->_body)) {
+
+            $request .= 'Content-Length: ' .
+                        (HTTP_REQUEST_MBSTRING? mb_strlen($this->_body, 'iso-8859-1'): strlen($this->_body)) .
+                        "\r\n\r\n";
+            $request .= $this->_body;
+
+        // No body: send a Content-Length header nonetheless (request #12900),
+        // but do that only for methods that require a body (bug #14740)
+        } else {
+
+            if (in_array($this->_method, $this->_bodyRequired)) {
+                $request .= "Content-Length: 0\r\n";
+            }
+            $request .= "\r\n";
+        }
+
+        return $request;
+    }
+
+   /**
+    * Helper function to change the (probably multidimensional) associative array
+    * into the simple one.
+    *
+    * @param    string  name for item
+    * @param    mixed   item's values
+    * @return   array   array with the following items: array('item name', 'item value');
+    * @access   private
+    */
+    function _flattenArray($name, $values)
+    {
+        if (!is_array($values)) {
+            return array(array($name, $values));
+        } else {
+            $ret = array();
+            foreach ($values as $k => $v) {
+                if (empty($name)) {
+                    $newName = $k;
+                } elseif ($this->_useBrackets) {
+                    $newName = $name . '[' . $k . ']';
+                } else {
+                    $newName = $name;
+                }
+                $ret = array_merge($ret, $this->_flattenArray($newName, $v));
+            }
+            return $ret;
+        }
+    }
+
+
+   /**
+    * Adds a Listener to the list of listeners that are notified of
+    * the object's events
+    *
+    * Events sent by HTTP_Request object
+    * - 'connect': on connection to server
+    * - 'sentRequest': after the request was sent
+    * - 'disconnect': on disconnection from server
+    *
+    * Events sent by HTTP_Response object
+    * - 'gotHeaders': after receiving response headers (headers are passed in $data)
+    * - 'tick': on receiving a part of response body (the part is passed in $data)
+    * - 'gzTick': on receiving a gzip-encoded part of response body (ditto)
+    * - 'gotBody': after receiving the response body (passes the decoded body in $data if it was gzipped)
+    *
+    * @param    HTTP_Request_Listener   listener to attach
+    * @return   boolean                 whether the listener was successfully attached
+    * @access   public
+    */
+    function attach(&$listener)
+    {
+        if (!is_a($listener, 'HTTP_Request_Listener')) {
+            return false;
+        }
+        $this->_listeners[$listener->getId()] =& $listener;
+        return true;
+    }
+
+
+   /**
+    * Removes a Listener from the list of listeners
+    *
+    * @param    HTTP_Request_Listener   listener to detach
+    * @return   boolean                 whether the listener was successfully detached
+    * @access   public
+    */
+    function detach(&$listener)
+    {
+        if (!is_a($listener, 'HTTP_Request_Listener') ||
+            !isset($this->_listeners[$listener->getId()])) {
+            return false;
+        }
+        unset($this->_listeners[$listener->getId()]);
+        return true;
+    }
+
+
+   /**
+    * Notifies all registered listeners of an event.
+    *
+    * @param    string  Event name
+    * @param    mixed   Additional data
+    * @access   private
+    * @see      HTTP_Request::attach()
+    */
+    function _notify($event, $data = null)
+    {
+        foreach (array_keys($this->_listeners) as $id) {
+            $this->_listeners[$id]->update($this, $event, $data);
+        }
+    }
+}
+
+
+/**
+ * Response class to complement the Request class
+ *
+ * @category    HTTP
+ * @package     HTTP_Request
+ * @author      Richard Heyes <richard@phpguru.org>
+ * @author      Alexey Borzov <avb@php.net>
+ * @version     Release: 1.4.4
+ */
+class HTTP_Response
+{
+    /**
+    * Socket object
+    * @var Net_Socket
+    */
+    var $_sock;
+
+    /**
+    * Protocol
+    * @var string
+    */
+    var $_protocol;
+
+    /**
+    * Return code
+    * @var string
+    */
+    var $_code;
+
+    /**
+    * Response reason phrase
+    * @var string
+    */
+    var $_reason;
+
+    /**
+    * Response headers
+    * @var array
+    */
+    var $_headers;
+
+    /**
+    * Cookies set in response
+    * @var array
+    */
+    var $_cookies;
+
+    /**
+    * Response body
+    * @var string
+    */
+    var $_body = '';
+
+   /**
+    * Used by _readChunked(): remaining length of the current chunk
+    * @var string
+    */
+    var $_chunkLength = 0;
+
+   /**
+    * Attached listeners
+    * @var array
+    */
+    var $_listeners = array();
+
+   /**
+    * Bytes left to read from message-body
+    * @var null|int
+    */
+    var $_toRead;
+
+    /**
+    * Constructor
+    *
+    * @param  Net_Socket    socket to read the response from
+    * @param  array         listeners attached to request
+    */
+    function HTTP_Response(&$sock, &$listeners)
+    {
+        $this->_sock      =& $sock;
+        $this->_listeners =& $listeners;
+    }
+
+
+   /**
+    * Processes a HTTP response
+    *
+    * This extracts response code, headers, cookies and decodes body if it
+    * was encoded in some way
+    *
+    * @access public
+    * @param  bool      Whether to store response body in object property, set
+    *                   this to false if downloading a LARGE file and using a Listener.
+    *                   This is assumed to be true if body is gzip-encoded.
+    * @param  bool      Whether the response can actually have a message-body.
+    *                   Will be set to false for HEAD requests.
+    * @throws PEAR_Error
+    * @return mixed     true on success, PEAR_Error in case of malformed response
+    */
+    function process($saveBody = true, $canHaveBody = true)
+    {
+        do {
+            $line = $this->_sock->readLine();
+            if (!preg_match('!^(HTTP/\d\.\d) (\d{3})(?: (.+))?!', $line, $s)) {
+                return PEAR::raiseError('Malformed response', HTTP_REQUEST_ERROR_RESPONSE);
+            } else {
+                $this->_protocol = $s[1];
+                $this->_code     = intval($s[2]);
+                $this->_reason   = empty($s[3])? null: $s[3];
+            }
+            while ('' !== ($header = $this->_sock->readLine())) {
+                $this->_processHeader($header);
+            }
+        } while (100 == $this->_code);
+
+        $this->_notify('gotHeaders', $this->_headers);
+
+        // RFC 2616, section 4.4:
+        // 1. Any response message which "MUST NOT" include a message-body ...
+        // is always terminated by the first empty line after the header fields
+        // 3. ... If a message is received with both a
+        // Transfer-Encoding header field and a Content-Length header field,
+        // the latter MUST be ignored.
+        $canHaveBody = $canHaveBody && $this->_code >= 200 &&
+                       $this->_code != 204 && $this->_code != 304;
+
+        // If response body is present, read it and decode
+        $chunked = isset($this->_headers['transfer-encoding']) && ('chunked' == $this->_headers['transfer-encoding']);
+        $gzipped = isset($this->_headers['content-encoding']) && ('gzip' == $this->_headers['content-encoding']);
+        $hasBody = false;
+        if ($canHaveBody && ($chunked || !isset($this->_headers['content-length']) ||
+                0 != $this->_headers['content-length']))
+        {
+            if ($chunked || !isset($this->_headers['content-length'])) {
+                $this->_toRead = null;
+            } else {
+                $this->_toRead = $this->_headers['content-length'];
+            }
+            while (!$this->_sock->eof() && (is_null($this->_toRead) || 0 < $this->_toRead)) {
+                if ($chunked) {
+                    $data = $this->_readChunked();
+                } elseif (is_null($this->_toRead)) {
+                    $data = $this->_sock->read(4096);
+                } else {
+                    $data = $this->_sock->read(min(4096, $this->_toRead));
+                    $this->_toRead -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data);
+                }
+                if ('' == $data && (!$this->_chunkLength || $this->_sock->eof())) {
+                    break;
+                } else {
+                    $hasBody = true;
+                    if ($saveBody || $gzipped) {
+                        $this->_body .= $data;
+                    }
+                    $this->_notify($gzipped? 'gzTick': 'tick', $data);
+                }
+            }
+        }
+
+        if ($hasBody) {
+            // Uncompress the body if needed
+            if ($gzipped) {
+                $body = $this->_decodeGzip($this->_body);
+                if (PEAR::isError($body)) {
+                    return $body;
+                }
+                $this->_body = $body;
+                $this->_notify('gotBody', $this->_body);
+            } else {
+                $this->_notify('gotBody');
+            }
+        }
+        return true;
+    }
+
+
+   /**
+    * Processes the response header
+    *
+    * @access private
+    * @param  string    HTTP header
+    */
+    function _processHeader($header)
+    {
+        if (false === strpos($header, ':')) {
+            return;
+        }
+        list($headername, $headervalue) = explode(':', $header, 2);
+        $headername  = strtolower($headername);
+        $headervalue = ltrim($headervalue);
+
+        if ('set-cookie' != $headername) {
+            if (isset($this->_headers[$headername])) {
+                $this->_headers[$headername] .= ',' . $headervalue;
+            } else {
+                $this->_headers[$headername]  = $headervalue;
+            }
+        } else {
+            $this->_parseCookie($headervalue);
+        }
+    }
+
+
+   /**
+    * Parse a Set-Cookie header to fill $_cookies array
+    *
+    * @access private
+    * @param  string    value of Set-Cookie header
+    */
+    function _parseCookie($headervalue)
+    {
+        $cookie = array(
+            'expires' => null,
+            'domain'  => null,
+            'path'    => null,
+            'secure'  => false
+        );
+
+        // Only a name=value pair
+        if (!strpos($headervalue, ';')) {
+            $pos = strpos($headervalue, '=');
+            $cookie['name']  = trim(substr($headervalue, 0, $pos));
+            $cookie['value'] = trim(substr($headervalue, $pos + 1));
+
+        // Some optional parameters are supplied
+        } else {
+            $elements = explode(';', $headervalue);
+            $pos = strpos($elements[0], '=');
+            $cookie['name']  = trim(substr($elements[0], 0, $pos));
+            $cookie['value'] = trim(substr($elements[0], $pos + 1));
+
+            for ($i = 1; $i < count($elements); $i++) {
+                if (false === strpos($elements[$i], '=')) {
+                    $elName  = trim($elements[$i]);
+                    $elValue = null;
+                } else {
+                    list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i]));
+                }
+                $elName = strtolower($elName);
+                if ('secure' == $elName) {
+                    $cookie['secure'] = true;
+                } elseif ('expires' == $elName) {
+                    $cookie['expires'] = str_replace('"', '', $elValue);
+                } elseif ('path' == $elName || 'domain' == $elName) {
+                    $cookie[$elName] = urldecode($elValue);
+                } else {
+                    $cookie[$elName] = $elValue;
+                }
+            }
+        }
+        $this->_cookies[] = $cookie;
+    }
+
+
+   /**
+    * Read a part of response body encoded with chunked Transfer-Encoding
+    *
+    * @access private
+    * @return string
+    */
+    function _readChunked()
+    {
+        // at start of the next chunk?
+        if (0 == $this->_chunkLength) {
+            $line = $this->_sock->readLine();
+            if (preg_match('/^([0-9a-f]+)/i', $line, $matches)) {
+                $this->_chunkLength = hexdec($matches[1]);
+                // Chunk with zero length indicates the end
+                if (0 == $this->_chunkLength) {
+                    $this->_sock->readLine(); // make this an eof()
+                    return '';
+                }
+            } else {
+                return '';
+            }
+        }
+        $data = $this->_sock->read($this->_chunkLength);
+        $this->_chunkLength -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data);
+        if (0 == $this->_chunkLength) {
+            $this->_sock->readLine(); // Trailing CRLF
+        }
+        return $data;
+    }
+
+
+   /**
+    * Notifies all registered listeners of an event.
+    *
+    * @param    string  Event name
+    * @param    mixed   Additional data
+    * @access   private
+    * @see HTTP_Request::_notify()
+    */
+    function _notify($event, $data = null)
+    {
+        foreach (array_keys($this->_listeners) as $id) {
+            $this->_listeners[$id]->update($this, $event, $data);
+        }
+    }
+
+
+   /**
+    * Decodes the message-body encoded by gzip
+    *
+    * The real decoding work is done by gzinflate() built-in function, this
+    * method only parses the header and checks data for compliance with
+    * RFC 1952
+    *
+    * @access   private
+    * @param    string  gzip-encoded data
+    * @return   string  decoded data
+    */
+    function _decodeGzip($data)
+    {
+        if (HTTP_REQUEST_MBSTRING) {
+            $oldEncoding = mb_internal_encoding();
+            mb_internal_encoding('iso-8859-1');
+        }
+        $length = strlen($data);
+        // If it doesn't look like gzip-encoded data, don't bother
+        if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) {
+            return $data;
+        }
+        $method = ord(substr($data, 2, 1));
+        if (8 != $method) {
+            return PEAR::raiseError('_decodeGzip(): unknown compression method', HTTP_REQUEST_ERROR_GZIP_METHOD);
+        }
+        $flags = ord(substr($data, 3, 1));
+        if ($flags & 224) {
+            return PEAR::raiseError('_decodeGzip(): reserved bits are set', HTTP_REQUEST_ERROR_GZIP_DATA);
+        }
+
+        // header is 10 bytes minimum. may be longer, though.
+        $headerLength = 10;
+        // extra fields, need to skip 'em
+        if ($flags & 4) {
+            if ($length - $headerLength - 2 < 8) {
+                return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA);
+            }
+            $extraLength = unpack('v', substr($data, 10, 2));
+            if ($length - $headerLength - 2 - $extraLength[1] < 8) {
+                return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA);
+            }
+            $headerLength += $extraLength[1] + 2;
+        }
+        // file name, need to skip that
+        if ($flags & 8) {
+            if ($length - $headerLength - 1 < 8) {
+                return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA);
+            }
+            $filenameLength = strpos(substr($data, $headerLength), chr(0));
+            if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) {
+                return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA);
+            }
+            $headerLength += $filenameLength + 1;
+        }
+        // comment, need to skip that also
+        if ($flags & 16) {
+            if ($length - $headerLength - 1 < 8) {
+                return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA);
+            }
+            $commentLength = strpos(substr($data, $headerLength), chr(0));
+            if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) {
+                return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA);
+            }
+            $headerLength += $commentLength + 1;
+        }
+        // have a CRC for header. let's check
+        if ($flags & 1) {
+            if ($length - $headerLength - 2 < 8) {
+                return PEAR::raiseError('_decodeGzip(): data too short', HTTP_REQUEST_ERROR_GZIP_DATA);
+            }
+            $crcReal   = 0xffff & crc32(substr($data, 0, $headerLength));
+            $crcStored = unpack('v', substr($data, $headerLength, 2));
+            if ($crcReal != $crcStored[1]) {
+                return PEAR::raiseError('_decodeGzip(): header CRC check failed', HTTP_REQUEST_ERROR_GZIP_CRC);
+            }
+            $headerLength += 2;
+        }
+        // unpacked data CRC and size at the end of encoded data
+        $tmp = unpack('V2', substr($data, -8));
+        $dataCrc  = $tmp[1];
+        $dataSize = $tmp[2];
+
+        // finally, call the gzinflate() function
+        // don't pass $dataSize to gzinflate, see bugs #13135, #14370
+        $unpacked = gzinflate(substr($data, $headerLength, -8));
+        if (false === $unpacked) {
+            return PEAR::raiseError('_decodeGzip(): gzinflate() call failed', HTTP_REQUEST_ERROR_GZIP_READ);
+        } elseif ($dataSize != strlen($unpacked)) {
+            return PEAR::raiseError('_decodeGzip(): data size check failed', HTTP_REQUEST_ERROR_GZIP_READ);
+        } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) {
+            return PEAR::raiseError('_decodeGzip(): data CRC check failed', HTTP_REQUEST_ERROR_GZIP_CRC);
+        }
+        if (HTTP_REQUEST_MBSTRING) {
+            mb_internal_encoding($oldEncoding);
+        }
+        return $unpacked;
+    }
+} // End class HTTP_Response
+?>
+>>>>>>> .merge-right.r23124
Index: anches/version-2_13-dev/data/module/HTTP/Request2.php
===================================================================
--- /branches/version-2_13-dev/data/module/HTTP/Request2.php	(revision 23125)
+++ 	(revision )
@@ -1,1050 +1,0 @@
-<?php
-/**
- * Class representing a HTTP request message
- *
- * PHP version 5
- *
- * LICENSE:
- *
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *    * Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *    * Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *    * The names of the authors may not be used to endorse or promote products
- *      derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category HTTP
- * @package  HTTP_Request2
- * @author   Alexey Borzov <avb@php.net>
- * @license  http://opensource.org/licenses/bsd-license.php New BSD License
- * @version  SVN: $Id: Request2.php 324936 2012-04-07 07:49:03Z avb $
- * @link     http://pear.php.net/package/HTTP_Request2
- */
-
-/**
- * A class representing an URL as per RFC 3986.
- */
-require_once 'Net/URL2.php';
-
-/**
- * Exception class for HTTP_Request2 package
- */
-require_once 'HTTP/Request2/Exception.php';
-
-/**
- * Class representing a HTTP request message
- *
- * @category HTTP
- * @package  HTTP_Request2
- * @author   Alexey Borzov <avb@php.net>
- * @license  http://opensource.org/licenses/bsd-license.php New BSD License
- * @version  Release: 2.1.1
- * @link     http://pear.php.net/package/HTTP_Request2
- * @link     http://tools.ietf.org/html/rfc2616#section-5
- */
-class HTTP_Request2 implements SplSubject
-{
-    /**#@+
-     * Constants for HTTP request methods
-     *
-     * @link http://tools.ietf.org/html/rfc2616#section-5.1.1
-     */
-    const METHOD_OPTIONS = 'OPTIONS';
-    const METHOD_GET     = 'GET';
-    const METHOD_HEAD    = 'HEAD';
-    const METHOD_POST    = 'POST';
-    const METHOD_PUT     = 'PUT';
-    const METHOD_DELETE  = 'DELETE';
-    const METHOD_TRACE   = 'TRACE';
-    const METHOD_CONNECT = 'CONNECT';
-    /**#@-*/
-
-    /**#@+
-     * Constants for HTTP authentication schemes
-     *
-     * @link http://tools.ietf.org/html/rfc2617
-     */
-    const AUTH_BASIC  = 'basic';
-    const AUTH_DIGEST = 'digest';
-    /**#@-*/
-
-    /**
-     * Regular expression used to check for invalid symbols in RFC 2616 tokens
-     * @link http://pear.php.net/bugs/bug.php?id=15630
-     */
-    const REGEXP_INVALID_TOKEN = '![\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]!';
-
-    /**
-     * Regular expression used to check for invalid symbols in cookie strings
-     * @link http://pear.php.net/bugs/bug.php?id=15630
-     * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html
-     */
-    const REGEXP_INVALID_COOKIE = '/[\s,;]/';
-
-    /**
-     * Fileinfo magic database resource
-     * @var  resource
-     * @see  detectMimeType()
-     */
-    private static $_fileinfoDb;
-
-    /**
-     * Observers attached to the request (instances of SplObserver)
-     * @var  array
-     */
-    protected $observers = array();
-
-    /**
-     * Request URL
-     * @var  Net_URL2
-     */
-    protected $url;
-
-    /**
-     * Request method
-     * @var  string
-     */
-    protected $method = self::METHOD_GET;
-
-    /**
-     * Authentication data
-     * @var  array
-     * @see  getAuth()
-     */
-    protected $auth;
-
-    /**
-     * Request headers
-     * @var  array
-     */
-    protected $headers = array();
-
-    /**
-     * Configuration parameters
-     * @var  array
-     * @see  setConfig()
-     */
-    protected $config = array(
-        'adapter'           => 'HTTP_Request2_Adapter_Socket',
-        'connect_timeout'   => 10,
-        'timeout'           => 0,
-        'use_brackets'      => true,
-        'protocol_version'  => '1.1',
-        'buffer_size'       => 16384,
-        'store_body'        => true,
-
-        'proxy_host'        => '',
-        'proxy_port'        => '',
-        'proxy_user'        => '',
-        'proxy_password'    => '',
-        'proxy_auth_scheme' => self::AUTH_BASIC,
-        'proxy_type'        => 'http',
-
-        'ssl_verify_peer'   => true,
-        'ssl_verify_host'   => true,
-        'ssl_cafile'        => null,
-        'ssl_capath'        => null,
-        'ssl_local_cert'    => null,
-        'ssl_passphrase'    => null,
-
-        'digest_compat_ie'  => false,
-
-        'follow_redirects'  => false,
-        'max_redirects'     => 5,
-        'strict_redirects'  => false
-    );
-
-    /**
-     * Last event in request / response handling, intended for observers
-     * @var  array
-     * @see  getLastEvent()
-     */
-    protected $lastEvent = array(
-        'name' => 'start',
-        'data' => null
-    );
-
-    /**
-     * Request body
-     * @var  string|resource
-     * @see  setBody()
-     */
-    protected $body = '';
-
-    /**
-     * Array of POST parameters
-     * @var  array
-     */
-    protected $postParams = array();
-
-    /**
-     * Array of file uploads (for multipart/form-data POST requests)
-     * @var  array
-     */
-    protected $uploads = array();
-
-    /**
-     * Adapter used to perform actual HTTP request
-     * @var  HTTP_Request2_Adapter
-     */
-    protected $adapter;
-
-    /**
-     * Cookie jar to persist cookies between requests
-     * @var HTTP_Request2_CookieJar
-     */
-    protected $cookieJar = null;
-
-    /**
-     * Constructor. Can set request URL, method and configuration array.
-     *
-     * Also sets a default value for User-Agent header.
-     *
-     * @param string|Net_Url2 $url    Request URL
-     * @param string          $method Request method
-     * @param array           $config Configuration for this Request instance
-     */
-    public function __construct(
-        $url = null, $method = self::METHOD_GET, array $config = array()
-    ) {
-        $this->setConfig($config);
-        if (!empty($url)) {
-            $this->setUrl($url);
-        }
-        if (!empty($method)) {
-            $this->setMethod($method);
-        }
-        $this->setHeader(
-            'user-agent', 'HTTP_Request2/2.1.1 ' .
-            '(http://pear.php.net/package/http_request2) PHP/' . phpversion()
-        );
-    }
-
-    /**
-     * Sets the URL for this request
-     *
-     * If the URL has userinfo part (username & password) these will be removed
-     * and converted to auth data. If the URL does not have a path component,
-     * that will be set to '/'.
-     *
-     * @param string|Net_URL2 $url Request URL
-     *
-     * @return   HTTP_Request2
-     * @throws   HTTP_Request2_LogicException
-     */
-    public function setUrl($url)
-    {
-        if (is_string($url)) {
-            $url = new Net_URL2(
-                $url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets'])
-            );
-        }
-        if (!$url instanceof Net_URL2) {
-            throw new HTTP_Request2_LogicException(
-                'Parameter is not a valid HTTP URL',
-                HTTP_Request2_Exception::INVALID_ARGUMENT
-            );
-        }
-        // URL contains username / password?
-        if ($url->getUserinfo()) {
-            $username = $url->getUser();
-            $password = $url->getPassword();
-            $this->setAuth(rawurldecode($username), $password? rawurldecode($password): '');
-            $url->setUserinfo('');
-        }
-        if ('' == $url->getPath()) {
-            $url->setPath('/');
-        }
-        $this->url = $url;
-
-        return $this;
-    }
-
-    /**
-     * Returns the request URL
-     *
-     * @return   Net_URL2
-     */
-    public function getUrl()
-    {
-        return $this->url;
-    }
-
-    /**
-     * Sets the request method
-     *
-     * @param string $method one of the methods defined in RFC 2616
-     *
-     * @return   HTTP_Request2
-     * @throws   HTTP_Request2_LogicException if the method name is invalid
-     */
-    public function setMethod($method)
-    {
-        // Method name should be a token: http://tools.ietf.org/html/rfc2616#section-5.1.1
-        if (preg_match(self::REGEXP_INVALID_TOKEN, $method)) {
-            throw new HTTP_Request2_LogicException(
-                "Invalid request method '{$method}'",
-                HTTP_Request2_Exception::INVALID_ARGUMENT
-            );
-        }
-        $this->method = $method;
-
-        return $this;
-    }
-
-    /**
-     * Returns the request method
-     *
-     * @return   string
-     */
-    public function getMethod()
-    {
-        return $this->method;
-    }
-
-    /**
-     * Sets the configuration parameter(s)
-     *
-     * The following parameters are available:
-     * <ul>
-     *   <li> 'adapter'           - adapter to use (string)</li>
-     *   <li> 'connect_timeout'   - Connection timeout in seconds (integer)</li>
-     *   <li> 'timeout'           - Total number of seconds a request can take.
-     *                              Use 0 for no limit, should be greater than
-     *                              'connect_timeout' if set (integer)</li>
-     *   <li> 'use_brackets'      - Whether to append [] to array variable names (bool)</li>
-     *   <li> 'protocol_version'  - HTTP Version to use, '1.0' or '1.1' (string)</li>
-     *   <li> 'buffer_size'       - Buffer size to use for reading and writing (int)</li>
-     *   <li> 'store_body'        - Whether to store response body in response object.
-     *                              Set to false if receiving a huge response and
-     *                              using an Observer to save it (boolean)</li>
-     *   <li> 'proxy_type'        - Proxy type, 'http' or 'socks5' (string)</li>
-     *   <li> 'proxy_host'        - Proxy server host (string)</li>
-     *   <li> 'proxy_port'        - Proxy server port (integer)</li>
-     *   <li> 'proxy_user'        - Proxy auth username (string)</li>
-     *   <li> 'proxy_password'    - Proxy auth password (string)</li>
-     *   <li> 'proxy_auth_scheme' - Proxy auth scheme, one of HTTP_Request2::AUTH_* constants (string)</li>
-     *   <li> 'proxy'             - Shorthand for proxy_* parameters, proxy given as URL,
-     *                              e.g. 'socks5://localhost:1080/' (string)</li>
-     *   <li> 'ssl_verify_peer'   - Whether to verify peer's SSL certificate (bool)</li>
-     *   <li> 'ssl_verify_host'   - Whether to check that Common Name in SSL
-     *                              certificate matches host name (bool)</li>
-     *   <li> 'ssl_cafile'        - Cerificate Authority file to verify the peer
-     *                              with (use with 'ssl_verify_peer') (string)</li>
-     *   <li> 'ssl_capath'        - Directory holding multiple Certificate
-     *                              Authority files (string)</li>
-     *   <li> 'ssl_local_cert'    - Name of a file containing local cerificate (string)</li>
-     *   <li> 'ssl_passphrase'    - Passphrase with which local certificate
-     *                              was encoded (string)</li>
-     *   <li> 'digest_compat_ie'  - Whether to imitate behaviour of MSIE 5 and 6
-     *                              in using URL without query string in digest
-     *                              authentication (boolean)</li>
-     *   <li> 'follow_redirects'  - Whether to automatically follow HTTP Redirects (boolean)</li>
-     *   <li> 'max_redirects'     - Maximum number of redirects to follow (integer)</li>
-     *   <li> 'strict_redirects'  - Whether to keep request method on redirects via status 301 and
-     *                              302 (true, needed for compatibility with RFC 2616)
-     *                              or switch to GET (false, needed for compatibility with most
-     *                              browsers) (boolean)</li>
-     * </ul>
-     *
-     * @param string|array $nameOrConfig configuration parameter name or array
-     *                                   ('parameter name' => 'parameter value')
-     * @param mixed        $value        parameter value if $nameOrConfig is not an array
-     *
-     * @return   HTTP_Request2
-     * @throws   HTTP_Request2_LogicException If the parameter is unknown
-     */
-    public function setConfig($nameOrConfig, $value = null)
-    {
-        if (is_array($nameOrConfig)) {
-            foreach ($nameOrConfig as $name => $value) {
-                $this->setConfig($name, $value);
-            }
-
-        } elseif ('proxy' == $nameOrConfig) {
-            $url = new Net_URL2($value);
-            $this->setConfig(array(
-                'proxy_type'     => $url->getScheme(),
-                'proxy_host'     => $url->getHost(),
-                'proxy_port'     => $url->getPort(),
-                'proxy_user'     => rawurldecode($url->getUser()),
-                'proxy_password' => rawurldecode($url->getPassword())
-            ));
-
-        } else {
-            if (!array_key_exists($nameOrConfig, $this->config)) {
-                throw new HTTP_Request2_LogicException(
-                    "Unknown configuration parameter '{$nameOrConfig}'",
-                    HTTP_Request2_Exception::INVALID_ARGUMENT
-                );
-            }
-            $this->config[$nameOrConfig] = $value;
-        }
-
-        return $this;
-    }
-
-    /**
-     * Returns the value(s) of the configuration parameter(s)
-     *
-     * @param string $name parameter name
-     *
-     * @return   mixed   value of $name parameter, array of all configuration
-     *                   parameters if $name is not given
-     * @throws   HTTP_Request2_LogicException If the parameter is unknown
-     */
-    public function getConfig($name = null)
-    {
-        if (null === $name) {
-            return $this->config;
-        } elseif (!array_key_exists($name, $this->config)) {
-            throw new HTTP_Request2_LogicException(
-                "Unknown configuration parameter '{$name}'",
-                HTTP_Request2_Exception::INVALID_ARGUMENT
-            );
-        }
-        return $this->config[$name];
-    }
-
-    /**
-     * Sets the autentification data
-     *
-     * @param string $user     user name
-     * @param string $password password
-     * @param string $scheme   authentication scheme
-     *
-     * @return   HTTP_Request2
-     */
-    public function setAuth($user, $password = '', $scheme = self::AUTH_BASIC)
-    {
-        if (empty($user)) {
-            $this->auth = null;
-        } else {
-            $this->auth = array(
-                'user'     => (string)$user,
-                'password' => (string)$password,
-                'scheme'   => $scheme
-            );
-        }
-
-        return $this;
-    }
-
-    /**
-     * Returns the authentication data
-     *
-     * The array has the keys 'user', 'password' and 'scheme', where 'scheme'
-     * is one of the HTTP_Request2::AUTH_* constants.
-     *
-     * @return   array
-     */
-    public function getAuth()
-    {
-        return $this->auth;
-    }
-
-    /**
-     * Sets request header(s)
-     *
-     * The first parameter may be either a full header string 'header: value' or
-     * header name. In the former case $value parameter is ignored, in the latter
-     * the header's value will either be set to $value or the header will be
-     * removed if $value is null. The first parameter can also be an array of
-     * headers, in that case method will be called recursively.
-     *
-     * Note that headers are treated case insensitively as per RFC 2616.
-     *
-     * <code>
-     * $req->setHeader('Foo: Bar'); // sets the value of 'Foo' header to 'Bar'
-     * $req->setHeader('FoO', 'Baz'); // sets the value of 'Foo' header to 'Baz'
-     * $req->setHeader(array('foo' => 'Quux')); // sets the value of 'Foo' header to 'Quux'
-     * $req->setHeader('FOO'); // removes 'Foo' header from request
-     * </code>
-     *
-     * @param string|array      $name    header name, header string ('Header: value')
-     *                                   or an array of headers
-     * @param string|array|null $value   header value if $name is not an array,
-     *                                   header will be removed if value is null
-     * @param bool              $replace whether to replace previous header with the
-     *                                   same name or append to its value
-     *
-     * @return   HTTP_Request2
-     * @throws   HTTP_Request2_LogicException
-     */
-    public function setHeader($name, $value = null, $replace = true)
-    {
-        if (is_array($name)) {
-            foreach ($name as $k => $v) {
-                if (is_string($k)) {
-                    $this->setHeader($k, $v, $replace);
-                } else {
-                    $this->setHeader($v, null, $replace);
-                }
-            }
-        } else {
-            if (null === $value && strpos($name, ':')) {
-                list($name, $value) = array_map('trim', explode(':', $name, 2));
-            }
-            // Header name should be a token: http://tools.ietf.org/html/rfc2616#section-4.2
-            if (preg_match(self::REGEXP_INVALID_TOKEN, $name)) {
-                throw new HTTP_Request2_LogicException(
-                    "Invalid header name '{$name}'",
-                    HTTP_Request2_Exception::INVALID_ARGUMENT
-                );
-            }
-            // Header names are case insensitive anyway
-            $name = strtolower($name);
-            if (null === $value) {
-                unset($this->headers[$name]);
-
-            } else {
-                if (is_array($value)) {
-                    $value = implode(', ', array_map('trim', $value));
-                } elseif (is_string($value)) {
-                    $value = trim($value);
-                }
-                if (!isset($this->headers[$name]) || $replace) {
-                    $this->headers[$name] = $value;
-                } else {
-                    $this->headers[$name] .= ', ' . $value;
-                }
-            }
-        }
-
-        return $this;
-    }
-
-    /**
-     * Returns the request headers
-     *
-     * The array is of the form ('header name' => 'header value'), header names
-     * are lowercased
-     *
-     * @return   array
-     */
-    public function getHeaders()
-    {
-        return $this->headers;
-    }
-
-    /**
-     * Adds a cookie to the request
-     *
-     * If the request does not have a CookieJar object set, this method simply
-     * appends a cookie to "Cookie:" header.
-     *
-     * If a CookieJar object is available, the cookie is stored in that object.
-     * Data from request URL will be used for setting its 'domain' and 'path'
-     * parameters, 'expires' and 'secure' will be set to null and false,
-     * respectively. If you need further control, use CookieJar's methods.
-     *
-     * @param string $name  cookie name
-     * @param string $value cookie value
-     *
-     * @return   HTTP_Request2
-     * @throws   HTTP_Request2_LogicException
-     * @see      setCookieJar()
-     */
-    public function addCookie($name, $value)
-    {
-        if (!empty($this->cookieJar)) {
-            $this->cookieJar->store(
-                array('name' => $name, 'value' => $value), $this->url
-            );
-
-        } else {
-            $cookie = $name . '=' . $value;
-            if (preg_match(self::REGEXP_INVALID_COOKIE, $cookie)) {
-                throw new HTTP_Request2_LogicException(
-                    "Invalid cookie: '{$cookie}'",
-                    HTTP_Request2_Exception::INVALID_ARGUMENT
-                );
-            }
-            $cookies = empty($this->headers['cookie'])? '': $this->headers['cookie'] . '; ';
-            $this->setHeader('cookie', $cookies . $cookie);
-        }
-
-        return $this;
-    }
-
-    /**
-     * Sets the request body
-     *
-     * If you provide file pointer rather than file name, it should support
-     * fstat() and rewind() operations.
-     *
-     * @param string|resource|HTTP_Request2_MultipartBody $body       Either a
-     *               string with the body or filename containing body or
-     *               pointer to an open file or object with multipart body data
-     * @param bool                                        $isFilename Whether
-     *               first parameter is a filename
-     *
-     * @return   HTTP_Request2
-     * @throws   HTTP_Request2_LogicException
-     */
-    public function setBody($body, $isFilename = false)
-    {
-        if (!$isFilename && !is_resource($body)) {
-            if (!$body instanceof HTTP_Request2_MultipartBody) {
-                $this->body = (string)$body;
-            } else {
-                $this->body = $body;
-            }
-        } else {
-            $fileData = $this->fopenWrapper($body, empty($this->headers['content-type']));
-            $this->body = $fileData['fp'];
-            if (empty($this->headers['content-type'])) {
-                $this->setHeader('content-type', $fileData['type']);
-            }
-        }
-        $this->postParams = $this->uploads = array();
-
-        return $this;
-    }
-
-    /**
-     * Returns the request body
-     *
-     * @return   string|resource|HTTP_Request2_MultipartBody
-     */
-    public function getBody()
-    {
-        if (self::METHOD_POST == $this->method
-            && (!empty($this->postParams) || !empty($this->uploads))
-        ) {
-            if (0 === strpos($this->headers['content-type'], 'application/x-www-form-urlencoded')) {
-                $body = http_build_query($this->postParams, '', '&');
-                if (!$this->getConfig('use_brackets')) {
-                    $body = preg_replace('/%5B\d+%5D=/', '=', $body);
-                }
-                // support RFC 3986 by not encoding '~' symbol (request #15368)
-                return str_replace('%7E', '~', $body);
-
-            } elseif (0 === strpos($this->headers['content-type'], 'multipart/form-data')) {
-                require_once 'HTTP/Request2/MultipartBody.php';
-                return new HTTP_Request2_MultipartBody(
-                    $this->postParams, $this->uploads, $this->getConfig('use_brackets')
-                );
-            }
-        }
-        return $this->body;
-    }
-
-    /**
-     * Adds a file to form-based file upload
-     *
-     * Used to emulate file upload via a HTML form. The method also sets
-     * Content-Type of HTTP request to 'multipart/form-data'.
-     *
-     * If you just want to send the contents of a file as the body of HTTP
-     * request you should use setBody() method.
-     *
-     * If you provide file pointers rather than file names, they should support
-     * fstat() and rewind() operations.
-     *
-     * @param string                $fieldName    name of file-upload field
-     * @param string|resource|array $filename     full name of local file,
-     *               pointer to open file or an array of files
-     * @param string                $sendFilename filename to send in the request
-     * @param string                $contentType  content-type of file being uploaded
-     *
-     * @return   HTTP_Request2
-     * @throws   HTTP_Request2_LogicException
-     */
-    public function addUpload(
-        $fieldName, $filename, $sendFilename = null, $contentType = null
-    ) {
-        if (!is_array($filename)) {
-            $fileData = $this->fopenWrapper($filename, empty($contentType));
-            $this->uploads[$fieldName] = array(
-                'fp'        => $fileData['fp'],
-                'filename'  => !empty($sendFilename)? $sendFilename
-                                :(is_string($filename)? basename($filename): 'anonymous.blob') ,
-                'size'      => $fileData['size'],
-                'type'      => empty($contentType)? $fileData['type']: $contentType
-            );
-        } else {
-            $fps = $names = $sizes = $types = array();
-            foreach ($filename as $f) {
-                if (!is_array($f)) {
-                    $f = array($f);
-                }
-                $fileData = $this->fopenWrapper($f[0], empty($f[2]));
-                $fps[]   = $fileData['fp'];
-                $names[] = !empty($f[1])? $f[1]
-                            :(is_string($f[0])? basename($f[0]): 'anonymous.blob');
-                $sizes[] = $fileData['size'];
-                $types[] = empty($f[2])? $fileData['type']: $f[2];
-            }
-            $this->uploads[$fieldName] = array(
-                'fp' => $fps, 'filename' => $names, 'size' => $sizes, 'type' => $types
-            );
-        }
-        if (empty($this->headers['content-type'])
-            || 'application/x-www-form-urlencoded' == $this->headers['content-type']
-        ) {
-            $this->setHeader('content-type', 'multipart/form-data');
-        }
-
-        return $this;
-    }
-
-    /**
-     * Adds POST parameter(s) to the request.
-     *
-     * @param string|array $name  parameter name or array ('name' => 'value')
-     * @param mixed        $value parameter value (can be an array)
-     *
-     * @return   HTTP_Request2
-     */
-    public function addPostParameter($name, $value = null)
-    {
-        if (!is_array($name)) {
-            $this->postParams[$name] = $value;
-        } else {
-            foreach ($name as $k => $v) {
-                $this->addPostParameter($k, $v);
-            }
-        }
-        if (empty($this->headers['content-type'])) {
-            $this->setHeader('content-type', 'application/x-www-form-urlencoded');
-        }
-
-        return $this;
-    }
-
-    /**
-     * Attaches a new observer
-     *
-     * @param SplObserver $observer any object implementing SplObserver
-     */
-    public function attach(SplObserver $observer)
-    {
-        foreach ($this->observers as $attached) {
-            if ($attached === $observer) {
-                return;
-            }
-        }
-        $this->observers[] = $observer;
-    }
-
-    /**
-     * Detaches an existing observer
-     *
-     * @param SplObserver $observer any object implementing SplObserver
-     */
-    public function detach(SplObserver $observer)
-    {
-        foreach ($this->observers as $key => $attached) {
-            if ($attached === $observer) {
-                unset($this->observers[$key]);
-                return;
-            }
-        }
-    }
-
-    /**
-     * Notifies all observers
-     */
-    public function notify()
-    {
-        foreach ($this->observers as $observer) {
-            $observer->update($this);
-        }
-    }
-
-    /**
-     * Sets the last event
-     *
-     * Adapters should use this method to set the current state of the request
-     * and notify the observers.
-     *
-     * @param string $name event name
-     * @param mixed  $data event data
-     */
-    public function setLastEvent($name, $data = null)
-    {
-        $this->lastEvent = array(
-            'name' => $name,
-            'data' => $data
-        );
-        $this->notify();
-    }
-
-    /**
-     * Returns the last event
-     *
-     * Observers should use this method to access the last change in request.
-     * The following event names are possible:
-     * <ul>
-     *   <li>'connect'                 - after connection to remote server,
-     *                                   data is the destination (string)</li>
-     *   <li>'disconnect'              - after disconnection from server</li>
-     *   <li>'sentHeaders'             - after sending the request headers,
-     *                                   data is the headers sent (string)</li>
-     *   <li>'sentBodyPart'            - after sending a part of the request body,
-     *                                   data is the length of that part (int)</li>
-     *   <li>'sentBody'                - after sending the whole request body,
-     *                                   data is request body length (int)</li>
-     *   <li>'receivedHeaders'         - after receiving the response headers,
-     *                                   data is HTTP_Request2_Response object</li>
-     *   <li>'receivedBodyPart'        - after receiving a part of the response
-     *                                   body, data is that part (string)</li>
-     *   <li>'receivedEncodedBodyPart' - as 'receivedBodyPart', but data is still
-     *                                   encoded by Content-Encoding</li>
-     *   <li>'receivedBody'            - after receiving the complete response
-     *                                   body, data is HTTP_Request2_Response object</li>
-     * </ul>
-     * Different adapters may not send all the event types. Mock adapter does
-     * not send any events to the observers.
-     *
-     * @return   array   The array has two keys: 'name' and 'data'
-     */
-    public function getLastEvent()
-    {
-        return $this->lastEvent;
-    }
-
-    /**
-     * Sets the adapter used to actually perform the request
-     *
-     * You can pass either an instance of a class implementing HTTP_Request2_Adapter
-     * or a class name. The method will only try to include a file if the class
-     * name starts with HTTP_Request2_Adapter_, it will also try to prepend this
-     * prefix to the class name if it doesn't contain any underscores, so that
-     * <code>
-     * $request->setAdapter('curl');
-     * </code>
-     * will work.
-     *
-     * @param string|HTTP_Request2_Adapter $adapter Adapter to use
-     *
-     * @return   HTTP_Request2
-     * @throws   HTTP_Request2_LogicException
-     */
-    public function setAdapter($adapter)
-    {
-        if (is_string($adapter)) {
-            if (!class_exists($adapter, false)) {
-                if (false === strpos($adapter, '_')) {
-                    $adapter = 'HTTP_Request2_Adapter_' . ucfirst($adapter);
-                }
-                if (!class_exists($adapter, false)
-                    && preg_match('/^HTTP_Request2_Adapter_([a-zA-Z0-9]+)$/', $adapter)
-                ) {
-                    include_once str_replace('_', DIRECTORY_SEPARATOR, $adapter) . '.php';
-                }
-                if (!class_exists($adapter, false)) {
-                    throw new HTTP_Request2_LogicException(
-                        "Class {$adapter} not found",
-                        HTTP_Request2_Exception::MISSING_VALUE
-                    );
-                }
-            }
-            $adapter = new $adapter;
-        }
-        if (!$adapter instanceof HTTP_Request2_Adapter) {
-            throw new HTTP_Request2_LogicException(
-                'Parameter is not a HTTP request adapter',
-                HTTP_Request2_Exception::INVALID_ARGUMENT
-            );
-        }
-        $this->adapter = $adapter;
-
-        return $this;
-    }
-
-    /**
-     * Sets the cookie jar
-     *
-     * A cookie jar is used to maintain cookies across HTTP requests and
-     * responses. Cookies from jar will be automatically added to the request
-     * headers based on request URL.
-     *
-     * @param HTTP_Request2_CookieJar|bool $jar Existing CookieJar object, true to
-     *                                          create a new one, false to remove
-     *
-     * @return HTTP_Request2
-     * @throws HTTP_Request2_LogicException
-     */
-    public function setCookieJar($jar = true)
-    {
-        if (!class_exists('HTTP_Request2_CookieJar', false)) {
-            require_once 'HTTP/Request2/CookieJar.php';
-        }
-
-        if ($jar instanceof HTTP_Request2_CookieJar) {
-            $this->cookieJar = $jar;
-        } elseif (true === $jar) {
-            $this->cookieJar = new HTTP_Request2_CookieJar();
-        } elseif (!$jar) {
-            $this->cookieJar = null;
-        } else {
-            throw new HTTP_Request2_LogicException(
-                'Invalid parameter passed to setCookieJar()',
-                HTTP_Request2_Exception::INVALID_ARGUMENT
-            );
-        }
-
-        return $this;
-    }
-
-    /**
-     * Returns current CookieJar object or null if none
-     *
-     * @return HTTP_Request2_CookieJar|null
-     */
-    public function getCookieJar()
-    {
-        return $this->cookieJar;
-    }
-
-    /**
-     * Sends the request and returns the response
-     *
-     * @throws   HTTP_Request2_Exception
-     * @return   HTTP_Request2_Response
-     */
-    public function send()
-    {
-        // Sanity check for URL
-        if (!$this->url instanceof Net_URL2
-            || !$this->url->isAbsolute()
-            || !in_array(strtolower($this->url->getScheme()), array('https', 'http'))
-        ) {
-            throw new HTTP_Request2_LogicException(
-                'HTTP_Request2 needs an absolute HTTP(S) request URL, '
-                . ($this->url instanceof Net_URL2
-                   ? "'" . $this->url->__toString() . "'" : 'none')
-                . ' given',
-                HTTP_Request2_Exception::INVALID_ARGUMENT
-            );
-        }
-        if (empty($this->adapter)) {
-            $this->setAdapter($this->getConfig('adapter'));
-        }
-        // magic_quotes_runtime may break file uploads and chunked response
-        // processing; see bug #4543. Don't use ini_get() here; see bug #16440.
-        if ($magicQuotes = get_magic_quotes_runtime()) {
-            set_magic_quotes_runtime(false);
-        }
-        // force using single byte encoding if mbstring extension overloads
-        // strlen() and substr(); see bug #1781, bug #10605
-        if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) {
-            $oldEncoding = mb_internal_encoding();
-            mb_internal_encoding('8bit');
-        }
-
-        try {
-            $response = $this->adapter->sendRequest($this);
-        } catch (Exception $e) {
-        }
-        // cleanup in either case (poor man's "finally" clause)
-        if ($magicQuotes) {
-            set_magic_quotes_runtime(true);
-        }
-        if (!empty($oldEncoding)) {
-            mb_internal_encoding($oldEncoding);
-        }
-        // rethrow the exception
-        if (!empty($e)) {
-            throw $e;
-        }
-        return $response;
-    }
-
-    /**
-     * Wrapper around fopen()/fstat() used by setBody() and addUpload()
-     *
-     * @param string|resource $file       file name or pointer to open file
-     * @param bool            $detectType whether to try autodetecting MIME
-     *                        type of file, will only work if $file is a
-     *                        filename, not pointer
-     *
-     * @return array array('fp' => file pointer, 'size' => file size, 'type' => MIME type)
-     * @throws HTTP_Request2_LogicException
-     */
-    protected function fopenWrapper($file, $detectType = false)
-    {
-        if (!is_string($file) && !is_resource($file)) {
-            throw new HTTP_Request2_LogicException(
-                "Filename or file pointer resource expected",
-                HTTP_Request2_Exception::INVALID_ARGUMENT
-            );
-        }
-        $fileData = array(
-            'fp'   => is_string($file)? null: $file,
-            'type' => 'application/octet-stream',
-            'size' => 0
-        );
-        if (is_string($file)) {
-            if (!($fileData['fp'] = @fopen($file, 'rb'))) {
-                $error = error_get_last();
-                throw new HTTP_Request2_LogicException(
-                    $error['message'], HTTP_Request2_Exception::READ_ERROR
-                );
-            }
-            if ($detectType) {
-                $fileData['type'] = self::detectMimeType($file);
-            }
-        }
-        if (!($stat = fstat($fileData['fp']))) {
-            throw new HTTP_Request2_LogicException(
-                "fstat() call failed", HTTP_Request2_Exception::READ_ERROR
-            );
-        }
-        $fileData['size'] = $stat['size'];
-
-        return $fileData;
-    }
-
-    /**
-     * Tries to detect MIME type of a file
-     *
-     * The method will try to use fileinfo extension if it is available,
-     * deprecated mime_content_type() function in the other case. If neither
-     * works, default 'application/octet-stream' MIME type is returned
-     *
-     * @param string $filename file name
-     *
-     * @return   string  file MIME type
-     */
-    protected static function detectMimeType($filename)
-    {
-        // finfo extension from PECL available
-        if (function_exists('finfo_open')) {
-            if (!isset(self::$_fileinfoDb)) {
-                self::$_fileinfoDb = @finfo_open(FILEINFO_MIME);
-            }
-            if (self::$_fileinfoDb) {
-                $info = finfo_file(self::$_fileinfoDb, $filename);
-            }
-        }
-        // (deprecated) mime_content_type function available
-        if (empty($info) && function_exists('mime_content_type')) {
-            return mime_content_type($filename);
-        }
-        return empty($info)? 'application/octet-stream': $info;
-    }
-}
-?>
Index: anches/version-2_13-dev/data/module/System.php
===================================================================
--- /branches/version-2_13-dev/data/module/System.php	(revision 23125)
+++ 	(revision )
@@ -1,629 +1,0 @@
-<?php
-/**
- * File/Directory manipulation
- *
- * PHP versions 4 and 5
- *
- * @category   pear
- * @package    System
- * @author     Tomas V.V.Cox <cox@idecnet.com>
- * @copyright  1997-2009 The Authors
- * @license    http://opensource.org/licenses/bsd-license.php New BSD License
- * @version    CVS: $Id: System.php 313024 2011-07-06 19:51:24Z dufuz $
- * @link       http://pear.php.net/package/PEAR
- * @since      File available since Release 0.1
- */
-
-/**
- * base class
- */
-require_once 'PEAR.php';
-require_once 'Console/Getopt.php';
-
-$GLOBALS['_System_temp_files'] = array();
-
-/**
-* System offers cross plattform compatible system functions
-*
-* Static functions for different operations. Should work under
-* Unix and Windows. The names and usage has been taken from its respectively
-* GNU commands. The functions will return (bool) false on error and will
-* trigger the error with the PHP trigger_error() function (you can silence
-* the error by prefixing a '@' sign after the function call, but this
-* is not recommended practice.  Instead use an error handler with
-* {@link set_error_handler()}).
-*
-* Documentation on this class you can find in:
-* http://pear.php.net/manual/
-*
-* Example usage:
-* if (!@System::rm('-r file1 dir1')) {
-*    print "could not delete file1 or dir1";
-* }
-*
-* In case you need to to pass file names with spaces,
-* pass the params as an array:
-*
-* System::rm(array('-r', $file1, $dir1));
-*
-* @category   pear
-* @package    System
-* @author     Tomas V.V. Cox <cox@idecnet.com>
-* @copyright  1997-2006 The PHP Group
-* @license    http://opensource.org/licenses/bsd-license.php New BSD License
-* @version    Release: 1.9.4
-* @link       http://pear.php.net/package/PEAR
-* @since      Class available since Release 0.1
-* @static
-*/
-class System
-{
-    /**
-     * returns the commandline arguments of a function
-     *
-     * @param    string  $argv           the commandline
-     * @param    string  $short_options  the allowed option short-tags
-     * @param    string  $long_options   the allowed option long-tags
-     * @return   array   the given options and there values
-     * @static
-     * @access private
-     */
-    function _parseArgs($argv, $short_options, $long_options = null)
-    {
-        if (!is_array($argv) && $argv !== null) {
-            // Find all items, quoted or otherwise
-            preg_match_all("/(?:[\"'])(.*?)(?:['\"])|([^\s]+)/", $argv, $av);
-            $argv = $av[1];
-            foreach ($av[2] as $k => $a) {
-                if (empty($a)) {
-                    continue;
-                }
-                $argv[$k] = trim($a) ;
-            }
-        }
-        return Console_Getopt::getopt2($argv, $short_options, $long_options);
-    }
-
-    /**
-     * Output errors with PHP trigger_error(). You can silence the errors
-     * with prefixing a "@" sign to the function call: @System::mkdir(..);
-     *
-     * @param mixed $error a PEAR error or a string with the error message
-     * @return bool false
-     * @static
-     * @access private
-     */
-    function raiseError($error)
-    {
-        if (PEAR::isError($error)) {
-            $error = $error->getMessage();
-        }
-        trigger_error($error, E_USER_WARNING);
-        return false;
-    }
-
-    /**
-     * Creates a nested array representing the structure of a directory
-     *
-     * System::_dirToStruct('dir1', 0) =>
-     *   Array
-     *    (
-     *    [dirs] => Array
-     *        (
-     *            [0] => dir1
-     *        )
-     *
-     *    [files] => Array
-     *        (
-     *            [0] => dir1/file2
-     *            [1] => dir1/file3
-     *        )
-     *    )
-     * @param    string  $sPath      Name of the directory
-     * @param    integer $maxinst    max. deep of the lookup
-     * @param    integer $aktinst    starting deep of the lookup
-     * @param    bool    $silent     if true, do not emit errors.
-     * @return   array   the structure of the dir
-     * @static
-     * @access   private
-     */
-    function _dirToStruct($sPath, $maxinst, $aktinst = 0, $silent = false)
-    {
-        $struct = array('dirs' => array(), 'files' => array());
-        if (($dir = @opendir($sPath)) === false) {
-            if (!$silent) {
-                System::raiseError("Could not open dir $sPath");
-            }
-            return $struct; // XXX could not open error
-        }
-
-        $struct['dirs'][] = $sPath = realpath($sPath); // XXX don't add if '.' or '..' ?
-        $list = array();
-        while (false !== ($file = readdir($dir))) {
-            if ($file != '.' && $file != '..') {
-                $list[] = $file;
-            }
-        }
-
-        closedir($dir);
-        natsort($list);
-        if ($aktinst < $maxinst || $maxinst == 0) {
-            foreach ($list as $val) {
-                $path = $sPath . DIRECTORY_SEPARATOR . $val;
-                if (is_dir($path) && !is_link($path)) {
-                    $tmp    = System::_dirToStruct($path, $maxinst, $aktinst+1, $silent);
-                    $struct = array_merge_recursive($struct, $tmp);
-                } else {
-                    $struct['files'][] = $path;
-                }
-            }
-        }
-
-        return $struct;
-    }
-
-    /**
-     * Creates a nested array representing the structure of a directory and files
-     *
-     * @param    array $files Array listing files and dirs
-     * @return   array
-     * @static
-     * @see System::_dirToStruct()
-     */
-    function _multipleToStruct($files)
-    {
-        $struct = array('dirs' => array(), 'files' => array());
-        settype($files, 'array');
-        foreach ($files as $file) {
-            if (is_dir($file) && !is_link($file)) {
-                $tmp    = System::_dirToStruct($file, 0);
-                $struct = array_merge_recursive($tmp, $struct);
-            } else {
-                if (!in_array($file, $struct['files'])) {
-                    $struct['files'][] = $file;
-                }
-            }
-        }
-        return $struct;
-    }
-
-    /**
-     * The rm command for removing files.
-     * Supports multiple files and dirs and also recursive deletes
-     *
-     * @param    string  $args   the arguments for rm
-     * @return   mixed   PEAR_Error or true for success
-     * @static
-     * @access   public
-     */
-    function rm($args)
-    {
-        $opts = System::_parseArgs($args, 'rf'); // "f" does nothing but I like it :-)
-        if (PEAR::isError($opts)) {
-            return System::raiseError($opts);
-        }
-        foreach ($opts[0] as $opt) {
-            if ($opt[0] == 'r') {
-                $do_recursive = true;
-            }
-        }
-        $ret = true;
-        if (isset($do_recursive)) {
-            $struct = System::_multipleToStruct($opts[1]);
-            foreach ($struct['files'] as $file) {
-                if (!@unlink($file)) {
-                    $ret = false;
-                }
-            }
-
-            rsort($struct['dirs']);
-            foreach ($struct['dirs'] as $dir) {
-                if (!@rmdir($dir)) {
-                    $ret = false;
-                }
-            }
-        } else {
-            foreach ($opts[1] as $file) {
-                $delete = (is_dir($file)) ? 'rmdir' : 'unlink';
-                if (!@$delete($file)) {
-                    $ret = false;
-                }
-            }
-        }
-        return $ret;
-    }
-
-    /**
-     * Make directories.
-     *
-     * The -p option will create parent directories
-     * @param    string  $args    the name of the director(y|ies) to create
-     * @return   bool    True for success
-     * @static
-     * @access   public
-     */
-    function mkDir($args)
-    {
-        $opts = System::_parseArgs($args, 'pm:');
-        if (PEAR::isError($opts)) {
-            return System::raiseError($opts);
-        }
-
-        $mode = 0777; // default mode
-        foreach ($opts[0] as $opt) {
-            if ($opt[0] == 'p') {
-                $create_parents = true;
-            } elseif ($opt[0] == 'm') {
-                // if the mode is clearly an octal number (starts with 0)
-                // convert it to decimal
-                if (strlen($opt[1]) && $opt[1]{0} == '0') {
-                    $opt[1] = octdec($opt[1]);
-                } else {
-                    // convert to int
-                    $opt[1] += 0;
-                }
-                $mode = $opt[1];
-            }
-        }
-
-        $ret = true;
-        if (isset($create_parents)) {
-            foreach ($opts[1] as $dir) {
-                $dirstack = array();
-                while ((!file_exists($dir) || !is_dir($dir)) &&
-                        $dir != DIRECTORY_SEPARATOR) {
-                    array_unshift($dirstack, $dir);
-                    $dir = dirname($dir);
-                }
-
-                while ($newdir = array_shift($dirstack)) {
-                    if (!is_writeable(dirname($newdir))) {
-                        $ret = false;
-                        break;
-                    }
-
-                    if (!mkdir($newdir, $mode)) {
-                        $ret = false;
-                    }
-                }
-            }
-        } else {
-            foreach($opts[1] as $dir) {
-                if ((@file_exists($dir) || !is_dir($dir)) && !mkdir($dir, $mode)) {
-                    $ret = false;
-                }
-            }
-        }
-
-        return $ret;
-    }
-
-    /**
-     * Concatenate files
-     *
-     * Usage:
-     * 1) $var = System::cat('sample.txt test.txt');
-     * 2) System::cat('sample.txt test.txt > final.txt');
-     * 3) System::cat('sample.txt test.txt >> final.txt');
-     *
-     * Note: as the class use fopen, urls should work also (test that)
-     *
-     * @param    string  $args   the arguments
-     * @return   boolean true on success
-     * @static
-     * @access   public
-     */
-    function &cat($args)
-    {
-        $ret = null;
-        $files = array();
-        if (!is_array($args)) {
-            $args = preg_split('/\s+/', $args, -1, PREG_SPLIT_NO_EMPTY);
-        }
-
-        $count_args = count($args);
-        for ($i = 0; $i < $count_args; $i++) {
-            if ($args[$i] == '>') {
-                $mode = 'wb';
-                $outputfile = $args[$i+1];
-                break;
-            } elseif ($args[$i] == '>>') {
-                $mode = 'ab+';
-                $outputfile = $args[$i+1];
-                break;
-            } else {
-                $files[] = $args[$i];
-            }
-        }
-        $outputfd = false;
-        if (isset($mode)) {
-            if (!$outputfd = fopen($outputfile, $mode)) {
-                $err = System::raiseError("Could not open $outputfile");
-                return $err;
-            }
-            $ret = true;
-        }
-        foreach ($files as $file) {
-            if (!$fd = fopen($file, 'r')) {
-                System::raiseError("Could not open $file");
-                continue;
-            }
-            while ($cont = fread($fd, 2048)) {
-                if (is_resource($outputfd)) {
-                    fwrite($outputfd, $cont);
-                } else {
-                    $ret .= $cont;
-                }
-            }
-            fclose($fd);
-        }
-        if (is_resource($outputfd)) {
-            fclose($outputfd);
-        }
-        return $ret;
-    }
-
-    /**
-     * Creates temporary files or directories. This function will remove
-     * the created files when the scripts finish its execution.
-     *
-     * Usage:
-     *   1) $tempfile = System::mktemp("prefix");
-     *   2) $tempdir  = System::mktemp("-d prefix");
-     *   3) $tempfile = System::mktemp();
-     *   4) $tempfile = System::mktemp("-t /var/tmp prefix");
-     *
-     * prefix -> The string that will be prepended to the temp name
-     *           (defaults to "tmp").
-     * -d     -> A temporary dir will be created instead of a file.
-     * -t     -> The target dir where the temporary (file|dir) will be created. If
-     *           this param is missing by default the env vars TMP on Windows or
-     *           TMPDIR in Unix will be used. If these vars are also missing
-     *           c:\windows\temp or /tmp will be used.
-     *
-     * @param   string  $args  The arguments
-     * @return  mixed   the full path of the created (file|dir) or false
-     * @see System::tmpdir()
-     * @static
-     * @access  public
-     */
-    function mktemp($args = null)
-    {
-        static $first_time = true;
-        $opts = System::_parseArgs($args, 't:d');
-        if (PEAR::isError($opts)) {
-            return System::raiseError($opts);
-        }
-
-        foreach ($opts[0] as $opt) {
-            if ($opt[0] == 'd') {
-                $tmp_is_dir = true;
-            } elseif ($opt[0] == 't') {
-                $tmpdir = $opt[1];
-            }
-        }
-
-        $prefix = (isset($opts[1][0])) ? $opts[1][0] : 'tmp';
-        if (!isset($tmpdir)) {
-            $tmpdir = System::tmpdir();
-        }
-
-        if (!System::mkDir(array('-p', $tmpdir))) {
-            return false;
-        }
-
-        $tmp = tempnam($tmpdir, $prefix);
-        if (isset($tmp_is_dir)) {
-            unlink($tmp); // be careful possible race condition here
-            if (!mkdir($tmp, 0700)) {
-                return System::raiseError("Unable to create temporary directory $tmpdir");
-            }
-        }
-
-        $GLOBALS['_System_temp_files'][] = $tmp;
-        if (isset($tmp_is_dir)) {
-            //$GLOBALS['_System_temp_files'][] = dirname($tmp);
-        }
-
-        if ($first_time) {
-            PEAR::registerShutdownFunc(array('System', '_removeTmpFiles'));
-            $first_time = false;
-        }
-
-        return $tmp;
-    }
-
-    /**
-     * Remove temporary files created my mkTemp. This function is executed
-     * at script shutdown time
-     *
-     * @static
-     * @access private
-     */
-    function _removeTmpFiles()
-    {
-        if (count($GLOBALS['_System_temp_files'])) {
-            $delete = $GLOBALS['_System_temp_files'];
-            array_unshift($delete, '-r');
-            System::rm($delete);
-            $GLOBALS['_System_temp_files'] = array();
-        }
-    }
-
-    /**
-     * Get the path of the temporal directory set in the system
-     * by looking in its environments variables.
-     * Note: php.ini-recommended removes the "E" from the variables_order setting,
-     * making unavaible the $_ENV array, that s why we do tests with _ENV
-     *
-     * @static
-     * @return string The temporary directory on the system
-     */
-    function tmpdir()
-    {
-        if (OS_WINDOWS) {
-            if ($var = isset($_ENV['TMP']) ? $_ENV['TMP'] : getenv('TMP')) {
-                return $var;
-            }
-            if ($var = isset($_ENV['TEMP']) ? $_ENV['TEMP'] : getenv('TEMP')) {
-                return $var;
-            }
-            if ($var = isset($_ENV['USERPROFILE']) ? $_ENV['USERPROFILE'] : getenv('USERPROFILE')) {
-                return $var;
-            }
-            if ($var = isset($_ENV['windir']) ? $_ENV['windir'] : getenv('windir')) {
-                return $var;
-            }
-            return getenv('SystemRoot') . '\temp';
-        }
-        if ($var = isset($_ENV['TMPDIR']) ? $_ENV['TMPDIR'] : getenv('TMPDIR')) {
-            return $var;
-        }
-        return realpath('/tmp');
-    }
-
-    /**
-     * The "which" command (show the full path of a command)
-     *
-     * @param string $program The command to search for
-     * @param mixed  $fallback Value to return if $program is not found
-     *
-     * @return mixed A string with the full path or false if not found
-     * @static
-     * @author Stig Bakken <ssb@php.net>
-     */
-    function which($program, $fallback = false)
-    {
-        // enforce API
-        if (!is_string($program) || '' == $program) {
-            return $fallback;
-        }
-
-        // full path given
-        if (basename($program) != $program) {
-            $path_elements[] = dirname($program);
-            $program = basename($program);
-        } else {
-            // Honor safe mode
-            if (!ini_get('safe_mode') || !$path = ini_get('safe_mode_exec_dir')) {
-                $path = getenv('PATH');
-                if (!$path) {
-                    $path = getenv('Path'); // some OSes are just stupid enough to do this
-                }
-            }
-            $path_elements = explode(PATH_SEPARATOR, $path);
-        }
-
-        if (OS_WINDOWS) {
-            $exe_suffixes = getenv('PATHEXT')
-                                ? explode(PATH_SEPARATOR, getenv('PATHEXT'))
-                                : array('.exe','.bat','.cmd','.com');
-            // allow passing a command.exe param
-            if (strpos($program, '.') !== false) {
-                array_unshift($exe_suffixes, '');
-            }
-            // is_executable() is not available on windows for PHP4
-            $pear_is_executable = (function_exists('is_executable')) ? 'is_executable' : 'is_file';
-        } else {
-            $exe_suffixes = array('');
-            $pear_is_executable = 'is_executable';
-        }
-
-        foreach ($exe_suffixes as $suff) {
-            foreach ($path_elements as $dir) {
-                $file = $dir . DIRECTORY_SEPARATOR . $program . $suff;
-                if (@$pear_is_executable($file)) {
-                    return $file;
-                }
-            }
-        }
-        return $fallback;
-    }
-
-    /**
-     * The "find" command
-     *
-     * Usage:
-     *
-     * System::find($dir);
-     * System::find("$dir -type d");
-     * System::find("$dir -type f");
-     * System::find("$dir -name *.php");
-     * System::find("$dir -name *.php -name *.htm*");
-     * System::find("$dir -maxdepth 1");
-     *
-     * Params implmented:
-     * $dir            -> Start the search at this directory
-     * -type d         -> return only directories
-     * -type f         -> return only files
-     * -maxdepth <n>   -> max depth of recursion
-     * -name <pattern> -> search pattern (bash style). Multiple -name param allowed
-     *
-     * @param  mixed Either array or string with the command line
-     * @return array Array of found files
-     * @static
-     *
-     */
-    function find($args)
-    {
-        if (!is_array($args)) {
-            $args = preg_split('/\s+/', $args, -1, PREG_SPLIT_NO_EMPTY);
-        }
-        $dir = realpath(array_shift($args));
-        if (!$dir) {
-            return array();
-        }
-        $patterns = array();
-        $depth = 0;
-        $do_files = $do_dirs = true;
-        $args_count = count($args);
-        for ($i = 0; $i < $args_count; $i++) {
-            switch ($args[$i]) {
-                case '-type':
-                    if (in_array($args[$i+1], array('d', 'f'))) {
-                        if ($args[$i+1] == 'd') {
-                            $do_files = false;
-                        } else {
-                            $do_dirs = false;
-                        }
-                    }
-                    $i++;
-                    break;
-                case '-name':
-                    $name = preg_quote($args[$i+1], '#');
-                    // our magic characters ? and * have just been escaped,
-                    // so now we change the escaped versions to PCRE operators
-                    $name = strtr($name, array('\?' => '.', '\*' => '.*'));
-                    $patterns[] = '('.$name.')';
-                    $i++;
-                    break;
-                case '-maxdepth':
-                    $depth = $args[$i+1];
-                    break;
-            }
-        }
-        $path = System::_dirToStruct($dir, $depth, 0, true);
-        if ($do_files && $do_dirs) {
-            $files = array_merge($path['files'], $path['dirs']);
-        } elseif ($do_dirs) {
-            $files = $path['dirs'];
-        } else {
-            $files = $path['files'];
-        }
-        if (count($patterns)) {
-            $dsq = preg_quote(DIRECTORY_SEPARATOR, '#');
-            $pattern = '#(^|'.$dsq.')'.implode('|', $patterns).'($|'.$dsq.')#';
-            $ret = array();
-            $files_count = count($files);
-            for ($i = 0; $i < $files_count; $i++) {
-                // only search in the part of the file below the current directory
-                $filepart = basename($files[$i]);
-                if (preg_match($pattern, $filepart)) {
-                    $ret[] = $files[$i];
-                }
-            }
-            return $ret;
-        }
-        return $files;
-    }
-}
