diff --git a/app/controllers/components/db_acl.sql b/app/controllers/components/db_acl.sql index 33730959d..87a49c223 100644 --- a/app/controllers/components/db_acl.sql +++ b/app/controllers/components/db_acl.sql @@ -1,36 +1,36 @@ CREATE TABLE `acos` ( - `id` int(11) NOT NULL auto_increment, - `object_id` int(11) default NULL, - `alias` varchar(255) NOT NULL default '', - `lft` int(11) default NULL, - `rght` int(11) default NULL, + `id` int(11) NOT NULL auto_increment, + `object_id` int(11) default NULL, + `alias` varchar(255) NOT NULL default '', + `lft` int(11) default NULL, + `rght` int(11) default NULL, PRIMARY KEY (`id`) ); CREATE TABLE `aros` ( - `id` int(11) NOT NULL auto_increment, - `user_id` int(11) default NULL, - `alias` varchar(255) NOT NULL default '', - `lft` int(11) default NULL, - `rght` int(11) default NULL, + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) default NULL, + `alias` varchar(255) NOT NULL default '', + `lft` int(11) default NULL, + `rght` int(11) default NULL, PRIMARY KEY (`id`) ); CREATE TABLE `aros_acos` ( - `id` int(11) NOT NULL auto_increment, - `aro_id` int(11) default NULL, - `aco_id` int(11) default NULL, - `create` tinyint(1) NOT NULL default '0', - `read` tinyint(1) NOT NULL default '0', - `update` tinyint(1) NOT NULL default '0', - `delete` tinyint(1) NOT NULL default '0', + `id` int(11) NOT NULL auto_increment, + `aro_id` int(11) default NULL, + `aco_id` int(11) default NULL, + `create` tinyint(1) NOT NULL default '0', + `read` tinyint(1) NOT NULL default '0', + `update` tinyint(1) NOT NULL default '0', + `delete` tinyint(1) NOT NULL default '0', PRIMARY KEY (`id`) ); CREATE TABLE `aco_actions` ( - `id` int(11) NOT NULL auto_increment, - `aros_acos_id` int(11) default NULL, - `action` varchar(255) NOT NULL default '', - `value` tinyint(1) NOT NULL default '0', + `id` int(11) NOT NULL auto_increment, + `aros_acos_id` int(11) default NULL, + `action` varchar(255) NOT NULL default '', + `value` tinyint(1) NOT NULL default '0', PRIMARY KEY (`id`) ); diff --git a/app/webroot/css/cake.default.css b/app/webroot/css/cake.default.css index 096f6d21c..117a762d2 100644 --- a/app/webroot/css/cake.default.css +++ b/app/webroot/css/cake.default.css @@ -48,14 +48,14 @@ h1, a { color:#DB8101; } h1 em, a em { - color:#008BCC; - font-style: normal; + color:#008BCC; + font-style: normal; } ul.colored a em h2 { - font-style: italic; - font-weight: bold; - color:#666; + font-style: italic; + font-weight: bold; + color:#666; } a:hover, a:hover em { color:#A22424; diff --git a/app/webroot/css/cake.forms.css b/app/webroot/css/cake.forms.css index 8ee223a07..243b3f18b 100644 --- a/app/webroot/css/cake.forms.css +++ b/app/webroot/css/cake.forms.css @@ -275,5 +275,5 @@ select.autoWidth { } option { - padding-left:1em; + padding-left:1em; } \ No newline at end of file diff --git a/app/webroot/index.php b/app/webroot/index.php index f16da5cda..f0d4c9dc1 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -9,7 +9,7 @@ * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, Cake Software Foundation, Inc. * 1785 E. Sahara Avenue, Suite 490-204 * Las Vegas, Nevada 89104 * @@ -66,8 +66,8 @@ if (!defined('WEBROOT_DIR')) require_once ROOT.'cake'.DS.'basics.php'; require_once ROOT.APP_DIR.DS.'config'.DS.'core.php'; require_once ROOT.'cake'.DS.'config'.DS.'paths.php'; -require_once LIBS.'log.php'; require_once LIBS.'object.php'; +require_once LIBS.'log.php'; require_once LIBS.'session.php'; require_once LIBS.'security.php'; require_once LIBS.'neat_array.php'; @@ -127,13 +127,12 @@ require_once LIBS.'model'.DS.'dbo'.DS.'dbo_factory.php'; config('database'); -if (class_exists('DATABASE_CONFIG')) +if (class_exists('DATABASE_CONFIG') && !class_exists('AppModel')) { - loadModels(); + require_once LIBS.'model'.DS.'model.php'; + loadModels(); } - - //RUN THE SCRIPT if(isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { diff --git a/cake/basics.php b/cake/basics.php index 8bc2165ec..c1fde431a 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -3,20 +3,20 @@ /** * Basic Cake functionality. - * + * * Core functions for including other source files, loading models and so forth. * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -42,15 +42,15 @@ define('YEAR', 365 * DAY); /** * Patch for PHP < 4.3 */ - if (!function_exists("ob_get_clean")) +if (!function_exists("ob_get_clean")) +{ + function ob_get_clean() { - function ob_get_clean() - { - $ob_contents = ob_get_contents(); - ob_end_clean(); - return $ob_contents; - } + $ob_contents = ob_get_contents(); + ob_end_clean(); + return $ob_contents; } +} /** * Loads all models. @@ -59,20 +59,23 @@ define('YEAR', 365 * DAY); * @uses APP * @uses MODELS */ -function loadModels () +function loadModels () { - if(file_exists(APP.'app_model.php')) - { - require_once(APP.'app_model.php'); - } - else - { - require_once(CAKE.'app_model.php'); - } - foreach (listClasses(MODELS) as $model_fn) - { - require_once (MODELS.$model_fn); - } + if(!class_exists('AppModel', FALSE)) + { + if(file_exists(APP.'app_model.php')) + { + require_once(APP.'app_model.php'); + } + else + { + require_once(CAKE.'app_model.php'); + } + foreach (listClasses(MODELS) as $model_fn) + { + require_once (MODELS.$model_fn); + } + } } /** @@ -83,21 +86,26 @@ function loadModels () * @uses HELPERS * @uses CONTROLLERS */ -function loadControllers () -{ - if(file_exists(APP.'app_controller.php')) - { - require_once(APP.'app_controller.php'); - } - else - { - require_once(CAKE.'app_controller.php'); - } - - foreach (listClasses(CONTROLLERS) as $controller) - { - require_once (CONTROLLERS.$controller.'.php'); - } +function loadControllers () +{ + if(!class_exists('AppController', FALSE)) + { + if(file_exists(APP.'app_controller.php')) + { + require_once(APP.'app_controller.php'); + } + else + { + require_once(CAKE.'app_controller.php'); + } + } + foreach (listClasses(CONTROLLERS) as $controller) + { + if(!class_exists($controller, FALSE)) + { + require_once (CONTROLLERS.$controller.'.php'); + } + } } /** @@ -106,41 +114,45 @@ function loadControllers () * @param string $name Name of controller * @return boolean Success */ -function loadController ($name) +function loadController ($name) { - $name = Inflector::underscore($name); - if(file_exists(CONTROLLERS.$name.'_controller.php')) - { - $controller_fn = CONTROLLERS.$name.'_controller.php'; - } - elseif(file_exists(LIBS.'controller'.DS.$name.'_controller.php')) - { - $controller_fn = LIBS.'controller'.DS.$name.'_controller.php'; - } - else - { - $controller_fn = false; - } - - if(file_exists(APP.'app_controller.php')) - { - require_once(APP.'app_controller.php'); - } - else - { - require_once(CAKE.'app_controller.php'); - } - - return file_exists($controller_fn)? require_once($controller_fn): false; + if(!class_exists('AppController', FALSE)) + { + if(file_exists(APP.'app_controller.php')) + { + require_once(APP.'app_controller.php'); + } + else + { + require_once(CAKE.'app_controller.php'); + } + } + if(!class_exists($name, FALSE)) + { + $name = Inflector::underscore($name); + if(file_exists(CONTROLLERS.$name.'_controller.php')) + { + $controller_fn = CONTROLLERS.$name.'_controller.php'; + } + elseif(file_exists(LIBS.'controller'.DS.$name.'_controller.php')) + { + $controller_fn = LIBS.'controller'.DS.$name.'_controller.php'; + } + else + { + $controller_fn = false; + } + return file_exists($controller_fn)? require_once($controller_fn): false; + } } /** * Lists PHP files in given directory. * - * @param string $path Path to scan for files - * @return array List of files in directory + * @param string $path Path to scan for files + * @return array List of files in directory */ -function listClasses($path) +function listClasses($path) { $modules = new Folder($path); return $modules->find('(.+)\.php'); @@ -151,26 +163,27 @@ function listClasses($path) * * @return boolean Success */ -function config () +function config () { $args = func_get_args(); - foreach ($args as $arg) + $count = count($args); + foreach ($args as $arg) { if (('database' == $arg) && file_exists(CONFIGS.$arg.'.php')) { include_once(CONFIGS.$arg.'.php'); } - elseif (file_exists(CONFIGS.$arg.'.php')) + elseif (file_exists(CONFIGS.$arg.'.php')) { include_once (CONFIGS.$arg.'.php'); - if (count($args) == 1) return true; + if ($count == 1) return true; } - else + else { - if (count($args) == 1) return false; + if ($count == 1) return false; } } - + return true; } @@ -187,7 +200,7 @@ function config () function uses () { $args = func_get_args(); - foreach ($args as $arg) + foreach ($args as $arg) { require_once(LIBS.strtolower($arg).'.php'); } @@ -202,7 +215,7 @@ function uses () function vendor($name) { $args = func_get_args(); - foreach ($args as $arg) + foreach ($args as $arg) { require_once(VENDORS.$arg.'.php'); } @@ -213,12 +226,12 @@ function vendor($name) * * Only runs if DEBUG level is non-zero. * - * @param boolean $var Variable to show debug information for. - * @param boolean $show_html If set to true, the method prints the debug data in a screen-friendly way. + * @param boolean $var Variable to show debug information for. + * @param boolean $show_html If set to true, the method prints the debug data in a screen-friendly way. */ -function debug($var = false, $show_html = false) +function debug($var = false, $show_html = false) { - if (DEBUG) + if (DEBUG) { print "\n
\n";
       if ($show_html) $var = str_replace('<', '<', str_replace('>', '>', $var));
@@ -228,21 +241,21 @@ function debug($var = false, $show_html = false)
 }
 
 
-if (!function_exists('getMicrotime')) 
+if (!function_exists('getMicrotime'))
 {
 /**
  * Returns microtime for execution time checking.
  *
  * @return integer
  */
-   function getMicrotime() 
+   function getMicrotime()
    {
       list($usec, $sec) = explode(" ", microtime());
       return ((float)$usec + (float)$sec);
    }
 }
 
-if (!function_exists('sortByKey')) 
+if (!function_exists('sortByKey'))
 {
 /**
  * Sorts given $array by key $sortby.
@@ -253,30 +266,33 @@ if (!function_exists('sortByKey'))
  * @param integer $type
  * @return mixed
  */
-   function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC) 
-   {
-      if (!is_array($array))
-         return null;
-
-      foreach ($array as $key => $val)
-      {
-         $sa[$key] = $val[$sortby];
-      }
-
-      $order == 'asc'
-         ? asort($sa, $type)
-         : arsort($sa, $type);
-
-      foreach ($sa as $key=>$val)
-      {
-         $out[] = $array[$key];
-      }
-
-      return $out;
-   }
+function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC)
+{
+    if (!is_array($array))
+    {
+        return null;
+    }
+    foreach ($array as $key => $val)
+    {
+        $sa[$key] = $val[$sortby];
+    }
+    if($order == 'asc')
+    {
+        asort($sa, $type);
+    }
+    else
+    {
+        arsort($sa, $type);
+    }
+    foreach ($sa as $key=>$val)
+    {
+        $out[] = $array[$key];
+    }
+    return $out;
+}
 }
 
-if (!function_exists('array_combine')) 
+if (!function_exists('array_combine'))
 {
 /**
  * Combines given identical arrays by using the first array's values as keys,
@@ -286,25 +302,29 @@ if (!function_exists('array_combine'))
  * @param array $a2
  * @return mixed Outputs either combined array or false.
  */
-   function array_combine($a1, $a2) 
-   {
-      $a1 = array_values($a1);
-      $a2 = array_values($a2);
-      $c1 = count($a1);
-      $c2 = count($a2);
+function array_combine($a1, $a2)
+{
+    $a1 = array_values($a1);
+    $a2 = array_values($a2);
+    $c1 = count($a1);
+    $c2 = count($a2);
 
-      if ($c1 != $c2) return false; // different lenghts
-      if ($c1 <= 0)   return false; // arrays are the same and both are empty
-      
-      $output = array();
-      
-      for ($i = 0; $i < $c1; $i++) 
-      {
-         $output[$a1[$i]] = $a2[$i];
-      }
-      
-      return $output;
-   }
+    if ($c1 != $c2)
+    {
+        return false; // different lenghts
+    }
+    if ($c1 <= 0)
+    {
+        return false; // arrays are the same and both are empty
+    }
+
+    $output = array();
+    for ($i = 0; $i < $c1; $i++)
+    {
+        $output[$a1[$i]] = $a2[$i];
+    }
+    return $output;
+}
 }
 
 /**
@@ -315,10 +335,9 @@ if (!function_exists('array_combine'))
  */
 function h($text)
 {
-	return htmlspecialchars($text);
+    return htmlspecialchars($text);
 }
 
-
 /**
  * Returns an array of all the given parameters, making parameter lists shorter to write.
  *
@@ -326,30 +345,35 @@ function h($text)
  */
 function a()
 {
-	$args = func_get_args();
-	return $args;
+    $args = func_get_args();
+    return $args;
 }
 
-
 /**
- * Hierarchical arrays. 
+ * Hierarchical arrays.
  *
  * @return array
  * @todo Explain this method better.
  */
 function ha()
 {
-	$args = func_get_args();
+    $args = func_get_args();
+    $count = count($args);
 
-	for($l=0 ; $l tags around 
+ * Print_r convenience function, which prints out 
 tags around
  * the output of given array. Similar to debug().
- * 
+ *
  * @see debug
  * @param array $var
  */
 function pr($var)
 {
-	if(DEBUG > 0)
-	{
-		echo "
";
-		print_r($var);
-		echo "
"; - } + if(DEBUG > 0) + { + echo "
";
+        print_r($var);
+        echo "
"; + } } /** @@ -386,21 +410,21 @@ function pr($var) function params($p) { - if(!is_array($p) || count($p) == 0) - { - return null; - } - else - { - if(is_array($p[0]) && count($p) == 1) - { - return $p[0]; - } - else - { - return $p; - } - } + if(!is_array($p) || count($p) == 0) + { + return null; + } + else + { + if(is_array($p[0]) && count($p) == 1) + { + return $p[0]; + } + else + { + return $p; + } + } } @@ -410,23 +434,23 @@ function params($p) * * @return string */ - function setUri() +function setUri() +{ + if (isset($_SERVER['REQUEST_URI'])) { - if (isset($_SERVER['REQUEST_URI'])) + $uri = $_SERVER['REQUEST_URI']; + } + else + { + if (isset($_SERVER['argv'])) { - $uri = $_SERVER['REQUEST_URI']; + $uri = $_SERVER['PHP_SELF'] .'/'. $_SERVER['argv'][0]; } else { - if (isset($_SERVER['argv'])) - { - $uri = $_SERVER['PHP_SELF'] .'/'. $_SERVER['argv'][0]; - } - else - { - $uri = $_SERVER['PHP_SELF'] .'/'. $_SERVER['QUERY_STRING']; - } + $uri = $_SERVER['PHP_SELF'] .'/'. $_SERVER['QUERY_STRING']; } - return $uri; - } + } + return $uri; +} ?> \ No newline at end of file diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 60692951e..16dcc3dfc 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -32,7 +32,7 @@ /** * List of helpers to include */ -uses('error_messages', 'object', 'router', DS.'controller'.DS.'controller', DS.'controller'.DS.'scaffold'); +uses('error_messages', 'router', DS.'controller'.DS.'controller'); /** * Dispatcher translates URLs to controller-action-paramter triads. @@ -78,8 +78,8 @@ class Dispatcher extends Object * the form of Missing Controllers information. It does the same with Actions (methods of Controllers are called * Actions). * - * @param string $url URL information to work on. - * @return boolean Success + * @param string $url URL information to work on. + * @return boolean Success */ function dispatch($url, $additionalParams=array()) { @@ -122,7 +122,7 @@ class Dispatcher extends Object $ctrlName = Inflector::camelize($params['controller']); $ctrlClass = $ctrlName.'Controller'; - if (!loadController($params['controller']) || !class_exists($ctrlClass)) + if (!loadController($params['controller']) || !class_exists($ctrlClass, FALSE)) { if(preg_match('/([\\.]+)/',$ctrlName)) { @@ -192,6 +192,7 @@ class Dispatcher extends Object if((in_array('scaffold', array_keys($classVars))) && ($missingAction === true)) { + uses(DS.'controller'.DS.'scaffold'); $scaffolding = new Scaffold($controller, $params); exit; } @@ -234,7 +235,7 @@ class Dispatcher extends Object /** * Returns array of GET and POST parameters. GET parameters are taken from given URL. * - * @param string $from_url URL to mine for parameter information. + * @param string $from_url URL to mine for parameter information. * @return array Parameters found in POST and GET. */ function parseParams($from_url) @@ -292,7 +293,7 @@ class Dispatcher extends Object /** * Returns a base URL. * - * @return string Base URL + * @return string Base URL */ function baseUrl() { @@ -360,27 +361,27 @@ class Dispatcher extends Object /** * Displays an error page (e.g. 404 Not found). * - * @param int $code Error code (e.g. 404) - * @param string $name Name of the error message (e.g. Not found) + * @param int $code Error code (e.g. 404) + * @param string $name Name of the error message (e.g. Not found) * @param string $message * @return unknown */ function error ($code, $name, $message) - { + { $controller =& new Controller ($this); $controller->base = $this->base; $controller->autoLayout = true; $controller->set(array('code'=>$code, 'name'=>$name, 'message'=>$message)); - $controller->pageTitle = $code.' '. $name; + $controller->pageTitle = $code.' '. $name; return $controller->render('errors/error404'); - } + } /** * Convenience method to display a 404 page. * - * @param string $url URL that spawned this message, to be included in the output. - * @param string $message Message text for the 404 page. + * @param string $url URL that spawned this message, to be included in the output. + * @param string $message Message text for the 404 page. */ function error404 ($url, $message) { diff --git a/cake/libs/bake.php b/cake/libs/bake.php index 6abfa7087..ce184422a 100644 --- a/cake/libs/bake.php +++ b/cake/libs/bake.php @@ -43,53 +43,53 @@ uses('object', 'inflector'); class Bake extends Object { - /** - * Standard input stream (php://stdin). - * - * @var resource - * @access private - */ + /** + * Standard input stream (php://stdin). + * + * @var resource + * @access private + */ var $stdin = null; - /** - * Standard output stream (php://stdout). - * - * @var resource - * @access private - */ + /** + * Standard output stream (php://stdout). + * + * @var resource + * @access private + */ var $stdout = null; - /** - * Standard error stream (php://stderr). - * - * @var resource - * @access private - */ + /** + * Standard error stream (php://stderr). + * + * @var resource + * @access private + */ var $stderr = null; - /** - * Counts actions taken. - * - * @var integer - * @access private - */ + /** + * Counts actions taken. + * + * @var integer + * @access private + */ var $actions = null; - /** - * Decides whether to overwrite existing files without asking. - * - * @var boolean - * @access private - */ + /** + * Decides whether to overwrite existing files without asking. + * + * @var boolean + * @access private + */ var $dontAsk = false; - /** - * Returns code template for PHP file generator. - * - * @param string $type - * @return string - * @access private - */ + /** + * Returns code template for PHP file generator. + * + * @param string $type + * @return string + * @access private + */ function template ($type) { switch ($type) @@ -103,27 +103,27 @@ class Bake extends Object class %sTest extends TestCase { - var $abc; + var $abc; - // called before the tests - function setUp() - { - $this->abc = new %s (); - } + // called before the tests + function setUp() + { + $this->abc = new %s (); + } - // called after the tests - function tearDown() - { - unset($this->abc); - } + // called after the tests + function tearDown() + { + unset($this->abc); + } /* - function testFoo () - { - $result = $this->abc->Foo(); - $expected = \'\'; - $this->assertEquals($result, $expected); - } + function testFoo () + { + $result = $this->abc->Foo(); + $expected = \'\'; + $this->assertEquals($result, $expected); + } */ } @@ -133,19 +133,19 @@ class %sTest extends TestCase } } - /** - * Baker's constructor method. Initialises bakery, and starts production. - * - * @param string $type - * @param array $names - * @access public - * @uses Bake::stdin Opens stream for reading. - * @uses Bake::stdout Opens stream for writing. - * @uses Bake::stderr Opens stream for writing. - * @uses Bake::newModel() Depending on the case, can create a new model. - * @uses Bake::newView() Depending on the case, can create a new view. - * @uses Bake::newController() Depending on the case, can create a new controller. - */ + /** + * Baker's constructor method. Initialises bakery, and starts production. + * + * @param string $type + * @param array $names + * @access public + * @uses Bake::stdin Opens stream for reading. + * @uses Bake::stdout Opens stream for writing. + * @uses Bake::stderr Opens stream for writing. + * @uses Bake::newModel() Depending on the case, can create a new model. + * @uses Bake::newView() Depending on the case, can create a new view. + * @uses Bake::newController() Depending on the case, can create a new controller. + */ function __construct ($type, $names) { $this->stdin = fopen('php://stdin', 'r'); @@ -221,19 +221,19 @@ class %sTest extends TestCase } } - /** - * Creates new view in VIEWS/$controller/ directory. - * - * @param string $controller - * @param string $name - * @access private - * @uses Inflector::underscore() Underscores directory's name. - * @uses Bake::createDir() Creates new directory in views dir, named after the controller. - * @uses VIEWS - * @uses Bake::createFile() Creates view file. - * @uses Bake::template() Collects view template. - * @uses Bake::actions Adds one action for each run. - */ + /** + * Creates new view in VIEWS/$controller/ directory. + * + * @param string $controller + * @param string $name + * @access private + * @uses Inflector::underscore() Underscores directory's name. + * @uses Bake::createDir() Creates new directory in views dir, named after the controller. + * @uses VIEWS + * @uses Bake::createFile() Creates view file. + * @uses Bake::template() Collects view template. + * @uses Bake::actions Adds one action for each run. + */ function newView ($controller, $name) { $dir = Inflector::underscore($controller); @@ -245,20 +245,20 @@ class %sTest extends TestCase $this->actions++; } - /** - * Creates new controller with defined actions, controller's test and - * helper with helper's test. - * - * @param string $name - * @param array $actions - * @access private - * @uses Inflector::pluralize() - * @uses Bake::makeController() - * @uses Bake::makeControllerTest() - * @uses Bake::makeHelper() - * @uses Bake::makeHelperTest() - * @uses Bake::actions Adds one action for each run. - */ + /** + * Creates new controller with defined actions, controller's test and + * helper with helper's test. + * + * @param string $name + * @param array $actions + * @access private + * @uses Inflector::pluralize() + * @uses Bake::makeController() + * @uses Bake::makeControllerTest() + * @uses Bake::makeHelper() + * @uses Bake::makeHelperTest() + * @uses Bake::actions Adds one action for each run. + */ function newController ($name, $actions=array()) { $this->makeController($name, $actions); @@ -268,20 +268,20 @@ class %sTest extends TestCase $this->actions++; } - /** - * Creates new controller file with defined actions. - * - * @param string $name - * @param array $actions - * @return boolean - * @access private - * @uses Bake::makeControllerName() CamelCase for controller's name. - * @uses Bake::makeHelperName() CamelCase for helper's name. - * @uses Bake::template() Controller's template. - * @uses Bake::getActions() Actions' templates to be included in the controller. - * @uses Bake::createFile() Creates controller's file. - * @uses Bake::makeControllerFn() Underscored name for controller's filename. - */ + /** + * Creates new controller file with defined actions. + * + * @param string $name + * @param array $actions + * @return boolean + * @access private + * @uses Bake::makeControllerName() CamelCase for controller's name. + * @uses Bake::makeHelperName() CamelCase for helper's name. + * @uses Bake::template() Controller's template. + * @uses Bake::getActions() Actions' templates to be included in the controller. + * @uses Bake::createFile() Creates controller's file. + * @uses Bake::makeControllerFn() Underscored name for controller's filename. + */ function makeController ($name, $actions) { $ctrl = $this->makeControllerName($name); @@ -291,44 +291,44 @@ class %sTest extends TestCase return $this->createFile($this->makeControllerFn($name), $body); } - /** - * Returns controller's name in CamelCase. - * - * @param string $name - * @return string - * @access private - * @uses Inflector::camelize CamelCase for controller name. - */ + /** + * Returns controller's name in CamelCase. + * + * @param string $name + * @return string + * @access private + * @uses Inflector::camelize CamelCase for controller name. + */ function makeControllerName ($name) { return Inflector::camelize($name).'Controller'; } - /** - * Returns a name for controller's file, underscored. - * - * @param string $name - * @return string - * @access private - * @uses Inflector::underscore() Underscore for controller's file name. - */ + /** + * Returns a name for controller's file, underscored. + * + * @param string $name + * @return string + * @access private + * @uses Inflector::underscore() Underscore for controller's file name. + */ function makeControllerFn ($name) { return CONTROLLERS.Inflector::underscore($name).'_controller.php'; } - /** - * Creates new test for a controller. - * - * @param string $name - * @return boolean - * @access private - * @uses CONTROLLER_TESTS - * @uses Inflector::underscore() - * @uses Bake::getTestBody() - * @uses Bake::makeControllerName() - * @uses Bake::createFile() - */ + /** + * Creates new test for a controller. + * + * @param string $name + * @return boolean + * @access private + * @uses CONTROLLER_TESTS + * @uses Inflector::underscore() + * @uses Bake::getTestBody() + * @uses Bake::makeControllerName() + * @uses Bake::createFile() + */ function makeControllerTest ($name) { $fn = CONTROLLER_TESTS.Inflector::underscore($name).'_controller_test.php'; @@ -337,17 +337,17 @@ class %sTest extends TestCase return true; //$this->createFile($fn, $body); // Disable creating tests till later } - /** - * Creates new helper. - * - * @param string $name - * @return boolean - * @access private - * @uses Bake::template() - * @uses Bake::makeHelperName() - * @uses Bake::createFile() - * @uses Bake::makeHelperFn() - */ + /** + * Creates new helper. + * + * @param string $name + * @return boolean + * @access private + * @uses Bake::template() + * @uses Bake::makeHelperName() + * @uses Bake::createFile() + * @uses Bake::makeHelperFn() + */ function makeHelper ($name) { $body = sprintf($this->template('helper'), $this->makeHelperName($name)); @@ -355,45 +355,45 @@ class %sTest extends TestCase return $this->createFile($this->makeHelperFn($name), $body); } - /** - * Returns CamelCase name for a helper. - * - * @param string $name - * @return string - * @access private - * @uses Inflector::camelize() - */ + /** + * Returns CamelCase name for a helper. + * + * @param string $name + * @return string + * @access private + * @uses Inflector::camelize() + */ function makeHelperName ($name) { return Inflector::camelize($name).'Helper'; } - /** - * Underscores file name for a helper. - * - * @param string $name - * @return string - * @access private - * @uses HELPERS - * @uses Inflector::underscore() - */ + /** + * Underscores file name for a helper. + * + * @param string $name + * @return string + * @access private + * @uses HELPERS + * @uses Inflector::underscore() + */ function makeHelperFn ($name) { return HELPERS.Inflector::underscore($name).'_helper.php'; } - /** - * Creates new test for a helper. - * - * @param string $name - * @return boolean - * @access private - * @uses HELPER_TESTS - * @uses Inflector::underscore() - * @uses Bake::getTestBody() - * @uses Bake::makeHelperName() - * @uses Bake::createFile() - */ + /** + * Creates new test for a helper. + * + * @param string $name + * @return boolean + * @access private + * @uses HELPER_TESTS + * @uses Inflector::underscore() + * @uses Bake::getTestBody() + * @uses Bake::makeHelperName() + * @uses Bake::createFile() + */ function makeHelperTest ($name) { $fn = HELPER_TESTS.Inflector::underscore($name).'_helper_test.php'; @@ -402,14 +402,14 @@ class %sTest extends TestCase return $this->createFile($fn, $body); } - /** - * Returns an array of actions' templates. - * - * @param array $as - * @return array - * @access private - * @uses Bake::template() - */ + /** + * Returns an array of actions' templates. + * + * @param array $as + * @return array + * @access private + * @uses Bake::template() + */ function getActions ($as) { $out = array(); @@ -420,44 +420,44 @@ class %sTest extends TestCase return $out; } - /** - * Returns a test template for given class. - * - * @param string $class - * @return string - * @access private - * @uses Bake::template() - */ + /** + * Returns a test template for given class. + * + * @param string $class + * @return string + * @access private + * @uses Bake::template() + */ function getTestBody ($class) { return sprintf($this->template('test'), $class, $class); } - /** - * Creates new model. - * - * @param string $name - * @access private - * @uses Bake::createFile() - * @uses Bake::getModelFn() - * @uses Bake::template() - * @uses Bake::getModelName() - * @uses Bake::makeModelTest() - * @uses Bake::actions - */ + /** + * Creates new model. + * + * @param string $name + * @access private + * @uses Bake::createFile() + * @uses Bake::getModelFn() + * @uses Bake::template() + * @uses Bake::getModelName() + * @uses Bake::makeModelTest() + * @uses Bake::actions + */ function newModel ($name) { $nameSingular = Inflector::singularize($name); if ($nameSingular != $name) { - fwrite($this->stdout, "I use singular Model names. You entered '$name'. I can inflect it to '$nameSingular'. Should I? If no, I will use '$name'. [y/n/q] "); + fwrite($this->stdout, "I use singular Model names. You entered '$name'. I can inflect it to '$nameSingular'. Should I? If no, I will use '$name'. [y/n/q] "); $key = trim(fgets($this->stdin)); - } - else - { - $key = 'n'; - } + } + else + { + $key = 'n'; + } if ($key=='q') { @@ -475,32 +475,32 @@ class %sTest extends TestCase $this->actions++; } - /** - * Returns an underscored filename for a model. - * - * @param string $name - * @return string - * @access private - * @uses MODELS - * @uses Inflector::underscore() - */ + /** + * Returns an underscored filename for a model. + * + * @param string $name + * @return string + * @access private + * @uses MODELS + * @uses Inflector::underscore() + */ function getModelFn ($name) { return MODELS.Inflector::underscore($name).'.php'; } - /** - * Creates a test for a given model. - * - * @param string $name - * @return boolean - * @access private - * @uses MODEL_TESTS - * @uses Inflector::underscore() - * @uses Bake::getTestBody() - * @uses Bake::getModelName() - * @uses Bake::createFile() - */ + /** + * Creates a test for a given model. + * + * @param string $name + * @return boolean + * @access private + * @uses MODEL_TESTS + * @uses Inflector::underscore() + * @uses Bake::getTestBody() + * @uses Bake::getModelName() + * @uses Bake::createFile() + */ function makeModelTest ($name) { $fn = MODEL_TESTS.Inflector::underscore($name).'_test.php'; @@ -509,31 +509,31 @@ class %sTest extends TestCase return $this->createFile($fn, $body); } - /** - * Returns CamelCased name of a model. - * - * @param string $name - * @return string - * @access private - * @uses Inflector::camelize() - */ + /** + * Returns CamelCased name of a model. + * + * @param string $name + * @return string + * @access private + * @uses Inflector::camelize() + */ function getModelName ($name) { return Inflector::camelize($name); } - /** - * Creates a file with given path and contents. - * - * @param string $path - * @param string $contents - * @return boolean - * @access private - * @uses Bake::dontAsk - * @uses Bake::stdin - * @uses Bake::stdout - * @uses Bake::stderr - */ + /** + * Creates a file with given path and contents. + * + * @param string $path + * @param string $contents + * @return boolean + * @access private + * @uses Bake::dontAsk + * @uses Bake::stdin + * @uses Bake::stdout + * @uses Bake::stderr + */ function createFile ($path, $contents) { echo "\nCreating file $path\n"; @@ -568,26 +568,26 @@ class %sTest extends TestCase fwrite($f, $contents); fclose($f); fwrite($this->stdout, "Wrote {$shortPath}\n"); - // debug ("Wrote {$path}"); + // 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 - * @return boolean - * @access private - * @uses Bake::stdin - * @uses Bake::stdout - */ + /** + * Creates a directory with given path. + * + * @param string $path + * @return boolean + * @access private + * @uses Bake::stdin + * @uses Bake::stdout + */ function createDir ($path) { if (is_dir($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 d892c0f54..75fdb59d2 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -3,20 +3,20 @@ /** * Caching for Cake. - * - * + * + * * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -33,12 +33,14 @@ * Included libraries. * */ -uses(DS.'model'.DS.'model'); - +if(!class_exists('Model', FALSE)) +{ + uses(DS.'model'.DS.'model'); +} /** * Caching for Cake. - * - * + * + * * * @package cake * @subpackage cake.cake.libs @@ -46,114 +48,114 @@ uses(DS.'model'.DS.'model'); */ class Cache extends Model { - /** - * Identifier. Either an MD5 string or NULL. - * - * @var string - */ - var $id = null; + /** + * Identifier. Either an MD5 string or NULL. + * + * @var string + */ + var $id = null; - /** - * Content container for cache data. - * - * @var unknown_type - */ - var $data = null; + /** + * Content container for cache data. + * + * @var unknown_type + */ + var $data = null; - /** - * Content to be cached. - * - * @var unknown_type - */ - var $for_caching = null; + /** + * Content to be cached. + * + * @var unknown_type + */ + var $for_caching = null; - /** - * Name of the database table used for caching. - * - * @var string - */ - var $useTable = 'cache'; + /** + * 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 - */ - function __construct ($id) - { - $this->id = (md5($id)); - parent::__construct($this->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 - */ - function id ($id=null) - { - if (!$id) return $this->id; - return ($this->id = $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 + */ + 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 - */ - function remember ($content, $keep_for=CACHE_PAGES_FOR) - { - $data = addslashes($this->for_caching.$content); - $expire = date("Y-m-d H:i:s",time()+($keep_for>0? $keep_for: 999999999)); - return $this->query("REPLACE {$this->useTable} (id,data,expire) VALUES ('{$this->id}', '{$data}', '{$expire}')"); - } + /** + * 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); + $expire = date("Y-m-d H:i:s",time()+($keep_for>0? $keep_for: 999999999)); + 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 - */ - function restore() - { - if (empty($this->data['data'])) - return $this->find("id='{$this->id}' AND expire>NOW()"); + /** + * 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'])) + return $this->find("id='{$this->id}' AND expire>NOW()"); - return $this->data['data']; - } + return $this->data['data']; + } - /** - * 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()")); - } + /** + * 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 - */ - function append($string) - { - $this->for_caching .= $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 - */ - function clear() - { - return $this->query("DELETE FROM {$this->useTable}"); - } + /** + * Clears the cache database table. + * + * @return unknown + */ + function clear() + { + return $this->query("DELETE FROM {$this->useTable}"); + } } ?> \ No newline at end of file diff --git a/cake/libs/class_registry.php b/cake/libs/class_registry.php index 9ee2805cf..d3ba2b5d8 100644 --- a/cake/libs/class_registry.php +++ b/cake/libs/class_registry.php @@ -84,8 +84,8 @@ /** * Returns true if given key is present in the ClassRegistry. * - * @param string $key Key to look for - * @return boolean Success + * @param string $key Key to look for + * @return boolean Success */ function isKeySet($key) { diff --git a/cake/libs/controller/component.php b/cake/libs/controller/component.php index 7d7ea7a47..7aa454ea5 100644 --- a/cake/libs/controller/component.php +++ b/cake/libs/controller/component.php @@ -2,19 +2,19 @@ /* SVN FILE: $Id$ */ /** - * + * * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -26,11 +26,6 @@ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ -/** - * Enter description here... - */ -uses('object'); - /** * * @@ -47,7 +42,7 @@ class Component extends Object * @var unknown_type */ var $components = array(); - + /** * Enter description here... * @@ -95,7 +90,7 @@ class Component extends Object if(in_array($component, array_keys($loaded)) !== true) { $componentFn = Inflector::underscore($component).'.php'; - + if(file_exists(COMPONENTS.$componentFn)) { $componentFn = COMPONENTS.$componentFn; @@ -104,16 +99,24 @@ class Component extends Object { $componentFn = LIBS.'controller'.DS.'components'.DS.$componentFn; } - + $componentCn = $component.'Component'; - + if (is_file($componentFn)) { require_once $componentFn; - - if(class_exists($componentCn)===true) + + if(class_exists($componentCn, FALSE)===true) { - $this->controller->{$component} =& new $componentCn; + if($componentCn == 'SessionComponent') + { + $param = $this->controller->base.'/'; + } + else + { + $param = null; + } + $this->controller->{$component} =& new $componentCn($param); $loaded[$component] =& $this->controller->{$component}; if (isset($this->controller->{$component}->components) && is_array($this->controller->{$component}->components)) { diff --git a/cake/libs/controller/components/dbacl/models/aclnode.php b/cake/libs/controller/components/dbacl/models/aclnode.php index b257c5c68..6c7b7ee42 100644 --- a/cake/libs/controller/components/dbacl/models/aclnode.php +++ b/cake/libs/controller/components/dbacl/models/aclnode.php @@ -44,7 +44,7 @@ require_once(CAKE . 'app_model.php'); * */ class AclNode extends AppModel -{ +{ /** * Enter description here... diff --git a/cake/libs/controller/components/dbacl/models/aco.php b/cake/libs/controller/components/dbacl/models/aco.php index 09df6797a..b2691057f 100644 --- a/cake/libs/controller/components/dbacl/models/aco.php +++ b/cake/libs/controller/components/dbacl/models/aco.php @@ -39,7 +39,7 @@ * */ class Aco extends AclNode -{ +{ var $name = 'Aco'; /** * Enter description here... diff --git a/cake/libs/controller/components/iniacl/ini_acl.php b/cake/libs/controller/components/iniacl/ini_acl.php index 078d0be45..d5d2e6892 100644 --- a/cake/libs/controller/components/iniacl/ini_acl.php +++ b/cake/libs/controller/components/iniacl/ini_acl.php @@ -129,46 +129,46 @@ class INI_ACL extends AclBase */ function readConfigFile ($fileName) { - $fileLineArray = file($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; + 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; } /** diff --git a/cake/libs/controller/components/session.php b/cake/libs/controller/components/session.php index 91a73177b..c96b1af63 100644 --- a/cake/libs/controller/components/session.php +++ b/cake/libs/controller/components/session.php @@ -3,20 +3,20 @@ /** * Short description for file. - * + * * Long description for file * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -45,9 +45,9 @@ class SessionComponent extends Object * Enter description here... * */ - function __construct () + function __construct ($base = null) { - $this->CakeSession = New CakeSession(); + $this->CakeSession = New CakeSession($base); parent::__construct(); } diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index fb29d986e..7dbd9a23f 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -7,7 +7,7 @@ * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, Cake Software Foundation, Inc. * 1785 E. Sahara Avenue, Suite 490-204 * Las Vegas, Nevada 89104 * @@ -29,7 +29,7 @@ /** * Include files */ -uses(DS.'controller'.DS.'component',DS.'model'.DS.'model', 'inflector', 'folder', DS.'view'.DS.'view'); +uses(DS.'controller'.DS.'component', DS.'view'.DS.'view'); /** * Controller @@ -414,14 +414,14 @@ class Controller extends Object $this->set('pause', $pause); $this->set('page_title', $message); - if(file_exists(VIEWS.'layouts'.DS.'flash.thtml')) - { - $flash = VIEWS.'layouts'.DS.'flash.thtml'; - } - else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml')) - { - $flash = LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml'; - } + if(file_exists(VIEWS.'layouts'.DS.'flash.thtml')) + { + $flash = VIEWS.'layouts'.DS.'flash.thtml'; + } + else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml')) + { + $flash = LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml'; + } @@ -458,93 +458,93 @@ class Controller extends Object * @todo View the database field types from all the supported databases. * */ - function generateFieldNames( $data = null, $doCreateOptions = true ) - { - $fieldNames = array(); + function generateFieldNames( $data = null, $doCreateOptions = true ) + { + $fieldNames = array(); - $model = $this->modelClass; - $modelKey = $this->modelKey; - $table = $this->{$model}->table; - $association = array_search($table,$this->{$model}->alias); + $model = $this->modelClass; + $modelKey = $this->modelKey; + $table = $this->{$model}->table; + $association = array_search($table,$this->{$model}->alias); - $classRegistry =& ClassRegistry::getInstance(); - $objRegistryModel = $classRegistry->getObject($modelKey); + $classRegistry =& ClassRegistry::getInstance(); + $objRegistryModel = $classRegistry->getObject($modelKey); - foreach ($objRegistryModel->_tableInfo as $tables) - { - foreach ($tables as $tabl) - { - $alias = null; - // set up the prompt - if( $objRegistryModel->isForeignKey($tabl['name']) ) - { - $niceName = substr( $tabl['name'], 0, strpos( $tabl['name'], "_id" ) ); - $fieldNames[ $tabl['name'] ]['prompt'] = Inflector::humanize($niceName); - // this is a foreign key, also set up the other controller - $fieldNames[ $tabl['name'] ]['table'] = Inflector::pluralize($niceName); - $association = array_search($fieldNames[ $tabl['name'] ]['table'],$this->{$model}->alias); - if($this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']] == $model) - { - $alias = 'Child_'; - } - $fieldNames[ $tabl['name'] ]['prompt'] = Inflector::humanize($alias.$niceName); - $fieldNames[ $tabl['name'] ]['model'] = $alias.$association; - $fieldNames[ $tabl['name'] ]['modelKey'] = $this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']]; - $fieldNames[ $tabl['name'] ]['controller'] = Inflector::pluralize($this->{$model}->tableToModel[Inflector::pluralize($niceName)]); - $fieldNames[ $tabl['name'] ]['foreignKey'] = true; - } - else if( 'created' != $tabl['name'] && 'updated' != $tabl['name'] ) - { - $fieldNames[$tabl['name']]['prompt'] = Inflector::humanize($tabl['name']); - } - else if( 'created' == $tabl['name'] ) - { - $fieldNames[$tabl['name']]['prompt'] = 'Created'; - } - else if( 'updated' == $tabl['name'] ) - { - $fieldNames[$tabl['name']]['prompt'] = 'Modified'; - } + foreach ($objRegistryModel->_tableInfo as $tables) + { + foreach ($tables as $tabl) + { + $alias = null; + // set up the prompt + if( $objRegistryModel->isForeignKey($tabl['name']) ) + { + $niceName = substr( $tabl['name'], 0, strpos( $tabl['name'], "_id" ) ); + $fieldNames[ $tabl['name'] ]['prompt'] = Inflector::humanize($niceName); + // this is a foreign key, also set up the other controller + $fieldNames[ $tabl['name'] ]['table'] = Inflector::pluralize($niceName); + $association = array_search($fieldNames[ $tabl['name'] ]['table'],$this->{$model}->alias); + if($this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']] == $model) + { + $alias = 'Child_'; + } + $fieldNames[ $tabl['name'] ]['prompt'] = Inflector::humanize($alias.$niceName); + $fieldNames[ $tabl['name'] ]['model'] = $alias.$association; + $fieldNames[ $tabl['name'] ]['modelKey'] = $this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']]; + $fieldNames[ $tabl['name'] ]['controller'] = Inflector::pluralize($this->{$model}->tableToModel[Inflector::pluralize($niceName)]); + $fieldNames[ $tabl['name'] ]['foreignKey'] = true; + } + else if( 'created' != $tabl['name'] && 'updated' != $tabl['name'] ) + { + $fieldNames[$tabl['name']]['prompt'] = Inflector::humanize($tabl['name']); + } + else if( 'created' == $tabl['name'] ) + { + $fieldNames[$tabl['name']]['prompt'] = 'Created'; + } + else if( 'updated' == $tabl['name'] ) + { + $fieldNames[$tabl['name']]['prompt'] = 'Modified'; + } - // Now, set up some other attributes that will be useful for auto generating a form. - //tagName is in the format table/field "post/title" - $fieldNames[ $tabl['name']]['tagName'] = $model.'/'.$tabl['name']; + // Now, set up some other attributes that will be useful for auto generating a form. + //tagName is in the format table/field "post/title" + $fieldNames[ $tabl['name']]['tagName'] = $model.'/'.$tabl['name']; - // Now, find out if this is a required field. - //$validationFields = $classRegistry->getObject($table)->validate; - $validationFields = $objRegistryModel->validate; - if( isset( $validationFields[ $tabl['name'] ] ) ) - { - // Now, we know that this field has some validation set. - // find out if it is a required field. - if( VALID_NOT_EMPTY == $validationFields[ $tabl['name'] ] ) - { - // this is a required field. - $fieldNames[$tabl['name']]['required'] = true; - $fieldNames[$tabl['name']]['errorMsg'] = "Required Field"; - } - } + // Now, find out if this is a required field. + //$validationFields = $classRegistry->getObject($table)->validate; + $validationFields = $objRegistryModel->validate; + if( isset( $validationFields[ $tabl['name'] ] ) ) + { + // Now, we know that this field has some validation set. + // find out if it is a required field. + if( VALID_NOT_EMPTY == $validationFields[ $tabl['name'] ] ) + { + // this is a required field. + $fieldNames[$tabl['name']]['required'] = true; + $fieldNames[$tabl['name']]['errorMsg'] = "Required Field"; + } + } - // now, determine what the input type should be for this database field. - $lParenPos = strpos( $tabl['type'], '('); - $rParenPos = strpos( $tabl['type'], ')'); - if( false != $lParenPos ) - { - $type = substr($tabl['type'], 0, $lParenPos ); - $fieldLength = substr( $tabl['type'], $lParenPos+1, $rParenPos - $lParenPos -1 ); - } - else - { - $type = $tabl['type']; - } - switch( $type ) - { + // now, determine what the input type should be for this database field. + $lParenPos = strpos( $tabl['type'], '('); + $rParenPos = strpos( $tabl['type'], ')'); + if( false != $lParenPos ) + { + $type = substr($tabl['type'], 0, $lParenPos ); + $fieldLength = substr( $tabl['type'], $lParenPos+1, $rParenPos - $lParenPos -1 ); + } + else + { + $type = $tabl['type']; + } + switch( $type ) + { - case "text": - case "mediumtext": - { - $fieldNames[ $tabl['name']]['type'] = 'area'; - //$fieldNames[ $tabl['name']]['size'] = $fieldLength; + case "text": + case "mediumtext": + { + $fieldNames[ $tabl['name']]['type'] = 'area'; + //$fieldNames[ $tabl['name']]['size'] = $fieldLength; } break; case "varchar": @@ -672,6 +672,14 @@ class Controller extends Object { if( 0 != strncmp( "created", $tabl['name'], 6 ) && 0 != strncmp("modified",$tabl['name'], 8) ) $fieldNames[ $tabl['name']]['type'] = $type; + if(isset($data[$model][$tabl['name']])) + { + $fieldNames[ $tabl['name']]['selected'] = $data[$model][$tabl['name']]; + } + else + { + $fieldNames[ $tabl['name']]['selected'] = null; + } } break; default: @@ -679,11 +687,11 @@ class Controller extends Object break; - } // end switch + } // end switch } - // now, add any necessary hasAndBelongsToMany list boxes - // loop through the many to many relations to make a list box. - foreach( $objRegistryModel->_manyToMany as $relation ) + // now, add any necessary hasAndBelongsToMany list boxes + // loop through the many to many relations to make a list box. + foreach( $objRegistryModel->_manyToMany as $relation ) { //list($modelName) = $relation; list($manyAssociation, $modelName, $value) = $relation; @@ -717,10 +725,10 @@ class Controller extends Object } } } // end loop through manytomany relations. - } + } return $fieldNames; - } + } } ?> \ No newline at end of file diff --git a/cake/libs/controller/pages_controller.php b/cake/libs/controller/pages_controller.php index 4bbd64ea7..e9af9bd8f 100644 --- a/cake/libs/controller/pages_controller.php +++ b/cake/libs/controller/pages_controller.php @@ -3,21 +3,21 @@ /** * Short description for file. - * - * This file is application-wide controller file. You can put all + * + * This file is application-wide controller file. You can put all * application-wide controller-related methods here. * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -33,24 +33,24 @@ /** * Short description for class. * - * This file is application-wide controller file. You can put all + * This file is application-wide controller file. You can put all * application-wide controller-related methods here. * - * Add your application-wide methods in the class below, your controllers + * Add your application-wide methods in the class below, your controllers * will inherit them. - * + * * @package cake * @subpackage cake.cake.libs.controller */ class PagesController extends AppController{ - + /** * Enter description here... * * @var unknown_type */ - var $helpers = array('html', 'ajax'); - + var $helpers = array('Html'); + /** * Displays a view @@ -64,7 +64,7 @@ class PagesController extends AppController{ } $path = func_get_args(); - + if (!count($path)) { $this->redirect('/'); diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index ad63d0ca0..c92521fab 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -9,14 +9,14 @@ * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -28,11 +28,6 @@ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ -/** - * Included libs. - */ -uses(DS.'model'.DS.'model', 'inflector', 'object'); - /** * Scaffolding is a set of automatic views, forms and controllers for starting web development work faster. * @@ -101,6 +96,7 @@ class Scaffold extends Object { $this->actionView = $controller->action; $this->modelKey = Inflector::singularize($controller->name); $this->scaffoldTitle = Inflector::humanize($this->modelKey); + $this->viewPath = Inflector::underscore($controller->name); $this->controllerClass->pageTitle = $this->scaffoldTitle; $this->_renderScaffold($params); } @@ -142,6 +138,10 @@ class Scaffold extends Object { $this->controllerClass->params['data'] = $this->controllerClass->{$this->modelKey}->read(); $this->controllerClass->set('data', $this->controllerClass->params['data'] ); $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames( $this->controllerClass->params['data'], false ) ); + if(file_exists(APP.'views'.DS.$this->viewPath.DS.'scaffold.show.thtml')) + { + return $this->controllerClass->render($this->actionView, '', APP.'views'.DS.$this->viewPath.DS.'scaffold.show.thtml'); + } return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'show.thtml'); } @@ -156,6 +156,10 @@ class Scaffold extends Object { { $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(null,false) ); $this->controllerClass->set('data', $this->controllerClass->{$this->modelKey}->findAll()); + if(file_exists(APP.'views'.DS.$this->viewPath.DS.'scaffold.list.thtml')) + { + return $this->controllerClass->render($this->actionView, '', APP.'views'.DS.$this->viewPath.DS.'scaffold.list.thtml'); + } return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml'); } @@ -169,7 +173,12 @@ class Scaffold extends Object { function _scaffoldNew($params) { $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() ); - return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); + $this->controllerClass->set('type', 'New'); + if(file_exists(APP.'views'.DS.$this->viewPath.DS.'scaffold.new.thtml')) + { + return $this->controllerClass->render($this->actionView, '', APP.'views'.DS.$this->viewPath.DS.'scaffold.new.thtml'); + } + return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml'); } /** @@ -179,11 +188,16 @@ class Scaffold extends Object { * @return A rendered view with a form to edit a record in the Models database table * @access private */ - function _scaffoldEdit($params) + function _scaffoldEdit($params=array()) { $this->controllerClass->params['data'] = $this->controllerClass->{$this->modelKey}->read(); $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames($this->controllerClass->params['data']) ); + $this->controllerClass->set('type', 'Edit'); $this->controllerClass->set('data', $this->controllerClass->params['data']); + if(file_exists(APP.'views'.DS.$this->viewPath.DS.'scaffold.edit.thtml')) + { + return $this->controllerClass->render($this->actionView, '', APP.'views'.DS.$this->viewPath.DS.'scaffold.edit.thtml'); + } return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml'); } @@ -227,7 +241,12 @@ class Scaffold extends Object { } $this->controllerClass->set('data', $this->controllerClass->params['data']); $this->controllerClass->validateErrors($this->controllerClass->{$this->modelKey}); - return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); + $this->controllerClass->set('type', 'New'); + if(file_exists(APP.'views'.DS.$this->viewPath.DS.'scaffolds'.DS.'new.thtml')) + { + return $this->controllerClass->render($this->actionView, '', APP.'views'.DS.$this->viewPath.DS.'scaffolds'.DS.'new.thtml'); + } + return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml'); } } @@ -244,8 +263,9 @@ class Scaffold extends Object { { return $this->_scaffoldNew($params); } - + $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() ); $this->_cleanUpFields(); + $this->controllerClass->{$this->modelKey}->set($this->controllerClass->params['data']); if ( $this->controllerClass->{$this->modelKey}->save()) @@ -266,15 +286,12 @@ class Scaffold extends Object { { if(is_object($this->controllerClass->Session)) { - $this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' has been updated.','/'); - $this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath)); - - } - else - { - return $this->controllerClass->flash('There was an error updating the '.Inflector::humanize($this->modelKey),'/'. - Inflector::underscore($this->controllerClass->viewPath)); + $this->controllerClass->Session->setFlash('Please correct errors below'); } + $this->controllerClass->validateErrors($this->controllerClass->{$this->modelKey}); + $this->controllerClass->set('data', $this->controllerClass->params['data']); + $this->controllerClass->set('type', 'Edit'); + return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml'); } } @@ -415,11 +432,9 @@ class Scaffold extends Object { { if('date' == $field['type'] && isset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'])) { - $newDate = mktime( 0,0,0, - $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month'], - $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day'], - $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'] ); - $newDate = date( 'Y-m-d', $newDate ); + $newDate = $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'].'-'; + $newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month'].'-'; + $newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day'].' '; $this->controllerClass->params['data'][$this->modelKey][$field['name']] = $newDate; } else if( 'datetime' == $field['type'] && isset($this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'] ) ) @@ -429,12 +444,10 @@ class Scaffold extends Object { { $hour = $hour + 12; } - $newDate = mktime( $hour, - $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_min'],0, - $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month'], - $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day'], - $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'] ); - $newDate = date( 'Y-m-d H:i:s', $newDate ); + $newDate = $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_year'].'-'; + $newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_month'].'-'; + $newDate .= $this->controllerClass->params['data'][$this->modelKey][$field['name'].'_day'].' '; + $newDate .= $hour.':'.$this->controllerClass->params['data'][$this->modelKey][$field['name'].'_min'].':00'; $this->controllerClass->params['data'][$this->modelKey][$field['name']] = $newDate; } else if( 'tinyint(1)' == $field['type'] ) diff --git a/cake/libs/file.php b/cake/libs/file.php index f682f7612..641008b16 100644 --- a/cake/libs/file.php +++ b/cake/libs/file.php @@ -3,19 +3,19 @@ /** * Convenience class for reading, writing and appending to files. - * + * * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -31,7 +31,10 @@ * Included libraries. * */ -uses('object'); +if(!class_exists('Object', FALSE)) +{ + uses('object'); +} /** * Convenience class for reading, writing and appending to files. @@ -109,10 +112,10 @@ class File extends Object } /** - * Write given data to this File. + * Write given data to this File. * - * @param string $data Data to write to this File. - * @param string $mode Mode of writing. {@link http://php.net/fwrite See fwrite()}. + * @param string $data Data to write to this File. + * @param string $mode Mode of writing. {@link http://php.net/fwrite See fwrite()}. * @return boolean Success */ function write ($data, $mode = 'w') @@ -136,7 +139,7 @@ class File extends Object /** * Get md5 Checksum of file with previous check of Filesize * - * @param string $force Data to write to this File. + * @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) @@ -153,7 +156,7 @@ class File extends Object /** * Returns the Filesize, either in bytes or in human-readable format. * - * @param boolean $humanReadeble Data to write to this File. + * @param boolean $humanReadeble Data to write to this File. * @return string|int filesize as int or as a human-readable string */ function getSize () @@ -343,4 +346,4 @@ class File extends Object } } -?> +?> \ No newline at end of file diff --git a/cake/libs/flay.php b/cake/libs/flay.php index b84db8245..6c93761d3 100644 --- a/cake/libs/flay.php +++ b/cake/libs/flay.php @@ -3,20 +3,20 @@ /** * Text-to-HTML parser. - * + * * Text-to-html parser, similar to {@link http://textism.com/tools/textile/ Textile} or {@link http://www.whytheluckystiff.net/ruby/redcloth/ RedCloth}. * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -30,13 +30,16 @@ /** * Included libraries. + * */ -uses('object'); - +if(!class_exists('Object', FALSE)) +{ + uses('object'); +} /** * Text-to-HTML parser. * - * Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax. + * Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax. * * @package cake * @subpackage cake.cake.libs @@ -64,21 +67,21 @@ class Flay extends Object * * @param string $text */ - function __construct ($text=null) + function __construct ($text=null) { $this->text = $text; parent::__construct(); } /** - * Returns given text translated to HTML using the Flay syntax. + * 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 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) + function toHtml ($text=null, $bare=false, $allowHtml=false) { if (empty($text) && empty($this->text)) @@ -98,7 +101,7 @@ class Flay extends Object $text = str_replace('<', '<', str_replace('>', '>', trim($text))); } - if (!$bare) + if (!$bare) { // 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); @@ -112,20 +115,20 @@ class Flay extends Object // split into paragraphs and parse $out = ''; - foreach (split('%PARAGRAPH%', $text) as $line) + foreach (split('%PARAGRAPH%', $text) as $line) { - - if ($line) + + if ($line) { - if (!$bare) + if (!$bare) { // pre-parse links $links = array(); $regs = null; - if (preg_match_all('#\[([^\[]{4,})\]#', $line, $regs)) + if (preg_match_all('#\[([^\[]{4,})\]#', $line, $regs)) { - foreach ($regs[1] as $reg) + foreach ($regs[1] as $reg) { $links[] = $reg; $line = str_replace("[{$reg}]",'%LINK'.(count($links)-1).'%', $line); @@ -148,47 +151,47 @@ class Flay extends Object // 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)) + 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) + if (!$bare) { // guess links $urls = null; - if (preg_match_all("#((?:http|https|ftp|nntp)://[^ ]+)#", $line, $urls)) + if (preg_match_all("#((?:http|https|ftp|nntp)://[^ ]+)#", $line, $urls)) { - foreach ($urls[1] as $url) + foreach ($urls[1] as $url) { $line = str_replace($url, "{$url}", $line); } } if (preg_match_all("#(www\.[^\n\%\ ]+[^\n\%\,\.\ ])#", $line, $urls)) { - foreach ($urls[1] as $url) + foreach ($urls[1] as $url) { $line = str_replace($url, "{$url}", $line); } } - + // re-parse links - if (count($links)) - { - for ($ii=0; $ii"; @@ -205,13 +208,13 @@ class Flay extends Object { $body = $regs[2]; } - + } - else + else { $body = $links[$ii]; } - + $with = "{$body}"; } else @@ -223,13 +226,13 @@ class Flay extends Object } } } - + // re-parse newlines $out .= str_replace('%LINEBREAK%', "
\n", "

{$line}

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

%BLOCKQUOTE%

', "
", $out); @@ -247,7 +250,7 @@ class Flay extends Object * @param string $string * @return array Array of words */ - function extractWords ($string) + function extractWords ($string) { return preg_split('/[\s,\.:\/="!\(\)<>~\[\]]+/', $string); } @@ -255,22 +258,22 @@ class Flay extends Object /** * Return given string with words in array colorMarked, up to a number of times (defaults to 5). * - * @param array $words Words to look for and markup - * @param string $string String to look in - * @param integer $max_snippets Max number of snippets to extract + * @param array $words Words to look for and markup + * @param string $string String to look in + * @param integer $max_snippets Max number of snippets to extract * @return string * @see colorMark */ - function markedSnippets ($words, $string, $max_snippets=5) + function markedSnippets ($words, $string, $max_snippets=5) { $string = strip_tags($string); $snips = array(); $rest = $string; - foreach ($words as $word) + foreach ($words as $word) { - if (preg_match_all("/[\s,]+.{0,40}{$word}.{0,40}[\s,]+/i", $rest, $r)) + if (preg_match_all("/[\s,]+.{0,40}{$word}.{0,40}[\s,]+/i", $rest, $r)) { foreach ($r as $result) { @@ -280,9 +283,9 @@ class Flay extends Object } } - if (count($snips) > $max_snippets) + 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) . '...'; @@ -293,16 +296,16 @@ class Flay extends Object /** * Returns string with EM elements with color classes added. * - * @param array $words Array of words to be colorized - * @param string $string Text in which the words might be found - * @return string + * @param array $words Array of words to be colorized + * @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; - foreach ($words as $word) + foreach ($words as $word) { $string = preg_replace("/({$word})/i", '\\1", $string); $nextColorIndex++; @@ -310,24 +313,24 @@ class Flay extends Object return $string; } - + /** * Returns given text with tags stripped out. * * @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. * * @param string $text * @return string - */ + */ function toParsedAndClean ($text) { return Flay::toClean(Flay::toHtml($text)); @@ -336,21 +339,21 @@ class Flay extends Object /** * Return a fragment of a text, up to $length characters long, with an ellipsis after it. * - * @param string $text Text to be truncated. - * @param integer $length Max length of text. - * @param string $ellipsis Sign to print after truncated text. + * @param string $text Text to be truncated. + * @param integer $length Max length of text. + * @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,\.:\/="!\(\)<>~\[\]]+.*/'; - if (preg_match($rx, $text, $r)) + if (preg_match($rx, $text, $r)) { $out = $r[1]; } - else + else { $out = substr($text, 0, $length); } diff --git a/cake/libs/folder.php b/cake/libs/folder.php index 2c3b9dc22..230220a80 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -3,19 +3,19 @@ /** * Convenience class for handling directories. - * + * * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -28,11 +28,13 @@ */ /** - * Included libraries. - * - */ -uses('object'); - + * Included libraries. + * + */ +if(!class_exists('Object', FALSE)) +{ + uses('object'); +} /** * Folder structure browser, lists folders and files. * @@ -106,7 +108,7 @@ class Folder extends Object { /** - * Returns an array of the contents of the current directory, or false on failure. + * 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 @@ -230,8 +232,8 @@ class Folder extends Object { * Returns true if given $path is a Windows path. * * @param string $path Path to check - * @return boolean - * @static + * @return boolean + * @static */ function isWindowsPath ($path) { @@ -242,8 +244,8 @@ class Folder extends Object { * Returns true if given $path is an absolute path. * * @param string $path Path to check - * @return boolean - * @static + * @return boolean + * @static */ function isAbsolute ($path) { @@ -255,7 +257,7 @@ class Folder extends Object { * * @param string $path Path to check * @return boolean - * @static + * @static */ function isSlashTerm ($path) { @@ -267,7 +269,7 @@ class Folder extends Object { * * @param string $path Path to check * @return string Set of slashes ("\\" or "/") - * @static + * @static */ function correctSlashFor ($path) { @@ -279,7 +281,7 @@ class Folder extends Object { * * @param string $path Path to check * @return string - * @static + * @static */ function slashTerm ($path) { @@ -292,7 +294,7 @@ class Folder extends Object { * @param string $path * @param string $element * @return string - * @static + * @static */ function addPathElement ($path, $element) { diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index b8237ba4d..aa7104a2f 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -3,20 +3,20 @@ /** * Pluralize and singularize English words. - * + * * Used by Cake's naming conventions throughout the framework. * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -28,10 +28,18 @@ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ +/** + * Included libraries. + * + */ +if(!class_exists('Object', FALSE)) +{ + uses('object'); +} /** * Pluralize and singularize English words. * - * Inflector pluralizes and singularizes English nouns. + * Inflector pluralizes and singularizes English nouns. * Used by Cake's naming conventions throughout the framework. * Test with $i = new Inflector(); $i->test(); * @@ -39,31 +47,31 @@ * @subpackage cake.cake.libs * @since CakePHP v 0.2.9 */ -class Inflector extends Object +class Inflector extends Object { - + /** * Constructor. * */ - function __construct () + function __construct () { parent::__construct(); } - + /** * Return $word in plural form. * * @param string $word Word in singular * @return string Word in plural */ - function pluralize ($word) + function pluralize ($word) { $plural_rules = array( '/(s)tatus$/' => '\1\2tatuses', - '/^(ox)$/' => '\1\2en', # ox - '/([m|l])ouse$/' => '\1ice', # mouse, louse - '/(matr|vert|ind)ix|ex$/' => '\1ices', # matrix, vertex, index + '/^(ox)$/' => '\1\2en', # ox + '/([m|l])ouse$/' => '\1ice', # mouse, louse + '/(matr|vert|ind)ix|ex$/' => '\1ices', # matrix, vertex, index '/(x|ch|ss|sh)$/' => '\1es', # search, switch, fix, box, process, address '/([^aeiouy]|qu)y$/' => '\1ies', # query, ability, agency '/(hive)$/' => '\1s', # archive, hive @@ -73,23 +81,23 @@ class Inflector extends Object '/(p)erson$/' => '\1eople', # person, salesperson '/(m)an$/' => '\1en', # man, woman, spokesman '/(c)hild$/' => '\1hildren', # child - '/(buffal|tomat)o$/' => '\1\2oes', # buffalo, tomato - '/(bu)s$/' => '\1\2ses', # bus + '/(buffal|tomat)o$/' => '\1\2oes', # buffalo, tomato + '/(bu)s$/' => '\1\2ses', # bus '/(alias)/' => '\1es', # alias - '/(octop|vir)us$/' => '\1i', # octopus, virus - virus has no defined plural (according to Latin/dictionary.com), but viri is better than viruses/viruss - '/(ax|cri|test)is$/' => '\1es', # axis, crisis + '/(octop|vir)us$/' => '\1i', # octopus, virus - virus has no defined plural (according to Latin/dictionary.com), but viri is better than viruses/viruss + '/(ax|cri|test)is$/' => '\1es', # axis, crisis '/s$/' => 's', # no change (compatibility) '/$/' => 's' ); - - foreach ($plural_rules as $rule => $replacement) + + foreach ($plural_rules as $rule => $replacement) { - if (preg_match($rule, $word)) + if (preg_match($rule, $word)) { return preg_replace($rule, $replacement, $word); } } - + return $word;//false; } @@ -104,15 +112,15 @@ class Inflector extends Object $singular_rules = array( '/(s)tatuses$/' => '\1\2tatus', '/(matr)ices$/' =>'\1ix', - '/(vert|ind)ices$/' => '\1ex', - '/^(ox)en/' => '\1', - '/(alias)es$/' => '\1', - '/([octop|vir])i$/' => '\1us', - '/(cris|ax|test)es$/' => '\1is', - '/(shoe)s$/' => '\1', - '/(o)es$/' => '\1', - '/(bus)es$/' => '\1', - '/([m|l])ice$/' => '\1ouse', + '/(vert|ind)ices$/' => '\1ex', + '/^(ox)en/' => '\1', + '/(alias)es$/' => '\1', + '/([octop|vir])i$/' => '\1us', + '/(cris|ax|test)es$/' => '\1is', + '/(shoe)s$/' => '\1', + '/(o)es$/' => '\1', + '/(bus)es$/' => '\1', + '/([m|l])ice$/' => '\1ouse', '/(x|ch|ss|sh)es$/' => '\1', '/(m)ovies$/' => '\1\2ovie', '/(s)eries$/' => '\1\2eries', @@ -131,9 +139,9 @@ class Inflector extends Object '/s$/' => '' ); - foreach ($singular_rules as $rule => $replacement) + foreach ($singular_rules as $rule => $replacement) { - if (preg_match($rule, $word)) + if (preg_match($rule, $word)) { return preg_replace($rule, $replacement, $word); } @@ -141,17 +149,17 @@ class Inflector extends Object // should not return false is not matched return $word;//false; } - + /** * 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($lower_case_and_underscored_word) + function camelize($lower_case_and_underscored_word) { return str_replace(" ","",ucwords(str_replace("_"," ",$lower_case_and_underscored_word))); - } + } /** * Returns an underscore-syntaxed ($like_this_dear_reader) version of the $camel_cased_word. @@ -159,7 +167,7 @@ class Inflector extends Object * @param string $camel_cased_word Camel-cased word to be "underscorized" * @return string Underscore-syntaxed version of the $camel_cased_word */ - function underscore($camel_cased_word) + function underscore($camel_cased_word) { $camel_cased_word = preg_replace('/([A-Z]+)([A-Z])/','\1_\2', $camel_cased_word); return strtolower(preg_replace('/([a-z])([A-Z])/','\1_\2', $camel_cased_word)); @@ -172,10 +180,10 @@ class Inflector extends Object * @param string $lower_case_and_underscored_word String to be made more readable * @return string Human-readable string */ - function humanize($lower_case_and_underscored_word) + function humanize($lower_case_and_underscored_word) { return ucwords(str_replace("_"," ",$lower_case_and_underscored_word)); - } + } /** * Returns corresponding table name for given $class_name. ("posts" for the model class "Post"). @@ -183,7 +191,7 @@ class Inflector extends Object * @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($class_name) + function tableize($class_name) { return Inflector::pluralize(Inflector::underscore($class_name)); } @@ -200,7 +208,7 @@ class Inflector extends Object } /** - * Returns $class_name in underscored form, with "_id" tacked on at the end. + * Returns $class_name in underscored form, with "_id" tacked on at the end. * This is for use in dealing with foreign keys in the database. * * @param string $class_name @@ -209,8 +217,8 @@ class Inflector extends Object function foreignKey($class_name) { return Inflector::underscore($class_name) . "_id"; - } - + } + /** * Returns filename for given Cake controller name. * @@ -221,7 +229,7 @@ class Inflector extends Object { return CONTROLLERS.Inflector::underscore($name).'.php'; } - + /** * Returns filename for given Cake helper name. * @@ -232,12 +240,12 @@ class Inflector extends Object { return HELPERS.Inflector::underscore($name).'.php'; } - + /** * Returns given name as camelized. * * @param string $name - * @param string $correct + * @param string $correct * @return string * @todo Explain this method */ @@ -247,24 +255,24 @@ class Inflector extends Object { return Inflector::camelize($name); } - + if (preg_match("/^(.*)({$correct})$/i", $name, $reg)) { if ($reg[2] == $correct) { return $name; } - else + else { return ucfirst($reg[1].$correct); } } - else + else { return ucfirst($name.$correct); } } - + /** * Returns filename for given Cake library name. * @@ -277,4 +285,4 @@ class Inflector extends Object } } -?> +?> \ No newline at end of file diff --git a/cake/libs/log.php b/cake/libs/log.php index 71e4989d1..c867a3966 100644 --- a/cake/libs/log.php +++ b/cake/libs/log.php @@ -3,20 +3,20 @@ /** * Logging. - * + * * Log messages to text files. * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -30,9 +30,13 @@ /** * Included libraries. + * */ -uses('file'); - +if(!class_exists('File', FALSE)) +{ + uses('file'); +} + /** * Logs messages to text files * @@ -45,7 +49,7 @@ class Log /** * Writes given message to a log file in the logs directory. * - * @param string $type Type of log, becomes part of the log's filename + * @param string $type Type of log, becomes part of the log's filename * @param string $msg Message to log * @return boolean Success */ diff --git a/cake/libs/model/dbo/dbo.php b/cake/libs/model/dbo/dbo.php index 489aedcf3..637fff1a3 100644 --- a/cake/libs/model/dbo/dbo.php +++ b/cake/libs/model/dbo/dbo.php @@ -61,11 +61,11 @@ uses('object'); * * // emulate the usual way of reading query results * if ($db->query("SELECT a,b,c FROM table")) - * { - * while ( $row = $db->farr() ) - * { - * print $row['a'].$row['b'].$row['c']; - * } + * { + * while ( $row = $db->farr() ) + * { + * print $row['a'].$row['b'].$row['c']; + * } * } * * // show a log of all queries, sorted by execution time diff --git a/cake/libs/model/dbo/dbo_mysql.php b/cake/libs/model/dbo/dbo_mysql.php index 37ec45f64..bb5155878 100644 --- a/cake/libs/model/dbo/dbo_mysql.php +++ b/cake/libs/model/dbo/dbo_mysql.php @@ -98,9 +98,9 @@ class DBO_MySQL extends DBO function fetchRow ($assoc=false) { //return mysql_fetch_array($this->_result, $assoc? MYSQL_ASSOC: MYSQL_BOTH); - $this->mysqlResultSet($this->_result); - $resultRow = $this->fetchResult(); - return $resultRow; + $this->mysqlResultSet($this->_result); + $resultRow = $this->fetchResult(); + return $resultRow; } @@ -145,14 +145,14 @@ class DBO_MySQL extends DBO // $fields[] = array('name'=>$column['Field'], 'type'=>$column['Type']); if(isset($column['COLUMNS']) && !isset($column[0])) { - $column[0] = $column['COLUMNS']; + $column[0] = $column['COLUMNS']; } if(isset($column[0])) { - $fields[] = array('name' => $column[0]['Field'], 'type' => $column[0]['Type']); - } - } + $fields[] = array('name' => $column[0]['Field'], 'type' => $column[0]['Type']); + } + } return $fields; } diff --git a/cake/libs/model/dbo/dbo_sqlite.php b/cake/libs/model/dbo/dbo_sqlite.php index 52421f633..73b303518 100644 --- a/cake/libs/model/dbo/dbo_sqlite.php +++ b/cake/libs/model/dbo/dbo_sqlite.php @@ -126,12 +126,12 @@ class DBO_SQLite extends DBO } } - /** - * 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 - */ + /** + * 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) { $fields = false; @@ -145,65 +145,65 @@ class DBO_SQLite extends DBO 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 - */ + /** + * 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 "'" . sqlite_escape_string($data) . "'"; } - /** - * Returns a formatted error message from previous database operation. - * - * @return string Error message - */ + /** + * Returns a formatted error message from previous database operation. + * + * @return string Error message + */ 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 - */ + /** + * 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->_result? sqlite_changes($this->_conn): false; } - /** - * Returns number of rows in previous resultset. If no previous resultset exists, - * this returns false. - * - * @return int Number of rows in resultset - */ + /** + * Returns number of rows in previous resultset. If no previous resultset exists, + * this returns false. + * + * @return int Number of rows in resultset + */ function lastNumRows() { return $this->_result? sqlite_num_rows($this->_result): false; } - /** - * Returns the ID generated from the previous INSERT operation. - * - * @return int - */ + /** + * Returns the ID generated from the previous INSERT operation. + * + * @return int + */ function lastInsertId() { return sqlite_last_insert_rowid($this->_conn); } - /** - * Returns a limit statement in the correct format for the particular database. - * - * @param int $limit Limit of results returned - * @param int $offset Offset from which to start results - * @return string SQL limit/offset statement - */ + /** + * Returns a limit statement in the correct format for the particular database. + * + * @param int $limit Limit of results returned + * @param int $offset Offset from which to start results + * @return string SQL limit/offset statement + */ function selectLimit($limit, $offset=null) { return " LIMIT {$limit}".($offset? ", {$offset}": null); diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 267287033..12de57f90 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -9,10 +9,10 @@ * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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. * @@ -31,7 +31,7 @@ /** * Enter description here... */ -uses('object', 'class_registry', 'validators', 'inflector'); +uses('class_registry', 'validators'); /** @@ -274,22 +274,22 @@ class Model extends Object function createLinks() { if (!empty($this->belongsTo)) - { - $this->_belongsToLink(); - } - if (!empty($this->hasOne)) - { - $this->_hasOneLink(); - } - if (!empty($this->hasMany)) - { - $this->_hasManyLinks(); - } - if (!empty($this->hasAndBelongsToMany)) - { - $this->_hasAndBelongsToManyLinks(); - } - } + { + $this->_belongsToLink(); + } + if (!empty($this->hasOne)) + { + $this->_hasOneLink(); + } + if (!empty($this->hasMany)) + { + $this->_hasManyLinks(); + } + if (!empty($this->hasAndBelongsToMany)) + { + $this->_hasAndBelongsToManyLinks(); + } + } /** * Enter description here... @@ -348,26 +348,26 @@ class Model extends Object * * @access private */ - function _hasManyLinks() - { - if(is_array($this->hasMany)) - { - foreach ($this->hasMany as $association => $associationValue) - { - $className = $association; - $this->_associationSwitch($association, $className, $associationValue, 'Many'); - } - } - else - { - $association = explode(',', $this->hasMany); - foreach ($association as $className) - { - $this->_constructAssociatedModels($className, $className , 'Many'); - $this->linkAssociation('Many', $className, $className, $this->id); - } - } - } + function _hasManyLinks() + { + if(is_array($this->hasMany)) + { + foreach ($this->hasMany as $association => $associationValue) + { + $className = $association; + $this->_associationSwitch($association, $className, $associationValue, 'Many'); + } + } + else + { + $association = explode(',', $this->hasMany); + foreach ($association as $className) + { + $this->_constructAssociatedModels($className, $className , 'Many'); + $this->linkAssociation('Many', $className, $className, $this->id); + } + } + } /** * Enter description here... @@ -436,47 +436,47 @@ class Model extends Object case 'counterSql': $this->{$association.'_countersql'} = $optionValue; - break; + break; - case 'deleteSql': + case 'deleteSql': $this->{$association.'_deletesql'} = $optionValue; - break; + break; - case 'dependent': - $this->{$association.'_dependent'} = $optionValue; - break; + case 'dependent': + $this->{$association.'_dependent'} = $optionValue; + break; - case 'exclusive': + case 'exclusive': $this->{$association.'_exclusive'} = $optionValue; - break; + break; - case 'finderSql': + case 'finderSql': $this->{$association.'_findersql'} = $optionValue; - break; + break; - case 'foreignKey': + case 'foreignKey': $this->{$association.'_foreignkey'} = $optionValue; - break; + break; - case 'insertSql': + case 'insertSql': $this->{$association.'_insertsql'} = $optionValue; - break; + break; - case 'joinTable': + case 'joinTable': $this->{$association.'_jointable'} = $optionValue; - break; + break; - case 'order': + case 'order': $this->{$association.'_order'} = $optionValue; break; case 'uniq': $this->{$association.'_uniq'} = $optionValue; - break; + break; case 'fields': $this->{$association.'_fields'} = $optionValue; - break; + break; } } $this->linkAssociation($type, $association, $className, $this->id); @@ -1355,16 +1355,17 @@ class Model extends Object } /** - * Enter description here... + * Finds all children of $parent_id using 'parent_id' field. * + * @param int $parent_id * @param string $conditions SQL conditions (WHERE clause conditions) * @param unknown_type $fields - * @return unknown + * @return unknown type */ - function findAllThreaded ($conditions=null, $fields=null, $sort=null) - { - return $this->_doThread(Model::findAll($conditions, $fields, $sort), null); - } + function findAllThreaded ($conditions=null, $fields=null, $sort=null, $parent_id='0') + { + return $this->_doThread(Model::findAll($conditions, $fields, $sort), $parent_id); + } /** * Enter description here... @@ -1374,22 +1375,20 @@ class Model extends Object * @return array * @access private */ - function _doThread ($data, $root) - { - $out = array(); - - for ($ii=0; $ii_doThread($data, $data[$ii]['id']): null; - $out[] = $tmp; - } - } - - return $out; - } + function _doThread ($data, $root) + { + $out = array(); + for ($ii=0; $iiname]['parent_id'] == $root) + { + $tmp = $data[$ii]; + $tmp['children'] = isset($data[$ii][$this->name][$this->primaryKey])? $this->_doThread($data, $data[$ii][$this->name][$this->primaryKey]): null; + $out[] = $tmp; + } + } + return $out; + } /** * Returns an array with keys "prev" and "next" that holds the id's of neighbouring data, @@ -1427,32 +1426,23 @@ 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) { - $errors = count($this->invalidFields($data? $data: $this->data)); - + if (!$data) + { + $data = $this->data; + } + $errors = count($this->invalidFields($data)); return $errors == 0; } -/** - * Returns an array of invalid fields. - * - * @param array $data Posted data - * @return array Array of invalid fields - */ - function invalidFields ($data=null) - { - return $this->_invalidFields($data); - } - /** * Returns an array of invalid fields. * * @param array $data * @return array Array of invalid fields - * @access private */ - function _invalidFields ($data=null) + function invalidFields ($data = null) { if (!isset($this->validate)) { @@ -1464,15 +1454,26 @@ class Model extends Object return $this->validationErrors; } - $data = ($data? $data: (isset($this->data)? $this->data: array())); + if (!$data) + { + if (isset($this->data)) + { + $data = $this->data; + } + else + { + $data = array(); + } + } $errors = array(); + foreach ($data as $table => $field) { foreach ($this->validate as $field_name=>$validator) { if (isset($data[$table][$field_name]) && !preg_match($validator, $data[$table][$field_name])) { - $errors[$field_name] = 1; + $errors[$field_name] = 1; } } $this->validationErrors = $errors; @@ -1487,11 +1488,11 @@ class Model extends Object * @param string $field Returns true if the input string ends in "_id" * @return True if the field is a foreign key listed in the belongsTo array. */ - function isForeignKey( $field ) - { - $foreignKeys = array(); + function isForeignKey( $field ) + { + $foreignKeys = array(); - if(!empty($this->_belongsToOther)) + if(!empty($this->_belongsToOther)) { foreach ($this->_belongsToOther as $rule) @@ -1501,44 +1502,44 @@ class Model extends Object } } - if( array_key_exists($field, $foreignKeys) ) - { - return true; - } - return false; - } + if( array_key_exists($field, $foreignKeys) ) + { + return true; + } + return false; + } /** * Enter description here... * * @return unknown */ - function getDisplayField() - { - // $displayField defaults to 'name' - $dispField = 'name'; + function getDisplayField() + { + // $displayField defaults to 'name' + $dispField = 'name'; - // If the $displayField variable is set in this model, use it. - if( isset( $this->displayField ) ) { - $dispField = $this->displayField; - } + // If the $displayField variable is set in this model, use it. + if( isset( $this->displayField ) ) { + $dispField = $this->displayField; + } - // And if the display field does not exist in the table info structure, use the ID field. - if( false == $this->hasField( $dispField ) ) - $dispField = $this->primaryKey; + // And if the display field does not exist in the table info structure, use the ID field. + if( false == $this->hasField( $dispField ) ) + $dispField = $this->primaryKey; - return $dispField; - } + return $dispField; + } /** * Enter description here... * * @return unknown */ - function getLastInsertID() - { + function getLastInsertID() + { return $this->db->lastInsertId($this->table, $this->primaryKey); - } + } } ?> \ No newline at end of file diff --git a/cake/libs/neat_array.php b/cake/libs/neat_array.php index 348d83537..ef303b897 100644 --- a/cake/libs/neat_array.php +++ b/cake/libs/neat_array.php @@ -3,20 +3,20 @@ /** * Library of array functions for Cake. - * + * * Internal use only. * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -39,35 +39,35 @@ */ class NeatArray { - /** - * Value of NeatArray. - * - * @var array - * @access public - */ +/** + * Value of NeatArray. + * + * @var array + * @access public + */ var $value; - /** - * Constructor. Defaults to an empty array. - * - * @param array $value - * @access public - * @uses NeatArray::value - */ +/** + * Constructor. Defaults to an empty array. + * + * @param array $value + * @access public + * @uses NeatArray::value + */ function NeatArray ($value=array()) { $this->value = $value; } - /** - * Finds and returns records with $fieldName equal to $value from this NeatArray. - * - * @param string $fieldName - * @param string $value - * @return mixed - * @access public - * @uses NeatArray::value - */ +/** + * Finds and returns records with $fieldName equal to $value from this NeatArray. + * + * @param string $fieldName + * @param string $value + * @return mixed + * @access public + * @uses NeatArray::value + */ function findIn ($fieldName, $value) { if (!is_array($this->value)) @@ -87,12 +87,12 @@ class NeatArray return $out; } - /** - * Checks if $this->value is an array, and removes all empty elements. - * - * @access public - * @uses NeatArray::value - */ +/** + * Checks if $this->value is an array, and removes all empty elements. + * + * @access public + * @uses NeatArray::value + */ function cleanup () { $out = is_array($this->value)? array(): null; @@ -110,40 +110,40 @@ class NeatArray $this->value = $out; } - /** - * Adds elements from given array to itself. - * - * @param string $value - * @return bool - * @access public - * @uses NeatArray::value - */ +/** + * Adds elements from given array to itself. + * + * @param string $value + * @return bool + * @access public + * @uses NeatArray::value + */ function add ($value) { return ($this->value = $this->plus($value))? true: false; } - /** - * Returns itself merged with given array. - * - * @param array $value Array to add to NeatArray. - * @return array - * @access public - * @uses NeatArray::value - */ +/** + * Returns itself merged with given array. + * + * @param array $value Array to add to NeatArray. + * @return array + * @access public + * @uses NeatArray::value + */ function plus ($value) { return array_merge($this->value, (is_array($value)? $value: array($value))); } - /** - * Counts repeating strings and returns an array of totals. - * - * @param int $sortedBy A value of 1 sorts by values, a value of 2 sorts by keys. Defaults to null (no sorting). - * @return array - * @access public - * @uses NeatArray::value - */ +/** + * Counts repeating strings and returns an array of totals. + * + * @param int $sortedBy A value of 1 sorts by values, a value of 2 sorts by keys. Defaults to null (no sorting). + * @return array + * @access public + * @uses NeatArray::value + */ function totals ($sortedBy=1,$reverse=true) { $out = array(); @@ -165,38 +165,38 @@ class NeatArray return $out; } - /** - * Performs an array_filter() on the contents of this NeatArray. - * - * @param string $with Name of callback function to perform on each element of this NeatArray. - * @return array - */ +/** + * Performs an array_filter() on the contents of this NeatArray. + * + * @param string $with Name of callback function to perform on each element of this NeatArray. + * @return array + */ function filter ($with) { return $this->value = array_filter($this->value, $with); } - /** - * Passes each of its values through a specified function or method. - * Think of PHP's {@link http://php.net/array_walk array_walk()}. - * - * @param string $with Name of callback function - * @return array Returns value of NeatArray::value - * @access public - * @uses NeatArray::value - */ +/** + * Passes each of its values through a specified function or method. + * Think of PHP's {@link http://php.net/array_walk array_walk()}. + * + * @param string $with Name of callback function + * @return array Returns value of NeatArray::value + * @access public + * @uses NeatArray::value + */ function walk ($with) { array_walk($this->value, $with); return $this->value; } - /** - * Apply $template to all elements of this NeatArray, and return the array itself. - * - * @param string $template {@link http://php.net/sprintf sprintf()}-compatible string to be applied to all values of this NeatArray. - * @return array - */ +/** + * Apply $template to all elements of this NeatArray, and return the array itself. + * + * @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) { for ($ii=0; $iivalue); $ii++) @@ -207,13 +207,13 @@ class NeatArray return $this->value; } - /** - * Extracts a value from all array items. - * - * @return array - * @access public - * @uses NeatArray::value - */ +/** + * Extracts a value from all array items. + * + * @return array + * @access public + * @uses NeatArray::value + */ function extract ($name) { $out = array(); @@ -225,58 +225,58 @@ class NeatArray return $out; } - /** - * Returns a list of unique elements. - * - * @return array - */ +/** + * Returns a list of unique elements. + * + * @return array + */ function unique () { return array_unique($this->value); } - /** - * Removes duplicate elements from the value and returns it. - * - * @return array - */ +/** + * Removes duplicate elements from the value and returns it. + * + * @return array + */ function makeUnique () { return $this->value = array_unique($this->value); } - /** - * Joins an array with myself using a key (like a join between database tables). - * - * Example: - * - * $alice = array('id'=>'1', 'name'=>'Alice'); - * $bob = array('id'=>'2', 'name'=>'Bob'); - * - * $users = new NeatArray(array($alice, $bob)); - * - * $born = array - * ( - * array('user_id'=>'1', 'born'=>'1980'), - * array('user_id'=>'2', 'born'=>'1976') - * ); - * - * $users->joinWith($born, 'id', 'user_id'); - * - * Result: - * - * $users->value == array - * ( - * array('id'=>'1', 'name'=>'Alice', 'born'=>'1980'), - * array('id'=>'2', 'name'=>'Bob', 'born'=>'1976') - * ); - * - * - * @param array $his The array to join with myself. - * @param string $onMine Key to use on myself. - * @param string $onHis Key to use on him. - * @return array - */ +/** + * Joins an array with myself using a key (like a join between database tables). + * + * Example: + * + * $alice = array('id'=>'1', 'name'=>'Alice'); + * $bob = array('id'=>'2', 'name'=>'Bob'); + * + * $users = new NeatArray(array($alice, $bob)); + * + * $born = array + * ( + * array('user_id'=>'1', 'born'=>'1980'), + * array('user_id'=>'2', 'born'=>'1976') + * ); + * + * $users->joinWith($born, 'id', 'user_id'); + * + * Result: + * + * $users->value == array + * ( + * array('id'=>'1', 'name'=>'Alice', 'born'=>'1980'), + * array('id'=>'2', 'name'=>'Bob', 'born'=>'1976') + * ); + * + * + * @param array $his The array to join with myself. + * @param string $onMine Key to use on myself. + * @param string $onHis Key to use on him. + * @return array + */ function joinWith ($his, $onMine, $onHis=null) { if (empty($onHis)) @@ -303,21 +303,21 @@ class NeatArray return $this->value = $out; } - /** - * Enter description here... - * @todo Explain this function. almost looks like it creates a tree - * - * @param string $root - * @param string $idKey - * @param string $parentIdKey - * @param string $childrenKey - * @return array - */ +/** + * Enter description here... + * @todo Explain this function. almost looks like it creates a tree + * + * @param string $root + * @param string $idKey + * @param string $parentIdKey + * @param string $childrenKey + * @return array + */ function threaded ($root=null, $idKey='id', $parentIdKey='parent_id', $childrenKey='children') { $out = array(); - - for ($ii=0; $iivalue); $ii++) + $sizeof = sizeof($this->value); + for ($ii=0; $ii < $sizeof; $ii++) { if ($this->value[$ii][$parentIdKey] == $root) { @@ -333,21 +333,21 @@ class NeatArray } - /** - * Array multi search - * - * @param string $search_value - * @param array $the_array - * @return array - * @link http://php.net/array_search#47116 - */ +/** + * Array multi search + * + * @param string $search_value + * @param array $the_array + * @return array + * @link http://php.net/array_search#47116 + */ function multi_search($search_value, $the_array=null) { if ( $the_array == null ) { $the_array = $this->value; } - + if (is_array($the_array)) { foreach ($the_array as $key => $value) @@ -380,4 +380,4 @@ class NeatArray -?> +?> \ No newline at end of file diff --git a/cake/libs/neat_string.php b/cake/libs/neat_string.php index f4b524759..7fe467ea1 100644 --- a/cake/libs/neat_string.php +++ b/cake/libs/neat_string.php @@ -40,23 +40,23 @@ */ class NeatString { - /** - * Returns an array with each of the non-empty characters in $string as an element. - * - * @param string $string - * @return array - */ + /** + * Returns an array with each of the non-empty characters in $string as an element. + * + * @param string $string + * @return array + */ function toArray ($string) { return preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY); } - /** - * Returns string with Cyrillic characters translated to Roman ones. - * - * @param string $string - * @return string - */ + /** + * Returns string with Cyrillic characters translated to Roman ones. + * + * @param string $string + * @return string + */ function toRoman ($string) { $pl = array('ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','�?','Ń','Ó','Ś','Ź','Ż'); @@ -65,25 +65,25 @@ class NeatString return str_replace($pl, $ro, $string); } - /** - * Returns string as lowercase with whitespace removed. - * - * @param string $string - * @return string - */ + /** + * Returns string as lowercase with whitespace removed. + * + * @param string $string + * @return string + */ function toCompressed ($string) { $whitespace = array("\n", " ", "\r", "\0", "\x0B", " "); return strtolower(str_replace($whitespace, '', $string)); } - /** - * Returns a random password. - * - * @param integer $length Length of generated password - * @param string $available_chars List of characters to use in password - * @return string Generated password - */ + /** + * Returns a random password. + * + * @param integer $length Length of generated password + * @param string $available_chars List of characters to use in password + * @return string Generated password + */ function randomPassword ($length, $available_chars = 'ABDEFHKMNPRTWXYABDEFHKMNPRTWXY23456789') { $chars = preg_split('//', $available_chars, -1, PREG_SPLIT_NO_EMPTY); diff --git a/cake/libs/object.php b/cake/libs/object.php index df30198ff..b7b6b1fd6 100644 --- a/cake/libs/object.php +++ b/cake/libs/object.php @@ -29,11 +29,6 @@ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ -/** - * Included libraries. - */ -uses('log'); - /** * Object class, allowing __construct and __destruct in PHP4. * @@ -121,6 +116,10 @@ class Object */ function log ($msg, $type=LOG_ERROR) { + if(!class_exists('Log', FALSE)) + { + uses('log'); + } if (is_null($this->_log)) { $this->_log = new Log (); @@ -182,6 +181,7 @@ class Object $this->missingView = $this->name; $this->pageTitle = 'Missing View'; $this->render('../errors/missingView'); + exit(); } /** @@ -202,8 +202,8 @@ class Object */ function missingTable($tableName) { - $error =& new Controller(); - $error->constructClasses(); + $error =& new Controller(); + $error->constructClasses(); $error->missingTable = $this->table; $error->missingTableName = $tableName; $error->pageTitle = 'Missing Database Table'; @@ -218,7 +218,7 @@ class Object function missingConnection() { $error =& new Controller(); - $error->constructClasses(); + $error->constructClasses(); $error->missingConnection = $this->name; $error->autoLayout = true; $error->pageTitle = 'Missing Database Connection'; diff --git a/cake/libs/router.php b/cake/libs/router.php index 6ece2db2c..52e6c189a 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -3,20 +3,20 @@ /** * Parses the request URL into controller, action, and parameters. - * + * * Long description for file * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -27,12 +27,14 @@ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ - /** * Included libraries. + * */ -uses('object', 'neat_array'); - +if(!class_exists('Object', FALSE)) +{ + uses('object'); +} /** * Parses the request URL into controller, action, and parameters. * @@ -49,7 +51,7 @@ class Router extends Object { * @var array */ var $routes = array(); - + /** * TODO: Better description. Returns this object's routes array. Returns false if there are no routes available. * @@ -58,17 +60,17 @@ class Router extends Object { * @see routes * @return array Array of routes */ - function connect ($route, $default=null) + function connect ($route, $default=null) { $parsed = $names = array (); $r = null; - if (($route == '') || ($route == '/')) + if (($route == '') || ($route == '/')) { $regexp = '/^[\/]*$/'; $this->routes[] = array($route, $regexp, array(), $default); } - else + else { $elements = array(); foreach (explode('/', $route) as $element) @@ -81,20 +83,20 @@ class Router extends Object { return false; } - foreach ($elements as $element) + foreach ($elements as $element) { - if (preg_match('/^:(.+)$/', $element, $r)) + if (preg_match('/^:(.+)$/', $element, $r)) { - $parsed[] = '(?:\/([^\/]+))?'; - $names[] = $r[1]; + $parsed[] = '(?:\/([^\/]+))?'; + $names[] = $r[1]; } - elseif (preg_match('/^\*$/', $element, $r)) + elseif (preg_match('/^\*$/', $element, $r)) { - $parsed[] = '(?:\/(.*))?'; + $parsed[] = '(?:\/(.*))?'; } - else + else { - $parsed[] = '/'.$element; + $parsed[] = '/'.$element; } } $regexp = '#^'.join('', $parsed).'[\/]*$#'; @@ -105,12 +107,12 @@ class Router extends Object { /** * Parses given URL and returns an array of controllers, action and parameters - * taken from that URL. + * taken from that URL. * - * @param string $url URL to be parsed - * @return array + * @param string $url URL to be parsed + * @return array */ - function parse ($url) + 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. @@ -118,7 +120,7 @@ class Router extends Object { { $url = '/'.$url; } - + $out = array(); $r = null; @@ -128,7 +130,7 @@ class Router extends Object { '/^(?:\/(?:([a-zA-Z0-9_\\-\\.]+)(?:\\/([a-zA-Z0-9_\\-\\.]+)(?:\\/(.*))?)?))[\\/]*$/', array('controller', 'action'), array()); - + if(defined('CAKE_ADMIN')) { $admin = CAKE_ADMIN; @@ -140,13 +142,13 @@ class Router extends Object { '/^(?:\/(?:('.$admin.')(?:\\/([a-zA-Z0-9_\\-\\.]+)(?:\\/([a-zA-Z0-9_\\-\\.]+)(?:\/(.*))?)?)?))[\/]*$/', array($admin, 'controller', 'action'), array()); - + } } - + $this->connect('/bare/:controller/:action/*', array('bare'=>'1')); $this->connect('/ajax/:controller/:action/*', array('bare'=>'1')); - + if(defined('WEBSERVICES') && WEBSERVICES == 'on' ) { $this->connect('/rest/:controller/:action/*', array('webservices'=>'Rest')); @@ -155,15 +157,15 @@ class Router extends Object { $this->connect('/xml/:controller/:action/*', array('webservices'=>'Xml')); $this->connect('/xmlrpc/:controller/:action/*', array('webservices'=>'XmlRpc')); } - + $this->routes[] = $default_route; - - foreach ($this->routes as $route) + + foreach ($this->routes as $route) { list($route, $regexp, $names, $defaults) = $route; - if (preg_match($regexp, $url, $r)) + if (preg_match($regexp, $url, $r)) { // $this->log($url.' matched '.$regexp, 'note'); // remove the first element, which is the url @@ -175,9 +177,9 @@ class Router extends Object { $ii = 0; - if (is_array($defaults)) + if (is_array($defaults)) { - foreach ($defaults as $name=>$value) + foreach ($defaults as $name=>$value) { if (preg_match('#[a-zA-Z_\-]#i', $name)) { @@ -190,15 +192,15 @@ class Router extends Object { } } - foreach ($r as $found) + foreach ($r as $found) { // if $found is a named url element (i.e. ':action') - if (isset($names[$ii])) + if (isset($names[$ii])) { $out[$names[$ii]] = $found; } // unnamed elements go in as 'pass' - else + else { $pass = new NeatArray(explode('/', $found)); $pass->cleanup(); diff --git a/cake/libs/sanitize.php b/cake/libs/sanitize.php index 9ee34f37a..a6a690e3a 100644 --- a/cake/libs/sanitize.php +++ b/cake/libs/sanitize.php @@ -48,10 +48,10 @@ class Sanitize * @param string $string * @return string */ - function paranoid($string) - { - return preg_replace( "/[^a-zA-Z0-9]/", "", $string ); - } + function paranoid($string) + { + return preg_replace( "/[^a-zA-Z0-9]/", "", $string ); + } /** * Makes a string SQL-safe by adding slashes (if needed). @@ -68,7 +68,7 @@ class Sanitize return $string; } - + /** * Returns given string safe for display as HTML. Renders entities and converts newlines to
. * @@ -85,13 +85,13 @@ class Sanitize else { $patterns = array("/\&/", "/%/", "//", '/"/', "/'/", "/\(/", "/\)/", "/\+/", "/-/", "/\n/"); - $replacements = array("&", "%", "<", ">", """, "'", "(", ")", "+", "-", "
"); - $string = preg_replace($patterns, $replacements, $string); + $replacements = array("&", "%", "<", ">", """, "'", "(", ")", "+", "-", "
"); + $string = preg_replace($patterns, $replacements, $string); } return $string; } - + /** * Recursively sanitizes given array of data for safe input. * @@ -131,7 +131,7 @@ class Sanitize return null; } } - + /** * Do we really need to sanitize array keys? If so, we can use this code... @@ -154,7 +154,7 @@ class Sanitize return $key; } */ - + /** * Method used by cleanArray() to sanitize array nodes. * @@ -177,10 +177,10 @@ class Sanitize //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); + $val = preg_replace( "/\\\$/" ,"$" ,$val); + $val = preg_replace( "/\r/" ,"" ,$val); + $val = str_replace ( "!" ,"!" ,$val); + $val = str_replace ( "'" , "'" ,$val); //Allow unicode (?) $val = preg_replace("/&#([0-9]+);/s", "&#\\1;", $val ); diff --git a/cake/libs/session.php b/cake/libs/session.php index ab056d3e9..edc493c71 100644 --- a/cake/libs/session.php +++ b/cake/libs/session.php @@ -3,20 +3,20 @@ /** * Short description for file. - * + * * Long description for file * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -44,43 +44,43 @@ class CakeSession extends Object * * @var unknown_type */ - var $valid = false; + var $valid = false; /** * Enter description here... * * @var unknown_type */ - var $error = false; + var $error = false; /** * Enter description here... * * @var unknown_type */ - var $ip = false; + var $ip = false; /** * Enter description here... * * @var unknown_type */ - var $userAgent = false; + var $userAgent = false; /** * Enter description here... * * @var unknown_type */ - var $path = false; + var $path = false; /** * Enter description here... * * @var unknown_type */ - var $lastError = null; + var $lastError = null; /** * Enter description here... * * @var unknown_type */ - var $sessionId = null; + var $sessionId = null; /** * Enter description here... @@ -91,23 +91,19 @@ class CakeSession extends Object function __construct($base = null) { $this->host = $_SERVER['HTTP_HOST']; - if (strpos($this->host, ':') !== false) - { - $this->host = substr($this->host,0, strpos($this->host, ':')); - } - if (empty($this->path)) + if (empty($base)) { - $dispatcher =& new Dispatcher(); - $this->path = $dispatcher->baseUrl(); + $this->path = '/'; } else { - $this->path = $base; + $this->path = $base; } - if (empty($this->path)) + + if (strpos($this->host, ':') !== false) { - $this->path = '/'; + $this->host = substr($this->host,0, strpos($this->host, ':')); } $this->ip = !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; @@ -155,33 +151,33 @@ class CakeSession extends Object */ function getError($errorNumber) { - if(!is_array($this->error) || !array_key_exists($errorNumber, $this->error)) - { - return false; - } - else - { - return $this->error[$errorNumber]; - } - } + if(!is_array($this->error) || !array_key_exists($errorNumber, $this->error)) + { + return false; + } + else + { + return $this->error[$errorNumber]; + } + } /** * Enter description here... * * @return unknown */ - function getLastError() - { + function getLastError() + { - if($this->lastError) - { - return $this->getError($this->lastError); - } - else - { - return false; - } - } + if($this->lastError) + { + return $this->getError($this->lastError); + } + else + { + return false; + } + } /** * Enter description here... diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 2fa83e5c9..55ba31077 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -40,57 +40,57 @@ */ class Helper extends Object { - /************************************************************************* + /************************************************************************* * Public variables *************************************************************************/ - /**#@+ + /**#@+ * @access public */ - /** - * Holds tag templates. - * - * @access public - * @var array - */ + /** + * Holds tag templates. + * + * @access public + * @var array + */ var $tags = array(); - /**#@-*/ + /**#@-*/ - /************************************************************************* + /************************************************************************* * Public methods *************************************************************************/ - /**#@+ + /**#@+ * @access public */ - /** - * Constructor. - * - * Parses tag templates into $this->tags. - * - * @return void - */ + /** + * Constructor. + * + * Parses tag templates into $this->tags. + * + * @return void + */ function Helper() { $this->tags = $this->readConfigFile(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 - * output a string, or return it. - * - * @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 - * and $return. - */ + /** + * Decides whether to output or return a string. + * + * Based on AUTO_OUTPUT and $return's value, this method decides whether to + * output a string, or return it. + * + * @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 + * and $return. + */ function output($str, $return = false) { if (AUTO_OUTPUT && $return === false) @@ -110,16 +110,16 @@ class Helper extends Object } } - /** - * Assigns values to tag templates. - * - * Finds a tag template by $keyName, and replaces $values's keys with - * $values's keys. - * - * @param string $keyName Name of the key in the tag array. - * @param array $values Values to be inserted into tag. - * @return string Tag with inserted values. - */ + /** + * Assigns values to tag templates. + * + * Finds a tag template by $keyName, and replaces $values's keys with + * $values's keys. + * + * @param string $keyName Name of the key in the tag array. + * @param array $values Values to be inserted into tag. + * @return string Tag with inserted values. + */ function assign($keyName, $values) { return str_replace('%%'.array_keys($values).'%%', array_values($values), @@ -174,7 +174,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 a4d5835c1..21fdcc209 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -44,110 +44,110 @@ class AjaxHelper extends Helper { - /** - * Included helpers. - * - * @var array - */ + /** + * Included helpers. + * + * @var array + */ var $helpers = array('Html', 'Javascript'); - /** - * Enter description here... - * - * @var array - */ + /** + * Enter description here... + * + * @var array + */ var $callbacks = array('uninitialized', 'loading', 'loaded', 'interactive', 'complete'); - /** - * Enter description here... - * - * @var array - */ + /** + * Enter description here... + * + * @var array + */ var $ajaxOptions = array('method','position','form','parameters','evalScripts', 'asynchronous', 'onComplete', 'onUninitialized', 'onLoading', 'onLoaded', 'onInteractive'); - /** - * Enter description here... - * - * @var array - */ + /** + * Enter description here... + * + * @var array + */ var $dragOptions = array('handle', 'revert', 'constraint', 'change'); - /** - * Enter description here... - * - * @var array - */ + /** + * Enter description here... + * + * @var array + */ var $dropOptions = array('accept', 'containment', 'overlap', 'greedy', 'hoverclass', 'onHover', 'onDrop'); - /** - * Enter description here... - * - * @var array - */ + /** + * Enter description here... + * + * @var array + */ var $sortOptions = array('tag', 'only', 'overlap', 'constraint', 'containment', 'handle', 'hoverClass', 'ghosting', 'dropOnEmpty', 'onUpdate', 'onChange'); - /** - * Returns link to remote action - * - * Returns a link to a remote action defined by options[url] - * (using the urlFor format) that's called in the background using - * XMLHttpRequest. The result of that request can then be inserted into a - * DOM object whose id can be specified with options[update]. - * Usually, the result would be a partial prepared by the controller with - * either renderPartial or renderPartialCollection. - * - * Examples: - * - * linkToRemote("Delete this post", - * array("update" => "posts", "url" => "delete/{$postid->id}")); - * linkToRemote(imageTag("refresh"), - * array("update" => "emails", "url" => "list_emails" )); - * - * - * By default, these remote requests are processed asynchronous during - * which various callbacks can be triggered (for progress indicators and - * the likes). - * - * Example: - * - * linkToRemote (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. - * - 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. - * - complete:: Called when the XMLHttpRequest is complete. - * - * If you for some reason or another need synchronous processing (that'll - * block the browser while the request is happening), you can specify - * options[type] = synchronous. - * - * You can customize further browser side call logic by passing - * in Javascript code snippets via some optional parameters. In - * their order of use these are: - * - * - confirm:: Adds confirmation dialog. - * -condition:: Perform remote request conditionally - * by this expression. Use this to - * describe browser-side conditions when - * request should not be initiated. - * - before:: Called before request is initiated. - * - after:: Called immediately after request was - * initiated and before loading. - * - * @param string $title Title of link - * @param array $options Options for JavaScript function - * @return string HTML code for link to remote action - */ + /** + * Returns link to remote action + * + * Returns a link to a remote action defined by options[url] + * (using the urlFor format) that's called in the background using + * XMLHttpRequest. The result of that request can then be inserted into a + * DOM object whose id can be specified with options[update]. + * Usually, the result would be a partial prepared by the controller with + * either renderPartial or renderPartialCollection. + * + * Examples: + * + * linkToRemote("Delete this post", + * array("update" => "posts", "url" => "delete/{$postid->id}")); + * linkToRemote(imageTag("refresh"), + * array("update" => "emails", "url" => "list_emails" )); + * + * + * By default, these remote requests are processed asynchronous during + * which various callbacks can be triggered (for progress indicators and + * the likes). + * + * Example: + * + * linkToRemote (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. + * - 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. + * - complete:: Called when the XMLHttpRequest is complete. + * + * If you for some reason or another need synchronous processing (that'll + * block the browser while the request is happening), you can specify + * options[type] = synchronous. + * + * You can customize further browser side call logic by passing + * in Javascript code snippets via some optional parameters. In + * their order of use these are: + * + * - confirm:: Adds confirmation dialog. + * -condition:: Perform remote request conditionally + * by this expression. Use this to + * describe browser-side conditions when + * request should not be initiated. + * - before:: Called before request is initiated. + * - after:: Called immediately after request was + * initiated and before loading. + * + * @param string $title Title of link + * @param array $options Options for JavaScript function + * @return string HTML code for link to remote action + */ function linkToRemote ($title, $options = null, $html_options = null) { $href = (!empty($options['fallback'])) ? $options['fallback'] : '#'; @@ -162,17 +162,17 @@ 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); @@ -200,16 +200,16 @@ class AjaxHelper extends Helper return $func; } - /** - * 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; @@ -217,18 +217,18 @@ class AjaxHelper extends Helper return $this->Javascript->codeBlock($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 string $id Form id - * @param array $options Callback options - * @return string JavaScript 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 string $id Form id + * @param array $options Callback options + * @return string JavaScript code + */ function form($id, $options = null, $html_options = array()) { $html_options['id'] = $id; @@ -237,17 +237,17 @@ class AjaxHelper extends Helper $this->remoteFunction($options) . "; return false;}"); } - /** - * 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 $name Input button name - * @param string $value Input button value - * @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 $name Input button name + * @param string $value Input button value + * @param array $options Callback options + * @return string Ajaxed input button + */ function submit ($name, $value, $options = null) { $options['with'] = 'Form.serialize(this.form)'; @@ -258,34 +258,34 @@ class AjaxHelper extends Helper return $this->Html->tag("input", $options['html'], false); } - /** - * 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 = null) { if (!isset($options['with'])) @@ -295,18 +295,18 @@ class AjaxHelper extends Helper return $this->Javascript->codeBlock($this->_buildObserver('Form.Element.Observer', $field_id, $options)); } - /** - * 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'])) @@ -316,18 +316,18 @@ class AjaxHelper extends Helper return $this->Javascript->codeBlock($this->_buildObserver('Form.Observer', $field_id, $options)); } - /** - * 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 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 array $options ajax options + * @return string ajax script + */ function autoComplete ($field, $url = "", $options = array()) { if (!isset($options['id'])) @@ -366,12 +366,12 @@ class AjaxHelper extends Helper return $this->Javascript->codeBlock("new Draggable('$id'$options);"); } - /** - * Enter description here... - * - * @param array $options - * @return array - */ + /** + * Enter description here... + * + * @param array $options + * @return array + */ function _optionsForDraggable ($options) { $options = $this->_optionsToString($options, array('handle','constraint')); @@ -379,11 +379,11 @@ class AjaxHelper extends Helper return $this->_buildOptions($options, $this->dragOptions); } - /** - * 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 + * + */ function drop($id, $options = array()) { $options = $this->_optionsForDroppable($options); @@ -402,14 +402,14 @@ class AjaxHelper extends Helper $options['onDrop'] = "function(element){" . $this->remoteFunction($ajaxOptions) . "}"; } - /** - * 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()) { @@ -428,10 +428,10 @@ class AjaxHelper extends Helper return $this->_buildOptions($options, $this->sortOptions); } - /** - * Javascript helper function (private). - * - */ + /** + * Javascript helper function (private). + * + */ function _optionsForAjax ($options = array()) { $js_options = $this->_buildCallbacks($options); @@ -487,14 +487,14 @@ class AjaxHelper extends Helper } } - /** - * Enter description here... Return JavaScript text for ... - * - * @param string $klass Name of JavaScript class - * @param string $name - * @param array $options - * @return string Formatted JavaScript - */ + /** + * Enter description here... Return JavaScript text for ... + * + * @param string $klass Name of JavaScript class + * @param string $name + * @param array $options + * @return string Formatted JavaScript + */ function _buildObserver ($klass, $name, $options=null) { if(!isset($options['with']) && isset($options['update'])) @@ -509,12 +509,12 @@ class AjaxHelper extends Helper return $javascript; } - /** - * Enter description here... Return JavaScript text for ... - * - * @param array $options - * @return array - */ + /** + * Enter description here... Return JavaScript text for ... + * + * @param array $options + * @return array + */ function _buildCallbacks($options) { $callbacks = array(); diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 6dd6e8520..b09994d09 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -9,10 +9,10 @@ * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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. * @@ -62,320 +62,320 @@ define('TAG_FIELDSET', '
%s%s'); class FormHelper extends Helper { - var $helpers = array('Html'); - /** - * Constructor which takes an instance of the HtmlHelper class. - * - * @param object $htmlHelper the HtmlHelper object to use as our helper. - * @return void - */ - function FormHelper() - { - } + var $helpers = array('Html'); + /** + * Constructor which takes an instance of the HtmlHelper class. + * + * @param object $htmlHelper the HtmlHelper object to use as our helper. + * @return void + */ + function FormHelper() + { + } - /** - * Returns a formatted error message for given FORM field, NULL if no errors. - * - * @param string $field If field is to be used for CRUD, this should be modelName/fieldName - * @return bool If there are errors this method returns true, else false. - */ - function isFieldError($field ) - { - $error = 1; - $this->Html->setFormTag( $field ); - if( $error == $this->Html->tagIsInvalid( $this->Html->model, $this->Html->field) ) - { - return true; - } else { - return false; - } - } + /** + * Returns a formatted error message for given FORM field, NULL if no errors. + * + * @param string $field If field is to be used for CRUD, this should be modelName/fieldName + * @return bool If there are errors this method returns true, else false. + */ + function isFieldError($field ) + { + $error = 1; + $this->Html->setFormTag( $field ); + if( $error == $this->Html->tagIsInvalid( $this->Html->model, $this->Html->field) ) + { + return true; + } else { + return false; + } + } - /** - * Returns a formatted LABEL element for HTML FORMs. - * - * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName - * @param string $text Text that will appear in the label field. - * @return string The formatted LABEL element - */ - function labelTag( $tagName, $text ) - { - return sprintf( TAG_LABEL, strtolower(str_replace('/', '_',$tagName)), $text ); - } + /** + * Returns a formatted LABEL element for HTML FORMs. + * + * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName + * @param string $text Text that will appear in the label field. + * @return string The formatted LABEL element + */ + function labelTag( $tagName, $text ) + { + return sprintf( TAG_LABEL, strtolower(str_replace('/', '_',$tagName)), $text ); + } - /** - * Returns a formatted DIV tag for HTML FORMs. - * - * @param string $class If field is to be used for CRUD, this should be modelName/fieldName - * @param string $text Text that will appear in the label field. - * @return string The formatted DIV element - */ - function divTag( $class, $text ) - { - return sprintf( TAG_DIV, $class, $text ); - } + /** + * Returns a formatted DIV tag for HTML FORMs. + * + * @param string $class If field is to be used for CRUD, this should be modelName/fieldName + * @param string $text Text that will appear in the label field. + * @return string The formatted DIV element + */ + function divTag( $class, $text ) + { + return sprintf( TAG_DIV, $class, $text ); + } - /** - * Returns a formatted P tag with class for HTML FORMs. - * - * @param string $class If field is to be used for CRUD, this should be modelName/fieldName - * @param string $text Text that will appear in the label field. - * @return string The formatted DIV element - */ - function pTag( $class, $text ) - { - return sprintf( TAG_P_CLASS, $class, $text ); - } + /** + * Returns a formatted P tag with class for HTML FORMs. + * + * @param string $class If field is to be used for CRUD, this should be modelName/fieldName + * @param string $text Text that will appear in the label field. + * @return string The formatted DIV element + */ + function pTag( $class, $text ) + { + return sprintf( TAG_P_CLASS, $class, $text ); + } - /** - * Returns a formatted INPUT tag for HTML FORMs. - * - * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName - * @param string $prompt Text that will appear in the label field. - * @param bool $required True if this field is required. - * @param string $errorMsg Text that will appear if an error has occurred. - * @param int $size Size attribute for INPUT element - * @param array $htmlOptions - * @return string The formatted INPUT element - */ - function generateInputDiv($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) - { - $htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));; - $str = $this->Html->inputTag( $tagName, $size, $htmlOptions ); - $strLabel = $this->labelTag( $tagName, $prompt ); + /** + * Returns a formatted INPUT tag for HTML FORMs. + * + * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName + * @param string $prompt Text that will appear in the label field. + * @param bool $required True if this field is required. + * @param string $errorMsg Text that will appear if an error has occurred. + * @param int $size Size attribute for INPUT element + * @param array $htmlOptions + * @return string The formatted INPUT element + */ + function generateInputDiv($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) + { + $htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));; + $str = $this->Html->inputTag( $tagName, $size, $htmlOptions ); + $strLabel = $this->labelTag( $tagName, $prompt ); - $divClass = "optional"; + $divClass = "optional"; - if( $required ) - $divClass = "required"; + 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. - $strError = $this->pTag( 'error', $errorMsg ); - $divClass = sprintf( "%s error", $divClass ); - } - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); + if( $this->isFieldError( $tagName ) ) + { + // 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 ); + } + $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); - return $this->divTag( $divClass, $divTagInside ); + return $this->divTag( $divClass, $divTagInside ); - } + } - /** - * Returns a formatted CHECKBOX tag inside a DIV for HTML FORMs. - * - * @param HtmlHelper $html The HtmlHelper object which is creating this form. - * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName - * @param string $prompt Text that will appear in the label field. - * @param bool $required True if this field is required. - * @param string $errorMsg Text that will appear if an error has occurred. - * @param int $size Size attribute for INPUT element - * @param array $htmlOptions - * @return string The formatted INPUT element - */ - function generateCheckboxDiv($tagName, $prompt, $required=false, $errorMsg=null, $htmlOptions=null ) - { - $htmlOptions['class'] = "inputCheckbox"; - $htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));; - $str = $this->Html->checkbox( $tagName, null, $htmlOptions ); - $strLabel = $this->labelTag( $tagName, $prompt ); + /** + * Returns a formatted CHECKBOX tag inside a DIV for HTML FORMs. + * + * @param HtmlHelper $html The HtmlHelper object which is creating this form. + * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName + * @param string $prompt Text that will appear in the label field. + * @param bool $required True if this field is required. + * @param string $errorMsg Text that will appear if an error has occurred. + * @param int $size Size attribute for INPUT element + * @param array $htmlOptions + * @return string The formatted INPUT element + */ + function generateCheckboxDiv($tagName, $prompt, $required=false, $errorMsg=null, $htmlOptions=null ) + { + $htmlOptions['class'] = "inputCheckbox"; + $htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));; + $str = $this->Html->checkbox( $tagName, null, $htmlOptions ); + $strLabel = $this->labelTag( $tagName, $prompt ); - $divClass = "optional"; + $divClass = "optional"; - if( $required ) - $divClass = "required"; + 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. - $strError = $this->pTag( 'error', $errorMsg ); - $divClass = sprintf( "%s error", $divClass ); - } - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); + if( $this->isFieldError( $tagName ) ) + { + // 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 ); + } + $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); - return $this->divTag( $divClass, $divTagInside ); + return $this->divTag( $divClass, $divTagInside ); - } + } - /** - * Returns a formatted date option element for HTML FORMs. - * - * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName - * @param string $prompt Text that will appear in the label field. - * @param bool $required True if this field is required. - * @param string $errorMsg Text that will appear if an error has occurred. - * @param int $size Size attribute for INPUT element - * @param array $htmlOptions - * @return string The formatted INPUT element - */ - function generateDate($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) - { - $htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));; - $str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , 'NONE', '', $htmlOptions); - $strLabel = $this->labelTag( $tagName, $prompt ); + /** + * Returns a formatted date option element for HTML FORMs. + * + * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName + * @param string $prompt Text that will appear in the label field. + * @param bool $required True if this field is required. + * @param string $errorMsg Text that will appear if an error has occurred. + * @param int $size Size attribute for INPUT element + * @param array $htmlOptions + * @return string The formatted INPUT element + */ + function generateDate($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected ) + { + $htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));; + $str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , 'NONE', '', $selected, $htmlOptions); + $strLabel = $this->labelTag( $tagName, $prompt ); - $divClass = "optional"; + $divClass = "optional"; - if( $required ) - $divClass = "required"; + 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. - $strError = $this->pTag( 'error', $errorMsg ); - $divClass = sprintf( "%s error", $divClass ); - } - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); + if( $this->isFieldError( $tagName ) ) + { + // 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 ); + } + $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); - $requiredDiv = $this->divTag( $divClass, $divTagInside ); + $requiredDiv = $this->divTag( $divClass, $divTagInside ); - return $this->divTag("date", $requiredDiv); - } + return $this->divTag("date", $requiredDiv); + } - /** - * Returns a formatted datetime option element for HTML FORMs. - * - * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName - * @param string $prompt Text that will appear in the label field. - * @param bool $required True if this field is required. - * @param string $errorMsg Text that will appear if an error has occurred. - * @param int $size Size attribute for INPUT element - * @param array $htmlOptions - * @return string The formatted datetime option element - */ - function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) - { - $htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));; - $str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , '12', '', $htmlOptions); - $strLabel = $this->labelTag( $tagName, $prompt ); + /** + * Returns a formatted datetime option element for HTML FORMs. + * + * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName + * @param string $prompt Text that will appear in the label field. + * @param bool $required True if this field is required. + * @param string $errorMsg Text that will appear if an error has occurred. + * @param int $size Size attribute for INPUT element + * @param array $htmlOptions + * @return string The formatted datetime option element + */ + function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected = null ) + { + $htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));; + $str = $this->Html->dateTimeOptionTag( $tagName, 'MDY' , '12', $selected, $htmlOptions); + $strLabel = $this->labelTag( $tagName, $prompt ); - $divClass = "optional"; + $divClass = "optional"; - if( $required ) - $divClass = "required"; + 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. - $strError = $this->pTag( 'error', $errorMsg ); - $divClass = sprintf( "%s error", $divClass ); - } - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); + if( $this->isFieldError( $tagName ) ) + { + // 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 ); + } + $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); - $requiredDiv = $this->divTag( $divClass, $divTagInside ); + $requiredDiv = $this->divTag( $divClass, $divTagInside ); - return $this->divTag("date", $requiredDiv); - } + return $this->divTag("date", $requiredDiv); + } - /** - * Returns a formatted TEXTAREA inside a DIV for use with HTML forms. - * - * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName - * @param string $prompt Text that will appear in the label field. - * @param boolean $required True if this field is required. - * @param string $errorMsg ext that will appear if an error has occurred. - * @param integer $cols Number of columns. - * @param integer $rows Number of rows. - * @param array $htmlOptions - * @return string The formatted TEXTAREA element - */ - function generateAreaDiv($tagName, $prompt, $required=false, $errorMsg=null, $cols=60, $rows=10, $htmlOptions=null ) - { - $htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));; - $str = $this->Html->areaTag( $tagName, $cols, $rows, $htmlOptions ); - $strLabel = $this->labelTag( $tagName, $prompt ); + /** + * Returns a formatted TEXTAREA inside a DIV for use with HTML forms. + * + * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName + * @param string $prompt Text that will appear in the label field. + * @param boolean $required True if this field is required. + * @param string $errorMsg ext that will appear if an error has occurred. + * @param integer $cols Number of columns. + * @param integer $rows Number of rows. + * @param array $htmlOptions + * @return string The formatted TEXTAREA element + */ + function generateAreaDiv($tagName, $prompt, $required=false, $errorMsg=null, $cols=60, $rows=10, $htmlOptions=null ) + { + $htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));; + $str = $this->Html->areaTag( $tagName, $cols, $rows, $htmlOptions ); + $strLabel = $this->labelTag( $tagName, $prompt ); - $divClass = "optional"; + $divClass = "optional"; - if( $required ) - $divClass = "required"; + 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. - $strError = $this->pTag( 'error', $errorMsg ); - $divClass = sprintf( "%s error", $divClass ); - } - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); + if( $this->isFieldError( $tagName ) ) + { + // 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 ); + } + $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); - return $this->divTag( $divClass, $divTagInside ); + return $this->divTag( $divClass, $divTagInside ); - } + } - /** - * Returns a formatted SELECT tag for HTML FORMs. - * - * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName - * @param string $prompt Text that will appear in the label field - * @param array $options Options to be contained in SELECT element - * @param string $selected Text of the currently selected item - * @param array $selectAttr Array of HTML attributes for the SELECT element - * @param array $optionAttr Array of HTML attributes for the OPTION elements - * @param bool $required True if this field is required - * @param string $errorMsg Text that will appear if an error has occurred - * @return string The formatted INPUT element - */ - function generateSelectDiv($tagName, $prompt, $options, $selected=null, $selectAttr=null, $optionAttr=null, $required=false, $errorMsg=null) - { - $selectAttr['id'] = strtolower(str_replace('/', '_',$tagName));; - $str = $this->Html->selectTag( $tagName, $options, $selected, $selectAttr, $optionAttr ); - $strLabel = $this->labelTag( $tagName, $prompt ); + /** + * Returns a formatted SELECT tag for HTML FORMs. + * + * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName + * @param string $prompt Text that will appear in the label field + * @param array $options Options to be contained in SELECT element + * @param string $selected Text of the currently selected item + * @param array $selectAttr Array of HTML attributes for the SELECT element + * @param array $optionAttr Array of HTML attributes for the OPTION elements + * @param bool $required True if this field is required + * @param string $errorMsg Text that will appear if an error has occurred + * @return string The formatted INPUT element + */ + function generateSelectDiv($tagName, $prompt, $options, $selected=null, $selectAttr=null, $optionAttr=null, $required=false, $errorMsg=null) + { + $selectAttr['id'] = strtolower(str_replace('/', '_',$tagName));; + $str = $this->Html->selectTag( $tagName, $options, $selected, $selectAttr, $optionAttr ); + $strLabel = $this->labelTag( $tagName, $prompt ); - $divClass = "optional"; + $divClass = "optional"; - if( $required ) - $divClass = "required"; + 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. - $strError = $this->pTag( 'error', $errorMsg ); - $divClass = sprintf( "%s error", $divClass ); - } - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); + if( $this->isFieldError( $tagName ) ) + { + // 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 ); + } + $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); - return $this->divTag( $divClass, $divTagInside ); + return $this->divTag( $divClass, $divTagInside ); - } + } - /** - * Returns a formatted submit widget for HTML FORMs. - * - * @param string $prompt Text that will appear on the widget - * @param array $htmlOptions - * @return string The formatted submit widget - */ - function generateSubmitDiv($displayText, $htmlOptions = null) - { - return $this->divTag( 'submit', $this->Html->submitTag( $displayText, $htmlOptions) ); + /** + * Returns a formatted submit widget for HTML FORMs. + * + * @param string $prompt Text that will appear on the widget + * @param array $htmlOptions + * @return string The formatted submit widget + */ + function generateSubmitDiv($displayText, $htmlOptions = null) + { + 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 - * @param boolean $readOnly True if the form should be rendered as READONLY - * @return string The completed form specified by the $fields parameter - */ - function generateFields( $fields, $readOnly = false ) - { - $strFormFields = ''; + /** + * Generates a form to go onto a HtmlHelper object. + * + * @param array $fields An array of form field definitions + * @param boolean $readOnly True if the form should be rendered as READONLY + * @return string The completed form specified by the $fields parameter + */ + function generateFields( $fields, $readOnly = false ) + { + $strFormFields = ''; - foreach( $fields as $field ) - { + foreach( $fields as $field ) + { if( isset( $field['type'] ) ) { // initialize some optional parameters to avoid the notices @@ -391,80 +391,80 @@ class FormHelper extends Helper $field['htmlOptions']['READONLY'] = "readonly"; } switch( $field['type'] ) - { - case "input" : - // If the size has not been set, initialize it to 40. - if( !isset( $field['size'] ) ) - { - $field['size'] = 40; - } - $strFormFields = $strFormFields.$this->generateInputDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['size'], $field['htmlOptions'] ); - break; - case "checkbox" : - $strFormFields = $strFormFields.$this->generateCheckboxDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['htmlOptions'] ); - break; - case "select"; - case "selectMultiple"; - { - if( "selectMultiple" == $field['type'] ) - { - $field['selectAttr']['multiple'] = 'multiple'; - $field['selectAttr']['class'] = 'selectMultiple'; - } - // If the selected attribute has not been set, initialize it to null. - if( !isset( $field['selected'] ) ) - $field['selected'] = null; - if( !isset( $field['selectAttr'] ) ) - $field['selectAttr'] = null; - if( !isset( $field['optionsAttr'] ) ) - $field['optionsAttr'] = null; + { + case "input" : + // If the size has not been set, initialize it to 40. + if( !isset( $field['size'] ) ) + { + $field['size'] = 40; + } + $strFormFields = $strFormFields.$this->generateInputDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['size'], $field['htmlOptions'] ); + break; + case "checkbox" : + $strFormFields = $strFormFields.$this->generateCheckboxDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['htmlOptions'] ); + break; + case "select"; + case "selectMultiple"; + { + if( "selectMultiple" == $field['type'] ) + { + $field['selectAttr']['multiple'] = 'multiple'; + $field['selectAttr']['class'] = 'selectMultiple'; + } + // If the selected attribute has not been set, initialize it to null. + if( !isset( $field['selected'] ) ) + $field['selected'] = null; + if( !isset( $field['selectAttr'] ) ) + $field['selectAttr'] = null; + if( !isset( $field['optionsAttr'] ) ) + $field['optionsAttr'] = null; - if( $readOnly ) - $field['selectAttr']['DISABLED'] = true; + if( $readOnly ) + $field['selectAttr']['DISABLED'] = true; - $strFormFields = $strFormFields.$this->generateSelectDiv( $field['tagName'], $field['prompt'], $field['options'], $field['selected'], $field['selectAttr'], $field['optionsAttr'], $field['required'], $field['errorMsg'] ); - } - break; - case "area"; - { - if( !isset( $field['rows'] ) ) - $field['rows'] = 10; - if( !isset( $field['cols'] ) ) - $field['cols'] = 60; - $strFormFields = $strFormFields.$this->generateAreaDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['cols'], $field['rows'], $field['htmlOptions'] ); - } - break; - case "fieldset"; - $strFieldsetFields = $this->generateFields( $field['fields'] ); + $strFormFields = $strFormFields.$this->generateSelectDiv( $field['tagName'], $field['prompt'], $field['options'], $field['selected'], $field['selectAttr'], $field['optionsAttr'], $field['required'], $field['errorMsg'] ); + } + break; + case "area"; + { + if( !isset( $field['rows'] ) ) + $field['rows'] = 10; + if( !isset( $field['cols'] ) ) + $field['cols'] = 60; + $strFormFields = $strFormFields.$this->generateAreaDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['cols'], $field['rows'], $field['htmlOptions'] ); + } + break; + case "fieldset"; + $strFieldsetFields = $this->generateFields( $field['fields'] ); - $strFieldSet = sprintf( ' -
- %s -
-

%s

-

%s

-
- %s -
', $field['legend'], $field['noteHeading'], $field['note'], $strFieldsetFields ); - $strFormFields = $strFormFields.$strFieldSet; - break; - case "hidden"; - $strFormFields = $strFormFields . $this->Html->hiddenTag( $field['tagName']); - break; - case "date": - $strFormFields = $strFormFields.$this->generateDate( $field['tagName'], $field['prompt'] ); - break; - case "datetime": - $strFormFields = $strFormFields.$this->generateDateTime( $field['tagName'], $field['prompt'] ); - break; - default: - //bugbug: i don't know how to put out a notice that an unknown type was entered. - break; - } // end switch $field['type'] + $strFieldSet = sprintf( ' +
+ %s +
+

%s

+

%s

+
+ %s +
', $field['legend'], $field['noteHeading'], $field['note'], $strFieldsetFields ); + $strFormFields = $strFormFields.$strFieldSet; + break; + case "hidden"; + $strFormFields = $strFormFields . $this->Html->hiddenTag( $field['tagName']); + break; + case "date": + $strFormFields = $strFormFields.$this->generateDate( $field['tagName'], $field['prompt'], null, null, null, null, $field['selected']); + break; + case "datetime": + $strFormFields = $strFormFields.$this->generateDateTime( $field['tagName'], $field['prompt'], '','','', '', $field['selected']); + break; + default: + //bugbug: i don't know how to put out a notice that an unknown type was entered. + break; + } // end switch $field['type'] } // end if isset $field['type'] - } - return $strFormFields; - } + } + return $strFormFields; + } } ?> \ No newline at end of file diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 918756f09..e9898932f 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -7,10 +7,10 @@ * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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. * @@ -37,386 +37,386 @@ */ class HtmlHelper extends Helper { - /************************************************************************* - * Public variables - *************************************************************************/ + /************************************************************************* + * Public variables + *************************************************************************/ - /**#@+ - * @access public - */ - - /** - * Base URL - * - * @var string - */ - var $base = null; + /**#@+ + * @access public + */ - /** - * URL to current action. - * - * @var string - */ - var $here = null; - /** - * Parameter array. - * - * @var array - */ - var $params = array(); - /** - * Enter description here... - * - * @var string - */ - var $action = null; - /** - * Enter description here... - * - * @var unknown_type - */ - var $data = null; - /** - * Name of model this helper is attached to. - * - * @var string - */ - var $model = null; - /** - * Enter description here... - * - * @var string - */ - var $field = null; + /** + * Base URL + * + * @var string + */ + var $base = null; - /**#@-*/ + /** + * URL to current action. + * + * @var string + */ + var $here = null; + /** + * Parameter array. + * + * @var array + */ + var $params = array(); + /** + * Enter description here... + * + * @var string + */ + var $action = null; + /** + * Enter description here... + * + * @var unknown_type + */ + 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 - *************************************************************************/ + /**#@-*/ - /**#@+ - * @access private - */ + /************************************************************************* + * Private variables + *************************************************************************/ - /** - * Breadcrumbs. - * - * @var array - * @access private - */ - var $_crumbs = array(); + /**#@+ + * @access private + */ + + /** + * Breadcrumbs. + * + * @var array + * @access private + */ + var $_crumbs = array(); - /** - * Adds a link to the breadcrumbs array. - * - * @param string $name Text for link - * @param string $link URL for link - */ - function addCrumb($name, $link) - { - $this->_crumbs[] = array($name, $link); - } + /** + * Adds a link to the breadcrumbs array. + * + * @param string $name Text for link + * @param string $link URL for link + */ + function addCrumb($name, $link) + { + $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 - * and $return. - */ - function charset($charset, $return) - { - return $this->output(sprintf($this->tags['charset'], $charset), $return); - } + /** + * 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 + * and $return. + */ + function charset($charset, $return) + { + 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. - * - * @param string $url - * @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 - * and $return. - */ - function url($url = null, $return = false) - { - if (empty($url)) - { - return $this->here; - } - elseif ($url{0} == '/') - { - $output = $this->base . $url; - } - else - { - $output = $this->base.'/'.strtolower($this->params['controller']).'/'.$url; - } - - return $this->output(preg_replace('/&([^a])/', '&\1', $output), $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. + * + * @param string $url + * @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 + * and $return. + */ + function url($url = null, $return = false) + { + if (empty($url)) + { + return $this->here; + } + elseif ($url{0} == '/') + { + $output = $this->base . $url; + } + else + { + $output = $this->base.'/'.strtolower($this->params['controller']).'/'.$url; + } - /** - * Creates an HTML link. - * - * If $url starts with "http://" this is treated as an external link. Else, - * it is treated as a path to controller/action and parsed with the - * HtmlHelper::url() method. - * - * If the $url is empty, $title is used instead. - * - * @param string $title The content of the A tag. - * @param string $url - * @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 - * and $return. - */ - function link($title, $url = null, $htmlAttributes = null, $confirmMessage = false, $escapeTitle = true, $return = false) - { - // prepare title for html display - if( $escapeTitle ) - { - $title = htmlspecialchars($title, ENT_QUOTES); - } + return $this->output(preg_replace('/&([^a])/', '&\1', $output), $return); + } - $url = $url? $url: $title; + /** + * Creates an HTML link. + * + * If $url starts with "http://" this is treated as an external link. Else, + * it is treated as a path to controller/action and parsed with the + * HtmlHelper::url() method. + * + * If the $url is empty, $title is used instead. + * + * @param string $title The content of the A tag. + * @param string $url + * @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 + * and $return. + */ + function link($title, $url = null, $htmlAttributes = null, $confirmMessage = false, $escapeTitle = true, $return = false) + { + // prepare title for html display + if( $escapeTitle ) + { + $title = htmlspecialchars($title, ENT_QUOTES); + } - if ($confirmMessage) - { - // prepare for HTML display (fix everything except quotes) - $confirmMessage = htmlspecialchars($confirmMessage, ENT_NOQUOTES); - // fix single quotes - $confirmMessage = str_replace("'", "\'", $confirmMessage); - // fix double quotes - $confirmMessage = str_replace('"', '"', $confirmMessage); + $url = $url? $url: $title; - $htmlAttributes['onclick'] = "return confirm('{$confirmMessage}');"; - } + if ($confirmMessage) + { + // prepare for HTML display (fix everything except quotes) + $confirmMessage = htmlspecialchars($confirmMessage, ENT_NOQUOTES); + // fix single quotes + $confirmMessage = str_replace("'", "\'", $confirmMessage); + // fix double quotes + $confirmMessage = str_replace('"', '"', $confirmMessage); - if (strpos($url, '://')) - { - $output = sprintf($this->tags['link'], $url, - $this->_parseAttributes($htmlAttributes), $title); - } - else - { - $output = sprintf($this->tags['link'], $this->url($url, true), - $this->_parseAttributes($htmlAttributes), $title); - } + $htmlAttributes['onclick'] = "return confirm('{$confirmMessage}');"; + } - return $this->output($output, $return); - } + if (strpos($url, '://')) + { + $output = sprintf($this->tags['link'], $url, + $this->_parseAttributes($htmlAttributes), $title); + } + else + { + $output = sprintf($this->tags['link'], $this->url($url, true), + $this->_parseAttributes($htmlAttributes), $title); + } - /** - * Creates a submit widget. - * - * @param string $caption Text on submit button - * @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 - * and $return. - */ - function submit($caption = 'Submit', $htmlAttributes = null, $return = false) - { - $htmlAttributes['value'] = $caption; - return $this->output(sprintf($this->tags['submit'], - $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return); - } + return $this->output($output, $return); + } + + /** + * Creates a submit widget. + * + * @param string $caption Text on submit button + * @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 + * and $return. + */ + function submit($caption = 'Submit', $htmlAttributes = null, $return = false) + { + $htmlAttributes['value'] = $caption; + return $this->output(sprintf($this->tags['submit'], + $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return); + } - /** - * Creates a password input widget. - * - * @param string $fieldName If field is to be used for CRUD, this - * should be modelName/fieldName. - * @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 - * and $return. - */ - function password($fieldName, $htmlAttributes = null, $return = false) - { - $this->setFormTag($fieldName); + /** + * Creates a password input widget. + * + * @param string $fieldName If field is to be used for CRUD, this + * should be modelName/fieldName. + * @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 + * and $return. + */ + function password($fieldName, $htmlAttributes = null, $return = false) + { + $this->setFormTag($fieldName); - if (empty($htmlAttributes['value'])) - { - $htmlAttributes['value'] = $this->tagValue($fieldName); - } + if (empty($htmlAttributes['value'])) + { + $htmlAttributes['value'] = $this->tagValue($fieldName); + } - return $this->output(sprintf($this->tags['password'], $this->model, $this->field, - $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return); - } + return $this->output(sprintf($this->tags['password'], $this->model, $this->field, + $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return); + } - /** - * Creates a textarea widget. - * - * @param string $fieldName If field is to be used for CRUD, this - * should be modelName/fieldName. - * @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 - * and $return. - */ - function textarea($fieldName, $htmlAttributes = null, $return = false) - { - $this->setFormTag($fieldName); - $value = $this->tagValue($fieldName); - - if(!empty($htmlAttributes['value']) && !$value) - { - $value = $htmlAttributes['value']; - } + /** + * Creates a textarea widget. + * + * @param string $fieldName If field is to be used for CRUD, this + * should be modelName/fieldName. + * @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 + * and $return. + */ + function textarea($fieldName, $htmlAttributes = null, $return = false) + { + $this->setFormTag($fieldName); + $value = $this->tagValue($fieldName); - if ($this->tagIsInvalid($this->model, $this->field)) - { - $htmlAttributes['class'] = 'form_error'; - } + if(!empty($htmlAttributes['value']) && !$value) + { + $value = $htmlAttributes['value']; + } - return $this->output(sprintf($this->tags['textarea'], $this->model,$this->field, - $this->_parseAttributes($htmlAttributes, null, ' '), $value), $return); - } + if ($this->tagIsInvalid($this->model, $this->field)) + { + $htmlAttributes['class'] = 'form_error'; + } - /** - * Creates a checkbox widget. - * - * @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 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 - * and $return. - */ - function checkbox($fieldName, $title = null, $htmlAttributes = null, - $return = false) - { - $this->setFormTag($fieldName); - $this->tagValue($fieldName)? $htmlAttributes['checked'] = 'checked': null; - $title = $title? $title: ucfirst($fieldName); - return $this->output(sprintf($this->tags['checkbox'], $this->model, $this->field, - $this->field, - $this->_parseAttributes($htmlAttributes, null, '', ' '), $title), $return); - } + return $this->output(sprintf($this->tags['textarea'], $this->model,$this->field, + $this->_parseAttributes($htmlAttributes, null, ' '), $value), $return); + } - /** - * Creates a link element for CSS stylesheets. - * - * @param string $path Path to CSS file - * @param string $rel Rel attribute. Defaults to "stylesheet". - * @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 - * and $return. - */ - function css($path, $rel = 'stylesheet', $htmlAttributes = null, $return = false) - { - $url = "{$this->webroot}".(COMPRESS_CSS? 'c': '').CSS_URL.$path.".css"; - return $this->output(sprintf($this->tags['css'], $rel, $url, - $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return); - } + /** + * Creates a checkbox widget. + * + * @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 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 + * and $return. + */ + function checkbox($fieldName, $title = null, $htmlAttributes = null, + $return = false) + { + $this->setFormTag($fieldName); + $this->tagValue($fieldName)? $htmlAttributes['checked'] = 'checked': null; + $title = $title? $title: ucfirst($fieldName); + return $this->output(sprintf($this->tags['checkbox'], $this->model, $this->field, + $this->field, + $this->_parseAttributes($htmlAttributes, null, '', ' '), $title), $return); + } - /** - * Creates file input widget. - * - * @param string $fieldName If field is to be used for CRUD, this - * should be modelName/fieldName. - * @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 - * and $return. - */ - function file($fieldName, $htmlAttributes = null, $return = false) - { - return $this->output(sprintf($this->tags['file'], $fieldName, - $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return); - } + /** + * Creates a link element for CSS stylesheets. + * + * @param string $path Path to CSS file + * @param string $rel Rel attribute. Defaults to "stylesheet". + * @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 + * and $return. + */ + function css($path, $rel = 'stylesheet', $htmlAttributes = null, $return = false) + { + $url = "{$this->webroot}".(COMPRESS_CSS? 'c': '').CSS_URL.$path.".css"; + return $this->output(sprintf($this->tags['css'], $rel, $url, + $this->parseHtmlOptions($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 - * and $return. If $this->_crumbs is empty, return null. - */ - function getCrumbs($separator = '»', $return = false) - { - if(count($this->_crumbs)) - { + /** + * Creates file input widget. + * + * @param string $fieldName If field is to be used for CRUD, this + * should be modelName/fieldName. + * @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 + * and $return. + */ + function file($fieldName, $htmlAttributes = null, $return = false) + { + return $this->output(sprintf($this->tags['file'], $fieldName, + $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return); + } - $out = array("base}\">START"); - foreach ($this->_crumbs as $crumb) - { - $out[] = "base}{$crumb[1]}\">{$crumb[0]}"; - } + /** + * 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 + * and $return. If $this->_crumbs is empty, return null. + */ + function getCrumbs($separator = '»', $return = false) + { + if(count($this->_crumbs)) + { - return $this->output(join($separator, $out), $return); - } - else - { - return null; - } - } + $out = array("base}\">START"); + foreach ($this->_crumbs as $crumb) + { + $out[] = "base}{$crumb[1]}\">{$crumb[0]}"; + } - /** - * Creates a hidden input tag. - * - * @param string $fieldName If field is to be used for CRUD, this - * should be modelName/fieldName. - * @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 - * and $return. - */ - function hidden($fieldName, $htmlAttributes = null, $return = false) - { - $this->setFormTag($fieldName); - if(!isset($htmlAttributes['value'])) { - $htmlAttributes['value'] = $this->tagValue($fieldName); - } - return $this->output(sprintf($this->tags['hidden'], $this->model, $this->field, - $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return); - } + return $this->output(join($separator, $out), $return); + } + else + { + return null; + } + } + + /** + * Creates a hidden input tag. + * + * @param string $fieldName If field is to be used for CRUD, this + * should be modelName/fieldName. + * @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 + * and $return. + */ + function hidden($fieldName, $htmlAttributes = null, $return = false) + { + $this->setFormTag($fieldName); + if(!isset($htmlAttributes['value'])) { + $htmlAttributes['value'] = $this->tagValue($fieldName); + } + return $this->output(sprintf($this->tags['hidden'], $this->model, $this->field, + $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return); + } - /** - * Creates a formatted IMG element. - * - * @param string $path Path to the image file. - * @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 - * and $return. - */ + /** + * Creates a formatted IMG element. + * + * @param string $path Path to the image file. + * @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 + * and $return. + */ function image($path, $htmlAttributes = null, $return = false) { @@ -424,1037 +424,1080 @@ 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 If field is to be used for CRUD, this - * should be modelName/fieldName. - * @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 - * and $return. - */ - function input($fieldName, $htmlAttributes = null, $return = false) - { - $this->setFormTag($fieldName); + /** + * Creates a text input widget. + * + * @param string $fieldName If field is to be used for CRUD, this + * should be modelName/fieldName. + * @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 + * and $return. + */ + function input($fieldName, $htmlAttributes = null, $return = false) + { + $this->setFormTag($fieldName); - if (!isset($htmlAttributes['value'])) - { - $htmlAttributes['value'] = $this->tagValue($fieldName); - } + if (!isset($htmlAttributes['value'])) + { + $htmlAttributes['value'] = $this->tagValue($fieldName); + } - if ($this->tagIsInvalid($this->model, $this->field)) - { - $htmlAttributes['class'] = 'form_error'; - } + if ($this->tagIsInvalid($this->model, $this->field)) + { + $htmlAttributes['class'] = 'form_error'; + } - return $this->output(sprintf($this->tags['input'], $this->model, $this->field, - $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return); - } + return $this->output(sprintf($this->tags['input'], $this->model, $this->field, + $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return); + } - /** - * Creates a set of radio widgets. - * - * @param string $fieldName If field is to be used for CRUD, this - * should be modelName/fieldName. - * @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 - * and $return. - */ - function radio($fieldName, $options, $inbetween = null, $htmlAttributes = null, - $return = false) - { - $this->setFormTag($fieldName); - $value = isset($htmlAttributes['value'])? $htmlAttributes['value']: $this->tagValue($fieldName); - $out = array(); - foreach ($options as $opt_value=>$opt_title) - { - $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'], $individual_tag_name, $this->model, $this->field, $individual_tag_name, $parsed_options, $opt_title); - } + /** + * Creates a set of radio widgets. + * + * @param string $fieldName If field is to be used for CRUD, this + * should be modelName/fieldName. + * @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 + * and $return. + */ + function radio($fieldName, $options, $inbetween = null, $htmlAttributes = null, + $return = false) + { + $this->setFormTag($fieldName); + $value = isset($htmlAttributes['value'])? $htmlAttributes['value']: $this->tagValue($fieldName); + $out = array(); + foreach ($options as $opt_value=>$opt_title) + { + $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'], $individual_tag_name, $this->model, $this->field, $individual_tag_name, $parsed_options, $opt_title); + } - $out = join($inbetween, $out); - return $this->output($out? $out: null, $return); - } + $out = join($inbetween, $out); + return $this->output($out? $out: null, $return); + } - /** - * Returns a row of formatted and named TABLE headers. - * - * @param array $names - * @param array $tr_options - * @param array $th_options - * @return string - */ - function tableHeaders($names, $tr_options=null, $th_options=null) - { - $out = array(); - foreach ($names as $arg) - { - $out[] = sprintf($this->tags['tableheader'], $this->parseHtmlOptions($th_options), $arg); - } - return sprintf($this->tags['tablerow'], $this->parseHtmlOptions($tr_options), join(' ', $out)); - } + /** + * Returns a row of formatted and named TABLE headers. + * + * @param array $names + * @param array $tr_options + * @param array $th_options + * @return string + */ + function tableHeaders($names, $tr_options=null, $th_options=null) + { + $out = array(); + foreach ($names as $arg) + { + $out[] = sprintf($this->tags['tableheader'], $this->parseHtmlOptions($th_options), $arg); + } + return sprintf($this->tags['tablerow'], $this->parseHtmlOptions($tr_options), 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 $tr_options HTML options for TR elements - * @param array $td_options HTML options for TD elements - * @return string - */ - function tableCells($data, $odd_tr_options=null, $even_tr_options=null) - { - if (empty($data[0]) || !is_array($data[0])) - { - $data = array($data); - } + /** + * Returns a formatted string of table rows (TR's with TD's in them). + * + * @param array $data Array of table data + * @param array $tr_options HTML options for TR elements + * @param array $td_options HTML options for TD elements + * @return string + */ + function tableCells($data, $odd_tr_options=null, $even_tr_options=null) + { + if (empty($data[0]) || !is_array($data[0])) + { + $data = array($data); + } - $count=0; - foreach ($data as $line) - { - $count++; - $cells_out = array(); - foreach ($line as $cell) - { - $cells_out[] = sprintf($this->tags['tablecell'], null, $cell); - } + $count=0; + foreach ($data as $line) + { + $count++; + $cells_out = array(); + foreach ($line as $cell) + { + $cells_out[] = 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? $odd_tr_options: $even_tr_options); + $out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cells_out)); + } - return join("\n", $out); - } + return join("\n", $out); + } - /** - * Returns value of $fieldName. False is the tag does not exist. - * - * @param string $fieldName - * @return unknown Value of the named tag. - */ - function tagValue ($fieldName) - { - $this->setFormTag($fieldName); - return isset($this->params['data'][$this->model][$this->field])? $this->params['data'][$this->model][$this->field]: false; - } + /** + * Returns value of $fieldName. False is the tag does not exist. + * + * @param string $fieldName + * @return unknown Value of the named tag. + */ + function tagValue ($fieldName) + { + $this->setFormTag($fieldName); + return isset($this->params['data'][$this->model][$this->field])? $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 - * @param string $field - * @return unknown - */ - function tagIsInvalid ($model, $field) - { - return empty($this->validationErrors[$model][$field])? 0: $this->validationErrors[$model][$field]; - } + /** + * Returns false if given FORM field has no errors. Otherwise it returns the constant set in the array Model->validationErrors. + * + * @param string $model + * @param string $field + * @return unknown + */ + function tagIsInvalid ($model, $field) + { + return empty($this->validationErrors[$model][$field])? 0: $this->validationErrors[$model][$field]; + } - /** - * Returns number of errors in a submitted FORM. - * - * @return int Number of errors - */ - function validate () - { - $args = func_get_args(); - $errors = call_user_func_array(array(&$this, 'validateErrors'), $args); + /** + * Returns number of errors in a submitted FORM. + * + * @return int Number of errors + */ + function validate () + { + $args = func_get_args(); + $errors = call_user_func_array(array(&$this, 'validateErrors'), $args); - return count($errors); - } + return count($errors); + } - /** - * Validates a FORM according to the rules set up in the Model. - * - * @return int Number of errors - */ - function validateErrors () - { - $objects = func_get_args(); - if (!count($objects)) return false; + /** + * Validates a FORM according to the rules set up in the Model. + * + * @return int Number of errors + */ + function validateErrors () + { + $objects = func_get_args(); + if (!count($objects)) return false; - $errors = array(); - foreach ($objects as $object) - { - $errors = array_merge($errors, $object->invalidFields($object->data)); - } + $errors = array(); + foreach ($objects as $object) + { + $errors = array_merge($errors, $object->invalidFields($object->data)); + } - return $this->validationErrors = (count($errors)? $errors: false); - } + return $this->validationErrors = (count($errors)? $errors: false); + } - /** - * Returns a formatted error message for given FORM field, NULL if no errors. - * - * @param string $field If field is to be used for CRUD, this should be modelName/fieldName - * @param string $text - * @return string If there are errors this method returns an error message, else NULL. - */ - function tagErrorMsg ($field, $text) - { - $error = 1; - $this->setFormTag($field); + /** + * Returns a formatted error message for given FORM field, NULL if no errors. + * + * @param string $field If field is to be used for CRUD, this should be modelName/fieldName + * @param string $text + * @return string If there are errors this method returns an error message, else NULL. + */ + function tagErrorMsg ($field, $text) + { + $error = 1; + $this->setFormTag($field); - if ($error == $this->tagIsInvalid($this->model, $this->field)) - { - return sprintf(SHORT_ERROR_MESSAGE, is_array($text)? (empty($text[$error-1])? 'Error in field': $text[$error-1]): $text); - } - else - { - return null; - } - } + if ($error == $this->tagIsInvalid($this->model, $this->field)) + { + return sprintf(SHORT_ERROR_MESSAGE, is_array($text)? (empty($text[$error-1])? 'Error in field': $text[$error-1]): $text); + } + else + { + return null; + } + } - /** - * Sets this helper's model and field properties to the slash-separated value-pair in $tagValue. - * - * @param string $tagValue Slash-separated model/field pair. - */ - function setFormTag($tagValue) - { - return list($this->model, $this->field) = explode("/", $tagValue); - } + /** + * Sets this helper's model and field properties to the slash-separated value-pair in $tagValue. + * + * @param string $tagValue Slash-separated model/field pair. + */ + function setFormTag($tagValue) + { + return list($this->model, $this->field) = explode("/", $tagValue); + } - /**#@-*/ + /**#@-*/ - /************************************************************************* - * Private methods - *************************************************************************/ + /************************************************************************* + * Private methods + *************************************************************************/ - /**#@+ - * @access private - */ + /**#@+ + * @access private + */ - /** - * Returns a space-separated 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' - * - * And it's value is one of: - * + 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 parameeter is not outputed. - * - * @param array $options Array of options. - * @param array $exclude Array of options to be excluded. - * @param string $insertBefore String to be inserted before options. - * @param string $insertAfter String to be inserted ater options. - * @return string - */ - function _parseAttributes($options, $exclude = null, $insertBefore = ' ', - $insertAfter = null) - { - $minimizedAttributes = array( - 'compact', - 'checked', - 'declare', - 'readonly', - 'disabled', - 'selected', - 'defer', - 'ismap', - 'nohref', - 'noshade', - 'nowrap', - 'multiple', - 'noresize'); + /** + * Returns a space-separated 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' + * + * And it's value is one of: + * + 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 parameeter is not outputed. + * + * @param array $options Array of options. + * @param array $exclude Array of options to be excluded. + * @param string $insertBefore String to be inserted before options. + * @param string $insertAfter String to be inserted ater options. + * @return string + */ + function _parseAttributes($options, $exclude = null, $insertBefore = ' ', + $insertAfter = null) + { + $minimizedAttributes = array( + 'compact', + 'checked', + 'declare', + 'readonly', + 'disabled', + 'selected', + 'defer', + 'ismap', + 'nohref', + 'noshade', + 'nowrap', + 'multiple', + 'noresize'); - if (!is_array($exclude)) - { - $exclude = array(); - } + if (!is_array($exclude)) + { + $exclude = array(); + } - if (is_array($options)) - { - $out = array(); + if (is_array($options)) + { + $out = array(); - foreach ($options as $key => $value) - { - if (!in_array($key, $exclude)) - { - if (in_array($key, $minimizedAttributes) && ($value === 1 || - $value === true || $value === 'true' || in_array($value, - $minimizedAttributes))) - { - $value = $key; - } - elseif (in_array($key, $minimizedAttributes)) - { - continue; - } - $out[] = "{$key}=\"{$value}\""; - } - } - $out = join(' ', $out); - return $out? $insertBefore.$out.$insertAfter: null; - } - else - { - return $options? $insertBefore.$options.$insertAfter: null; - } - } + foreach ($options as $key => $value) + { + if (!in_array($key, $exclude)) + { + if (in_array($key, $minimizedAttributes) && ($value === 1 || + $value === true || $value === 'true' || in_array($value, + $minimizedAttributes))) + { + $value = $key; + } + elseif (in_array($key, $minimizedAttributes)) + { + continue; + } + $out[] = "{$key}=\"{$value}\""; + } + } + $out = join(' ', $out); + return $out? $insertBefore.$out.$insertAfter: null; + } + else + { + return $options? $insertBefore.$options.$insertAfter: null; + } + } - /**#@-*/ + /**#@-*/ - /************************************************************************* - * 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 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 - * and $return. - */ - function areaTag($tagName, $cols = 60, $rows = 10, $htmlAttributes = null, $return = false) - { - $htmlAttributes['cols'] = $cols; - $htmlAttributes['rows'] = $rows; - return $this->textarea($tagName, $htmlAttributes, $return); - } + /** + * @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 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 + * and $return. + */ + function areaTag($tagName, $cols = 60, $rows = 10, $htmlAttributes = null, $return = false) + { + $htmlAttributes['cols'] = $cols; + $htmlAttributes['rows'] = $rows; + 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 - * and $return. - */ - function charsetTag($charset, $return = false) - { - return $this->charset($charset, $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 + * and $return. + */ + function charsetTag($charset, $return = false) + { + 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 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 - * and $return. - */ - function checkboxTag($fieldName, $title = null, $htmlAttributes = null, $return = false) - { - return $this->checkbox($fieldName, $title, $htmlAttributes, $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 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 + * and $return. + */ + function checkboxTag($fieldName, $title = null, $htmlAttributes = null, $return = false) + { + 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 $rel Rel attribute. Defaults to "stylesheet". - * @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 - * and $return. - */ - function cssTag($path, $rel = 'stylesheet', $htmlAttributes = null, $return = false) - { - return $this->css($path, $rel , $htmlAttributes , $return ); - } + /** + * @deprecated Name changed to 'css'. Version 0.9.2. + * @see HtmlHelper::css() + * @param string $path Path to CSS file + * @param string $rel Rel attribute. Defaults to "stylesheet". + * @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 + * and $return. + */ + function cssTag($path, $rel = 'stylesheet', $htmlAttributes = null, $return = false) + { + return $this->css($path, $rel , $htmlAttributes , $return ); + } - /** - * @deprecated Name changed to 'file'. Version 0.9.2. - * @see HtmlHelper::file() - * @param string $fieldName If field is to be used for CRUD, this - * should be modelName/fieldName. - * @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 - * and $return. - */ - function fileTag($fieldName, $htmlAttributes = null, $return = false) - { - return $this->file($fieldName, $htmlAttributes, $return); - } + /** + * @deprecated Name changed to 'file'. Version 0.9.2. + * @see HtmlHelper::file() + * @param string $fieldName If field is to be used for CRUD, this + * should be modelName/fieldName. + * @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 + * and $return. + */ + function fileTag($fieldName, $htmlAttributes = null, $return = false) + { + 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 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 - * and $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 $alt - * @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 - * and $return. - */ - function imageTag($path, $alt = null, $htmlAttributes = null, $return = false) - { - $htmlAttributes['alt'] = $alt; - return $this->image($path, $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 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 + * and $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 $alt + * @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 + * and $return. + */ + function imageTag($path, $alt = null, $htmlAttributes = null, $return = false) + { + $htmlAttributes['alt'] = $alt; + 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 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 - * and $return. - */ - //function inputTag($fieldName, $value = null, $htmlAttributes = null, $return = false) - //{ - // $htmlAttributes['value'] = $value; - // return $this->input($fieldName, $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 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 + * and $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) - { - $this->setFormTag($tagName); - $htmlOptions['value'] = isset($htmlOptions['value'])? $htmlOptions['value']: $this->tagValue($tagName); - $this->tagIsInvalid($this->model,$this->field)? $htmlOptions['class'] = 'form_error': null; - return $this->output(sprintf($this->tags['input'], $this->model, $this->field, $this->parseHtmlOptions($htmlOptions, null, '', ' '))); - } + function inputTag($tagName, $size=20, $htmlOptions=null) + { + $this->setFormTag($tagName); + $htmlOptions['value'] = isset($htmlOptions['value'])? $htmlOptions['value']: $this->tagValue($tagName); + $this->tagIsInvalid($this->model,$this->field)? $htmlOptions['class'] = 'form_error': null; + 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 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 - * and $return. - */ - function linkOut($title, $url = null, $htmlAttributes = null, $escapeTitle = true, $return = false) - { + /** + * @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 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 + * and $return. + */ + function linkOut($title, $url = null, $htmlAttributes = null, $escapeTitle = true, $return = false) + { 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 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 - * and $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 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 + * and $return. + */ function linkTo($title, $url, $htmlAttributes = null, $confirmMessage = false, $escapeTitle = true, $return = false) { 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. - * @param array $exclude Array of options to be excluded. - * @param string $insertBefore String to be inserted before options. - * @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); - // } + /** + * @deprecated Name changed to '_parseAttributes'. Version 0.9.2. + * @see HtmlHelper::_parseAttributes() + * @param array $options Array of options. + * @param array $exclude Array of options to be excluded. + * @param string $insertBefore String to be inserted before options. + * @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, $insert_before=' ', $insert_after=null) - { - if (!is_array($exclude)) $exclude = array(); + function parseHtmlOptions($options, $exclude=null, $insert_before=' ', $insert_after=null) + { + if (!is_array($exclude)) $exclude = array(); - if (is_array($options)) - { - $out = array(); - foreach ($options as $k=>$v) - { - if (!in_array($k, $exclude)) - { - $out[] = "{$k}=\"{$v}\""; - } - } - $out = join(' ', $out); - return $out? $insert_before.$out.$insert_after: null; - } - else - { - return $options? $insert_before.$options.$insert_after: null; - } - } + if (is_array($options)) + { + $out = array(); + foreach ($options as $k=>$v) + { + if (!in_array($k, $exclude)) + { + $pos = strpos($v, '"'); + if($pos === false) + { + $out[] = "{$k}=\"{$v}\""; + } + else + { + $out[] = "{$k}='{$v}'"; + } - /** - * @deprecated Name changed to 'password'. Version 0.9.2. - * @see HtmlHelper::password() - * @param string $fieldName If field is to be used for CRUD, this - * should be modelName/fieldName. - * @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 - * and $return. - */ - function passwordTag($fieldName, $size = 20, $htmlAttributes = null, $return = false) - { - $args = func_get_args(); - return call_user_func_array(array(&$this, "password"), $args); - } + } + } + $out = join(' ', $out); + return $out? $insert_before.$out.$insert_after: null; + } + else + { + return $options? $insert_before.$options.$insert_after: null; + } + } - /** - * @deprecated Name changed to 'radio'. Version 0.9.2. - * @see HtmlHelper::radio() - * @param string $fieldName If field is to be used for CRUD, this - * should be modelName/fieldName. - * @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 - * and $return. - */ - function radioTags($fieldName, $options, $inbetween = null, $htmlAttributes = null, - $return = false) - { - return $this->radio($fieldName, $options, $inbetween, $htmlAttributes, $return); - } + /** + * @deprecated Name changed to 'password'. Version 0.9.2. + * @see HtmlHelper::password() + * @param string $fieldName If field is to be used for CRUD, this + * should be modelName/fieldName. + * @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 + * and $return. + */ + function passwordTag($fieldName, $size = 20, $htmlAttributes = null, $return = false) + { + $args = func_get_args(); + return call_user_func_array(array(&$this, "password"), $args); + } - /** - * 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 boolean $show_empty Show/hide the empty select option - * @param array $select_attr 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) - { - $this->setFormTag($fieldName); + /** + * @deprecated Name changed to 'radio'. Version 0.9.2. + * @see HtmlHelper::radio() + * @param string $fieldName If field is to be used for CRUD, this + * should be modelName/fieldName. + * @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 + * and $return. + */ + function radioTags($fieldName, $options, $inbetween = null, $htmlAttributes = null, + $return = false) + { + return $this->radio($fieldName, $options, $inbetween, $htmlAttributes, $return); + } - // do not display the select tag if no option elements are avaible - if (!is_array($option_elements) || count($option_elements) == 0) - { - return null; - } + /** + * 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 boolean $show_empty Show/hide the empty select option + * @param array $select_attr 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) + { + $this->setFormTag($fieldName); - if( isset($select_attr) && array_key_exists( "multiple", $select_attr) ) - { - $select[] = sprintf($this->tags['selectmultiplestart'], $this->model, $this->field, $this->parseHtmlOptions($select_attr)); - } - else - { - $select[] = sprintf($this->tags['selectstart'], $this->model, $this->field, $this->parseHtmlOptions($select_attr)); - } + // do not display the select tag if no option elements are avaible + if (!is_array($option_elements) || count($option_elements) == 0) + { + return null; + } - if($showEmpty == true) - { - $select[] = sprintf($this->tags['selectempty'], $this->parseHtmlOptions($optionAttr)); - } + if( isset($select_attr) && array_key_exists( "multiple", $select_attr) ) + { + $select[] = sprintf($this->tags['selectmultiplestart'], $this->model, $this->field, $this->parseHtmlOptions($select_attr)); + } + else + { + $select[] = sprintf($this->tags['selectstart'], $this->model, $this->field, $this->parseHtmlOptions($select_attr)); + } - foreach ($option_elements as $name=>$title) - { - $options_here = $optionAttr; - if (!empty($selected) && ($selected == $name)) - { - $options_here['selected'] = 'selected'; - } else if ( is_array($selected) && array_key_exists($name, $selected) ) - { - $options_here['selected'] = 'selected'; - } - $select[] = sprintf($this->tags['selectoption'], $name, $this->parseHtmlOptions($options_here), $title); - } + if($showEmpty == true) + { + $select[] = sprintf($this->tags['selectempty'], $this->parseHtmlOptions($optionAttr)); + } - $select[] = sprintf($this->tags['selectend']); + foreach ($option_elements as $name=>$title) + { + $options_here = $optionAttr; + if (!empty($selected) && ($selected == $name)) + { + $options_here['selected'] = 'selected'; + } else if ( is_array($selected) && array_key_exists($name, $selected) ) + { + $options_here['selected'] = 'selected'; + } + $select[] = sprintf($this->tags['selectoption'], $name, $this->parseHtmlOptions($options_here), $title); + } - return implode("\n", $select); - } + $select[] = sprintf($this->tags['selectend']); + + return implode("\n", $select); + } - /** - * @deprecated Name changed to 'url'. Version 0.9.2. - * @see HtmlHelper::url() - */ - function urlFor($url) - { - return $this->url($url); - } + /** + * @deprecated Name changed to 'url'. Version 0.9.2. + * @see HtmlHelper::url() + */ + function urlFor($url) + { + return $this->url($url); + } - /** - * @deprecated Name changed to 'submit'. Version 0.9.2. - * @see HtmlHelper::submit() - */ - function submitTag() - { - $args = func_get_args(); - return call_user_func_array(array(&$this, "submit"), $args); - } + /** + * @deprecated Name changed to 'submit'. Version 0.9.2. + * @see HtmlHelper::submit() + */ + function submitTag() + { + $args = func_get_args(); + return call_user_func_array(array(&$this, "submit"), $args); + } - /************************************************************************* - * Moved methods - *************************************************************************/ + /************************************************************************* + * Moved methods + *************************************************************************/ - /** - * @deprecated Moved to TextHelper. Version 0.9.2. - */ - function trim() - { - die("Method HtmlHelper::trim() was moved to TextHelper::trim()."); - } + /** + * @deprecated Moved to TextHelper. Version 0.9.2. + */ + function trim() + { + die("Method HtmlHelper::trim() was moved to TextHelper::trim()."); + } - /** - * @deprecated Moved to JavascriptHelper. Version 0.9.2. - */ - function javascriptIncludeTag($url) - { - die("Method HtmlHelper::javascriptIncludeTag() was moved to JavascriptHelper::link()."); - } + /** + * @deprecated Moved to JavascriptHelper. Version 0.9.2. + */ + function javascriptIncludeTag($url) + { + die("Method HtmlHelper::javascriptIncludeTag() was moved to JavascriptHelper::link()."); + } - /** - * @deprecated Moved to JavascriptHelper. Version 0.9.2. - */ - function javascriptTag($script) - { - die("Method HtmlHelper::javascriptTag() was moved to JavascriptHelper::codeBlock()."); - } + /** + * @deprecated Moved to JavascriptHelper. Version 0.9.2. + */ + function javascriptTag($script) + { + 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. - * @param string $type FORM type (POST/GET). - * @param array $htmlAttributes - * @return string An formatted opening FORM tag. - * @deprecated This is very WYSIWYG unfriendly, use HtmlHelper::url() to get - * contents of "action" attribute. Version 0.9.2. - */ - function formTag($target=null, $type='post', $htmlAttributes=null) - { - $htmlAttributes['action'] = $this->UrlFor($target); - $htmlAttributes['method'] = $type=='get'? 'get': 'post'; - $type == 'file'? $htmlAttributes['enctype'] = 'multipart/form-data': null; + /** + * Returns an HTML FORM element. + * + * @param string $target URL for the FORM's ACTION attribute. + * @param string $type FORM type (POST/GET). + * @param array $htmlAttributes + * @return string An formatted opening FORM tag. + * @deprecated This is very WYSIWYG unfriendly, use HtmlHelper::url() to get + * contents of "action" attribute. Version 0.9.2. + */ + function formTag($target=null, $type='post', $htmlAttributes=null) + { + $htmlAttributes['action'] = $this->UrlFor($target); + $htmlAttributes['method'] = $type=='get'? 'get': 'post'; + $type == 'file'? $htmlAttributes['enctype'] = 'multipart/form-data': null; - return sprintf($this->tags['form'], $this->parseHtmlOptions($htmlAttributes, null, '')); - } + 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 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 - * and $return. If $this->_crumbs is empty, return null. - * @deprecated This seems useless. Version 0.9.2. - */ - function guiListTree($data, $htmlAttributes = null, $bodyKey = 'body', $childrenKey='children', $return = false) - { - $out = "_parseAttributes($htmlAttributes).">\n"; + /** + * Generates a nested unordered list tree from an array. + * + * @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 + * and $return. If $this->_crumbs is empty, return null. + * @deprecated This seems useless. Version 0.9.2. + */ + function guiListTree($data, $htmlAttributes = null, $bodyKey = 'body', $childrenKey='children', $return = false) + { + $out = "_parseAttributes($htmlAttributes).">\n"; - foreach ($data as $item) - { - $out .= "
  • {$item[$bodyKey]}
  • \n"; - if (isset($item[$childrenKey]) && is_array($item[$childrenKey]) && count($item[$childrenKey])) - { - $out .= $this->guiListTree($item[$childrenKey], $htmlAttributes, $bodyKey, $childrenKey); - } - } + foreach ($data as $item) + { + $out .= "
  • {$item[$bodyKey]}\n"; + if (isset($item[$childrenKey]) && is_array($item[$childrenKey]) && count($item[$childrenKey])) + { + $out .= $this->guiListTree($item[$childrenKey], $htmlAttributes, $bodyKey, $childrenKey); + } + $out .= "
  • \n"; + } - $out .= "\n"; + $out .= "\n"; - return $this->output($out, $return); - } + return $this->output($out, $return); + } - /** - * Returns a mailto: link. - * - * @param string $title Title of the link, or the e-mail address - * (if the same). - * @param string $email E-mail address if different from title. - * @param array $options - * @return string Formatted A tag - * @deprecated This should be done using a content filter. Version 0.9.2. - */ - function linkEmail($title, $email=null, $options=null) - { - // if no $email, then title contains the email. - if (empty($email)) $email = $title; + /** + * Returns a mailto: link. + * + * @param string $title Title of the link, or the e-mail address + * (if the same). + * @param string $email E-mail address if different from title. + * @param array $options + * @return string Formatted A tag + * @deprecated This should be done using a content filter. Version 0.9.2. + */ + function linkEmail($title, $email=null, $options=null) + { + // if no $email, then title contains the email. + if (empty($email)) $email = $title; - $match = array(); + $match = array(); - // does the address contain extra attributes? - preg_match('!^(.*)(\?.*)$!', $email, $match); + // does the address contain extra attributes? + preg_match('!^(.*)(\?.*)$!', $email, $match); - // plaintext - if (empty($options['encode']) || !empty($match[2])) - { - return sprintf($this->tags['mailto'], $email, $this->parseHtmlOptions($options), $title); - } - // encoded to avoid spiders - else - { - $email_encoded = null; - for ($ii=0; $ii < strlen($email); $ii++) - { - if(preg_match('!\w!',$email[$ii])) - { - $email_encoded .= '%' . bin2hex($email[$ii]); - } - else - { - $email_encoded .= $email[$ii]; - } - } + // plaintext + if (empty($options['encode']) || !empty($match[2])) + { + return sprintf($this->tags['mailto'], $email, $this->parseHtmlOptions($options), $title); + } + // encoded to avoid spiders + else + { + $email_encoded = null; + for ($ii=0; $ii < strlen($email); $ii++) + { + if(preg_match('!\w!',$email[$ii])) + { + $email_encoded .= '%' . bin2hex($email[$ii]); + } + else + { + $email_encoded .= $email[$ii]; + } + } - $title_encoded = null; - for ($ii=0; $ii < strlen($title); $ii++) - { - $title_encoded .= preg_match('/^[A-Za-z0-9]$/', $title[$ii])? '&#x' . bin2hex($title[$ii]).';': $title[$ii]; - } + $title_encoded = null; + for ($ii=0; $ii < strlen($title); $ii++) + { + $title_encoded .= preg_match('/^[A-Za-z0-9]$/', $title[$ii])? '&#x' . bin2hex($title[$ii]).';': $title[$ii]; + } - return sprintf($this->tags['mailto'], $email_encoded, $this->parseHtmlOptions($options, array('encode')), $title_encoded); - } - } + return sprintf($this->tags['mailto'], $email_encoded, $this->parseHtmlOptions($options, array('encode')), $title_encoded); + } + } - /** - * Returns a generic HTML tag (no content). - * - * Examples: - * + 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 "/>") - * @return string The formatted HTML tag - * @deprecated This seems useless. Version 0.9.2. - */ - function tag($name, $options=null, $open=false) - { - $tag = "<$name ". $this->parseHtmlOptions($options); - $tag .= $open? ">" : " />"; - return $tag; - } + /** + * Returns a generic HTML tag (no content). + * + * Examples: + * + 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 "/>") + * @return string The formatted HTML tag + * @deprecated This seems useless. Version 0.9.2. + */ + function tag($name, $options=null, $open=false) + { + $tag = "<$name ". $this->parseHtmlOptions($options); + $tag .= $open? ">" : " />"; + return $tag; + } - /** - * Returns a generic HTML tag with content. - * - * Examples: - * - * content_tag("p", "Hello world!") =>

    Hello world!

    - * content_tag("div", content_tag("p", "Hello world!"), - * array("class" => "strong")) =>

    Hello world!

    - *
    - * - * @param string $name Name of HTML element - * @param array $options HTML options - * @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. - */ - function contentTag($name, $content, $options=null) - { - return "<$name ". $this->parseHtmlOptions($options). ">$content"; - } + /** + * Returns a generic HTML tag with content. + * + * Examples: + * + * content_tag("p", "Hello world!") =>

    Hello world!

    + * content_tag("div", content_tag("p", "Hello world!"), + * array("class" => "strong")) =>

    Hello world!

    + *
    + * + * @param string $name Name of HTML element + * @param array $options HTML options + * @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. + */ + function contentTag($name, $content, $options=null) + { + return "<$name ". $this->parseHtmlOptions($options). ">$content"; + } - /** - * Returns a SELECT element for days. - * - * @param string $tagName Prefix name for the SELECT element - * @param string $value - * @param string $selected Option which is selected. - * @param array $optionAttr Attribute array for the option elements. - * @return string - */ - function dayOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) - { - $value = isset($value)? $value : $this->tagValue($tagName."_day"); - $dayValue = empty($value) ? date('d') : $value; - $days=array('1'=>'1','2'=>'2','3'=>'3','4'=>'4', - '5'=>'5','6'=>'6','7'=>'7','8'=>'8','9'=>'9', - '10'=>'10','11'=>'11','12'=>'12', - '13'=>'13','14'=>'14','15'=>'15', - '16'=>'16','17'=>'17','18'=>'18', - '19'=>'19','20'=>'20','21'=>'21', - '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, - $optionAttr); - return $option; - } + /** + * Returns a SELECT element for days. + * + * @param string $tagName Prefix name for the SELECT element + * @param string $value + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @return string + */ + function dayOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) + { + $value = isset($value)? $value : $this->tagValue($tagName."_day"); + $dayValue = empty($selected) ? date('d') : $selected; + $days=array('01'=>'1','02'=>'2','03'=>'3','04'=>'4', + '05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9', + '10'=>'10','11'=>'11','12'=>'12', + '13'=>'13','14'=>'14','15'=>'15', + '16'=>'16','17'=>'17','18'=>'18', + '19'=>'19','20'=>'20','21'=>'21', + '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, + $optionAttr); + return $option; + } - /** - * Returns a SELECT element for years - * - * @param string $tagName Prefix name for the SELECT element - * @param string $value - * @param integer $minYear First year in sequence - * @param integer $maxYear Last year in sequence - * @param string $selected Option which is selected. - * @param array $optionAttr Attribute array for the option elements. - * @return string - */ - function yearOptionTag( $tagName, $value=null, $minYear=null, $maxYear=null, $selected=null, $optionAttr=null) - { - $value = isset($value)? $value : $this->tagValue($tagName."_year"); + /** + * Returns a SELECT element for years + * + * @param string $tagName Prefix name for the SELECT element + * @param string $value + * @param integer $minYear First year in sequence + * @param integer $maxYear Last year in sequence + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @return string + */ + function yearOptionTag( $tagName, $value=null, $minYear=null, $maxYear=null, $selected=null, $optionAttr=null) + { + $value = isset($value)? $value : $this->tagValue($tagName."_year"); - $yearValue = empty($value) ? date('Y') : $value; + $yearValue = empty($selected) ? date('Y') : $selected; + $currentYear = date('Y'); - $maxYear = is_null($maxYear) ? $yearValue + 10 : $maxYear; + $maxYear = is_null($maxYear) ? $currentYear + 11 : $maxYear + 1; - $minYear = is_null($minYear) ? $yearValue - 10 : $minYear; + $minYear = is_null($minYear) ? $currentYear - 60 : $minYear; - if ( $minYear>$minYear) - { - $tmpYear = $minYear; - $minYear = $maxYear; - $maxYear = $tmpYear; - }; - $minYear = $yearValue < $minYear ? $yearValue : $minYear; - $maxYear = $yearValue > $maxYear ? $yearValue : $maxYear; + if ( $minYear > $maxYear) + { + $tmpYear = $minYear; + $minYear = $maxYear; + $maxYear = $tmpYear; + }; + $minYear = $currentYear < $minYear ? $currentYear : $minYear; + $maxYear = $currentYear > $maxYear ? $currentYear : $maxYear; - for ( $yearCounter=$minYear; $yearCounter<$maxYear; $yearCounter++) - { - $years[$yearCounter]=$yearCounter; - } + for ( $yearCounter = $minYear; $yearCounter < $maxYear; $yearCounter++) + { + $years[$yearCounter] = $yearCounter; + } - $option = $this->selectTag($tagName.'_year', $years, $yearValue, - $optionAttr); - return $option; - } + $option = $this->selectTag($tagName.'_year', $years, $yearValue, + $optionAttr); + return $option; + } - /** - * Returns a SELECT element for months. - * - * @param string $tagName Prefix name for the SELECT element - * @param string $value - * @param string $selected Option which is selected. - * @param array $optionAttr Attribute array for the option elements. - * @return string - */ - function monthOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) - { - $value = isset($value)? $value : $this->tagValue($tagName."_month"); - $monthValue = empty($value) ? date('m') : $value ; - $months=array('1'=>'January','2'=>'February','3'=>'March', - '4'=>'April','5'=>'May','6'=>'June','7'=>'July','8'=>'August', - '9'=>'September','10'=>'October','11'=>'November','12'=>'December'); - $option = $this->selectTag($tagName.'_month', $months, $monthValue, - $optionAttr); - return $option; - } + /** + * Returns a SELECT element for months. + * + * @param string $tagName Prefix name for the SELECT element + * @param string $value + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @return string + */ + function monthOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) + { + $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, + $optionAttr); + return $option; + } - /** - * Returns a SELECT element for hours. - * - * @param string $tagName Prefix name for the SELECT element - * @param string $value - * @param boolean $format24Hours True for 24 hours format - * @param string $selected Option which is selected. - * @param array $optionAttr Attribute array for the option elements. - * @return string - */ - function hourOptionTag( $tagName,$value=null, - $format24Hours = false, - $selected=null, - $optionAttr=null ) - { - $value = isset($value)? $value : $this->tagValue($tagName."_hour"); - if ( $format24Hours ) - { - $hourValue = empty($value) ? date('H') : $value; - } - else - { - $hourValue = empty($value) ? date('g') : $value; - } - if ( $format24Hours ) - { $hours = array('0'=>'00','1'=>'01','2'=>'02','3'=>'03','4'=>'04', - '5'=>'05','6'=>'06','7'=>'07','8'=>'08','9'=>'09', - '10'=>'10','11'=>'11','12'=>'12', - '13'=>'13','14'=>'14','15'=>'15', - '16'=>'16','17'=>'17','18'=>'18', - '19'=>'19','20'=>'20','21'=>'21', - '22'=>'22','23'=>'23'); - } - else - { - $hours = array('1'=>'1','2'=>'2','3'=>'3','4'=>'4', - '5'=>'5','6'=>'6','7'=>'7','8'=>'8','9'=>'9', - '10'=>'10','11'=>'11','12'=>'12'); - } + /** + * Returns a SELECT element for hours. + * + * @param string $tagName Prefix name for the SELECT element + * @param string $value + * @param boolean $format24Hours True for 24 hours format + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @return string + */ + function hourOptionTag($tagName, $value=null, $format24Hours = false, $selected=null, $optionAttr=null ) + { + $value = isset($value)? $value : $this->tagValue($tagName."_hour"); + if ( $format24Hours ) + { + $hourValue = empty($selected) ? date('H') : $selected; + } + else + { + $hourValue = empty($selected) ? date('g') : $selected; + } + if ( $format24Hours ) + { $hours = array('00'=>'00','01'=>'01','02'=>'02','03'=>'03','04'=>'04', + '05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'09', + '10'=>'10','11'=>'11','12'=>'12', + '13'=>'13','14'=>'14','15'=>'15', + '16'=>'16','17'=>'17','18'=>'18', + '19'=>'19','20'=>'20','21'=>'21', + '22'=>'22','23'=>'23'); + } + else + { + $hours = array('01'=>'1','02'=>'2','03'=>'3','04'=>'4', + '05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9', + '10'=>'10','11'=>'11','12'=>'12'); + } - $option = $this->selectTag($tagName.'_hour', $hours, $hourValue, - $optionAttr); - return $option; - } + $option = $this->selectTag($tagName.'_hour', $hours, $hourValue, + $optionAttr); + return $option; + } - /** - * Returns a SELECT element for minutes. - * - * @param string $tagName Prefix name for the SELECT element - * @param string $value - * @param string $selected Option which is selected. - * @param array $optionAttr Attribute array for the option elements. - * @return string - */ - function minuteOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) - { - $value = isset($value)? $value : $this->tagValue($tagName."_min"); - $minValue = empty($value) ? date('i') : $value ; - for( $minCount=0; $minCount<61; $minCount++) - { - $mins[$minCount] = sprintf('%02d', $minCount); - } + /** + * Returns a SELECT element for minutes. + * + * @param string $tagName Prefix name for the SELECT element + * @param string $value + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @return string + */ + function minuteOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) + { + $value = isset($value)? $value : $this->tagValue($tagName."_min"); + $minValue = empty($selected) ? date('i') : $selected ; + for( $minCount=0; $minCount<61; $minCount++) + { + $mins[$minCount] = sprintf('%02d', $minCount); + } - $option = $this->selectTag($tagName.'_min', $mins, $minValue, - $optionAttr); - return $option; - } + $option = $this->selectTag($tagName.'_min', $mins, $minValue, + $optionAttr); + return $option; + } - /** - * Returns a SELECT element for AM or PM. - * - * @param string $tagName Prefix name for the SELECT element - * @param string $value - * @param string $selected Option which is selected. - * @param array $optionAttr Attribute array for the option elements. - * @return string - */ - function meridianOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) - { - $value = isset($value)? $value : $this->tagValue($tagName."_meridian"); - $merValue = empty($value) ? date('a') : $value ; - $meridians = array('am'=>'am','pm'=>'pm'); + /** + * Returns a SELECT element for AM or PM. + * + * @param string $tagName Prefix name for the SELECT element + * @param string $value + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @return string + */ + function meridianOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) + { + $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, - $optionAttr); - return $option; - } + $option = $this->selectTag($tagName.'_meridian', $meridians, $merValue, + $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 - * @param string $dateFormat DMY, MDY, YMD or NONE. - * @param string $timeFormat 12, 24, NONE - * @param string $selected Option which is selected. - * @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, $optionAttr=null) - { - switch ( $dateFormat ) - { - case 'DMY' : - $opt = $this->dayOptionTag( $tagName ) . '-' . $this->monthOptionTag( $tagName ) . '-' . $this->yearOptionTag( $tagName ); - break; - case 'MDY' : - $opt = $this->monthOptionTag( $tagName ) .'-'.$this->dayOptionTag( $tagName ) . '-' . $this->yearOptionTag($tagName); - break; - case 'YMD' : - $opt = $this->yearOptionTag($tagName) . '-' . $this->monthOptionTag( $tagName ) . '-' . $this->dayOptionTag( $tagName ); - break; - case 'NONE': - $opt =''; - break; - default: - $opt = ''; - break; - } - switch ($timeFormat) - { - case '24': - $opt .= $this->hourOptionTag( $tagName, null , true ) . ':' . $this->minuteOptionTag( $tagName ); - break; - case '12': - $opt .= $this->hourOptionTag( $tagName ) . ':' . $this->minuteOptionTag( $tagName ) . ' ' . $this->meridianOptionTag($tagName); - break; - case 'NONE': - $opt .=''; - break; - default : + /** + * 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 + * @param string $dateFormat DMY, MDY, YMD or NONE. + * @param string $timeFormat 12, 24, NONE + * @param string $selected Option which is selected. + * @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, $optionAttr=null) + { + $day = null; + $month = null; + $year = null; + $hour = null; + $min = null; + $meridian = null; - break; - } - return $opt; - } + if(!empty($selected)) + { + if(is_int($selected)) + { + $selected = strftime('%G-%m-%d %T',$selected); + } + $meridian = 'am'; + $date = explode('-',$selected); + $day = explode(' ',$date[2]); + $time = explode(':',$day[1]); + + if(($time[0] > 12) && $timeFormat == '12') + { + $time[0] = $time[0] - 12; + $meridian = 'pm'; + } + elseif($time[0] > 12) + { + $meridian = 'pm'; + } + + $day = $day[0]; + $month = $date[1]; + $year = $date[0]; + $hour = $time[0]; + $min = $time[1]; + } + + switch ( $dateFormat ) + { + case 'DMY' : + $opt = $this->dayOptionTag( $tagName ,null ,$day) . '-' . $this->monthOptionTag( $tagName, null, $month ) . '-' . $this->yearOptionTag( $tagName, null, null, null, $year ); + break; + case 'MDY' : + $opt = $this->monthOptionTag($tagName, null, $month) .'-'.$this->dayOptionTag( $tagName, null, $day ) . '-' . $this->yearOptionTag($tagName, null, null, null, $year); + break; + case 'YMD' : + $opt = $this->yearOptionTag($tagName, null, null, null, $year) . '-' . $this->monthOptionTag( $tagName, null, $month ) . '-' . $this->dayOptionTag( $tagName, null, $day ); + break; + case 'NONE': + $opt =''; + break; + default: + $opt = ''; + break; + } + switch ($timeFormat) + { + case '24': + $opt .= $this->hourOptionTag( $tagName, null , true, $hour) . ':' . $this->minuteOptionTag( $tagName, null, $min ); + break; + case '12': + $opt .= $this->hourOptionTag( $tagName, null, false, $hour) . ':' . $this->minuteOptionTag( $tagName, null, $min) . ' ' . $this->meridianOptionTag($tagName, null, $meridian); + break; + case 'NONE': + $opt .=''; + break; + default : + + break; + } + return $opt; + } } ?> \ No newline at end of file diff --git a/cake/libs/view/helpers/javascript.php b/cake/libs/view/helpers/javascript.php index 6943ebd03..12ce81c47 100644 --- a/cake/libs/view/helpers/javascript.php +++ b/cake/libs/view/helpers/javascript.php @@ -43,35 +43,35 @@ 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. - * @return string The full SCRIPT element, with the JavaScript inside it. - */ + /** + * Returns a JavaScript script tag. + * + * @param string $script The JavaScript to be wrapped in SCRIPT tags. + * @return string The full SCRIPT element, with the JavaScript inside it. + */ function codeBlock($script) { return sprintf($this->tags['javascriptblock'], $script); } - /** - * Returns a JavaScript include tag (SCRIPT element) - * - * @param string $url URL to JavaScript file. - * @return string - */ + /** + * Returns a JavaScript include tag (SCRIPT element) + * + * @param string $url URL to JavaScript file. + * @return string + */ function link($url) { if(strpos($url, ".") === false) $url .= ".js"; return sprintf($this->tags['javascriptlink'], $this->webroot . JS_URL . $url); } - /** - * Returns a JavaScript include tag for an externally-hosted script - * - * @param string $url URL to JavaScript file. - * @return string - */ + /** + * Returns a JavaScript include tag for an externally-hosted script + * + * @param string $url URL to JavaScript file. + * @return string + */ function linkOut($url) { if(strpos($url, ".") === false) $url .= ".js"; @@ -84,12 +84,12 @@ class JavascriptHelper extends Helper * @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); - $script = str_replace(array('"', "'"), array('\"', "\\'"), $script); - return $script; - } + function escapeScript ($script) + { + $script = str_replace(array("\r\n","\n","\r"),'\n', $script); + $script = str_replace(array('"', "'"), array('\"', "\\'"), $script); + return $script; + } /** * Attach an event to an element. Used with the Prototype library. @@ -155,26 +155,26 @@ class JavascriptHelper extends Helper * create remote script links. * @return string script with all javascript in /javascripts folder */ - function includeScript ($script = "") - { - if($script == "") - { - $files = scandir(JS); - $javascript = ''; - foreach($files as $file) - { - if (substr($file, -3) == '.js') - { - $javascript .= file_get_contents(JS."{$file}") . "\n\n"; - } - } - } - else - { - $javascript = file_get_contents(JS."$script.js") . "\n\n"; - } - return $this->codeBlock("\n\n" . $javascript); - } + function includeScript ($script = "") + { + if($script == "") + { + $files = scandir(JS); + $javascript = ''; + foreach($files as $file) + { + if (substr($file, -3) == '.js') + { + $javascript .= file_get_contents(JS."{$file}") . "\n\n"; + } + } + } + else + { + $javascript = file_get_contents(JS."$script.js") . "\n\n"; + } + return $this->codeBlock("\n\n" . $javascript); + } } diff --git a/cake/libs/view/helpers/number.php b/cake/libs/view/helpers/number.php index c7dc1f964..d20333fe1 100644 --- a/cake/libs/view/helpers/number.php +++ b/cake/libs/view/helpers/number.php @@ -41,26 +41,26 @@ */ class NumberHelper extends Helper { - /** - * Formats a number with a level of precision. - * - * @param float $number A floating point number. - * @param integer $precision The precision of the returned number. - * @return float Enter description here... - * @static - */ + /** + * Formats a number with a level of precision. + * + * @param float $number A floating point number. + * @param integer $precision The precision of the returned number. + * @return float Enter description here... + * @static + */ function precision($number, $precision = 3) { return sprintf("%01.{$precision}f", $number); } - /** - * Returns a formatted-for-humans file size. - * - * @param integer $length Size in bytes - * @return string Human readable size - * @static - */ + /** + * Returns a formatted-for-humans file size. + * + * @param integer $length Size in bytes + * @return string Human readable size + * @static + */ function toReadableSize($size) { switch ($size) @@ -74,14 +74,14 @@ class NumberHelper extends Helper } } - /** - * Formats a number into a percentage string. - * - * @param float $number A floating point number - * @param integer $precision The precision of the returned number - * @return string Percentage string - * @static - */ + /** + * Formats a number into a percentage string. + * + * @param float $number A floating point number + * @param integer $precision The precision of the returned number + * @return string Percentage string + * @static + */ function toPercentage($number, $precision = 2) { return NumberHelper::precision($number, $precision) . '%'; diff --git a/cake/libs/view/helpers/text.php b/cake/libs/view/helpers/text.php index 617d45439..808a850eb 100644 --- a/cake/libs/view/helpers/text.php +++ b/cake/libs/view/helpers/text.php @@ -30,8 +30,13 @@ /** * Included libraries. + * */ -uses('flay', DS.'view'.DS.'helpers'.DS.'html'); +if(!class_exists('Flay') || !class_exists('Html')) +{ + uses('flay', DS.'view'.DS.'helpers'.DS.'html'); +} + /** * Text helper library. @@ -45,14 +50,14 @@ uses('flay', DS.'view'.DS.'helpers'.DS.'html'); */ class TextHelper extends Helper { - /** - * Highlights a given phrase in a text. - * - * @param string $text Text to search the phrase in - * @param string $phrase The phrase that will be searched - * @param string $highlighter The piece of html with that the phrase will be highlighted - * @return string The highlighted text - */ + /** + * Highlights a given phrase in a text. + * + * @param string $text Text to search the phrase in + * @param string $phrase The phrase that will be searched + * @param string $highlighter The piece of html with that the phrase will be highlighted + * @return string The highlighted text + */ function highlight($text, $phrase, $highlighter = '\1') { if (empty($phrase)) return $text; @@ -78,25 +83,25 @@ class TextHelper extends Helper } } - /** - * Strips given text of all links ((.*)<\/a>|im', '\1', $text); } - /** - * Adds links (autoLinkEmails($this->autoLinkUrls($text, $htmlOptions), $htmlOptions); } - /** - * Truncates text. - * - * Cuts a string to the length of $length and replaces the last characters - * with the ending if the text is longer than length. - * - * @param string $text String to truncate. - * @param integer $length Length of returned string, including ellipsis. - * @param string $ending Ending to be appended to the trimmed string. - * @return string Trimmed string. - */ + /** + * Truncates text. + * + * Cuts a string to the length of $length and replaces the last characters + * with the ending if the text is longer than length. + * + * @param string $text String to truncate. + * @param integer $length Length of returned string, including ellipsis. + * @param string $ending Ending to be appended to the trimmed string. + * @return string Trimmed string. + */ function truncate($text, $length, $ending='...') { if (strlen($text) <= $length) @@ -182,26 +187,26 @@ class TextHelper extends Helper } - /** - * Alias for truncate(). - * - * @see TextHelper::truncate() - */ + /** + * Alias for truncate(). + * + * @see TextHelper::truncate() + */ function trim() { $args = func_get_args(); return call_user_func_array(array(&$this, "truncate"), $args); } - /** - * Extracts an excerpt from the text surrounding the phrase with a number of characters on each side determined by radius. - * - * @param string $text String to search the phrase in - * @param string $phrase Phrase that will be searched for - * @param integer $radius The amount of characters that will be returned on each side of the founded phrase - * @param string $ending Ending that will be appended - * @return string Enter description here... - */ + /** + * Extracts an excerpt from the text surrounding the phrase with a number of characters on each side determined by radius. + * + * @param string $text String to search the phrase in + * @param string $phrase Phrase that will be searched for + * @param integer $radius The amount of characters that will be returned on each side of the founded phrase + * @param string $ending Ending that will be appended + * @return string Enter description here... + */ function excerpt($text, $phrase, $radius = 100, $ending = "...") { if (empty($text) or empty($phrase)) return $this->truncate($text, $radius * 2, $ending); @@ -219,14 +224,14 @@ class TextHelper extends Helper return $excerpt; } - /** - * Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax. - * - * @param string $text String to "flay" - * @param boolean $allowHtml Set to true if if html is allowed - * @return string "Flayed" text - * @todo Change this. We need a real Textile parser. - */ + /** + * Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax. + * + * @param string $text String to "flay" + * @param boolean $allowHtml Set to true if if html is allowed + * @return string "Flayed" text + * @todo Change this. We need a real Textile parser. + */ function flay($text, $allowHtml=false) { return Flay::toHtml($text, false, $allowHtml); diff --git a/cake/libs/view/helpers/time.php b/cake/libs/view/helpers/time.php index 781720fc8..ac6e14a0e 100644 --- a/cake/libs/view/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -1,461 +1,484 @@ - - * Copyright (c) 2005, 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 - * @copyright Copyright (c) 2005, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project - * @package cake - * @subpackage cake.cake.libs.view.helpers - * @since CakePHP v 0.10.0.1076 - * @version $Revision: 578 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2005-08-11 22:09:07 -0600 (Thu, 11 Aug 2005) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ - -/** - * Time Helper class for easy use of time data. - * - * Manipulation of time data. - * - * @package cake - * @subpackage cake.cake.libs.view.helpers - * @since CakePHP v 0.10.0.1076 - */ -class TimeHelper extends Helper -{ - /** - * Returns given string trimmed to given length, adding an ending (default: "..") if necessary. - * - * @param string $string String to trim - * @param integer $length Length of returned string, excluding ellipsis - * @param string $ending Ending to be appended after trimmed string - * @return string Trimmed string - */ - function trim($string, $length, $ending='..') - { - return substr($string, 0, $length).(strlen($string)>$length? $ending: null); - } - - - /** - * Returns a UNIX timestamp, given either a UNIX timestamp or a valid strtotime() date string. - * - * @param string $date_string Datetime string - * @return string Formatted date string - */ - function fromString ($date_string) - { - return is_integer($date_string) - ? $date_string - : strtotime($date_string); - } - - - /** - * Returns a nicely formatted date string for given Datetime string. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Formatted date string - */ - function nice ($date_string=null, $return = false) - { - $date = $date_string? strtotime($date_string): time(); - $date = $date_string? $this->fromString($date_string): time(); - $ret = date("D, M jS Y, H:i", $date); - - return $this->output($ret, $return); - } - - - /** - * Returns a formatted descriptive date string for given datetime string. - * - * If the given date is today, the returned string could be "Today, 16:54". - * If the given date was yesterday, the returned string could be "Yesterday, 16:54". - * If $date_string's year is the current year, the returned string does not - * include mention of the year. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Described, relative date string - */ - function niceShort ($date_string=null,$return = false) - { - $date = $date_string? $this->fromString($date_string): time(); - - $y = $this->isThisYear($date)? '': ' Y'; - - if ($this->isToday($date)) - { - $ret = "Today, ".date("H:i", $date); - } - elseif ($this->wasYesterday($date)) - { - $ret = "Yesterday, ".date("H:i", $date); - } - else - { - $ret = date("M jS{$y}, H:i", $date); - } - - return $this->output($ret, $return); - } - - - /** - * Returns true if given datetime string is today. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return boolean True if datetime string is today - */ - function isToday ($date_string) - { - $date = $this->fromString($date_string, $return = false); - $ret = date('Y-m-d', $date) == date('Y-m-d', time()); - - return $this->output($ret, $return); - } - - - /** - * Returns a partial SQL string to search for all records between two dates. - * - * @param string $date_string Datetime string or Unix timestamp - * @param string $end Datetime string or Unix timestamp - * @param string $field_name Name of database field to compare with - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Partial SQL string. - */ - function daysAsSql ($begin, $end, $field_name, $return = false) - { - $begin = $this->fromString($begin); - $end = $this->fromString($end); - $begin = date('Y-m-d', $begin).' 00:00:00'; - $end = date('Y-m-d', $end). ' 23:59:59'; - - $ret = "($field_name >= '$begin') AND ($field_name <= '$end')"; - - return $this->output($ret, $return); - } - - - /** - * Returns a partial SQL string to search for all records between two times - * occurring on the same day. - * - * @param string $date_string Datetime string or Unix timestamp - * @param string $field_name Name of database field to compare with - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Partial SQL string. - */ - function dayAsSql ($date_string, $field_name, $return = false) - { - $date = $this->fromString($date_string); - $ret = $this->daysAsSql($date_string, $date_string, $field_name); - - return $this->output($ret, $return); - } - - - /** - * Returns true if given datetime string is within current year. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return boolean True if datetime string is within current year - */ - function isThisYear ($date_string, $return = false) { - $date = $this->fromString($date_string); - $ret = date('Y', $date) == date('Y', time()); - - return $this->output($ret, $return); - } - - - /** - * Returns true if given datetime string was yesterday. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return boolean True if datetime string was yesterday - */ - function wasYesterday ($date_string, $return = false) { - $date = $this->fromString($date_string); - $ret = date('Y-m-d', $date) == date('Y-m-d', strtotime('yesterday')); - - return $this->output($ret, $return); - } - - - /** - * Returns true if given datetime string is tomorrow. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return boolean True if datetime string was yesterday - */ - function isTomorrow ($date_string, $return = false) { - $date = $this->fromString($date_string); - $ret = date('Y-m-d', $date) == date('Y-m-d', strtotime('tomorrow')); - - return $this->output($ret, $return); - } - - - /** - * Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime(). - * - * @param string $date_string Datetime string to be represented as a Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return int Unix timestamp - */ - function toUnix ($date_string, $return = false) { - $ret = strtotime($date_string); - - return $this->output($ret, $return); - } - - /** - * Returns a date formatted for Atom RSS feeds. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Formatted date string - */ - function toAtom ($date_string, $return = false) { - $date = $this->fromString($date_string); - $ret = date('Y-m-d\TH:i:s\Z', $date); - - return $this->output($ret, $return); - } - - /** - * Formats date for RSS feeds - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Formatted date string - */ - function toRSS ($date_string, $return = false) { - $date = TimeHelper::fromString($date_string); - $ret = date("r", $date); - - return $this->output($ret, $return); - } - - - /** - * Returns either a relative date or a formatted date depending - * on the difference between the current time and given datetime. - * $datetime should be in a strtotime-parsable format like MySQL datetime. - * - * Relative dates look something like this: - * 3 weeks, 4 days ago - * 15 seconds ago - * Formatted dates look like this: - * on 02/18/2004 - * - * The returned string includes 'ago' or 'on' and assumes you'll properly add a word - * like 'Posted ' before the function output. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Relative time string. - */ - function timeAgoInWords ($datetime_string, $return = false) - { - $datetime = $this->fromString($datetime_string); - - $in_seconds = $datetime; - $diff = time()-$in_seconds; - $months = floor($diff/2419200); - $diff -= $months*2419200; - $weeks = floor($diff/604800); - $diff -= $weeks*604800; - $days = floor($diff/86400); - $diff -= $days*86400; - $hours = floor($diff/3600); - $diff -= $hours*3600; - $minutes = floor($diff/60); - $diff -= $minutes*60; - $seconds = $diff; - - if ($months>0) - { - // over a month old, just show date (mm/dd/yyyy format) - $ret = 'on '.date("j/n/Y", $in_seconds); - } - else - { - $relative_date=''; - if ($weeks>0) - { - // weeks and days - $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':''); - $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):''; - } - elseif ($days>0) - { - // days and hours - $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':''); - $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):''; - } - elseif ($hours>0) - { - // hours and minutes - $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''); - $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):''; - } - elseif ($minutes>0) - { - // minutes only - $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''); - } - else - { - // seconds only - $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':''); - } - } - // show relative date and add proper verbiage - $ret = $relative_date.' ago'; - - return $this->output($ret, $return); - } - - - /** - * Alias for timeAgoInWords - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Relative time string. - */ - function relativeTime ($datetime_string, $return = false) - { - $ret = $this->timeAgoInWords ($datetime_string); - - return $this->output($ret, $return); - } - - /** - * Returns true if specified datetime was within the interval specified, else false. - * - * @param mixed $timeInterval the numeric value with space then time - * type. Example of valid types: 6 hours, 2 days, 1 minute. - * @param mixed $date the datestring or unix timestamp to compare - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return boolean - */ - function wasWithinLast($timeInterval, $date_string, $return = false) - { - $date = $this->fromString($date_string); - - $result = preg_split('/\\s/', $timeInterval); - - $numInterval = $result[0]; - $textInterval = $result[1]; - $currentTime = floor(time()); - $seconds = ($currentTime - floor($date)); - - switch($textInterval) - { - - case "seconds": - case "second": - $timePeriod = $seconds; - $ret = $return; - break; - - case "minutes": - case "minute": - $minutes = floor($seconds / 60); - $timePeriod = $minutes; - break; - - - case "hours": - case "hour": - $hours = floor($seconds / 3600); - $timePeriod = $hours; - break; - - case "days": - case "day": - $days = floor($seconds / 86400); - $timePeriod = $days; - break; - - case "weeks": - case "week": - $weeks = floor($seconds / 604800); - $timePeriod = $weeks; - break; - - - case "months": - case "month": - $months = floor($seconds / 2629743.83); - $timePeriod = $months; - break; - - - case "years": - case "year": - $years = floor($seconds / 31556926); - $timePeriod = $years; - break; - - - default: - $days = floor($seconds / 86400); - $timePeriod = $days; - break; - } - - if ($timePeriod <= $numInterval) - { - $ret = true; - } - else - { - $ret = false; - } - - return $this->output($ret, $return); - - } - - -} - + + * Copyright (c) 2005, 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 + * @copyright Copyright (c) 2005, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP v 0.10.0.1076 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ + +/** + * Time Helper class for easy use of time data. + * + * Manipulation of time data. + * + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP v 0.10.0.1076 + */ +class TimeHelper extends Helper +{ +/** + * Returns given string trimmed to given length, adding an ending (default: "..") if necessary. + * + * @param string $string String to trim + * @param integer $length Length of returned string, excluding ellipsis + * @param string $ending Ending to be appended after trimmed string + * @return string Trimmed string + */ + function trim($string, $length, $ending='..') + { + return substr($string, 0, $length).(strlen($string)>$length? $ending: null); + } + +/** + * Returns a UNIX timestamp, given either a UNIX timestamp or a valid strtotime() date string. + * + * @param string $date_string Datetime string + * @return string Formatted date string + */ + function fromString ($date_string) + { + if (is_integer($date_string)) + { + return $date_string; + } + else + { + return strtotime($date_string); + } + } + +/** + * Returns a nicely formatted date string for given Datetime string. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Formatted date string + */ + function nice ($date_string=null, $return = false) + { + if($date_string != null) + { + $date = $this->fromString($date_string); + } + else + { + $date = time(); + } + $ret = date("D, M jS Y, H:i", $date); + return $this->output($ret, $return); + } + +/** + * Returns a formatted descriptive date string for given datetime string. + * + * If the given date is today, the returned string could be "Today, 16:54". + * If the given date was yesterday, the returned string could be "Yesterday, 16:54". + * If $date_string's year is the current year, the returned string does not + * include mention of the year. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Described, relative date string + */ + function niceShort ($date_string=null,$return = false) + { + $date = $date_string? $this->fromString($date_string): time(); + + $y = $this->isThisYear($date)? '': ' Y'; + + if ($this->isToday($date)) + { + $ret = "Today, ".date("H:i", $date); + } + elseif ($this->wasYesterday($date)) + { + $ret = "Yesterday, ".date("H:i", $date); + } + else + { + $ret = date("M jS{$y}, H:i", $date); + } + + return $this->output($ret, $return); + } + +/** + * Returns true if given datetime string is today. + * + * @param string $date_string Datetime string or Unix timestamp + + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return boolean True if datetime string is today + */ + function isToday ($date_string) + { + $date = $this->fromString($date_string, $return = false); + $ret = date('Y-m-d', $date) == date('Y-m-d', time()); + + return $this->output($ret, $return); + } + +/** + * Returns a partial SQL string to search for all records between two dates. + * + * @param string $date_string Datetime string or Unix timestamp + * @param string $end Datetime string or Unix timestamp + * @param string $field_name Name of database field to compare with + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Partial SQL string. + */ + function daysAsSql ($begin, $end, $field_name, $return = false) + { + $begin = $this->fromString($begin); + $end = $this->fromString($end); + $begin = date('Y-m-d', $begin).' 00:00:00'; + $end = date('Y-m-d', $end). ' 23:59:59'; + + $ret = "($field_name >= '$begin') AND ($field_name <= '$end')"; + + return $this->output($ret, $return); + } + +/** + * Returns a partial SQL string to search for all records between two times + * occurring on the same day. + * + * @param string $date_string Datetime string or Unix timestamp + * @param string $field_name Name of database field to compare with + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Partial SQL string. + */ + function dayAsSql ($date_string, $field_name, $return = false) + { + $date = $this->fromString($date_string); + $ret = $this->daysAsSql($date_string, $date_string, $field_name); + + return $this->output($ret, $return); + } + +/** + * Returns true if given datetime string is within current year. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return boolean True if datetime string is within current year + */ + function isThisYear ($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y', $date) == date('Y', time()); + + return $this->output($ret, $return); + } + +/** + * Returns true if given datetime string was yesterday. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return boolean True if datetime string was yesterday + */ + function wasYesterday ($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y-m-d', $date) == date('Y-m-d', strtotime('yesterday')); + + return $this->output($ret, $return); + } + +/** + * Returns true if given datetime string is tomorrow. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return boolean True if datetime string was yesterday + */ + function isTomorrow ($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y-m-d', $date) == date('Y-m-d', strtotime('tomorrow')); + + return $this->output($ret, $return); + } + +/** + * Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime(). + * + * @param string $date_string Datetime string to be represented as a Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return int Unix timestamp + */ + function toUnix ($date_string, $return = false) { + $ret = strtotime($date_string); + + return $this->output($ret, $return); + } + +/** + * Returns a date formatted for Atom RSS feeds. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Formatted date string + */ + function toAtom ($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y-m-d\TH:i:s\Z', $date); + + return $this->output($ret, $return); + } + +/** + * Formats date for RSS feeds + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Formatted date string + */ + function toRSS ($date_string, $return = false) + { + $date = TimeHelper::fromString($date_string); + $ret = date("r", $date); + + return $this->output($ret, $return); + } + +/** + * Returns either a relative date or a formatted date depending + * on the difference between the current time and given datetime. + * $datetime should be in a strtotime-parsable format like MySQL datetime. + * + * Relative dates look something like this: + * 3 weeks, 4 days ago + * 15 seconds ago + * Formatted dates look like this: + * on 02/18/2004 + * + * The returned string includes 'ago' or 'on' and assumes you'll properly add a word + * like 'Posted ' before the function output. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Relative time string. + */ + function timeAgoInWords ($datetime_string, $return = false, $backwards = false) + { + $datetime = $this->fromString($datetime_string); + + $in_seconds = $datetime; + if($backwards) + { + $diff = $in_seconds-time(); + } + else + { + $diff = time()-$in_seconds; + } + $months = floor($diff/2419200); + $diff -= $months*2419200; + $weeks = floor($diff/604800); + $diff -= $weeks*604800; + $days = floor($diff/86400); + $diff -= $days*86400; + $hours = floor($diff/3600); + $diff -= $hours*3600; + $minutes = floor($diff/60); + $diff -= $minutes*60; + $seconds = $diff; + + if ($months>0) + { + // over a month old, just show date (mm/dd/yyyy format) + $relative_date = 'on '.date("j/n/Y", $in_seconds); + $old = true; + } + else + { + $relative_date=''; + $old = false; + if ($weeks>0) + { + // weeks and days + $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':''); + $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):''; + } + elseif ($days>0) + { + // days and hours + $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':''); + $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):''; + } + elseif ($hours>0) + { + // hours and minutes + $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''); + $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):''; + } + elseif ($minutes>0) + { + // minutes only + $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''); + } + else + { + // seconds only + $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':''); + } + } + + $ret = $relative_date; + // show relative date and add proper verbiage + if(!$backwards && !$old) + { + $ret .= ' ago'; + } + + return $this->output($ret, $return); + } + +/** + * Alias for timeAgoInWords + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Relative time string. + */ + function relativeTime ($datetime_string, $return = false) + { + $date = strtotime($datetime_string); + + if(strtotime("now") > $date) + { + $ret = $this->timeAgoInWords($datetime_string); + } + else + { + $ret = $this->timeAgoInWords($datetime_string, $return, true); + } + + return $this->output($ret, $return); + } + +/** + * Returns true if specified datetime was within the interval specified, else false. + * + * @param mixed $timeInterval the numeric value with space then time + * type. Example of valid types: 6 hours, 2 days, 1 minute. + * @param mixed $date the datestring or unix timestamp to compare + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return boolean + */ + function wasWithinLast($timeInterval, $date_string, $return = false) + { + $date = $this->fromString($date_string); + + $result = preg_split('/\\s/', $timeInterval); + + $numInterval = $result[0]; + $textInterval = $result[1]; + $currentTime = floor(time()); + $seconds = ($currentTime - floor($date)); + + switch($textInterval) + { + + case "seconds": + case "second": + $timePeriod = $seconds; + $ret = $return; + break; + + case "minutes": + case "minute": + $minutes = floor($seconds / 60); + $timePeriod = $minutes; + break; + + + case "hours": + case "hour": + $hours = floor($seconds / 3600); + $timePeriod = $hours; + break; + + case "days": + case "day": + $days = floor($seconds / 86400); + $timePeriod = $days; + break; + + case "weeks": + case "week": + $weeks = floor($seconds / 604800); + $timePeriod = $weeks; + break; + + + case "months": + case "month": + $months = floor($seconds / 2629743.83); + $timePeriod = $months; + break; + + + case "years": + case "year": + $years = floor($seconds / 31556926); + $timePeriod = $years; + break; + + + default: + $days = floor($seconds / 86400); + $timePeriod = $days; + break; + } + + if ($timePeriod <= $numInterval) + { + $ret = true; + } + else + { + $ret = false; + } + + return $this->output($ret, $return); + + } + + +} + ?> \ No newline at end of file diff --git a/cake/libs/view/templates/errors/missing_action.thtml b/cake/libs/view/templates/errors/missing_action.thtml index 213dfec80..1644c82cd 100644 --- a/cake/libs/view/templates/errors/missing_action.thtml +++ b/cake/libs/view/templates/errors/missing_action.thtml @@ -3,20 +3,20 @@ /** * - * + * * * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -32,9 +32,9 @@

    Missing Method in

    -

    You are seeing this error because the action controller->missingAction;?> +

    You are seeing this error because the action controller->missingAction;?> is not defined in controller -

    +

    @@ -43,7 +43,7 @@ view file, a user-customizable error page for handling invalid action dispatches

    -Fatal: Create Method: +Fatal: Create Method:

    <?php\n\nclass " . $controller ." extends AppController {\n @@ -62,9 +62,9 @@ in file : 1):?>

    Controller dump:

    -db);
    -print_r($this); 
    +print_r($this);
     ?>
     
    - \ No newline at end of file + \ No newline at end of file diff --git a/cake/libs/view/templates/errors/missing_controller.thtml b/cake/libs/view/templates/errors/missing_controller.thtml index 89189b9bd..86b7332d2 100644 --- a/cake/libs/view/templates/errors/missing_controller.thtml +++ b/cake/libs/view/templates/errors/missing_controller.thtml @@ -3,20 +3,20 @@ /** * - * + * * * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -32,7 +32,7 @@ controller->missingController; ?>

    You are seeing this error because controller could not be found. -

    +

    Notice: this error is being rendered by the app/views/errors/missing_controller.thtml @@ -43,7 +43,7 @@ view file, a user-customizable error page for handling invalid controller dispat Fatal: Unable to load controller

    -Fatal: Create Class: +Fatal: Create Class:

    <?php\n\nclass " . $missing ." extends AppController {\n}\n\n?>

    "; ?> @@ -52,9 +52,9 @@ in file : 1):?>

    Controller dump:

    -db);
    -print_r($this); 
    +print_r($this);
     ?>
     
    - \ No newline at end of file + \ No newline at end of file diff --git a/cake/libs/view/templates/errors/missing_database.thtml b/cake/libs/view/templates/errors/missing_database.thtml index 0842be914..a51133364 100644 --- a/cake/libs/view/templates/errors/missing_database.thtml +++ b/cake/libs/view/templates/errors/missing_database.thtml @@ -38,12 +38,10 @@ view file, a user-customizable error page for handling errors within CakePHP.

    -1):?> + 1) { ?>

    Controller dump:

    -
    -db);
    -print_r($this); 
    +db);
    +    pr($this); 
     ?>
    -
    - \ No newline at end of file + \ No newline at end of file diff --git a/cake/libs/view/templates/errors/missing_helper_class.thtml b/cake/libs/view/templates/errors/missing_helper_class.thtml index c59895bfd..fa6af4dd2 100644 --- a/cake/libs/view/templates/errors/missing_helper_class.thtml +++ b/cake/libs/view/templates/errors/missing_helper_class.thtml @@ -1,75 +1,75 @@ - - * Copyright (c) 2005, 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 - * @copyright Copyright (c) 2005, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors - * @since CakePHP v 0.10.0.1076 - * @version $Revision:$ - * @modifiedby $LastChangedBy:$ - * @lastmodified $Date:$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -?> -controller->missingHelperClass; - $missingFile = $this->controller->missingHelperFile; - -?> -

    Missing Helper Class

    - -

    You are seeing this error because the view helper class - can't be found or doesn't exist in -

    - - -

    -Notice: this error is being rendered by the app/views/errors/missing_helper_class.thtml -view file, a user-customizable error page for handling non-existent view helper classes. -

    - -

    -Fatal: Create the Class: -

    -

    -<?php\n\nclass " . $missingClass ." extends Helper {\n - // Your helper functions here - function myHelperFunction () - { - } -}\n?>

    "; ?> -in file : -

    - -

    -Error: Unable to load helper class in -View::_loadHelpers -

    - -1):?> -

    Controller dump:

    -
    -db);
    -print_r($this);
    -?>
    -
    - \ No newline at end of file + + * Copyright (c) 2005, 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 + * @copyright Copyright (c) 2005, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP v 0.10.0.1076 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +controller->missingHelperClass; + $missingFile = $this->controller->missingHelperFile; + +?> +

    Missing Helper Class

    + +

    You are seeing this error because the view helper class + can't be found or doesn't exist in +

    + + +

    +Notice: this error is being rendered by the app/views/errors/missing_helper_class.thtml +view file, a user-customizable error page for handling non-existent view helper classes. +

    + +

    +Fatal: Create the Class: +

    +

    +<?php\n\nclass " . $missingClass ." extends Helper {\n + // Your helper functions here + function myHelperFunction () + { + } +}\n?>"; ?> +in file : +

    + +

    +Error: Unable to load helper class in +View::_loadHelpers +

    + +1):?> +

    Controller dump:

    +
    +db);
    +print_r($this);
    +?>
    +
    + diff --git a/cake/libs/view/templates/errors/missing_helper_file.thtml b/cake/libs/view/templates/errors/missing_helper_file.thtml index 8a41bebd5..9b12b7aa3 100644 --- a/cake/libs/view/templates/errors/missing_helper_file.thtml +++ b/cake/libs/view/templates/errors/missing_helper_file.thtml @@ -1,75 +1,75 @@ - - * Copyright (c) 2005, 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 - * @copyright Copyright (c) 2005, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors - * @since CakePHP v 0.10.0.1076 - * @version $Revision:$ - * @modifiedby $LastChangedBy:$ - * @lastmodified $Date:$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -?> -controller->missingHelperClass; - $missingFile = $this->controller->missingHelperFile; - -?> -

    Missing Helper File

    - -

    You are seeing this error because the view helper file - can't be found or doesn't exist -

    - - -

    -Notice: this error is being rendered by the app/views/errors/missing_helper_file.thtml -view file, a user-customizable error page for handling non-existent view helper files. -

    - -

    -Fatal: Create the Class: -

    -

    -<?php\n\nclass " . $missingClass ." extends Helper {\n - // Your helper functions here - function myHelperFunction () - { - } -}\n?>"; ?> -in file : -

    - -

    -Error: Unable to load helper file in -View::_loadHelpers -

    - -1):?> -

    Controller dump:

    -
    -db);
    -print_r($this);
    -?>
    -
    - \ No newline at end of file + + * Copyright (c) 2005, 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 + * @copyright Copyright (c) 2005, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP v 0.10.0.1076 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +controller->missingHelperClass; + $missingFile = $this->controller->missingHelperFile; + +?> +

    Missing Helper File

    + +

    You are seeing this error because the view helper file + can't be found or doesn't exist +

    + + +

    +Notice: this error is being rendered by the app/views/errors/missing_helper_file.thtml +view file, a user-customizable error page for handling non-existent view helper files. +

    + +

    +Fatal: Create the Class: +

    +

    +<?php\n\nclass " . $missingClass ." extends Helper {\n + // Your helper functions here + function myHelperFunction () + { + } +}\n?>"; ?> +in file : +

    + +

    +Error: Unable to load helper file in +View::_loadHelpers +

    + +1):?> +

    Controller dump:

    +
    +db);
    +print_r($this);
    +?>
    +
    + diff --git a/cake/libs/view/templates/errors/missing_scaffolddb.thtml b/cake/libs/view/templates/errors/missing_scaffolddb.thtml index 18d4eb7d3..2ca8cbf40 100644 --- a/cake/libs/view/templates/errors/missing_scaffolddb.thtml +++ b/cake/libs/view/templates/errors/missing_scaffolddb.thtml @@ -3,20 +3,20 @@ /** * - * + * * * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -31,19 +31,19 @@

    Scaffold Requires a Database Connection

    Missing Database Connection: Scaffold Does not work without a database connection -

    +

    Notice: this error is being rendered by the app/views/errors/missing_database.thtml view file, a user-customizable error page for handling errors within CakePHP.

    -1):?> +1):?>

    Controller dump:

    -db);
    -print_r($this); 
    +print_r($this);
     ?>
     
    - \ No newline at end of file + \ No newline at end of file diff --git a/cake/libs/view/templates/errors/missing_table.thtml b/cake/libs/view/templates/errors/missing_table.thtml index 36d8fda2f..92d086db7 100644 --- a/cake/libs/view/templates/errors/missing_table.thtml +++ b/cake/libs/view/templates/errors/missing_table.thtml @@ -3,20 +3,20 @@ /** * - * + * * * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -30,8 +30,8 @@ ?> controller->missingTable;?>

    Missing Database Table

    -

    No Database table for model (expected "controller->missingTableName;?>"), create it first. -

    +

    No Database table for model (expected "controller->missingTableName;?>"), create it first. +

    Notice: this error is being rendered by the app/views/errors/missing_table.thtml view file, a user-customizable error page. diff --git a/cake/libs/view/templates/errors/missing_view.thtml b/cake/libs/view/templates/errors/missing_view.thtml index 993a2230e..39b5aee38 100644 --- a/cake/libs/view/templates/errors/missing_view.thtml +++ b/cake/libs/view/templates/errors/missing_view.thtml @@ -3,20 +3,20 @@ /** * - * + * * * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework - * Copyright (c) 2005, Cake Software Foundation, Inc. + * Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package cake @@ -30,10 +30,10 @@ ?>

    Missing view

    -

    You are seeing this error because the view missingView;?> - for action params['action'];?> +

    You are seeing this error because the view missingView;?> + for action params['action'];?> in controller name);?> could not be found. -

    +

    Notice: this error is being rendered by the app/views/errors/missing_view.thtml @@ -48,9 +48,9 @@ action missingView;?>::params['action']; 1):?>

    Controller dump:

    -db);
    -print_r($this); 
    +print_r($this);
     ?>
     
    - \ No newline at end of file + \ No newline at end of file diff --git a/cake/libs/view/templates/layouts/default.thtml b/cake/libs/view/templates/layouts/default.thtml index f5481679a..e79ef1fb5 100644 --- a/cake/libs/view/templates/layouts/default.thtml +++ b/cake/libs/view/templates/layouts/default.thtml @@ -42,15 +42,15 @@ image('cake.logo.png', array('alt'=>'CakePHP : Rapid Development Framework', 'border'=>"0"))?>
    - controller->Session)) $this->controller->Session->flash(); ?> - + controller->Session)) $this->controller->Session->flash(); ?> +