Revision: [1638]
removing php short tags

Revision: [1637]
Remove renderElememnts loading of helpers also, forgot it in the last commit

Revision: [1636]
Refactoring after profiling code.
Session was creating a new instance of Dispatcher removed the need for it.
Added a check to the Component class to pass the base to the SessionComponent class, will refactor that at a later time.

Changed View class so it would not load helpers when rending a layout, no need for that.
A great performance boost after the change.

Change the loadModels method call in app/webroot/index.php.
Will only attempt the loadModels call if the AppModel class is not in memory, and the Database class is in memory.
Removed all unnecessary calls to basics uses(). Again another big performance increase.
Added fix to the Html::guiListTree() after discussing the output that is expected.
A ticket was closed on this already.

Revision: [1635]
Removing calls to basic uses()

Revision: [1634]
Removing calls to basics uses() that are not needed.

Revision: [1633]
Removing calls to basics uses() that are not needed.
Moved Object class further up in the loading order

Revision: [1632]
adding fix for Ticket #132

Revision: [1631]
Added fix from Ticket #122

Revision: [1630]
Scaffold views can now be placed in a view directory.
These will override the core.
Example (Must have the scaffold dot name):
app/views/posts/scaffold.list.thtml
app/views/posts/scaffold.new.thtml
app/views/posts/scaffold.edit.thtml
app/views/posts/scaffold.show.thtml

Revision: [1629]
Think I fixed the issue with scaffold showing proper dates prior to January 1 1970 00:00:00.

Revision: [1628]
Added a few more change to allow saving dates prior to January 1 1970 00:00:00.
Still a few issues with this, but will get them figured out soon.
Changed scaffold to use only one form view.

Revision: [1627]
Added fix for Ticket #189

Revision: [1626]
Added fix for Ticket #120.

Revision: [1625]
left justified doc blocks

Revision: [1624]
remove files from uses() that are loaded by default in app/webroot/index.php no reason to attempt to load them again in the classes

Revision: [1623]
adding check to the loadModels and loadController that will only attempt to load files if the classes are not already in memory

Revision: [1622]
Adding fix to time helper that was lost in a previous merge
Removing all tabs from code

Revision: [1621]
Addtional model validation fixes

Revision: [1620]
fixed parse error

Revision: [1619]
Fixing ticket #102

Revision: [1618]
correcting mime types and keywords

Revision: [1617]
correcting mime types and keywords

Revision: [1616]
fixed link in footer

Revision: [1615]
Fixing ticket #207

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1639 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-12-27 03:33:44 +00:00
parent 134744b5d6
commit 9560f78884
54 changed files with 4331 additions and 4176 deletions

View file

@ -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`)
);

View file

@ -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;

View file

@ -275,5 +275,5 @@ select.autoWidth {
}
option {
padding-left:1em;
padding-left:1em;
}

View file

@ -9,7 +9,7 @@
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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')
{

View file

@ -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 <http://www.cakephp.org/>
* 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<pre>\n";
if ($show_html) $var = str_replace('<', '&lt;', str_replace('>', '&gt;', $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<count($args) ; $l++)
{
$a[$args[$l]] = $l+1<count($args) ? $args[$l+1] : null;
$l++;
}
return $a;
for($i=0 ; $i < $count ; $i++)
{
if($i+1 < $count)
{
$a[$args[$i]] = $args[$i+1];
}
else
{
$a[$args[$i]] = null;
}
}
return $a;
}
/**
* Convenience method for echo().
*
@ -357,24 +381,24 @@ function ha()
*/
function e($text)
{
echo $text;
echo $text;
}
/**
* Print_r convenience function, which prints out <PRE> tags around
* Print_r convenience function, which prints out <PRE> tags around
* the output of given array. Similar to debug().
*
*
* @see debug
* @param array $var
*/
function pr($var)
{
if(DEBUG > 0)
{
echo "<pre>";
print_r($var);
echo "</pre>";
}
if(DEBUG > 0)
{
echo "<pre>";
print_r($var);
echo "</pre>";
}
}
/**
@ -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;
}
?>

View file

@ -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)
{

View file

@ -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;
}
}

View file

@ -3,20 +3,20 @@
/**
* Caching for Cake.
*
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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}");
}
}
?>

View file

@ -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)
{

View file

@ -2,19 +2,19 @@
/* SVN FILE: $Id$ */
/**
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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))
{

View file

@ -44,7 +44,7 @@ require_once(CAKE . 'app_model.php');
*
*/
class AclNode extends AppModel
{
{
/**
* Enter description here...

View file

@ -39,7 +39,7 @@
*
*/
class Aco extends AclNode
{
{
var $name = 'Aco';
/**
* Enter description here...

View file

@ -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;
}
/**

View file

@ -3,20 +3,20 @@
/**
* Short description for file.
*
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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();
}

View file

@ -7,7 +7,7 @@
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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;
}
}
}
?>

View file

@ -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 <http://www.cakephp.org/>
* 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('/');

View file

@ -9,14 +9,14 @@
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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'] )

View file

@ -3,19 +3,19 @@
/**
* Convenience class for reading, writing and appending to files.
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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
}
}
?>
?>

View file

@ -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 <http://www.cakephp.org/>
* 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 <p> transforms and > to &gt;, no typography additions.
* @param string $text String to format
* @param boolean $bare Set this to only do <p> transforms and > to &gt;, 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('<', '&lt;', str_replace('>', '&gt;', 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, "<a href=\"mailto:{$email}\">{$email}</a>", $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, "<a href=\"{$url}\">{$url}</a>", $line);
}
}
if (preg_match_all("#(www\.[^\n\%\ ]+[^\n\%\,\.\ ])#", $line, $urls))
{
foreach ($urls[1] as $url)
foreach ($urls[1] as $url)
{
$line = str_replace($url, "<a href=\"http://{$url}\">{$url}</a>", $line);
}
}
// re-parse links
if (count($links))
{
for ($ii=0; $ii<count($links); $ii++)
if (count($links))
{
for ($ii=0; $ii<count($links); $ii++)
{
if (preg_match("#^(http|https|ftp|nntp)://#", $links[$ii]))
{
$prefix = null;
}
else
else
{
$prefix = 'http://';
}
if (preg_match('#^[^\ ]+\.(jpg|jpeg|gif|png)$#', $links[$ii]))
{
$with = "<img src=\"{$prefix}{$links[$ii]}\" alt=\"\" />";
@ -205,13 +208,13 @@ class Flay extends Object
{
$body = $regs[2];
}
}
else
else
{
$body = $links[$ii];
}
$with = "<a href=\"{$prefix}{$regs[1]}\" target=\"_blank\">{$body}</a>";
}
else
@ -223,13 +226,13 @@ class Flay extends Object
}
}
}
// re-parse newlines
$out .= str_replace('%LINEBREAK%', "<br />\n", "<p>{$line}</p>\n");
}
}
if (!$bare)
if (!$bare)
{
// re-parse multilines
$out = str_replace('<p>%BLOCKQUOTE%</p>', "<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(' <b>...</b> ', $snips);
$snips = $joined? "<b>...</b> {$joined} <b>...</b>": substr($string, 0, 80) . '<b>...</b>';
@ -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", '<em class="' . $colors[$nextColorIndex%count($colors)] . "\">\\1</em>", $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);
}

View file

@ -3,19 +3,19 @@
/**
* Convenience class for handling directories.
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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)
{

View file

@ -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 <http://www.cakephp.org/>
* 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
}
}
?>
?>

View file

@ -3,20 +3,20 @@
/**
* Logging.
*
*
* Log messages to text files.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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
*/

View file

@ -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

View file

@ -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;
}

View file

@ -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);

View file

@ -9,10 +9,10 @@
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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<sizeof($data); $ii++)
{
if ($data[$ii]['parent_id'] == $root)
{
$tmp = $data[$ii];
$tmp['children'] = isset($data[$ii]['id'])? $this->_doThread($data, $data[$ii]['id']): null;
$out[] = $tmp;
}
}
return $out;
}
function _doThread ($data, $root)
{
$out = array();
for ($ii=0; $ii<sizeof($data); $ii++)
{
if ($data[$ii][$this->name]['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);
}
}
}
?>

View file

@ -3,20 +3,20 @@
/**
* Library of array functions for Cake.
*
*
* Internal use only.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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; $ii<count($this->value); $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; $ii<sizeof($this->value); $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
?>
?>

View file

@ -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('ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','<27>?','Ń','Ó','Ś','Ź','Ż');
@ -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);

View file

@ -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';

View file

@ -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 <http://www.cakephp.org/>
* 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();

View file

@ -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 <br/>.
*
@ -85,13 +85,13 @@ class Sanitize
else
{
$patterns = array("/\&/", "/%/", "/</", "/>/", '/"/', "/'/", "/\(/", "/\)/", "/\+/", "/-/", "/\n/");
$replacements = array("&amp;", "&#37;", "&lt;", "&gt;", "&quot;", "&#39;", "&#40;", "&#41;", "&#43;", "&#45;", "<br/>");
$string = preg_replace($patterns, $replacements, $string);
$replacements = array("&amp;", "&#37;", "&lt;", "&gt;", "&quot;", "&#39;", "&#40;", "&#41;", "&#43;", "&#45;", "<br/>");
$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("/&amp;#([0-9]+);/s", "&#\\1;", $val );

View file

@ -3,20 +3,20 @@
/**
* Short description for file.
*
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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...

View file

@ -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;
}
/**#@-*/
/**#@-*/
}
?>

View file

@ -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 <i>options[url]</i>
* (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 <i>options[update]</i>.
* Usually, the result would be a partial prepared by the controller with
* either renderPartial or renderPartialCollection.
*
* Examples:
* <code>
* linkToRemote("Delete this post",
* array("update" => "posts", "url" => "delete/{$postid->id}"));
* linkToRemote(imageTag("refresh"),
* array("update" => "emails", "url" => "list_emails" ));
* </code>
*
* By default, these remote requests are processed asynchronous during
* which various callbacks can be triggered (for progress indicators and
* the likes).
*
* Example:
* <code>
* linkToRemote (word,
* array("url" => "undo", "n" => word_counter),
* array("complete" => "undoRequestCompleted(request)"));
* </code>
*
* The callbacks that may be specified are:
*
* - <i>loading</i>:: Called when the remote document is being
* loaded with data by the browser.
* - <i>loaded</i>:: Called when the browser has finished loading
* the remote document.
* - <i>interactive</i>:: Called when the user can interact with the
* remote document, even though it has not
* finished loading.
* - <i>complete</i>:: 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
* <i>options[type] = synchronous</i>.
*
* 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:
*
* - <i>confirm</i>:: Adds confirmation dialog.
* -<i>condition</i>:: Perform remote request conditionally
* by this expression. Use this to
* describe browser-side conditions when
* request should not be initiated.
* - <i>before</i>:: Called before request is initiated.
* - <i>after</i>:: Called immediately after request was
* initiated and before <i>loading</i>.
*
* @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 <i>options[url]</i>
* (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 <i>options[update]</i>.
* Usually, the result would be a partial prepared by the controller with
* either renderPartial or renderPartialCollection.
*
* Examples:
* <code>
* linkToRemote("Delete this post",
* array("update" => "posts", "url" => "delete/{$postid->id}"));
* linkToRemote(imageTag("refresh"),
* array("update" => "emails", "url" => "list_emails" ));
* </code>
*
* By default, these remote requests are processed asynchronous during
* which various callbacks can be triggered (for progress indicators and
* the likes).
*
* Example:
* <code>
* linkToRemote (word,
* array("url" => "undo", "n" => word_counter),
* array("complete" => "undoRequestCompleted(request)"));
* </code>
*
* The callbacks that may be specified are:
*
* - <i>loading</i>:: Called when the remote document is being
* loaded with data by the browser.
* - <i>loaded</i>:: Called when the browser has finished loading
* the remote document.
* - <i>interactive</i>:: Called when the user can interact with the
* remote document, even though it has not
* finished loading.
* - <i>complete</i>:: 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
* <i>options[type] = synchronous</i>.
*
* 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:
*
* - <i>confirm</i>:: Adds confirmation dialog.
* -<i>condition</i>:: Perform remote request conditionally
* by this expression. Use this to
* describe browser-side conditions when
* request should not be initiated.
* - <i>before</i>:: Called before request is initiated.
* - <i>after</i>:: Called immediately after request was
* initiated and before <i>loading</i>.
*
* @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 (<i>options[url]</i>) every <i>options[frequency]</i> seconds (default is 10).
* Usually used to update a specified div (<i>options[update]</i>) 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 (<i>options[url]</i>) every <i>options[frequency]</i> seconds (default is 10).
* Usually used to update a specified div (<i>options[update]</i>) 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. <i>options</i> argument is the same as in <i>form_remote_tag</i>
*
* @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. <i>options</i> argument is the same as in <i>form_remote_tag</i>
*
* @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 <i>field_id</i> and makes
* an Ajax when its contents have changed.
*
* Required +options+ are:
* - <i>frequency</i>:: The frequency (in seconds) at which changes to
* this field will be detected.
* - <i>url</i>:: @see urlFor() -style options for the action to call
* when the field has changed.
*
* Additional options are:
* - <i>update</i>:: Specifies the DOM ID of the element whose
* innerHTML should be updated with the
* XMLHttpRequest response text.
* - <i>with</i>:: 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 <i>field_id</i> and makes
* an Ajax when its contents have changed.
*
* Required +options+ are:
* - <i>frequency</i>:: The frequency (in seconds) at which changes to
* this field will be detected.
* - <i>url</i>:: @see urlFor() -style options for the action to call
* when the field has changed.
*
* Additional options are:
* - <i>update</i>:: Specifies the DOM ID of the element whose
* innerHTML should be updated with the
* XMLHttpRequest response text.
* - <i>with</i>:: 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 <b>form_id</b>. <b>options</b> are the same as <b>observe_field</b>, except
* the default value of the <i>with</i> 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 <b>form_id</b>. <b>options</b> are the same as <b>observe_field</b>, except
* the default value of the <i>with</i> 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();

View file

@ -9,10 +9,10 @@
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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', '<fieldset><legend>%s</legend>%s</label>');
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( '
<fieldset>
<legend>%s</legend>
<div class="notes">
<h4>%s</h4>
<p class="last">%s</p>
</div>
%s
</fieldset>', $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( '
<fieldset>
<legend>%s</legend>
<div class="notes">
<h4>%s</h4>
<p class="last">%s</p>
</div>
%s
</fieldset>', $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;
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -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);
}
}

View file

@ -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) . '%';

View file

@ -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 = '<span class="highlight">\1</span>')
{
if (empty($phrase)) return $text;
@ -78,25 +83,25 @@ class TextHelper extends Helper
}
}
/**
* Strips given text of all links (<a href=....)
*
* @param string $text Text
* @return string The text without links
*/
/**
* Strips given text of all links (<a href=....)
*
* @param string $text Text
* @return string The text without links
*/
function stripLinks($text)
{
return preg_replace('|<a.*>(.*)<\/a>|im', '\1', $text);
}
/**
* Adds links (<a href=....) to a given text, by finding text that begins with
* strings like http:// and ftp://.
*
* @param string $text Text to add links to
* @param array $htmlOptions Array of HTML options.
* @return string The text with links
*/
/**
* Adds links (<a href=....) to a given text, by finding text that begins with
* strings like http:// and ftp://.
*
* @param string $text Text to add links to
* @param array $htmlOptions Array of HTML options.
* @return string The text with links
*/
function autoLinkUrls($text, $htmlOptions = array())
{
$options = 'array(';
@ -124,13 +129,13 @@ class TextHelper extends Helper
);
}
/**
* Adds email links (<a href="mailto:....) to a given text.
*
* @param string $text Text
* @param array $htmlOptions Array of HTML options.
* @return string The text with links
*/
/**
* Adds email links (<a href="mailto:....) to a given text.
*
* @param string $text Text
* @param array $htmlOptions Array of HTML options.
* @return string The text with links
*/
function autoLinkEmails($text, $htmlOptions = array())
{
$options = 'array(';
@ -150,29 +155,29 @@ class TextHelper extends Helper
);
}
/**
* Convert all links and email adresses to HTML links.
*
* @param string $text Text
* @param array $htmlOptions Array of HTML options.
* @return string The text with links
*/
/**
* Convert all links and email adresses to HTML links.
*
* @param string $text Text
* @param array $htmlOptions Array of HTML options.
* @return string The text with links
*/
function autoLink($text, $htmlOptions = array())
{
return $this->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);

View file

@ -1,461 +1,484 @@
<?php
/* SVN FILE: $Id: html.php 578 2005-08-12 04:09:07Z phpnut $ */
/**
* Time Helper class file.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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 <i>strtotime</i>-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);
}
}
<?php
/* SVN FILE: $Id$ */
/**
* Time Helper class file.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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 <i>strtotime</i>-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);
}
}
?>

View file

@ -3,20 +3,20 @@
/**
*
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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 @@
<h1>Missing Method in <?php echo $controller;?></h1>
<p class="error">You are seeing this error because the action <em><?php echo $this->controller->missingAction;?></em>
<p class="error">You are seeing this error because the action <em><?php echo $this->controller->missingAction;?></em>
is not defined in controller <em><?php echo $controller;?></em>
</p>
</p>
<p>
@ -43,7 +43,7 @@ view file, a user-customizable error page for handling invalid action dispatches
</p>
<p>
<strong>Fatal</strong>: Create Method:
<strong>Fatal</strong>: Create Method:
</p>
<p>
<?php echo "<pre>&lt;?php\n\nclass " . $controller ." extends AppController {\n
@ -62,9 +62,9 @@ in file : <?php echo "app".DS."controllers".DS.Inflector::underscore($controller
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
<?php
unset($this->db);
print_r($this);
print_r($this);
?>
</pre>
<?php endif?>
<?php endif;?>

View file

@ -3,20 +3,20 @@
/**
*
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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 @@
<?php $missing = $this->controller->missingController; ?>
<p class="error">You are seeing this error because controller <em><?php echo $missing;?></em>
could not be found.
</p>
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_controller.thtml</code>
@ -43,7 +43,7 @@ view file, a user-customizable error page for handling invalid controller dispat
<strong>Fatal</strong>: Unable to load controller <em><?php echo $missing;?></em>
</p>
<p>
<strong>Fatal</strong>: Create Class:
<strong>Fatal</strong>: Create Class:
</p>
<p>
<?php echo "<pre>&lt;?php\n\nclass " . $missing ." extends AppController {\n}\n\n?&gt;</pre>"; ?>
@ -52,9 +52,9 @@ in file : <?php echo "app".DS."controllers".DS.Inflector::underscore($missing)."
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
<?php
unset($this->db);
print_r($this);
print_r($this);
?>
</pre>
<?php endif?>
<?php endif;?>

View file

@ -38,12 +38,10 @@
view file, a user-customizable error page for handling errors within CakePHP.</span>
</p>
<?if (DEBUG>1):?>
<?php if (DEBUG > 1) { ?>
<h2>Controller dump:</h2>
<pre>
<?
unset($this->db);
print_r($this);
<?php
unset($this->db);
pr($this);
?>
</pre>
<?endif?>
<?php } ?>

View file

@ -1,75 +1,75 @@
<?php
/* SVN FILE: $Id:$ */
/**
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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
*/
?>
<?php
$missingClass = $this->controller->missingHelperClass;
$missingFile = $this->controller->missingHelperFile;
?>
<h1>Missing Helper Class</h1>
<p class="error">You are seeing this error because the view helper class <em><?php echo $missingClass;?></em>
can't be found or doesn't exist in <em><?php echo $missingFile;?></em>
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_helper_class.thtml</code>
view file, a user-customizable error page for handling non-existent view helper classes.</span>
</p>
<p>
<strong>Fatal</strong>: Create the Class:
</p>
<p>
<?php echo "<pre>&lt;?php\n\nclass " . $missingClass ." extends Helper {\n
// Your helper functions here
function <em>myHelperFunction</em> ()
{
}
}\n?&gt;</pre>"; ?>
in file : <?php echo "app".DS."views".DS."helpers".DS.$missingFile.".php"; ?>
</p>
<p>
<strong>Error</strong>: Unable to load helper class <em><?php echo $missingClass;?></em> in
<em>View::_loadHelpers</em>
</p>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
unset($this->db);
print_r($this);
?>
</pre>
<?php endif?>
<?php
/* SVN FILE: $Id$ */
/**
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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
*/
?>
<?php
$missingClass = $this->controller->missingHelperClass;
$missingFile = $this->controller->missingHelperFile;
?>
<h1>Missing Helper Class</h1>
<p class="error">You are seeing this error because the view helper class <em><?php echo $missingClass;?></em>
can't be found or doesn't exist in <em><?php echo $missingFile;?></em>
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_helper_class.thtml</code>
view file, a user-customizable error page for handling non-existent view helper classes.</span>
</p>
<p>
<strong>Fatal</strong>: Create the Class:
</p>
<p>
<?php echo "<pre>&lt;?php\n\nclass " . $missingClass ." extends Helper {\n
// Your helper functions here
function <em>myHelperFunction</em> ()
{
}
}\n?&gt;</pre>"; ?>
in file : <?php echo "app".DS."views".DS."helpers".DS.$missingFile.".php"; ?>
</p>
<p>
<strong>Error</strong>: Unable to load helper class <em><?php echo $missingClass;?></em> in
<em>View::_loadHelpers</em>
</p>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
unset($this->db);
print_r($this);
?>
</pre>
<?php endif;?>

View file

@ -1,75 +1,75 @@
<?php
/* SVN FILE: $Id:$ */
/**
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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
*/
?>
<?php
$missingClass = $this->controller->missingHelperClass;
$missingFile = $this->controller->missingHelperFile;
?>
<h1>Missing Helper File</h1>
<p class="error">You are seeing this error because the view helper file <em><?php echo $missingFile;?></em>
can't be found or doesn't exist
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_helper_file.thtml</code>
view file, a user-customizable error page for handling non-existent view helper files.</span>
</p>
<p>
<strong>Fatal</strong>: Create the Class:
</p>
<p>
<?php echo "<pre>&lt;?php\n\nclass " . $missingClass ." extends Helper {\n
// Your helper functions here
function <em>myHelperFunction</em> ()
{
}
}\n?&gt;</pre>"; ?>
in file : <?php echo "app".DS."views".DS."helpers".DS.$missingFile.".php"; ?>
</p>
<p>
<strong>Error</strong>: Unable to load helper file <em><?php echo $missingFile.".php";?></em> in
<em>View::_loadHelpers</em>
</p>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
unset($this->db);
print_r($this);
?>
</pre>
<?php endif?>
<?php
/* SVN FILE: $Id$ */
/**
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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
*/
?>
<?php
$missingClass = $this->controller->missingHelperClass;
$missingFile = $this->controller->missingHelperFile;
?>
<h1>Missing Helper File</h1>
<p class="error">You are seeing this error because the view helper file <em><?php echo $missingFile;?></em>
can't be found or doesn't exist
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_helper_file.thtml</code>
view file, a user-customizable error page for handling non-existent view helper files.</span>
</p>
<p>
<strong>Fatal</strong>: Create the Class:
</p>
<p>
<?php echo "<pre>&lt;?php\n\nclass " . $missingClass ." extends Helper {\n
// Your helper functions here
function <em>myHelperFunction</em> ()
{
}
}\n?&gt;</pre>"; ?>
in file : <?php echo "app".DS."views".DS."helpers".DS.$missingFile.".php"; ?>
</p>
<p>
<strong>Error</strong>: Unable to load helper file <em><?php echo $missingFile.".php";?></em> in
<em>View::_loadHelpers</em>
</p>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
unset($this->db);
print_r($this);
?>
</pre>
<?php endif;?>

View file

@ -3,20 +3,20 @@
/**
*
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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 @@
<h1>Scaffold Requires a Database Connection</h1>
<p class="error">Missing Database Connection: Scaffold Does not work without a database connection
</p>
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_database.thtml</code>
view file, a user-customizable error page for handling errors within CakePHP.</span>
</p>
<?if (DEBUG>1):?>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?
<?php
unset($this->db);
print_r($this);
print_r($this);
?>
</pre>
<?endif?>
<?php endif;?>

View file

@ -3,20 +3,20 @@
/**
*
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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 @@
?>
<?php $missing = $this->controller->missingTable;?>
<h1>Missing Database Table</h1>
<p class="error">No Database table for model <?php echo $missing;?> (expected "<? echo $this->controller->missingTableName;?>"), create it first.
</p>
<p class="error">No Database table for model <?php echo $missing;?> (expected "<?php echo $this->controller->missingTableName;?>"), create it first.
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_table.thtml</code>
view file, a user-customizable error page.</span>

View file

@ -3,20 +3,20 @@
/**
*
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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 @@
?>
<h1>Missing view</h1>
<p class="error">You are seeing this error because the view <em><?php echo $this->missingView;?></em>
for action <em><?php echo $this->params['action'];?></em>
<p class="error">You are seeing this error because the view <em><?php echo $this->missingView;?></em>
for action <em><?php echo $this->params['action'];?></em>
in controller <em><?php echo Inflector::camelize($this->name);?></em> could not be found.
</p>
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_view.thtml</code>
@ -48,9 +48,9 @@ action <em><?php echo $this->missingView;?>::<?php echo $this->params['action'];
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
<?php
unset($this->db);
print_r($this);
print_r($this);
?>
</pre>
<?endif?>
<?php endif;?>

View file

@ -42,15 +42,15 @@
<?php echo $html->image('cake.logo.png', array('alt'=>'CakePHP : Rapid Development Framework', 'border'=>"0"))?>
</div>
<div id="content">
<?php if (isset($this->controller->Session)) $this->controller->Session->flash(); ?>
<?php echo $content_for_layout?>
<?php if (isset($this->controller->Session)) $this->controller->Session->flash(); ?>
<?php echo $content_for_layout?>
</div>
<div id="footer">
<p>&copy; 2005 CakePHP ::
<a href="http://www.cakefoundation.org/copyright/cakephp/"><?php echo 'Cake Software Foundation, Inc.'; ?></a>
</p>
<br />
<p>
<p>&copy; 2005 CakePHP ::
<a href="http://www.cakefoundation.org/pages/copyright/"><?php echo 'Cake Software Foundation, Inc.'; ?></a>
</p>
<br />
<p>
<!--PLEASE USE ONE OF THE POWERED BY CAKEPHP LOGO-->
<a href="http://www.cakephp.org/" target="_new">
<?php echo $html->image('cake.power.png', array('alt'=>'CakePHP : Rapid Development Framework',

View file

@ -7,10 +7,10 @@
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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.
*
@ -30,28 +30,41 @@
$modelKey = $modelName;
?>
<h1>Edit <?php echo Inflector::humanize($modelName);?></h1>
<h1><?php echo $type.' '.Inflector::humanize($modelName);?></h1>
<?php
echo $html->formTag('/'. Inflector::underscore($this->name) .'/update');
if($type == 'Edit')
{
echo $html->formTag('/'. Inflector::underscore($this->name) .'/update');
}
else
{
echo $html->formTag('/'. Inflector::underscore($this->name).'/create');
}
echo $form->generateFields( $fieldNames );
echo $form->generateFields( $fieldNames );
echo $form->generateSubmitDiv( 'Save' )
echo $form->generateSubmitDiv( 'Save' )
?>
</form>
<ul class='actions'>
<?php
if($type == 'Edit')
{
echo "<li>".$html->linkTo('Delete '.Inflector::humanize($modelName), '/'.$this->viewPath.'/destroy/'.$data[$modelKey][$this->controller->{$modelName}->primaryKey])."</li>";
}
echo "<li>".$html->linkTo('List '.Inflector::humanize($modelName), '/'.$this->viewPath.'/index')."</li>";
foreach( $fieldNames as $field => $value ) {
if( isset( $value['foreignKey'] ) )
{
echo "<li>".$html->linkTo( "View ".Inflector::humanize($value['controller']), "/".Inflector::underscore($value['controller'])."/show/".$data[$modelKey][$field] )."</li>";
}
}
if($type == 'Edit')
{
foreach( $fieldNames as $field => $value )
{
if( isset( $value['foreignKey'] ) )
{
echo "<li>".$html->linkTo( "View ".Inflector::humanize($value['controller']), "/".Inflector::underscore($value['controller'])."/show/".$data[$modelKey][$field] )."</li>";
}
}
}
?>
</ul>

View file

@ -33,7 +33,7 @@
$modelKey = $model;
$humanName = Inflector::humanize($this->name);
$humanSingularName = Inflector::singularize( $humanName );
// var_dump( $data );
// var_dump( $data );
?>
<table class="inav" cellspacing="0">
<tr>

View file

@ -29,11 +29,11 @@
<h1>New <?php echo Inflector::humanize($this->name)?></h1>
<?php
echo $html->formTag('/'. Inflector::underscore($this->name).'/create');
echo $html->formTag('/'. Inflector::underscore($this->name).'/create');
echo $form->generateFields( $fieldNames );
echo $form->generateFields( $fieldNames );
echo $form->generateSubmitDiv( 'Add' )
echo $form->generateSubmitDiv( 'Add' )
?>
</form>
<ul class='actions'>

View file

@ -3,19 +3,19 @@
/**
* Methods for displaying presentation data
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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,16 +30,16 @@
/**
* Included libraries.
*/
uses('object', DS.'view'.DS.'helper');
uses(DS.'view'.DS.'helper');
/**
* View, the V in the MVC triad.
*
* Class holding methods for displaying presentation data.
*
* @package cake
* @subpackage cake.cake.libs.view
* @since CakePHP v 0.10.0.1076
* @package cake
* @subpackage cake.cake.libs.view
* @since CakePHP v 0.10.0.1076
*/
class View extends Object
{
@ -247,7 +247,11 @@ class View extends Object
$this->setLayout($layout);
}
$viewFileName = $file? $file: $this->_getViewFileName($action);
$viewFileName = $this->_getViewFileName($action);
if ($file)
{
$viewFileName = $file;
}
if (!is_file($viewFileName))
{
@ -366,7 +370,7 @@ class View extends Object
{
return "(Error rendering {$name})";
}
return $this->_render($fn, array_merge($this->_viewVars, $params));
return $this->_render($fn, array_merge($this->_viewVars, $params), true, false);
}
/**
@ -385,7 +389,7 @@ class View extends Object
if (is_file($layout_fn))
{
$out = $this->_render($layout_fn, $data_for_layout);
$out = $this->_render($layout_fn, $data_for_layout, true, false);
if ($out === false)
{
@ -496,15 +500,15 @@ class View extends Object
}
$layoutFileName = LAYOUTS.$type."{$this->layout}.thtml";
if(file_exists(LAYOUTS.$type."{$this->layout}.thtml"))
{
$layoutFileName = LAYOUTS.$type."{$this->layout}.thtml";
}
else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS.$type."{$this->layout}.thtml"))
{
$layoutFileName = LIBS.'view'.DS.'templates'.DS."layouts".DS.$type."{$this->layout}.thtml";
}
return $layoutFileName;
if(file_exists(LAYOUTS.$type."{$this->layout}.thtml"))
{
$layoutFileName = LAYOUTS.$type."{$this->layout}.thtml";
}
else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS.$type."{$this->layout}.thtml"))
{
$layoutFileName = LIBS.'view'.DS.'templates'.DS."layouts".DS.$type."{$this->layout}.thtml";
}
return $layoutFileName;
}
/**
@ -517,12 +521,12 @@ class View extends Object
* @return string Rendered output
* @access private
*/
function _render($___viewFn, $___data_for_view, $___play_safe = true)
function _render($___viewFn, $___data_for_view, $___play_safe = true, $loadHelpers = true)
{
/**
/**
* Fetching helpers
*/
if ($this->helpers !== false)
if ($this->helpers != false && $loadHelpers = true)
{
$loadedHelpers = array();
$loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
@ -544,19 +548,19 @@ class View extends Object
}
extract($___data_for_view, EXTR_SKIP); # load all view variables
/**
/**
* Local template variables.
*/
$BASE = $this->base;
$params = &$this->params;
$page_title = $this->pageTitle;
/**
/**
* Start caching output (eval outputs directly so we need to cache).
*/
ob_start();
/**
/**
* Include the template.
*/
$___play_safe? @include($___viewFn): include($___viewFn);
@ -566,81 +570,81 @@ class View extends Object
return $out;
}
/**
/**
* Loads helpers, with their dependencies.
*
* @param array $loaded List of helpers that are already loaded.
* @param array $helpers List of helpers to load.
* @return array
*/
function &_loadHelpers(&$loaded, $helpers) {
foreach ($helpers as $helper)
{
if(in_array($helper, array_keys($loaded)) !== true)
function &_loadHelpers(&$loaded, $helpers)
{
foreach ($helpers as $helper)
{
$helperFn = Inflector::underscore($helper).'.php';
$helperCn = $helper.'Helper';
if(file_exists(HELPERS.$helperFn))
if(in_array($helper, array_keys($loaded)) !== true)
{
$helperFn = HELPERS.$helperFn;
}
else if(file_exists(LIBS.'view'.DS.'helpers'.DS.$helperFn))
{
$helperFn = LIBS.'view'.DS.'helpers'.DS.$helperFn;
}
$helperCn = $helper.'Helper';
$replace = strtolower(substr($helper, 0, 1));
$camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1);
if (is_file($helperFn))
{
require_once $helperFn;
if(class_exists($helperCn)===true)
{
${$camelBackedHelper} =& new $helperCn;
${$camelBackedHelper}->base = $this->base;
${$camelBackedHelper}->webroot = $this->webroot;
${$camelBackedHelper}->here = $this->here;
${$camelBackedHelper}->params = $this->params;
${$camelBackedHelper}->action = $this->action;
${$camelBackedHelper}->data = $this->data;
if(!empty($this->validationErrors))
if(!class_exists($helperCn))
{
${$camelBackedHelper}->validationErrors = $this->validationErrors;
$helperFn = Inflector::underscore($helper).'.php';
if(file_exists(HELPERS.$helperFn))
{
$helperFn = HELPERS.$helperFn;
}
else if(file_exists(LIBS.'view'.DS.'helpers'.DS.$helperFn))
{
$helperFn = LIBS.'view'.DS.'helpers'.DS.$helperFn;
}
if (is_file($helperFn))
{
require_once $helperFn;
}
else
{
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->base;
call_user_func_array(array(&$error, 'missingHelperFile'), Inflector::underscore($helper));
exit();
}
}
$loaded[$helper] =& ${$camelBackedHelper};
// Find and load helper dependencies
if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers))
$replace = strtolower(substr($helper, 0, 1));
$camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1);
if(class_exists($helperCn, FALSE))
{
$loaded =& $this->_loadHelpers($loaded, ${$camelBackedHelper}->helpers);
}
}
else
{
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->base;
call_user_func_array(array(&$error, 'missingHelperClass'), $helper);
exit();
}
}
else
{
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->base;
call_user_func_array(array(&$error, 'missingHelperFile'), Inflector::underscore($helper));
exit();
}
}
}
${$camelBackedHelper} =& new $helperCn;
${$camelBackedHelper}->base = $this->base;
${$camelBackedHelper}->webroot = $this->webroot;
${$camelBackedHelper}->here = $this->here;
${$camelBackedHelper}->params = $this->params;
${$camelBackedHelper}->action = $this->action;
${$camelBackedHelper}->data = $this->data;
return $loaded;
}
if(!empty($this->validationErrors))
{
${$camelBackedHelper}->validationErrors = $this->validationErrors;
}
$loaded[$helper] =& ${$camelBackedHelper};
if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers))
{
$loaded =& $this->_loadHelpers($loaded, ${$camelBackedHelper}->helpers);
}
}
else
{
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->base;
call_user_func_array(array(&$error, 'missingHelperClass'), $helper);
exit();
}
}
}
return $loaded;
}
}
?>

View file

@ -75,46 +75,46 @@ $aclCLI = new AclCLI ($command, $args);
class AclCLI {
/**
/**
* Enter description here...
*
* @var unknown_type
*/
var $stdin;
/**
/**
* Enter description here...
*
* @var unknown_type
*/
var $stdout;
/**
/**
* Enter description here...
*
* @var unknown_type
*/
var $stderr;
/**
/**
* Enter description here...
*
* @var unknown_type
*/
var $acl;
/**
/**
* Enter description here...
*
* @var unknown_type
*/
var $controller;
/**
/**
* Enter description here...
*
* @var unknown_type
*/
var $args;
/**
/**
* Enter description here...
*
* @param unknown_type $command
@ -126,7 +126,7 @@ class AclCLI {
$this->__construct($command, $args);
}
/**
/**
* Enter description here...
*
* @param unknown_type $command
@ -200,7 +200,7 @@ class AclCLI {
}
/**
/**
* Enter description here...
*
*/
@ -221,7 +221,7 @@ class AclCLI {
fwrite($this->stdout, "New $class '".$this->args[3]."' created.\n\n");
}
/**
/**
* Enter description here...
*
*/
@ -237,7 +237,7 @@ class AclCLI {
//fwrite($this->stdout, "$class deleted.\n\n");
}
/**
/**
* Enter description here...
*
*/
@ -258,7 +258,7 @@ class AclCLI {
}
}
/**
/**
* Enter description here...
*
*/
@ -285,7 +285,7 @@ class AclCLI {
}
}
/**
/**
* Enter description here...
*
*/
@ -299,7 +299,7 @@ class AclCLI {
fwrite($this->stdout, "Permission granted.\n");
}
/**
/**
* Enter description here...
*
*/
@ -312,13 +312,13 @@ class AclCLI {
fwrite($this->stdout, "Requested permission successfully denied.\n");
}
/**
/**
* Enter description here...
*
*/
function inherit() {}
/**
/**
* Enter description here...
*
*/
@ -361,7 +361,7 @@ class AclCLI {
fwrite($this->stdout, "------------------------------------------------\n");
}
/**
/**
* Enter description here...
*
*/
@ -406,7 +406,7 @@ class AclCLI {
fwrite($this->stdout, "\nDone.\n");
}
/**
/**
* Enter description here...
*
*/
@ -485,7 +485,7 @@ class AclCLI {
fwrite($this->stdout, $out);
}
/**
/**
* Enter description here...
*
* @param unknown_type $title
@ -501,7 +501,7 @@ class AclCLI {
exit();
}
/**
/**
* Enter description here...
*
* @param unknown_type $expectedNum
@ -515,7 +515,7 @@ class AclCLI {
}
}
/**
/**
* Enter description here...
*
*/
@ -527,7 +527,7 @@ class AclCLI {
}
}
/**
/**
* Enter description here...
*
* @param unknown_type $type
@ -552,7 +552,7 @@ class AclCLI {
}
}
/**
/**
* Enter description here...
*
* @param unknown_type $type