diff --git a/.htaccess b/.htaccess index a3860192c..f23967b59 100644 --- a/.htaccess +++ b/.htaccess @@ -1,5 +1,5 @@ RewriteEngine on - RewriteRule ^$ app/webroot/ [L] - RewriteRule (.*) app/webroot/$1 [L] + RewriteRule ^$ app/webroot/ [L] + RewriteRule (.*) app/webroot/$1 [L] \ No newline at end of file diff --git a/VERSION.txt b/VERSION.txt index aba202c56..0c70ef9fc 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -6,4 +6,4 @@ // +---------------------------------------------------------------------------------------------------+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////// -0.10.8.2010 \ No newline at end of file +0.10.8.2026 \ No newline at end of file diff --git a/app/.htaccess b/app/.htaccess index f7f835c56..0ed8662ea 100644 --- a/app/.htaccess +++ b/app/.htaccess @@ -1,5 +1,5 @@ RewriteEngine on - RewriteRule ^$ webroot/ [L] - RewriteRule (.*) webroot/$1 [L] + RewriteRule ^$ webroot/ [L] + RewriteRule (.*) webroot/$1 [L] \ No newline at end of file diff --git a/app/config/core.php b/app/config/core.php index 0efc0d0c6..7cc65df77 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -54,14 +54,14 @@ */ define('DEBUG', 1); /** - * Error constant. Used for differentiating error logging and debugging. - * Currently PHP supports LOG_DEBUG - */ + * Error constant. Used for differentiating error logging and debugging. + * Currently PHP supports LOG_DEBUG + */ define ('LOG_ERROR', 2); /** * CakePHP includes 3 types of session saves - * database or file. Set this to your preffered method. - * If you want to use your own save handeler place it in + * database or file. Set this to your preferred method. + * If you want to use your own save handler place it in * app/config/name.php DO NOT USE file or database as the name. * and use just the name portion below. * @@ -117,7 +117,7 @@ define('WEBSERVICES', 'off'); /** * Compress output CSS (removing comments, whitespace, repeating tags etc.) - * This requires a /var/cache directory to be writable by the web server (caching). + * This requires a/var/cache directory to be writable by the web server (caching). * To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use Controller::cssTag(). */ define('COMPRESS_CSS', false); @@ -141,6 +141,6 @@ define('MAX_MD5SIZE', (5*1024)*1024 ); * To use Access Control Lists with Cake... */ define('ACL_CLASSNAME', 'DB_ACL'); -define('ACL_FILENAME', 'dbacl'.DS.'db_acl'); +define('ACL_FILENAME', 'dbacl'.DS.'db_acl'); ?> \ No newline at end of file diff --git a/app/config/database.php.default b/app/config/database.php.default index 21afe7aa6..ed3e2a319 100644 --- a/app/config/database.php.default +++ b/app/config/database.php.default @@ -48,8 +48,8 @@ * PostgreSQL set the connect to either pg_pconnect of pg_connect * SQLite set the connect to sqlite_popen sqlite_open * ADOdb set the connect to one of these - * (http://phplens.com/adodb/supported.databases.html) and - * append it '|p' for persistent connection. (mssql|p for example, or just mssql for not persistent) + * (http://phplens.com/adodb/supported.databases.html) and + * append it '|p' for persistent connection. (mssql|p for example, or just mssql for not persistent) * * host => * the host you connect to the database @@ -59,21 +59,21 @@ */ class DATABASE_CONFIG { - var $default = array('driver' => 'mysql', + var $default = array('driver' => 'mysql', 'connect' => 'mysql_pconnect', 'host' => 'localhost', 'login' => 'user', 'password' => 'password', 'database' => 'project_name', - 'prefix' => ''); + 'prefix' => ''); - var $test = array('driver' => 'mysql', + var $test = array('driver' => 'mysql', 'connect' => 'mysql_pconnect', 'host' => 'localhost', 'login' => 'user', 'password' => 'password', 'database' => 'project_name-test', - 'prefix' => ''); + 'prefix' => ''); } ?> \ No newline at end of file diff --git a/app/config/routes.php b/app/config/routes.php index 0fe841934..2d183b994 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -3,22 +3,22 @@ /** * Short description for file. - * + * * In this file, you set up routes to your controllers and their actions. - * Routes are very important mechanism that allows you to freely connect + * Routes are very important mechanism that allows you to freely connect * different urls to chosen controllers and their actions (functions). * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2006, Cake Software Foundation, Inc. + * Copyright (c) 2006, Cake Software Foundation, Inc. * 1785 E. Sahara Avenue, Suite 490-204 * Las Vegas, Nevada 89104 * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * - * @filesource + * @filesource * @copyright Copyright (c) 2006, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -31,8 +31,8 @@ */ /** - * Here, we are connecting '/' (base path) to controller called 'Pages', - * its action called 'display', and we pass a param to select the view file + * Here, we are connecting '/' (base path) to controller called 'Pages', + * its action called 'display', and we pass a param to select the view file * to use (in this case, /app/views/pages/home.thtml)... */ $Route->connect ('/', array('controller'=>'pages', 'action'=>'display', 'home')); diff --git a/app/config/sql/sessions.sql b/app/config/sql/sessions.sql index 15b16b5e5..6ff635dfa 100644 --- a/app/config/sql/sessions.sql +++ b/app/config/sql/sessions.sql @@ -1,7 +1,7 @@ -# @copyright Copyright (c) 2006, Cake Software Foundation, Inc. -# @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project -# @since CakePHP v 0.10.8.1997 -# @version $Revision$ +-- @copyright Copyright (c) 2006, Cake Software Foundation, Inc. +-- @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project +-- @since CakePHP v 0.10.8.1997 +-- @version $Revision$ CREATE TABLE cake_sessions ( id varchar(255) NOT NULL default '', diff --git a/app/webroot/css.php b/app/webroot/css.php index ccc37d4ce..c8b399e01 100644 --- a/app/webroot/css.php +++ b/app/webroot/css.php @@ -3,20 +3,20 @@ /** * Short description for file. - * + * * Long description for file * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2006, Cake Software Foundation, Inc. + * Copyright (c) 2006, Cake Software Foundation, Inc. * 1785 E. Sahara Avenue, Suite 490-204 * Las Vegas, Nevada 89104 * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * - * @filesource + * @filesource * @copyright Copyright (c) 2006, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -46,16 +46,16 @@ require(LIBS.'legacy.php'); */ function make_clean_css ($path, $name) { - require(VENDORS.'csspp'.DS.'csspp.php'); + require(VENDORS.'csspp'.DS.'csspp.php'); - $data = file_get_contents($path); - $csspp = new csspp(); - $output = $csspp->compress($data); + $data = file_get_contents($path); + $csspp = new csspp(); + $output = $csspp->compress($data); - $ratio = 100-(round(strlen($output)/strlen($data), 3)*100); - $output = " /* file: $name, ratio: $ratio% */ " . $output; + $ratio = 100-(round(strlen($output)/strlen($data), 3)*100); + $output = " /* file: $name, ratio: $ratio% */ " . $output; - return $output; + return $output; } /** @@ -67,50 +67,50 @@ function make_clean_css ($path, $name) */ function write_css_cache ($path, $content) { - if (!is_dir(dirname($path))) + if (!is_dir(dirname($path))) mkdir(dirname($path)); - - $cache = new File($path); - return $cache->write($content); + + $cache = new File($path); + return $cache->write($content); } -if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) - die('Wrong file name.'); +if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) + die('Wrong file name.'); $filename = 'css/'.$regs[1]; $filepath = CSS.$regs[1]; $cachepath = CACHE.'css'.DS.str_replace(array('/','\\'), '-', $regs[1]); if (!file_exists($filepath)) - die('Wrong file name.'); + die('Wrong file name.'); if (file_exists($cachepath)) { - $templateModified = filemtime($filepath); - $cacheModified = filemtime($cachepath); - - if ($templateModified > $cacheModified) - { + $templateModified = filemtime($filepath); + $cacheModified = filemtime($cachepath); + + if ($templateModified > $cacheModified) + { $output = make_clean_css ($filepath, $filename); write_css_cache ($cachepath, $output); - } - else - { + } + else + { $output = file_get_contents($cachepath); - } + } } -else +else { - $output = make_clean_css ($filepath, $filename); - write_css_cache ($cachepath, $output); + $output = make_clean_css ($filepath, $filename); + write_css_cache ($cachepath, $output); } header("Date: ".date("D, j M Y G:i:s ", $templateModified).'GMT'); header("Content-Type: text/css"); header("Expires: ".gmdate("D, j M Y H:i:s", time()+DAY)." GMT"); -header("Cache-Control: cache"); // HTTP/1.1 -header("Pragma: cache"); // HTTP/1.0 +header("Cache-Control: cache");// HTTP/1.1 +header("Pragma: cache");// HTTP/1.0 print $output; ?> \ No newline at end of file diff --git a/app/webroot/index.php b/app/webroot/index.php index ea451b36d..beb5c10dd 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -37,13 +37,13 @@ if (!defined('ROOT')) { - //define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED DO NOT ADD A TRAILING DIRECTORY SEPARATOR'; +//define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED DO NOT ADD A TRAILING DIRECTORY SEPARATOR'; define('ROOT', dirname(dirname(dirname(__FILE__)))); } if (!defined('APP_DIR')) { - //define('APP_DIR', 'DIRECTORY NAME OF APPLICATION'; +//define('APP_DIR', 'DIRECTORY NAME OF APPLICATION'; define ('APP_DIR', basename(dirname(dirname(__FILE__)))); } @@ -53,7 +53,7 @@ if (!defined('APP_DIR')) */ if (!defined('CAKE_CORE_INCLUDE_PATH')) { - //define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR'; +//define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR'; define('CAKE_CORE_INCLUDE_PATH', ROOT); } @@ -62,7 +62,7 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) /////////////////////////////// if (!defined('DS')) { - define('DS', DIRECTORY_SEPARATOR); + define('DS', DIRECTORY_SEPARATOR); } if (!defined('WEBROOT_DIR')) diff --git a/app/webroot/js/vendors.php b/app/webroot/js/vendors.php index 5cebc2b07..de705f3d9 100644 --- a/app/webroot/js/vendors.php +++ b/app/webroot/js/vendors.php @@ -3,21 +3,21 @@ /** * Short description for file. - * + * * This file includes js vendor-files from /vendor/ directory if they need to * be accessible to the public. * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2006, Cake Software Foundation, Inc. + * Copyright (c) 2006, Cake Software Foundation, Inc. * 1785 E. Sahara Avenue, Suite 490-204 * Las Vegas, Nevada 89104 * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * - * @filesource + * @filesource * @copyright Copyright (c) 2006, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -34,7 +34,7 @@ */ if(is_file('../../vendors/javascript/'.$_GET['file']) && (preg_match('/(.+)\\.js/', $_GET['file']))) { - readfile('../../vendors/javascript/'.$_GET['file']); + readfile('../../vendors/javascript/'.$_GET['file']); } ?> diff --git a/cake/basics.php b/cake/basics.php index c9eda0c85..7e811c6de 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -33,7 +33,7 @@ */ define('SECOND', 1); define('MINUTE', 60 * SECOND); -define('HOUR', 60 * MINUTE); +define('HOUR', 60 * MINUTE); define('DAY', 24 * HOUR); define('WEEK', 7 * DAY); define('MONTH', 30 * DAY); @@ -165,7 +165,7 @@ function loadModel($name) { $name = Inflector::underscore($name); - // Make sure AppModel is loaded +// Make sure AppModel is loaded if(!class_exists('AppModel')) { if(file_exists(APP.'app_model.php')) @@ -289,23 +289,33 @@ function loadPluginController ($plugin, $controller) } } + if(empty($controller)) + { + if(file_exists(APP.'plugins'.DS.$plugin.DS.'controllers'.DS.$plugin.'_controller.php')) + { + require(APP.'plugins'.DS.$plugin.DS.'controllers'.DS.$plugin.'_controller.php'); + return true; + } + } + if(!class_exists($controller.'Controller')) { $controller = Inflector::underscore($controller); $file = APP.'plugins'.DS.$plugin.DS.'controllers'.DS.$controller.'_controller.php'; - if(!file_exists($file)) - { - return false; - } - else + if(file_exists($file)) { require($file); return true; } - } - else - { - return true; + elseif(file_exists(APP.'plugins'.DS.$plugin.DS.'controllers'.DS.$plugin.'_controller.php')) + { + require(APP.'plugins'.DS.$plugin.DS.'controllers'.DS.$plugin.'_controller.php'); + return true; + } + else + { + return false; + } } } @@ -428,7 +438,7 @@ function debug($var = false, $showHtml = false) } print "{$var}\n\n"; - } + } } if (!function_exists('getMicrotime')) @@ -438,11 +448,11 @@ if (!function_exists('getMicrotime')) * * @return integer */ - function getMicrotime() - { + function getMicrotime() + { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); - } + } } if (!function_exists('sortByKey')) @@ -450,7 +460,7 @@ if (!function_exists('sortByKey')) /** * Sorts given $array by key $sortby. * - * @param array $array + * @param array $array * @param string $sortby * @param string $order Sort order asc/desc (ascending or descending). * @param integer $type @@ -506,11 +516,11 @@ if (!function_exists('array_combine')) if ($c1 != $c2) { - return false; // different lenghts + return false;// different lenghts } if ($c1 <= 0) { - return false; // arrays are the same and both are empty + return false;// arrays are the same and both are empty } $output = array(); @@ -645,8 +655,8 @@ function r($search, $replace, $subject) * Print_r convenience function, which prints out
 tags around
  * the output of given array. Similar to debug().
  *
- * @see   debug()
- * @param array   $var
+ * @see    debug()
+ * @param array    $var
  */
 function pr($var)
 {
@@ -750,14 +760,14 @@ function env($key)
 
 if (!function_exists('file_get_contents'))
 {
-    /**
-     * Returns contents of a file as a string.
-     *
-     * @param  string  $fileName       Name of the file.
-     * @param  boolean $useIncludePath Wheter the function should use the
-     *                                 include path or not.
-     * @return mixed   Boolean false or contents of required file.
-     */
+/**
+ * Returns contents of a file as a string.
+ *
+ * @param  string  $fileName        Name of the file.
+ * @param  boolean $useIncludePath Wheter the function should use the
+ *                                 include path or not.
+ * @return mixed    Boolean false or contents of required file.
+ */
     function file_get_contents($fileName, $useIncludePath = false)
     {
         $res = fopen($fileName, 'rb', $useIncludePath);
@@ -788,15 +798,15 @@ if (!function_exists('file_get_contents'))
 
 if (!function_exists('file_put_contents'))
 {
-    /**
-     * Writes data into file.
-     *
-     * If file exists, it will be overwritten. If data is an array, it will be
-     * join()ed with an empty string.
-     *
-     * @param string $fileName File name.
-     * @param mixed  $data     String or array.
-     */
+/**
+ * Writes data into file.
+ *
+ * If file exists, it will be overwritten. If data is an array, it will be
+ * join()ed with an empty string.
+ *
+ * @param string $fileName File name.
+ * @param mixed  $data     String or array.
+ */
     function file_put_contents($fileName, $data)
     {
         if (is_array($data))
@@ -843,12 +853,12 @@ function cache($path, $data = null, $expires = '+1 day', $target = 'cache')
 
     if ($data == null)
     {
-        // Read data from file
+// Read data from file
         if (file_exists($filename) && $filetime !== false)
         {
             if ($filetime + $timediff < $now)
             {
-                // File has expired
+// File has expired
                 @unlink($filename);
             }
             else
@@ -906,8 +916,8 @@ function countdim($array)
 }
 
 /**
-  * Shortcut to Log::write.
-  */
+ * Shortcut to Log::write.
+ */
 function LogError ($message)
 {
     if(!class_exists('CakeLog'))
diff --git a/cake/bootstrap.php b/cake/bootstrap.php
index 75ce37413..521bd43cf 100644
--- a/cake/bootstrap.php
+++ b/cake/bootstrap.php
@@ -79,7 +79,7 @@ else
     }
     else
     {
-       $url = $_GET['url'];
+        $url = $_GET['url'];
     }
 
 }
@@ -87,8 +87,8 @@ else
 
 if (strpos($url, 'ccss/') === 0)
 {
-   include WWW_ROOT.DS.'css.php';
-   die();
+    include WWW_ROOT.DS.'css.php';
+    die();
 }
 
 
diff --git a/cake/config/paths.php b/cake/config/paths.php
index 8c5554a2e..166b7c7a5 100644
--- a/cake/config/paths.php
+++ b/cake/config/paths.php
@@ -36,12 +36,12 @@
  */
 if(!defined('ROOT'))
 {
-   define ('ROOT', '../');
+    define ('ROOT', '../');
 }
 
 if(!defined('WEBROOT_DIR'))
 {
-   define ('WEBROOT_DIR', 'webroot');
+    define ('WEBROOT_DIR', 'webroot');
 }
 
 /**
diff --git a/cake/dispatcher.php b/cake/dispatcher.php
index a9e4d6ab9..145b83a3b 100644
--- a/cake/dispatcher.php
+++ b/cake/dispatcher.php
@@ -49,30 +49,30 @@ class Dispatcher extends Object
  * Base URL
  * @var string
  */
-   var $base = false;
+    var $base = false;
 
 /**
  * @var string
  */
-   var $admin = false;
+    var $admin = false;
 
 /**
  * @var string
  */
-   var $webservices = null;
+    var $webservices = null;
 
 /**
  * @var string
  */
-   var $plugin = null;
+    var $plugin = null;
 
 /**
  * Constructor.
  */
-   function __construct()
-   {
+    function __construct()
+    {
       parent::__construct();
-   }
+    }
 
 /**
  * Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set).
@@ -84,12 +84,12 @@ class Dispatcher extends Object
  * @param string $url    URL information to work on.
  * @return boolean        Success
  */
-   function dispatch($url, $additionalParams=array())
-   {
+    function dispatch($url, $additionalParams=array())
+    {
       $params = array_merge($this->parseParams($url), $additionalParams);
       $missingController = false;
       $missingAction     = false;
-      $missingView       = false;
+      $missingView        = false;
       $privateAction     = false;
       $this->base = $this->baseUrl();
       if (empty($params['controller']))
@@ -125,11 +125,18 @@ class Dispatcher extends Object
                  else
                  {
                      $ctrlClass = $pluginClass;
+                     $oldAction = $params['action'];
                      $params = $this->_restructureParams($params);
                      $plugin = Inflector::underscore($ctrlName);
                      $this->plugin = $plugin.DS;
                      loadPluginModels($plugin);
                      $this->base = $this->base.'/'.Inflector::underscore($ctrlName);
+                     if(empty($params['controller']) || !class_exists($pluginClass))
+                     {
+                         $params['controller'] = Inflector::underscore($ctrlName);
+                         $ctrlClass = $ctrlName.'Controller';
+                         $params['action'] = $oldAction;
+                     }
                  }
              }
          }
@@ -157,7 +164,7 @@ class Dispatcher extends Object
       if ($missingController)
       {
           return $this->cakeError('missingController',array(array('className' => Inflector::camelize($params['controller']."Controller"),
-                                   'webroot' => $this->webroot)));
+                                    'webroot' => $this->webroot)));
       }
       else
       {
@@ -229,7 +236,7 @@ class Dispatcher extends Object
       }
 
       return $this->_invoke($controller, $params);
-   }
+    }
 
 /**
  * Invokes given controller's render action if autoRender option is set. Otherwise the contents of the operation are returned as a string.
@@ -238,47 +245,47 @@ class Dispatcher extends Object
  * @param array $params
  * @return string
  */
-   function _invoke (&$controller, $params)
-   {
-       if (!empty($controller->beforeFilter))
-       {
-           if(is_array($controller->beforeFilter))
-           {
-               foreach($controller->beforeFilter as $filter)
-               {
-                   if(is_callable(array($controller,$filter)) && $filter != 'beforeFilter')
-                   {
-                       $controller->$filter();
-                   }
-               }
-           }
-           else
-           {
-               if(is_callable(array($controller, $controller->beforeFilter)) && $controller->beforeFilter != 'beforeFilter')
-               {
-                   $controller->{$controller->beforeFilter}();
-               }
-           }
-       }
-       $controller->beforeFilter();
+    function _invoke (&$controller, $params)
+    {
+        if (!empty($controller->beforeFilter))
+        {
+            if(is_array($controller->beforeFilter))
+            {
+                foreach($controller->beforeFilter as $filter)
+                {
+                    if(is_callable(array($controller,$filter)) && $filter != 'beforeFilter')
+                    {
+                        $controller->$filter();
+                    }
+                }
+            }
+            else
+            {
+                if(is_callable(array($controller, $controller->beforeFilter)) && $controller->beforeFilter != 'beforeFilter')
+                {
+                    $controller->{$controller->beforeFilter}();
+                }
+            }
+        }
+        $controller->beforeFilter();
 
-       foreach($controller->components as $c)
-       {
-           if (isset($controller->{$c}) && is_object($controller->{$c}) && is_callable(array($controller->{$c}, 'startup')))
-           {
-               $controller->{$c}->startup($controller);
-           }
-       }
+        foreach($controller->components as $c)
+        {
+            if (isset($controller->{$c}) && is_object($controller->{$c}) && is_callable(array($controller->{$c}, 'startup')))
+            {
+                $controller->{$c}->startup($controller);
+            }
+        }
 
-       $output = call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']);
-       if ($controller->autoRender)
-       {
-           $output = $controller->render();
-       }
-       $controller->output =& $output;
-       $controller->afterFilter();
-       return $controller->output;
-   }
+        $output = call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']);
+        if ($controller->autoRender)
+        {
+            $output = $controller->render();
+        }
+        $controller->output =& $output;
+        $controller->afterFilter();
+        return $controller->output;
+    }
 
 /**
  * Returns array of GET and POST parameters. GET parameters are taken from given URL.
@@ -286,52 +293,52 @@ class Dispatcher extends Object
  * @param string $from_url    URL to mine for parameter information.
  * @return array Parameters found in POST and GET.
  */
-   function parseParams($from_url)
-   {
-       // load routes config
-       $Route = new Router();
-       include CONFIGS.'routes.php';
-       $params = $Route->parse ($from_url);
+    function parseParams($from_url)
+    {
+// load routes config
+        $Route = new Router();
+        include CONFIGS.'routes.php';
+        $params = $Route->parse ($from_url);
 
-       if (ini_get('magic_quotes_gpc') == 1)
-       {
-           if(!empty($_POST))
-           {
-               $params['form'] = stripslashes_deep($_POST);
-           }
-       }
-       else
-       {
-           $params['form'] = $_POST;
-       }
+        if (ini_get('magic_quotes_gpc') == 1)
+        {
+            if(!empty($_POST))
+            {
+                $params['form'] = stripslashes_deep($_POST);
+            }
+        }
+        else
+        {
+            $params['form'] = $_POST;
+        }
 
-       if (isset($params['form']['data']))
-       {
-               $params['data'] = $params['form']['data'];
-       }
+        if (isset($params['form']['data']))
+        {
+                $params['data'] = $params['form']['data'];
+        }
 
-       if (isset($_GET))
-       {
-           if (ini_get('magic_quotes_gpc') == 1)
-           {
-               $params['url'] = stripslashes_deep($_GET);
-           }
-           else
-           {
-               $params['url'] = $_GET;
-           }
-       }
+        if (isset($_GET))
+        {
+            if (ini_get('magic_quotes_gpc') == 1)
+            {
+                $params['url'] = stripslashes_deep($_GET);
+            }
+            else
+            {
+                $params['url'] = $_GET;
+            }
+        }
 
-       foreach ($_FILES as $name => $data)
-       {
-           $params['form'][$name] = $data;
-       }
-       $params['bare'] = empty($params['ajax'])? (empty($params['bare'])? 0: 1): 1;
+        foreach ($_FILES as $name => $data)
+        {
+            $params['form'][$name] = $data;
+        }
+        $params['bare'] = empty($params['ajax'])? (empty($params['bare'])? 0: 1): 1;
 
-       $params['webservices'] = empty($params['webservices']) ? null : $params['webservices'];
+        $params['webservices'] = empty($params['webservices']) ? null : $params['webservices'];
 
-       return $params;
-   }
+        return $params;
+    }
 
 /**
  * Returns a base URL.
@@ -340,18 +347,18 @@ class Dispatcher extends Object
  */
     function baseUrl()
     {
-       $htaccess = null;
-       $base = $this->admin;
-       $this->webroot = '';
-       if (defined('BASE_URL'))
-       {
-           $base = BASE_URL.$this->admin;
-       }
+        $htaccess = null;
+        $base = $this->admin;
+        $this->webroot = '';
+        if (defined('BASE_URL'))
+        {
+            $base = BASE_URL.$this->admin;
+        }
 
-       $docRoot = env('DOCUMENT_ROOT');
-       $scriptName = env('PHP_SELF');
+        $docRoot = env('DOCUMENT_ROOT');
+        $scriptName = env('PHP_SELF');
 
-      // If document root ends with 'webroot', it's probably correctly set
+// If document root ends with 'webroot', it's probably correctly set
       $r = null;
       if (preg_match('/'.APP_DIR.'\\'.DS.WEBROOT_DIR.'/', $docRoot))
       {
@@ -399,21 +406,21 @@ class Dispatcher extends Object
           }
       }
       return $base;
-   }
+    }
 
-   function _restructureParams($params)
-   {
-       $params['controller'] = $params['action'];
-       if(isset($params['pass'][0]))
-       {
-           $params['action'] = $params['pass'][0];
-           array_shift($params['pass']);
-       }
-       else
-       {
-           $params['action'] = null;
-       }
-       return $params;
-   }
+    function _restructureParams($params)
+    {
+        $params['controller'] = $params['action'];
+        if(isset($params['pass'][0]))
+        {
+            $params['action'] = $params['pass'][0];
+            array_shift($params['pass']);
+        }
+        else
+        {
+            $params['action'] = null;
+        }
+        return $params;
+    }
 }
 ?>
\ No newline at end of file
diff --git a/cake/docs/CHANGELOG.txt b/cake/docs/CHANGELOG.txt
index 6b9988c68..fc14935bb 100644
--- a/cake/docs/CHANGELOG.txt
+++ b/cake/docs/CHANGELOG.txt
@@ -1,7 +1,7 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-// +---------------------------------------------------------------------------------------------------+ //
+// +---------------------------------------------------------------------------------------------------+//
 // + $Id$
 // + Last Modified: $Date$
 // + Modified By: $LastChangedBy$
-// +---------------------------------------------------------------------------------------------------+ //
+// +---------------------------------------------------------------------------------------------------+//
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
\ No newline at end of file
diff --git a/cake/docs/CREDITS.txt b/cake/docs/CREDITS.txt
index 6b9988c68..fc14935bb 100644
--- a/cake/docs/CREDITS.txt
+++ b/cake/docs/CREDITS.txt
@@ -1,7 +1,7 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-// +---------------------------------------------------------------------------------------------------+ //
+// +---------------------------------------------------------------------------------------------------+//
 // + $Id$
 // + Last Modified: $Date$
 // + Modified By: $LastChangedBy$
-// +---------------------------------------------------------------------------------------------------+ //
+// +---------------------------------------------------------------------------------------------------+//
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
\ No newline at end of file
diff --git a/cake/docs/GOTCHAS.txt b/cake/docs/GOTCHAS.txt
index 8a99a96e0..b903f01e8 100644
--- a/cake/docs/GOTCHAS.txt
+++ b/cake/docs/GOTCHAS.txt
@@ -1,9 +1,9 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-// +---------------------------------------------------------------------------------------------------+ //
+// +---------------------------------------------------------------------------------------------------+//
 // + $Id$
 // + Last Modified:$
 // + Modified By:$
-// +---------------------------------------------------------------------------------------------------+ //
+// +---------------------------------------------------------------------------------------------------+//
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 You can find some help with problems you may have installing CakePHP here:
diff --git a/cake/docs/README.txt b/cake/docs/README.txt
index 46f7b6cd3..c6c37ac5d 100644
--- a/cake/docs/README.txt
+++ b/cake/docs/README.txt
@@ -1,9 +1,9 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
-// +---------------------------------------------------------------------------------------------------+ //
+// +---------------------------------------------------------------------------------------------------+//
 // + $Id$
 // + Last Modified: $Date$
 // + Modified By: $LastChangedBy$
-// +---------------------------------------------------------------------------------------------------+ //
+// +---------------------------------------------------------------------------------------------------+//
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 This README will be updated
diff --git a/cake/libs/bake.php b/cake/libs/bake.php
index 2f4d8e654..20e74062b 100644
--- a/cake/libs/bake.php
+++ b/cake/libs/bake.php
@@ -39,11 +39,11 @@ uses('object', 'inflector');
  * @package cake
  * @subpackage cake.libs
  * @since CakePHP v CakePHP v 0.10.3.1612
-  */
+ */
 class Bake extends Object
 {
 
- /**
+/**
  * Standard input stream (php://stdin).
  *
  * @var resource
@@ -51,7 +51,7 @@ class Bake extends Object
  */
     var $stdin = null;
 
- /**
+/**
  * Standard output stream (php://stdout).
  *
  * @var resource
@@ -59,7 +59,7 @@ class Bake extends Object
  */
     var $stdout = null;
 
- /**
+/**
  * Standard error stream (php://stderr).
  *
  * @var resource
@@ -67,7 +67,7 @@ class Bake extends Object
  */
     var $stderr = null;
 
- /**
+/**
  * Counts actions taken.
  *
  * @var integer
@@ -75,7 +75,7 @@ class Bake extends Object
  */
     var $actions = null;
 
- /**
+/**
  * Decides whether to overwrite existing files without asking.
  *
  * @var boolean
@@ -83,7 +83,7 @@ class Bake extends Object
  */
     var $dontAsk = false;
 
- /**
+/**
  * Returns code template for PHP file generator.
  *
  * @param string $type
@@ -94,24 +94,24 @@ class Bake extends Object
     {
         switch ($type)
         {
-            case 'view':   return "%s";
+            case 'view':    return "%s";
             case 'model':  return "";
             case 'action': return "\n\tfunction %s () {\n\t\t\n\t}\n";
-            case 'ctrl':   return "";
+            case 'ctrl':    return "";
             case 'helper': return "";
-            case 'test':   return 'abc = new %s ();
     }
 
-    // called after the tests
+// called after the tests
     function tearDown()
     {
         unset($this->abc);
@@ -120,7 +120,7 @@ class %sTest extends TestCase
 /*
     function testFoo ()
     {
-        $result   = $this->abc->Foo();
+        $result    = $this->abc->Foo();
         $expected = \'\';
         $this->assertEquals($result, $expected);
     }
@@ -133,7 +133,7 @@ class %sTest extends TestCase
         }
     }
 
- /**
+/**
  * Baker's constructor method. Initialises bakery, and starts production.
  *
  * @param string $type
@@ -152,7 +152,7 @@ class %sTest extends TestCase
         $this->stdout = fopen('php://stdout', 'w');
         $this->stderr = fopen('php://stderr', 'w');
 
-        // Output directory name
+// Output directory name
         fwrite($this->stderr, "\n".substr(ROOT,0,strlen(ROOT)-1).":\n".str_repeat('-',strlen(ROOT)+1)."\n");
 
         switch ($type)
@@ -172,7 +172,7 @@ class %sTest extends TestCase
             $add_actions = array();
 
             $controllerPlural = Inflector::pluralize($controller);
-            
+
             if ($controllerPlural != $controller)
             {
                 fwrite($this->stdout, "I use pluralized Controller names. You entered '$controller'. I can inflect it to '$controllerPlural'. Should I? If no, I will use '$controller'. [y/n/q] ");
@@ -221,7 +221,7 @@ class %sTest extends TestCase
         }
     }
 
- /**
+/**
  * Creates new view in VIEWS/$controller/ directory.
  *
  * @param string $controller
@@ -245,7 +245,7 @@ class %sTest extends TestCase
         $this->actions++;
     }
 
- /**
+/**
  * Creates new controller with defined actions, controller's test and
  * helper with helper's test.
  *
@@ -263,12 +263,12 @@ class %sTest extends TestCase
     {
         $this->makeController($name, $actions);
         $this->makeControllerTest($name);
-        //$this->makeHelper($name);
-        //$this->makeHelperTest($name);
+//$this->makeHelper($name);
+//$this->makeHelperTest($name);
         $this->actions++;
     }
 
- /**
+/**
  * Creates new controller file with defined actions.
  *
  * @param string $name
@@ -284,14 +284,14 @@ class %sTest extends TestCase
  */
     function makeController ($name, $actions)
     {
-        $ctrl   = $this->makeControllerName($name);
+        $ctrl    = $this->makeControllerName($name);
         $helper = $this->makeHelperName($name);
-        //$body   = sprintf($this->template('ctrl'), $ctrl, $helper, join('', $this->getActions($actions)));
-        $body   = sprintf($this->template('ctrl'), $ctrl, 'AppController', join('', $this->getActions($actions)));
+//$body    = sprintf($this->template('ctrl'), $ctrl, $helper, join('', $this->getActions($actions)));
+        $body    = sprintf($this->template('ctrl'), $ctrl, 'AppController', join('', $this->getActions($actions)));
         return $this->createFile($this->makeControllerFn($name), $body);
     }
 
- /**
+/**
  * Returns controller's name in CamelCase.
  *
  * @param string $name
@@ -304,7 +304,7 @@ class %sTest extends TestCase
         return Inflector::camelize($name).'Controller';
     }
 
- /**
+/**
  * Returns a name for controller's file, underscored.
  *
  * @param string $name
@@ -317,7 +317,7 @@ class %sTest extends TestCase
         return CONTROLLERS.Inflector::underscore($name).'_controller.php';
     }
 
- /**
+/**
  * Creates new test for a controller.
  *
  * @param string $name
@@ -331,13 +331,13 @@ class %sTest extends TestCase
  */
     function makeControllerTest ($name)
     {
-        $fn   = CONTROLLER_TESTS.Inflector::underscore($name).'_controller_test.php';
+        $fn    = CONTROLLER_TESTS.Inflector::underscore($name).'_controller_test.php';
         $body = $this->getTestBody($this->makeControllerName($name));
 
-        return true; //$this->createFile($fn, $body); // Disable creating tests till later
+        return true;//$this->createFile($fn, $body);// Disable creating tests till later
     }
 
- /**
+/**
  * Creates new helper.
  *
  * @param string $name
@@ -355,7 +355,7 @@ class %sTest extends TestCase
         return $this->createFile($this->makeHelperFn($name), $body);
     }
 
- /**
+/**
  * Returns CamelCase name for a helper.
  *
  * @param string $name
@@ -368,7 +368,7 @@ class %sTest extends TestCase
         return Inflector::camelize($name).'Helper';
     }
 
- /**
+/**
  * Underscores file name for a helper.
  *
  * @param string $name
@@ -382,7 +382,7 @@ class %sTest extends TestCase
         return HELPERS.Inflector::underscore($name).'_helper.php';
     }
 
- /**
+/**
  * Creates new test for a helper.
  *
  * @param string $name
@@ -396,13 +396,13 @@ class %sTest extends TestCase
  */
     function makeHelperTest ($name)
     {
-        $fn   = HELPER_TESTS.Inflector::underscore($name).'_helper_test.php';
+        $fn    = HELPER_TESTS.Inflector::underscore($name).'_helper_test.php';
         $body = $this->getTestBody($this->makeHelperName($name));
 
         return $this->createFile($fn, $body);
     }
 
- /**
+/**
  * Returns an array of actions' templates.
  *
  * @param array $as
@@ -420,7 +420,7 @@ class %sTest extends TestCase
         return $out;
     }
 
- /**
+/**
  * Returns a test template for given class.
  *
  * @param string $class
@@ -433,7 +433,7 @@ class %sTest extends TestCase
         return sprintf($this->template('test'), $class, $class);
     }
 
- /**
+/**
  * Creates new model.
  *
  * @param string $name
@@ -470,12 +470,12 @@ class %sTest extends TestCase
         }
 
         $this->createFile($this->getModelFn($name), sprintf($this->template('model'), $this->getModelName($name)));
-        //$this->makeModelTest ($name);
-        // TODO: Add model test back when I'm less lazy
+//$this->makeModelTest ($name);
+// TODO: Add model test back when I'm less lazy
         $this->actions++;
     }
 
- /**
+/**
  * Returns an underscored filename for a model.
  *
  * @param string $name
@@ -489,7 +489,7 @@ class %sTest extends TestCase
         return MODELS.Inflector::underscore($name).'.php';
     }
 
- /**
+/**
  * Creates a test for a given model.
  *
  * @param string $name
@@ -503,13 +503,13 @@ class %sTest extends TestCase
  */
     function makeModelTest ($name)
     {
-        $fn   = MODEL_TESTS.Inflector::underscore($name).'_test.php';
+        $fn    = MODEL_TESTS.Inflector::underscore($name).'_test.php';
         $body = $this->getTestBody($this->getModelName($name));
 
         return $this->createFile($fn, $body);
     }
 
- /**
+/**
  * Returns CamelCased name of a model.
  *
  * @param string $name
@@ -522,7 +522,7 @@ class %sTest extends TestCase
         return Inflector::camelize($name);
     }
 
- /**
+/**
  * Creates a file with given path and contents.
  *
  * @param string $path
@@ -558,7 +558,7 @@ class %sTest extends TestCase
             }
             else
             {
-                fwrite($this->stdout, "Skip   {$shortPath}\n");
+                fwrite($this->stdout, "Skip    {$shortPath}\n");
                 return false;
             }
         }
@@ -567,19 +567,19 @@ class %sTest extends TestCase
         {
             fwrite($f, $contents);
             fclose($f);
-            fwrite($this->stdout, "Wrote   {$shortPath}\n");
-            //            debug ("Wrote {$path}");
+            fwrite($this->stdout, "Wrote    {$shortPath}\n");
+//            debug ("Wrote {$path}");
             return true;
         }
         else
         {
             fwrite($this->stderr, "Error! Couldn't open {$shortPath} for writing.\n");
-            //            debug ("Error! Couldn't open {$path} for writing.");
+//            debug ("Error! Couldn't open {$path} for writing.");
             return false;
         }
     }
 
- /**
+/**
  * Creates a directory with given path.
  *
  * @param string $path
@@ -600,13 +600,13 @@ class %sTest extends TestCase
         if (mkdir($path))
         {
             fwrite($this->stdout, "Created {$shortPath}\n");
-            //            debug ("Created {$path}");
+//            debug ("Created {$path}");
             return true;
         }
         else
         {
             fwrite($this->stderr, "Error! Couldn't create dir {$shortPath}\n");
-            //            debug ("Error! Couldn't create dir {$path}");
+//            debug ("Error! Couldn't create dir {$path}");
             return false;
         }
     }
diff --git a/cake/libs/cache.php b/cake/libs/cache.php
index 3cbc51ce8..35b22c36c 100644
--- a/cake/libs/cache.php
+++ b/cake/libs/cache.php
@@ -30,9 +30,9 @@
 
 
 /**
-  * Included libraries.
-  *
-  */
+ * Included libraries.
+ *
+ */
 if(!class_exists('Model'))
 {
     uses(DS.'model'.DS.'model');
@@ -48,64 +48,64 @@ if(!class_exists('Model'))
  */
 class Cache extends Model {
 
- /**
-  * Identifier. Either an MD5 string or NULL.
-  *
-  * @var string
-  */
+/**
+ * Identifier. Either an MD5 string or NULL.
+ *
+ * @var string
+ */
     var $id = null;
 
- /**
-  * Content container for cache data.
-  *
-  * @var unknown_type
-  */
+/**
+ * Content container for cache data.
+ *
+ * @var unknown_type
+ */
     var $data = null;
 
- /**
-  * Content to be cached.
-  *
-  * @var unknown_type
-  */
+/**
+ * Content to be cached.
+ *
+ * @var unknown_type
+ */
     var $for_caching = null;
 
- /**
-  * Name of the database table used for caching.
-  *
-  * @var string
-  */
+/**
+ * Name of the database table used for caching.
+ *
+ * @var string
+ */
     var $useTable = 'cache';
 
- /**
-  * Constructor. Generates an md5'ed id for internal use. Calls the constructor on Model as well.
-  *
-  * @param unknown_type $id
-  */
+/**
+ * Constructor. Generates an md5'ed id for internal use. Calls the constructor on Model as well.
+ *
+ * @param unknown_type $id
+ */
     function __construct ($id)
     {
         $this->id = (md5($id));
         parent::__construct($this->id);
     }
 
- /**
-  * Returns this object's id after setting it. If called without parameters the current object's id is returned.
-  *
-  * @param unknown_type $id
-  * @return unknown
-  */
+/**
+ * Returns this object's id after setting it. If called without parameters the current object's id is returned.
+ *
+ * @param unknown_type $id
+ * @return unknown
+ */
     function id ($id=null)
     {
         if (!$id) return $this->id;
         return ($this->id = $id);
     }
 
- /**
-  * Store given content in cache database.
-  *
-  * @param string $content         Content to keep in cache.
-  * @param int $keep_for         Number of seconds to keep data in cache.
-  * @return boolean                Success
-  */
+/**
+ * Store given content in cache database.
+ *
+ * @param string $content         Content to keep in cache.
+ * @param int $keep_for         Number of seconds to keep data in cache.
+ * @return boolean                Success
+ */
     function remember ($content, $keep_for=CACHE_PAGES_FOR)
     {
         $data = addslashes($this->for_caching.$content);
@@ -113,12 +113,12 @@ class Cache extends Model {
         return $this->query("REPLACE {$this->useTable} (id,data,expire) VALUES ('{$this->id}', '{$data}', '{$expire}')");
     }
 
- /**
-  * Returns content from the Cache object itself, if the Cache object has a non-empty data property.
-  * Else from the database cache.
-   *
-  * @return unknown
-    */
+/**
+ * Returns content from the Cache object itself, if the Cache object has a non-empty data property.
+ * Else from the database cache.
+ *
+ * @return unknown
+ */
     function restore()
     {
         if (empty($this->data['data']))
@@ -127,31 +127,31 @@ class Cache extends Model {
         return $this->data['data'];
     }
 
- /**
-  * Returns true if the cache data property has current (non-stale) content for given id.
-  *
-  * @return boolean
-  */
+/**
+ * Returns true if the cache data property has current (non-stale) content for given id.
+ *
+ * @return boolean
+ */
     function has()
     {
         return is_array($this->data = $this->find("id='{$this->id}' AND expire>NOW()"));
     }
 
- /**
-  * Appends $string to the for_caching property of the Cache object.
-  *
-  * @param string $string
-  */
+/**
+ * Appends $string to the for_caching property of the Cache object.
+ *
+ * @param string $string
+ */
     function append($string)
     {
         $this->for_caching .= $string;
     }
 
- /**
-  * Clears the cache database table.
-  *
-  * @return unknown
-  */
+/**
+ * Clears the cache database table.
+ *
+ * @return unknown
+ */
     function clear()
     {
         return $this->query("DELETE FROM {$this->useTable}");
diff --git a/cake/libs/cake_log.php b/cake/libs/cake_log.php
index e7ef5af06..1fa7f801a 100644
--- a/cake/libs/cake_log.php
+++ b/cake/libs/cake_log.php
@@ -29,9 +29,9 @@
  */
 
 /**
-  * Included libraries.
-  *
-  */
+ * Included libraries.
+ *
+ */
 if(!class_exists('File'))
 {
     uses('file');
@@ -53,14 +53,14 @@ class CakeLog
  * @param string $msg  Message to log
  * @return boolean Success
  */
-   function write($type, $msg)
-   {
+    function write($type, $msg)
+    {
       $filename = LOGS.$type.'.log';
       $output = date('y-m-d H:i:s').' '.ucfirst($type).': '.$msg."\n";
 
       $log = new File($filename);
       return $log->append($output);
-   }
+    }
 }
 
 ?>
\ No newline at end of file
diff --git a/cake/libs/class_registry.php b/cake/libs/class_registry.php
index 29c3c6943..de732c11a 100644
--- a/cake/libs/class_registry.php
+++ b/cake/libs/class_registry.php
@@ -48,22 +48,22 @@ class ClassRegistry
  * @var array
  * @access private
  */
-   var $_objects = array();
+    var $_objects = array();
 
 /**
  * Return a singleton instance of the ClassRegistry.
  *
  * @return ClassRegistry instance
  */
-   function &getInstance()
-   {
-       static $instance = array();
-       if (!$instance)
-       {
-           $instance[0] =& new ClassRegistry;
-       }
-       return $instance[0];
-   }
+    function &getInstance()
+    {
+        static $instance = array();
+        if (!$instance)
+        {
+            $instance[0] =& new ClassRegistry;
+        }
+        return $instance[0];
+    }
 
 /**
  * Add $object to the registry, associating it with the name $key.
@@ -71,8 +71,8 @@ class ClassRegistry
  * @param string $key
  * @param mixed $object
  */
-   function addObject($key, &$object)
-   {
+    function addObject($key, &$object)
+    {
       $_this =& ClassRegistry::getInstance();
       $key = strtolower($key);
 
@@ -80,7 +80,7 @@ class ClassRegistry
       {
          $_this->_objects[$key] =& $object;
       }
-   }
+    }
 
 /**
  * Returns true if given key is present in the ClassRegistry.
@@ -88,12 +88,12 @@ class ClassRegistry
  * @param string $key     Key to look for
  * @return boolean         Success
  */
-   function isKeySet($key)
-   {
+    function isKeySet($key)
+    {
       $_this =& ClassRegistry::getInstance();
       $key = strtolower($key);
       return array_key_exists($key, $_this->_objects);
-   }
+    }
 
 /**
  * Return object which corresponds to given key.
@@ -101,11 +101,11 @@ class ClassRegistry
  * @param string $key
  * @return mixed
  */
-   function &getObject($key)
-   {
+    function &getObject($key)
+    {
       $key = strtolower($key);
       $_this =& ClassRegistry::getInstance();
       return $_this->_objects[$key];
-   }
+    }
 }
 ?>
\ No newline at end of file
diff --git a/cake/libs/controller/components/acl.php b/cake/libs/controller/components/acl.php
index 473963117..06833a9e7 100644
--- a/cake/libs/controller/components/acl.php
+++ b/cake/libs/controller/components/acl.php
@@ -41,25 +41,25 @@
 class AclComponent extends Object
 {
 
-   var $_instance  = null;
-   var $controller = true;
+    var $_instance  = null;
+    var $controller = true;
 
 /**
  * Constructor. Will return an instance of the correct ACL class.
  *
  */
-   function __construct()
-   {
+    function __construct()
+    {
       $this->getACL();
-   }
+    }
 
 /**
  * Static function used to gain an instance of the correct ACL class.
  *
  * @return MyACL
  */
-   function &getACL()
-   {
+    function &getACL()
+    {
       if($this->_instance == null)
       {
         uses('controller'.DS.'components'.DS.ACL_FILENAME);
@@ -67,26 +67,26 @@ class AclComponent extends Object
         $this->_instance = new $classname;
       }
       return $this->_instance;
-   }
+    }
 
 /**
  * Empty class defintion, to be overridden in subclasses.
  *
  */
-   function _initACL()
-   {
+    function _initACL()
+    {
 
-   }
+    }
 
 /**
  * Pass-thru function for ACL check instance.
  *
  * @return boolean
  */
-   function check($aro, $aco, $action = "*")
-   {
+    function check($aro, $aco, $action = "*")
+    {
       return $this->_instance->check($aro, $aco, $action);
-   }
+    }
 
 
 /**
@@ -94,50 +94,50 @@ class AclComponent extends Object
  *
  * @return boolean
  */
-   function allow($aro, $aco, $action = "*")
-   {
+    function allow($aro, $aco, $action = "*")
+    {
       return $this->_instance->allow($aro, $aco, $action);
-   }
+    }
 
 /**
  * Pass-thru function for ACL deny instance.
  *
  * @return boolean
  */
-   function deny($aro, $aco, $action = "*")
-   {
+    function deny($aro, $aco, $action = "*")
+    {
       return $this->_instance->deny($aro, $aco, $action);
-   }
+    }
 
 /**
  * Pass-thru function for ACL inherit instance.
  *
  * @return boolean
  */
-   function inherit($aro, $aco, $action = "*")
-   {
+    function inherit($aro, $aco, $action = "*")
+    {
       return $this->_instance->inherit($aro, $aco, $action);
-   }
+    }
 
 /**
  * Pass-thru function for ACL grant instance.
  *
  * @return boolean
  */
-   function grant($aro, $aco, $action = "*")
-   {
+    function grant($aro, $aco, $action = "*")
+    {
       return $this->_instance->grant($aro, $aco, $action);
-   }
+    }
 
 /**
  * Pass-thru function for ACL grant instance.
  *
  * @return boolean
  */
-   function revoke($aro, $aco, $action = "*")
-   {
+    function revoke($aro, $aco, $action = "*")
+    {
       return $this->_instance->revoke($aro, $aco, $action);
-   }
+    }
 
 
 /**
@@ -145,10 +145,10 @@ class AclComponent extends Object
  *
  * @return Aro
  */
-   function getAro($id)
-   {
+    function getAro($id)
+    {
       return $this->_instance->getAro($id);
-   }
+    }
 
 
 /**
@@ -156,10 +156,10 @@ class AclComponent extends Object
  *
  * @return Aco
  */
-   function getAco($id)
-   {
+    function getAco($id)
+    {
       return $this->_instance->getAco($id);
-   }
+    }
 
 }
 
diff --git a/cake/libs/controller/components/acl_base.php b/cake/libs/controller/components/acl_base.php
index 528f04bd2..3251778c0 100644
--- a/cake/libs/controller/components/acl_base.php
+++ b/cake/libs/controller/components/acl_base.php
@@ -45,16 +45,16 @@ class AclBase
  *
  * @return AclBase
  */
-   function AclBase()
-   {
-      //No instantiations or constructor calls (even statically)
+    function AclBase()
+    {
+//No instantiations or constructor calls (even statically)
       if (strcasecmp(get_class($this), "AclBase") == 0 || !is_subclass_of($this, "AclBase"))
       {
          trigger_error(__("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration."), E_USER_ERROR);
          return NULL;
       }
 
-   }
+    }
 
 /**
  * Empty method to be overridden in subclasses
@@ -63,7 +63,7 @@ class AclBase
  * @param unknown_type $aco
  * @param string $action
  */
-   function check($aro, $aco, $action = "*") {}
+    function check($aro, $aco, $action = "*") {}
 
 }
 
diff --git a/cake/libs/controller/components/dbacl/db_acl.php b/cake/libs/controller/components/dbacl/db_acl.php
index 7ce3c81b1..88a3dc7f2 100644
--- a/cake/libs/controller/components/dbacl/db_acl.php
+++ b/cake/libs/controller/components/dbacl/db_acl.php
@@ -49,10 +49,10 @@ class DB_ACL extends AclBase
  * Enter description here...
  *
  */
-   function __construct()
-   {
+    function __construct()
+    {
 
-   }
+    }
 
 /**
  * Enter description here...
@@ -62,8 +62,8 @@ class DB_ACL extends AclBase
  * @param unknown_type $action
  * @return unknown
  */
-   function check($aro, $aco, $action = "*")
-   {
+    function check($aro, $aco, $action = "*")
+    {
 
       $Perms = new ArosAco();
       $Aro = new Aro();
@@ -101,9 +101,9 @@ class DB_ACL extends AclBase
          {
             foreach($perms as $perm)
             {
-               if($action == '*')
-               {
-                  // ARO must be cleared for ALL ACO actions
+                if($action == '*')
+                {
+// ARO must be cleared for ALL ACO actions
                   foreach($permKeys as $key)
                   {
                      if(isset($perm['aros_acos']))
@@ -115,9 +115,9 @@ class DB_ACL extends AclBase
                      }
                   }
                   return true;
-               }
-               else
-               {
+                }
+                else
+                {
                   switch($perm['aros_acos']['_' . $action])
                   {
                      case -1:
@@ -128,21 +128,21 @@ class DB_ACL extends AclBase
                      case 1:
                         return true;
                   }
-               }
+                }
             }
          }
       }
 
       return false;
-   }
+    }
 
 /**
  * Allow
  *
  * @return boolean
  */
-   function allow($aro, $aco, $action = "*", $value = 1)
-   {
+    function allow($aro, $aco, $action = "*", $value = 1)
+    {
       $Perms = new ArosAco();
       $perms = $this->getAclLink($aro, $aco);
       $permKeys = $this->_getAcoKeys($Perms->loadInfo());
@@ -151,7 +151,7 @@ class DB_ACL extends AclBase
 
       if($perms == false)
       {
-         // One of the nodes does not exist
+// One of the nodes does not exist
          return false;
       }
 
@@ -176,7 +176,7 @@ class DB_ACL extends AclBase
          }
          else
          {
-            // Raise an error
+// Raise an error
             return false;
          }
       }
@@ -188,7 +188,7 @@ class DB_ACL extends AclBase
       {
          $save['id'] = $perms['link'][0]['aros_acos']['id'];
       }
-      //return $Perms->save(array('ArosAco' => $save));
+//return $Perms->save(array('ArosAco' => $save));
 
       if(isset($save['id']))
       {
@@ -198,7 +198,7 @@ class DB_ACL extends AclBase
          {
             if($key != 'id')
             {
-               $saveKeys[] = $key . ' = ' . $val;
+                $saveKeys[] = $key . ' = ' . $val;
             }
          }
          $q .= implode(', ', $saveKeys) . ' where id = ' . $save['id'];
@@ -210,47 +210,47 @@ class DB_ACL extends AclBase
 
       $Perms->db->query($q);
       return true;
-   }
+    }
 
 /**
  * Deny
  *
  * @return boolean
  */
-   function deny($aro, $aco, $action = "*")
-   {
+    function deny($aro, $aco, $action = "*")
+    {
       return $this->allow($aro, $aco, $action, -1);
-   }
+    }
 
 /**
  * Inherit
  *
  * @return boolean
  */
-   function inherit($aro, $aco, $action = "*")
-   {
+    function inherit($aro, $aco, $action = "*")
+    {
       return $this->allow($aro, $aco, $action, 0);
-   }
+    }
 
 /**
  * Allow alias
  *
  * @return boolean
  */
-   function grant($aro, $aco, $action = "*")
-   {
+    function grant($aro, $aco, $action = "*")
+    {
       return $this->allow($aro, $aco, $action);
-   }
+    }
 
 /**
  * Deny alias
  *
  * @return boolean
  */
-   function revoke($aro, $aco, $action = "*")
-   {
+    function revoke($aro, $aco, $action = "*")
+    {
       return $this->deny($aro, $aco, $action);
-   }
+    }
 
 
 
@@ -260,17 +260,17 @@ class DB_ACL extends AclBase
  * @param unknown_type $id
  * @return unknown
  */
-   function getAro($id = null)
-   {
+    function getAro($id = null)
+    {
      if($id == null)
      {
-        // Raise error
+// Raise error
      }
      $aro = new Aro();
-     $tmp = $aro->find(is_string($aro) ? "aros.alias = '" . addslashes($aro) . "'" : "aros.user_id   = {$aro}");
+     $tmp = $aro->find(is_string($aro) ? "aros.alias = '" . addslashes($aro) . "'" : "aros.user_id    = {$aro}");
      $aro->setId($tmp['aro']['id']);
      return $aro;
-   }
+    }
 
 
 /**
@@ -279,17 +279,17 @@ class DB_ACL extends AclBase
  * @param unknown_type $id
  * @return unknown
  */
-   function getAco($id = null)
-   {
+    function getAco($id = null)
+    {
      if($id == null)
      {
-        // Raise error
+// Raise error
      }
      $aco = new Aco();
-     $tmp = $aco->find(is_string($aco) ? "acos.alias = '" . addslashes($aco) . "'" : "acos.user_id   = {$aco}");
+     $tmp = $aco->find(is_string($aco) ? "acos.alias = '" . addslashes($aco) . "'" : "acos.user_id    = {$aco}");
      $aro->setId($tmp['aco']['id']);
      return $aco;
-   }
+    }
 
 
 /**
@@ -299,12 +299,12 @@ class DB_ACL extends AclBase
  * @param unknown_type $aco
  * @return unknown
  */
-   function getAclLink($aro, $aco)
-   {
+    function getAclLink($aro, $aco)
+    {
       $Aro = new Aro();
       $Aco = new Aco();
 
-      $qAro = (is_string($aro) ? "alias = '" . addslashes($aro) . "'" : "user_id   = {$aro}");
+      $qAro = (is_string($aro) ? "alias = '" . addslashes($aro) . "'" : "user_id    = {$aro}");
       $qAco = (is_string($aco) ? "alias = '" . addslashes($aco) . "'" : "object_id = {$aco}");
 
       $obj = array();
@@ -323,7 +323,7 @@ class DB_ACL extends AclBase
          'aco'  => $obj['Aco']['id'],
          'link' => $Aro->findBySql("select * from aros_acos where aro_id = {$obj['Aro']['id']} and aco_id = {$obj['Aco']['id']}")
       );
-   }
+    }
 
 /**
  * Enter description here...
@@ -331,8 +331,8 @@ class DB_ACL extends AclBase
  * @param unknown_type $keys
  * @return unknown
  */
-   function _getAcoKeys($keys)
-   {
+    function _getAcoKeys($keys)
+    {
       $newKeys = array();
       $keys = $keys->value;
       foreach($keys as $key)
@@ -343,7 +343,7 @@ class DB_ACL extends AclBase
          }
       }
       return $newKeys;
-   }
+    }
 
 }
 
diff --git a/cake/libs/controller/components/dbacl/models/aclnode.php b/cake/libs/controller/components/dbacl/models/aclnode.php
index 64f28f8ed..488139868 100644
--- a/cake/libs/controller/components/dbacl/models/aclnode.php
+++ b/cake/libs/controller/components/dbacl/models/aclnode.php
@@ -46,11 +46,11 @@ class AclNode extends AppModel
  * Enter description here...
  *
  */
-   function __construct()
-   {
+    function __construct()
+    {
       $this->setSource();
       parent::__construct();
-   }
+    }
 
 /**
  * Enter description here...
@@ -60,8 +60,8 @@ class AclNode extends AppModel
  * @param unknown_type $alias
  * @return unknown
  */
-   function create($link_id = 0, $parent_id = null, $alias = '')
-   {
+    function create($link_id = 0, $parent_id = null, $alias = '')
+    {
       parent::create();
 
       if (strtolower(get_class($this)) == "aclnode")
@@ -78,7 +78,7 @@ class AclNode extends AppModel
 
          if($parent[0]['MAX(rght)'] == null)
          {
-            // The tree is empty
+// The tree is empty
             $parent['lft'] = 0;
          }
       }
@@ -96,14 +96,14 @@ class AclNode extends AppModel
 
       $return = $this->save(array($class => array(
         $secondary_id => $link_id,
-        'alias'       => $alias,
+        'alias'        => $alias,
         'lft'         => $parent['lft'] + 1,
         'rght'        => $parent['lft'] + 2
       )));
 
       $this->setId($this->getLastInsertID());
       return $return;
-   }
+    }
 
 
 /**
@@ -113,8 +113,8 @@ class AclNode extends AppModel
  * @param unknown_type $id
  * @return unknown
  */
-   function setParent($parent_id = null, $id = null)
-   {
+    function setParent($parent_id = null, $id = null)
+    {
       if (strtolower(get_class($this)) == "aclnode")
       {
          trigger_error(__("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration."), E_USER_ERROR);
@@ -134,12 +134,12 @@ class AclNode extends AppModel
       $object = $this->find($this->_resolveID($id, $secondary_id));
       if($object == null || count($object) == 0)
       {
-         // Couldn't find object
+// Couldn't find object
          return false;
       }
       $parent = $this->getParent(intval($object[$class][$secondary_id]));
 
-      // Node is already at root, or new parent == old parent
+// Node is already at root, or new parent == old parent
       if(($parent == null && $parent_id == null) || ($parent_id == $parent[$class][$secondary_id]) || ($parent_id == $parent[$class]['alias']))
       {
          return false;
@@ -147,7 +147,7 @@ class AclNode extends AppModel
 
       if($parent_id != null && $parent[$class]['lft'] <= $object[$class]['lft'] && $parent[$class]['rght'] >= $object[$class]['rght'])
       {
-         // Can't move object inside self or own child
+// Can't move object inside self or own child
          return false;
       }
       $this->_syncTable($table_name, 0, $object[$class]['lft'], $object[$class]['lft']);
@@ -173,7 +173,7 @@ class AclNode extends AppModel
          $this->_syncTable($table_name, 2, $parent['lft'], $parent['lft']);
       }
 
-   }
+    }
 
 
 /**
@@ -182,8 +182,8 @@ class AclNode extends AppModel
  * @param unknown_type $id
  * @return unknown
  */
-   function getParent($id)
-   {
+    function getParent($id)
+    {
       $path = $this->getPath($id);
       if($path == null || count($path) < 2)
       {
@@ -193,7 +193,7 @@ class AclNode extends AppModel
       {
          return $path[count($path) - 2];
       }
-   }
+    }
 
 /**
  * Enter description here...
@@ -201,8 +201,8 @@ class AclNode extends AppModel
  * @param unknown_type $id
  * @return unknown
  */
-   function getPath($id)
-   {
+    function getPath($id)
+    {
       if (strtolower(get_class($this)) == "aclnode")
       {
          trigger_error(__("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration."), E_USER_ERROR);
@@ -216,7 +216,7 @@ class AclNode extends AppModel
          return null;
       }
       return $this->findAll("{$data_name}.lft <= {$item[$class]['lft']} and {$data_name}.rght >= {$item[$class]['rght']}");
-   }
+    }
 
 /**
  * Enter description here...
@@ -224,8 +224,8 @@ class AclNode extends AppModel
  * @param unknown_type $id
  * @return unknown
  */
-   function getChildren($id)
-   {
+    function getChildren($id)
+    {
       if (strtolower(get_class($this)) == "aclnode")
       {
          trigger_error(__("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration."), E_USER_ERROR);
@@ -235,7 +235,7 @@ class AclNode extends AppModel
 
       $item = $this->find($this->_resolveID($id, $secondary_id));
       return $this->findAll("{$data_name}.lft > {$item[$class]['lft']} and {$data_name}.rght < {$item[$class]['rght']}");
-   }
+    }
 
 /**
  * Enter description here...
@@ -244,12 +244,12 @@ class AclNode extends AppModel
  * @param unknown_type $fKey
  * @return unknown
  */
-   function _resolveID($id, $fKey)
-   {
+    function _resolveID($id, $fKey)
+    {
       $key = (is_string($id) ? 'alias' : $fKey);
       $val = (is_string($id) ? '"' . addslashes($id) . '"' : $id);
       return "{$key} = {$val}";
-   }
+    }
 
 /**
  * Enter description here...
@@ -259,37 +259,37 @@ class AclNode extends AppModel
  * @param unknown_type $lft
  * @param unknown_type $rght
  */
-   function _syncTable($table, $dir, $lft, $rght)
-   {
+    function _syncTable($table, $dir, $lft, $rght)
+    {
       $shift = ($dir == 2 ? 1 : 2);
       $this->db->query("UPDATE $table SET rght = rght " . ($dir > 0 ? "+" : "-") . " {$shift} WHERE rght > " . $rght);
       $this->db->query("UPDATE $table SET lft  = lft  " . ($dir > 0 ? "+" : "-") . " {$shift} WHERE lft  > " . $lft);
-   }
+    }
 
 /**
  * Enter description here...
  *
  * @return unknown
  */
-   function __dataVars()
-   {
+    function __dataVars()
+    {
       $vars = array();
       $class = Inflector::camelize(strtolower(get_class($this)));
       $vars['secondary_id'] = (strtolower($class) == 'aro' ? 'user_id' : 'object_id');
       $vars['data_name']    = $class;
-      $vars['table_name']   = strtolower($class) . 's';
+      $vars['table_name']    = strtolower($class) . 's';
       $vars['class']        = Inflector::camelize($class);
       return $vars;
-   }
+    }
 
 /**
  * Enter description here...
  *
  */
-   function setSource()
-   {
+    function setSource()
+    {
       $this->table = low(get_class($this)) . "s";
-   }
+    }
 }
 
 ?>
\ No newline at end of file
diff --git a/cake/libs/controller/components/dbacl/models/aco.php b/cake/libs/controller/components/dbacl/models/aco.php
index e06f5bf02..6f41be80e 100644
--- a/cake/libs/controller/components/dbacl/models/aco.php
+++ b/cake/libs/controller/components/dbacl/models/aco.php
@@ -40,13 +40,13 @@
  */
 class Aco extends AclNode
 {
-   var $name = 'Aco';
+    var $name = 'Aco';
 /**
  * Enter description here...
  *
  * @var unknown_type
  */
-   var $hasMany = 'ArosAco';
+    var $hasMany = 'ArosAco';
 
 }
 
diff --git a/cake/libs/controller/components/dbacl/models/acoaction.php b/cake/libs/controller/components/dbacl/models/acoaction.php
index d9cfe8f57..9159d912e 100644
--- a/cake/libs/controller/components/dbacl/models/acoaction.php
+++ b/cake/libs/controller/components/dbacl/models/acoaction.php
@@ -52,7 +52,7 @@ class AcoAction extends AppModel
  *
  * @var unknown_type
  */
-   var $belongsTo = 'Aco';
+    var $belongsTo = 'Aco';
 }
 
 ?>
\ No newline at end of file
diff --git a/cake/libs/controller/components/dbacl/models/aros_aco.php b/cake/libs/controller/components/dbacl/models/aros_aco.php
index ccc9c1604..fae62a723 100644
--- a/cake/libs/controller/components/dbacl/models/aros_aco.php
+++ b/cake/libs/controller/components/dbacl/models/aros_aco.php
@@ -47,19 +47,19 @@ class ArosAco extends AppModel
  *
  * @var unknown_type
  */
-   var $name = 'ArosAco';
+    var $name = 'ArosAco';
 /**
  * Enter description here...
  *
  * @var unknown_type
  */
-   var $useTable = 'aros_acos';
+    var $useTable = 'aros_acos';
 /**
  * Enter description here...
  *
  * @var unknown_type
  */
-   var $belongsTo = 'Aro,Aco';
+    var $belongsTo = 'Aro,Aco';
 }
 
 ?>
\ No newline at end of file
diff --git a/cake/libs/controller/components/iniacl/ini_acl.php b/cake/libs/controller/components/iniacl/ini_acl.php
index abdeaf564..8288fb7ce 100644
--- a/cake/libs/controller/components/iniacl/ini_acl.php
+++ b/cake/libs/controller/components/iniacl/ini_acl.php
@@ -43,152 +43,152 @@ class INI_ACL extends AclBase
  * The constructor must be overridden, as AclBase is abstract.
  *
  */
-   function __construct()
-   {
+    function __construct()
+    {
       
-   }
-   
+    }
+    
 /**
  * Main ACL check function. Checks to see if the ARO (access request object) has access to the ACO (access control object).
- * Looks at the acl.ini.php file for permissions (see instructions in /config/acl.ini.php).
+ * Looks at the acl.ini.php file for permissions (see instructions in/config/acl.ini.php).
  *
  * @param string $aro
  * @param string $aco
  * @return boolean
  */
-   function check($aro, $aco, $aco_action = null)
-   {
+    function check($aro, $aco, $aco_action = null)
+    {
       $aclConfig = $this->readConfigFile(CONFIGS . 'acl.ini.php');
       
-      //First, if the user is specifically denied, then DENY
+//First, if the user is specifically denied, then DENY
       if(isset($aclConfig[$aro]['deny']))
       {
          $userDenies = $this->arrayTrim(explode(",", $aclConfig[$aro]['deny']));
          if (array_search($aco, $userDenies))
          {
-            //echo "User Denied!";
+//echo "User Denied!";
             return false;
          }
       }
       
-      //Second, if the user is specifically allowed, then ALLOW
+//Second, if the user is specifically allowed, then ALLOW
       if(isset($aclConfig[$aro]['allow']))
       {
          $userAllows = $this->arrayTrim(explode(",", $aclConfig[$aro]['allow']));
          if (array_search($aco, $userAllows))
          {
-            //echo "User Allowed!";
+//echo "User Allowed!";
             return true;
          }
       }
       
-      //Check group permissions
+//Check group permissions
       if (isset($aclConfig[$aro]['groups']))
       {
          $userGroups = $this->arrayTrim(explode(",", $aclConfig[$aro]['groups']));
          foreach ($userGroups as $group)
          {
-            //If such a group exists,
+//If such a group exists,
             if(array_key_exists($group, $aclConfig))
             {
-               //If the group is specifically denied, then DENY
-               if(isset($aclConfig[$group]['deny']))
-               {
+//If the group is specifically denied, then DENY
+                if(isset($aclConfig[$group]['deny']))
+                {
                   $groupDenies = $this->arrayTrim(explode(",", $aclConfig[$group]['deny']));
                   if (array_search($aco, $groupDenies))
                   {
-                     //echo("Group Denied!");
+//echo("Group Denied!");
                      return false;
                   }
-               }
+                }
       
-               //If the group is specifically allowed, then ALLOW
-               if(isset($aclConfig[$group]['allow']))
-               {
+//If the group is specifically allowed, then ALLOW
+                if(isset($aclConfig[$group]['allow']))
+                {
                   $groupAllows = $this->arrayTrim(explode(",", $aclConfig[$group]['allow']));
                   if (array_search($aco, $groupAllows))
                   {
-                     //echo("Group Allowed!");
+//echo("Group Allowed!");
                      return true;
                   }
-               }
+                }
             }
          }
       }
       
-      //Default, DENY
-      //echo("DEFAULT: DENY.");
+//Default, DENY
+//echo("DEFAULT: DENY.");
       return false;
-   }
-   
+    }
+    
 /**
  * Parses an INI file and returns an array that reflects the INI file's section structure. Double-quote friendly.
  *
  * @param string $fileName
  * @return array
  */
-   function readConfigFile ($fileName)
-   {
-       $fileLineArray = file($fileName);
-   
-       foreach ($fileLineArray  as $fileLine)
-       {
-           $dataLine = trim($fileLine);
-           $firstChar = substr($dataLine, 0, 1);
-           if ($firstChar != ';' && $dataLine != '')
-           {
-               if ($firstChar == '[' && substr($dataLine, -1, 1) == ']')
-               {
-                   $sectionName = preg_replace('/[\[\]]/', '', $dataLine);
-               }
-               else
-               {
-                   $delimiter = strpos($dataLine, '=');
-                   if ($delimiter > 0)
-                   {
-                       $key = strtolower(trim(substr($dataLine, 0, $delimiter)));
-                       $value = trim(substr($dataLine, $delimiter + 1));
-                       if (substr($value, 0, 1) == '"' && substr($value, -1) == '"')
-                       {
-                           $value = substr($value, 1, -1);
-                       }
-                       $iniSetting[$sectionName][$key] = stripcslashes($value);
-                   }
-                   else
-                   {
+    function readConfigFile ($fileName)
+    {
+        $fileLineArray = file($fileName);
+    
+        foreach ($fileLineArray  as $fileLine)
+        {
+            $dataLine = trim($fileLine);
+            $firstChar = substr($dataLine, 0, 1);
+            if ($firstChar != ';' && $dataLine != '')
+            {
+                if ($firstChar == '[' && substr($dataLine, -1, 1) == ']')
+                {
+                    $sectionName = preg_replace('/[\[\]]/', '', $dataLine);
+                }
+                else
+                {
+                    $delimiter = strpos($dataLine, '=');
+                    if ($delimiter > 0)
+                    {
+                        $key = strtolower(trim(substr($dataLine, 0, $delimiter)));
+                        $value = trim(substr($dataLine, $delimiter + 1));
+                        if (substr($value, 0, 1) == '"' && substr($value, -1) == '"')
+                        {
+                            $value = substr($value, 1, -1);
+                        }
+                        $iniSetting[$sectionName][$key] = stripcslashes($value);
+                    }
+                    else
+                    {
                       if(!isset($sectionName))
                       {
                          $sectionName = '';
                       }
-                       $iniSetting[$sectionName][strtolower(trim($dataLine))]='';
-                   }
-               }
-           }
-           else
-           {
-           }
-       }
-       return $iniSetting;
-   }
-   
+                        $iniSetting[$sectionName][strtolower(trim($dataLine))]='';
+                    }
+                }
+            }
+            else
+            {
+            }
+        }
+        return $iniSetting;
+    }
+    
 /**
  * Removes trailing spaces on all array elements (to prepare for searching)
  *
  * @param array $array
  * @return array
  */
-   function arrayTrim($array)
-   {
+    function arrayTrim($array)
+    {
       foreach($array as $element) {
          $element = trim($element);
       }
       
-      //Adding this element keeps array_search from returning 0:
-      //0 is the first key, which may be correct, but 0 is interpreted as false.
-      //Adding this element makes all the keys be positive integers.
+//Adding this element keeps array_search from returning 0:
+//0 is the first key, which may be correct, but 0 is interpreted as false.
+//Adding this element makes all the keys be positive integers.
       array_unshift($array, "");
       return $array;
-   }
+    }
 
 }
 
diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php
index 5918ad2f7..317527d48 100644
--- a/cake/libs/controller/components/request_handler.php
+++ b/cake/libs/controller/components/request_handler.php
@@ -73,7 +73,7 @@ class RequestHandlerComponent extends Object
         {
             $controller->layout = $this->ajaxLayout;
 
-            // Add UTF-8 header for IE6 on XPsp2 bug
+// Add UTF-8 header for IE6 on XPsp2 bug
             header('Content-Type: text/html; charset=UTF-8');
         }
     }
diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php
index a7db47f4e..cb6e192f4 100644
--- a/cake/libs/controller/controller.php
+++ b/cake/libs/controller/controller.php
@@ -246,7 +246,7 @@ class Controller extends Object
         elseif($this->uses === false)
         {
             return $this->cakeError('missingModel',array(array('className' => $this->modelClass,
-                                                               'webroot' => '')));
+                                                                'webroot' => '')));
         }
         if ($this->uses)
         {
@@ -264,7 +264,7 @@ class Controller extends Object
                 else
                 {
                     return $this->cakeError('missingModel',array(array('className' => $modelClass,
-                                                                       'webroot' => '')));
+                                                                        'webroot' => '')));
                 }
             }
         }
@@ -518,7 +518,7 @@ class Controller extends Object
  * @param string $url Relative URL to redirect to after the time expires
  * @param int $time Time to show the message
  */
-    function flash($message, $url, $pause=1)
+    function flash($message, $url, $pause = 1)
     {
         $this->autoRender = false;
         $this->autoLayout = false;
@@ -532,14 +532,11 @@ class Controller extends Object
         {
             $flash = VIEWS.'layouts'.DS.'flash.thtml';
         }
-        else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml'))
+        elseif($flash = fileExistsInPath(LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml'))
         {
-            $flash = LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml';
+
         }
-
-
-
-        $this->render(null,false,$flash);
+        $this->render(null, false, $flash);
     }
 
 /**
@@ -563,7 +560,7 @@ class Controller extends Object
         $this->set('message', $message);
         $this->set('time', $time);
 
-        $this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
+        $this->render(null, false, VIEWS.'layouts'.DS.'flash.thtml');
     }
 
 /**
diff --git a/cake/libs/controller/pages_controller.php b/cake/libs/controller/pages_controller.php
index 4e6481e9d..bb08f7498 100644
--- a/cake/libs/controller/pages_controller.php
+++ b/cake/libs/controller/pages_controller.php
@@ -49,35 +49,35 @@ class PagesController extends AppController{
  *
  * @var unknown_type
  */
-   var $helpers = array('Html');
+    var $helpers = array('Html');
 
 /**
  * This controller does not use a model
  *
  * @var $uses
  */
-   var $uses = null;
+    var $uses = null;
 
 
 /**
  * Displays a view
  *
  */
-   function display()
-   {
-       if (!func_num_args())
-       {
-           $this->redirect('/');
-       }
-       $path = func_get_args();
-       if (!count($path))
-       {
-           $this->redirect('/');
-       }
-       $this->set('page', $path[0]);
-       $this->set('subpage', empty($path[1])? null: $path[1]);
-       $this->set('title', ucfirst($path[count($path)-1]));
-       $this->render(join('/', $path));
-   }
+    function display()
+    {
+        if (!func_num_args())
+        {
+            $this->redirect('/');
+        }
+        $path = func_get_args();
+        if (!count($path))
+        {
+            $this->redirect('/');
+        }
+        $this->set('page', $path[0]);
+        $this->set('subpage', empty($path[1])? null: $path[1]);
+        $this->set('title', ucfirst($path[count($path)-1]));
+        $this->render(join('/', $path));
+    }
 }
 ?>
\ No newline at end of file
diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php
index acb4ea0d5..b0b263fa7 100644
--- a/cake/libs/controller/scaffold.php
+++ b/cake/libs/controller/scaffold.php
@@ -329,7 +329,7 @@ class Scaffold extends Object {
             }
             else
             {
-           return $this->controllerClass->flash('There was an error deleting the '.Inflector::humanize($this->modelKey).' with the id '.
+            return $this->controllerClass->flash('There was an error deleting the '.Inflector::humanize($this->modelKey).' with the id '.
                                                 $id, '/'.Inflector::underscore($this->controllerClass->viewPath));
             }
         }
@@ -360,52 +360,52 @@ class Scaffold extends Object {
         if(isset($this->controllerClass->{$this->modelKey}->db))
         {
             if($params['action'] === 'index'  || $params['action'] === 'list' ||
-               $params['action'] === 'show'   || $params['action'] === 'add' ||
-               $params['action'] === 'create' || $params['action'] === 'edit' ||
-               $params['action'] === 'update' || $params['action'] === 'destroy')
-               {
-                   switch ($params['action'])
-                   {
-                       case 'index':
-                           $this->_scaffoldIndex($params);
-                       break;
+                $params['action'] === 'show'    || $params['action'] === 'add' ||
+                $params['action'] === 'create' || $params['action'] === 'edit' ||
+                $params['action'] === 'update' || $params['action'] === 'destroy')
+                {
+                    switch ($params['action'])
+                    {
+                        case 'index':
+                            $this->_scaffoldIndex($params);
+                        break;
 
-                       case 'show':
-                           $this->_scaffoldShow($params);
-                       break;
+                        case 'show':
+                            $this->_scaffoldShow($params);
+                        break;
 
-                       case 'list':
-                           $this->_scaffoldList($params);
-                       break;
+                        case 'list':
+                            $this->_scaffoldList($params);
+                        break;
 
-                       case 'add':
-                           $this->_scaffoldNew($params);
-                       break;
+                        case 'add':
+                            $this->_scaffoldNew($params);
+                        break;
 
-                       case 'edit':
-                           $this->_scaffoldEdit($params);
-                       break;
+                        case 'edit':
+                            $this->_scaffoldEdit($params);
+                        break;
 
-                       case 'create':
-                           $this->_scaffoldCreate($params);
-                       break;
+                        case 'create':
+                            $this->_scaffoldCreate($params);
+                        break;
 
-                       case 'update':
-                           $this->_scaffoldUpdate($params);
-                       break;
+                        case 'update':
+                            $this->_scaffoldUpdate($params);
+                        break;
 
-                       case 'destroy':
-                           $this->_scaffoldDestroy($params);
-                       break;
-                   }
-               }
-               else
-               {
-                   return $this->cakeError('missingAction',
-                               array(array('className' => Inflector::camelize($params['controller']."Controller"),
-                                           'action' => $params['action'],
-                                           'webroot' => $this->controllerClass->webroot)));
-               }
+                        case 'destroy':
+                            $this->_scaffoldDestroy($params);
+                        break;
+                    }
+                }
+                else
+                {
+                    return $this->cakeError('missingAction',
+                                array(array('className' => Inflector::camelize($params['controller']."Controller"),
+                                            'action' => $params['action'],
+                                            'webroot' => $this->controllerClass->webroot)));
+                }
         }
         else
         {
diff --git a/cake/libs/file.php b/cake/libs/file.php
index 5f06908f1..b553c17f3 100644
--- a/cake/libs/file.php
+++ b/cake/libs/file.php
@@ -55,14 +55,14 @@ class File extends Object
  *
  * @var Folder
  */
-   var $folder = null;
+    var $folder = null;
 
 /**
  * Filename
  *
  * @var string
  */
-   var $name = null;
+    var $name = null;
 
 /**
  * Constructor
@@ -71,8 +71,8 @@ class File extends Object
  * @param boolean $create Create file if it does not exist
  * @return File
  */
-   function __construct ($path, $create = false)
-   {
+    function __construct ($path, $create = false)
+    {
       parent::__construct();
 
       $this->folder = new Folder(dirname($path), $create);
@@ -84,7 +84,7 @@ class File extends Object
          {
             if (!$this->create())
             {
-               return false;
+                return false;
             }
          }
          else
@@ -92,17 +92,17 @@ class File extends Object
             return false;
          }
       }
-   }
+    }
 
 /**
  * Return the contents of this File as a string.
  *
  * @return string Contents
  */
-   function read ()
-   {
+    function read ()
+    {
       return file_get_contents($this->getFullPath());
-   }
+    }
 
 /**
  * Append given data string to this File.
@@ -110,10 +110,10 @@ class File extends Object
  * @param string $data Data to write
  * @return boolean Success
  */
-   function append ($data)
-   {
+    function append ($data)
+    {
       return $this->write($data, 'a');
-   }
+    }
 
 /**
  * Write given data to this File.
@@ -122,8 +122,8 @@ class File extends Object
  * @param string $mode    Mode of writing. {@link http://php.net/fwrite See fwrite()}.
  * @return boolean Success
  */
-   function write ($data, $mode = 'w')
-   {
+    function write ($data, $mode = 'w')
+    {
       $file = $this->getFullPath();
       if (!($handle = fopen( $file , $mode)))
       {
@@ -138,7 +138,7 @@ class File extends Object
       return false;
 
       return true;
-   }
+    }
 
 /**
  * Get md5 Checksum of file with previous check of Filesize
@@ -146,8 +146,8 @@ class File extends Object
  * @param string $force    Data to write to this File.
  * @return string md5 Checksum {@link http://php.net/md5_file See md5_file()}
  */
-   function getMd5 ($force = false)
-   {
+    function getMd5 ($force = false)
+    {
       $md5 = '';
       if ( $force == true || $this->getSize(false) < MAX_MD5SIZE )
       {
@@ -155,7 +155,7 @@ class File extends Object
       }
 
       return $md5;
-   }
+    }
 
 /**
  * Returns the Filesize, either in bytes or in human-readable format.
@@ -163,19 +163,19 @@ class File extends Object
  * @param boolean $humanReadeble    Data to write to this File.
  * @return string|int filesize as int or as a human-readable string
  */
-   function getSize ()
-   {
+    function getSize ()
+    {
       $size = filesize( $this->getFullPath() );
       return $size;
-   }
+    }
 
 /**
  * Returns the File extension.
  *
  * @return string The Fileextension
  */
-   function getExt ()
-   {
+    function getExt ()
+    {
       $ext = '';
 
       $parts = explode('.', $this->getName() );
@@ -190,45 +190,45 @@ class File extends Object
       }
 
       return $ext;
-   }
+    }
 
 /**
  * Returns the filename.
  *
  * @return string The Filename
  */
-   function getName ()
-   {
+    function getName ()
+    {
       return $this->name;
-   }
+    }
 
 /**
  * Returns the File's owner.
  *
  * @return int the Fileowner
  */
-   function getOwner ()
-   {
+    function getOwner ()
+    {
       return fileowner( $this->getFullPath() );
-   }
+    }
 
 /**
  * Returns the File group.
  *
  * @return int the Filegroup
  */
-   function getGroup ()
-   {
+    function getGroup ()
+    {
       return filegroup( $this->getFullPath() );
-   }
+    }
 
 /**
  * Creates the File.
  *
  * @return boolean Success
  */
-   function create ()
-   {
+    function create ()
+    {
       $dir = $this->folder->pwd();
       if ( file_exists( $dir ) && is_dir($dir) && is_writable($dir) && !$this->exists() )
       {
@@ -247,107 +247,107 @@ class File extends Object
          print ("[File] Could not create $this->getName()!");
          return false;
       }
-   }
+    }
 
 /**
  * Returns true if the File exists.
  *
  * @return boolean
  */
-   function exists ()
-   {
+    function exists ()
+    {
       return file_exists( $this->getFullPath() );
-   }
+    }
 
 /**
  * Deletes the File.
  *
  * @return boolean
  */
-   function delete ()
-   {
+    function delete ()
+    {
       return unlink( $this->getFullPath() );
-   }
+    }
 
 /**
  * Returns true if the File is writable.
  *
  * @return boolean
  */
-   function writable ()
-   {
+    function writable ()
+    {
       return is_writable( $this->getFullPath() );
-   }
+    }
 
 /**
  * Returns true if the File is executable.
  *
  * @return boolean
  */
-   function executable ()
-   {
+    function executable ()
+    {
       return is_executable( $this->getFullPath() );
-   }
+    }
 
 /**
  * Returns true if the File is readable.
  *
  * @return boolean
  */
-   function readable ()
-   {
+    function readable ()
+    {
       return is_readable( $this->getFullPath() );
-   }
+    }
 
 /**
  * Returns last access time.
  *
  * @return int timestamp
  */
-   function lastAccess ()
-   {
+    function lastAccess ()
+    {
       return fileatime( $this->getFullPath() );
-   }
+    }
 
 /**
  * Returns last modified time.
  *
  * @return int timestamp
  */
-   function lastChange ()
-   {
+    function lastChange ()
+    {
       return filemtime( $this->getFullPath() );
-   }
+    }
 
 /**
  * Returns the current folder.
  *
  * @return Folder
  */
-   function getFolder ()
-   {
+    function getFolder ()
+    {
       return $this->folder;
-   }
+    }
 
 /**
  * Returns the "chmod" (permissions) of the File.
  *
  * @return string
  */
-   function getChmod (  )
-   {
+    function getChmod (  )
+    {
       return substr(sprintf('%o', fileperms($this->getFullPath())), -4);
-   }
+    }
 
 /**
  * Returns the full path of the File.
  *
  * @return string
  */
-   function getFullPath (  )
-   {
+    function getFullPath (  )
+    {
       return Folder::slashTerm($this->folder->pwd()).$this->getName();
-   }
+    }
 }
 
 ?>
\ No newline at end of file
diff --git a/cake/libs/flay.php b/cake/libs/flay.php
index ca39591c9..a26cf21bd 100644
--- a/cake/libs/flay.php
+++ b/cake/libs/flay.php
@@ -29,9 +29,9 @@
  */
 
 /**
-  * Included libraries.
-  *
-  */
+ * Included libraries.
+ *
+ */
 if(!class_exists('Object'))
 {
     uses('object');
@@ -49,40 +49,40 @@ if(!class_exists('Object'))
 class Flay extends Object
 {
 /**
-  * Text to be parsed.
-  *
-  * @var string
-  */
-   var $text = null;
+ * Text to be parsed.
+ *
+ * @var string
+ */
+    var $text = null;
 
 /**
-  * Set this to allow HTML in the markup.
-  *
-  * @var boolean
-  */
-   var $allow_html = false;
+ * Set this to allow HTML in the markup.
+ *
+ * @var boolean
+ */
+    var $allow_html = false;
 
 /**
-  * Constructor.
-  *
-  * @param string $text
-  */
-   function __construct ($text=null)
-   {
+ * Constructor.
+ *
+ * @param string $text
+ */
+    function __construct ($text=null)
+    {
       $this->text = $text;
       parent::__construct();
-   }
+    }
 
 /**
-  * Returns given text translated to HTML using the Flay syntax.
-  *
-  * @param string $text     String to format
-  * @param boolean $bare    Set this to only do 

transforms and > to >, no typography additions. - * @param boolean $allowHtml Set this to trim whitespace and disable all HTML - * @return string Formatted text - */ - function toHtml ($text=null, $bare=false, $allowHtml=false) - { + * Returns given text translated to HTML using the Flay syntax. + * + * @param string $text String to format + * @param boolean $bare Set this to only do

transforms and > to >, no typography additions. + * @param boolean $allowHtml Set this to trim whitespace and disable all HTML + * @return string Formatted text + */ + function toHtml ($text=null, $bare=false, $allowHtml=false) + { if (empty($text) && empty($this->text)) { @@ -91,7 +91,7 @@ class Flay extends Object $text = $text? $text: $this->text; - // trim whitespace and disable all HTML +// trim whitespace and disable all HTML if ($allowHtml) { $text = trim($text); @@ -103,17 +103,17 @@ class Flay extends Object if (!$bare) { - // multi-paragraph functions +// multi-paragraph functions $text = preg_replace('#(?:[\n]{0,2})"""(.*)"""(?:[\n]{0,2})#s', "\n\n%BLOCKQUOTE%\n\n\\1\n\n%ENDBLOCKQUOTE%\n\n", $text); $text = preg_replace('#(?:[\n]{0,2})===(.*)===(?:[\n]{0,2})#s', "\n\n%CENTER%\n\n\\1\n\n%ENDCENTER%\n\n", $text); } - // pre-parse newlines +// pre-parse newlines $text = preg_replace("#\r\n#", "\n", $text); $text = preg_replace("#[\n]{2,}#", "%PARAGRAPH%", $text); $text = preg_replace('#[\n]{1}#', "%LINEBREAK%", $text); - // split into paragraphs and parse +// split into paragraphs and parse $out = ''; foreach (split('%PARAGRAPH%', $text) as $line) { @@ -123,64 +123,64 @@ class Flay extends Object if (!$bare) { - // pre-parse links - $links = array(); - $regs = null; - if (preg_match_all('#\[([^\[]{4,})\]#', $line, $regs)) - { +// pre-parse links + $links = array(); + $regs = null; + if (preg_match_all('#\[([^\[]{4,})\]#', $line, $regs)) + { foreach ($regs[1] as $reg) { $links[] = $reg; $line = str_replace("[{$reg}]",'%LINK'.(count($links)-1).'%', $line); } - } + } - // MAIN TEXT FUNCTIONS - // bold - $line = ereg_replace("\*([^\*]*)\*", "\\1", $line); - // italic - $line = ereg_replace("_([^_]*)_", "\\1", $line); +// MAIN TEXT FUNCTIONS +// bold + $line = ereg_replace("\*([^\*]*)\*", "\\1", $line); +// italic + $line = ereg_replace("_([^_]*)_", "\\1", $line); } - // entities +// entities $line = str_replace(' - ', ' – ', $line); $line = str_replace(' -- ', ' — ', $line); $line = str_replace('(C)', '©', $line); $line = str_replace('(R)', '®', $line); $line = str_replace('(TM)', '™', $line); - // guess e-mails +// guess e-mails $emails = null; if (preg_match_all("#([_A-Za-z0-9+-+]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#", $line, $emails)) { - foreach ($emails[1] as $email) - { + foreach ($emails[1] as $email) + { $line = str_replace($email, "{$email}", $line); - } + } } if (!$bare) { - // guess links - $urls = null; - if (preg_match_all("#((?:http|https|ftp|nntp)://[^ ]+)#", $line, $urls)) - { +// guess links + $urls = null; + if (preg_match_all("#((?:http|https|ftp|nntp)://[^ ]+)#", $line, $urls)) + { foreach ($urls[1] as $url) { $line = str_replace($url, "{$url}", $line); } - } - if (preg_match_all("#(www\.[^\n\%\ ]+[^\n\%\,\.\ ])#", $line, $urls)) - { + } + if (preg_match_all("#(www\.[^\n\%\ ]+[^\n\%\,\.\ ])#", $line, $urls)) + { foreach ($urls[1] as $url) { $line = str_replace($url, "{$url}", $line); } - } + } - // re-parse links - if (count($links)) - { +// re-parse links + if (count($links)) + { for ($ii=0; $ii"; - } - else - { + } + else + { $body = $regs[2]; - } + } } else { - $body = $links[$ii]; + $body = $links[$ii]; } $with = "{$body}"; @@ -224,17 +224,17 @@ class Flay extends Object $line = str_replace("%LINK{$ii}%", $with, $line); } - } + } } - // re-parse newlines +// re-parse newlines $out .= str_replace('%LINEBREAK%', "
\n", "

{$line}

\n"); } } if (!$bare) { - // re-parse multilines +// re-parse multilines $out = str_replace('

%BLOCKQUOTE%

', "
", $out); $out = str_replace('

%ENDBLOCKQUOTE%

', "
", $out); $out = str_replace('

%CENTER%

', "
", $out); @@ -242,7 +242,7 @@ class Flay extends Object } return $out; - } + } /** * Return the words of the string as an array. @@ -250,10 +250,10 @@ class Flay extends Object * @param string $string * @return array Array of words */ - function extractWords ($string) - { + function extractWords ($string) + { return preg_split('/[\s,\.:\/="!\(\)<>~\[\]]+/', $string); - } + } /** * Return given string with words in array colorMarked, up to a number of times (defaults to 5). @@ -264,8 +264,8 @@ class Flay extends Object * @return string * @see colorMark */ - function markedSnippets ($words, $string, $max_snippets=5) - { + function markedSnippets ($words, $string, $max_snippets=5) + { $string = strip_tags($string); @@ -277,7 +277,7 @@ class Flay extends Object { foreach ($r as $result) { - $rest = str_replace($result, '', $rest); + $rest = str_replace($result, '', $rest); } $snips = array_merge($snips, $r[0]); } @@ -285,13 +285,13 @@ class Flay extends Object if (count($snips) > $max_snippets) { - $snips = array_slice($snips, 0, $max_snippets); + $snips = array_slice($snips, 0, $max_snippets); } $joined = join(' ... ', $snips); $snips = $joined? "... {$joined} ...": substr($string, 0, 80) . '...'; return Flay::colorMark($words, $snips); - } + } /** * Returns string with EM elements with color classes added. @@ -300,8 +300,8 @@ class Flay extends Object * @param string $string Text in which the words might be found * @return string */ - function colorMark($words, $string) - { + function colorMark($words, $string) + { $colors = array('yl','gr','rd','bl','fu','cy'); $nextColorIndex = 0; @@ -312,7 +312,7 @@ class Flay extends Object } return $string; - } + } /** * Returns given text with tags stripped out. @@ -320,10 +320,10 @@ class Flay extends Object * @param string $text * @return string */ - function toClean ($text) - { + function toClean ($text) + { return strip_tags(html_entity_decode($text, ENT_QUOTES)); - } + } /** * Return parsed text with tags stripped out. @@ -331,10 +331,10 @@ class Flay extends Object * @param string $text * @return string */ - function toParsedAndClean ($text) - { + function toParsedAndClean ($text) + { return Flay::toClean(Flay::toHtml($text)); - } + } /** * Return a fragment of a text, up to $length characters long, with an ellipsis after it. @@ -344,8 +344,8 @@ class Flay extends Object * @param string $ellipsis Sign to print after truncated text. * @return string */ - function fragment ($text, $length, $ellipsis='...') - { + function fragment ($text, $length, $ellipsis='...') + { $soft = $length - 5; $hard = $length + 5; $rx = '/(.{' . $soft . ',' . $hard . '})[\s,\.:\/="!\(\)<>~\[\]]+.*/'; @@ -360,7 +360,7 @@ class Flay extends Object $out = $out . (strlen($out) \ No newline at end of file diff --git a/cake/libs/folder.php b/cake/libs/folder.php index 08e4ab5e5..2380e7f6d 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -28,9 +28,9 @@ */ /** - * Included libraries. - * - */ + * Included libraries. + * + */ if(!class_exists('Object')) { uses('object'); @@ -47,27 +47,27 @@ if(!class_exists('Object')) class Folder extends Object { /** - * Path to Folder. - * - * @var string - */ - var $path = null; + * Path to Folder. + * + * @var string + */ + var $path = null; /** - * Sortedness. - * - * @var boolean - */ - var $sort = false; + * Sortedness. + * + * @var boolean + */ + var $sort = false; /** - * Constructor. - * - * @param string $path - * @param boolean $path - */ - function Folder ($path = false , $create = false, $mode = false) - { + * Constructor. + * + * @param string $path + * @param boolean $path + */ + function Folder ($path = false , $create = false, $mode = false) + { if (empty($path)) { $path = getcwd(); @@ -78,45 +78,45 @@ class Folder extends Object { $this->mkdirr($path, $mode); } $this->cd($path); - } + } /** - * Return current path. - * - * @return string Current path - */ - function pwd () - { + * Return current path. + * + * @return string Current path + */ + function pwd () + { return $this->path; - } + } /** - * Change directory to $desired_path. - * - * @param string $desired_path Path to the directory to change to - * @return string The new path. Returns false on failure - */ - function cd ($desired_path) - { + * Change directory to $desired_path. + * + * @param string $desired_path Path to the directory to change to + * @return string The new path. Returns false on failure + */ + function cd ($desired_path) + { $desired_path = realpath($desired_path); $new_path = Folder::isAbsolute($desired_path)? $desired_path: Folder::addPathElement($this->path, $desired_path); return is_dir($new_path)? $this->path = $new_path: false; - } + } /** - * Returns an array of the contents of the current directory, or false on failure. - * The returned array holds two arrays: one of dirs and one of files. - * - * @param boolean $sort - * @param boolean $noDotFiles - * @return array - */ - function ls($sort=true , $noDotFiles = false) - { + * Returns an array of the contents of the current directory, or false on failure. + * The returned array holds two arrays: one of dirs and one of files. + * + * @param boolean $sort + * @param boolean $noDotFiles + * @return array + */ + function ls($sort=true , $noDotFiles = false) + { $dir = opendir($this->path); if ($dir) @@ -126,14 +126,14 @@ class Folder extends Object { { if ( (!preg_match('#^\.+$#', $n) && $noDotFiles == false) || ( $noDotFiles == true && !preg_match('#^\.(.*)$#', $n) ) ) { - if (is_dir($this->addPathElement($this->path, $n))) - { + if (is_dir($this->addPathElement($this->path, $n))) + { $dirs[] = $n; - } - else - { + } + else + { $files[] = $n; - } + } } } @@ -151,17 +151,17 @@ class Folder extends Object { { return false; } - } + } /** - * Returns an array of all matching files in current directory. - * - * @param string $pattern Preg_match pattern (Defaults to: .*) - * @return array - */ - function find ($regexp_pattern='.*') - { + * Returns an array of all matching files in current directory. + * + * @param string $pattern Preg_match pattern (Defaults to: .*) + * @return array + */ + function find ($regexp_pattern='.*') + { $data = $this->ls(); if (!is_array($data)) @@ -181,32 +181,32 @@ class Folder extends Object { } return $found; - } + } /** - * Returns an array of all matching files in and below current directory. - * - * @param string $pattern Preg_match pattern (Defaults to: .*) - * @return array Files matching $pattern - */ - function findRecursive ($pattern='.*') - { + * Returns an array of all matching files in and below current directory. + * + * @param string $pattern Preg_match pattern (Defaults to: .*) + * @return array Files matching $pattern + */ + function findRecursive ($pattern='.*') + { $starts_on = $this->path; $out = $this->_findRecursive($pattern); $this->cd($starts_on); return $out; - } + } /** - * Private helper function for findRecursive. - * - * @param string $pattern - * @return array Files matching pattern - * @access private - */ - function _findRecursive ($pattern) - { + * Private helper function for findRecursive. + * + * @param string $pattern + * @return array Files matching pattern + * @access private + */ + function _findRecursive ($pattern) + { list($dirs, $files) = $this->ls(); $found = array(); @@ -226,102 +226,102 @@ class Folder extends Object { } return $found; - } + } /** - * Returns true if given $path is a Windows path. - * - * @param string $path Path to check - * @return boolean - * @static - */ - function isWindowsPath ($path) - { + * Returns true if given $path is a Windows path. + * + * @param string $path Path to check + * @return boolean + * @static + */ + function isWindowsPath ($path) + { return preg_match('#^[A-Z]:\\\#i', $path)? true: false; - } + } /** - * Returns true if given $path is an absolute path. - * - * @param string $path Path to check - * @return boolean - * @static - */ - function isAbsolute ($path) - { + * Returns true if given $path is an absolute path. + * + * @param string $path Path to check + * @return boolean + * @static + */ + function isAbsolute ($path) + { return preg_match('#^\/#', $path) || preg_match('#^[A-Z]:\\\#i', $path); - } + } /** - * Returns true if given $path ends in a slash (i.e. is slash-terminated). - * - * @param string $path Path to check - * @return boolean - * @static - */ - function isSlashTerm ($path) - { + * Returns true if given $path ends in a slash (i.e. is slash-terminated). + * + * @param string $path Path to check + * @return boolean + * @static + */ + function isSlashTerm ($path) + { return preg_match('#[\\\/]$#', $path)? true: false; - } + } /** - * Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.) - * - * @param string $path Path to check - * @return string Set of slashes ("\\" or "/") - * @static - */ - function correctSlashFor ($path) - { + * Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.) + * + * @param string $path Path to check + * @return string Set of slashes ("\\" or "/") + * @static + */ + function correctSlashFor ($path) + { return Folder::isWindowsPath($path)? '\\': '/'; - } + } /** - * Returns $path with added terminating slash (corrected for Windows or other OS). - * - * @param string $path Path to check - * @return string - * @static - */ - function slashTerm ($path) - { + * Returns $path with added terminating slash (corrected for Windows or other OS). + * + * @param string $path Path to check + * @return string + * @static + */ + function slashTerm ($path) + { return $path . (Folder::isSlashTerm($path)? null: Folder::correctSlashFor($path)); - } + } /** - * Returns $path with $element added, with correct slash in-between. - * - * @param string $path - * @param string $element - * @return string - * @static - */ - function addPathElement ($path, $element) - { + * Returns $path with $element added, with correct slash in-between. + * + * @param string $path + * @param string $element + * @return string + * @static + */ + function addPathElement ($path, $element) + { return Folder::slashTerm($path).$element; - } + } /** * Returns true if the File is in a given CakePath. * * @return boolean */ - function inCakePath ( $path = '' ) - { + function inCakePath ( $path = '' ) + { $dir = substr( Folder::slashTerm(ROOT) , 0 , -1 ); $newdir = Folder::slashTerm($dir.$path); return $this->inPath( $newdir ); - } + } /** * Returns true if the File is in given path. * * @return boolean */ - function inPath ( $path = '' ) - { + function inPath ( $path = '' ) + { $dir = substr( Folder::slashTerm($path) , 0 , -1 ); $return = preg_match('/^'.preg_quote(Folder::slashTerm($dir),'/').'(.*)/' , Folder::slashTerm($this->pwd()) ); @@ -334,30 +334,30 @@ class Folder extends Object { { return false; } - } + } /** * Create a directory structure recursively. * - * @param string $pathname The directory structure to create + * @param string $pathname The directory structure to create * @return bool Returns TRUE on success, FALSE on failure */ - function mkdirr($pathname, $mode = null) - { - // Check if directory already exists + function mkdirr($pathname, $mode = null) + { +// Check if directory already exists if (is_dir($pathname) || empty($pathname)) { return true; } - // Ensure a file does not already exist with the same name +// Ensure a file does not already exist with the same name if (is_file($pathname)) { trigger_error('mkdirr() File exists', E_USER_WARNING); return false; } - // Crawl up the directory tree +// Crawl up the directory tree $next_pathname = substr($pathname, 0, strrpos($pathname, DIRECTORY_SEPARATOR)); if ($this->mkdirr($next_pathname, $mode)) { @@ -369,67 +369,67 @@ class Folder extends Object { } return false; - } + } /** * Returns the size in bytes of this Folder. * - * @param string $directory Path to directory + * @param string $directory Path to directory */ - function dirsize() - { - // Init + function dirsize() + { +// Init $size = 0; $directory = Folder::slashTerm($this->path); - // Creating the stack array +// Creating the stack array $stack = array($directory); - // Iterate stack +// Iterate stack for ($i = 0, $j = count($stack); $i < $j; ++$i) { - // Add to total size +// Add to total size if (is_file($stack[$i])) { $size += filesize($stack[$i]); } - // Add to stack +// Add to stack elseif (is_dir($stack[$i])) { - // Read directory +// Read directory $dir = dir($stack[$i]); while (false !== ($entry = $dir->read())) { - // No pointers - if ($entry == '.' || $entry == '..') - { +// No pointers + if ($entry == '.' || $entry == '..') + { continue; - } + } - // Add to stack - $add = $stack[$i] . $entry; - if (is_dir($stack[$i] . $entry)) - { +// Add to stack + $add = $stack[$i] . $entry; + if (is_dir($stack[$i] . $entry)) + { $add = Folder::slashTerm($add); - } - $stack[] = $add; + } + $stack[] = $add; } - // Clean up +// Clean up $dir->close(); } - // Recount stack +// Recount stack $j = count($stack); } return $size; - } + } } ?> \ No newline at end of file diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index a4e440cb7..fd7eb11b5 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -29,9 +29,9 @@ */ /** - * Included libraries. - * - */ + * Included libraries. + * + */ if(!class_exists('Object')) { uses('object'); @@ -51,13 +51,13 @@ class Inflector extends Object { /** - * Constructor. - * - */ - function __construct () - { + * Constructor. + * + */ + function __construct () + { parent::__construct(); - } + } /** * Return $word in plural form. @@ -69,22 +69,22 @@ class Inflector extends Object { $pluralRules = array('/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', # ox - '/([m|l])ouse$/i' => '\1ice', # mouse, louse + '/([m|l])ouse$/i' => '\1ice', # mouse, louse '/(matr|vert|ind)ix|ex$/i' => '\1ices', # matrix, vertex, index - '/(x|ch|ss|sh)$/i' => '\1es', # search, switch, fix, box, process, address + '/(x|ch|ss|sh)$/i' => '\1es', # search, switch, fix, box, process, address '/([^aeiouy]|qu)y$/i' => '\1ies', # query, ability, agency - '/(hive)$/i' => '\1s', # archive, hive + '/(hive)$/i' => '\1s', # archive, hive '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves', # half, safe, wife '/sis$/i' => 'ses', # basis, diagnosis '/([ti])um$/i' => '\1a', # datum, medium '/(p)erson$/i' => '\1eople', # person, salesperson - '/(m)an$/i' => '\1en', # man, woman, spokesman + '/(m)an$/i' => '\1en', # man, woman, spokesman '/(c)hild$/i' => '\1hildren', # child '/(buffal|tomat)o$/i' => '\1\2oes', # buffalo, tomato '/(bu)s$/i' => '\1\2ses', # bus - '/(alias)/i' => '\1es', # alias + '/(alias)/i' => '\1es', # alias '/(octop|vir)us$/i' => '\1i', # octopus, virus - virus has no defined plural (according to Latin/dictionary.com), but viri is better than viruses/viruss - '/(ax|cri|test)is$/i' => '\1es', # axis, crisis + '/(ax|cri|test)is$/i' => '\1es', # axis, crisis '/s$/' => 's', # no change (compatibility) '/$/' => 's'); @@ -100,34 +100,34 @@ class Inflector extends Object 'whiting', 'wildebeest', 'Yengeese',); $irregular = array('atlas' => 'atlases', - 'beef' => 'beefs', - 'brother' => 'brothers', - 'child' => 'children', - 'corpus' => 'corpuses', - 'cow' => 'cows', - 'ganglion' => 'ganglions', - 'genie' => 'genies', - 'genus' => 'genera', - 'graffito' => 'graffiti', - 'hoof' => 'hoofs', - 'loaf' => 'loaves', - 'man' => 'men', - 'money' => 'monies', - 'mongoose' => 'mongooses', - 'move' => 'moves', - 'mythos' => 'mythoi', - 'numen' => 'numina', - 'occiput' => 'occiputs', - 'octopus' => 'octopuses', - 'opus' => 'opuses', - 'ox' => 'oxen', - 'penis' => 'penises', - 'person' => 'people', - 'sex' => 'sexes', - 'soliloquy' => 'soliloquies', - 'testis' => 'testes', - 'trilby' => 'trilbys', - 'turf' => 'turfs',); + 'beef' => 'beefs', + 'brother' => 'brothers', + 'child' => 'children', + 'corpus' => 'corpuses', + 'cow' => 'cows', + 'ganglion' => 'ganglions', + 'genie' => 'genies', + 'genus' => 'genera', + 'graffito' => 'graffiti', + 'hoof' => 'hoofs', + 'loaf' => 'loaves', + 'man' => 'men', + 'money' => 'monies', + 'mongoose' => 'mongooses', + 'move' => 'moves', + 'mythos' => 'mythoi', + 'numen' => 'numina', + 'occiput' => 'occiputs', + 'octopus' => 'octopuses', + 'opus' => 'opuses', + 'ox' => 'oxen', + 'penis' => 'penises', + 'person' => 'people', + 'sex' => 'sexes', + 'soliloquy' => 'soliloquies', + 'testis' => 'testes', + 'trilby' => 'trilbys', + 'turf' => 'turfs',); $regexUninflected = __enclose(join( '|', $uninflected)); $regexIrregular = __enclose(join( '|', array_keys($irregular))); @@ -161,33 +161,33 @@ class Inflector extends Object function singularize ($word) { $singularRules = array('/(s)tatuses$/i' => '\1\2tatus', - '/(matr)ices$/i' =>'\1ix', - '/(vert|ind)ices$/i' => '\1ex', - '/^(ox)en/i' => '\1', - '/(alias)es$/i' => '\1', - '/([octop|vir])i$/i' => '\1us', - '/(cris|ax|test)es$/i' => '\1is', - '/(shoe)s$/i' => '\1', - '/(o)es$/i' => '\1', - '/(bus)es$/i' => '\1', - '/([m|l])ice$/i' => '\1ouse', - '/(x|ch|ss|sh)es$/i' => '\1', - '/(m)ovies$/i' => '\1\2ovie', - '/(s)eries$/i' => '\1\2eries', - '/([^aeiouy]|qu)ies$/i' => '\1y', - '/([lr])ves$/i' => '\1f', - '/(tive)s$/i' => '\1', - '/(hive)s$/i' => '\1', - '/(drive)s$/i' => '\1', - '/([^f])ves$/i' => '\1fe', - '/(^analy)ses$/i' => '\1sis', - '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis', - '/([ti])a$/i' => '\1um', - '/(p)eople$/i' => '\1\2erson', - '/(m)en$/i' => '\1an', - '/(c)hildren$/i' => '\1\2hild', - '/(n)ews$/i' => '\1\2ews', - '/s$/i' => ''); + '/(matr)ices$/i' =>'\1ix', + '/(vert|ind)ices$/i' => '\1ex', + '/^(ox)en/i' => '\1', + '/(alias)es$/i' => '\1', + '/([octop|vir])i$/i' => '\1us', + '/(cris|ax|test)es$/i' => '\1is', + '/(shoe)s$/i' => '\1', + '/(o)es$/i' => '\1', + '/(bus)es$/i' => '\1', + '/([m|l])ice$/i' => '\1ouse', + '/(x|ch|ss|sh)es$/i' => '\1', + '/(m)ovies$/i' => '\1\2ovie', + '/(s)eries$/i' => '\1\2eries', + '/([^aeiouy]|qu)ies$/i' => '\1y', + '/([lr])ves$/i' => '\1f', + '/(tive)s$/i' => '\1', + '/(hive)s$/i' => '\1', + '/(drive)s$/i' => '\1', + '/([^f])ves$/i' => '\1fe', + '/(^analy)ses$/i' => '\1sis', + '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis', + '/([ti])a$/i' => '\1um', + '/(p)eople$/i' => '\1\2erson', + '/(m)en$/i' => '\1an', + '/(c)hildren$/i' => '\1\2hild', + '/(n)ews$/i' => '\1\2ews', + '/s$/i' => ''); $uninflected = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*rice', '.*sheep', 'Amoyese', 'bison', 'Borghese', 'bream', 'breeches', 'britches', 'buffalo', 'cantus', 'carp', 'chassis', 'clippers', @@ -200,35 +200,35 @@ class Inflector extends Object 'siemens', 'species', 'swine', 'testes', 'trousers', 'trout', 'tuna', 'Vermontese', 'Wenchowese', 'whiting', 'wildebeest', 'Yengeese',); - $irregular = array('atlas' => 'atlases', - 'beefs' => 'beef', - 'brothers' => 'brother', - 'children' => 'child', - 'corpuses' => 'corpus', - 'cows' => 'cow', - 'ganglions' => 'ganglion', - 'genies' => 'genie', - 'genera' => 'genus', - 'graffiti' => 'graffito', - 'hoofs' => 'hoof', - 'loaves' => 'loaf', - 'men' => 'man', - 'monies' => 'money', - 'mongooses' => 'mongoose', - 'moves' => 'move', - 'mythoi' => 'mythos', - 'numina' => 'numen', - 'occiputs' => 'occiput', - 'octopuses' => 'octopus', - 'opuses' => 'opus', - 'oxen' => 'ox', - 'penises' => 'penis', - 'people' => 'person', - 'sexes' => 'sex', - 'soliloquies' => 'soliloquy', - 'testes' => 'testis', - 'trilbys' => 'trilby', - 'turfs' => 'turf',); + $irregular = array('atlas' => 'atlases', + 'beefs' => 'beef', + 'brothers' => 'brother', + 'children' => 'child', + 'corpuses' => 'corpus', + 'cows' => 'cow', + 'ganglions' => 'ganglion', + 'genies' => 'genie', + 'genera' => 'genus', + 'graffiti' => 'graffito', + 'hoofs' => 'hoof', + 'loaves' => 'loaf', + 'men' => 'man', + 'monies' => 'money', + 'mongooses' => 'mongoose', + 'moves' => 'move', + 'mythoi' => 'mythos', + 'numina' => 'numen', + 'occiputs' => 'occiput', + 'octopuses' => 'octopus', + 'opuses' => 'opus', + 'oxen' => 'ox', + 'penises' => 'penis', + 'people' => 'person', + 'sexes' => 'sex', + 'soliloquies' => 'soliloquy', + 'testes' => 'testis', + 'trilbys' => 'trilby', + 'turfs' => 'turf',); $regexUninflected = __enclose(join( '|', $uninflected)); $regexIrregular = __enclose(join( '|', array_keys($irregular))); @@ -254,60 +254,60 @@ class Inflector extends Object } /** - * Returns given $lower_case_and_underscored_word as a camelCased word. - * - * @param string $lower_case_and_underscored_word Word to camelize - * @return string Camelized word. likeThis. - */ - function camelize($lowerCaseAndUnderscoredWord) - { + * Returns given $lower_case_and_underscored_word as a camelCased word. + * + * @param string $lower_case_and_underscored_word Word to camelize + * @return string Camelized word. likeThis. + */ + function camelize($lowerCaseAndUnderscoredWord) + { return str_replace(" ","",ucwords(str_replace("_"," ",$lowerCaseAndUnderscoredWord))); - } + } /** - * Returns an underscore-syntaxed ($like_this_dear_reader) version of the $camel_cased_word. - * - * @param string $camel_cased_word Camel-cased word to be "underscorized" - * @return string Underscore-syntaxed version of the $camel_cased_word - */ - function underscore($camelCasedWord) - { + * Returns an underscore-syntaxed ($like_this_dear_reader) version of the $camel_cased_word. + * + * @param string $camel_cased_word Camel-cased word to be "underscorized" + * @return string Underscore-syntaxed version of the $camel_cased_word + */ + function underscore($camelCasedWord) + { return strtolower (preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord)); - } + } /** - * Returns a human-readable string from $lower_case_and_underscored_word, - * by replacing underscores with a space, and by upper-casing the initial characters. - * - * @param string $lower_case_and_underscored_word String to be made more readable - * @return string Human-readable string - */ - function humanize($lowerCaseAndUnderscoredWord) - { + * Returns a human-readable string from $lower_case_and_underscored_word, + * by replacing underscores with a space, and by upper-casing the initial characters. + * + * @param string $lower_case_and_underscored_word String to be made more readable + * @return string Human-readable string + */ + function humanize($lowerCaseAndUnderscoredWord) + { return ucwords(str_replace("_"," ",$lowerCaseAndUnderscoredWord)); - } + } /** - * Returns corresponding table name for given $class_name. ("posts" for the model class "Post"). - * - * @param string $class_name Name of class to get database table name for - * @return string Name of the database table for given class - */ - function tableize($className) - { + * Returns corresponding table name for given $class_name. ("posts" for the model class "Post"). + * + * @param string $class_name Name of class to get database table name for + * @return string Name of the database table for given class + */ + function tableize($className) + { return Inflector::pluralize(Inflector::underscore($className)); - } + } /** - * Returns Cake model class name ("Post" for the database table "posts".) for given database table. - * - * @param string $tableName Name of database table to get class name for - * @return string - */ - function classify($tableName) - { + * Returns Cake model class name ("Post" for the database table "posts".) for given database table. + * + * @param string $tableName Name of database table to get class name for + * @return string + */ + function classify($tableName) + { return Inflector::camelize(Inflector::singularize($tableName)); - } + } } function __enclose($string) diff --git a/cake/libs/legacy.php b/cake/libs/legacy.php index 155d01397..9623df187 100644 --- a/cake/libs/legacy.php +++ b/cake/libs/legacy.php @@ -48,7 +48,7 @@ if (!function_exists('file_get_contents')) * Replace file_get_contents() * * @internal resource_context is not supported - * @since PHP 5 + * @since PHP 5 * require PHP 4.0.0 (user_error) * * @param unknown_type $filename diff --git a/cake/libs/model/connection_manager.php b/cake/libs/model/connection_manager.php index af4b34f2c..c81f74c96 100644 --- a/cake/libs/model/connection_manager.php +++ b/cake/libs/model/connection_manager.php @@ -107,13 +107,13 @@ class ConnectionManager extends Object if(isset($config['driver']) && $config['driver'] != null && $config['driver'] != '') { - $filename = 'dbo_'.$config['driver']; - $classname = Inflector::camelize(strtolower('DBO_'.$config['driver'])); + $filename = 'dbo_'.$config['driver']; + $classname = Inflector::camelize(strtolower('DBO_'.$config['driver'])); } else { - $filename = $config['datasource'].'_source'; - $classname = Inflector::camelize(strtolower($config['datasource'].'_source')); + $filename = $config['datasource'].'_source'; + $classname = Inflector::camelize(strtolower($config['datasource'].'_source')); } $tail = 'dbo'.DS.$filename.'.php'; diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index db72f6ab4..1cf414b81 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -47,7 +47,7 @@ class DataSource extends Object * @var boolean * @access public */ - var $connected = false; + var $connected = false; /** * Print debug info? @@ -55,7 +55,7 @@ class DataSource extends Object * @var boolean * @access public */ - var $debug = false; + var $debug = false; /** * Print full query debug info? @@ -63,7 +63,7 @@ class DataSource extends Object * @var boolean * @access public */ - var $fullDebug = false; + var $fullDebug = false; /** * Error description of last query @@ -71,7 +71,7 @@ class DataSource extends Object * @var unknown_type * @access public */ - var $error = null; + var $error = null; /** * String to hold how many rows were affected by the last SQL operation. @@ -79,7 +79,7 @@ class DataSource extends Object * @var string * @access public */ - var $affected = null; + var $affected = null; /** * Number of rows in current resultset @@ -87,7 +87,7 @@ class DataSource extends Object * @var int * @access public */ - var $numRows = null; + var $numRows = null; /** * Time the last query took @@ -95,7 +95,7 @@ class DataSource extends Object * @var int * @access public */ - var $took = null; + var $took = null; /** * Enter description here... @@ -103,7 +103,7 @@ class DataSource extends Object * @var array * @access private */ - var $_result = null; + var $_result = null; /** * Queries count. @@ -111,7 +111,7 @@ class DataSource extends Object * @var int * @access private */ - var $_queriesCnt = 0; + var $_queriesCnt = 0; /** * Total duration of all queries. @@ -119,7 +119,7 @@ class DataSource extends Object * @var unknown_type * @access private */ - var $_queriesTime = null; + var $_queriesTime = null; /** * Log of queries executed by this DataSource @@ -127,7 +127,7 @@ class DataSource extends Object * @var unknown_type * @access private */ - var $_queriesLog = array(); + var $_queriesLog = array(); /** * Maximum number of items in query log, to prevent query log taking over @@ -137,7 +137,7 @@ class DataSource extends Object * @var int Maximum number of queries in the queries log. * @access private */ - var $_queriesLogMax = 200; + var $_queriesLogMax = 200; /** * The default configuration of a specific DataSource @@ -192,14 +192,14 @@ class DataSource extends Object * Constructor. * */ - function __construct () - { - parent::__construct(); - if(func_num_args() > 0) - { + function __construct () + { + parent::__construct(); + if(func_num_args() > 0) + { $this->setConfig(func_get_arg(0)); - } - } + } + } /** * Returns true if the DataSource supports the given interface (method) @@ -207,13 +207,13 @@ class DataSource extends Object * @param string $interface The name of the interface (method) * @return boolean True on success */ - function isInterfaceSupported ($interface) - { + function isInterfaceSupported ($interface) + { $methods = get_class_methods(get_class($this)); $methods = strtolower(implode('|', $methods)); $methods = explode('|', $methods); return in_array(strtolower($interface), $methods); - } + } /** * Sets the configuration for the DataSource @@ -221,17 +221,17 @@ class DataSource extends Object * @param array $config The configuration array * @return void */ - function setConfig ($config) - { - if(is_array($this->_baseConfig)) - { + function setConfig ($config) + { + if(is_array($this->_baseConfig)) + { $this->config = $this->_baseConfig; foreach($config as $key => $val) { $this->config[$key] = $val; } - } - } + } + } /** * Cache the DataSource description @@ -264,7 +264,7 @@ class DataSource extends Object $new = cache('models'.DS.low(get_class($this)).'_'.$object, $cache, $expires); if($new != null) { - $new = unserialize($new); + $new = unserialize($new); } return $new; } @@ -412,14 +412,14 @@ class DataSource extends Object */ function insertQueryData($query, $data, $association, $assocData, &$model, &$linkModel, $index) { - $keys = array('{$__cake_id__$}', '{$__cake_foreignKey__$}'); + $keys = array('{$__cakeID__$}', '{$__cakeForeignKey__$}'); foreach($keys as $key) { if (strpos($query, $key) !== false) { switch($key) { - case '{$__cake_id__$}': + case '{$__cakeID__$}': $val = null; if (isset($data[$index][$model->name])) { diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index dc578ff99..0d4fc0983 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -51,24 +51,24 @@ class DboSource extends DataSource * * @var unknown_type */ - var $__bypass = false; + var $__bypass = false; /** * Enter description here... * * @var array */ - var $__assocJoins = null; + var $__assocJoins = null; /** * Constructor * */ - function __construct($config = null) - { + function __construct($config = null) + { $this->debug = DEBUG > 0; $this->fullDebug = DEBUG > 1; parent::__construct($config); return $this->connect(); - } + } /** * Prepares a value, or an array of values for database queries by quoting and escaping them. @@ -76,8 +76,8 @@ class DboSource extends DataSource * @param mixed $data A value or an array of values to prepare. * @return mixed Prepared value or array of values. */ - function value ($data, $column = null) - { + function value ($data, $column = null) + { if (is_array($data)) { $out = array(); @@ -91,17 +91,17 @@ class DboSource extends DataSource { return null; } - } + } /** * Convenience method for DboSource::listSources(). * * @return array */ - function sources () - { + function sources () + { return array_map('strtolower', $this->listSources()); - } + } /** * Executes given SQL statement. @@ -109,11 +109,11 @@ class DboSource extends DataSource * @param string $sql SQL statement * @return unknown */ - function rawQuery ($sql) - { + function rawQuery ($sql) + { $this->took = $this->error = $this->numRows = false; return $this->execute($sql); - } + } /** * Queries the database with given SQL statement, and obtains some metadata about the result @@ -123,8 +123,8 @@ class DboSource extends DataSource * @param string $sql * @return unknown */ - function execute($sql) - { + function execute($sql) + { $t = getMicrotime(); $this->_result = $this->_execute($sql); @@ -142,7 +142,7 @@ class DboSource extends DataSource { return $this->_result; } - } + } /** * Returns a single row of results from the _last_ SQL query. @@ -150,8 +150,8 @@ class DboSource extends DataSource * @param resource $res * @return array A single row of results */ - function fetchArray ($assoc=false) - { + function fetchArray ($assoc=false) + { if ($assoc === false) { return $this->fetchRow(); @@ -160,7 +160,7 @@ class DboSource extends DataSource { return $this->fetchRow($assoc); } - } + } /** * Returns a single row of results for a _given_ SQL query. @@ -168,14 +168,14 @@ class DboSource extends DataSource * @param string $sql SQL statement * @return array A single row of results */ - function one ($sql) - { + function one ($sql) + { if ($this->execute($sql)) { return $this->fetchArray(); } return false; - } + } /** * Returns an array of all result rows for a given SQL query. @@ -184,8 +184,8 @@ class DboSource extends DataSource * @param string $sql SQL statement * @return array Array of resultset rows, or false if no rows matched */ - function fetchAll ($sql) - { + function fetchAll ($sql) + { if($this->execute($sql)) { $out = array(); @@ -199,7 +199,7 @@ class DboSource extends DataSource { return false; } - } + } /** * Returns a single field of the first of query results for a given SQL query, or false if empty. @@ -226,18 +226,18 @@ class DboSource extends DataSource * * @return boolean True if the database is connected, else false */ - function isConnected() - { + function isConnected() + { return $this->connected; - } + } /** * Outputs the contents of the queries log. * * @param boolean $sorted */ - function showLog($sorted=false) - { + function showLog($sorted=false) + { $log = $sorted? sortByKey($this->_queriesLog, 'took', 'desc', SORT_NUMERIC): $this->_queriesLog; @@ -259,15 +259,15 @@ class DboSource extends DataSource } print("\n"); - } + } /** * Log given SQL query. * * @param string $sql SQL statement */ - function logQuery($sql) - { + function logQuery($sql) + { $this->_queriesCnt++; $this->_queriesTime += $this->took; @@ -286,10 +286,10 @@ class DboSource extends DataSource if ($this->error) { - return false; // shouldn't we be logging errors somehow? - // TODO: Add hook to error log + return false;// shouldn't we be logging errors somehow? +// TODO: Add hook to error log } - } + } /** * Output information about an SQL query. The SQL statement, number of rows in resultset, @@ -299,22 +299,22 @@ class DboSource extends DataSource */ function showQuery($sql) { - $error = $this->error; + $error = $this->error; - if (strlen($sql) > 200 && !$this->fullDebug) - { + if (strlen($sql) > 200 && !$this->fullDebug) + { $sql = substr($sql, 0, 200) .'[...]'; - } + } - if ($this->debug || $error) - { + if ($this->debug || $error) + { print("

Query: {$sql} [Aff:{$this->affected} Num:{$this->numRows} Took:{$this->took}ms]"); if($error) { print("
ERROR: {$this->error}"); } print('

'); - } + } } /** @@ -403,7 +403,7 @@ class DboSource extends DataSource } } - // Build final query SQL +// Build final query SQL $query = $this->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null); $resultSet = $this->fetchAll($query); @@ -421,7 +421,7 @@ class DboSource extends DataSource // Fetch recursively on belongsTo and hasOne if ($model->recursive > 1) { - //$this->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive - 1); +//$this->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive - 1); } } } @@ -593,7 +593,7 @@ class DboSource extends DataSource { if(array_key_exists('selfJoin', $queryData)) { - return $this->generateSelfAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet); + return $this->generateSelfAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet); } else { @@ -606,7 +606,7 @@ class DboSource extends DataSource { $joinFields = null; } - // Generates primary query +// Generates primary query $sql = 'SELECT ' . join(', ', $this->fields($model, $model->name, $queryData['fields'])) .$joinFields. ' FROM '; $sql .= $this->name($model->table).' AS '; $sql .= $this->name($model->name).' ' . join(' ', $queryData['joins']).' '; @@ -639,7 +639,7 @@ class DboSource extends DataSource $sql .= ' FROM '.$this->name($linkModel->table).' AS '.$alias; $conditions = $queryData['conditions']; $condition = $model->escapeField($assocData['foreignKey']); - $condition .= '={$__cake_foreignKey__$}'; + $condition .= '={$__cakeForeignKey__$}'; if (is_array($conditions)) { $conditions[] = $condition; @@ -702,7 +702,7 @@ class DboSource extends DataSource $conditions = $assocData['conditions']; $condition = $linkModel->escapeField($linkModel->primaryKey); - $condition .= '={$__cake_id__$}'; + $condition .= '={$__cakeID__$}'; if (is_array($conditions)) { @@ -775,12 +775,12 @@ class DboSource extends DataSource if (is_array($conditions)) { - $conditions[$alias.'.'.$assocData['foreignKey']] = '{$__cake_id__$}'; + $conditions[$alias.'.'.$assocData['foreignKey']] = '{$__cakeID__$}'; } else { $cond = $this->name($alias).'.'.$this->name($assocData['foreignKey']); - $cond .= '={$__cake_id__$}'; + $cond .= '={$__cakeID__$}'; if (trim($conditions) != '') { @@ -805,7 +805,7 @@ class DboSource extends DataSource $sql = 'SELECT '.join(', ', $this->fields($linkModel, $alias, $assocData['fields'])); $sql .= ' FROM '.$this->name($linkModel->table).' AS '.$this->name($alias); $sql .= ' JOIN '.$joinTbl.' ON '.$joinTbl; - $sql .= '.'.$this->name($assocData['foreignKey']).'={$__cake_id__$}'; + $sql .= '.'.$this->name($assocData['foreignKey']).'={$__cakeID__$}'; $sql .= ' AND '.$joinTbl.'.'.$this->name($assocData['associationForeignKey']); $sql .= ' = '.$this->name($alias).'.'.$this->name($linkModel->primaryKey); @@ -971,7 +971,13 @@ class DboSource extends DataSource } $count = count($fields); - if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false) + if ($count >= 1 && $fields[0] != '*' + && strpos($fields[0], 'COUNT(') === false + && strpos($fields[0], 'MAX(') === false + && strpos($fields[0], 'MIN(') === false + && strpos($fields[0], 'DISTINCT') === false + && strpos($fields[0], 'SUM(') === false + && strpos($fields[0], 'CONCAT(') === false) { for ($i = 0; $i < $count; $i++) { @@ -1010,6 +1016,16 @@ class DboSource extends DataSource { $conditions = ' 1 = 1'; } + else + { + preg_match_all('/([a-zA-Z0-9_]{1,})\\.([a-zA-Z0-9_]{1,})/', $conditions, $result, PREG_PATTERN_ORDER); + $pregCount = count($result[0]); + + for ($i = 0; $i < $pregCount; $i++) + { + $conditions = preg_replace('/'.$result[0][$i].'/', $this->name($result[0][$i]), $conditions); + } + } return $rt.$conditions; } elseif (is_array($conditions)) @@ -1032,7 +1048,7 @@ class DboSource extends DataSource } else { - if (($value != '{$__cake_id__$}') && ($value != '{$__cake_foreignKey__$}')) + if (($value != '{$__cakeID__$}') && ($value != '{$__cakeForeignKey__$}')) { $value = $this->value($value); } @@ -1118,12 +1134,12 @@ class DboSource extends DataSource */ function close () { - if ($this->fullDebug) - { - $this->showLog(); - } - $this->_conn = NULL; - $this->connected = false; + if ($this->fullDebug) + { + $this->showLog(); + } + $this->_conn = NULL; + $this->connected = false; } /** @@ -1147,10 +1163,10 @@ class DboSource extends DataSource * @param string $sql SQL WHERE clause (condition only, not the "WHERE" part) * @return boolean True if the table has a matching record, else false */ - function hasAny($table, $sql) - { + function hasAny($table, $sql) + { $out = $this->one("SELECT COUNT(*) AS count FROM {$table}".($sql? " WHERE {$sql}":"")); return is_array($out)? $out[0]['count']: false; - } + } } ?> \ No newline at end of file diff --git a/cake/libs/model/dbo/dbo_adodb.php b/cake/libs/model/dbo/dbo_adodb.php index 923e94ece..ae11db011 100644 --- a/cake/libs/model/dbo/dbo_adodb.php +++ b/cake/libs/model/dbo/dbo_adodb.php @@ -50,7 +50,7 @@ class DboAdodb extends DboSource * * @var unknown_type */ - var $description = "ADOdb DBO Driver"; + var $description = "ADOdb DBO Driver"; /** @@ -59,15 +59,15 @@ class DboAdodb extends DboSource * @var ADOConnection The connection object. * @access private */ - var $_adodb = null; + var $_adodb = null; /** * Connects to the database using options in the given configuration array. * * @param array $config Configuration array for connecting */ - function connect () - { + function connect () + { $config = $this->config; $persistent = strrpos($config['connect'], '|p'); if($persistent === FALSE){ @@ -86,19 +86,19 @@ class DboAdodb extends DboSource if(!$this->connected) { - //die('Could not connect to DB.'); +//die('Could not connect to DB.'); } - } + } /** * Disconnects from database. * * @return boolean True if the database could be disconnected, else false */ - function disconnect () - { + function disconnect () + { return $this->_adodb->Close(); - } + } /** * Executes given SQL statement. @@ -106,20 +106,20 @@ class DboAdodb extends DboSource * @param string $sql SQL statement * @return resource Result resource identifier */ - function execute ($sql) - { + function execute ($sql) + { return $this->_adodb->execute($sql); - } + } /** * Returns a row from given resultset as an array . * * @return array The fetched row as an array */ - function fetchRow () - { + function fetchRow () + { return $this->_result->FetchRow(); - } + } /** * Begin a transaction @@ -181,8 +181,8 @@ class DboAdodb extends DboSource * * @return array Array of tablenames in the database */ - function tablesList () - { + function tablesList () + { $tables = $this->_adodb->MetaTables('TABLES'); if (!sizeof($tables) > 0) { @@ -190,7 +190,7 @@ class DboAdodb extends DboSource exit; } return $tables; - } + } /** * Returns an array of the fields in given table name. @@ -198,8 +198,8 @@ class DboAdodb extends DboSource * @param string $tableName Name of database table to inspect * @return array Fields in table. Keys are name and type */ - function fields ($tableName) - { + function fields ($tableName) + { $data = $this->_adodb->MetaColumns($tableName); $fields = false; @@ -207,7 +207,7 @@ class DboAdodb extends DboSource $fields[] = array('name'=>$item->name, 'type'=>$item->type); return $fields; - } + } /** * Returns a quoted and escaped string of $data for use in an SQL statement. @@ -217,40 +217,40 @@ class DboAdodb extends DboSource * * @todo To be implemented. */ - function prepareValue ($data) - { + function prepareValue ($data) + { return $this->_adodb->Quote($data); - } + } /** * Returns a formatted error message from previous database operation. * * @return string Error message */ - function lastError () - { + function lastError () + { return $this->_adodb->ErrorMsg(); - } + } /** * Returns number of affected rows in previous database operation, or false if no previous operation exists. * * @return int Number of affected rows */ - function lastAffected () - { + function lastAffected () + { return $this->_adodb->Affected_Rows(); - } + } /** * Returns number of rows in previous resultset, or false if no previous resultset exists. * * @return int Number of rows in resultset */ - function lastNumRows () - { - return $this->_result? $this->_result->RecordCount(): false; - } + function lastNumRows () + { + return $this->_result? $this->_result->RecordCount(): false; + } /** * Returns the ID generated from the previous INSERT operation. @@ -259,10 +259,10 @@ class DboAdodb extends DboSource * * @Returns the last autonumbering ID inserted. Returns false if function not supported. */ - function lastInsertId () - { - return $this->_adodb->Insert_ID(); - } + function lastInsertId () + { + return $this->_adodb->Insert_ID(); + } /** * Returns a LIMIT statement in the correct format for the particular database. @@ -272,12 +272,12 @@ class DboAdodb extends DboSource * @return string SQL limit/offset statement * @todo Please change output string to whatever select your database accepts. adodb doesn't allow us to get the correct limit string out of it. */ - function selectLimit ($limit, $offset=null) - { + function selectLimit ($limit, $offset=null) + { return " LIMIT {$limit}".($offset? "{$offset}": null); - // please change to whatever select your database accepts - // adodb doesn't allow us to get the correct limit string out of it - } +// please change to whatever select your database accepts +// adodb doesn't allow us to get the correct limit string out of it + } } diff --git a/cake/libs/model/dbo/dbo_dbo.php b/cake/libs/model/dbo/dbo_dbo.php index 860d6f887..1643e1ba8 100644 --- a/cake/libs/model/dbo/dbo_dbo.php +++ b/cake/libs/model/dbo/dbo_dbo.php @@ -44,22 +44,22 @@ uses('object'); * Example usage: * * - * require('dbo_mysql.php'); // or 'dbo_postgres.php' + * require('dbo_mysql.php');// or 'dbo_postgres.php' * - * // create and connect the object - * $db = new DBO_MySQL(array( // or 'DBO_Postgres' + *// create and connect the object + * $db = new DBO_MySQL(array(// or 'DBO_Postgres' * 'host'=>'localhost', * 'login'=>'username', * 'password'=>'password', * 'database'=>'database')); * - * // read the whole query result array (of rows) + *// read the whole query result array (of rows) * $all_rows = $db->fetchAll("SELECT a,b,c FROM table"); * - * // read the first row with debugging on + *// read the first row with debugging on * $first_row_only = $db->one("SELECT a,b,c FROM table WHERE a=1", TRUE); * - * // emulate the usual way of reading query results + *// emulate the usual way of reading query results * if ($db->query("SELECT a,b,c FROM table")) * { * while ($row = $db->fetchArray()) @@ -68,7 +68,7 @@ uses('object'); * } * } * - * // show a log of all queries, sorted by execution time + *// show a log of all queries, sorted by execution time * $db->showLog(TRUE); * * @@ -85,7 +85,7 @@ class DBO extends Object * @var boolean * @access public */ - var $connected=FALSE; + var $connected=FALSE; /** * Connection configuration. @@ -93,7 +93,7 @@ class DBO extends Object * @var array * @access public */ - var $config=FALSE; + var $config=FALSE; /** * Enter description here... @@ -101,7 +101,7 @@ class DBO extends Object * @var boolean * @access public */ - var $debug=FALSE; + var $debug=FALSE; /** * Enter description here... @@ -109,7 +109,7 @@ class DBO extends Object * @var boolean * @access public */ - var $fullDebug=FALSE; + var $fullDebug=FALSE; /** * Enter description here... @@ -117,7 +117,7 @@ class DBO extends Object * @var unknown_type * @access public */ - var $error=NULL; + var $error=NULL; /** * String to hold how many rows were affected by the last SQL operation. @@ -125,7 +125,7 @@ class DBO extends Object * @var unknown_type * @access public */ - var $affected=NULL; + var $affected=NULL; /** * Number of rows in current resultset @@ -133,7 +133,7 @@ class DBO extends Object * @var int * @access public */ - var $numRows=NULL; + var $numRows=NULL; /** * Time the last query took @@ -141,7 +141,7 @@ class DBO extends Object * @var unknown_type * @access public */ - var $took=NULL; + var $took=NULL; /** * Enter description here... @@ -149,7 +149,7 @@ class DBO extends Object * @var unknown_type * @access private */ - var $_conn=NULL; + var $_conn=NULL; /** * Enter description here... @@ -157,7 +157,7 @@ class DBO extends Object * @var unknown_type * @access private */ - var $_result=NULL; + var $_result=NULL; /** * Queries count. @@ -165,7 +165,7 @@ class DBO extends Object * @var unknown_type * @access private */ - var $_queriesCnt=0; + var $_queriesCnt=0; /** * Total duration of all queries. @@ -173,7 +173,7 @@ class DBO extends Object * @var unknown_type * @access private */ - var $_queriesTime=NULL; + var $_queriesTime=NULL; /** * Enter description here... @@ -181,7 +181,7 @@ class DBO extends Object * @var unknown_type * @access private */ - var $_queriesLog=array(); + var $_queriesLog=array(); /** * Maximum number of items in query log, to prevent query log taking over @@ -191,7 +191,7 @@ class DBO extends Object * @var int Maximum number of queries in the queries log. * @access private */ - var $_queriesLogMax=200; + var $_queriesLogMax=200; /** @@ -200,22 +200,22 @@ class DBO extends Object * @param array $config * @return unknown */ - function __construct($config=NULL) - { + function __construct($config=NULL) + { $this->debug = DEBUG > 0; $this->fullDebug = DEBUG > 1; parent::__construct(); return $this->connect($config); - } + } /** * Destructor. Closes connection to the database. * */ - function __destructor() - { + function __destructor() + { $this->close(); - } + } /** * Returns a string with a USE [databasename] SQL statement. @@ -223,22 +223,22 @@ class DBO extends Object * @param string $db_name Name of database to use * @return unknown Result of the query */ - function useDb($db_name) - { + function useDb($db_name) + { return $this->query("USE {$db_name}"); - } + } /** * Disconnects database, kills the connection and says the connection is closed, and if DEBUG is turned on, the log for this object is shown. * */ - function close () - { + function close () + { if ($this->fullDebug) $this->showLog(); $this->disconnect(); $this->_conn = NULL; $this->connected = false; - } + } /** * Prepares a value, or an array of values for database queries by quoting and escaping them. @@ -246,8 +246,8 @@ class DBO extends Object * @param mixed $data A value or an array of values to prepare. * @return mixed Prepared value or array of values. */ - function prepare ($data) - { + function prepare ($data) + { if (is_array($data)) { $out = null; @@ -261,12 +261,12 @@ class DBO extends Object { return $this->prepareValue($data); } - } + } - function sources () - { + function sources () + { return array_map('strtolower', $this->listSources()); - } + } /** * Executes given SQL statement. @@ -274,11 +274,11 @@ class DBO extends Object * @param string $sql SQL statement * @return unknown */ - function rawQuery ($sql) - { + function rawQuery ($sql) + { $this->took = $this->error = $this->numRows = false; return $this->execute($sql); - } + } /** * Queries the database with given SQL statement, and obtains some metadata about the result @@ -288,8 +288,8 @@ class DBO extends Object * @param string $sql * @return unknown */ - function query($sql) - { + function query($sql) + { $t = getMicrotime(); $this->_result = $this->execute($sql); $this->affected = $this->lastAffected(); @@ -301,7 +301,7 @@ class DBO extends Object $this->showQuery($sql); return $this->error? false: $this->_result; - } + } /** * Returns a single row of results from the _last_ SQL query. @@ -309,8 +309,8 @@ class DBO extends Object * @param resource $res * @return array A single row of results */ - function farr ($assoc=false) - { + function farr ($assoc=false) + { if ($assoc === false) { return $this->fetchRow(); @@ -319,7 +319,7 @@ class DBO extends Object { return $this->fetchRow($assoc); } - } + } /** * Returns a single row of results for a _given_ SQL query. @@ -327,10 +327,10 @@ class DBO extends Object * @param string $sql SQL statement * @return array A single row of results */ - function one ($sql) - { + function one ($sql) + { return $this->query($sql)? $this->fetchArray(): false; - } + } /** * Returns an array of all result rows for a given SQL query. @@ -339,8 +339,8 @@ class DBO extends Object * @param string $sql SQL statement * @return array Array of resultset rows, or false if no rows matched */ - function all ($sql) - { + function all ($sql) + { if($this->query($sql)) { $out=array(); @@ -354,7 +354,7 @@ class DBO extends Object { return false; } - } + } /** * Returns a single field of the first of query results for a given SQL query, or false if empty. @@ -363,11 +363,11 @@ class DBO extends Object * @param string $sql SQL query * @return unknown */ - function field ($name, $sql) - { + function field ($name, $sql) + { $data = $this->one($sql); return empty($data[$name])? false: $data[$name]; - } + } /** * Checks if the specified table contains any record matching specified SQL @@ -376,29 +376,29 @@ class DBO extends Object * @param string $sql SQL WHERE clause (condition only, not the "WHERE" part) * @return boolean True if the table has a matching record, else false */ - function hasAny($table, $sql) - { + function hasAny($table, $sql) + { $out = $this->one("SELECT COUNT(*) AS count FROM {$table}".($sql? " WHERE {$sql}":"")); return is_array($out)? $out[0]['count']: false; - } + } /** * Checks if it's connected to the database * * @return boolean True if the database is connected, else false */ - function isConnected() - { + function isConnected() + { return $this->connected; - } + } /** * Outputs the contents of the log. * * @param boolean $sorted */ - function showLog($sorted=false) - { + function showLog($sorted=false) + { $log = $sorted? sortByKey($this->_queriesLog, 'took', 'desc', SORT_NUMERIC): $this->_queriesLog; @@ -412,15 +412,15 @@ class DBO extends Object } print("\n"); - } + } /** * Log given SQL query. * * @param string $sql SQL statement */ - function logQuery($sql) - { + function logQuery($sql) + { $this->_queriesCnt++; $this->_queriesTime += $this->took; @@ -438,8 +438,8 @@ class DBO extends Object } if ($this->error) - return false; // shouldn't we be logging errors somehow? - } + return false;// shouldn't we be logging errors somehow? + } /** * Output information about an SQL query. The SQL statement, number of rows in resultset, @@ -447,8 +447,8 @@ class DBO extends Object * * @param string $sql */ - function showQuery($sql) - { + function showQuery($sql) + { $error = $this->error; if (strlen($sql)>200 && !$this->fullDebug) @@ -465,7 +465,7 @@ class DBO extends Object } print('

'); } - } + } } ?> \ No newline at end of file diff --git a/cake/libs/model/dbo/dbo_generic.php b/cake/libs/model/dbo/dbo_generic.php index 8fb6f0841..9d63c3424 100644 --- a/cake/libs/model/dbo/dbo_generic.php +++ b/cake/libs/model/dbo/dbo_generic.php @@ -44,99 +44,99 @@ class DBO_generic extends DBO * Abstract method defined in subclasses. * */ - function connect ($config) - { - } + function connect ($config) + { + } /** * Abstract method defined in subclasses. * */ - function disconnect () - { - } + function disconnect () + { + } /** * Abstract method defined in subclasses. * */ - function execute ($sql) - { - } - -/** - * Abstract method defined in subclasses. - * - * - */ - function fetchRow () - { - } + function execute ($sql) + { + } /** * Abstract method defined in subclasses. * * */ - function tablesList () - { - } + function fetchRow () + { + } + +/** + * Abstract method defined in subclasses. + * + * + */ + function tablesList () + { + } /** * Abstract method defined in subclasses. * */ - function fields ($tableName) - { - } + function fields ($tableName) + { + } /** * Abstract method defined in subclasses. * */ - function prepareValue ($data) - { - } + function prepareValue ($data) + { + } /** * Abstract method defined in subclasses. * */ - function lastError () - { - } + function lastError () + { + } /** * Abstract method defined in subclasses. * */ - function lastAffected () - { - } + function lastAffected () + { + } /** * Abstract method defined in subclasses. * */ - function lastNumRows () - { - } + function lastNumRows () + { + } /** * Abstract method defined in subclasses. * */ - function lastInsertId () - { - } + function lastInsertId () + { + } /** * Abstract method defined in subclasses. * */ - function selectLimit ($limit, $offset=null) - { - } + function selectLimit ($limit, $offset=null) + { + } } diff --git a/cake/libs/model/dbo/dbo_mysql.php b/cake/libs/model/dbo/dbo_mysql.php index 496de8d80..1e7f255d0 100644 --- a/cake/libs/model/dbo/dbo_mysql.php +++ b/cake/libs/model/dbo/dbo_mysql.php @@ -58,11 +58,11 @@ class DboMysql extends DboSource * @var unknown_type */ var $_baseConfig = array('persistent' => true, - 'host' => 'localhost', + 'host' => 'localhost', 'login' => 'root', - 'password' => '', - 'database' => 'cake', - 'port' => 3306); + 'password' => '', + 'database' => 'cake', + 'port' => 3306); /** * Enter description here... @@ -73,9 +73,9 @@ class DboMysql extends DboSource 'string' => array('name' => 'varchar', 'limit' => '255'), 'text' => array('name' => 'text'), 'integer' => array('name' => 'int', 'limit' => '11'), - 'float' => array('name' => 'float'), + 'float' => array('name' => 'float'), 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s'), - 'timestamp' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s'), + 'timestamp' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s'), 'time' => array('name' => 'time', 'format' => 'h:i:s'), 'date' => array('name' => 'date', 'format' => 'Y-m-d'), 'binary' => array('name' => 'blob'), @@ -115,7 +115,7 @@ class DboMysql extends DboSource } else { - //die('Could not connect to DB.'); +//die('Could not connect to DB.'); } } @@ -257,7 +257,12 @@ class DboMysql extends DboSource { return '*'; } - return '`'. ereg_replace('\.', '`.`', $data) .'`'; + $pos = strpos($data, '`'); + if ($pos === false) + { + $data = '`'. str_replace('.', '`.`', $data) .'`'; + } + return $data; } /** @@ -294,7 +299,7 @@ class DboMysql extends DboSource $return = $data; } return $return; - } + } /** * Translates between PHP boolean values and MySQL (faked) boolean values diff --git a/cake/libs/model/dbo/dbo_pear.php b/cake/libs/model/dbo/dbo_pear.php index 07cfcc4f6..91e2ec221 100644 --- a/cake/libs/model/dbo/dbo_pear.php +++ b/cake/libs/model/dbo/dbo_pear.php @@ -29,8 +29,8 @@ */ /** - * Create an include path required PEAR libraries. - */ + * Create an include path required PEAR libraries. + */ uses('model'.DS.'dbo'.DS.'dbo'); ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . PEAR); vendor('Pear/DB'); @@ -53,21 +53,21 @@ class DBO_Pear extends DBO * @var DB The connection object. * @access private */ - var $_pear = null; + var $_pear = null; /** - * Connects to the database using options in the given configuration array. - * - * @param array $config Configuration array for connecting - * @return boolean True if the database could be connected, else false - */ - function connect ($config) - { + * Connects to the database using options in the given configuration array. + * + * @param array $config Configuration array for connecting + * @return boolean True if the database could be connected, else false + */ + function connect ($config) + { $this->config = $config; $dsn = $config['driver'].'://'.$config['login'].':'.$config['password'].'@'.$config['host'].'/'.$config['database']; $options = array( - 'debug' => DEBUG-1, + 'debug' => DEBUG-1, 'portability' => DB_PORTABILITY_ALL, ); @@ -76,47 +76,47 @@ class DBO_Pear extends DBO return !(PEAR::isError($this->_pear)); - } + } /** - * Disconnects from database. - * - * @return boolean True if the database could be disconnected, else false - */ - function disconnect () - { + * Disconnects from database. + * + * @return boolean True if the database could be disconnected, else false + */ + function disconnect () + { die('Please implement DBO::disconnect() first.'); - } + } /** - * Executes given SQL statement. - * - * @param string $sql SQL statement - * @return resource Result resource identifier - */ - function execute ($sql) - { + * Executes given SQL statement. + * + * @param string $sql SQL statement + * @return resource Result resource identifier + */ + function execute ($sql) + { return $this->_pear->query($sql); - } + } /** - * Returns a row from given resultset as an array . - * - * @return array The fetched row as an array - */ - function fetchRow () - { + * Returns a row from given resultset as an array . + * + * @return array The fetched row as an array + */ + function fetchRow () + { return $this->_result->fetchRow(DB_FETCHMODE_ASSOC); - } + } /** - * Returns an array of tables in the database. If there are no tables, an error is raised and the application exits. - * :WARNING: :TODO: POSTGRESQL & MYSQL ONLY! PEAR::DB doesn't support universal table listing. - * - * @return array Array of tablenames in the database - */ - function tablesList () - { + * Returns an array of tables in the database. If there are no tables, an error is raised and the application exits. + * :WARNING: :TODO: POSTGRESQL & MYSQL ONLY! PEAR::DB doesn't support universal table listing. + * + * @return array Array of tablenames in the database + */ + function tablesList () + { $driver = $this->config['driver']; $tables = array(); @@ -159,16 +159,16 @@ class DBO_Pear extends DBO { return $tables; } - } + } /** - * Returns an array of the fields in given table name. - * - * @param string $tableName Name of database table to inspect - * @return array Fields in table. Keys are name and type - */ - function fields ($tableName) - { + * Returns an array of the fields in given table name. + * + * @param string $tableName Name of database table to inspect + * @return array Fields in table. Keys are name and type + */ + function fields ($tableName) + { $data = $this->_pear->tableInfo($tableName); $fields = false; @@ -176,47 +176,47 @@ class DBO_Pear extends DBO $fields[] = array('name'=>$item['name'], 'type'=>$item['type']); return $fields; - } + } /** - * Returns a quoted and escaped string of $data for use in an SQL statement. - * - * @param string $data String to be prepared for use in an SQL statement - * @return string Quoted and escaped - */ - function prepareValue ($data) - { + * Returns a quoted and escaped string of $data for use in an SQL statement. + * + * @param string $data String to be prepared for use in an SQL statement + * @return string Quoted and escaped + */ + function prepareValue ($data) + { return $this->_pear->quoteSmart($data); - } + } /** - * Returns a formatted error message from previous database operation. - * - * @return string Error message - */ - function lastError () - { + * Returns a formatted error message from previous database operation. + * + * @return string Error message + */ + function lastError () + { return PEAR::isError($this->_result)? $this->_result->getMessage(): null; - } + } /** - * Returns number of affected rows in previous database operation. If no previous operation exists, this returns false. - * - * @return int Number of affected rows - */ - function lastAffected () - { + * Returns number of affected rows in previous database operation. If no previous operation exists, this returns false. + * + * @return int Number of affected rows + */ + function lastAffected () + { return $this->_pear->affectedRows(); - } + } /** - * Returns number of rows in previous resultset. If no previous resultset exists, - * this returns false. - * - * @return int Number of rows in resultset - */ - function lastNumRows () - { + * Returns number of rows in previous resultset. If no previous resultset exists, + * this returns false. + * + * @return int Number of rows in resultset + */ + function lastNumRows () + { if (method_exists($this->_result, 'numRows')) { return $this->_result->numRows(); @@ -225,18 +225,18 @@ class DBO_Pear extends DBO { return false; } - } + } /** - * Returns the ID generated from the previous INSERT operation. - * - * @param string $table Name of the database table - * @return int - */ - function lastInsertId ($table) - { + * Returns the ID generated from the previous INSERT operation. + * + * @param string $table Name of the database table + * @return int + */ + function lastInsertId ($table) + { return $this->field('id', "SELECT MAX(id) FROM {$table}"); - } + } /** * Returns a limit statement in the correct format for the particular database. @@ -245,10 +245,10 @@ class DBO_Pear extends DBO * @param int $offset Offset from which to start results * @return string SQL limit/offset statement */ - function selectLimit ($limit, $offset='0') - { + function selectLimit ($limit, $offset='0') + { return ' ' . $this->_pear->modifyLimitQuery('', $offset, $limit); - } + } } diff --git a/cake/libs/model/dbo/dbo_postgres.php b/cake/libs/model/dbo/dbo_postgres.php index 93c654656..507c28481 100644 --- a/cake/libs/model/dbo/dbo_postgres.php +++ b/cake/libs/model/dbo/dbo_postgres.php @@ -29,8 +29,8 @@ */ /** - * Include DBO. - */ + * Include DBO. + */ uses('model'.DS.'datasources'.DS.'dbo_source'); /** @@ -45,23 +45,23 @@ uses('model'.DS.'datasources'.DS.'dbo_source'); class DboPostgres extends DboSource { - var $description = "PostgreSQL DBO Driver"; + var $description = "PostgreSQL DBO Driver"; - var $_baseConfig = array('persistent' => true, - 'host' => 'localhost', + var $_baseConfig = array('persistent' => true, + 'host' => 'localhost', 'login' => 'root', - 'password' => '', - 'database' => 'cake', - 'port' => 3306); + 'password' => '', + 'database' => 'cake', + 'port' => 3306); - var $columns = array( + var $columns = array( 'primary_key' => array('name' => 'serial primary key'), 'string' => array('name' => 'varchar', 'limit' => '255'), 'text' => array('name' => 'text'), 'integer' => array('name' => 'integer'), - 'float' => array('name' => 'float'), + 'float' => array('name' => 'float'), 'datetime' => array('name' => 'timestamp'), - 'timestamp' => array('name' => 'timestamp'), + 'timestamp' => array('name' => 'timestamp'), 'time' => array('name' => 'time'), 'date' => array('name' => 'date'), 'binary' => array('name' => 'bytea'), @@ -69,12 +69,12 @@ class DboPostgres extends DboSource 'number' => array('name' => 'numeric')); /** - * Connects to the database using options in the given configuration array. - * - * @return True if successfully connected. - */ - function connect () - { + * Connects to the database using options in the given configuration array. + * + * @return True if successfully connected. + */ + function connect () + { $config = $this->config; $connect = $config['connect']; @@ -89,31 +89,31 @@ class DboPostgres extends DboSource } return $this->connected; - } + } /** - * Disconnects from database. - * - * @return boolean True if the database could be disconnected, else false - */ - function disconnect () - { + * Disconnects from database. + * + * @return boolean True if the database could be disconnected, else false + */ + function disconnect () + { return pg_close($this->connection); - } + } /** - * Executes given SQL statement. - * - * @param string $sql SQL statement - * @return resource Result resource identifier - */ - function _execute ($sql) - { + * Executes given SQL statement. + * + * @param string $sql SQL statement + * @return resource Result resource identifier + */ + function _execute ($sql) + { return pg_query($this->connection, $sql); - } + } - function query () - { + function query () + { $args = func_get_args(); if (count($args) == 1) { @@ -131,26 +131,34 @@ class DboPostgres extends DboSource $query = '"' . $args[2]->name . '"."' . $field . '" = ' . $this->value($args[1][0]); return $args[2]->findAll($query); } - } + } /** - * Returns a row from given resultset as an array . - * - * @return array The fetched row as an array - */ - function fetchRow ($assoc = false) - { - $assoc = ($assoc === false) ? PGSQL_BOTH : PGSQL_ASSOC; - return pg_fetch_array($this->_result, null, $assoc); - } + * Returns a row from given resultset as an array . + * + * @return array The fetched row as an array + */ + function fetchRow ($assoc = false) + { + if(is_resource($this->_result)) + { + $this->resultSet($this->_result); + $resultRow = $this->fetchResult(); + return $resultRow; + } + else + { + return null; + } + } /** - * Returns an array of tables in the database. If there are no tables, an error is raised and the application exits. - * - * @return array Array of tablenames in the database - */ - function listSources () - { + * Returns an array of tables in the database. If there are no tables, an error is raised and the application exits. + * + * @return array Array of tablenames in the database + */ + function listSources () + { $sql = "SELECT table_name as name FROM information_schema.tables WHERE table_schema = 'public';"; $result = $this->query($sql); @@ -164,33 +172,72 @@ class DboPostgres extends DboSource $tables = array(); foreach ($result as $item) { - $tables[] = $item['name']; + $tables[] = $item[0]['name']; } return $tables; } - } + } /** - * Returns an array of the fields in given table name. - * - * @param string $tableName Name of database table to inspect - * @return array Fields in table. Keys are name and type - */ - function fields ($tableName) - { - $sql = "SELECT c.relname, a.attname, t.typname FROM pg_class c, pg_attribute a, pg_type t WHERE c.relname = '{$tableName}' AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid"; + * Generates the fields list of an SQL query. + * + * @param Model $model + * @param string $alias Alias tablename + * @param mixed $fields + * @return array + */ + function fields (&$model, $alias, $fields) + { + if (is_array($fields)) + { + $fields = $fields; + } + else + { + if ($fields != null) + { + if (strpos($fields, ',')) + { + $fields = explode(',', $fields); + } + else + { + $fields = array($fields); + } + $fields = array_map('trim', $fields); + } + else + { + foreach ($model->_tableInfo->value as $field) + { + $fields[]= $field[0]['name']; + } - $fields = false; - foreach ($this->all($sql) as $field) { - $fields[] = array( - 'name' => $field['attname'], - 'type' => $field['typname']); - } + } + } - return $fields; - } + $count = count($fields); + if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false) + { + for ($i = 0; $i < $count; $i++) + { + $dot = strrpos($fields[$i], '.'); + if ($dot === false) + { + $fields[$i] = $this->name($alias).'.'.$this->name($fields[$i]) . ' AS ' . $this->name($alias . '__' . $fields[$i]); + } + else + { + $build = explode('.',$fields[$i]); + $fields[$i] = $this->name($build[0]).'.'.$this->name($build[1]) . ' AS ' . $this->name($build[0] . '__' . $build[1]); + } + } + } + + return $fields; + } - /** +/** * Returns an array of the fields in given table name. * * @param string $tableName Name of database table to inspect @@ -206,92 +253,115 @@ class DboPostgres extends DboSource $fields = false; - $fields = $this->query("SELECT column_name as name, data_type as type FROM information_schema.columns WHERE table_name =".$this->name($model->table)); + $fields = $this->query("SELECT column_name as name, data_type as type FROM information_schema.columns WHERE table_name =".$this->value($model->table)); $this->__cacheDescription($model->table, $fields); return $fields; } /** - * Returns a quoted and escaped string of $data for use in an SQL statement. - * - * @param string $data String to be prepared for use in an SQL statement - * @return string Quoted and escaped - */ - function name ($data) - { - return "'". $data."'"; - } + * Returns a quoted and escaped string of $data for use in an SQL statement. + * + * @param string $data String to be prepared for use in an SQL statement + * @return string Quoted and escaped + */ + function name ($data) + { + if ($data == '*') + { + return '*'; + } + return '"'. ereg_replace('\.', '"."', $data) .'"'; + } /** - * Returns a quoted and escaped string of $data for use in an SQL statement. - * - * @param string $data String to be prepared for use in an SQL statement - * @return string Quoted and escaped - */ - function value ($data) - { - return "'".pg_escape_string($data)."'"; - } + * Returns a quoted and escaped string of $data for use in an SQL statement. + * + * @param string $data String to be prepared for use in an SQL statement + * @param string $column The column into which this data will be inserted + * @return string Quoted and escaped + * @todo Add logic that formats/escapes data based on column type + */ + function value ($data, $column = null) + { + $parent = parent::value($data, $column); + if ($parent != null) + { + return $parent; + } + if ($data === null) + { + return 'NULL'; + } + if (ini_get('magic_quotes_gpc') == 1) + { + $data = stripslashes($data); + } + + $data = pg_escape_string($data); + + $return = "'" . $data . "'"; + return $return; + } /** - * Returns a formatted error message from previous database operation. - * - * @return string Error message - */ - function lastError () - { + * Returns a formatted error message from previous database operation. + * + * @return string Error message + */ + function lastError () + { $last_error = pg_last_error($this->connection); if ($last_error) { return $last_error; } return null; - } + } /** - * Returns number of affected rows in previous database operation. If no previous operation exists, this returns false. - * - * @return int Number of affected rows - */ - function lastAffected () - { + * Returns number of affected rows in previous database operation. If no previous operation exists, this returns false. + * + * @return int Number of affected rows + */ + function lastAffected () + { if ($this->_result) { return pg_affected_rows($this->_result); } return false; - } + } /** - * Returns number of rows in previous resultset. If no previous resultset exists, - * this returns false. - * - * @return int Number of rows in resultset - */ - function lastNumRows () - { + * Returns number of rows in previous resultset. If no previous resultset exists, + * this returns false. + * + * @return int Number of rows in resultset + */ + function lastNumRows () + { if ($this->_result) { return pg_num_rows($this->_result); } return false; - } + } /** - * Returns the ID generated from the previous INSERT operation. - * - * @param string $source Name of the database table - * @param string $field Name of the ID database field. Defaults to "id" - * @return int - */ - function lastInsertId ($source, $field='id') - { + * Returns the ID generated from the previous INSERT operation. + * + * @param string $source Name of the database table + * @param string $field Name of the ID database field. Defaults to "id" + * @return int + */ + function lastInsertId ($source, $field='id') + { $sql = "SELECT CURRVAL('{$source}_{$field}_seq') AS max"; $res = $this->rawQuery($sql); $data = $this->fetchRow($res); return $data['max']; - } + } /** * Returns a limit statement in the correct format for the particular database. @@ -300,16 +370,74 @@ class DboPostgres extends DboSource * @param int $offset Offset from which to start results * @return string SQL limit/offset statement */ - function limit ($limit, $offset = null) - { - $rt = ' LIMIT ' . $limit; - if ($offset) - { - $rt .= ' OFFSET ' . $offset; - } - return $rt; - } + function limit ($limit, $offset = null) + { + if ($limit) + { + $rt = ''; + if (!strpos(low($limit), 'limit') || strpos(low($limit), 'limit') === 0) + { + $rt = ' LIMIT'; + } + if ($offset) + { + $rt .= ' ' . $offset. ','; + } + $rt .= ' ' . $limit; + return $rt; + } + return null; + } + + function resultSet(&$results) + { + $this->results =& $results; + $this->map = array(); + $num_fields = pg_num_fields($results); + $index = 0; + $j = 0; + while ($j < $num_fields) + { + $columnName = pg_field_name($results, $j); + + if (strpos($columnName, '__')) + { + $parts = explode('__', $columnName); + $this->map[$index++] = array($parts[0], $parts[1]); + } + else + { + $this->map[$index++] = array(0, $columnName); + } + $j++; + } + } + +/** + * Fetches the next row from the current result set + * + * @return unknown + */ + function fetchResult() + { + if ($row = pg_fetch_row($this->results)) + { + $resultRow = array(); + $i =0; + foreach ($row as $index => $field) + { + list($table, $column) = $this->map[$index]; + $resultRow[$table][$column] = $row[$index]; + $i++; + } + return $resultRow; + } + else + { + return false; + } + } } -?> \ No newline at end of file +?> diff --git a/cake/libs/model/dbo/dbo_sqlite.php b/cake/libs/model/dbo/dbo_sqlite.php index 8baabb43f..a30864863 100644 --- a/cake/libs/model/dbo/dbo_sqlite.php +++ b/cake/libs/model/dbo/dbo_sqlite.php @@ -51,8 +51,8 @@ class DBO_SQLite extends DBO * @param array $config Configuration array for connecting * @return mixed */ - function connect($config) - { + function connect($config) + { if ($config) { $this->config = $config; @@ -66,19 +66,19 @@ class DBO_SQLite extends DBO } else { - //die('Could not connect to DB.'); +//die('Could not connect to DB.'); } - } + } /** * Disconnects from database. * * @return boolean True if the database could be disconnected, else false */ - function disconnect() - { + function disconnect() + { return sqlite_close($this->_conn); - } + } /** * Executes given SQL statement. @@ -86,28 +86,28 @@ class DBO_SQLite extends DBO * @param string $sql SQL statement * @return resource Result resource identifier */ - function execute($sql) - { + function execute($sql) + { return sqlite_query($this->_conn, $sql); - } + } /** * Returns a row from given resultset as an array. * * @return array The fetched row as an array */ - function fetchRow() - { + function fetchRow() + { return sqlite_fetch_array($this->_result); - } + } /** * Returns an array of tables in the database. If there are no tables, an error is raised and the application exits. * * @return array Array of tablenames in the database */ - function tablesList() - { + function tablesList() + { $result = sqlite_query($this->_conn, "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"); if (!$result) @@ -124,7 +124,7 @@ class DBO_SQLite extends DBO } return $tables; } - } + } /** * Returns an array of the fields in given table name. @@ -132,8 +132,8 @@ class DBO_SQLite extends DBO * @param string $tableName Name of database table to inspect * @return array Fields in table. Keys are name and type */ - function fields($tableName) - { + function fields($tableName) + { $fields = false; $cols = sqlite_fetch_column_types($tableName, $this->_conn); @@ -143,7 +143,7 @@ class DBO_SQLite extends DBO } return $fields; - } + } /** * Returns a quoted and escaped string of $data for use in an SQL statement. @@ -151,30 +151,30 @@ class DBO_SQLite extends DBO * @param string $data String to be prepared for use in an SQL statement * @return string Quoted and escaped */ - function prepareValue($data) - { + function prepareValue($data) + { return "'" . sqlite_escape_string($data) . "'"; - } + } /** * Returns a formatted error message from previous database operation. * * @return string Error message */ - function lastError() - { + function lastError() + { return sqlite_last_error($this->_conn)? sqlite_last_error($this->_conn).': '.sqlite_error_string(sqlite_last_error($this->_conn)): null; - } + } /** * Returns number of affected rows in previous database operation. If no previous operation exists, this returns false. * * @return int Number of affected rows */ - function lastAffected() - { + function lastAffected() + { return $this->_result? sqlite_changes($this->_conn): false; - } + } /** * Returns number of rows in previous resultset. If no previous resultset exists, @@ -182,20 +182,20 @@ class DBO_SQLite extends DBO * * @return int Number of rows in resultset */ - function lastNumRows() - { + function lastNumRows() + { return $this->_result? sqlite_num_rows($this->_result): false; - } + } /** * Returns the ID generated from the previous INSERT operation. * * @return int */ - function lastInsertId() - { + function lastInsertId() + { return sqlite_last_insert_rowid($this->_conn); - } + } /** * Returns a limit statement in the correct format for the particular database. @@ -204,9 +204,9 @@ class DBO_SQLite extends DBO * @param int $offset Offset from which to start results * @return string SQL limit/offset statement */ - function selectLimit($limit, $offset=null) - { + function selectLimit($limit, $offset=null) + { return " LIMIT {$limit}".($offset? ", {$offset}": null); - } + } } ?> \ No newline at end of file diff --git a/cake/libs/model/model_php4.php b/cake/libs/model/model_php4.php index 0ce5fef0a..d1961818b 100644 --- a/cake/libs/model/model_php4.php +++ b/cake/libs/model/model_php4.php @@ -57,7 +57,7 @@ class Model extends Object * @var string * @access public */ - var $useDbConfig = 'default'; + var $useDbConfig = 'default'; /** * The DataSource connection object that this Model uses @@ -65,7 +65,7 @@ class Model extends Object * @var unknown_type * @access public */ - var $db = null; + var $db = null; /** * Enter description here... Still used? @@ -74,7 +74,7 @@ class Model extends Object * @access public * @todo Is this still used? -OJ 22 nov 2006 */ - var $parent = false; + var $parent = false; /** * Custom database table name. @@ -82,7 +82,7 @@ class Model extends Object * @var string * @access public */ - var $useTable = null; + var $useTable = null; /** * Custom display field name. Display fields are used by Scaffold, in SELECT boxes' OPTION elements. @@ -90,7 +90,7 @@ class Model extends Object * @var string * @access public */ - var $displayField = null; + var $displayField = null; /** *Value of the primary key ID of the record that this model is currently pointing to @@ -98,7 +98,7 @@ class Model extends Object * @var unknown_type * @access public */ - var $id = false; + var $id = false; /** * Container for the data that this model gets from persistent storage (the database). @@ -106,7 +106,7 @@ class Model extends Object * @var array * @access public */ - var $data = array(); + var $data = array(); /** * Table name for this Model. @@ -114,7 +114,7 @@ class Model extends Object * @var string * @access public */ - var $table = false; + var $table = false; /** * The name of the ID field for this Model. @@ -122,7 +122,7 @@ class Model extends Object * @var string * @access public */ - var $primaryKey = null; + var $primaryKey = null; /** * Table metadata @@ -130,7 +130,7 @@ class Model extends Object * @var array * @access private */ - var $_tableInfo = null; + var $_tableInfo = null; /** * List of validation rules. Append entries for validation as ('field_name' => '/^perl_compat_regexp$/') @@ -138,118 +138,118 @@ class Model extends Object * * @var array */ - var $validate = array(); + var $validate = array(); /** * Errors in validation * @var array */ - var $validationErrors = null; + var $validationErrors = null; /** * Database table prefix for tables in model. * * @var string */ - var $tablePrefix = null; + var $tablePrefix = null; /** * Name of the model. * * @var string */ - var $name = null; + var $name = null; /** * Name of the current model. * * @var string */ - var $currentModel = null; + var $currentModel = null; /** * List of table names included in the Model description. Used for associations. * * @var array */ - var $tableToModel = array(); + var $tableToModel = array(); /** * List of Model names by used tables. Used for associations. * * @var array */ - var $modelToTable = array(); + var $modelToTable = array(); /** * List of Foreign Key names to used tables. Used for associations. * * @var array */ - var $keyToTable = array(); + var $keyToTable = array(); /** * Alias table names for model, for use in SQL JOIN statements. * * @var array */ - var $alias = array(); + var $alias = array(); /** * Whether or not transactions for this model should be logged * * @var boolean */ - var $logTransactions = false; + var $logTransactions = false; /** * Whether or not to enable transactions for this model (i.e. BEGIN/COMMIT/ROLLBACK) * * @var boolean */ - var $transactional = false; + var $transactional = false; /** * belongsTo association * * @var array */ - var $belongsTo = array(); + var $belongsTo = array(); /** * hasOne association * * @var array */ - var $hasOne = array(); + var $hasOne = array(); /** * hasMany association * * @var array */ - var $hasMany = array(); + var $hasMany = array(); /** * hasAndBelongsToMany association * * @var array */ - var $hasAndBelongsToMany = array(); + var $hasAndBelongsToMany = array(); /** * Depth of recursive association * * @var int */ - var $recursive = 1; + var $recursive = 1; /** * Default association keys * * @var array */ - var $__associationKeys = array('belongsTo' => array('className', 'conditions', 'order', 'foreignKey', 'counterCache'), + var $__associationKeys = array('belongsTo' => array('className', 'conditions', 'order', 'foreignKey', 'counterCache'), 'hasOne' => array('className', 'conditions', 'order', 'foreignKey', 'dependent'), 'hasMany' => array('className', 'conditions', 'order', 'foreignKey', 'fields', 'dependent', 'exclusive', 'finder_query', 'counter_query'), 'hasAndBelongsToMany' => array('className', 'joinTable', 'fields', 'foreignKey', 'associationForeignKey', 'conditions', 'order', 'uniq', 'finderQuery', 'deleteQuery', 'insertQuery') @@ -260,7 +260,7 @@ class Model extends Object * * @var array */ - var $__associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); + var $__associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); /** * The last inserted ID of the data that this model created @@ -268,7 +268,7 @@ class Model extends Object * @var int * @access private */ - var $__insertID = null; + var $__insertID = null; /** * The number of records returned by the last query @@ -276,7 +276,7 @@ class Model extends Object * @access private * @var int */ - var $__numRows = null; + var $__numRows = null; /** * The number of records affected by the last query @@ -284,7 +284,7 @@ class Model extends Object * @access private * @var int */ - var $__affectedRows = null; + var $__affectedRows = null; /** * Constructor. Binds the Model's database table to the object. @@ -330,37 +330,37 @@ class Model extends Object } } - if (in_array('settableprefix', get_class_methods($this))) - { - $this->setTablePrefix(); - } + if (in_array('settableprefix', get_class_methods($this))) + { + $this->setTablePrefix(); + } - if ($this->tablePrefix) - { - $this->setSource($this->tablePrefix.$tableName); - } - else - { - $this->setSource($tableName); - } + if ($this->tablePrefix) + { + $this->setSource($this->tablePrefix.$tableName); + } + else + { + $this->setSource($tableName); + } - $this->__createLinks(); + $this->__createLinks(); - if ($this->displayField == null) - { - if ($this->hasField('title')) - { - $this->displayField = 'title'; - } - if ($this->hasField('name')) - { - $this->displayField = 'name'; - } - if ($this->displayField == null) - { - $this->displayField = $this->primaryKey; - } - } + if ($this->displayField == null) + { + if ($this->hasField('title')) + { + $this->displayField = 'title'; + } + if ($this->hasField('name')) + { + $this->displayField = 'name'; + } + if ($this->displayField == null) + { + $this->displayField = $this->primaryKey; + } + } } } @@ -378,8 +378,8 @@ class Model extends Object */ function __call($method, $params, &$return) { - $return = $this->db->query($method, $params, $this); - return true; + $return = $this->db->query($method, $params, $this); + return true; } /** @@ -389,7 +389,7 @@ class Model extends Object */ function __createLinks() { - // Convert all string-based associations to array based +// Convert all string-based associations to array based foreach($this->__associations as $type) { if(!is_array($this->{$type})) @@ -514,23 +514,23 @@ class Model extends Object { if($this->db->isInterfaceSupported('listSources')) { - if (!in_array(strtolower($tableName), $this->db->listSources())) - { - return $this->cakeError('missingTable',array(array('className' => $this->name, + if (!in_array(strtolower($tableName), $this->db->listSources())) + { + return $this->cakeError('missingTable',array(array('className' => $this->name, 'table' => $tableName))); - } - else - { - $this->table = $tableName; - $this->tableToModel[$this->table] = $this->name; - $this->loadInfo(); - } + } + else + { + $this->table = $tableName; + $this->tableToModel[$this->table] = $this->name; + $this->loadInfo(); + } } else { - $this->table = $tableName; - $this->tableToModel[$this->table] = $this->name; - $this->loadInfo(); + $this->table = $tableName; + $this->tableToModel[$this->table] = $this->name; + $this->loadInfo(); } } @@ -578,31 +578,31 @@ class Model extends Object * * @return array Array of table metadata */ - function loadInfo () - { + function loadInfo () + { if (!is_object($this->_tableInfo) && $this->db->isInterfaceSupported('describe')) { $this->_tableInfo = new NeatArray($this->db->describe($this)); } return $this->_tableInfo; - } + } /** * Returns an associative array of field names and column types. * * @return array */ - function getColumnTypes () - { - $columns = $this->loadInfo(); - $columns = $columns->value; + function getColumnTypes () + { + $columns = $this->loadInfo(); + $columns = $columns->value; - $cols = array(); - foreach($columns as $col) { - $cols[$col['name']] = $col['type']; - } - return $cols; - } + $cols = array(); + foreach($columns as $col) { + $cols[$col['name']] = $col['type']; + } + return $cols; + } /** * Returns true if this Model has given field in its database table. @@ -612,15 +612,15 @@ class Model extends Object */ function hasField ($name) { - if (empty($this->_tableInfo)) - { + if (empty($this->_tableInfo)) + { $this->loadInfo(); - } - if($this->_tableInfo != null) - { + } + if($this->_tableInfo != null) + { return $this->_tableInfo->findIn('name', $name); - } - return null; + } + return null; } /** @@ -628,31 +628,31 @@ class Model extends Object * * @return boolean True */ - function create () - { + function create () + { $this->id = false; unset($this->data); $this->data = array(); return true; - } + } /** * Deprecated * */ - function setId ($id) - { + function setId ($id) + { $this->id = $id; - } + } /** * Deprecated. Use query() instead. * */ - function findBySql ($sql) - { + function findBySql ($sql) + { return $this->query($sql); - } + } /** @@ -964,10 +964,10 @@ class Model extends Object { if ($this->id && $this->db->delete($this)) { - //$this->__deleteJoins($id); +//$this->__deleteJoins($id); if ($cascade) { - //$this->__deleteMulti($id); +//$this->__deleteMulti($id); } $this->afterDelete(); $this->id = false; @@ -1046,7 +1046,7 @@ class Model extends Object /** * Return a single row as a resultset array. - * By using the $recursive parameter, the call can access further "levels of association" than + * By using the $recursive parameter, the call can access further "levels of association" than * the ones this model is directly associated to. * * @param array $conditions SQL conditions array @@ -1113,25 +1113,25 @@ class Model extends Object * @param string $data Query data * @return array */ - function execute ($data) - { - $data = $this->db->fetchAll($data); - foreach ($data as $key => $value) - { - foreach ($this->tableToModel as $key1 => $value1) - { - if (isset($data[$key][$key1])) - { - $newData[$key][$value1] = $data[$key][$key1]; - } - } - } - if (!empty($newData)) - { - return $newData; - } - return $data; - } + function execute ($data) + { + $data = $this->db->fetchAll($data); + foreach ($data as $key => $value) + { + foreach ($this->tableToModel as $key1 => $value1) + { + if (isset($data[$key][$key1])) + { + $newData[$key][$value1] = $data[$key][$key1]; + } + } + } + if (!empty($newData)) + { + return $newData; + } + return $data; + } /** * Returns number of rows matching given SQL condition. @@ -1141,15 +1141,15 @@ class Model extends Object * @return int Number of matching rows * @see Model::findAll */ - function findCount ($conditions = null, $recursive = 0) - { + function findCount ($conditions = null, $recursive = 0) + { list($data) = $this->findAll($conditions, 'COUNT(*) AS count', null, null, 1, $recursive); if (isset($data[0]['count'])) { return $data[0]['count']; } return false; - } + } /** * Special findAll variation for tables joined to themselves. @@ -1161,10 +1161,10 @@ class Model extends Object * @return array * @todo Perhaps create a Component with this logic */ - function findAllThreaded ($conditions=null, $fields=null, $sort=null) - { + function findAllThreaded ($conditions=null, $fields=null, $sort=null) + { return $this->__doThread(Model::findAll($conditions, $fields, $sort), null); - } + } /** * Private, recursive helper method for findAllThreaded. @@ -1175,28 +1175,28 @@ class Model extends Object * @access private * @see findAllThreaded */ - function __doThread ($data, $root) - { - $out = array(); - $sizeOf = sizeof($data); - for ($ii=0; $ii < $sizeOf; $ii++) - { - if ($data[$ii][$this->name]['parent_id'] == $root) - { - $tmp = $data[$ii]; - if (isset($data[$ii][$this->name][$this->primaryKey])) - { - $tmp['children'] = $this->__doThread($data, $data[$ii][$this->name][$this->primaryKey]); - } - else - { - $tmp['children'] = null; - } - $out[] = $tmp; - } - } - return $out; - } + function __doThread ($data, $root) + { + $out = array(); + $sizeOf = sizeof($data); + for ($ii=0; $ii < $sizeOf; $ii++) + { + if ($data[$ii][$this->name]['parent_id'] == $root) + { + $tmp = $data[$ii]; + if (isset($data[$ii][$this->name][$this->primaryKey])) + { + $tmp['children'] = $this->__doThread($data, $data[$ii][$this->name][$this->primaryKey]); + } + else + { + $tmp['children'] = null; + } + $out[] = $tmp; + } + } + return $out; + } /** * Returns an array with keys "prev" and "next" that holds the id's of neighbouring data, @@ -1233,11 +1233,11 @@ class Model extends Object * @param string $sql SQL statement * @return array Resultset */ - function query () - { + function query () + { $params = func_get_args(); return call_user_func_array(array(&$this->db, 'query'), $params); - } + } /** * Returns true if all fields pass validation, otherwise false. @@ -1245,15 +1245,15 @@ class Model extends Object * @param array $data POST data * @return boolean True if there are no errors */ - function validates ($data = null) - { + function validates ($data = null) + { if ($data == null) { $data = $this->data; } $errors = $this->invalidFields($data); return count($errors) == 0; - } + } /** * Returns an array of invalid fields. @@ -1261,8 +1261,8 @@ class Model extends Object * @param array $data * @return array Array of invalid fields */ - function invalidFields ($data=null) - { + function invalidFields ($data=null) + { if (!isset($this->validate) || is_array($this->validationErrors)) { if (!isset($this->validate)) @@ -1292,7 +1292,7 @@ class Model extends Object { foreach ($this->validate as $field_name => $validator) { - if (isset($data[$table][$field_name]) && !preg_match($validator, $data[$table][$field_name])) + if (isset($data[$table][$field_name]) && !preg_match($validator, $data[$table][$field_name])) { $errors[$field_name] = 1; } @@ -1300,7 +1300,7 @@ class Model extends Object $this->validationErrors = $errors; return $errors; } - } + } /** * Returns true if given field name is a foreign key in this Model. @@ -1310,16 +1310,16 @@ class Model extends Object */ function isForeignKey($field) { - $foreignKeys = array(); - if(count($this->belongsTo)) - { + $foreignKeys = array(); + if(count($this->belongsTo)) + { foreach ($this->belongsTo as $assoc => $data) { $foreignKeys[] = $data['foreignKey']; } - } + } - return (bool)(in_array($field, $foreignKeys)); + return (bool)(in_array($field, $foreignKeys)); } /** @@ -1425,7 +1425,7 @@ class Model extends Object */ function getNumRows () { - //return $this->__numRows; +//return $this->__numRows; return $this->db->lastNumRows(); } @@ -1436,7 +1436,7 @@ class Model extends Object */ function getAffectedRows () { - //return $this->__affectedRows; +//return $this->__affectedRows; return $this->db->lastAffected(); } diff --git a/cake/libs/model/model_php5.php b/cake/libs/model/model_php5.php index 767bb79c9..fe6a4b12a 100644 --- a/cake/libs/model/model_php5.php +++ b/cake/libs/model/model_php5.php @@ -57,7 +57,7 @@ class Model extends Object * @var string * @access public */ - var $useDbConfig = 'default'; + var $useDbConfig = 'default'; /** * The DataSource connection object that this Model uses @@ -65,7 +65,7 @@ class Model extends Object * @var unknown_type * @access public */ - var $db = null; + var $db = null; /** * Enter description here... Still used? @@ -74,7 +74,7 @@ class Model extends Object * @access public * @todo Is this still used? -OJ 22 nov 2006 */ - var $parent = false; + var $parent = false; /** * Custom database table name. @@ -82,7 +82,7 @@ class Model extends Object * @var string * @access public */ - var $useTable = null; + var $useTable = null; /** * Custom display field name. Display fields are used by Scaffold, in SELECT boxes' OPTION elements. @@ -90,7 +90,7 @@ class Model extends Object * @var string * @access public */ - var $displayField = null; + var $displayField = null; /** *Value of the primary key ID of the record that this model is currently pointing to @@ -98,7 +98,7 @@ class Model extends Object * @var unknown_type * @access public */ - var $id = false; + var $id = false; /** * Container for the data that this model gets from persistent storage (the database). @@ -106,7 +106,7 @@ class Model extends Object * @var array * @access public */ - var $data = array(); + var $data = array(); /** * Table name for this Model. @@ -114,7 +114,7 @@ class Model extends Object * @var string * @access public */ - var $table = false; + var $table = false; /** * The name of the ID field for this Model. @@ -122,7 +122,7 @@ class Model extends Object * @var string * @access public */ - var $primaryKey = null; + var $primaryKey = null; /** * Table metadata @@ -130,7 +130,7 @@ class Model extends Object * @var array * @access private */ - var $_tableInfo = null; + var $_tableInfo = null; /** * List of validation rules. Append entries for validation as ('field_name' => '/^perl_compat_regexp$/') @@ -138,118 +138,118 @@ class Model extends Object * * @var array */ - var $validate = array(); + var $validate = array(); /** * Errors in validation * @var array */ - var $validationErrors = null; + var $validationErrors = null; /** * Database table prefix for tables in model. * * @var string */ - var $tablePrefix = null; + var $tablePrefix = null; /** * Name of the model. * * @var string */ - var $name = null; + var $name = null; /** * Name of the current model. * * @var string */ - var $currentModel = null; + var $currentModel = null; /** * List of table names included in the Model description. Used for associations. * * @var array */ - var $tableToModel = array(); + var $tableToModel = array(); /** * List of Model names by used tables. Used for associations. * * @var array */ - var $modelToTable = array(); + var $modelToTable = array(); /** * List of Foreign Key names to used tables. Used for associations. * * @var array */ - var $keyToTable = array(); + var $keyToTable = array(); /** * Alias table names for model, for use in SQL JOIN statements. * * @var array */ - var $alias = array(); + var $alias = array(); /** * Whether or not transactions for this model should be logged * * @var boolean */ - var $logTransactions = false; + var $logTransactions = false; /** * Whether or not to enable transactions for this model (i.e. BEGIN/COMMIT/ROLLBACK) * * @var boolean */ - var $transactional = false; + var $transactional = false; /** * belongsTo association * * @var array */ - var $belongsTo = array(); + var $belongsTo = array(); /** * hasOne association * * @var array */ - var $hasOne = array(); + var $hasOne = array(); /** * hasMany association * * @var array */ - var $hasMany = array(); + var $hasMany = array(); /** * hasAndBelongsToMany association * * @var array */ - var $hasAndBelongsToMany = array(); + var $hasAndBelongsToMany = array(); /** * Depth of recursive association * * @var int */ - var $recursive = 1; + var $recursive = 1; /** * Default association keys * * @var array */ - var $__associationKeys = array('belongsTo' => array('className', 'conditions', 'order', 'foreignKey', 'counterCache'), + var $__associationKeys = array('belongsTo' => array('className', 'conditions', 'order', 'foreignKey', 'counterCache'), 'hasOne' => array('className', 'conditions', 'order', 'foreignKey', 'dependent'), 'hasMany' => array('className', 'conditions', 'order', 'foreignKey', 'fields', 'dependent', 'exclusive', 'finder_query', 'counter_query'), 'hasAndBelongsToMany' => array('className', 'joinTable', 'fields', 'foreignKey', 'associationForeignKey', 'conditions', 'order', 'uniq', 'finderQuery', 'deleteQuery', 'insertQuery') @@ -260,7 +260,7 @@ class Model extends Object * * @var array */ - var $__associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); + var $__associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); /** * The last inserted ID of the data that this model created @@ -268,7 +268,7 @@ class Model extends Object * @var int * @access private */ - var $__insertID = null; + var $__insertID = null; /** * The number of records returned by the last query @@ -276,7 +276,7 @@ class Model extends Object * @access private * @var int */ - var $__numRows = null; + var $__numRows = null; /** * The number of records affected by the last query @@ -284,7 +284,7 @@ class Model extends Object * @access private * @var int */ - var $__affectedRows = null; + var $__affectedRows = null; /** * Constructor. Binds the Model's database table to the object. @@ -330,37 +330,37 @@ class Model extends Object } } - if (in_array('settableprefix', get_class_methods($this))) - { - $this->setTablePrefix(); - } + if (in_array('settableprefix', get_class_methods($this))) + { + $this->setTablePrefix(); + } - if ($this->tablePrefix) - { - $this->setSource($this->tablePrefix.$tableName); - } - else - { - $this->setSource($tableName); - } + if ($this->tablePrefix) + { + $this->setSource($this->tablePrefix.$tableName); + } + else + { + $this->setSource($tableName); + } - $this->__createLinks(); + $this->__createLinks(); - if ($this->displayField == null) - { - if ($this->hasField('title')) - { - $this->displayField = 'title'; - } - if ($this->hasField('name')) - { - $this->displayField = 'name'; - } - if ($this->displayField == null) - { - $this->displayField = $this->primaryKey; - } - } + if ($this->displayField == null) + { + if ($this->hasField('title')) + { + $this->displayField = 'title'; + } + if ($this->hasField('name')) + { + $this->displayField = 'name'; + } + if ($this->displayField == null) + { + $this->displayField = $this->primaryKey; + } + } } } @@ -375,7 +375,7 @@ class Model extends Object */ function __call($method, $params) { - return $this->db->query($method, $params, $this); + return $this->db->query($method, $params, $this); } /** @@ -385,7 +385,7 @@ class Model extends Object */ function __createLinks() { - // Convert all string-based associations to array based +// Convert all string-based associations to array based foreach($this->__associations as $type) { if(!is_array($this->{$type})) @@ -510,23 +510,23 @@ class Model extends Object { if($this->db->isInterfaceSupported('listSources')) { - if (!in_array(strtolower($tableName), $this->db->listSources())) - { - return $this->cakeError('missingTable',array(array('className' => $this->name, + if (!in_array(strtolower($tableName), $this->db->listSources())) + { + return $this->cakeError('missingTable',array(array('className' => $this->name, 'table' => $tableName))); - } - else - { - $this->table = $tableName; - $this->tableToModel[$this->table] = $this->name; - $this->loadInfo(); - } + } + else + { + $this->table = $tableName; + $this->tableToModel[$this->table] = $this->name; + $this->loadInfo(); + } } else { - $this->table = $tableName; - $this->tableToModel[$this->table] = $this->name; - $this->loadInfo(); + $this->table = $tableName; + $this->tableToModel[$this->table] = $this->name; + $this->loadInfo(); } } @@ -574,31 +574,31 @@ class Model extends Object * * @return array Array of table metadata */ - function loadInfo () - { + function loadInfo () + { if (!is_object($this->_tableInfo) && $this->db->isInterfaceSupported('describe')) { $this->_tableInfo = new NeatArray($this->db->describe($this)); } return $this->_tableInfo; - } + } /** * Returns an associative array of field names and column types. * * @return array */ - function getColumnTypes () - { - $columns = $this->loadInfo(); - $columns = $columns->value; + function getColumnTypes () + { + $columns = $this->loadInfo(); + $columns = $columns->value; - $cols = array(); - foreach($columns as $col) { - $cols[$col['name']] = $col['type']; - } - return $cols; - } + $cols = array(); + foreach($columns as $col) { + $cols[$col['name']] = $col['type']; + } + return $cols; + } /** * Returns true if this Model has given field in its database table. @@ -608,15 +608,15 @@ class Model extends Object */ function hasField ($name) { - if (empty($this->_tableInfo)) - { + if (empty($this->_tableInfo)) + { $this->loadInfo(); - } - if($this->_tableInfo != null) - { + } + if($this->_tableInfo != null) + { return $this->_tableInfo->findIn('name', $name); - } - return null; + } + return null; } /** @@ -624,31 +624,31 @@ class Model extends Object * * @return boolean True */ - function create () - { + function create () + { $this->id = false; unset($this->data); $this->data = array(); return true; - } + } /** * Deprecated * */ - function setId ($id) - { + function setId ($id) + { $this->id = $id; - } + } /** * Deprecated. Use query() instead. * */ - function findBySql ($sql) - { + function findBySql ($sql) + { return $this->query($sql); - } + } /** @@ -960,10 +960,10 @@ class Model extends Object { if ($this->id && $this->db->delete($this)) { - //$this->__deleteJoins($id); +//$this->__deleteJoins($id); if ($cascade) { - //$this->__deleteMulti($id); +//$this->__deleteMulti($id); } $this->afterDelete(); $this->id = false; @@ -1042,7 +1042,7 @@ class Model extends Object /** * Return a single row as a resultset array. - * By using the $recursive parameter, the call can access further "levels of association" than + * By using the $recursive parameter, the call can access further "levels of association" than * the ones this model is directly associated to. * * @param array $conditions SQL conditions array @@ -1109,25 +1109,25 @@ class Model extends Object * @param string $data Query data * @return array */ - function execute ($data) - { - $data = $this->db->fetchAll($data); - foreach ($data as $key => $value) - { - foreach ($this->tableToModel as $key1 => $value1) - { - if (isset($data[$key][$key1])) - { - $newData[$key][$value1] = $data[$key][$key1]; - } - } - } - if (!empty($newData)) - { - return $newData; - } - return $data; - } + function execute ($data) + { + $data = $this->db->fetchAll($data); + foreach ($data as $key => $value) + { + foreach ($this->tableToModel as $key1 => $value1) + { + if (isset($data[$key][$key1])) + { + $newData[$key][$value1] = $data[$key][$key1]; + } + } + } + if (!empty($newData)) + { + return $newData; + } + return $data; + } /** * Returns number of rows matching given SQL condition. @@ -1137,15 +1137,15 @@ class Model extends Object * @return int Number of matching rows * @see Model::findAll */ - function findCount ($conditions = null, $recursive = 0) - { + function findCount ($conditions = null, $recursive = 0) + { list($data) = $this->findAll($conditions, 'COUNT(*) AS count', null, null, 1, $recursive); if (isset($data[0]['count'])) { return $data[0]['count']; } return false; - } + } /** * Special findAll variation for tables joined to themselves. @@ -1157,10 +1157,10 @@ class Model extends Object * @return array * @todo Perhaps create a Component with this logic */ - function findAllThreaded ($conditions=null, $fields=null, $sort=null) - { + function findAllThreaded ($conditions=null, $fields=null, $sort=null) + { return $this->__doThread(Model::findAll($conditions, $fields, $sort), null); - } + } /** * Private, recursive helper method for findAllThreaded. @@ -1171,28 +1171,28 @@ class Model extends Object * @access private * @see findAllThreaded */ - function __doThread ($data, $root) - { - $out = array(); - $sizeOf = sizeof($data); - for ($ii=0; $ii < $sizeOf; $ii++) - { - if ($data[$ii][$this->name]['parent_id'] == $root) - { - $tmp = $data[$ii]; - if (isset($data[$ii][$this->name][$this->primaryKey])) - { - $tmp['children'] = $this->__doThread($data, $data[$ii][$this->name][$this->primaryKey]); - } - else - { - $tmp['children'] = null; - } - $out[] = $tmp; - } - } - return $out; - } + function __doThread ($data, $root) + { + $out = array(); + $sizeOf = sizeof($data); + for ($ii=0; $ii < $sizeOf; $ii++) + { + if ($data[$ii][$this->name]['parent_id'] == $root) + { + $tmp = $data[$ii]; + if (isset($data[$ii][$this->name][$this->primaryKey])) + { + $tmp['children'] = $this->__doThread($data, $data[$ii][$this->name][$this->primaryKey]); + } + else + { + $tmp['children'] = null; + } + $out[] = $tmp; + } + } + return $out; + } /** * Returns an array with keys "prev" and "next" that holds the id's of neighbouring data, @@ -1229,11 +1229,11 @@ class Model extends Object * @param string $sql SQL statement * @return array Resultset */ - function query () - { + function query () + { $params = func_get_args(); return call_user_func_array(array(&$this->db, 'query'), $params); - } + } /** * Returns true if all fields pass validation, otherwise false. @@ -1241,15 +1241,15 @@ class Model extends Object * @param array $data POST data * @return boolean True if there are no errors */ - function validates ($data = null) - { + function validates ($data = null) + { if ($data == null) { $data = $this->data; } $errors = $this->invalidFields($data); return count($errors) == 0; - } + } /** * Returns an array of invalid fields. @@ -1257,8 +1257,8 @@ class Model extends Object * @param array $data * @return array Array of invalid fields */ - function invalidFields ($data=null) - { + function invalidFields ($data=null) + { if (!isset($this->validate) || is_array($this->validationErrors)) { if (!isset($this->validate)) @@ -1288,7 +1288,7 @@ class Model extends Object { foreach ($this->validate as $field_name => $validator) { - if (isset($data[$table][$field_name]) && !preg_match($validator, $data[$table][$field_name])) + if (isset($data[$table][$field_name]) && !preg_match($validator, $data[$table][$field_name])) { $errors[$field_name] = 1; } @@ -1296,7 +1296,7 @@ class Model extends Object $this->validationErrors = $errors; return $errors; } - } + } /** * Returns true if given field name is a foreign key in this Model. @@ -1306,16 +1306,16 @@ class Model extends Object */ function isForeignKey($field) { - $foreignKeys = array(); - if(count($this->belongsTo)) - { + $foreignKeys = array(); + if(count($this->belongsTo)) + { foreach ($this->belongsTo as $assoc => $data) { $foreignKeys[] = $data['foreignKey']; } - } + } - return (bool)(in_array($field, $foreignKeys)); + return (bool)(in_array($field, $foreignKeys)); } /** @@ -1421,7 +1421,7 @@ class Model extends Object */ function getNumRows () { - //return $this->__numRows; +//return $this->__numRows; return $this->db->lastNumRows(); } @@ -1432,7 +1432,7 @@ class Model extends Object */ function getAffectedRows () { - //return $this->__affectedRows; +//return $this->__affectedRows; return $this->db->lastAffected(); } diff --git a/cake/libs/neat_array.php b/cake/libs/neat_array.php index f08b3fc51..a0e5eec86 100644 --- a/cake/libs/neat_array.php +++ b/cake/libs/neat_array.php @@ -45,7 +45,7 @@ class NeatArray * @var array * @access public */ - var $value; + var $value; /** * Constructor. Defaults to an empty array. @@ -54,10 +54,10 @@ class NeatArray * @access public * @uses NeatArray::value */ - function NeatArray ($value=array()) - { + function NeatArray ($value=array()) + { $this->value = $value; - } + } /** * Finds and returns records with $fieldName equal to $value from this NeatArray. @@ -68,8 +68,8 @@ class NeatArray * @access public * @uses NeatArray::value */ - function findIn ($fieldName, $value) - { + function findIn ($fieldName, $value) + { if (!is_array($this->value)) { return false; @@ -85,7 +85,7 @@ class NeatArray } return $out; - } + } /** * Checks if $this->value is an array, and removes all empty elements. @@ -93,8 +93,8 @@ class NeatArray * @access public * @uses NeatArray::value */ - function cleanup () - { + function cleanup () + { $out = is_array($this->value)? array(): null; foreach ($this->value as $k=>$v) { @@ -108,7 +108,7 @@ class NeatArray } } $this->value = $out; - } + } /** * Adds elements from given array to itself. @@ -118,10 +118,10 @@ class NeatArray * @access public * @uses NeatArray::value */ - function add ($value) - { + function add ($value) + { return ($this->value = $this->plus($value))? true: false; - } + } /** * Returns itself merged with given array. @@ -131,10 +131,10 @@ class NeatArray * @access public * @uses NeatArray::value */ - function plus ($value) - { + function plus ($value) + { return array_merge($this->value, (is_array($value)? $value: array($value))); - } + } /** * Counts repeating strings and returns an array of totals. @@ -144,8 +144,8 @@ class NeatArray * @access public * @uses NeatArray::value */ - function totals ($sortedBy=1,$reverse=true) - { + function totals ($sortedBy=1,$reverse=true) + { $out = array(); foreach ($this->value as $val) { @@ -163,7 +163,7 @@ class NeatArray } return $out; - } + } /** * Performs an array_filter() on the contents of this NeatArray. @@ -171,10 +171,10 @@ class NeatArray * @param string $with Name of callback function to perform on each element of this NeatArray. * @return array */ - function filter ($with) - { + function filter ($with) + { return $this->value = array_filter($this->value, $with); - } + } /** * Passes each of its values through a specified function or method. @@ -185,11 +185,11 @@ class NeatArray * @access public * @uses NeatArray::value */ - function walk ($with) - { + function walk ($with) + { array_walk($this->value, $with); return $this->value; - } + } /** * Apply $template to all elements of this NeatArray, and return the array itself. @@ -197,15 +197,15 @@ class NeatArray * @param string $template {@link http://php.net/sprintf sprintf()}-compatible string to be applied to all values of this NeatArray. * @return array */ - function sprintf($template) - { + function sprintf($template) + { for ($ii=0; $iivalue); $ii++) { $this->value[$ii] = sprintf($template, $this->value[$ii]); } return $this->value; - } + } /** * Extracts a value from all array items. @@ -214,8 +214,8 @@ class NeatArray * @access public * @uses NeatArray::value */ - function extract ($name) - { + function extract ($name) + { $out = array(); foreach ($this->value as $val) { @@ -223,27 +223,27 @@ class NeatArray $out[] = $val[$name]; } return $out; - } + } /** * Returns a list of unique elements. * * @return array */ - function unique () - { + function unique () + { return array_unique($this->value); - } + } /** * Removes duplicate elements from the value and returns it. * * @return array */ - function makeUnique () - { + function makeUnique () + { return $this->value = array_unique($this->value); - } + } /** * Joins an array with myself using a key (like a join between database tables). @@ -251,7 +251,7 @@ class NeatArray * Example: * * $alice = array('id'=>'1', 'name'=>'Alice'); - * $bob = array('id'=>'2', 'name'=>'Bob'); + * $bob = array('id'=>'2', 'name'=>'Bob'); * * $users = new NeatArray(array($alice, $bob)); * @@ -268,7 +268,7 @@ class NeatArray * $users->value == array * ( * array('id'=>'1', 'name'=>'Alice', 'born'=>'1980'), - * array('id'=>'2', 'name'=>'Bob', 'born'=>'1976') + * array('id'=>'2', 'name'=>'Bob', 'born'=>'1976') * ); * * @@ -277,8 +277,8 @@ class NeatArray * @param string $onHis Key to use on him. * @return array */ - function joinWith ($his, $onMine, $onHis=null) - { + function joinWith ($his, $onMine, $onHis=null) + { if (empty($onHis)) { $onHis = $onMine; @@ -301,7 +301,7 @@ class NeatArray } return $this->value = $out; - } + } /** * Enter description here... @@ -313,8 +313,8 @@ class NeatArray * @param string $childrenKey * @return array */ - function threaded ($root=null, $idKey='id', $parentIdKey='parent_id', $childrenKey='children') - { + function threaded ($root=null, $idKey='id', $parentIdKey='parent_id', $childrenKey='children') + { $out = array(); $sizeof = sizeof($this->value); for ($ii=0; $ii < $sizeof; $ii++) @@ -330,7 +330,7 @@ class NeatArray } return $out; - } + } /** @@ -341,8 +341,8 @@ class NeatArray * @return array * @link http://php.net/array_search#47116 */ - function multi_search($search_value, $the_array=null) - { + function multi_search($search_value, $the_array=null) + { if ( $the_array == null ) { $the_array = $this->value; @@ -355,14 +355,14 @@ class NeatArray $result = $this->multi_search($search_value, $value); if (is_array($result)) { - $return = $result; - array_unshift($return, $key); - return $return; + $return = $result; + array_unshift($return, $key); + return $return; } elseif ($result == true) { - $return[] = $key; - return $return; + $return[] = $key; + return $return; } } return false; @@ -375,7 +375,7 @@ class NeatArray } else return false; } - } + } } diff --git a/cake/libs/neat_string.php b/cake/libs/neat_string.php index c6a06d0c5..2c5517d52 100644 --- a/cake/libs/neat_string.php +++ b/cake/libs/neat_string.php @@ -40,7 +40,7 @@ */ class NeatString { - /** +/** * Returns an array with each of the non-empty characters in $string as an element. * * @param string $string @@ -51,7 +51,7 @@ class NeatString return preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY); } - /** +/** * Returns string with Cyrillic characters translated to Roman ones. * * @param string $string @@ -65,7 +65,7 @@ class NeatString return str_replace($pl, $ro, $string); } - /** +/** * Returns string as lowercase with whitespace removed. * * @param string $string @@ -77,7 +77,7 @@ class NeatString return strtolower(str_replace($whitespace, '', $string)); } - /** +/** * Returns a random password. * * @param integer $length Length of generated password diff --git a/cake/libs/object.php b/cake/libs/object.php index 20854e733..5b116fb8f 100644 --- a/cake/libs/object.php +++ b/cake/libs/object.php @@ -47,7 +47,7 @@ class Object * * @var object */ - var $_log = null; + var $_log = null; /** * A hack to support __construct() on PHP 4 @@ -57,24 +57,24 @@ class Object * * @return Object */ - function Object() - { - $args = func_get_args(); + function Object() + { + $args = func_get_args(); - if (method_exists($this, '__destruct')) - { - register_shutdown_function(array(&$this, '__destruct')); - } + if (method_exists($this, '__destruct')) + { + register_shutdown_function(array(&$this, '__destruct')); + } - call_user_func_array(array(&$this, '__construct'), $args); - } + call_user_func_array(array(&$this, '__construct'), $args); + } /** * Class constructor, overridden in descendant classes. */ - function __construct() - { - } + function __construct() + { + } /** * Object-to-string conversion. @@ -82,10 +82,10 @@ class Object * * @return string The name of this class */ - function toString() - { + function toString() + { return get_class($this); - } + } /** * Calls a controller's method from any location. @@ -102,7 +102,7 @@ class Object if(in_array('return', $extra)) { $extra['return'] = 0; - $extra['bare'] = 1; + $extra['bare'] = 1; ob_start(); $out = $dispatcher->dispatch($url, $extra); $out = ob_get_clean(); @@ -111,7 +111,7 @@ class Object else { $extra['return'] = 1; - $extra['bare'] = 1; + $extra['bare'] = 1; return $dispatcher->dispatch($url, $extra); } } @@ -127,12 +127,12 @@ class Object * @param string $msg Log message * @param int $type Error type constant. Defined in app/config/core.php. */ - function log ($msg, $type=LOG_ERROR) - { - if(!class_exists('CakeLog')) - { - uses('cake_log'); - } + function log ($msg, $type=LOG_ERROR) + { + if(!class_exists('CakeLog')) + { + uses('cake_log'); + } if (is_null($this->_log)) { $this->_log = new CakeLog(); @@ -145,7 +145,7 @@ class Object default: return $this->_log->write('error', $msg); } - } + } /** * Enter description here... @@ -154,14 +154,14 @@ class Object * @param unknown_type $messages * @return unknown */ - function cakeError($method, $messages) - { - if(!class_exists('ErrorHandler')) - { - uses('error'); - } - return new ErrorHandler($method, $messages); - } + function cakeError($method, $messages) + { + if(!class_exists('ErrorHandler')) + { + uses('error'); + } + return new ErrorHandler($method, $messages); + } } ?> \ No newline at end of file diff --git a/cake/libs/router.php b/cake/libs/router.php index 89b82f064..076b302d0 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -28,40 +28,40 @@ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ /** - * Included libraries. - * - */ + * Included libraries. + * + */ if(!class_exists('Object')) { uses('object'); } /** - * Parses the request URL into controller, action, and parameters. - * - * @package cake - * @subpackage cake.cake.libs - * @since CakePHP v 0.2.9 - * - */ + * Parses the request URL into controller, action, and parameters. + * + * @package cake + * @subpackage cake.cake.libs + * @since CakePHP v 0.2.9 + * + */ class Router extends Object { /** - * Array of routes - * - * @var array - */ - var $routes = array(); + * Array of routes + * + * @var array + */ + var $routes = array(); /** - * TODO: Better description. Returns this object's routes array. Returns false if there are no routes available. - * - * @param string $route An empty string, or a route string "/" - * @param array $default NULL or an array describing the default route - * @see routes - * @return array Array of routes - */ - function connect ($route, $default=null) - { + * TODO: Better description. Returns this object's routes array. Returns false if there are no routes available. + * + * @param string $route An empty string, or a route string "/" + * @param array $default NULL or an array describing the default route + * @see routes + * @return array Array of routes + */ + function connect ($route, $default=null) + { $parsed = $names = array (); $r = null; @@ -103,19 +103,19 @@ class Router extends Object { $this->routes[] = array($route, $regexp, $names, $default); } return $this->routes; - } + } /** - * Parses given URL and returns an array of controllers, action and parameters - * taken from that URL. - * - * @param string $url URL to be parsed - * @return array - */ - function parse ($url) - { - // An URL should start with a '/', mod_rewrite doesn't respect that, but no-mod_rewrite version does. - // Here's the fix. + * Parses given URL and returns an array of controllers, action and parameters + * taken from that URL. + * + * @param string $url URL to be parsed + * @return array + */ + function parse ($url) + { +// An URL should start with a '/', mod_rewrite doesn't respect that, but no-mod_rewrite version does. +// Here's the fix. if ($url && ('/' != $url[0])) { $url = '/'.$url; @@ -167,20 +167,20 @@ class Router extends Object { if (preg_match($regexp, $url, $r)) { - // $this->log($url.' matched '.$regexp, 'note'); - // remove the first element, which is the url +// $this->log($url.' matched '.$regexp, 'note'); +// remove the first element, which is the url array_shift($r); - // hack, pre-fill the default route names +// hack, pre-fill the default route names foreach ($names as $name) - $out[$name] = null; + $out[$name] = null; $ii = 0; if (is_array($defaults)) { - foreach ($defaults as $name=>$value) - { + foreach ($defaults as $name=>$value) + { if (preg_match('#[a-zA-Z_\-]#i', $name)) { $out[$name] = $value; @@ -189,31 +189,31 @@ class Router extends Object { { $out['pass'][] = $value; } - } + } } foreach ($r as $found) { - // if $found is a named url element (i.e. ':action') - if (isset($names[$ii])) - { +// if $found is a named url element (i.e. ':action') + if (isset($names[$ii])) + { $out[$names[$ii]] = $found; - } - // unnamed elements go in as 'pass' - else - { + } +// unnamed elements go in as 'pass' + else + { $pass = new NeatArray(explode('/', $found)); $pass->cleanup(); $out['pass'] = $pass->value; - } - $ii++; + } + $ii++; } break; } } return $out; - } + } } ?> \ No newline at end of file diff --git a/cake/libs/sanitize.php b/cake/libs/sanitize.php index 999ce8168..ad7c52270 100644 --- a/cake/libs/sanitize.php +++ b/cake/libs/sanitize.php @@ -62,10 +62,10 @@ class Sanitize if(is_array($string)) { - foreach ($string as $key => $clean) - { + foreach ($string as $key => $clean) + { $cleaned[$key] = preg_replace( "/[^{$allow}a-zA-Z0-9]/", "", $clean); - } + } } else { @@ -80,38 +80,38 @@ class Sanitize * @param string $string * @return string */ - function sql($string) - { + function sql($string) + { if (!ini_get('magic_quotes_gpc')) { $string = addslashes($string); } return $string; - } + } /** - * Returns given string safe for display as HTML. Renders entities and converts newlines to
. + * Returns given string safe for display as HTML. Renders entities and converts newlines to
. * * @param string $string * @param boolean $remove If true, the string is stripped of all HTML tags * @return string */ - function html($string, $remove = false) - { + function html($string, $remove = false) + { if ($remove) { $string = strip_tags($string); } else { - $patterns = array("/\&/", "/%/", "//", '/"/', "/'/", "/\(/", "/\)/", "/\+/", "/-/", "/\n/"); - $replacements = array("&", "%", "<", ">", """, "'", "(", ")", "+", "-", "
"); + $patterns = array("/\&/", "/%/", "//", '/"/', "/'/", "/\(/", "/\)/", "/\+/", "/-/", "/\n/"); + $replacements = array("&", "%", "<", ">", """, "'", "(", ")", "+", "-", "
"); $string = preg_replace($patterns, $replacements, $string); } return $string; - } + } /** * Recursively sanitizes given array of data for safe input. @@ -119,10 +119,10 @@ class Sanitize * @param mixed $toClean * @return mixed */ - function cleanArray(&$toClean) - { + function cleanArray(&$toClean) + { return $this->cleanArrayR($toClean); - } + } /** * Private method used for recursion (see cleanArray()). @@ -131,19 +131,19 @@ class Sanitize * @return array * @see cleanArray */ - function cleanArrayR(&$toClean) - { + function cleanArrayR(&$toClean) + { if (is_array($toClean)) { while(list($k, $v) = each($toClean)) { if ( is_array($toClean[$k]) ) { - $this->cleanArray($toClean[$k]); + $this->cleanArray($toClean[$k]); } else { - $toClean[$k] = $this->cleanValue($v); + $toClean[$k] = $this->cleanValue($v); } } } @@ -151,29 +151,29 @@ class Sanitize { return null; } - } + } /** * Do we really need to sanitize array keys? If so, we can use this code... - function cleanKey($key) - { + function cleanKey($key) + { if ($key == "") { return ""; } - //URL decode and convert chars to HTML entities +//URL decode and convert chars to HTML entities $key = htmlspecialchars(urldecode($key)); - //Remove .. +//Remove .. $key = preg_replace( "/\.\./", "", $key ); - //Remove __FILE__, etc. +//Remove __FILE__, etc. $key = preg_replace( "/\_\_(.+?)\_\_/", "", $key ); - //Trim word chars, '.', '-', '_' +//Trim word chars, '.', '-', '_' $key = preg_replace( "/^([\w\.\-\_]+)$/", "$1", $key ); return $key; - } + } */ /** @@ -182,37 +182,37 @@ class Sanitize * @param string $val * @return string */ - function cleanValue($val) - { + function cleanValue($val) + { if ($val == "") { return ""; } - //Replace odd spaces with safe ones +//Replace odd spaces with safe ones $val = str_replace(" ", " ", $val); $val = str_replace(chr(0xCA), "", $val); - //Encode any HTML to entities (including \n -->
) +//Encode any HTML to entities (including \n -->
) $val = $this->html($val); - //Double-check special chars and remove carriage returns - //For increased SQL security +//Double-check special chars and remove carriage returns +//For increased SQL security $val = preg_replace( "/\\\$/" ,"$" ,$val); $val = preg_replace( "/\r/" ,"" ,$val); $val = str_replace ( "!" ,"!" ,$val); $val = str_replace ( "'" , "'" ,$val); - //Allow unicode (?) +//Allow unicode (?) $val = preg_replace("/&#([0-9]+);/s", "&#\\1;", $val ); - //Add slashes for SQL +//Add slashes for SQL $val = $this->sql($val); - //Swap user-inputted backslashes (?) +//Swap user-inputted backslashes (?) $val = preg_replace( "/\\\(?!&#|\?#)/", "\\", $val ); return $val; - } + } } ?> \ No newline at end of file diff --git a/cake/libs/security.php b/cake/libs/security.php index 6c50613fa..f12d8a5ee 100644 --- a/cake/libs/security.php +++ b/cake/libs/security.php @@ -116,7 +116,7 @@ class Security extends Object { if (!defined('CIPHER_SEED')) { - //This is temporary will change later +//This is temporary will change later define('CIPHER_SEED', 'mKEZGy8AB8FErX4t'); } srand(CIPHER_SEED); diff --git a/cake/libs/session.php b/cake/libs/session.php index 20c6d0516..907f35998 100644 --- a/cake/libs/session.php +++ b/cake/libs/session.php @@ -62,7 +62,7 @@ class CakeSession extends Object * * @var string */ - var $path = false; + var $path = false; /** * Error number of last occurred error * @@ -87,7 +87,7 @@ class CakeSession extends Object * * @var integer */ - var $time = false; + var $time = false; /** * Time when this session becomes invalid. * @@ -431,7 +431,7 @@ class CakeSession extends Object if($this->readSessionVar("Config")) { if($this->userAgent == $this->readSessionVar("Config.userAgent") - && $this->time <= $this->readSessionVar("Config.time")) + && $this->time <= $this->readSessionVar("Config.time")) { $this->writeSessionVar("Config.time", $this->sessionTime); $this->valid = true; diff --git a/cake/libs/validators.php b/cake/libs/validators.php index 20686e6d4..cc801b32f 100644 --- a/cake/libs/validators.php +++ b/cake/libs/validators.php @@ -29,23 +29,23 @@ */ /** - * Not empty. - */ + * Not empty. + */ define('VALID_NOT_EMPTY', '/.+/'); /** - * Numbers [0-9] only. - */ + * Numbers [0-9] only. + */ define('VALID_NUMBER', '/^[0-9]+$/'); /** - * A valid email address. - */ + * A valid email address. + */ define('VALID_EMAIL', '/\\A(?:^([a-z0-9][a-z0-9_\\-\\.\\+]*)@([a-z0-9][a-z0-9\\.\\-]{0,63}\\.(com|org|net|biz|info|name|net|pro|aero|coop|museum|[a-z]{2,4}))$)\\z/i'); /** - * A valid year (1000-2999). - */ + * A valid year (1000-2999). + */ define('VALID_YEAR', '/^[12][0-9]{3}$/'); ?> \ No newline at end of file diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 098f8244a..8cd11460e 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -40,16 +40,16 @@ */ class Helper extends Object { - /************************************************************************* - * Public variables - *************************************************************************/ +/************************************************************************* + * Public variables + *************************************************************************/ - /**#@+ - * @access public - */ +/**#@+ + * @access public + */ - /** +/** * Holds tag templates. * * @access public @@ -57,17 +57,17 @@ class Helper extends Object */ var $tags = array(); - /**#@-*/ +/**#@-*/ - /************************************************************************* - * Public methods - *************************************************************************/ +/************************************************************************* + * Public methods + *************************************************************************/ - /**#@+ - * @access public - */ +/**#@+ + * @access public + */ - /** +/** * Constructor. * * Parses tag templates into $this->tags. @@ -80,10 +80,10 @@ class Helper extends Object function loadConfig() { - return $this->readConfigFile($config = fileExistsInPath(CAKE.'config'.DS.'tags.ini.php')); + return $this->readConfigFile($config = fileExistsInPath(CAKE.'config'.DS.'tags.ini.php')); } - /** +/** * Decides whether to output or return a string. * * Based on AUTO_OUTPUT and $return's value, this method decides whether to @@ -92,7 +92,7 @@ class Helper extends Object * @param string $str String to be output or returned. * @param boolean $return Whether this method should return a value or * output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function output($str, $return = false) @@ -114,7 +114,7 @@ class Helper extends Object } } - /** +/** * Assigns values to tag templates. * * Finds a tag template by $keyName, and replaces $values's keys with @@ -148,9 +148,9 @@ class Helper extends Object { if ($firstChar == '[' && substr($dataLine, -1, 1) == ']') { - // [section block] we might use this later do not know for sure - // this could be used to add a key with the section block name - // but it adds another array level +// [section block] we might use this later do not know for sure +// this could be used to add a key with the section block name +// but it adds another array level } else { @@ -178,7 +178,7 @@ class Helper extends Object return $iniSetting; } - /**#@-*/ +/**#@-*/ } ?> \ No newline at end of file diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index caa5bdb75..b2b9328a9 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -43,58 +43,58 @@ class AjaxHelper extends Helper { /** - * Included helpers. - * - * @var array + * Included helpers. + * + * @var array */ var $helpers = array('Html', 'Javascript'); /** - * Names of Javascript callback functions. - * - * @var array + * Names of Javascript callback functions. + * + * @var array */ var $callbacks = array('uninitialized', 'loading', 'loaded', 'interactive', 'complete'); /** - * Names of AJAX options. - * - * @var array + * Names of AJAX options. + * + * @var array */ var $ajaxOptions = array('type', 'confirm', 'condition', 'before', 'after', 'fallback', 'update', 'loading', 'loaded', 'interactive', 'complete', 'with', 'url', 'method', 'position', 'form', 'parameters', 'evalScripts', 'asynchronous', 'onComplete', 'onUninitialized', 'onLoading', 'onLoaded', 'onInteractive'); /** - * Options for draggable. - * - * @var array + * Options for draggable. + * + * @var array */ var $dragOptions = array('handle', 'revert', 'constraint', 'change'); /** - * Options for droppable. - * - * @var array + * Options for droppable. + * + * @var array */ var $dropOptions = array('accept', 'containment', 'overlap', 'greedy', 'hoverclass', 'onHover', 'onDrop'); /** - * Options for sortable. - * - * @var array + * Options for sortable. + * + * @var array */ var $sortOptions = array('tag', 'only', 'overlap', 'constraint', 'containment', 'handle', 'hoverClass', 'ghosting', 'dropOnEmpty', 'onUpdate', 'onChange'); /** - * Options for slider. - * - * @var array + * Options for slider. + * + * @var array */ var $sliderOptions = array('axis', 'increment', 'maximum', 'minimum', 'alignX', 'alignY', 'sliderValue', 'disabled', 'handleImage', 'handleDisabled', 'values', 'onSlide', 'onChange'); /** - * Options for in-place editor. - * - * @var array + * Options for in-place editor. + * + * @var array */ var $editorOptions = array('okText', 'cancelText', 'savingText', 'formId', 'externalControl', 'rows', 'cols', 'size', 'highlightcolor', 'highlightendcolor', 'savingClassName', 'formClassName', 'loadTextURL', 'loadingText', 'callback', 'ajaxOptions'); @@ -122,20 +122,20 @@ class AjaxHelper extends Helper * * Example: * - * link (word, - * array("url" => "undo", "n" => word_counter), - * array("complete" => "undoRequestCompleted(request)")); + * link (word, + * array("url" => "undo", "n" => word_counter), + * array("complete" => "undoRequestCompleted(request)")); * * * The callbacks that may be specified are: * - * - loading:: Called when the remote document is being - * loaded with data by the browser. + * - loading:: Called when the remote document is being + * loaded with data by the browser. * - loaded:: Called when the browser has finished loading - * the remote document. - * - interactive:: Called when the user can interact with the - * remote document, even though it has not - * finished loading. + * the remote document. + * - interactive:: Called when the user can interact with the + * remote document, even though it has not + * finished loading. * - complete:: Called when the XMLHttpRequest is complete. * * If you for some reason or another need synchronous processing (that'll @@ -151,17 +151,17 @@ class AjaxHelper extends Helper * by this expression. Use this to * describe browser-side conditions when * request should not be initiated. - * - before:: Called before request is initiated. + * - before:: Called before request is initiated. * - after:: Called immediately after request was - * initiated and before loading. + * initiated and before loading. * * @param string $title Title of link * @param string $href Href string "/products/view/12" * @param array $options Options for JavaScript function - * @param string $confirm Confirmation message. Calls up a JavaScript confirm() message. + * @param string $confirm Confirmation message. Calls up a JavaScript confirm() message. * @param boolean $escapeTitle Escaping the title string to HTML entities * - * @return string HTML code for link to remote action + * @return string HTML code for link to remote action */ function link($title, $href = null, $options = array(), $confirm = null, $escapeTitle = true) { @@ -200,7 +200,7 @@ class AjaxHelper extends Helper function linkToRemote ($title, $options = array(), $html_options = array()) { - //trigger_error('Deprecated function: use AjaxHelper::link', E_USER_WARNING); +//trigger_error('Deprecated function: use AjaxHelper::link', E_USER_WARNING); $href = '#'; if (!empty($options['fallback']) && isset($options['fallback'])) { @@ -217,16 +217,16 @@ class AjaxHelper extends Helper } } /** - * Creates JavaScript function for remote AJAX call - * - * This function creates the javascript needed to make a remote call - * it is primarily used as a helper for linkToRemote. - * - * @see linkToRemote() for docs on options parameter. - * - * @param array $options options for javascript - * @return string html code for link to remote action - */ + * Creates JavaScript function for remote AJAX call + * + * This function creates the javascript needed to make a remote call + * it is primarily used as a helper for linkToRemote. + * + * @see linkToRemote() for docs on options parameter. + * + * @param array $options options for javascript + * @return string html code for link to remote action + */ function remoteFunction ($options = null) { $javascript_options = $this->__optionsForAjax($options); @@ -255,15 +255,15 @@ class AjaxHelper extends Helper } /** - * Periodically call remote url via AJAX. - * - * Periodically calls the specified url (options[url]) every options[frequency] seconds (default is 10). - * Usually used to update a specified div (options[update]) with the results of the remote call. - * The options for specifying the target with url and defining callbacks is the same as linkToRemote. - * - * @param array $options Callback options - * @return string Javascript code - */ + * Periodically call remote url via AJAX. + * + * Periodically calls the specified url (options[url]) every options[frequency] seconds (default is 10). + * Usually used to update a specified div (options[update]) with the results of the remote call. + * The options for specifying the target with url and defining callbacks is the same as linkToRemote. + * + * @param array $options Callback options + * @return string Javascript code + */ function remoteTimer ($options = null) { $frequency = (isset($options['frequency']))? $options['frequency'] : 10; @@ -272,18 +272,18 @@ class AjaxHelper extends Helper } /** - * Returns form tag that will submit using Ajax. - * - * Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular - * reloading POST arrangement. Even though it's using Javascript to serialize the form elements, the form submission - * will work just like a regular submission as viewed by the receiving side (all elements available in params). - * The options for specifying the target with :url and defining callbacks is the same as link_to_remote. - * - * @param array $params Form id - * @param array $type How form data is posted: 'get' or 'post' - * @param array $options Callback/HTML options - * @return string JavaScript/HTML code - */ + * Returns form tag that will submit using Ajax. + * + * Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular + * reloading POST arrangement. Even though it's using Javascript to serialize the form elements, the form submission + * will work just like a regular submission as viewed by the receiving side (all elements available in params). + * The options for specifying the target with :url and defining callbacks is the same as link_to_remote. + * + * @param array $params Form id + * @param array $type How form data is posted: 'get' or 'post' + * @param array $options Callback/HTML options + * @return string JavaScript/HTML code + */ function form($params = null, $type = 'post', $options = array()) { if (is_array($params)) @@ -326,15 +326,15 @@ class AjaxHelper extends Helper } /** - * Returns a button input tag that will submit using Ajax - * - * Returns a button input tag that will submit form using XMLHttpRequest in the background instead of regular - * reloading POST arrangement. options argument is the same as in form_remote_tag - * - * @param string $title Input button title - * @param array $options Callback options - * @return string Ajaxed input button - */ + * Returns a button input tag that will submit using Ajax + * + * Returns a button input tag that will submit form using XMLHttpRequest in the background instead of regular + * reloading POST arrangement. options argument is the same as in form_remote_tag + * + * @param string $title Input button title + * @param array $options Callback options + * @return string Ajaxed input button + */ function submit ($title = 'Submit', $options = array()) { $htmlOptions = $this->__getHtmlOptions($options); @@ -360,33 +360,33 @@ class AjaxHelper extends Helper } /** - * Observe field and call ajax on change. - * - * Observes the field with the DOM ID specified by field_id and makes - * an Ajax when its contents have changed. - * - * Required +options+ are: - * - frequency:: The frequency (in seconds) at which changes to - * this field will be detected. - * - url:: @see urlFor() -style options for the action to call - * when the field has changed. - * - * Additional options are: - * - update:: Specifies the DOM ID of the element whose - * innerHTML should be updated with the - * XMLHttpRequest response text. - * - with:: A Javascript expression specifying the - * parameters for the XMLHttpRequest. This defaults - * to Form.Element.serialize('$field_id'), which can be - * accessed from params['form']['field_id']. - * - * Additionally, you may specify any of the options documented in - * @see linkToRemote(). - * - * @param string $field_id DOM ID of field to observe - * @param array $options ajax options - * @return string ajax script - */ + * Observe field and call ajax on change. + * + * Observes the field with the DOM ID specified by field_id and makes + * an Ajax when its contents have changed. + * + * Required +options+ are: + * - frequency:: The frequency (in seconds) at which changes to + * this field will be detected. + * - url:: @see urlFor() -style options for the action to call + * when the field has changed. + * + * Additional options are: + * - update:: Specifies the DOM ID of the element whose + * innerHTML should be updated with the + * XMLHttpRequest response text. + * - with:: A Javascript expression specifying the + * parameters for the XMLHttpRequest. This defaults + * to Form.Element.serialize('$field_id'), which can be + * accessed from params['form']['field_id']. + * + * Additionally, you may specify any of the options documented in + * @see linkToRemote(). + * + * @param string $field_id DOM ID of field to observe + * @param array $options ajax options + * @return string ajax script + */ function observeField ($field_id, $options = array()) { if (!isset($options['with'])) @@ -397,17 +397,17 @@ class AjaxHelper extends Helper } /** - * Observe entire form and call ajax on change. - * - * Like @see observeField(), but operates on an entire form identified by the - * DOM ID form_id. options are the same as observe_field, except - * the default value of the with option evaluates to the - * serialized (request string) value of the form. - * - * @param string $field_id DOM ID of field to observe - * @param array $options ajax options - * @return string ajax script - */ + * Observe entire form and call ajax on change. + * + * Like @see observeField(), but operates on an entire form identified by the + * DOM ID form_id. options are the same as observe_field, except + * the default value of the with option evaluates to the + * serialized (request string) value of the form. + * + * @param string $field_id DOM ID of field to observe + * @param array $options ajax options + * @return string ajax script + */ function observeForm ($field_id, $options = array()) { if (!isset($options['with'])) @@ -418,18 +418,18 @@ class AjaxHelper extends Helper } /** - * Create a text field with Autocomplete. - * - * Creates an autocomplete field with the given ID and options. - * - * options['with'] defaults to "Form.Element.serialize('$field_id')", - * but can be any valid javascript expression defining the - * - * @param string $field_id DOM ID of field to observe - * @param string $url URL for the autocomplete action - * @param array $options Ajax options - * @return string Ajax script - */ + * Create a text field with Autocomplete. + * + * Creates an autocomplete field with the given ID and options. + * + * options['with'] defaults to "Form.Element.serialize('$field_id')", + * but can be any valid javascript expression defining the + * + * @param string $field_id DOM ID of field to observe + * @param string $url URL for the autocomplete action + * @param array $options Ajax options + * @return string Ajax script + */ function autoComplete ($field, $url = "", $options = array()) { if (!isset($options['id'])) @@ -468,10 +468,10 @@ class AjaxHelper extends Helper } /** - * Private helper method to return an array of options for draggable. - * - * @param array $options - * @return array + * Private helper method to return an array of options for draggable. + * + * @param array $options + * @return array */ function _optionsForDraggable ($options) { @@ -480,13 +480,13 @@ class AjaxHelper extends Helper } /** - * For a reference on the options for this function, check out - * http://wiki.script.aculo.us/scriptaculous/show/Droppables.add - * + * For a reference on the options for this function, check out + * http://wiki.script.aculo.us/scriptaculous/show/Droppables.add + * * @param unknown_type $id - * @param array $options - * @return array - */ + * @param array $options + * @return array + */ function drop($id, $options = array()) { $options = $this->_optionsForDroppable($options); @@ -520,13 +520,13 @@ class AjaxHelper extends Helper } /** - * Makes a slider control. - * - * @param string $id DOM ID of slider handle - * @param string $track_id DOM ID of slider track - * @param array $options Array of options to control the slider - * @link http://wiki.script.aculo.us/scriptaculous/show/Slider - */ + * Makes a slider control. + * + * @param string $id DOM ID of slider handle + * @param string $track_id DOM ID of slider track + * @param array $options Array of options to control the slider + * @link http://wiki.script.aculo.us/scriptaculous/show/Slider + */ function slider($id, $track_id, $options = array()) { $options = $this->_optionsToString($options, array('axis','handleImage','handleDisabled')); @@ -545,13 +545,13 @@ class AjaxHelper extends Helper } /** - * Makes an Ajax In Place editor control. - * - * @param string $id DOM ID of input element - * @param string $url Postback URL of saved data - * @param array $options Array of options to control the editor, including ajaxOptions (see link). - * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor - */ + * Makes an Ajax In Place editor control. + * + * @param string $id DOM ID of input element + * @param string $url Postback URL of saved data + * @param array $options Array of options to control the editor, including ajaxOptions (see link). + * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor + */ function editor($id, $url, $options = array()) { $url = $this->Html->url($url); @@ -574,12 +574,12 @@ class AjaxHelper extends Helper } /** - * Makes a list or group of floated objects sortable. - * - * @param string $id DOM ID of parent - * @param array $options Array of options to control sort.http://wiki.script.aculo.us/scriptaculous/show/Sortable.create - * @link http://wiki.script.aculo.us/scriptaculous/show/Sortable.create - */ + * Makes a list or group of floated objects sortable. + * + * @param string $id DOM ID of parent + * @param array $options Array of options to control sort.http://wiki.script.aculo.us/scriptaculous/show/Sortable.create + * @link http://wiki.script.aculo.us/scriptaculous/show/Sortable.create + */ function sortable($id, $options = array()) { if (!empty($options['url'])) @@ -604,9 +604,9 @@ class AjaxHelper extends Helper } /** - * Private helper function for Javascript. - * - */ + * Private helper function for Javascript. + * + */ function __optionsForAjax ($options = array()) { $js_options = $this->_buildCallbacks($options); @@ -690,12 +690,12 @@ class AjaxHelper extends Helper } /** - * Return JavaScript text for an observer... - * - * @param string $klass Name of JavaScript class - * @param string $name - * @param array $options Ajax options - * @return string Formatted JavaScript + * Return JavaScript text for an observer... + * + * @param string $klass Name of JavaScript class + * @param string $name + * @param array $options Ajax options + * @return string Formatted JavaScript */ function _buildObserver ($klass, $name, $options=null) { @@ -712,10 +712,10 @@ class AjaxHelper extends Helper } /** - * Enter description here... Return JavaScript text for all callbacks... - * - * @param array $options - * @return array + * Enter description here... Return JavaScript text for all callbacks... + * + * @param array $options + * @return array */ function _buildCallbacks($options) { @@ -744,10 +744,10 @@ class AjaxHelper extends Helper { foreach ($stringOpts as $option) { - if(isset($options[$option]) && !$options[$option][0] != "'") - { - $options[$option] = "'{$options[$option]}'"; - } + if(isset($options[$option]) && !$options[$option][0] != "'") + { + $options[$option] = "'{$options[$option]}'"; + } } return $options; } diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index d66fd0400..67d18ee88 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -63,7 +63,7 @@ class FormHelper extends Helper { var $helpers = array('Html'); - /** +/** * Constructor which takes an instance of the HtmlHelper class. * * @return void @@ -72,7 +72,7 @@ class FormHelper extends Helper { } - /** +/** * Returns a formatted error message for given FORM field, NULL if no errors. * * @param string $field This should be "Modelname/fieldname" @@ -92,7 +92,7 @@ class FormHelper extends Helper } } - /** +/** * Returns a formatted LABEL element for HTML FORMs. * * @param string $tagName This should be "Modelname/fieldname" @@ -104,10 +104,10 @@ class FormHelper extends Helper return sprintf( TAG_LABEL, strtolower(str_replace('/', '_',$tagName)), $text ); } - /** +/** * Returns a formatted DIV tag for HTML FORMs. * - * @param string $class CSS class name of the div element. + * @param string $class CSS class name of the div element. * @param string $text String content that will appear inside the div element. * @return string The formatted DIV element */ @@ -116,7 +116,7 @@ class FormHelper extends Helper return sprintf( TAG_DIV, $class, $text ); } - /** +/** * Returns a formatted P tag with class for HTML FORMs. * * @param string $class CSS class name of the p element. @@ -128,13 +128,13 @@ class FormHelper extends Helper return sprintf( TAG_P_CLASS, $class, $text ); } - /** +/** * Returns a formatted INPUT tag for HTML FORMs. * * @param string $tagName This should be "Modelname/fieldname" * @param string $prompt Text that will appear in the label field. * @param bool $required True if this field is a required field. - * @param string $errorMsg Text that will appear if an error has occurred. + * @param string $errorMsg Text that will appear if an error has occurred. * @param int $size Size attribute for INPUT element * @param array $htmlOptions HTML options array. * @return string The formatted INPUT element, with a label and wrapped in a div. @@ -152,11 +152,11 @@ class FormHelper extends Helper if( $required ) $divClass = "required"; - $strError = ""; // initialize the error to empty. + $strError = "";// initialize the error to empty. if( $this->isFieldError( $tagName ) ) { - // if it was an error that occured, then add the error message, and append " error" to the div tag. +// if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); $divClass = sprintf( "%s error", $divClass ); } @@ -166,7 +166,7 @@ class FormHelper extends Helper } - /** +/** * Returns a formatted CHECKBOX tag inside a DIV for HTML FORMs. * * @param string $tagName This should be "Modelname/fieldname" @@ -188,11 +188,11 @@ class FormHelper extends Helper if( $required ) $divClass = "required"; - $strError = ""; // initialize the error to empty. + $strError = "";// initialize the error to empty. if( $this->isFieldError( $tagName ) ) { - // if it was an error that occured, then add the error message, and append " error" to the div tag. +// if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); $divClass = sprintf( "%s error", $divClass ); } @@ -202,13 +202,13 @@ class FormHelper extends Helper } - /** +/** * Returns a formatted date option element for HTML FORMs. * * @param string $tagName This should be "Modelname/fieldname" * @param string $prompt Text that will appear in the label field. * @param bool $required True if this field is a required field. - * @param string $errorMsg Text that will appear if an error has occurred. + * @param string $errorMsg Text that will appear if an error has occurred. * @param int $size Not used. * @todo Remove the $size parameter from this method. * @param array $htmlOptions HTML options array @@ -225,11 +225,11 @@ class FormHelper extends Helper if( $required ) $divClass = "required"; - $strError = ""; // initialize the error to empty. + $strError = "";// initialize the error to empty. if( $this->isFieldError( $tagName ) ) { - // if it was an error that occured, then add the error message, and append " error" to the div tag. +// if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); $divClass = sprintf( "%s error", $divClass ); } @@ -240,7 +240,7 @@ class FormHelper extends Helper return $this->divTag("date", $requiredDiv); } - /** +/** * Returns a formatted datetime option element for HTML FORMs. * * @param string $tagName This should be "Modelname/fieldname" @@ -264,11 +264,11 @@ class FormHelper extends Helper if( $required ) $divClass = "required"; - $strError = ""; // initialize the error to empty. + $strError = "";// initialize the error to empty. if( $this->isFieldError( $tagName ) ) { - // if it was an error that occured, then add the error message, and append " error" to the div tag. +// if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); $divClass = sprintf( "%s error", $divClass ); } @@ -279,7 +279,7 @@ class FormHelper extends Helper return $this->divTag("date", $requiredDiv); } - /** +/** * Returns a formatted TEXTAREA inside a DIV for use with HTML forms. * * @param string $tagName This should be "Modelname/fieldname" @@ -305,11 +305,11 @@ class FormHelper extends Helper if( $required ) $divClass = "required"; - $strError = ""; // initialize the error to empty. + $strError = "";// initialize the error to empty. if( $this->isFieldError( $tagName ) ) { - // if it was an error that occured, then add the error message, and append " error" to the div tag. +// if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); $divClass = sprintf( "%s error", $divClass ); } @@ -319,7 +319,7 @@ class FormHelper extends Helper } - /** +/** * Returns a formatted SELECT tag for HTML FORMs. * * @param string $tagName This should be "Modelname/fieldname" @@ -343,11 +343,11 @@ class FormHelper extends Helper if( $required ) $divClass = "required"; - $strError = ""; // initialize the error to empty. + $strError = "";// initialize the error to empty. if( $this->isFieldError( $tagName ) ) { - // if it was an error that occured, then add the error message, and append " error" to the div tag. +// if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); $divClass = sprintf( "%s error", $divClass ); } @@ -357,7 +357,7 @@ class FormHelper extends Helper } - /** +/** * Returns a formatted submit widget for HTML FORMs. * * @param string $displayText Text that will appear on the widget @@ -369,7 +369,7 @@ class FormHelper extends Helper return $this->divTag( 'submit', $this->Html->submitTag( $displayText, $htmlOptions) ); } - /** +/** * Generates a form to go onto a HtmlHelper object. * * @param array $fields An array of form field definitions diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 53beddb48..13757c89b 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -37,69 +37,69 @@ */ class HtmlHelper extends Helper { - /************************************************************************* - * Public variables - *************************************************************************/ +/************************************************************************* + * Public variables + *************************************************************************/ - /**#@+ - * @access public - */ +/**#@+ + * @access public + */ - /** +/** * Base URL * * @var string */ - var $base = null; + var $base = null; - /** +/** * URL to current action. * * @var string */ - var $here = null; - /** + var $here = null; +/** * Parameter array. * * @var array */ var $params = array(); - /** +/** * Current action. * * @var string */ var $action = null; - /** +/** * Enter description here... * * @var array */ - var $data = null; - /** + var $data = null; +/** * Name of model this helper is attached to. * * @var string */ var $model = null; - /** +/** * Enter description here... * * @var string */ var $field = null; - /**#@-*/ +/**#@-*/ - /************************************************************************* - * Private variables - *************************************************************************/ +/************************************************************************* + * Private variables + *************************************************************************/ - /**#@+ - * @access private - */ +/**#@+ + * @access private + */ - /** +/** * Breadcrumbs. * * @var array @@ -109,7 +109,7 @@ class HtmlHelper extends Helper - /** +/** * Adds a link to the breadcrumbs array. * * @param string $name Text for link @@ -120,13 +120,13 @@ class HtmlHelper extends Helper $this->_crumbs[] = array($name, $link); } - /** +/** * Returns a charset META-tag. * * @param string $charset * @param boolean $return Wheter this method should return a value or * output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function charset($charset, $return = false) @@ -134,19 +134,19 @@ class HtmlHelper extends Helper return $this->output(sprintf($this->tags['charset'], $charset), $return); } - /** +/** * Finds URL for specified action. * * Returns an URL pointing to a combination of controller and action. Param * $url can be: - * + Empty - the method will find adress to actuall controller/action. - * + '/' - the method will find base URL of application. - * + A combination of controller/action - the method will find url for it. + * + Empty - the method will find adress to actuall controller/action. + * + '/' - the method will find base URL of application. + * + A combination of controller/action - the method will find url for it. * * @param string $url Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4" * @param boolean $return Wheter this method should return a value or * output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function url($url = null, $return = false) @@ -167,7 +167,7 @@ class HtmlHelper extends Helper return $this->output(preg_replace('/&([^a])/', '&\1', $output), $return); } - /** +/** * Creates an HTML link. * * If $url starts with "http://" this is treated as an external link. Else, @@ -178,17 +178,17 @@ class HtmlHelper extends Helper * * @param string $title The content of the A tag. * @param string $url Cake-relative URL, or external URL (starts with http://) - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param string $confirmMessage Confirmation message. * @param boolean $escapeTitle Whether or not the text in the $title variable should be HTML escaped. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function link($title, $url = null, $htmlAttributes = null, $confirmMessage = false, $escapeTitle = true, $return = false) { - // prepare title for html display +// prepare title for html display if( $escapeTitle ) { $title = htmlspecialchars($title, ENT_QUOTES); @@ -198,11 +198,11 @@ class HtmlHelper extends Helper if ($confirmMessage) { - // prepare for HTML display (fix everything except quotes) +// prepare for HTML display (fix everything except quotes) $confirmMessage = htmlspecialchars($confirmMessage, ENT_NOQUOTES); - // fix single quotes +// fix single quotes $confirmMessage = str_replace("'", "\'", $confirmMessage); - // fix double quotes +// fix double quotes $confirmMessage = str_replace('"', '"', $confirmMessage); $htmlAttributes['onclick'] = "return confirm('{$confirmMessage}');"; @@ -222,14 +222,14 @@ class HtmlHelper extends Helper return $this->output($output, $return); } - /** +/** * Creates a submit widget. * * @param string $caption Text on submit button - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function submit($caption = 'Submit', $htmlAttributes = null, $return = false) @@ -241,14 +241,14 @@ class HtmlHelper extends Helper - /** +/** * Creates a password input widget. * * @param string $fieldName Name of a field, like this "Modelname/fieldname" - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function password($fieldName, $htmlAttributes = null, $return = false) @@ -268,14 +268,14 @@ class HtmlHelper extends Helper - /** +/** * Creates a textarea widget. * * @param string $fieldName Name of a field, like this "Modelname/fieldname" - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function textarea($fieldName, $htmlAttributes = null, $return = false) @@ -304,15 +304,15 @@ class HtmlHelper extends Helper $this->_parseAttributes($htmlAttributes, null, ' '), $value), $return); } - /** +/** * Creates a checkbox widget. * * @param string $fieldName Name of a field, like this "Modelname/fieldname" * @param string $title - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function checkbox($fieldName, $title = null, $htmlAttributes = null, @@ -326,15 +326,15 @@ class HtmlHelper extends Helper $this->_parseAttributes($htmlAttributes, null, '', ' '), $title), $return); } - /** +/** * Creates a link element for CSS stylesheets. * - * @param string $path Path to CSS file + * @param string $path Path to CSS file * @param string $rel Rel attribute. Defaults to "stylesheet". - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function css($path, $rel = 'stylesheet', $htmlAttributes = null, $return = false) @@ -344,14 +344,14 @@ class HtmlHelper extends Helper $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return); } - /** +/** * Creates file input widget. * * @param string $fieldName Name of a field, like this "Modelname/fieldname" or just "thefile" - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function file($fieldName, $htmlAttributes = null, $return = false) @@ -360,13 +360,13 @@ class HtmlHelper extends Helper $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return); } - /** +/** * Returns the breadcrumb trail as a sequence of »-separated links. * * @param string $separator Text to separate crumbs. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. If $this->_crumbs is empty, return null. */ function getCrumbs($separator = '»', $return = false) @@ -388,14 +388,14 @@ class HtmlHelper extends Helper } } - /** +/** * Creates a hidden input field. * * @param string $fieldName Name of a field, like this "Modelname/fieldname" - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function hidden($fieldName, $htmlAttributes = null, $return = false) @@ -409,14 +409,14 @@ class HtmlHelper extends Helper } - /** +/** * Creates a formatted IMG element. * - * @param string $path Path to the image file, relative to the webroot/img/ directory. - * @param array $htmlAttributes Array of HTML attributes. + * @param string $path Path to the image file, relative to the webroot/img/ directory. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ @@ -433,14 +433,14 @@ class HtmlHelper extends Helper return $this->output(sprintf($this->tags['image'], $url, $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return); } - /** +/** * Creates a text input widget. * * @param string $fieldName Name of a field, like this "Modelname/fieldname" - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function input($fieldName, $htmlAttributes = null, $return = false) @@ -478,31 +478,30 @@ class HtmlHelper extends Helper $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return); } - /** +/** * Creates a set of radio widgets. * * @param string $fieldName Name of a field, like this "Modelname/fieldname" - * @param array $options Radio button options array - * @param array $inbetween String that separates the radio buttons. - * @param array $htmlAttributes Array of HTML attributes. + * @param array $options Radio button options array + * @param array $inbetween String that separates the radio buttons. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ - function radio($fieldName, $options, $inbetween = null, $htmlAttributes = null, - $return = false) + function radio($fieldName, $options, $inbetween = null, $htmlAttributes = array(), $return = false) { $this->setFormTag($fieldName); $value = isset($htmlAttributes['value'])? $htmlAttributes['value']: $this->tagValue($fieldName); $out = array(); - foreach ($options as $opt_value=>$opt_title) + foreach ($options as $optValue => $optTitle) { - $options_here = array('value' => $opt_value); - $opt_value==$value? $options_here['checked'] = 'checked': null; - $parsed_options = $this->parseHtmlOptions(array_merge($htmlAttributes, $options_here), null, '', ' '); - $individual_tag_name = "{$this->field}_{$opt_value}"; - $out[] = sprintf($this->tags['radio'], $this->model, $this->field, $individual_tag_name, $parsed_options, $opt_title); + $optionsHere = array('value' => $optValue); + $optValue==$value? $optionsHere['checked'] = 'checked': null; + $parsedOptions = $this->parseHtmlOptions(array_merge($htmlAttributes, $optionsHere), null, '', ' '); + $individualTagName = "{$this->field}_{$optValue}"; + $out[] = sprintf($this->tags['radio'], $this->model, $this->field, $individualTagName, $parsedOptions, $optTitle); } $out = join($inbetween, $out); @@ -510,34 +509,34 @@ class HtmlHelper extends Helper } - /** +/** * Returns a row of formatted and named TABLE headers. * * @param array $names Array of tablenames. - * @param array $tr_options HTML options for TR elements. - * @param array $th_options HTML options for TH elements. + * @param array $trOptions HTML options for TR elements. + * @param array $thOptions HTML options for TH elements. * @return string */ - function tableHeaders($names, $tr_options=null, $th_options=null) + function tableHeaders($names, $trOptions=null, $thOptions=null) { $out = array(); foreach ($names as $arg) { - $out[] = sprintf($this->tags['tableheader'], $this->parseHtmlOptions($th_options), $arg); + $out[] = sprintf($this->tags['tableheader'], $this->parseHtmlOptions($thOptions), $arg); } - return sprintf($this->tags['tablerow'], $this->parseHtmlOptions($tr_options), join(' ', $out)); + return sprintf($this->tags['tablerow'], $this->parseHtmlOptions($trOptions), join(' ', $out)); } - /** - * Returns a formatted string of table rows (TR's with TD's in them). - * - * @param array $data Array of table data - * @param array $odd_tr_options HTML options for odd TR elements - * @param array $even_tr_options HTML options for even TR elements - * @return string Formatted HTML - */ - function tableCells($data, $odd_tr_options=null, $even_tr_options=null) +/** + * Returns a formatted string of table rows (TR's with TD's in them). + * + * @param array $data Array of table data + * @param array $oddTrOptions HTML options for odd TR elements + * @param array $evenTrOptions HTML options for even TR elements + * @return string Formatted HTML + */ + function tableCells($data, $oddTrOptions=null, $evenTrOptions=null) { if (empty($data[0]) || !is_array($data[0])) { @@ -548,21 +547,21 @@ class HtmlHelper extends Helper foreach ($data as $line) { $count++; - $cells_out = array(); + $cellsOut = array(); foreach ($line as $cell) { - $cells_out[] = sprintf($this->tags['tablecell'], null, $cell); + $cellsOut[] = sprintf($this->tags['tablecell'], null, $cell); } - $options = $this->parseHtmlOptions($count%2? $odd_tr_options: $even_tr_options); - $out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cells_out)); + $options = $this->parseHtmlOptions($count%2? $oddTrOptions: $evenTrOptions); + $out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cellsOut)); } return join("\n", $out); } - /** +/** * Returns value of $fieldName. False if the tag does not exist. * * @param string $fieldName Fieldname as "Modelname/fieldname" string @@ -574,7 +573,7 @@ class HtmlHelper extends Helper return isset($this->params['data'][$this->model][$this->field])? htmlspecialchars($this->params['data'][$this->model][$this->field]): false; } - /** +/** * Returns false if given FORM field has no errors. Otherwise it returns the constant set in the array Model->validationErrors. * * @param string $model Model name as string @@ -586,7 +585,7 @@ class HtmlHelper extends Helper return empty($this->validationErrors[$model][$field])? 0: $this->validationErrors[$model][$field]; } - /** +/** * Returns number of errors in a submitted FORM. * * @return int Number of errors @@ -599,7 +598,7 @@ class HtmlHelper extends Helper return count($errors); } - /** +/** * Validates a FORM according to the rules set up in the Model. * * @return int Number of errors @@ -618,7 +617,7 @@ class HtmlHelper extends Helper return $this->validationErrors = (count($errors)? $errors: false); } - /** +/** * Returns a formatted error message for given FORM field, NULL if no errors. * * @param string $field A field name, like "Modelname/fieldname" @@ -640,7 +639,7 @@ class HtmlHelper extends Helper } } - /** +/** * Sets this helper's model and field properties to the slash-separated value-pair in $tagValue. * * @param string $tagValue A field name, like "Modelname/fieldname" @@ -650,37 +649,37 @@ class HtmlHelper extends Helper return list($this->model, $this->field) = explode("/", $tagValue); } - /**#@-*/ +/**#@-*/ - /************************************************************************* - * Private methods - *************************************************************************/ +/************************************************************************* + * Private methods + *************************************************************************/ - /**#@+ - * @access private - */ +/**#@+ + * @access private + */ - /** +/** * Returns a space-delimited string with items of the $options array. If a * key of $options array happens to be one of: - * + 'compact' - * + 'checked' - * + 'declare' - * + 'readonly' - * + 'disabled' - * + 'selected' - * + 'defer' - * + 'ismap' - * + 'nohref' - * + 'noshade' - * + 'nowrap' - * + 'multiple' - * + 'noresize' + * + 'compact' + * + 'checked' + * + 'declare' + * + 'readonly' + * + 'disabled' + * + 'selected' + * + 'defer' + * + 'ismap' + * + 'nohref' + * + 'noshade' + * + 'nowrap' + * + 'multiple' + * + 'noresize' * * And its value is one of: - * + 1 - * + true - * + 'true' + * + 1 + * + true + * + 'true' * * Then the value will be reset to be identical with key's name. * If the value is not one of these 3, the parameter is not output. @@ -744,22 +743,22 @@ class HtmlHelper extends Helper } } - /**#@-*/ +/**#@-*/ - /************************************************************************* - * Renamed methods - *************************************************************************/ +/************************************************************************* + * Renamed methods + *************************************************************************/ - /** +/** * @deprecated Name changed to 'textarea'. Version 0.9.2. * @see HtmlHelper::textarea() * @param string $tagName * @param integer $cols * @param integer $rows - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function areaTag($tagName, $cols = 60, $rows = 10, $htmlAttributes = null, $return = false) @@ -769,13 +768,13 @@ class HtmlHelper extends Helper return $this->textarea($tagName, $htmlAttributes, $return); } - /** +/** * @deprecated Name changed to 'charset'. Version 0.9.2. * @see HtmlHelper::charset() * @param string $charset * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function charsetTag($charset, $return = false) @@ -783,16 +782,16 @@ class HtmlHelper extends Helper return $this->charset($charset, $return); } - /** +/** * @deprecated Name changed to 'checkbox'. Version 0.9.2. * @see HtmlHelper::checkbox() * @param string $fieldName If field is to be used for CRUD, this * should be modelName/fieldName. * @param string $title - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function checkboxTag($fieldName, $title = null, $htmlAttributes = null, $return = false) @@ -800,15 +799,15 @@ class HtmlHelper extends Helper return $this->checkbox($fieldName, $title, $htmlAttributes, $return); } - /** +/** * @deprecated Name changed to 'css'. Version 0.9.2. * @see HtmlHelper::css() - * @param string $path Path to CSS file + * @param string $path Path to CSS file * @param string $rel Rel attribute. Defaults to "stylesheet". - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function cssTag($path, $rel = 'stylesheet', $htmlAttributes = null, $return = false) @@ -816,14 +815,14 @@ class HtmlHelper extends Helper return $this->css($path, $rel , $htmlAttributes , $return ); } - /** +/** * @deprecated Name changed to 'file'. Version 0.9.2. * @see HtmlHelper::file() * @param string $fieldName Name of a field, like this "Modelname/fieldname" - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function fileTag($fieldName, $htmlAttributes = null, $return = false) @@ -831,38 +830,38 @@ class HtmlHelper extends Helper return $this->file($fieldName, $htmlAttributes, $return); } - /** +/** * @deprecated Name changed to 'hidden'. Version 0.9.2. * @see HtmlHelper::hidden() * @param string $fieldName If field is to be used for CRUD, this * should be modelName/fieldName. * @param string $value - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ - //function hiddenTag($fieldName, $value = null, $htmlAttributes = null, $return = false) - //{ - // $htmlAttributes['value'] = $value; - // return $this->hidden($fieldName, $htmlAttributes, $return); - //} +//function hiddenTag($fieldName, $value = null, $htmlAttributes = null, $return = false) +//{ +// $htmlAttributes['value'] = $value; +// return $this->hidden($fieldName, $htmlAttributes, $return); +//} function hiddenTag($tagName, $value=null, $htmlOptions=null) { $this->setFormTag($tagName); $htmlOptions['value'] = $value? $value: $this->tagValue($tagName); return $this->output(sprintf($this->tags['hidden'], $this->model, $this->field, $this->parseHtmlOptions($htmlOptions, null, '', ' '))); } - /** +/** * @deprecated Name changed to 'image'. Version 0.9.2. * @see HtmlHelper::image() - * @param string $path Path to the image file. + * @param string $path Path to the image file. * @param string $alt - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function imageTag($path, $alt = null, $htmlAttributes = null, $return = false) @@ -871,23 +870,23 @@ class HtmlHelper extends Helper return $this->image($path, $htmlAttributes, $return); } - /** +/** * @deprecated Name changed to 'input'. Version 0.9.2. * @see HtmlHelper::input() * @param string $fieldName If field is to be used for CRUD, this * should be modelName/fieldName. * @param string $value - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ - //function inputTag($fieldName, $value = null, $htmlAttributes = null, $return = false) - //{ - // $htmlAttributes['value'] = $value; - // return $this->input($fieldName, $htmlAttributes, $return); - //} +//function inputTag($fieldName, $value = null, $htmlAttributes = null, $return = false) +//{ +// $htmlAttributes['value'] = $value; +// return $this->input($fieldName, $htmlAttributes, $return); +//} function inputTag($tagName, $size=20, $htmlOptions=null) { @@ -897,16 +896,16 @@ class HtmlHelper extends Helper return $this->output(sprintf($this->tags['input'], $this->model, $this->field, $this->parseHtmlOptions($htmlOptions, null, '', ' '))); } - /** +/** * @deprecated Unified with 'link'. Version 0.9.2. * @see HtmlHelper::link() * @param string $title The content of the "a" tag. * @param string $url - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $escapeTitle Whether or not the text in the $title variable should be HTML escaped. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function linkOut($title, $url = null, $htmlAttributes = null, $escapeTitle = true, $return = false) @@ -914,17 +913,17 @@ class HtmlHelper extends Helper return $this->link($title, $url, $htmlAttributes, false, $escapeTitle, $return); } - /** +/** * @deprecated Unified with 'link'. Version 0.9.2. * @see HtmlHelper::link() * @param string $title The content of the "a" tag. * @param string $url - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param string $confirmMessage Confirmation message. * @param boolean $escapeTitle Whether or not the text in the $title variable should be HTML escaped. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function linkTo($title, $url, $htmlAttributes = null, $confirmMessage = false, $escapeTitle = true, $return = false) @@ -932,7 +931,7 @@ class HtmlHelper extends Helper return $this->link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle, $return); } - /** +/** * @deprecated Name changed to '_parseAttributes'. Version 0.9.2. * @see HtmlHelper::_parseAttributes() * @param array $options Array of options. @@ -941,12 +940,12 @@ class HtmlHelper extends Helper * @param string $insertAfter String to be inserted ater options. * @return string */ - //function parseHtmlOptions($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) - // { - // $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter); - // } +//function parseHtmlOptions($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) +// { +// $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter); +// } - function parseHtmlOptions($options, $exclude=null, $insert_before=' ', $insert_after=null) + function parseHtmlOptions($options, $exclude=null, $insertBefore=' ', $insertAfter=null) { if (!is_array($exclude)) $exclude = array(); @@ -961,22 +960,22 @@ class HtmlHelper extends Helper } } $out = join(' ', $out); - return $out? $insert_before.$out.$insert_after: null; + return $out? $insertBefore.$out.$insertAfter: null; } else { - return $options? $insert_before.$options.$insert_after: null; + return $options? $insertBefore.$options.$insertAfter: null; } } - /** +/** * @deprecated Name changed to 'password'. Version 0.9.2. * @see HtmlHelper::password() * @param string $fieldName Name of a field, like this "Modelname/fieldname" - * @param array $htmlAttributes Array of HTML attributes. + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function passwordTag($fieldName, $size = 20, $htmlAttributes = null, $return = false) @@ -985,16 +984,16 @@ class HtmlHelper extends Helper return call_user_func_array(array(&$this, "password"), $args); } - /** +/** * @deprecated Name changed to 'radio'. Version 0.9.2. * @see HtmlHelper::radio() * @param string $fieldName Name of a field, like this "Modelname/fieldname" - * @param array $options - * @param array $inbetween - * @param array $htmlAttributes Array of HTML attributes. + * @param array $options + * @param array $inbetween + * @param array $htmlAttributes Array of HTML attributes. * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. */ function radioTags($fieldName, $options, $inbetween = null, $htmlAttributes = null, @@ -1003,33 +1002,33 @@ class HtmlHelper extends Helper return $this->radio($fieldName, $options, $inbetween, $htmlAttributes, $return); } - /** +/** * Returns a SELECT element, * * @param string $fieldName Name attribute of the SELECT - * @param array $option_elements Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the SELECT element + * @param array $optionElements Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the SELECT element * @param boolean $show_empty Show/hide the empty select option - * @param array $select_attr Array of HTML options for the opening SELECT element + * @param array $selectAttr Array of HTML options for the opening SELECT element * @param array $optionAttr Array of HTML options for the enclosed OPTION elements * @return string Formatted SELECT element */ - function selectTag($fieldName, $option_elements, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty=true) + function selectTag($fieldName, $optionElements, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty=true) { $this->setFormTag($fieldName); - // do not display the select tag if no option elements are avaible - if (!is_array($option_elements) || count($option_elements) == 0) +// do not display the select tag if no option elements are avaible + if (!is_array($optionElements) || count($optionElements) == 0) { return null; } - if( isset($select_attr) && array_key_exists( "multiple", $select_attr) ) + if( isset($selectAttr) && array_key_exists( "multiple", $selectAttr) ) { - $select[] = sprintf($this->tags['selectmultiplestart'], $this->model, $this->field, $this->parseHtmlOptions($select_attr)); + $select[] = sprintf($this->tags['selectmultiplestart'], $this->model, $this->field, $this->parseHtmlOptions($selectAttr)); } else { - $select[] = sprintf($this->tags['selectstart'], $this->model, $this->field, $this->parseHtmlOptions($select_attr)); + $select[] = sprintf($this->tags['selectstart'], $this->model, $this->field, $this->parseHtmlOptions($selectAttr)); } if($showEmpty == true) @@ -1037,17 +1036,17 @@ class HtmlHelper extends Helper $select[] = sprintf($this->tags['selectempty'], $this->parseHtmlOptions($optionAttr)); } - foreach ($option_elements as $name=>$title) + foreach ($optionElements as $name => $title) { - $options_here = $optionAttr; + $optionsHere = $optionAttr; if (($selected !== null) && ($selected == $name)) { - $options_here['selected'] = 'selected'; + $optionsHere['selected'] = 'selected'; } else if ( is_array($selected) && array_key_exists($name, $selected) ) { - $options_here['selected'] = 'selected'; + $optionsHere['selected'] = 'selected'; } - $select[] = sprintf($this->tags['selectoption'], $name, $this->parseHtmlOptions($options_here), $title); + $select[] = sprintf($this->tags['selectoption'], $name, $this->parseHtmlOptions($optionsHere), $title); } $select[] = sprintf($this->tags['selectend']); @@ -1056,7 +1055,7 @@ class HtmlHelper extends Helper } - /** +/** * @deprecated Name changed to 'url'. Version 0.9.2. * @see HtmlHelper::url() */ @@ -1069,7 +1068,7 @@ class HtmlHelper extends Helper - /** +/** * @deprecated Name changed to 'submit'. Version 0.9.2. * @see HtmlHelper::submit() */ @@ -1079,11 +1078,11 @@ class HtmlHelper extends Helper return call_user_func_array(array(&$this, "submit"), $args); } - /************************************************************************* - * Moved methods - *************************************************************************/ +/************************************************************************* + * Moved methods + *************************************************************************/ - /** +/** * @deprecated Moved to TextHelper. Version 0.9.2. */ function trim() @@ -1091,7 +1090,7 @@ class HtmlHelper extends Helper die("Method HtmlHelper::trim() was moved to TextHelper::trim()."); } - /** +/** * @deprecated Moved to JavascriptHelper. Version 0.9.2. */ function javascriptIncludeTag($url) @@ -1099,7 +1098,7 @@ class HtmlHelper extends Helper die("Method HtmlHelper::javascriptIncludeTag() was moved to JavascriptHelper::link()."); } - /** +/** * @deprecated Moved to JavascriptHelper. Version 0.9.2. */ function javascriptTag($script) @@ -1107,11 +1106,11 @@ class HtmlHelper extends Helper die("Method HtmlHelper::javascriptTag() was moved to JavascriptHelper::codeBlock()."); } - /************************************************************************* - * Deprecated methods - *************************************************************************/ +/************************************************************************* + * Deprecated methods + *************************************************************************/ - /** +/** * Returns an HTML FORM element. * * @param string $target URL for the FORM's ACTION attribute. @@ -1130,16 +1129,16 @@ class HtmlHelper extends Helper return sprintf($this->tags['form'], $this->parseHtmlOptions($htmlAttributes, null, '')); } - /** +/** * Generates a nested unordered list tree from an array. * - * @param array $data - * @param array $htmlAttributes + * @param array $data + * @param array $htmlAttributes * @param string $bodyKey * @param string $childrenKey * @param boolean $return Wheter this method should return a value * or output it. This overrides AUTO_OUTPUT. - * @return mixed Either string or boolean value, depends on AUTO_OUTPUT + * @return mixed Either string or boolean value, depends on AUTO_OUTPUT * and $return. If $this->_crumbs is empty, return null. * @deprecated This seems useless. Version 0.9.2. */ @@ -1162,11 +1161,11 @@ class HtmlHelper extends Helper return $this->output($out, $return); } - /** +/** * Returns a mailto: link. * * @param string $title Title of the link, or the e-mail address - * (if the same). + * (if the same). * @param string $email E-mail address if different from title. * @param array $options * @return string Formatted A tag @@ -1174,20 +1173,20 @@ class HtmlHelper extends Helper */ function linkEmail($title, $email=null, $options=null) { - // if no $email, then title contains the email. +// if no $email, then title contains the email. if (empty($email)) $email = $title; $match = array(); - // does the address contain extra attributes? +// does the address contain extra attributes? preg_match('!^(.*)(\?.*)$!', $email, $match); - // plaintext +// plaintext if (empty($options['encode']) || !empty($match[2])) { return sprintf($this->tags['mailto'], $email, $this->parseHtmlOptions($options), $title); } - // encoded to avoid spiders +// encoded to avoid spiders else { $email_encoded = null; @@ -1213,16 +1212,16 @@ class HtmlHelper extends Helper } } - /** +/** * Returns a generic HTML tag (no content). * * Examples: - * + tag("br") =>
- * + tag("input", array("type" => "text")) => + * + tag("br") =>
+ * + tag("input", array("type" => "text")) => * * @param string $name Name of HTML element * @param array $options HTML options - * @param bool $open Is the tag open or closed? (defaults to closed "/>") + * @param bool $open Is the tag open or closed? (defaults to closed "/>") * @return string The formatted HTML tag * @deprecated This seems useless. Version 0.9.2. */ @@ -1233,7 +1232,7 @@ class HtmlHelper extends Helper return $tag; } - /** +/** * Returns a generic HTML tag with content. * * Examples: @@ -1245,7 +1244,7 @@ class HtmlHelper extends Helper * * @param string $name Name of HTML element * @param array $options HTML options - * @param bool $open Is the tag open or closed? (defaults to closed "/>") + * @param bool $open Is the tag open or closed? (defaults to closed "/>") * @return string The formatted HTML tag * @deprecated This seems useless. Version 0.9.2. */ @@ -1254,7 +1253,7 @@ class HtmlHelper extends Helper return "<$name ". $this->parseHtmlOptions($options). ">$content"; } - /** +/** * Returns a SELECT element for days. * * @param string $tagName Prefix name for the SELECT element @@ -1264,7 +1263,7 @@ class HtmlHelper extends Helper * @param boolean $show_empty Show/hide the empty select option * @return string */ - function dayOptionTag($tagName, $value=null, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true) + function dayOptionTag($tagName, $value=null, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true) { $value = isset($value)? $value : $this->tagValue($tagName."_day"); $dayValue = empty($selected) ? date('d') : $selected; @@ -1277,11 +1276,11 @@ class HtmlHelper extends Helper '22'=>'22','23'=>'23','24'=>'24', '25'=>'25','26'=>'26','27'=>'27', '28'=>'28','29'=>'29','30'=>'30','31'=>'31'); - $option = $this->selectTag($tagName.'_day', $days, $dayValue, $select_attr, $optionAttr, $showEmpty); + $option = $this->selectTag($tagName.'_day', $days, $dayValue, $selectAttr, $optionAttr, $showEmpty); return $option; } - /** +/** * Returns a SELECT element for years * * @param string $tagName Prefix name for the SELECT element @@ -1293,7 +1292,7 @@ class HtmlHelper extends Helper * @param boolean $show_empty Show/hide the empty select option * @return string */ - function yearOptionTag($tagName, $value=null, $minYear=null, $maxYear=null, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true) + function yearOptionTag($tagName, $value=null, $minYear=null, $maxYear=null, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true) { $value = isset($value)? $value : $this->tagValue($tagName."_year"); @@ -1318,11 +1317,11 @@ class HtmlHelper extends Helper $years[$yearCounter] = $yearCounter; } - $option = $this->selectTag($tagName.'_year', $years, $yearValue, $select_attr, $optionAttr, $showEmpty); + $option = $this->selectTag($tagName.'_year', $years, $yearValue, $selectAttr, $optionAttr, $showEmpty); return $option; } - /** +/** * Returns a SELECT element for months. * * @param string $tagName Prefix name for the SELECT element @@ -1332,18 +1331,18 @@ class HtmlHelper extends Helper * @param boolean $show_empty Show/hide the empty select option * @return string */ - function monthOptionTag($tagName, $value=null, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true) + function monthOptionTag($tagName, $value=null, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true) { $value = isset($value)? $value : $this->tagValue($tagName."_month"); $monthValue = empty($selected) ? date('m') : $selected ; $months=array('01'=>'January','02'=>'February','03'=>'March', '04'=>'April','05'=>'May','06'=>'June','07'=>'July','08'=>'August', '09'=>'September','10'=>'October','11'=>'November','12'=>'December'); - $option = $this->selectTag($tagName.'_month', $months, $monthValue, $select_attr, $optionAttr, $showEmpty); + $option = $this->selectTag($tagName.'_month', $months, $monthValue, $selectAttr, $optionAttr, $showEmpty); return $option; } - /** +/** * Returns a SELECT element for hours. * * @param string $tagName Prefix name for the SELECT element @@ -1353,7 +1352,7 @@ class HtmlHelper extends Helper * @param array $optionAttr Attribute array for the option elements. * @return string */ - function hourOptionTag($tagName, $value=null, $format24Hours = false, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true ) + function hourOptionTag($tagName, $value=null, $format24Hours = false, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true ) { $value = isset($value)? $value : $this->tagValue($tagName."_hour"); if ( $format24Hours ) @@ -1380,12 +1379,12 @@ class HtmlHelper extends Helper '10'=>'10','11'=>'11','12'=>'12'); } - $option = $this->selectTag($tagName.'_hour', $hours, $hourValue, $select_attr, + $option = $this->selectTag($tagName.'_hour', $hours, $hourValue, $selectAttr, $optionAttr); return $option; } - /** +/** * Returns a SELECT element for minutes. * * @param string $tagName Prefix name for the SELECT element @@ -1394,7 +1393,7 @@ class HtmlHelper extends Helper * @param array $optionAttr Attribute array for the option elements. * @return string */ - function minuteOptionTag( $tagName, $value=null, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true) + function minuteOptionTag( $tagName, $value=null, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true) { $value = isset($value)? $value : $this->tagValue($tagName."_min"); $minValue = empty($selected) ? date('i') : $selected ; @@ -1403,12 +1402,12 @@ class HtmlHelper extends Helper $mins[$minCount] = sprintf('%02d', $minCount); } - $option = $this->selectTag($tagName.'_min', $mins, $minValue, $select_attr, + $option = $this->selectTag($tagName.'_min', $mins, $minValue, $selectAttr, $optionAttr); return $option; } - /** +/** * Returns a SELECT element for AM or PM. * * @param string $tagName Prefix name for the SELECT element @@ -1417,18 +1416,18 @@ class HtmlHelper extends Helper * @param array $optionAttr Attribute array for the option elements. * @return string */ - function meridianOptionTag( $tagName, $value=null, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true) + function meridianOptionTag( $tagName, $value=null, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true) { $value = isset($value)? $value : $this->tagValue($tagName."_meridian"); $merValue = empty($selected) ? date('a') : $selected ; $meridians = array('am'=>'am','pm'=>'pm'); - $option = $this->selectTag($tagName.'_meridian', $meridians, $merValue, $select_attr, + $option = $this->selectTag($tagName.'_meridian', $meridians, $merValue, $selectAttr, $optionAttr); return $option; } - /** +/** * Returns a set of SELECT elements for a full datetime setup: day, month and year, and then time. * * @param string $tagName Prefix name for the SELECT element @@ -1438,13 +1437,13 @@ class HtmlHelper extends Helper * @param array $optionAttr Attribute array for the option elements. * @return string The HTML formatted OPTION element */ - function dateTimeOptionTag( $tagName, $dateFormat = 'DMY', $timeFormat = '12',$selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true) + function dateTimeOptionTag( $tagName, $dateFormat = 'DMY', $timeFormat = '12',$selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true) { - $day = null; + $day = null; $month = null; $year = null; $hour = null; - $min = null; + $min = null; $meridian = null; if(!empty($selected)) @@ -1457,7 +1456,7 @@ class HtmlHelper extends Helper $date = explode('-',$selected); $days = explode(' ',$date[2]); - $day = $days[0]; + $day = $days[0]; $month = $date[1]; $year = $date[0]; @@ -1474,7 +1473,7 @@ class HtmlHelper extends Helper $meridian = 'pm'; } $hour = $time[0]; - $min = $time[1]; + $min = $time[1]; } } @@ -1482,13 +1481,13 @@ class HtmlHelper extends Helper switch ( $dateFormat ) { case 'DMY' : - $opt = $this->dayOptionTag( $tagName ,null ,$day, $select_attr, $optionAttr, $showEmpty) . '-' . $this->monthOptionTag( $tagName, null, $month, $select_attr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag( $tagName, null, null, null, $year, $select_attr, $optionAttr, $showEmpty); + $opt = $this->dayOptionTag( $tagName ,null ,$day, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->monthOptionTag( $tagName, null, $month, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag( $tagName, null, null, null, $year, $selectAttr, $optionAttr, $showEmpty); break; case 'MDY' : - $opt = $this->monthOptionTag($tagName, null, $month, $select_attr, $optionAttr, $showEmpty) .'-'.$this->dayOptionTag( $tagName, null, $day, $select_attr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $optionAttr, $select_attr, $showEmpty); + $opt = $this->monthOptionTag($tagName, null, $month, $selectAttr, $optionAttr, $showEmpty) .'-'.$this->dayOptionTag( $tagName, null, $day, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $optionAttr, $selectAttr, $showEmpty); break; case 'YMD' : - $opt = $this->yearOptionTag($tagName, null, null, null, $year, $select_attr, $optionAttr, $showEmpty) . '-' . $this->monthOptionTag( $tagName, null, $month, $select_attr, $optionAttr, $showEmpty) . '-' . $this->dayOptionTag( $tagName, null, $day, $optionAttr, $select_attr, $showEmpty); + $opt = $this->yearOptionTag($tagName, null, null, null, $year, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->monthOptionTag( $tagName, null, $month, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->dayOptionTag( $tagName, null, $day, $optionAttr, $selectAttr, $showEmpty); break; case 'NONE': $opt =''; @@ -1500,10 +1499,10 @@ class HtmlHelper extends Helper switch ($timeFormat) { case '24': - $opt .= $this->hourOptionTag( $tagName, null , true, $hour, $select_attr, $optionAttr, $showEmpty) . ':' . $this->minuteOptionTag( $tagName, null, $min, $select_attr, $optionAttr, $showEmpty); + $opt .= $this->hourOptionTag( $tagName, null , true, $hour, $selectAttr, $optionAttr, $showEmpty) . ':' . $this->minuteOptionTag( $tagName, null, $min, $selectAttr, $optionAttr, $showEmpty); break; case '12': - $opt .= $this->hourOptionTag( $tagName, null, false, $hour, $select_attr, $optionAttr, $showEmpty) . ':' . $this->minuteOptionTag( $tagName, null, $min, $select_attr, $optionAttr, $showEmpty) . ' ' . $this->meridianOptionTag($tagName, null, $meridian, $select_attr, $optionAttr, $showEmpty); + $opt .= $this->hourOptionTag( $tagName, null, false, $hour, $selectAttr, $optionAttr, $showEmpty) . ':' . $this->minuteOptionTag( $tagName, null, $min, $selectAttr, $optionAttr, $showEmpty) . ' ' . $this->meridianOptionTag($tagName, null, $meridian, $selectAttr, $optionAttr, $showEmpty); break; case 'NONE': $opt .=''; diff --git a/cake/libs/view/helpers/javascript.php b/cake/libs/view/helpers/javascript.php index 822115d99..29c5a2179 100644 --- a/cake/libs/view/helpers/javascript.php +++ b/cake/libs/view/helpers/javascript.php @@ -43,7 +43,7 @@ class JavascriptHelper extends Helper var $_cachedEvents = array(); var $_cacheEvents = false; - /** +/** * Returns a JavaScript script tag. * * @param string $script The JavaScript to be wrapped in SCRIPT tags. @@ -54,7 +54,7 @@ class JavascriptHelper extends Helper return sprintf($this->tags['javascriptblock'], $script); } - /** +/** * Returns a JavaScript include tag (SCRIPT element) * * @param string $url URL to JavaScript file. @@ -66,7 +66,7 @@ class JavascriptHelper extends Helper return sprintf($this->tags['javascriptlink'], $this->webroot.JS_URL.$this->themeWeb.$url); } - /** +/** * Returns a JavaScript include tag for an externally-hosted script * * @param string $url URL to JavaScript file. @@ -79,11 +79,11 @@ class JavascriptHelper extends Helper } /** - * Escape carriage returns and single and double quotes for JavaScript segments. - * - * @param string $script string that might have javascript elements - * @return string escaped string - */ + * Escape carriage returns and single and double quotes for JavaScript segments. + * + * @param string $script string that might have javascript elements + * @return string escaped string + */ function escapeScript ($script) { $script = str_replace(array("\r\n","\n","\r"),'\n', $script); @@ -95,11 +95,11 @@ class JavascriptHelper extends Helper * Escape a string to be JavaScript friendly. * * List of escaped ellements: - * + "\r\n" => '\n' - * + "\r" => '\n' - * + "\n" => '\n' - * + '"' => '\"' - * + "'" => "\\'" + * + "\r\n" => '\n' + * + "\r" => '\n' + * + "\n" => '\n' + * + '"' => '\"' + * + "'" => "\\'" * * @param string $script String that needs to get escaped. * @return string Escaped string. @@ -108,8 +108,8 @@ class JavascriptHelper extends Helper { $escape = array( "\r\n" => '\n', - "\r" => '\n', - "\n" => '\n', + "\r" => '\n', + "\n" => '\n', '"' => '\"', "'" => "\\'" ); @@ -117,14 +117,14 @@ class JavascriptHelper extends Helper return str_replace(array_keys($escape), array_values($escape), $string); } /** - * Attach an event to an element. Used with the Prototype library. - * - * @param string $object Object to be observed - * @param string $event event to observe - * @param string $observer function to call - * @param boolean $useCapture default true - * @return boolean true on success - */ + * Attach an event to an element. Used with the Prototype library. + * + * @param string $object Object to be observed + * @param string $event event to observe + * @param string $observer function to call + * @param boolean $useCapture default true + * @return boolean true on success + */ function event ($object, $event, $observer, $useCapture = true) { if($useCapture == true) @@ -149,10 +149,10 @@ class JavascriptHelper extends Helper /** - * Cache JavaScript events created with event() - * - * @return null - */ + * Cache JavaScript events created with event() + * + * @return null + */ function cacheEvents () { $this->_cacheEvents = true; @@ -160,10 +160,10 @@ class JavascriptHelper extends Helper /** - * Write cached JavaScript events - * - * @return string A single code block of all cached JavaScript events created with event() - */ + * Write cached JavaScript events + * + * @return string A single code block of all cached JavaScript events created with event() + */ function writeEvents () { $this->_cacheEvents = false; @@ -171,14 +171,14 @@ class JavascriptHelper extends Helper } /** - * Includes the Prototype Javascript library (and anything else) inside a single script tag. - * - * Note: The recommended approach is to copy the contents of - * javascripts into your application's - * public/javascripts/ directory, and use @see javascriptIncludeTag() to - * create remote script links. - * @return string script with all javascript in /javascripts folder - */ + * Includes the Prototype Javascript library (and anything else) inside a single script tag. + * + * Note: The recommended approach is to copy the contents of + * javascripts into your application's + * public/javascripts/ directory, and use @see javascriptIncludeTag() to + * create remote script links. + * @return string script with all javascript in/javascripts folder + */ function includeScript ($script = "") { if($script == "") @@ -201,18 +201,18 @@ class JavascriptHelper extends Helper } /** - * Generates a JavaScript object in JavaScript Object Notation (JSON) - * from an array - * - * @param array $data Data to be converted - * @param boolean $block Wraps return value in a