Merging fixes and enhancements into trunk

Revision: [2025]
A little more work on plugin to set some default routing.

Revision: [2024]
Changed DboSource::field() so the name() is not called for some field variables.

Revision: [2023]
Changes made in [2022] should only check if the $conditions is not empty.

Revision: [2022]
Changed DboSource::conditions() so it will add the "ticks" needed around the Model.field names.
The Model.field name conventions must be used for this to work.

Revision: [2021]
Adding fix for Ticket #405

Revision: [2020]
Added fix for Ticket #403

Revision: [2019]
Added patch from Ticket #404.
Fixing formatting of files.

Revision: [2018]
Fixing formatting of files 

Revision: [2017]
Fixed bad search and replace

Revision: [2016]
Fixing formatting of files 

Revision: [2015]
Replaced all 3 space indents with 4 space indents

Revision: [2014]
Updating variables to use the naming proper conventions

Revision: [2013]
Added patch from Ticket #406

Revision: [2012]
Adding fix for Ticket #407.
Fix variables that where not formatted per the coding conventions

Revision: [2011]
Adding patch from Ticket #401

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2026 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-02-18 23:42:21 +00:00
parent 9a8d5c15fe
commit a75e08976f
74 changed files with 3207 additions and 3045 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
0.10.8.2010
0.10.8.2026

View file

@ -60,8 +60,8 @@ define('DEBUG', 1);
define ('LOG_ERROR', 2);
/**
* CakePHP includes 3 types of session saves
* database or file. Set this to your preffered method.
* If you want to use your own save handeler place it in
* database or file. Set this to your preferred method.
* If you want to use your own save handler place it in
* app/config/name.php DO NOT USE file or database as the name.
* and use just the name portion below.
*
@ -117,7 +117,7 @@ define('WEBSERVICES', 'off');
/**
* Compress output CSS (removing comments, whitespace, repeating tags etc.)
* This requires a /var/cache directory to be writable by the web server (caching).
* This requires a/var/cache directory to be writable by the web server (caching).
* To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use Controller::cssTag().
*/
define('COMPRESS_CSS', false);

View file

@ -1,7 +1,7 @@
# @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
# @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
# @since CakePHP v 0.10.8.1997
# @version $Revision$
-- @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
-- @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
-- @since CakePHP v 0.10.8.1997
-- @version $Revision$
CREATE TABLE cake_sessions (
id varchar(255) NOT NULL default '',

View file

@ -109,8 +109,8 @@ else
header("Date: ".date("D, j M Y G:i:s ", $templateModified).'GMT');
header("Content-Type: text/css");
header("Expires: ".gmdate("D, j M Y H:i:s", time()+DAY)." GMT");
header("Cache-Control: cache"); // HTTP/1.1
header("Pragma: cache"); // HTTP/1.0
header("Cache-Control: cache");// HTTP/1.1
header("Pragma: cache");// HTTP/1.0
print $output;
?>

View file

@ -37,13 +37,13 @@
if (!defined('ROOT'))
{
//define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
//define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
if (!defined('APP_DIR'))
{
//define('APP_DIR', 'DIRECTORY NAME OF APPLICATION';
//define('APP_DIR', 'DIRECTORY NAME OF APPLICATION';
define ('APP_DIR', basename(dirname(dirname(__FILE__))));
}
@ -53,7 +53,7 @@ if (!defined('APP_DIR'))
*/
if (!defined('CAKE_CORE_INCLUDE_PATH'))
{
//define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
//define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
define('CAKE_CORE_INCLUDE_PATH', ROOT);
}

View file

@ -165,7 +165,7 @@ function loadModel($name)
{
$name = Inflector::underscore($name);
// Make sure AppModel is loaded
// Make sure AppModel is loaded
if(!class_exists('AppModel'))
{
if(file_exists(APP.'app_model.php'))
@ -289,23 +289,33 @@ function loadPluginController ($plugin, $controller)
}
}
if(empty($controller))
{
if(file_exists(APP.'plugins'.DS.$plugin.DS.'controllers'.DS.$plugin.'_controller.php'))
{
require(APP.'plugins'.DS.$plugin.DS.'controllers'.DS.$plugin.'_controller.php');
return true;
}
}
if(!class_exists($controller.'Controller'))
{
$controller = Inflector::underscore($controller);
$file = APP.'plugins'.DS.$plugin.DS.'controllers'.DS.$controller.'_controller.php';
if(!file_exists($file))
{
return false;
}
else
if(file_exists($file))
{
require($file);
return true;
}
elseif(file_exists(APP.'plugins'.DS.$plugin.DS.'controllers'.DS.$plugin.'_controller.php'))
{
require(APP.'plugins'.DS.$plugin.DS.'controllers'.DS.$plugin.'_controller.php');
return true;
}
else
{
return true;
return false;
}
}
}
@ -506,11 +516,11 @@ if (!function_exists('array_combine'))
if ($c1 != $c2)
{
return false; // different lenghts
return false;// different lenghts
}
if ($c1 <= 0)
{
return false; // arrays are the same and both are empty
return false;// arrays are the same and both are empty
}
$output = array();
@ -750,7 +760,7 @@ function env($key)
if (!function_exists('file_get_contents'))
{
/**
/**
* Returns contents of a file as a string.
*
* @param string $fileName Name of the file.
@ -788,7 +798,7 @@ if (!function_exists('file_get_contents'))
if (!function_exists('file_put_contents'))
{
/**
/**
* Writes data into file.
*
* If file exists, it will be overwritten. If data is an array, it will be
@ -843,12 +853,12 @@ function cache($path, $data = null, $expires = '+1 day', $target = 'cache')
if ($data == null)
{
// Read data from file
// Read data from file
if (file_exists($filename) && $filetime !== false)
{
if ($filetime + $timediff < $now)
{
// File has expired
// File has expired
@unlink($filename);
}
else

View file

@ -125,11 +125,18 @@ class Dispatcher extends Object
else
{
$ctrlClass = $pluginClass;
$oldAction = $params['action'];
$params = $this->_restructureParams($params);
$plugin = Inflector::underscore($ctrlName);
$this->plugin = $plugin.DS;
loadPluginModels($plugin);
$this->base = $this->base.'/'.Inflector::underscore($ctrlName);
if(empty($params['controller']) || !class_exists($pluginClass))
{
$params['controller'] = Inflector::underscore($ctrlName);
$ctrlClass = $ctrlName.'Controller';
$params['action'] = $oldAction;
}
}
}
}
@ -288,7 +295,7 @@ class Dispatcher extends Object
*/
function parseParams($from_url)
{
// load routes config
// load routes config
$Route = new Router();
include CONFIGS.'routes.php';
$params = $Route->parse ($from_url);
@ -351,7 +358,7 @@ class Dispatcher extends Object
$docRoot = env('DOCUMENT_ROOT');
$scriptName = env('PHP_SELF');
// If document root ends with 'webroot', it's probably correctly set
// If document root ends with 'webroot', it's probably correctly set
$r = null;
if (preg_match('/'.APP_DIR.'\\'.DS.WEBROOT_DIR.'/', $docRoot))
{

View file

@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// +---------------------------------------------------------------------------------------------------+ //
// +---------------------------------------------------------------------------------------------------+//
// + $Id$
// + Last Modified: $Date$
// + Modified By: $LastChangedBy$
// +---------------------------------------------------------------------------------------------------+ //
// +---------------------------------------------------------------------------------------------------+//
///////////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// +---------------------------------------------------------------------------------------------------+ //
// +---------------------------------------------------------------------------------------------------+//
// + $Id$
// + Last Modified: $Date$
// + Modified By: $LastChangedBy$
// +---------------------------------------------------------------------------------------------------+ //
// +---------------------------------------------------------------------------------------------------+//
///////////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -1,9 +1,9 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// +---------------------------------------------------------------------------------------------------+ //
// +---------------------------------------------------------------------------------------------------+//
// + $Id$
// + Last Modified:$
// + Modified By:$
// +---------------------------------------------------------------------------------------------------+ //
// +---------------------------------------------------------------------------------------------------+//
///////////////////////////////////////////////////////////////////////////////////////////////////////////
You can find some help with problems you may have installing CakePHP here:

View file

@ -1,9 +1,9 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// +---------------------------------------------------------------------------------------------------+ //
// +---------------------------------------------------------------------------------------------------+//
// + $Id$
// + Last Modified: $Date$
// + Modified By: $LastChangedBy$
// +---------------------------------------------------------------------------------------------------+ //
// +---------------------------------------------------------------------------------------------------+//
///////////////////////////////////////////////////////////////////////////////////////////////////////////
This README will be updated

View file

@ -43,7 +43,7 @@ uses('object', 'inflector');
class Bake extends Object
{
/**
/**
* Standard input stream (php://stdin).
*
* @var resource
@ -51,7 +51,7 @@ class Bake extends Object
*/
var $stdin = null;
/**
/**
* Standard output stream (php://stdout).
*
* @var resource
@ -59,7 +59,7 @@ class Bake extends Object
*/
var $stdout = null;
/**
/**
* Standard error stream (php://stderr).
*
* @var resource
@ -67,7 +67,7 @@ class Bake extends Object
*/
var $stderr = null;
/**
/**
* Counts actions taken.
*
* @var integer
@ -75,7 +75,7 @@ class Bake extends Object
*/
var $actions = null;
/**
/**
* Decides whether to overwrite existing files without asking.
*
* @var boolean
@ -83,7 +83,7 @@ class Bake extends Object
*/
var $dontAsk = false;
/**
/**
* Returns code template for PHP file generator.
*
* @param string $type
@ -105,13 +105,13 @@ class %sTest extends TestCase
{
var $abc;
// called before the tests
// called before the tests
function setUp()
{
$this->abc = new %s ();
}
// called after the tests
// called after the tests
function tearDown()
{
unset($this->abc);
@ -133,7 +133,7 @@ class %sTest extends TestCase
}
}
/**
/**
* Baker's constructor method. Initialises bakery, and starts production.
*
* @param string $type
@ -152,7 +152,7 @@ class %sTest extends TestCase
$this->stdout = fopen('php://stdout', 'w');
$this->stderr = fopen('php://stderr', 'w');
// Output directory name
// Output directory name
fwrite($this->stderr, "\n".substr(ROOT,0,strlen(ROOT)-1).":\n".str_repeat('-',strlen(ROOT)+1)."\n");
switch ($type)
@ -221,7 +221,7 @@ class %sTest extends TestCase
}
}
/**
/**
* Creates new view in VIEWS/$controller/ directory.
*
* @param string $controller
@ -245,7 +245,7 @@ class %sTest extends TestCase
$this->actions++;
}
/**
/**
* Creates new controller with defined actions, controller's test and
* helper with helper's test.
*
@ -263,12 +263,12 @@ class %sTest extends TestCase
{
$this->makeController($name, $actions);
$this->makeControllerTest($name);
//$this->makeHelper($name);
//$this->makeHelperTest($name);
//$this->makeHelper($name);
//$this->makeHelperTest($name);
$this->actions++;
}
/**
/**
* Creates new controller file with defined actions.
*
* @param string $name
@ -286,12 +286,12 @@ class %sTest extends TestCase
{
$ctrl = $this->makeControllerName($name);
$helper = $this->makeHelperName($name);
//$body = sprintf($this->template('ctrl'), $ctrl, $helper, join('', $this->getActions($actions)));
//$body = sprintf($this->template('ctrl'), $ctrl, $helper, join('', $this->getActions($actions)));
$body = sprintf($this->template('ctrl'), $ctrl, 'AppController', join('', $this->getActions($actions)));
return $this->createFile($this->makeControllerFn($name), $body);
}
/**
/**
* Returns controller's name in CamelCase.
*
* @param string $name
@ -304,7 +304,7 @@ class %sTest extends TestCase
return Inflector::camelize($name).'Controller';
}
/**
/**
* Returns a name for controller's file, underscored.
*
* @param string $name
@ -317,7 +317,7 @@ class %sTest extends TestCase
return CONTROLLERS.Inflector::underscore($name).'_controller.php';
}
/**
/**
* Creates new test for a controller.
*
* @param string $name
@ -334,10 +334,10 @@ class %sTest extends TestCase
$fn = CONTROLLER_TESTS.Inflector::underscore($name).'_controller_test.php';
$body = $this->getTestBody($this->makeControllerName($name));
return true; //$this->createFile($fn, $body); // Disable creating tests till later
return true;//$this->createFile($fn, $body);// Disable creating tests till later
}
/**
/**
* Creates new helper.
*
* @param string $name
@ -355,7 +355,7 @@ class %sTest extends TestCase
return $this->createFile($this->makeHelperFn($name), $body);
}
/**
/**
* Returns CamelCase name for a helper.
*
* @param string $name
@ -368,7 +368,7 @@ class %sTest extends TestCase
return Inflector::camelize($name).'Helper';
}
/**
/**
* Underscores file name for a helper.
*
* @param string $name
@ -382,7 +382,7 @@ class %sTest extends TestCase
return HELPERS.Inflector::underscore($name).'_helper.php';
}
/**
/**
* Creates new test for a helper.
*
* @param string $name
@ -402,7 +402,7 @@ class %sTest extends TestCase
return $this->createFile($fn, $body);
}
/**
/**
* Returns an array of actions' templates.
*
* @param array $as
@ -420,7 +420,7 @@ class %sTest extends TestCase
return $out;
}
/**
/**
* Returns a test template for given class.
*
* @param string $class
@ -433,7 +433,7 @@ class %sTest extends TestCase
return sprintf($this->template('test'), $class, $class);
}
/**
/**
* Creates new model.
*
* @param string $name
@ -470,12 +470,12 @@ class %sTest extends TestCase
}
$this->createFile($this->getModelFn($name), sprintf($this->template('model'), $this->getModelName($name)));
//$this->makeModelTest ($name);
// TODO: Add model test back when I'm less lazy
//$this->makeModelTest ($name);
// TODO: Add model test back when I'm less lazy
$this->actions++;
}
/**
/**
* Returns an underscored filename for a model.
*
* @param string $name
@ -489,7 +489,7 @@ class %sTest extends TestCase
return MODELS.Inflector::underscore($name).'.php';
}
/**
/**
* Creates a test for a given model.
*
* @param string $name
@ -509,7 +509,7 @@ class %sTest extends TestCase
return $this->createFile($fn, $body);
}
/**
/**
* Returns CamelCased name of a model.
*
* @param string $name
@ -522,7 +522,7 @@ class %sTest extends TestCase
return Inflector::camelize($name);
}
/**
/**
* Creates a file with given path and contents.
*
* @param string $path
@ -568,18 +568,18 @@ 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
@ -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

@ -48,35 +48,35 @@ if(!class_exists('Model'))
*/
class Cache extends Model {
/**
/**
* Identifier. Either an MD5 string or NULL.
*
* @var string
*/
var $id = null;
/**
/**
* Content container for cache data.
*
* @var unknown_type
*/
var $data = 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';
/**
/**
* Constructor. Generates an md5'ed id for internal use. Calls the constructor on Model as well.
*
* @param unknown_type $id
@ -87,7 +87,7 @@ class Cache extends Model {
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
@ -99,7 +99,7 @@ class Cache extends Model {
return ($this->id = $id);
}
/**
/**
* Store given content in cache database.
*
* @param string $content Content to keep in cache.
@ -113,7 +113,7 @@ class Cache extends Model {
return $this->query("REPLACE {$this->useTable} (id,data,expire) VALUES ('{$this->id}', '{$data}', '{$expire}')");
}
/**
/**
* Returns content from the Cache object itself, if the Cache object has a non-empty data property.
* Else from the database cache.
*
@ -127,7 +127,7 @@ class Cache extends Model {
return $this->data['data'];
}
/**
/**
* Returns true if the cache data property has current (non-stale) content for given id.
*
* @return boolean
@ -137,7 +137,7 @@ class Cache extends Model {
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
@ -147,7 +147,7 @@ class Cache extends Model {
$this->for_caching .= $string;
}
/**
/**
* Clears the cache database table.
*
* @return unknown

View file

@ -47,7 +47,7 @@ class AclBase
*/
function AclBase()
{
//No instantiations or constructor calls (even statically)
//No instantiations or constructor calls (even statically)
if (strcasecmp(get_class($this), "AclBase") == 0 || !is_subclass_of($this, "AclBase"))
{
trigger_error(__("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration."), E_USER_ERROR);

View file

@ -103,7 +103,7 @@ class DB_ACL extends AclBase
{
if($action == '*')
{
// ARO must be cleared for ALL ACO actions
// ARO must be cleared for ALL ACO actions
foreach($permKeys as $key)
{
if(isset($perm['aros_acos']))
@ -151,7 +151,7 @@ class DB_ACL extends AclBase
if($perms == false)
{
// One of the nodes does not exist
// One of the nodes does not exist
return false;
}
@ -176,7 +176,7 @@ class DB_ACL extends AclBase
}
else
{
// Raise an error
// Raise an error
return false;
}
}
@ -188,7 +188,7 @@ class DB_ACL extends AclBase
{
$save['id'] = $perms['link'][0]['aros_acos']['id'];
}
//return $Perms->save(array('ArosAco' => $save));
//return $Perms->save(array('ArosAco' => $save));
if(isset($save['id']))
{
@ -264,7 +264,7 @@ class DB_ACL extends AclBase
{
if($id == null)
{
// Raise error
// Raise error
}
$aro = new Aro();
$tmp = $aro->find(is_string($aro) ? "aros.alias = '" . addslashes($aro) . "'" : "aros.user_id = {$aro}");
@ -283,7 +283,7 @@ class DB_ACL extends AclBase
{
if($id == null)
{
// Raise error
// Raise error
}
$aco = new Aco();
$tmp = $aco->find(is_string($aco) ? "acos.alias = '" . addslashes($aco) . "'" : "acos.user_id = {$aco}");

View file

@ -78,7 +78,7 @@ class AclNode extends AppModel
if($parent[0]['MAX(rght)'] == null)
{
// The tree is empty
// The tree is empty
$parent['lft'] = 0;
}
}
@ -134,12 +134,12 @@ class AclNode extends AppModel
$object = $this->find($this->_resolveID($id, $secondary_id));
if($object == null || count($object) == 0)
{
// Couldn't find object
// Couldn't find object
return false;
}
$parent = $this->getParent(intval($object[$class][$secondary_id]));
// Node is already at root, or new parent == old parent
// Node is already at root, or new parent == old parent
if(($parent == null && $parent_id == null) || ($parent_id == $parent[$class][$secondary_id]) || ($parent_id == $parent[$class]['alias']))
{
return false;
@ -147,7 +147,7 @@ class AclNode extends AppModel
if($parent_id != null && $parent[$class]['lft'] <= $object[$class]['lft'] && $parent[$class]['rght'] >= $object[$class]['rght'])
{
// Can't move object inside self or own child
// Can't move object inside self or own child
return false;
}
$this->_syncTable($table_name, 0, $object[$class]['lft'], $object[$class]['lft']);

View file

@ -50,7 +50,7 @@ class INI_ACL extends AclBase
/**
* Main ACL check function. Checks to see if the ARO (access request object) has access to the ACO (access control object).
* Looks at the acl.ini.php file for permissions (see instructions in /config/acl.ini.php).
* Looks at the acl.ini.php file for permissions (see instructions in/config/acl.ini.php).
*
* @param string $aro
* @param string $aco
@ -60,55 +60,55 @@ class INI_ACL extends AclBase
{
$aclConfig = $this->readConfigFile(CONFIGS . 'acl.ini.php');
//First, if the user is specifically denied, then DENY
//First, if the user is specifically denied, then DENY
if(isset($aclConfig[$aro]['deny']))
{
$userDenies = $this->arrayTrim(explode(",", $aclConfig[$aro]['deny']));
if (array_search($aco, $userDenies))
{
//echo "User Denied!";
//echo "User Denied!";
return false;
}
}
//Second, if the user is specifically allowed, then ALLOW
//Second, if the user is specifically allowed, then ALLOW
if(isset($aclConfig[$aro]['allow']))
{
$userAllows = $this->arrayTrim(explode(",", $aclConfig[$aro]['allow']));
if (array_search($aco, $userAllows))
{
//echo "User Allowed!";
//echo "User Allowed!";
return true;
}
}
//Check group permissions
//Check group permissions
if (isset($aclConfig[$aro]['groups']))
{
$userGroups = $this->arrayTrim(explode(",", $aclConfig[$aro]['groups']));
foreach ($userGroups as $group)
{
//If such a group exists,
//If such a group exists,
if(array_key_exists($group, $aclConfig))
{
//If the group is specifically denied, then DENY
//If the group is specifically denied, then DENY
if(isset($aclConfig[$group]['deny']))
{
$groupDenies = $this->arrayTrim(explode(",", $aclConfig[$group]['deny']));
if (array_search($aco, $groupDenies))
{
//echo("Group Denied!");
//echo("Group Denied!");
return false;
}
}
//If the group is specifically allowed, then ALLOW
//If the group is specifically allowed, then ALLOW
if(isset($aclConfig[$group]['allow']))
{
$groupAllows = $this->arrayTrim(explode(",", $aclConfig[$group]['allow']));
if (array_search($aco, $groupAllows))
{
//echo("Group Allowed!");
//echo("Group Allowed!");
return true;
}
}
@ -116,8 +116,8 @@ class INI_ACL extends AclBase
}
}
//Default, DENY
//echo("DEFAULT: DENY.");
//Default, DENY
//echo("DEFAULT: DENY.");
return false;
}
@ -183,9 +183,9 @@ class INI_ACL extends AclBase
$element = trim($element);
}
//Adding this element keeps array_search from returning 0:
//0 is the first key, which may be correct, but 0 is interpreted as false.
//Adding this element makes all the keys be positive integers.
//Adding this element keeps array_search from returning 0:
//0 is the first key, which may be correct, but 0 is interpreted as false.
//Adding this element makes all the keys be positive integers.
array_unshift($array, "");
return $array;
}

View file

@ -73,7 +73,7 @@ class RequestHandlerComponent extends Object
{
$controller->layout = $this->ajaxLayout;
// Add UTF-8 header for IE6 on XPsp2 bug
// Add UTF-8 header for IE6 on XPsp2 bug
header('Content-Type: text/html; charset=UTF-8');
}
}

View file

@ -518,7 +518,7 @@ class Controller extends Object
* @param string $url Relative URL to redirect to after the time expires
* @param int $time Time to show the message
*/
function flash($message, $url, $pause=1)
function flash($message, $url, $pause = 1)
{
$this->autoRender = false;
$this->autoLayout = false;
@ -532,14 +532,11 @@ class Controller extends Object
{
$flash = VIEWS.'layouts'.DS.'flash.thtml';
}
else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml'))
elseif($flash = fileExistsInPath(LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml'))
{
$flash = LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml';
}
$this->render(null,false,$flash);
$this->render(null, false, $flash);
}
/**
@ -563,7 +560,7 @@ class Controller extends Object
$this->set('message', $message);
$this->set('time', $time);
$this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
$this->render(null, false, VIEWS.'layouts'.DS.'flash.thtml');
}
/**

View file

@ -91,7 +91,7 @@ class Flay extends Object
$text = $text? $text: $this->text;
// trim whitespace and disable all HTML
// trim whitespace and disable all HTML
if ($allowHtml)
{
$text = trim($text);
@ -103,17 +103,17 @@ class Flay extends Object
if (!$bare)
{
// multi-paragraph functions
// multi-paragraph functions
$text = preg_replace('#(?:[\n]{0,2})"""(.*)"""(?:[\n]{0,2})#s', "\n\n%BLOCKQUOTE%\n\n\\1\n\n%ENDBLOCKQUOTE%\n\n", $text);
$text = preg_replace('#(?:[\n]{0,2})===(.*)===(?:[\n]{0,2})#s', "\n\n%CENTER%\n\n\\1\n\n%ENDCENTER%\n\n", $text);
}
// pre-parse newlines
// pre-parse newlines
$text = preg_replace("#\r\n#", "\n", $text);
$text = preg_replace("#[\n]{2,}#", "%PARAGRAPH%", $text);
$text = preg_replace('#[\n]{1}#', "%LINEBREAK%", $text);
// split into paragraphs and parse
// split into paragraphs and parse
$out = '';
foreach (split('%PARAGRAPH%', $text) as $line)
{
@ -123,7 +123,7 @@ class Flay extends Object
if (!$bare)
{
// pre-parse links
// pre-parse links
$links = array();
$regs = null;
if (preg_match_all('#\[([^\[]{4,})\]#', $line, $regs))
@ -135,21 +135,21 @@ class Flay extends Object
}
}
// MAIN TEXT FUNCTIONS
// bold
// MAIN TEXT FUNCTIONS
// bold
$line = ereg_replace("\*([^\*]*)\*", "<strong>\\1</strong>", $line);
// italic
// italic
$line = ereg_replace("_([^_]*)_", "<em>\\1</em>", $line);
}
// entities
// entities
$line = str_replace(' - ', ' &ndash; ', $line);
$line = str_replace(' -- ', ' &mdash; ', $line);
$line = str_replace('(C)', '&copy;', $line);
$line = str_replace('(R)', '&reg;', $line);
$line = str_replace('(TM)', '&trade;', $line);
// guess e-mails
// guess e-mails
$emails = null;
if (preg_match_all("#([_A-Za-z0-9+-+]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#", $line, $emails))
{
@ -161,7 +161,7 @@ class Flay extends Object
if (!$bare)
{
// guess links
// guess links
$urls = null;
if (preg_match_all("#((?:http|https|ftp|nntp)://[^ ]+)#", $line, $urls))
{
@ -178,7 +178,7 @@ class Flay extends Object
}
}
// re-parse links
// re-parse links
if (count($links))
{
for ($ii=0; $ii<count($links); $ii++)
@ -227,14 +227,14 @@ class Flay extends Object
}
}
// re-parse newlines
// re-parse newlines
$out .= str_replace('%LINEBREAK%', "<br />\n", "<p>{$line}</p>\n");
}
}
if (!$bare)
{
// re-parse multilines
// re-parse multilines
$out = str_replace('<p>%BLOCKQUOTE%</p>', "<blockquote>", $out);
$out = str_replace('<p>%ENDBLOCKQUOTE%</p>', "</blockquote>", $out);
$out = str_replace('<p>%CENTER%</p>', "<center>", $out);

View file

@ -344,20 +344,20 @@ class Folder extends Object {
*/
function mkdirr($pathname, $mode = null)
{
// Check if directory already exists
// Check if directory already exists
if (is_dir($pathname) || empty($pathname))
{
return true;
}
// Ensure a file does not already exist with the same name
// Ensure a file does not already exist with the same name
if (is_file($pathname))
{
trigger_error('mkdirr() File exists', E_USER_WARNING);
return false;
}
// Crawl up the directory tree
// Crawl up the directory tree
$next_pathname = substr($pathname, 0, strrpos($pathname, DIRECTORY_SEPARATOR));
if ($this->mkdirr($next_pathname, $mode))
{
@ -378,39 +378,39 @@ class Folder extends Object {
*/
function dirsize()
{
// Init
// Init
$size = 0;
$directory = Folder::slashTerm($this->path);
// Creating the stack array
// Creating the stack array
$stack = array($directory);
// Iterate stack
// Iterate stack
for ($i = 0, $j = count($stack); $i < $j; ++$i)
{
// Add to total size
// Add to total size
if (is_file($stack[$i]))
{
$size += filesize($stack[$i]);
}
// Add to stack
// Add to stack
elseif (is_dir($stack[$i]))
{
// Read directory
// Read directory
$dir = dir($stack[$i]);
while (false !== ($entry = $dir->read()))
{
// No pointers
// No pointers
if ($entry == '.' || $entry == '..')
{
continue;
}
// Add to stack
// Add to stack
$add = $stack[$i] . $entry;
if (is_dir($stack[$i] . $entry))
{
@ -420,11 +420,11 @@ class Folder extends Object {
}
// Clean up
// Clean up
$dir->close();
}
// Recount stack
// Recount stack
$j = count($stack);
}

View file

@ -412,14 +412,14 @@ class DataSource extends Object
*/
function insertQueryData($query, $data, $association, $assocData, &$model, &$linkModel, $index)
{
$keys = array('{$__cake_id__$}', '{$__cake_foreignKey__$}');
$keys = array('{$__cakeID__$}', '{$__cakeForeignKey__$}');
foreach($keys as $key)
{
if (strpos($query, $key) !== false)
{
switch($key)
{
case '{$__cake_id__$}':
case '{$__cakeID__$}':
$val = null;
if (isset($data[$index][$model->name]))
{

View file

@ -286,8 +286,8 @@ class DboSource extends DataSource
if ($this->error)
{
return false; // shouldn't we be logging errors somehow?
// TODO: Add hook to error log
return false;// shouldn't we be logging errors somehow?
// TODO: Add hook to error log
}
}
@ -403,7 +403,7 @@ class DboSource extends DataSource
}
}
// Build final query SQL
// Build final query SQL
$query = $this->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null);
$resultSet = $this->fetchAll($query);
@ -421,7 +421,7 @@ class DboSource extends DataSource
// Fetch recursively on belongsTo and hasOne
if ($model->recursive > 1)
{
//$this->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive - 1);
//$this->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive - 1);
}
}
}
@ -606,7 +606,7 @@ class DboSource extends DataSource
{
$joinFields = null;
}
// Generates primary query
// Generates primary query
$sql = 'SELECT ' . join(', ', $this->fields($model, $model->name, $queryData['fields'])) .$joinFields. ' FROM ';
$sql .= $this->name($model->table).' AS ';
$sql .= $this->name($model->name).' ' . join(' ', $queryData['joins']).' ';
@ -639,7 +639,7 @@ class DboSource extends DataSource
$sql .= ' FROM '.$this->name($linkModel->table).' AS '.$alias;
$conditions = $queryData['conditions'];
$condition = $model->escapeField($assocData['foreignKey']);
$condition .= '={$__cake_foreignKey__$}';
$condition .= '={$__cakeForeignKey__$}';
if (is_array($conditions))
{
$conditions[] = $condition;
@ -702,7 +702,7 @@ class DboSource extends DataSource
$conditions = $assocData['conditions'];
$condition = $linkModel->escapeField($linkModel->primaryKey);
$condition .= '={$__cake_id__$}';
$condition .= '={$__cakeID__$}';
if (is_array($conditions))
{
@ -775,12 +775,12 @@ class DboSource extends DataSource
if (is_array($conditions))
{
$conditions[$alias.'.'.$assocData['foreignKey']] = '{$__cake_id__$}';
$conditions[$alias.'.'.$assocData['foreignKey']] = '{$__cakeID__$}';
}
else
{
$cond = $this->name($alias).'.'.$this->name($assocData['foreignKey']);
$cond .= '={$__cake_id__$}';
$cond .= '={$__cakeID__$}';
if (trim($conditions) != '')
{
@ -805,7 +805,7 @@ class DboSource extends DataSource
$sql = 'SELECT '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
$sql .= ' FROM '.$this->name($linkModel->table).' AS '.$this->name($alias);
$sql .= ' JOIN '.$joinTbl.' ON '.$joinTbl;
$sql .= '.'.$this->name($assocData['foreignKey']).'={$__cake_id__$}';
$sql .= '.'.$this->name($assocData['foreignKey']).'={$__cakeID__$}';
$sql .= ' AND '.$joinTbl.'.'.$this->name($assocData['associationForeignKey']);
$sql .= ' = '.$this->name($alias).'.'.$this->name($linkModel->primaryKey);
@ -971,7 +971,13 @@ class DboSource extends DataSource
}
$count = count($fields);
if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false)
if ($count >= 1 && $fields[0] != '*'
&& strpos($fields[0], 'COUNT(') === false
&& strpos($fields[0], 'MAX(') === false
&& strpos($fields[0], 'MIN(') === false
&& strpos($fields[0], 'DISTINCT') === false
&& strpos($fields[0], 'SUM(') === false
&& strpos($fields[0], 'CONCAT(') === false)
{
for ($i = 0; $i < $count; $i++)
{
@ -1010,6 +1016,16 @@ class DboSource extends DataSource
{
$conditions = ' 1 = 1';
}
else
{
preg_match_all('/([a-zA-Z0-9_]{1,})\\.([a-zA-Z0-9_]{1,})/', $conditions, $result, PREG_PATTERN_ORDER);
$pregCount = count($result[0]);
for ($i = 0; $i < $pregCount; $i++)
{
$conditions = preg_replace('/'.$result[0][$i].'/', $this->name($result[0][$i]), $conditions);
}
}
return $rt.$conditions;
}
elseif (is_array($conditions))
@ -1032,7 +1048,7 @@ class DboSource extends DataSource
}
else
{
if (($value != '{$__cake_id__$}') && ($value != '{$__cake_foreignKey__$}'))
if (($value != '{$__cakeID__$}') && ($value != '{$__cakeForeignKey__$}'))
{
$value = $this->value($value);
}

View file

@ -86,7 +86,7 @@ class DboAdodb extends DboSource
if(!$this->connected)
{
//die('Could not connect to DB.');
//die('Could not connect to DB.');
}
}
@ -275,8 +275,8 @@ class DboAdodb extends DboSource
function selectLimit ($limit, $offset=null)
{
return " LIMIT {$limit}".($offset? "{$offset}": null);
// please change to whatever select your database accepts
// adodb doesn't allow us to get the correct limit string out of it
// please change to whatever select your database accepts
// adodb doesn't allow us to get the correct limit string out of it
}
}

View file

@ -44,22 +44,22 @@ uses('object');
* Example usage:
*
* <code>
* require('dbo_mysql.php'); // or 'dbo_postgres.php'
* require('dbo_mysql.php');// or 'dbo_postgres.php'
*
* // create and connect the object
* $db = new DBO_MySQL(array( // or 'DBO_Postgres'
*// create and connect the object
* $db = new DBO_MySQL(array(// or 'DBO_Postgres'
* 'host'=>'localhost',
* 'login'=>'username',
* 'password'=>'password',
* 'database'=>'database'));
*
* // read the whole query result array (of rows)
*// read the whole query result array (of rows)
* $all_rows = $db->fetchAll("SELECT a,b,c FROM table");
*
* // read the first row with debugging on
*// read the first row with debugging on
* $first_row_only = $db->one("SELECT a,b,c FROM table WHERE a=1", TRUE);
*
* // emulate the usual way of reading query results
*// emulate the usual way of reading query results
* if ($db->query("SELECT a,b,c FROM table"))
* {
* while ($row = $db->fetchArray())
@ -68,7 +68,7 @@ uses('object');
* }
* }
*
* // show a log of all queries, sorted by execution time
*// show a log of all queries, sorted by execution time
* $db->showLog(TRUE);
* </code>
*
@ -438,7 +438,7 @@ class DBO extends Object
}
if ($this->error)
return false; // shouldn't we be logging errors somehow?
return false;// shouldn't we be logging errors somehow?
}
/**

View file

@ -115,7 +115,7 @@ class DboMysql extends DboSource
}
else
{
//die('Could not connect to DB.');
//die('Could not connect to DB.');
}
}
@ -257,7 +257,12 @@ class DboMysql extends DboSource
{
return '*';
}
return '`'. ereg_replace('\.', '`.`', $data) .'`';
$pos = strpos($data, '`');
if ($pos === false)
{
$data = '`'. str_replace('.', '`.`', $data) .'`';
}
return $data;
}
/**

View file

@ -140,8 +140,16 @@ class DboPostgres extends DboSource
*/
function fetchRow ($assoc = false)
{
$assoc = ($assoc === false) ? PGSQL_BOTH : PGSQL_ASSOC;
return pg_fetch_array($this->_result, null, $assoc);
if(is_resource($this->_result))
{
$this->resultSet($this->_result);
$resultRow = $this->fetchResult();
return $resultRow;
}
else
{
return null;
}
}
/**
@ -164,33 +172,72 @@ class DboPostgres extends DboSource
$tables = array();
foreach ($result as $item)
{
$tables[] = $item['name'];
$tables[] = $item[0]['name'];
}
return $tables;
}
}
/**
* Returns an array of the fields in given table name.
* Generates the fields list of an SQL query.
*
* @param string $tableName Name of database table to inspect
* @return array Fields in table. Keys are name and type
* @param Model $model
* @param string $alias Alias tablename
* @param mixed $fields
* @return array
*/
function fields ($tableName)
function fields (&$model, $alias, $fields)
{
$sql = "SELECT c.relname, a.attname, t.typname FROM pg_class c, pg_attribute a, pg_type t WHERE c.relname = '{$tableName}' AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid";
if (is_array($fields))
{
$fields = $fields;
}
else
{
if ($fields != null)
{
if (strpos($fields, ','))
{
$fields = explode(',', $fields);
}
else
{
$fields = array($fields);
}
$fields = array_map('trim', $fields);
}
else
{
foreach ($model->_tableInfo->value as $field)
{
$fields[]= $field[0]['name'];
}
$fields = false;
foreach ($this->all($sql) as $field) {
$fields[] = array(
'name' => $field['attname'],
'type' => $field['typname']);
}
}
$count = count($fields);
if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false)
{
for ($i = 0; $i < $count; $i++)
{
$dot = strrpos($fields[$i], '.');
if ($dot === false)
{
$fields[$i] = $this->name($alias).'.'.$this->name($fields[$i]) . ' AS ' . $this->name($alias . '__' . $fields[$i]);
}
else
{
$build = explode('.',$fields[$i]);
$fields[$i] = $this->name($build[0]).'.'.$this->name($build[1]) . ' AS ' . $this->name($build[0] . '__' . $build[1]);
}
}
}
return $fields;
}
/**
/**
* Returns an array of the fields in given table name.
*
* @param string $tableName Name of database table to inspect
@ -206,7 +253,7 @@ class DboPostgres extends DboSource
$fields = false;
$fields = $this->query("SELECT column_name as name, data_type as type FROM information_schema.columns WHERE table_name =".$this->name($model->table));
$fields = $this->query("SELECT column_name as name, data_type as type FROM information_schema.columns WHERE table_name =".$this->value($model->table));
$this->__cacheDescription($model->table, $fields);
return $fields;
@ -220,18 +267,41 @@ class DboPostgres extends DboSource
*/
function name ($data)
{
return "'". $data."'";
if ($data == '*')
{
return '*';
}
return '"'. ereg_replace('\.', '"."', $data) .'"';
}
/**
* Returns a quoted and escaped string of $data for use in an SQL statement.
*
* @param string $data String to be prepared for use in an SQL statement
* @param string $column The column into which this data will be inserted
* @return string Quoted and escaped
* @todo Add logic that formats/escapes data based on column type
*/
function value ($data)
function value ($data, $column = null)
{
return "'".pg_escape_string($data)."'";
$parent = parent::value($data, $column);
if ($parent != null)
{
return $parent;
}
if ($data === null)
{
return 'NULL';
}
if (ini_get('magic_quotes_gpc') == 1)
{
$data = stripslashes($data);
}
$data = pg_escape_string($data);
$return = "'" . $data . "'";
return $return;
}
/**
@ -302,14 +372,72 @@ class DboPostgres extends DboSource
*/
function limit ($limit, $offset = null)
{
$rt = ' LIMIT ' . $limit;
if ($limit)
{
$rt = '';
if (!strpos(low($limit), 'limit') || strpos(low($limit), 'limit') === 0)
{
$rt = ' LIMIT';
}
if ($offset)
{
$rt .= ' OFFSET ' . $offset;
$rt .= ' ' . $offset. ',';
}
$rt .= ' ' . $limit;
return $rt;
}
return null;
}
function resultSet(&$results)
{
$this->results =& $results;
$this->map = array();
$num_fields = pg_num_fields($results);
$index = 0;
$j = 0;
while ($j < $num_fields)
{
$columnName = pg_field_name($results, $j);
if (strpos($columnName, '__'))
{
$parts = explode('__', $columnName);
$this->map[$index++] = array($parts[0], $parts[1]);
}
else
{
$this->map[$index++] = array(0, $columnName);
}
$j++;
}
}
/**
* Fetches the next row from the current result set
*
* @return unknown
*/
function fetchResult()
{
if ($row = pg_fetch_row($this->results))
{
$resultRow = array();
$i =0;
foreach ($row as $index => $field)
{
list($table, $column) = $this->map[$index];
$resultRow[$table][$column] = $row[$index];
$i++;
}
return $resultRow;
}
else
{
return false;
}
}
}
?>

View file

@ -66,7 +66,7 @@ class DBO_SQLite extends DBO
}
else
{
//die('Could not connect to DB.');
//die('Could not connect to DB.');
}
}

View file

@ -389,7 +389,7 @@ class Model extends Object
*/
function __createLinks()
{
// Convert all string-based associations to array based
// Convert all string-based associations to array based
foreach($this->__associations as $type)
{
if(!is_array($this->{$type}))
@ -964,10 +964,10 @@ class Model extends Object
{
if ($this->id && $this->db->delete($this))
{
//$this->__deleteJoins($id);
//$this->__deleteJoins($id);
if ($cascade)
{
//$this->__deleteMulti($id);
//$this->__deleteMulti($id);
}
$this->afterDelete();
$this->id = false;
@ -1425,7 +1425,7 @@ class Model extends Object
*/
function getNumRows ()
{
//return $this->__numRows;
//return $this->__numRows;
return $this->db->lastNumRows();
}
@ -1436,7 +1436,7 @@ class Model extends Object
*/
function getAffectedRows ()
{
//return $this->__affectedRows;
//return $this->__affectedRows;
return $this->db->lastAffected();
}

View file

@ -385,7 +385,7 @@ class Model extends Object
*/
function __createLinks()
{
// Convert all string-based associations to array based
// Convert all string-based associations to array based
foreach($this->__associations as $type)
{
if(!is_array($this->{$type}))
@ -960,10 +960,10 @@ class Model extends Object
{
if ($this->id && $this->db->delete($this))
{
//$this->__deleteJoins($id);
//$this->__deleteJoins($id);
if ($cascade)
{
//$this->__deleteMulti($id);
//$this->__deleteMulti($id);
}
$this->afterDelete();
$this->id = false;
@ -1421,7 +1421,7 @@ class Model extends Object
*/
function getNumRows ()
{
//return $this->__numRows;
//return $this->__numRows;
return $this->db->lastNumRows();
}
@ -1432,7 +1432,7 @@ class Model extends Object
*/
function getAffectedRows ()
{
//return $this->__affectedRows;
//return $this->__affectedRows;
return $this->db->lastAffected();
}

View file

@ -40,7 +40,7 @@
*/
class NeatString
{
/**
/**
* Returns an array with each of the non-empty characters in $string as an element.
*
* @param string $string
@ -51,7 +51,7 @@ class NeatString
return preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
}
/**
/**
* Returns string with Cyrillic characters translated to Roman ones.
*
* @param string $string
@ -65,7 +65,7 @@ class NeatString
return str_replace($pl, $ro, $string);
}
/**
/**
* Returns string as lowercase with whitespace removed.
*
* @param string $string
@ -77,7 +77,7 @@ class NeatString
return strtolower(str_replace($whitespace, '', $string));
}
/**
/**
* Returns a random password.
*
* @param integer $length Length of generated password

View file

@ -114,8 +114,8 @@ class Router extends Object {
*/
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.
// An URL should start with a '/', mod_rewrite doesn't respect that, but no-mod_rewrite version does.
// Here's the fix.
if ($url && ('/' != $url[0]))
{
$url = '/'.$url;
@ -167,11 +167,11 @@ class Router extends Object {
if (preg_match($regexp, $url, $r))
{
// $this->log($url.' matched '.$regexp, 'note');
// remove the first element, which is the url
// $this->log($url.' matched '.$regexp, 'note');
// remove the first element, which is the url
array_shift($r);
// hack, pre-fill the default route names
// hack, pre-fill the default route names
foreach ($names as $name)
$out[$name] = null;
@ -194,12 +194,12 @@ class Router extends Object {
foreach ($r as $found)
{
// if $found is a named url element (i.e. ':action')
// if $found is a named url element (i.e. ':action')
if (isset($names[$ii]))
{
$out[$names[$ii]] = $found;
}
// unnamed elements go in as 'pass'
// unnamed elements go in as 'pass'
else
{
$pass = new NeatArray(explode('/', $found));

View file

@ -91,7 +91,7 @@ class Sanitize
}
/**
* Returns given string safe for display as HTML. Renders entities and converts newlines to <br/>.
* Returns given string safe for display as HTML. Renders entities and converts newlines to <br />.
*
* @param string $string
* @param boolean $remove If true, the string is stripped of all HTML tags
@ -106,7 +106,7 @@ class Sanitize
else
{
$patterns = array("/\&/", "/%/", "/</", "/>/", '/"/', "/'/", "/\(/", "/\)/", "/\+/", "/-/", "/\n/");
$replacements = array("&amp;", "&#37;", "&lt;", "&gt;", "&quot;", "&#39;", "&#40;", "&#41;", "&#43;", "&#45;", "<br/>");
$replacements = array("&amp;", "&#37;", "&lt;", "&gt;", "&quot;", "&#39;", "&#40;", "&#41;", "&#43;", "&#45;", "<br />");
$string = preg_replace($patterns, $replacements, $string);
}
@ -163,13 +163,13 @@ class Sanitize
return "";
}
//URL decode and convert chars to HTML entities
//URL decode and convert chars to HTML entities
$key = htmlspecialchars(urldecode($key));
//Remove ..
//Remove ..
$key = preg_replace( "/\.\./", "", $key );
//Remove __FILE__, etc.
//Remove __FILE__, etc.
$key = preg_replace( "/\_\_(.+?)\_\_/", "", $key );
//Trim word chars, '.', '-', '_'
//Trim word chars, '.', '-', '_'
$key = preg_replace( "/^([\w\.\-\_]+)$/", "$1", $key );
return $key;
@ -189,27 +189,27 @@ class Sanitize
return "";
}
//Replace odd spaces with safe ones
//Replace odd spaces with safe ones
$val = str_replace(" ", " ", $val);
$val = str_replace(chr(0xCA), "", $val);
//Encode any HTML to entities (including \n --> <br/>)
//Encode any HTML to entities (including \n --> <br />)
$val = $this->html($val);
//Double-check special chars and remove carriage returns
//For increased SQL security
//Double-check special chars and remove carriage returns
//For increased SQL security
$val = preg_replace( "/\\\$/" ,"$" ,$val);
$val = preg_replace( "/\r/" ,"" ,$val);
$val = str_replace ( "!" ,"!" ,$val);
$val = str_replace ( "'" , "'" ,$val);
//Allow unicode (?)
//Allow unicode (?)
$val = preg_replace("/&amp;#([0-9]+);/s", "&#\\1;", $val );
//Add slashes for SQL
//Add slashes for SQL
$val = $this->sql($val);
//Swap user-inputted backslashes (?)
//Swap user-inputted backslashes (?)
$val = preg_replace( "/\\\(?!&amp;#|\?#)/", "\\", $val );
return $val;

View file

@ -116,7 +116,7 @@ class Security extends Object
{
if (!defined('CIPHER_SEED'))
{
//This is temporary will change later
//This is temporary will change later
define('CIPHER_SEED', 'mKEZGy8AB8FErX4t');
}
srand(CIPHER_SEED);

View file

@ -40,16 +40,16 @@
*/
class Helper extends Object
{
/*************************************************************************
/*************************************************************************
* Public variables
*************************************************************************/
/**#@+
/**#@+
* @access public
*/
/**
/**
* Holds tag templates.
*
* @access public
@ -57,17 +57,17 @@ class Helper extends Object
*/
var $tags = array();
/**#@-*/
/**#@-*/
/*************************************************************************
/*************************************************************************
* Public methods
*************************************************************************/
/**#@+
/**#@+
* @access public
*/
/**
/**
* Constructor.
*
* Parses tag templates into $this->tags.
@ -83,7 +83,7 @@ class Helper extends Object
return $this->readConfigFile($config = fileExistsInPath(CAKE.'config'.DS.'tags.ini.php'));
}
/**
/**
* Decides whether to output or return a string.
*
* Based on AUTO_OUTPUT and $return's value, this method decides whether to
@ -114,7 +114,7 @@ class Helper extends Object
}
}
/**
/**
* Assigns values to tag templates.
*
* Finds a tag template by $keyName, and replaces $values's keys with
@ -148,9 +148,9 @@ class Helper extends Object
{
if ($firstChar == '[' && substr($dataLine, -1, 1) == ']')
{
// [section block] we might use this later do not know for sure
// this could be used to add a key with the section block name
// but it adds another array level
// [section block] we might use this later do not know for sure
// this could be used to add a key with the section block name
// but it adds another array level
}
else
{
@ -178,7 +178,7 @@ class Helper extends Object
return $iniSetting;
}
/**#@-*/
/**#@-*/
}
?>

View file

@ -200,7 +200,7 @@ class AjaxHelper extends Helper
function linkToRemote ($title, $options = array(), $html_options = array())
{
//trigger_error('Deprecated function: use AjaxHelper::link', E_USER_WARNING);
//trigger_error('Deprecated function: use AjaxHelper::link', E_USER_WARNING);
$href = '#';
if (!empty($options['fallback']) && isset($options['fallback']))
{

View file

@ -63,7 +63,7 @@ class FormHelper extends Helper
{
var $helpers = array('Html');
/**
/**
* Constructor which takes an instance of the HtmlHelper class.
*
* @return void
@ -72,7 +72,7 @@ class FormHelper extends Helper
{
}
/**
/**
* Returns a formatted error message for given FORM field, NULL if no errors.
*
* @param string $field This should be "Modelname/fieldname"
@ -92,7 +92,7 @@ class FormHelper extends Helper
}
}
/**
/**
* Returns a formatted LABEL element for HTML FORMs.
*
* @param string $tagName This should be "Modelname/fieldname"
@ -104,7 +104,7 @@ class FormHelper extends Helper
return sprintf( TAG_LABEL, strtolower(str_replace('/', '_',$tagName)), $text );
}
/**
/**
* Returns a formatted DIV tag for HTML FORMs.
*
* @param string $class CSS class name of the div element.
@ -116,7 +116,7 @@ class FormHelper extends Helper
return sprintf( TAG_DIV, $class, $text );
}
/**
/**
* Returns a formatted P tag with class for HTML FORMs.
*
* @param string $class CSS class name of the p element.
@ -128,7 +128,7 @@ class FormHelper extends Helper
return sprintf( TAG_P_CLASS, $class, $text );
}
/**
/**
* Returns a formatted INPUT tag for HTML FORMs.
*
* @param string $tagName This should be "Modelname/fieldname"
@ -152,11 +152,11 @@ class FormHelper extends Helper
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
$strError = "";// initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
@ -166,7 +166,7 @@ class FormHelper extends Helper
}
/**
/**
* Returns a formatted CHECKBOX tag inside a DIV for HTML FORMs.
*
* @param string $tagName This should be "Modelname/fieldname"
@ -188,11 +188,11 @@ class FormHelper extends Helper
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
$strError = "";// initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
@ -202,7 +202,7 @@ class FormHelper extends Helper
}
/**
/**
* Returns a formatted date option element for HTML FORMs.
*
* @param string $tagName This should be "Modelname/fieldname"
@ -225,11 +225,11 @@ class FormHelper extends Helper
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
$strError = "";// initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
@ -240,7 +240,7 @@ class FormHelper extends Helper
return $this->divTag("date", $requiredDiv);
}
/**
/**
* Returns a formatted datetime option element for HTML FORMs.
*
* @param string $tagName This should be "Modelname/fieldname"
@ -264,11 +264,11 @@ class FormHelper extends Helper
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
$strError = "";// initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
@ -279,7 +279,7 @@ class FormHelper extends Helper
return $this->divTag("date", $requiredDiv);
}
/**
/**
* Returns a formatted TEXTAREA inside a DIV for use with HTML forms.
*
* @param string $tagName This should be "Modelname/fieldname"
@ -305,11 +305,11 @@ class FormHelper extends Helper
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
$strError = "";// initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
@ -319,7 +319,7 @@ class FormHelper extends Helper
}
/**
/**
* Returns a formatted SELECT tag for HTML FORMs.
*
* @param string $tagName This should be "Modelname/fieldname"
@ -343,11 +343,11 @@ class FormHelper extends Helper
if( $required )
$divClass = "required";
$strError = ""; // initialize the error to empty.
$strError = "";// initialize the error to empty.
if( $this->isFieldError( $tagName ) )
{
// if it was an error that occured, then add the error message, and append " error" to the div tag.
// if it was an error that occured, then add the error message, and append " error" to the div tag.
$strError = $this->pTag( 'error', $errorMsg );
$divClass = sprintf( "%s error", $divClass );
}
@ -357,7 +357,7 @@ class FormHelper extends Helper
}
/**
/**
* Returns a formatted submit widget for HTML FORMs.
*
* @param string $displayText Text that will appear on the widget
@ -369,7 +369,7 @@ class FormHelper extends Helper
return $this->divTag( 'submit', $this->Html->submitTag( $displayText, $htmlOptions) );
}
/**
/**
* Generates a form to go onto a HtmlHelper object.
*
* @param array $fields An array of form field definitions

View file

@ -37,69 +37,69 @@
*/
class HtmlHelper extends Helper
{
/*************************************************************************
/*************************************************************************
* Public variables
*************************************************************************/
/**#@+
/**#@+
* @access public
*/
/**
/**
* Base URL
*
* @var string
*/
var $base = null;
/**
/**
* URL to current action.
*
* @var string
*/
var $here = null;
/**
/**
* Parameter array.
*
* @var array
*/
var $params = array();
/**
/**
* Current action.
*
* @var string
*/
var $action = null;
/**
/**
* Enter description here...
*
* @var array
*/
var $data = null;
/**
/**
* Name of model this helper is attached to.
*
* @var string
*/
var $model = null;
/**
/**
* Enter description here...
*
* @var string
*/
var $field = null;
/**#@-*/
/**#@-*/
/*************************************************************************
/*************************************************************************
* Private variables
*************************************************************************/
/**#@+
/**#@+
* @access private
*/
/**
/**
* Breadcrumbs.
*
* @var array
@ -109,7 +109,7 @@ class HtmlHelper extends Helper
/**
/**
* Adds a link to the breadcrumbs array.
*
* @param string $name Text for link
@ -120,7 +120,7 @@ class HtmlHelper extends Helper
$this->_crumbs[] = array($name, $link);
}
/**
/**
* Returns a charset META-tag.
*
* @param string $charset
@ -134,7 +134,7 @@ class HtmlHelper extends Helper
return $this->output(sprintf($this->tags['charset'], $charset), $return);
}
/**
/**
* Finds URL for specified action.
*
* Returns an URL pointing to a combination of controller and action. Param
@ -167,7 +167,7 @@ class HtmlHelper extends Helper
return $this->output(preg_replace('/&([^a])/', '&amp;\1', $output), $return);
}
/**
/**
* Creates an HTML link.
*
* If $url starts with "http://" this is treated as an external link. Else,
@ -188,7 +188,7 @@ class HtmlHelper extends Helper
*/
function link($title, $url = null, $htmlAttributes = null, $confirmMessage = false, $escapeTitle = true, $return = false)
{
// prepare title for html display
// prepare title for html display
if( $escapeTitle )
{
$title = htmlspecialchars($title, ENT_QUOTES);
@ -198,11 +198,11 @@ class HtmlHelper extends Helper
if ($confirmMessage)
{
// prepare for HTML display (fix everything except quotes)
// prepare for HTML display (fix everything except quotes)
$confirmMessage = htmlspecialchars($confirmMessage, ENT_NOQUOTES);
// fix single quotes
// fix single quotes
$confirmMessage = str_replace("'", "\'", $confirmMessage);
// fix double quotes
// fix double quotes
$confirmMessage = str_replace('"', '&quot;', $confirmMessage);
$htmlAttributes['onclick'] = "return confirm('{$confirmMessage}');";
@ -222,7 +222,7 @@ class HtmlHelper extends Helper
return $this->output($output, $return);
}
/**
/**
* Creates a submit widget.
*
* @param string $caption Text on submit button
@ -241,7 +241,7 @@ class HtmlHelper extends Helper
/**
/**
* Creates a password input widget.
*
* @param string $fieldName Name of a field, like this "Modelname/fieldname"
@ -268,7 +268,7 @@ class HtmlHelper extends Helper
/**
/**
* Creates a textarea widget.
*
* @param string $fieldName Name of a field, like this "Modelname/fieldname"
@ -304,7 +304,7 @@ class HtmlHelper extends Helper
$this->_parseAttributes($htmlAttributes, null, ' '), $value), $return);
}
/**
/**
* Creates a checkbox widget.
*
* @param string $fieldName Name of a field, like this "Modelname/fieldname"
@ -326,7 +326,7 @@ class HtmlHelper extends Helper
$this->_parseAttributes($htmlAttributes, null, '', ' '), $title), $return);
}
/**
/**
* Creates a link element for CSS stylesheets.
*
* @param string $path Path to CSS file
@ -344,7 +344,7 @@ class HtmlHelper extends Helper
$this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return);
}
/**
/**
* Creates file input widget.
*
* @param string $fieldName Name of a field, like this "Modelname/fieldname" or just "thefile"
@ -360,7 +360,7 @@ class HtmlHelper extends Helper
$this->_parseAttributes($htmlAttributes, null, '', ' ')), $return);
}
/**
/**
* Returns the breadcrumb trail as a sequence of &raquo;-separated links.
*
* @param string $separator Text to separate crumbs.
@ -388,7 +388,7 @@ class HtmlHelper extends Helper
}
}
/**
/**
* Creates a hidden input field.
*
* @param string $fieldName Name of a field, like this "Modelname/fieldname"
@ -409,7 +409,7 @@ class HtmlHelper extends Helper
}
/**
/**
* Creates a formatted IMG element.
*
* @param string $path Path to the image file, relative to the webroot/img/ directory.
@ -433,7 +433,7 @@ class HtmlHelper extends Helper
return $this->output(sprintf($this->tags['image'], $url, $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return);
}
/**
/**
* Creates a text input widget.
*
* @param string $fieldName Name of a field, like this "Modelname/fieldname"
@ -478,7 +478,7 @@ class HtmlHelper extends Helper
$this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return);
}
/**
/**
* Creates a set of radio widgets.
*
* @param string $fieldName Name of a field, like this "Modelname/fieldname"
@ -490,19 +490,18 @@ class HtmlHelper extends Helper
* @return mixed Either string or boolean value, depends on AUTO_OUTPUT
* and $return.
*/
function radio($fieldName, $options, $inbetween = null, $htmlAttributes = null,
$return = false)
function radio($fieldName, $options, $inbetween = null, $htmlAttributes = array(), $return = false)
{
$this->setFormTag($fieldName);
$value = isset($htmlAttributes['value'])? $htmlAttributes['value']: $this->tagValue($fieldName);
$out = array();
foreach ($options as $opt_value=>$opt_title)
foreach ($options as $optValue => $optTitle)
{
$options_here = array('value' => $opt_value);
$opt_value==$value? $options_here['checked'] = 'checked': null;
$parsed_options = $this->parseHtmlOptions(array_merge($htmlAttributes, $options_here), null, '', ' ');
$individual_tag_name = "{$this->field}_{$opt_value}";
$out[] = sprintf($this->tags['radio'], $this->model, $this->field, $individual_tag_name, $parsed_options, $opt_title);
$optionsHere = array('value' => $optValue);
$optValue==$value? $optionsHere['checked'] = 'checked': null;
$parsedOptions = $this->parseHtmlOptions(array_merge($htmlAttributes, $optionsHere), null, '', ' ');
$individualTagName = "{$this->field}_{$optValue}";
$out[] = sprintf($this->tags['radio'], $this->model, $this->field, $individualTagName, $parsedOptions, $optTitle);
}
$out = join($inbetween, $out);
@ -510,34 +509,34 @@ class HtmlHelper extends Helper
}
/**
/**
* Returns a row of formatted and named TABLE headers.
*
* @param array $names Array of tablenames.
* @param array $tr_options HTML options for TR elements.
* @param array $th_options HTML options for TH elements.
* @param array $trOptions HTML options for TR elements.
* @param array $thOptions HTML options for TH elements.
* @return string
*/
function tableHeaders($names, $tr_options=null, $th_options=null)
function tableHeaders($names, $trOptions=null, $thOptions=null)
{
$out = array();
foreach ($names as $arg)
{
$out[] = sprintf($this->tags['tableheader'], $this->parseHtmlOptions($th_options), $arg);
$out[] = sprintf($this->tags['tableheader'], $this->parseHtmlOptions($thOptions), $arg);
}
return sprintf($this->tags['tablerow'], $this->parseHtmlOptions($tr_options), join(' ', $out));
return sprintf($this->tags['tablerow'], $this->parseHtmlOptions($trOptions), join(' ', $out));
}
/**
/**
* Returns a formatted string of table rows (TR's with TD's in them).
*
* @param array $data Array of table data
* @param array $odd_tr_options HTML options for odd TR elements
* @param array $even_tr_options HTML options for even TR elements
* @param array $oddTrOptions HTML options for odd TR elements
* @param array $evenTrOptions HTML options for even TR elements
* @return string Formatted HTML
*/
function tableCells($data, $odd_tr_options=null, $even_tr_options=null)
function tableCells($data, $oddTrOptions=null, $evenTrOptions=null)
{
if (empty($data[0]) || !is_array($data[0]))
{
@ -548,21 +547,21 @@ class HtmlHelper extends Helper
foreach ($data as $line)
{
$count++;
$cells_out = array();
$cellsOut = array();
foreach ($line as $cell)
{
$cells_out[] = sprintf($this->tags['tablecell'], null, $cell);
$cellsOut[] = sprintf($this->tags['tablecell'], null, $cell);
}
$options = $this->parseHtmlOptions($count%2? $odd_tr_options: $even_tr_options);
$out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cells_out));
$options = $this->parseHtmlOptions($count%2? $oddTrOptions: $evenTrOptions);
$out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cellsOut));
}
return join("\n", $out);
}
/**
/**
* Returns value of $fieldName. False if the tag does not exist.
*
* @param string $fieldName Fieldname as "Modelname/fieldname" string
@ -574,7 +573,7 @@ class HtmlHelper extends Helper
return isset($this->params['data'][$this->model][$this->field])? htmlspecialchars($this->params['data'][$this->model][$this->field]): false;
}
/**
/**
* Returns false if given FORM field has no errors. Otherwise it returns the constant set in the array Model->validationErrors.
*
* @param string $model Model name as string
@ -586,7 +585,7 @@ class HtmlHelper extends Helper
return empty($this->validationErrors[$model][$field])? 0: $this->validationErrors[$model][$field];
}
/**
/**
* Returns number of errors in a submitted FORM.
*
* @return int Number of errors
@ -599,7 +598,7 @@ class HtmlHelper extends Helper
return count($errors);
}
/**
/**
* Validates a FORM according to the rules set up in the Model.
*
* @return int Number of errors
@ -618,7 +617,7 @@ class HtmlHelper extends Helper
return $this->validationErrors = (count($errors)? $errors: false);
}
/**
/**
* Returns a formatted error message for given FORM field, NULL if no errors.
*
* @param string $field A field name, like "Modelname/fieldname"
@ -640,7 +639,7 @@ class HtmlHelper extends Helper
}
}
/**
/**
* Sets this helper's model and field properties to the slash-separated value-pair in $tagValue.
*
* @param string $tagValue A field name, like "Modelname/fieldname"
@ -650,17 +649,17 @@ class HtmlHelper extends Helper
return list($this->model, $this->field) = explode("/", $tagValue);
}
/**#@-*/
/**#@-*/
/*************************************************************************
/*************************************************************************
* Private methods
*************************************************************************/
/**#@+
/**#@+
* @access private
*/
/**
/**
* Returns a space-delimited string with items of the $options array. If a
* key of $options array happens to be one of:
* + 'compact'
@ -744,13 +743,13 @@ class HtmlHelper extends Helper
}
}
/**#@-*/
/**#@-*/
/*************************************************************************
/*************************************************************************
* Renamed methods
*************************************************************************/
/**
/**
* @deprecated Name changed to 'textarea'. Version 0.9.2.
* @see HtmlHelper::textarea()
* @param string $tagName
@ -769,7 +768,7 @@ class HtmlHelper extends Helper
return $this->textarea($tagName, $htmlAttributes, $return);
}
/**
/**
* @deprecated Name changed to 'charset'. Version 0.9.2.
* @see HtmlHelper::charset()
* @param string $charset
@ -783,7 +782,7 @@ class HtmlHelper extends Helper
return $this->charset($charset, $return);
}
/**
/**
* @deprecated Name changed to 'checkbox'. Version 0.9.2.
* @see HtmlHelper::checkbox()
* @param string $fieldName If field is to be used for CRUD, this
@ -800,7 +799,7 @@ class HtmlHelper extends Helper
return $this->checkbox($fieldName, $title, $htmlAttributes, $return);
}
/**
/**
* @deprecated Name changed to 'css'. Version 0.9.2.
* @see HtmlHelper::css()
* @param string $path Path to CSS file
@ -816,7 +815,7 @@ class HtmlHelper extends Helper
return $this->css($path, $rel , $htmlAttributes , $return );
}
/**
/**
* @deprecated Name changed to 'file'. Version 0.9.2.
* @see HtmlHelper::file()
* @param string $fieldName Name of a field, like this "Modelname/fieldname"
@ -831,7 +830,7 @@ class HtmlHelper extends Helper
return $this->file($fieldName, $htmlAttributes, $return);
}
/**
/**
* @deprecated Name changed to 'hidden'. Version 0.9.2.
* @see HtmlHelper::hidden()
* @param string $fieldName If field is to be used for CRUD, this
@ -843,18 +842,18 @@ class HtmlHelper extends Helper
* @return mixed Either string or boolean value, depends on AUTO_OUTPUT
* and $return.
*/
//function hiddenTag($fieldName, $value = null, $htmlAttributes = null, $return = false)
//{
// $htmlAttributes['value'] = $value;
// return $this->hidden($fieldName, $htmlAttributes, $return);
//}
//function hiddenTag($fieldName, $value = null, $htmlAttributes = null, $return = false)
//{
// $htmlAttributes['value'] = $value;
// return $this->hidden($fieldName, $htmlAttributes, $return);
//}
function hiddenTag($tagName, $value=null, $htmlOptions=null)
{
$this->setFormTag($tagName);
$htmlOptions['value'] = $value? $value: $this->tagValue($tagName);
return $this->output(sprintf($this->tags['hidden'], $this->model, $this->field, $this->parseHtmlOptions($htmlOptions, null, '', ' ')));
}
/**
/**
* @deprecated Name changed to 'image'. Version 0.9.2.
* @see HtmlHelper::image()
* @param string $path Path to the image file.
@ -871,7 +870,7 @@ class HtmlHelper extends Helper
return $this->image($path, $htmlAttributes, $return);
}
/**
/**
* @deprecated Name changed to 'input'. Version 0.9.2.
* @see HtmlHelper::input()
* @param string $fieldName If field is to be used for CRUD, this
@ -883,11 +882,11 @@ class HtmlHelper extends Helper
* @return mixed Either string or boolean value, depends on AUTO_OUTPUT
* and $return.
*/
//function inputTag($fieldName, $value = null, $htmlAttributes = null, $return = false)
//{
// $htmlAttributes['value'] = $value;
// return $this->input($fieldName, $htmlAttributes, $return);
//}
//function inputTag($fieldName, $value = null, $htmlAttributes = null, $return = false)
//{
// $htmlAttributes['value'] = $value;
// return $this->input($fieldName, $htmlAttributes, $return);
//}
function inputTag($tagName, $size=20, $htmlOptions=null)
{
@ -897,7 +896,7 @@ class HtmlHelper extends Helper
return $this->output(sprintf($this->tags['input'], $this->model, $this->field, $this->parseHtmlOptions($htmlOptions, null, '', ' ')));
}
/**
/**
* @deprecated Unified with 'link'. Version 0.9.2.
* @see HtmlHelper::link()
* @param string $title The content of the "a" tag.
@ -914,7 +913,7 @@ class HtmlHelper extends Helper
return $this->link($title, $url, $htmlAttributes, false, $escapeTitle, $return);
}
/**
/**
* @deprecated Unified with 'link'. Version 0.9.2.
* @see HtmlHelper::link()
* @param string $title The content of the "a" tag.
@ -932,7 +931,7 @@ class HtmlHelper extends Helper
return $this->link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle, $return);
}
/**
/**
* @deprecated Name changed to '_parseAttributes'. Version 0.9.2.
* @see HtmlHelper::_parseAttributes()
* @param array $options Array of options.
@ -941,12 +940,12 @@ class HtmlHelper extends Helper
* @param string $insertAfter String to be inserted ater options.
* @return string
*/
//function parseHtmlOptions($options, $exclude = null, $insertBefore = ' ', $insertAfter = null)
// {
// $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter);
// }
//function parseHtmlOptions($options, $exclude = null, $insertBefore = ' ', $insertAfter = null)
// {
// $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter);
// }
function parseHtmlOptions($options, $exclude=null, $insert_before=' ', $insert_after=null)
function parseHtmlOptions($options, $exclude=null, $insertBefore=' ', $insertAfter=null)
{
if (!is_array($exclude)) $exclude = array();
@ -961,15 +960,15 @@ class HtmlHelper extends Helper
}
}
$out = join(' ', $out);
return $out? $insert_before.$out.$insert_after: null;
return $out? $insertBefore.$out.$insertAfter: null;
}
else
{
return $options? $insert_before.$options.$insert_after: null;
return $options? $insertBefore.$options.$insertAfter: null;
}
}
/**
/**
* @deprecated Name changed to 'password'. Version 0.9.2.
* @see HtmlHelper::password()
* @param string $fieldName Name of a field, like this "Modelname/fieldname"
@ -985,7 +984,7 @@ class HtmlHelper extends Helper
return call_user_func_array(array(&$this, "password"), $args);
}
/**
/**
* @deprecated Name changed to 'radio'. Version 0.9.2.
* @see HtmlHelper::radio()
* @param string $fieldName Name of a field, like this "Modelname/fieldname"
@ -1003,33 +1002,33 @@ class HtmlHelper extends Helper
return $this->radio($fieldName, $options, $inbetween, $htmlAttributes, $return);
}
/**
/**
* Returns a SELECT element,
*
* @param string $fieldName Name attribute of the SELECT
* @param array $option_elements Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the SELECT element
* @param array $optionElements Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the SELECT element
* @param boolean $show_empty Show/hide the empty select option
* @param array $select_attr Array of HTML options for the opening SELECT element
* @param array $selectAttr Array of HTML options for the opening SELECT element
* @param array $optionAttr Array of HTML options for the enclosed OPTION elements
* @return string Formatted SELECT element
*/
function selectTag($fieldName, $option_elements, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty=true)
function selectTag($fieldName, $optionElements, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty=true)
{
$this->setFormTag($fieldName);
// do not display the select tag if no option elements are avaible
if (!is_array($option_elements) || count($option_elements) == 0)
// do not display the select tag if no option elements are avaible
if (!is_array($optionElements) || count($optionElements) == 0)
{
return null;
}
if( isset($select_attr) && array_key_exists( "multiple", $select_attr) )
if( isset($selectAttr) && array_key_exists( "multiple", $selectAttr) )
{
$select[] = sprintf($this->tags['selectmultiplestart'], $this->model, $this->field, $this->parseHtmlOptions($select_attr));
$select[] = sprintf($this->tags['selectmultiplestart'], $this->model, $this->field, $this->parseHtmlOptions($selectAttr));
}
else
{
$select[] = sprintf($this->tags['selectstart'], $this->model, $this->field, $this->parseHtmlOptions($select_attr));
$select[] = sprintf($this->tags['selectstart'], $this->model, $this->field, $this->parseHtmlOptions($selectAttr));
}
if($showEmpty == true)
@ -1037,17 +1036,17 @@ class HtmlHelper extends Helper
$select[] = sprintf($this->tags['selectempty'], $this->parseHtmlOptions($optionAttr));
}
foreach ($option_elements as $name=>$title)
foreach ($optionElements as $name => $title)
{
$options_here = $optionAttr;
$optionsHere = $optionAttr;
if (($selected !== null) && ($selected == $name))
{
$options_here['selected'] = 'selected';
$optionsHere['selected'] = 'selected';
} else if ( is_array($selected) && array_key_exists($name, $selected) )
{
$options_here['selected'] = 'selected';
$optionsHere['selected'] = 'selected';
}
$select[] = sprintf($this->tags['selectoption'], $name, $this->parseHtmlOptions($options_here), $title);
$select[] = sprintf($this->tags['selectoption'], $name, $this->parseHtmlOptions($optionsHere), $title);
}
$select[] = sprintf($this->tags['selectend']);
@ -1056,7 +1055,7 @@ class HtmlHelper extends Helper
}
/**
/**
* @deprecated Name changed to 'url'. Version 0.9.2.
* @see HtmlHelper::url()
*/
@ -1069,7 +1068,7 @@ class HtmlHelper extends Helper
/**
/**
* @deprecated Name changed to 'submit'. Version 0.9.2.
* @see HtmlHelper::submit()
*/
@ -1079,11 +1078,11 @@ class HtmlHelper extends Helper
return call_user_func_array(array(&$this, "submit"), $args);
}
/*************************************************************************
/*************************************************************************
* Moved methods
*************************************************************************/
/**
/**
* @deprecated Moved to TextHelper. Version 0.9.2.
*/
function trim()
@ -1091,7 +1090,7 @@ class HtmlHelper extends Helper
die("Method HtmlHelper::trim() was moved to TextHelper::trim().");
}
/**
/**
* @deprecated Moved to JavascriptHelper. Version 0.9.2.
*/
function javascriptIncludeTag($url)
@ -1099,7 +1098,7 @@ class HtmlHelper extends Helper
die("Method HtmlHelper::javascriptIncludeTag() was moved to JavascriptHelper::link().");
}
/**
/**
* @deprecated Moved to JavascriptHelper. Version 0.9.2.
*/
function javascriptTag($script)
@ -1107,11 +1106,11 @@ class HtmlHelper extends Helper
die("Method HtmlHelper::javascriptTag() was moved to JavascriptHelper::codeBlock().");
}
/*************************************************************************
/*************************************************************************
* Deprecated methods
*************************************************************************/
/**
/**
* Returns an HTML FORM element.
*
* @param string $target URL for the FORM's ACTION attribute.
@ -1130,7 +1129,7 @@ class HtmlHelper extends Helper
return sprintf($this->tags['form'], $this->parseHtmlOptions($htmlAttributes, null, ''));
}
/**
/**
* Generates a nested unordered list tree from an array.
*
* @param array $data
@ -1162,7 +1161,7 @@ class HtmlHelper extends Helper
return $this->output($out, $return);
}
/**
/**
* Returns a mailto: link.
*
* @param string $title Title of the link, or the e-mail address
@ -1174,20 +1173,20 @@ class HtmlHelper extends Helper
*/
function linkEmail($title, $email=null, $options=null)
{
// if no $email, then title contains the email.
// if no $email, then title contains the email.
if (empty($email)) $email = $title;
$match = array();
// does the address contain extra attributes?
// does the address contain extra attributes?
preg_match('!^(.*)(\?.*)$!', $email, $match);
// plaintext
// plaintext
if (empty($options['encode']) || !empty($match[2]))
{
return sprintf($this->tags['mailto'], $email, $this->parseHtmlOptions($options), $title);
}
// encoded to avoid spiders
// encoded to avoid spiders
else
{
$email_encoded = null;
@ -1213,12 +1212,12 @@ class HtmlHelper extends Helper
}
}
/**
/**
* Returns a generic HTML tag (no content).
*
* Examples:
* + <code>tag("br") => <br /></code>
* + <code>tag("input", array("type" => "text")) => <input type="text" /></code>
* + <code>tag("input", array("type" => "text")) => <input type="text"/></code>
*
* @param string $name Name of HTML element
* @param array $options HTML options
@ -1233,7 +1232,7 @@ class HtmlHelper extends Helper
return $tag;
}
/**
/**
* Returns a generic HTML tag with content.
*
* Examples:
@ -1254,7 +1253,7 @@ class HtmlHelper extends Helper
return "<$name ". $this->parseHtmlOptions($options). ">$content</$name>";
}
/**
/**
* Returns a SELECT element for days.
*
* @param string $tagName Prefix name for the SELECT element
@ -1264,7 +1263,7 @@ class HtmlHelper extends Helper
* @param boolean $show_empty Show/hide the empty select option
* @return string
*/
function dayOptionTag($tagName, $value=null, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true)
function dayOptionTag($tagName, $value=null, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true)
{
$value = isset($value)? $value : $this->tagValue($tagName."_day");
$dayValue = empty($selected) ? date('d') : $selected;
@ -1277,11 +1276,11 @@ class HtmlHelper extends Helper
'22'=>'22','23'=>'23','24'=>'24',
'25'=>'25','26'=>'26','27'=>'27',
'28'=>'28','29'=>'29','30'=>'30','31'=>'31');
$option = $this->selectTag($tagName.'_day', $days, $dayValue, $select_attr, $optionAttr, $showEmpty);
$option = $this->selectTag($tagName.'_day', $days, $dayValue, $selectAttr, $optionAttr, $showEmpty);
return $option;
}
/**
/**
* Returns a SELECT element for years
*
* @param string $tagName Prefix name for the SELECT element
@ -1293,7 +1292,7 @@ class HtmlHelper extends Helper
* @param boolean $show_empty Show/hide the empty select option
* @return string
*/
function yearOptionTag($tagName, $value=null, $minYear=null, $maxYear=null, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true)
function yearOptionTag($tagName, $value=null, $minYear=null, $maxYear=null, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true)
{
$value = isset($value)? $value : $this->tagValue($tagName."_year");
@ -1318,11 +1317,11 @@ class HtmlHelper extends Helper
$years[$yearCounter] = $yearCounter;
}
$option = $this->selectTag($tagName.'_year', $years, $yearValue, $select_attr, $optionAttr, $showEmpty);
$option = $this->selectTag($tagName.'_year', $years, $yearValue, $selectAttr, $optionAttr, $showEmpty);
return $option;
}
/**
/**
* Returns a SELECT element for months.
*
* @param string $tagName Prefix name for the SELECT element
@ -1332,18 +1331,18 @@ class HtmlHelper extends Helper
* @param boolean $show_empty Show/hide the empty select option
* @return string
*/
function monthOptionTag($tagName, $value=null, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true)
function monthOptionTag($tagName, $value=null, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true)
{
$value = isset($value)? $value : $this->tagValue($tagName."_month");
$monthValue = empty($selected) ? date('m') : $selected ;
$months=array('01'=>'January','02'=>'February','03'=>'March',
'04'=>'April','05'=>'May','06'=>'June','07'=>'July','08'=>'August',
'09'=>'September','10'=>'October','11'=>'November','12'=>'December');
$option = $this->selectTag($tagName.'_month', $months, $monthValue, $select_attr, $optionAttr, $showEmpty);
$option = $this->selectTag($tagName.'_month', $months, $monthValue, $selectAttr, $optionAttr, $showEmpty);
return $option;
}
/**
/**
* Returns a SELECT element for hours.
*
* @param string $tagName Prefix name for the SELECT element
@ -1353,7 +1352,7 @@ class HtmlHelper extends Helper
* @param array $optionAttr Attribute array for the option elements.
* @return string
*/
function hourOptionTag($tagName, $value=null, $format24Hours = false, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true )
function hourOptionTag($tagName, $value=null, $format24Hours = false, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true )
{
$value = isset($value)? $value : $this->tagValue($tagName."_hour");
if ( $format24Hours )
@ -1380,12 +1379,12 @@ class HtmlHelper extends Helper
'10'=>'10','11'=>'11','12'=>'12');
}
$option = $this->selectTag($tagName.'_hour', $hours, $hourValue, $select_attr,
$option = $this->selectTag($tagName.'_hour', $hours, $hourValue, $selectAttr,
$optionAttr);
return $option;
}
/**
/**
* Returns a SELECT element for minutes.
*
* @param string $tagName Prefix name for the SELECT element
@ -1394,7 +1393,7 @@ class HtmlHelper extends Helper
* @param array $optionAttr Attribute array for the option elements.
* @return string
*/
function minuteOptionTag( $tagName, $value=null, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true)
function minuteOptionTag( $tagName, $value=null, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true)
{
$value = isset($value)? $value : $this->tagValue($tagName."_min");
$minValue = empty($selected) ? date('i') : $selected ;
@ -1403,12 +1402,12 @@ class HtmlHelper extends Helper
$mins[$minCount] = sprintf('%02d', $minCount);
}
$option = $this->selectTag($tagName.'_min', $mins, $minValue, $select_attr,
$option = $this->selectTag($tagName.'_min', $mins, $minValue, $selectAttr,
$optionAttr);
return $option;
}
/**
/**
* Returns a SELECT element for AM or PM.
*
* @param string $tagName Prefix name for the SELECT element
@ -1417,18 +1416,18 @@ class HtmlHelper extends Helper
* @param array $optionAttr Attribute array for the option elements.
* @return string
*/
function meridianOptionTag( $tagName, $value=null, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true)
function meridianOptionTag( $tagName, $value=null, $selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true)
{
$value = isset($value)? $value : $this->tagValue($tagName."_meridian");
$merValue = empty($selected) ? date('a') : $selected ;
$meridians = array('am'=>'am','pm'=>'pm');
$option = $this->selectTag($tagName.'_meridian', $meridians, $merValue, $select_attr,
$option = $this->selectTag($tagName.'_meridian', $meridians, $merValue, $selectAttr,
$optionAttr);
return $option;
}
/**
/**
* Returns a set of SELECT elements for a full datetime setup: day, month and year, and then time.
*
* @param string $tagName Prefix name for the SELECT element
@ -1438,7 +1437,7 @@ class HtmlHelper extends Helper
* @param array $optionAttr Attribute array for the option elements.
* @return string The HTML formatted OPTION element
*/
function dateTimeOptionTag( $tagName, $dateFormat = 'DMY', $timeFormat = '12',$selected=null, $select_attr=null, $optionAttr=null, $showEmpty = true)
function dateTimeOptionTag( $tagName, $dateFormat = 'DMY', $timeFormat = '12',$selected=null, $selectAttr=null, $optionAttr=null, $showEmpty = true)
{
$day = null;
$month = null;
@ -1482,13 +1481,13 @@ class HtmlHelper extends Helper
switch ( $dateFormat )
{
case 'DMY' :
$opt = $this->dayOptionTag( $tagName ,null ,$day, $select_attr, $optionAttr, $showEmpty) . '-' . $this->monthOptionTag( $tagName, null, $month, $select_attr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag( $tagName, null, null, null, $year, $select_attr, $optionAttr, $showEmpty);
$opt = $this->dayOptionTag( $tagName ,null ,$day, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->monthOptionTag( $tagName, null, $month, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag( $tagName, null, null, null, $year, $selectAttr, $optionAttr, $showEmpty);
break;
case 'MDY' :
$opt = $this->monthOptionTag($tagName, null, $month, $select_attr, $optionAttr, $showEmpty) .'-'.$this->dayOptionTag( $tagName, null, $day, $select_attr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $optionAttr, $select_attr, $showEmpty);
$opt = $this->monthOptionTag($tagName, null, $month, $selectAttr, $optionAttr, $showEmpty) .'-'.$this->dayOptionTag( $tagName, null, $day, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $optionAttr, $selectAttr, $showEmpty);
break;
case 'YMD' :
$opt = $this->yearOptionTag($tagName, null, null, null, $year, $select_attr, $optionAttr, $showEmpty) . '-' . $this->monthOptionTag( $tagName, null, $month, $select_attr, $optionAttr, $showEmpty) . '-' . $this->dayOptionTag( $tagName, null, $day, $optionAttr, $select_attr, $showEmpty);
$opt = $this->yearOptionTag($tagName, null, null, null, $year, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->monthOptionTag( $tagName, null, $month, $selectAttr, $optionAttr, $showEmpty) . '-' . $this->dayOptionTag( $tagName, null, $day, $optionAttr, $selectAttr, $showEmpty);
break;
case 'NONE':
$opt ='';
@ -1500,10 +1499,10 @@ class HtmlHelper extends Helper
switch ($timeFormat)
{
case '24':
$opt .= $this->hourOptionTag( $tagName, null , true, $hour, $select_attr, $optionAttr, $showEmpty) . ':' . $this->minuteOptionTag( $tagName, null, $min, $select_attr, $optionAttr, $showEmpty);
$opt .= $this->hourOptionTag( $tagName, null , true, $hour, $selectAttr, $optionAttr, $showEmpty) . ':' . $this->minuteOptionTag( $tagName, null, $min, $selectAttr, $optionAttr, $showEmpty);
break;
case '12':
$opt .= $this->hourOptionTag( $tagName, null, false, $hour, $select_attr, $optionAttr, $showEmpty) . ':' . $this->minuteOptionTag( $tagName, null, $min, $select_attr, $optionAttr, $showEmpty) . ' ' . $this->meridianOptionTag($tagName, null, $meridian, $select_attr, $optionAttr, $showEmpty);
$opt .= $this->hourOptionTag( $tagName, null, false, $hour, $selectAttr, $optionAttr, $showEmpty) . ':' . $this->minuteOptionTag( $tagName, null, $min, $selectAttr, $optionAttr, $showEmpty) . ' ' . $this->meridianOptionTag($tagName, null, $meridian, $selectAttr, $optionAttr, $showEmpty);
break;
case 'NONE':
$opt .='';

View file

@ -43,7 +43,7 @@ class JavascriptHelper extends Helper
var $_cachedEvents = array();
var $_cacheEvents = false;
/**
/**
* Returns a JavaScript script tag.
*
* @param string $script The JavaScript to be wrapped in SCRIPT tags.
@ -54,7 +54,7 @@ class JavascriptHelper extends Helper
return sprintf($this->tags['javascriptblock'], $script);
}
/**
/**
* Returns a JavaScript include tag (SCRIPT element)
*
* @param string $url URL to JavaScript file.
@ -66,7 +66,7 @@ class JavascriptHelper extends Helper
return sprintf($this->tags['javascriptlink'], $this->webroot.JS_URL.$this->themeWeb.$url);
}
/**
/**
* Returns a JavaScript include tag for an externally-hosted script
*
* @param string $url URL to JavaScript file.
@ -177,7 +177,7 @@ class JavascriptHelper extends Helper
* javascripts into your application's
* public/javascripts/ directory, and use @see javascriptIncludeTag() to
* create remote script links.
* @return string script with all javascript in /javascripts folder
* @return string script with all javascript in/javascripts folder
*/
function includeScript ($script = "")
{
@ -205,7 +205,7 @@ class JavascriptHelper extends Helper
* from an array
*
* @param array $data Data to be converted
* @param boolean $block Wraps return value in a <script /> block if true
* @param boolean $block Wraps return value in a <script/> block if true
* @param string $prefix Prepends the string to the returned data
* @param string $postfix Appends the string to the returned data
* @param array $stringKeys A list of array keys to be treated as a string

View file

@ -41,7 +41,7 @@
*/
class NumberHelper extends Helper
{
/**
/**
* Formats a number with a level of precision.
*
* @param float $number A floating point number.
@ -54,7 +54,7 @@ class NumberHelper extends Helper
return sprintf("%01.{$precision}f", $number);
}
/**
/**
* Returns a formatted-for-humans file size.
*
* @param integer $length Size in bytes
@ -74,7 +74,7 @@ class NumberHelper extends Helper
}
}
/**
/**
* Formats a number into a percentage string.
*
* @param float $number A floating point number

View file

@ -53,7 +53,7 @@ if(!class_exists('Html'))
*/
class TextHelper extends Helper
{
/**
/**
* Highlights a given phrase in a text.
*
* @param string $text Text to search the phrase in
@ -86,7 +86,7 @@ class TextHelper extends Helper
}
}
/**
/**
* Strips given text of all links (<a href=....)
*
* @param string $text Text
@ -97,7 +97,7 @@ class TextHelper extends Helper
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://.
*
@ -132,7 +132,7 @@ class TextHelper extends Helper
);
}
/**
/**
* Adds email links (<a href="mailto:....) to a given text.
*
* @param string $text Text
@ -158,7 +158,7 @@ class TextHelper extends Helper
);
}
/**
/**
* Convert all links and email adresses to HTML links.
*
* @param string $text Text
@ -170,7 +170,7 @@ class TextHelper extends Helper
return $this->autoLinkEmails($this->autoLinkUrls($text, $htmlOptions), $htmlOptions);
}
/**
/**
* Truncates text.
*
* Cuts a string to the length of $length and replaces the last characters
@ -190,7 +190,7 @@ class TextHelper extends Helper
}
/**
/**
* Alias for truncate().
*
* @see TextHelper::truncate()
@ -201,7 +201,7 @@ class TextHelper extends Helper
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
@ -227,7 +227,7 @@ 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"

View file

@ -325,7 +325,7 @@ class TimeHelper extends Helper
if ($months > 0)
{
// over a month old, just show date (mm/dd/yyyy format)
// over a month old, just show date (mm/dd/yyyy format)
$relative_date = 'on '. date($format, $in_seconds);
$old = true;
}
@ -335,36 +335,36 @@ class TimeHelper extends Helper
$old = false;
if ($weeks > 0)
{
// weeks and days
// 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
// 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
// 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
// minutes only
$relative_date .= ($relative_date ? ', ' : '').$minutes.' minute'.($minutes > 1 ? 's' : '');
}
else
{
// seconds only
// seconds only
$relative_date .= ($relative_date ? ', ' : '').$seconds.' second'.($seconds > 1 ? 's' : '');
}
}
$ret = $relative_date;
// show relative date and add proper verbiage
// show relative date and add proper verbiage
if(!$backwards && !$old)
{
$ret .= ' ago';

View file

@ -28,13 +28,13 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl" xml:lang="pl">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $page_title?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php if(DEBUG == 0) { ?>
<meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>" />
<meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>"/>
<?php } ?>
<style><!--
P { text-align:center; font:bold 1.1em sans-serif }

View file

@ -288,7 +288,7 @@ class View extends Object
return array('action' => $action, 'layout' => $layout, 'viewFn' => $viewFileName);
}
// check to see if the missing view is due to a custom missingAction
// check to see if the missing view is due to a custom missingAction
if (strpos($action, 'missingAction') !== false)
{
$errorAction = 'missingAction';
@ -298,7 +298,7 @@ class View extends Object
$errorAction = 'missingView';
}
// check for controller-level view handler
// check for controller-level view handler
foreach(array($this->name, 'errors') as $viewDir)
{
$errorAction =Inflector::underscore($errorAction);
@ -342,7 +342,7 @@ class View extends Object
if (!$missingViewExists || $isFatal)
{
// app/view/errors/missing_view.thtml view is missing!
// app/view/errors/missing_view.thtml view is missing!
if (DEBUG)
{
trigger_error(sprintf(__("No template file for view %s (expected %s), create it first'"), $action, $viewFileName), E_USER_ERROR);
@ -394,7 +394,7 @@ class View extends Object
* Element.
*
* @link http://wiki.cakephp.org/docs:view:renderelement
* @param string $name Name of template file in the /app/views/elements/ folder
* @param string $name Name of template file in the/app/views/elements/ folder
* @param array $params Array of data to be made available to the for rendered view (i.e. the Element)
* @return string Rendered output
*/
@ -594,12 +594,12 @@ class View extends Object
* array of data.
*
* @param string $___viewFn Filename of the view
* @param array $___data_for_view Data to include in rendered view
* @param boolean $___play_safe If set to false, the include() of the $__viewFn is done without suppressing output of errors
* @param array $___dataForView Data to include in rendered view
* @param boolean $___playSafe If set to false, the include() of the $__viewFn is done without suppressing output of errors
* @return string Rendered output
* @access private
*/
function _render($___viewFn, $___data_for_view, $___play_safe = true, $loadHelpers = true)
function _render($___viewFn, $___dataForView, $___playSafe = true, $loadHelpers = true)
{
if ($this->helpers != false && $loadHelpers === true)
{
@ -624,7 +624,7 @@ class View extends Object
}
}
extract($___data_for_view, EXTR_SKIP); # load all view variables
extract($___dataForView, EXTR_SKIP); # load all view variables
/**
* Local template variables.
*/
@ -640,7 +640,7 @@ class View extends Object
/**
* Include the template.
*/
$___play_safe? @include($___viewFn): include($___viewFn);
$___playSafe? @include($___viewFn): include($___viewFn);
$out = ob_get_clean();

View file

@ -149,7 +149,7 @@ class AclCLI {
$this->stdout = fopen('php://stdout', 'w');
$this->stderr = fopen('php://stderr', 'w');
//Check to see if DB ACL is enabled
//Check to see if DB ACL is enabled
if (ACL_CLASSNAME != 'DB_ACL')
{
$out = "--------------------------------------------------\n";
@ -235,9 +235,9 @@ class AclCLI {
extract($this->__dataVars());
$node = &new $class;
//What about children?
//$node->del($this->args[1]);
//fwrite($this->stdout, "$class deleted.\n\n");
//What about children?
//$node->del($this->args[1]);
//fwrite($this->stdout, "$class deleted.\n\n");
}
/**
@ -295,7 +295,7 @@ class AclCLI {
function grant()
{
$this->checkArgNumber(3, 'grant');
//add existence checks for nodes involved
//add existence checks for nodes involved
$this->acl->allow(intval($this->args[0]), intval($this->args[1]), $this->args[2]);
@ -309,7 +309,7 @@ class AclCLI {
function deny()
{
$this->checkArgNumber(3, 'deny');
//add existence checks for nodes involved
//add existence checks for nodes involved
$this->acl->deny(intval($this->args[0]), intval($this->args[1]), $this->args[2]);
fwrite($this->stdout, "Requested permission successfully denied.\n");
@ -539,7 +539,7 @@ class AclCLI {
*/
function nodeExists($type, $id)
{
//fwrite($this->stdout, "Check to see if $type with ID = $id exists...\n");
//fwrite($this->stdout, "Check to see if $type with ID = $id exists...\n");
extract($this->__dataVars($type));
$node = &new $class;

View file

@ -6,7 +6,7 @@
*
* This file collects requests if:
* - no mod_rewrite is avilable or .htaccess files are not supported
* - /public is not set as a web root.
* -/public is not set as a web root.
*
* PHP versions 4 and 5
*
@ -42,7 +42,7 @@ define ('ROOT', dirname(__FILE__).DS);
*/
if (!defined('CAKE_CORE_INCLUDE_PATH'))
{
//define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
//define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
define('CAKE_CORE_INCLUDE_PATH', ROOT);
}