-
-
diff --git a/app/views/layouts/test.thtml b/app/views/layouts/test.thtml
deleted file mode 100644
index 60f4569c6..000000000
--- a/app/views/layouts/test.thtml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-=$content_for_layout?>
-
-
-
\ No newline at end of file
diff --git a/app/views/pages/home.thtml b/app/views/pages/home.thtml
deleted file mode 100644
index dd6cd4ae3..000000000
--- a/app/views/pages/home.thtml
+++ /dev/null
@@ -1,29 +0,0 @@
-
CakePHP Works!
-
-Your database configuration file is
-
-
-Cake connected ? "is able to" : "is not able to" ?> connect to the database.
-
-
-
-
Editing this Page
-
-To change the content of this page, edit /app/views/pages/home.thtml. To change it's layout, edit /app/views/layouts/default.thtml. You can also edit the CSS styles for this page at /public/css/default.css.
-
-
-
Introducing Cake
-
-
Cake is a rapid development framework for PHP: a structure of libraries, classes and run-time infrastructure for programmers creating web applications. Our primary goal is to enable you to work in a structured and rapid manner within a framework - without loss of flexibility.
-
Tired of repeating yourself? Ever copy and pasted code? Want to get your app in production quicker? Cake is for you.
-
-
Get Involved
-
Cake PHP needs you! We have an active user base and are always open to new bug reports or feature ideas!
-linkOut('Google Group','http://groups-beta.google.com/group/cake-php')?> – for public discussions about everything Cake.
-linkOut('Wiki','https://trac.cakephp.org/wiki')?> – fastest way of getting newest information on Cake PHP.
-linkOut('Report a bug or feature request','https://trac.cakephp.org/newticket')?>.
-linkOut('Roadmap','https://trac.cakephp.org/roadmap')?> – check our plans for the bright future.
-#cakephp on irc.euirc.net for quick help
-
-
-
Cake 0.9.2
\ No newline at end of file
diff --git a/app/views/tests/index.thtml b/app/views/tests/index.thtml
deleted file mode 100644
index e5f845bbf..000000000
--- a/app/views/tests/index.thtml
+++ /dev/null
@@ -1,4 +0,0 @@
-
diff --git a/app/views/tests/test_all.thtml b/app/views/tests/test_all.thtml
deleted file mode 100644
index ac03dc2d7..000000000
--- a/app/views/tests/test_all.thtml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
+
+
diff --git a/libs/controllers/templates/scaffolds/show.thtml b/cake/libs/controller/templates/scaffolds/show.thtml
similarity index 100%
rename from libs/controllers/templates/scaffolds/show.thtml
rename to cake/libs/controller/templates/scaffolds/show.thtml
diff --git a/libs/error_messages.php b/cake/libs/error_messages.php
similarity index 98%
rename from libs/error_messages.php
rename to cake/libs/error_messages.php
index ab0211fa1..d42aed2b2 100644
--- a/libs/error_messages.php
+++ b/cake/libs/error_messages.php
@@ -94,7 +94,7 @@ define ('ERROR_NO_FIELD_IN_MODEL_DB', '[Model::set()] Field "%s" is not present
/**
* Error string short short error message.
*/
-define ('SHORT_ERROR_MESSAGE', '
%s
');
+define ('SHORT_ERROR_MESSAGE', '
%s
');
/**
* Error string for when original image can not be loaded.
diff --git a/cake/libs/file.php b/cake/libs/file.php
new file mode 100644
index 000000000..95f6e89fa
--- /dev/null
+++ b/cake/libs/file.php
@@ -0,0 +1,348 @@
+
+ * Copyright (c) 2005, CakePHP Authors/Developers
+ *
+ * Author(s): Michal Tatarynowicz aka Pies
+ * Larry E. Masters aka PhpNut
+ * Kamil Dzielinski aka Brego
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @author CakePHP Authors/Developers
+ * @copyright Copyright (c) 2005, CakePHP Authors/Developers
+ * @link https://trac.cakephp.org/wiki/Authors Authors/Developers
+ * @package cake
+ * @subpackage cake.libs
+ * @since CakePHP v 0.2.9
+ * @version $Revision$
+ * @modifiedby $LastChangedBy$
+ * @lastmodified $Date$
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Enter description here...
+ *
+ */
+uses('object');
+
+/**
+ * Convenience class for reading, writing and appending to files.
+ *
+ *
+ * @package cake
+ * @subpackage cake.libs
+ * @since CakePHP v 0.2.9
+ */
+class File extends Object
+{
+/**
+ * Folder of the File
+ *
+ * @var Folder
+ */
+ var $folder = null;
+
+/**
+ * Filename
+ *
+ * @var string
+ */
+ var $name = null;
+
+/**
+ * Constructor
+ *
+ * @param string $path
+ * @param boolean $create Create file if it does not exist
+ * @return File
+ */
+ function File ($path , $create = false )
+ {
+ $this->folder = new Folder( dirname( realpath($path) ) , $create );
+
+ $this->name = basename( realpath($path) );
+
+ if ( !$this->exists() )
+ {
+ if ( $create === true )
+ {
+ if ( !$this->create() )
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+/**
+ * Return the contents of this File as a string.
+ *
+ * @return string Contents
+ */
+ function read ()
+ {
+ return file_get_contents( $this->getFullPath() );
+ }
+
+/**
+ * Append given data string to this File.
+ *
+ * @param string $data Data to write
+ * @return boolean Success
+ */
+ function append ($data)
+ {
+ return $this->write($data, 'a');
+ }
+
+/**
+ * Write given data to this File.
+ *
+ * @param string $data Data to write to this File.
+ * @param string $mode Mode of writing. {@link http://php.net/fwrite See fwrite()}.
+ * @return boolean Success
+ */
+ function write ($data, $mode = 'w')
+ {
+ $file = $this->getFullPath();
+ if (!($handle = fopen( $file , $mode)))
+ {
+ print ("[File] Could not open $file with mode $mode!");
+ return false;
+ }
+
+ if (!fwrite($handle, $data))
+ return false;
+
+ if (!fclose($handle))
+ return false;
+
+ return true;
+ }
+
+/**
+ * Get md5 Checksum of file with previous check of Filesize
+ *
+ * @param string $force Data to write to this File.
+ * @return string md5 Checksum {@link http://php.net/md5_file See md5_file()}
+ */
+ function getMd5 ($force = false)
+ {
+ $md5 = '';
+ if ( $force == true || $this->getSize(false) < MAX_MD5SIZE )
+ {
+ $md5 = md5_file( $this->getFullPath() );
+ }
+
+ return $md5;
+ }
+
+/**
+ * Get the Filesize
+ *
+ * @param boolean $humanReadeble Data to write to this File.
+ * @return string|int filesize as int or as humand readable string
+ */
+ function getSize ()
+ {
+ $size = filesize( $this->getFullPath() );
+ return $size;
+ }
+
+/**
+ * Get the Fileextension
+ *
+ * @return string The Fileextension
+ */
+ function getExt ()
+ {
+ $ext = '';
+
+ $parts = explode('.', $this->getName() );
+
+ if ( count($parts) > 1 )
+ {
+ $ext = array_pop( $parts );
+ }
+ else
+ {
+ $ext = '';
+ }
+
+ return $ext;
+ }
+
+/**
+ * Get the Filename
+ *
+ * @return string The Filename
+ */
+ function getName ()
+ {
+ return $this->name;
+ }
+
+/**
+ * get the File owner
+ *
+ * @return int the Fileowner
+ */
+ function getOwner ()
+ {
+ return fileowner( $this->getFullPath() );
+ }
+
+/**
+ * get the File owner
+ *
+ * @return int the Filegroup
+ */
+ function getGroup ()
+ {
+ return filegroup( $this->getFullPath() );
+ }
+
+/**
+ * creates the File
+ *
+ * @return boolean
+ */
+ function create ()
+ {
+ $dir = $this->folder->pwd();
+ if ( file_exists( $dir ) && is_dir($dir) && is_writable($dir) && !$this->exists() )
+ {
+ if ( !touch( $this->getFullPath() ) )
+ {
+ print ("[File] Could not create $this->getName()!");
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else
+ {
+ print ("[File] Could not create $this->getName()!");
+ return false;
+ }
+ }
+
+/**
+ * deletes the File
+ *
+ * @return boolean
+ */
+ function exists ()
+ {
+ return file_exists( $this->getFullPath() );
+ }
+
+/**
+ * deletes the File
+ *
+ * @return boolean
+ */
+ function delete ()
+ {
+ return unlink( $this->getFullPath() );
+ }
+
+/**
+ * check if the File writable
+ *
+ * @return boolean
+ */
+ function writable ()
+ {
+ return is_writable( $this->getFullPath() );
+ }
+
+/**
+ * check if the File executable
+ *
+ * @return boolean
+ */
+ function executable ()
+ {
+ return is_executable( $this->getFullPath() );
+ }
+
+/**
+ * check if the File readable
+ *
+ * @return boolean
+ */
+ function readable ()
+ {
+ return is_readable( $this->getFullPath() );
+ }
+
+/**
+ * get last access time
+ *
+ * @return int timestamp
+ */
+ function lastAccess ()
+ {
+ return fileatime( $this->getFullPath() );
+ }
+
+/**
+ * get last access time
+ *
+ * @return int timestamp
+ */
+ function lastChange ()
+ {
+ return filemtime( $this->getFullPath() );
+ }
+
+/**
+ * get the current folder
+ *
+ * @return Folder
+ */
+ function getFolder ()
+ {
+ return $this->folder;
+ }
+
+/**
+ * get the chmod of the File
+ *
+ * @return string
+ */
+ function getChmod ( )
+ {
+ return substr(sprintf('%o', fileperms($this->getFullPath())), -4);
+ }
+
+/**
+ * get the chmod of the File
+ *
+ * @return string
+ */
+ function getFullPath ( )
+ {
+ return Folder::slashTerm($this->folder->pwd()).$this->getName();
+ }
+}
+
+?>
diff --git a/libs/flay.php b/cake/libs/flay.php
similarity index 100%
rename from libs/flay.php
rename to cake/libs/flay.php
diff --git a/libs/folder.php b/cake/libs/folder.php
similarity index 54%
rename from libs/folder.php
rename to cake/libs/folder.php
index 8ab0a7aca..25459ee94 100644
--- a/libs/folder.php
+++ b/cake/libs/folder.php
@@ -46,7 +46,7 @@ uses('object');
* @since CakePHP v 0.2.9
*/
class Folder extends Object {
-
+
/**
* Enter description here...
*
@@ -65,22 +65,28 @@ class Folder extends Object {
* Constructor.
*
* @param string $path
+ * @param bollean $path
*/
- function __construct ($path=false)
+ function Folder ($path=false , $create = false)
{
- if (empty($path))
- {
- $path = getcwd();
- }
- $this->cd($path);
- }
+ if (empty($path))
+ {
+ $path = getcwd();
+ }
+
+ if ( !file_exists( $path ) && $create==true )
+ {
+ $this->mkdirr($path);
+ }
+ $this->cd($path);
+ }
/**
* Return current path.
*
* @return string Current path
*/
- function pwd ()
+ function pwd ()
{
return $this->path;
}
@@ -91,12 +97,12 @@ class Folder extends Object {
* @param string $desired_path Path to the directory to change to
* @return string The new path. Returns false on failure
*/
- function cd ($desired_path)
+ function cd ($desired_path)
{
$desired_path = realpath($desired_path);
- $new_path = Folder::isAbsolute($desired_path)?
- $desired_path:
- Folder::addPathElement($this->path, $desired_path);
+ $new_path = Folder::isAbsolute($desired_path)?
+ $desired_path:
+ Folder::addPathElement($this->path, $desired_path);
return is_dir($new_path)? $this->path = $new_path: false;
}
@@ -107,41 +113,42 @@ class Folder extends Object {
* The returned array holds two arrays: one of dirs and one of files.
*
* @param boolean $sort
+ * @param boolean $noDotFiles
* @return array
*/
- function ls($sort=true)
+ function ls($sort=true , $noDotFiles = false)
{
$dir = opendir($this->path);
- if ($dir)
+ if ($dir)
{
$dirs = $files = array();
- while (false !== ($n = readdir($dir)))
+ while (false !== ($n = readdir($dir)))
{
- if (!preg_match('#^\.+$#', $n))
+ if ( (!preg_match('#^\.+$#', $n) && $noDotFiles == false) || ( $noDotFiles == true && !preg_match('#^\.(.*)$#', $n) ) )
{
if (is_dir($this->addPathElement($this->path, $n)))
{
$dirs[] = $n;
}
else
- {
+ {
$files[] = $n;
}
}
}
- if ($sort || $this->sort)
+ if ($sort || $this->sort)
{
sort($dirs);
sort($files);
}
-
+
closedir($dir);
return array($dirs,$files);
}
- else
+ else
{
return false;
}
@@ -154,21 +161,21 @@ class Folder extends Object {
* @param string $pattern Preg_match pattern (Defaults to: .*)
* @return array
*/
- function find ($regexp_pattern='.*')
+ function find ($regexp_pattern='.*')
{
$data = $this->ls();
-
+
if (!is_array($data))
{
return array();
}
-
+
list($dirs, $files) = $data;
$found = array();
- foreach ($files as $file)
+ foreach ($files as $file)
{
- if (preg_match("/^{$regexp_pattern}$/i", $file))
+ if (preg_match("/^{$regexp_pattern}$/i", $file))
{
$found[] = $file;
}
@@ -184,7 +191,7 @@ class Folder extends Object {
* @param string $pattern Preg_match pattern (Defaults to: .*)
* @return array Files matching $pattern
*/
- function findRecursive ($pattern='.*')
+ function findRecursive ($pattern='.*')
{
$starts_on = $this->path;
$out = $this->_findRecursive($pattern);
@@ -199,21 +206,21 @@ class Folder extends Object {
* @return array Files matching pattern
* @access private
*/
- function _findRecursive ($pattern)
+ function _findRecursive ($pattern)
{
list($dirs, $files) = $this->ls();
$found = array();
- foreach ($files as $file)
+ foreach ($files as $file)
{
- if (preg_match("/^{$pattern}$/i", $file))
+ if (preg_match("/^{$pattern}$/i", $file))
{
$found[] = $this->addPathElement($this->path, $file);
}
}
$start = $this->path;
- foreach ($dirs as $dir)
+ foreach ($dirs as $dir)
{
$this->cd($this->addPathElement($start, $dir));
$found = array_merge($found, $this->findRecursive($pattern));
@@ -227,8 +234,9 @@ class Folder extends Object {
*
* @param string $path Path to check
* @return boolean
+ * @static
*/
- function isWindowsPath ($path)
+ function isWindowsPath ($path)
{
return preg_match('#^[A-Z]:\\\#i', $path)? true: false;
}
@@ -238,8 +246,9 @@ class Folder extends Object {
*
* @param string $path Path to check
* @return boolean
+ * @static
*/
- function isAbsolute ($path)
+ function isAbsolute ($path)
{
return preg_match('#^\/#', $path) || preg_match('#^[A-Z]:\\\#i', $path);
}
@@ -249,8 +258,9 @@ class Folder extends Object {
*
* @param string $path Path to check
* @return boolean
+ * @static
*/
- function isSlashTerm ($path)
+ function isSlashTerm ($path)
{
return preg_match('#[\\\/]$#', $path)? true: false;
}
@@ -260,8 +270,9 @@ class Folder extends Object {
*
* @param string $path Path to check
* @return string Set of slashes ("\\" or "/")
+ * @static
*/
- function correctSlashFor ($path)
+ function correctSlashFor ($path)
{
return Folder::isWindowsPath($path)? '\\': '/';
}
@@ -271,8 +282,9 @@ class Folder extends Object {
*
* @param string $path Path to check
* @return string
+ * @static
*/
- function slashTerm ($path)
+ function slashTerm ($path)
{
return $path . (Folder::isSlashTerm($path)? null: Folder::correctSlashFor($path));
}
@@ -283,11 +295,145 @@ class Folder extends Object {
* @param string $path
* @param string $element
* @return string
+ * @static
*/
- function addPathElement ($path, $element)
+ function addPathElement ($path, $element)
{
return Folder::slashTerm($path).$element;
}
+
+/**
+ * check if the File is in a given CakePath
+ *
+ * @return boolean
+ */
+ function inCakePath ( $path = '' )
+ {
+ $dir = substr( Folder::slashTerm(ROOT) , 0 , -1 );
+
+ $newdir = Folder::slashTerm($dir.$path);
+
+ return $this->inPath( $newdir );
+ }
+
+/**
+ * check if the File is in a given Path
+ *
+ * @return boolean
+ */
+ function inPath ( $path = '' )
+ {
+ $dir = substr( Folder::slashTerm($path) , 0 , -1 );
+
+ $return = preg_match('/^'.preg_quote(Folder::slashTerm($dir),'/').'(.*)/' , Folder::slashTerm($this->pwd()) );
+
+ if ( $return == 1 )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+/**
+ * Create a directory structure recursively
+ *
+ * @author Aidan Lister
+ * @version 1.0.0
+ * @param string $pathname The directory structure to create
+ * @return bool Returns TRUE on success, FALSE on failure
+ */
+ function mkdirr($pathname, $mode = null)
+ {
+ // Check if directory already exists
+ if (is_dir($pathname) || empty($pathname))
+ {
+ return true;
+ }
+
+ // 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
+ $next_pathname = substr($pathname, 0, strrpos($pathname, DIRECTORY_SEPARATOR));
+ if (mkdirr($next_pathname, $mode))
+ {
+ if (!file_exists($pathname))
+ {
+ return mkdir($pathname, $mode);
+ }
+ }
+
+ return false;
+ }
+
+/**
+ * Get the size of a directory.
+ *
+ * @author Aidan Lister
+ * @version 1.0.0
+ * @param string $directory Path to directory
+ */
+ function dirsize()
+ {
+ // Init
+ $size = 0;
+
+ $directory = Folder::slashTerm($this->path);
+
+ // Creating the stack array
+ $stack = array($directory);
+
+ // Iterate stack
+ for ($i = 0, $j = count($stack); $i < $j; ++$i)
+ {
+
+ // Add to total size
+ if (is_file($stack[$i]))
+ {
+ $size += filesize($stack[$i]);
+
+ }
+
+ // Add to stack
+ elseif (is_dir($stack[$i]))
+ {
+ // Read directory
+ $dir = dir($stack[$i]);
+ while (false !== ($entry = $dir->read()))
+ {
+ // No pointers
+ if ($entry == '.' || $entry == '..')
+ {
+ continue;
+ }
+
+ // Add to stack
+ $add = $stack[$i] . $entry;
+ if (is_dir($stack[$i] . $entry))
+ {
+ $add = Folder::slashTerm($add);
+ }
+ $stack[] = $add;
+
+ }
+
+ // Clean up
+ $dir->close();
+ }
+
+ // Recount stack
+ $j = count($stack);
+ }
+
+ return $size;
+ }
}
?>
\ No newline at end of file
diff --git a/libs/bake.php b/cake/libs/generator/bake.php
similarity index 100%
rename from libs/bake.php
rename to cake/libs/generator/bake.php
diff --git a/libs/generator/base.php b/cake/libs/generator/base.php
similarity index 100%
rename from libs/generator/base.php
rename to cake/libs/generator/base.php
diff --git a/libs/generator/commands.php b/cake/libs/generator/commands.php
similarity index 100%
rename from libs/generator/commands.php
rename to cake/libs/generator/commands.php
diff --git a/libs/generator/generators/applications/app/app_generator.php b/cake/libs/generator/generators/applications/app/app_generator.php
similarity index 100%
rename from libs/generator/generators/applications/app/app_generator.php
rename to cake/libs/generator/generators/applications/app/app_generator.php
diff --git a/libs/generator/generators/components/controller/controller_generator.php b/cake/libs/generator/generators/class_templates/controller/controller_generator.php
similarity index 100%
rename from libs/generator/generators/components/controller/controller_generator.php
rename to cake/libs/generator/generators/class_templates/controller/controller_generator.php
diff --git a/libs/generator/generators/components/controller/templates/controller.php b/cake/libs/generator/generators/class_templates/controller/templates/controller.php
similarity index 100%
rename from libs/generator/generators/components/controller/templates/controller.php
rename to cake/libs/generator/generators/class_templates/controller/templates/controller.php
diff --git a/libs/generator/generators/components/controller/templates/functional_test.php b/cake/libs/generator/generators/class_templates/controller/templates/functional_test.php
similarity index 100%
rename from libs/generator/generators/components/controller/templates/functional_test.php
rename to cake/libs/generator/generators/class_templates/controller/templates/functional_test.php
diff --git a/libs/generator/generators/components/controller/templates/helper.php b/cake/libs/generator/generators/class_templates/controller/templates/helper.php
similarity index 100%
rename from libs/generator/generators/components/controller/templates/helper.php
rename to cake/libs/generator/generators/class_templates/controller/templates/helper.php
diff --git a/libs/generator/generators/components/controller/templates/view.thtml b/cake/libs/generator/generators/class_templates/controller/templates/view.thtml
similarity index 100%
rename from libs/generator/generators/components/controller/templates/view.thtml
rename to cake/libs/generator/generators/class_templates/controller/templates/view.thtml
diff --git a/libs/generator/generators/components/model/model_generator.php b/cake/libs/generator/generators/class_templates/model/model_generator.php
similarity index 100%
rename from libs/generator/generators/components/model/model_generator.php
rename to cake/libs/generator/generators/class_templates/model/model_generator.php
diff --git a/libs/generator/generators/components/model/templates/fixtures.php b/cake/libs/generator/generators/class_templates/model/templates/fixtures.php
similarity index 100%
rename from libs/generator/generators/components/model/templates/fixtures.php
rename to cake/libs/generator/generators/class_templates/model/templates/fixtures.php
diff --git a/libs/generator/generators/components/model/templates/model.php b/cake/libs/generator/generators/class_templates/model/templates/model.php
similarity index 100%
rename from libs/generator/generators/components/model/templates/model.php
rename to cake/libs/generator/generators/class_templates/model/templates/model.php
diff --git a/libs/generator/generators/components/model/templates/unit_test.php b/cake/libs/generator/generators/class_templates/model/templates/unit_test.php
similarity index 100%
rename from libs/generator/generators/components/model/templates/unit_test.php
rename to cake/libs/generator/generators/class_templates/model/templates/unit_test.php
diff --git a/libs/generator/generators/components/scaffold/scaffold_generator.php b/cake/libs/generator/generators/class_templates/scaffold/scaffold_generator.php
similarity index 100%
rename from libs/generator/generators/components/scaffold/scaffold_generator.php
rename to cake/libs/generator/generators/class_templates/scaffold/scaffold_generator.php
diff --git a/libs/generator/generators/components/scaffold/templates/controller.php b/cake/libs/generator/generators/class_templates/scaffold/templates/controller.php
similarity index 100%
rename from libs/generator/generators/components/scaffold/templates/controller.php
rename to cake/libs/generator/generators/class_templates/scaffold/templates/controller.php
diff --git a/libs/generator/generators/components/scaffold/templates/form.thtml b/cake/libs/generator/generators/class_templates/scaffold/templates/form.thtml
similarity index 100%
rename from libs/generator/generators/components/scaffold/templates/form.thtml
rename to cake/libs/generator/generators/class_templates/scaffold/templates/form.thtml
diff --git a/libs/generator/generators/components/scaffold/templates/form_scaffolding.thtml b/cake/libs/generator/generators/class_templates/scaffold/templates/form_scaffolding.thtml
similarity index 100%
rename from libs/generator/generators/components/scaffold/templates/form_scaffolding.thtml
rename to cake/libs/generator/generators/class_templates/scaffold/templates/form_scaffolding.thtml
diff --git a/libs/generator/generators/components/scaffold/templates/functional_test.php b/cake/libs/generator/generators/class_templates/scaffold/templates/functional_test.php
similarity index 100%
rename from libs/generator/generators/components/scaffold/templates/functional_test.php
rename to cake/libs/generator/generators/class_templates/scaffold/templates/functional_test.php
diff --git a/libs/generator/generators/components/scaffold/templates/helper.php b/cake/libs/generator/generators/class_templates/scaffold/templates/helper.php
similarity index 100%
rename from libs/generator/generators/components/scaffold/templates/helper.php
rename to cake/libs/generator/generators/class_templates/scaffold/templates/helper.php
diff --git a/libs/controllers/templates/rescues/layout.thtml b/cake/libs/generator/generators/class_templates/scaffold/templates/layout.thtml
similarity index 100%
rename from libs/controllers/templates/rescues/layout.thtml
rename to cake/libs/generator/generators/class_templates/scaffold/templates/layout.thtml
diff --git a/libs/generator/generators/components/scaffold/templates/style.css b/cake/libs/generator/generators/class_templates/scaffold/templates/style.css
similarity index 100%
rename from libs/generator/generators/components/scaffold/templates/style.css
rename to cake/libs/generator/generators/class_templates/scaffold/templates/style.css
diff --git a/libs/generator/generators/components/scaffold/templates/view_edit.thtml b/cake/libs/generator/generators/class_templates/scaffold/templates/view_edit.thtml
similarity index 100%
rename from libs/generator/generators/components/scaffold/templates/view_edit.thtml
rename to cake/libs/generator/generators/class_templates/scaffold/templates/view_edit.thtml
diff --git a/libs/generator/generators/components/scaffold/templates/view_list.thtml b/cake/libs/generator/generators/class_templates/scaffold/templates/view_list.thtml
similarity index 100%
rename from libs/generator/generators/components/scaffold/templates/view_list.thtml
rename to cake/libs/generator/generators/class_templates/scaffold/templates/view_list.thtml
diff --git a/libs/generator/generators/components/scaffold/templates/view_new.thtml b/cake/libs/generator/generators/class_templates/scaffold/templates/view_new.thtml
similarity index 100%
rename from libs/generator/generators/components/scaffold/templates/view_new.thtml
rename to cake/libs/generator/generators/class_templates/scaffold/templates/view_new.thtml
diff --git a/libs/generator/generators/components/scaffold/templates/view_show.thtml b/cake/libs/generator/generators/class_templates/scaffold/templates/view_show.thtml
similarity index 100%
rename from libs/generator/generators/components/scaffold/templates/view_show.thtml
rename to cake/libs/generator/generators/class_templates/scaffold/templates/view_show.thtml
diff --git a/libs/generator/generators/components/web/templates/api_definition.php b/cake/libs/generator/generators/class_templates/web/templates/api_definition.php
similarity index 100%
rename from libs/generator/generators/components/web/templates/api_definition.php
rename to cake/libs/generator/generators/class_templates/web/templates/api_definition.php
diff --git a/libs/generator/generators/components/web/templates/controller.php b/cake/libs/generator/generators/class_templates/web/templates/controller.php
similarity index 100%
rename from libs/generator/generators/components/web/templates/controller.php
rename to cake/libs/generator/generators/class_templates/web/templates/controller.php
diff --git a/libs/generator/generators/components/web/templates/functional_test.php b/cake/libs/generator/generators/class_templates/web/templates/functional_test.php
similarity index 100%
rename from libs/generator/generators/components/web/templates/functional_test.php
rename to cake/libs/generator/generators/class_templates/web/templates/functional_test.php
diff --git a/libs/generator/generators/components/web/web_generator.php b/cake/libs/generator/generators/class_templates/web/web_generator.php
similarity index 100%
rename from libs/generator/generators/components/web/web_generator.php
rename to cake/libs/generator/generators/class_templates/web/web_generator.php
diff --git a/libs/generator/lookup.php b/cake/libs/generator/lookup.php
similarity index 100%
rename from libs/generator/lookup.php
rename to cake/libs/generator/lookup.php
diff --git a/libs/generator/manifest.php b/cake/libs/generator/manifest.php
similarity index 100%
rename from libs/generator/manifest.php
rename to cake/libs/generator/manifest.php
diff --git a/libs/generator/options.php b/cake/libs/generator/options.php
similarity index 100%
rename from libs/generator/options.php
rename to cake/libs/generator/options.php
diff --git a/libs/generator/scripts.php b/cake/libs/generator/scripts.php
similarity index 100%
rename from libs/generator/scripts.php
rename to cake/libs/generator/scripts.php
diff --git a/libs/generator/scripts/destroy.php b/cake/libs/generator/scripts/destroy.php
similarity index 100%
rename from libs/generator/scripts/destroy.php
rename to cake/libs/generator/scripts/destroy.php
diff --git a/libs/generator/scripts/generate.php b/cake/libs/generator/scripts/generate.php
similarity index 100%
rename from libs/generator/scripts/generate.php
rename to cake/libs/generator/scripts/generate.php
diff --git a/libs/generator/scripts/update.php b/cake/libs/generator/scripts/update.php
similarity index 100%
rename from libs/generator/scripts/update.php
rename to cake/libs/generator/scripts/update.php
diff --git a/libs/generator/simple_logger.php b/cake/libs/generator/simple_logger.php
similarity index 100%
rename from libs/generator/simple_logger.php
rename to cake/libs/generator/simple_logger.php
diff --git a/libs/generator/spec.php b/cake/libs/generator/spec.php
similarity index 100%
rename from libs/generator/spec.php
rename to cake/libs/generator/spec.php
diff --git a/libs/inflector.php b/cake/libs/inflector.php
similarity index 100%
rename from libs/inflector.php
rename to cake/libs/inflector.php
diff --git a/libs/legacy.php b/cake/libs/legacy.php
similarity index 100%
rename from libs/legacy.php
rename to cake/libs/legacy.php
diff --git a/libs/log.php b/cake/libs/log.php
similarity index 100%
rename from libs/log.php
rename to cake/libs/log.php
diff --git a/libs/dbo.php b/cake/libs/model/dbo/dbo.php
similarity index 100%
rename from libs/dbo.php
rename to cake/libs/model/dbo/dbo.php
diff --git a/libs/dbo/dbo_adodb.php b/cake/libs/model/dbo/dbo_adodb.php
similarity index 100%
rename from libs/dbo/dbo_adodb.php
rename to cake/libs/model/dbo/dbo_adodb.php
diff --git a/libs/dbo_factory.php b/cake/libs/model/dbo/dbo_factory.php
similarity index 92%
rename from libs/dbo_factory.php
rename to cake/libs/model/dbo/dbo_factory.php
index af0b4d104..761835a5d 100644
--- a/libs/dbo_factory.php
+++ b/cake/libs/model/dbo/dbo_factory.php
@@ -78,7 +78,7 @@ class DboFactory extends Object
// special case for AdoDB -- driver name in the form of 'adodb-drivername'
if (preg_match('#^adodb[\-_](.*)$#i', $config['driver'], $res))
{
- uses('dbo/dbo_adodb');
+ uses('model'.DS.'dbo'.DS.'dbo_adodb');
$config['driver'] = $res[1];
$instance[0] =& new DBO_AdoDB($config);
@@ -86,7 +86,7 @@ class DboFactory extends Object
// special case for PEAR:DB -- driver name in the form of 'pear-drivername'
elseif (preg_match('#^pear[\-_](.*)$#i', $config['driver'], $res))
{
- uses('dbo/dbo_pear');
+ uses('model'.DS.'dbo'.DS.'dbo_pear');
$config['driver'] = $res[1];
$instance[0] =& new DBO_Pear($config);
@@ -95,11 +95,11 @@ class DboFactory extends Object
else
{
$db_driver_class = 'DBO_'.$config['driver'];
- $db_driver_fn = LIBS.strtolower('dbo'.DS.$db_driver_class.'.php');
+ $db_driver_fn = LIBS.strtolower('model'.DS.'dbo'.DS.$db_driver_class.'.php');
if (file_exists($db_driver_fn))
{
- uses(strtolower('dbo'.DS.$db_driver_class));
+ uses(strtolower('model'.DS.'dbo'.DS.$db_driver_class));
$instance[0] =& new $db_driver_class($config);
}
else
diff --git a/libs/dbo/dbo_generic.php b/cake/libs/model/dbo/dbo_generic.php
similarity index 100%
rename from libs/dbo/dbo_generic.php
rename to cake/libs/model/dbo/dbo_generic.php
diff --git a/libs/dbo/dbo_mysql.php b/cake/libs/model/dbo/dbo_mysql.php
similarity index 99%
rename from libs/dbo/dbo_mysql.php
rename to cake/libs/model/dbo/dbo_mysql.php
index b674c3a23..075448dc9 100644
--- a/libs/dbo/dbo_mysql.php
+++ b/cake/libs/model/dbo/dbo_mysql.php
@@ -35,7 +35,7 @@
/**
* Include DBO.
*/
-uses('dbo');
+uses('model'.DS.'dbo'.DS.'dbo');
/**
* Short description for class.
diff --git a/libs/dbo/dbo_pear.php b/cake/libs/model/dbo/dbo_pear.php
similarity index 99%
rename from libs/dbo/dbo_pear.php
rename to cake/libs/model/dbo/dbo_pear.php
index 55bbc325a..64bce128b 100644
--- a/libs/dbo/dbo_pear.php
+++ b/cake/libs/model/dbo/dbo_pear.php
@@ -34,7 +34,7 @@
/**
* Create an include path required PEAR libraries.
*/
-uses('dbo');
+uses('model'.DS.'dbo'.DS.'dbo');
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . PEAR);
vendor('Pear/DB');
diff --git a/libs/dbo/dbo_postgres.php b/cake/libs/model/dbo/dbo_postgres.php
similarity index 99%
rename from libs/dbo/dbo_postgres.php
rename to cake/libs/model/dbo/dbo_postgres.php
index 87d19e6ef..d69e7fa48 100644
--- a/libs/dbo/dbo_postgres.php
+++ b/cake/libs/model/dbo/dbo_postgres.php
@@ -34,7 +34,7 @@
/**
* Include DBO.
*/
-uses('dbo');
+uses('model'.DS.'dbo'.DS.'dbo');
/**
* PostgreSQL layer for DBO.
diff --git a/libs/dbo/dbo_sqlite.php b/cake/libs/model/dbo/dbo_sqlite.php
similarity index 99%
rename from libs/dbo/dbo_sqlite.php
rename to cake/libs/model/dbo/dbo_sqlite.php
index 402a931f1..f6f8efb7b 100644
--- a/libs/dbo/dbo_sqlite.php
+++ b/cake/libs/model/dbo/dbo_sqlite.php
@@ -34,7 +34,7 @@
/**
* Include DBO.
*/
-uses('dbo');
+uses('model'.DS.'dbo'.DS.'dbo');
/**
* DBO implementation for the SQLite DBMS.
diff --git a/libs/model.php b/cake/libs/model/model.php
similarity index 99%
rename from libs/model.php
rename to cake/libs/model/model.php
index 0fea7d24f..298d64159 100644
--- a/libs/model.php
+++ b/cake/libs/model/model.php
@@ -1207,7 +1207,7 @@ class Model extends Object
foreach ($conditions as $key=>$value)
{
$slashedValue = (ini_get('magic_quotes_gpc') == 1) ? $this->db->prepare(stripslashes($value)) : $this->db->prepare($value);
-
+ //Should remove the = below so LIKE and other compares can be used
$out[] = "{$key}=".($value===null? 'null': $slashedValue);
}
return join(' and ', $out);
@@ -1349,22 +1349,18 @@ class Model extends Object
}
$count++;
}
- if(empty($newValue2) && !empty($original))
+ if(empty($newValue) && !empty($original))
{
for ($i = 0; $i< count($original); $i++)
{
- $newValue2[$i] = $original[$i];
- }
- if(count($this->_oneToMany < 2))
- {
- $newValue = $newValue2;
+ $newValue[$i] = $original[$i];
}
}
elseif(!empty($original))
{
for ($i = 0; $i< count($original); $i++)
{
- $newValue[$i] = array_merge($newValue2[$i], $original[$i]);
+ $newValue[$i] = array_merge($newValue[$i], $original[$i]);
}
}
$this->joinedHasMany[] = new NeatArray($this->db->fields($table));
@@ -1667,7 +1663,7 @@ class Model extends Object
*/
function _throwMissingTable($tableName)
{
- $error = new AppController();
+ $error =& new AppController();
$error->missingTable = get_class($this);
call_user_func_array(array(&$error, 'missingTable'), $tableName);
exit;
@@ -1679,7 +1675,7 @@ class Model extends Object
*/
function _throwMissingConnection()
{
- $error = new AppController();
+ $error =& new AppController();
$error->missingConnection = get_class($this);
call_user_func_array(array(&$error, 'missingConnection'), null);
exit;
diff --git a/libs/neat_array.php b/cake/libs/neat_array.php
similarity index 53%
rename from libs/neat_array.php
rename to cake/libs/neat_array.php
index aa73696c2..4253e0915 100644
--- a/libs/neat_array.php
+++ b/cake/libs/neat_array.php
@@ -42,27 +42,27 @@
*/
class NeatArray
{
- /**
+ /**
* Value of NeatArray.
*
* @var array
* @access public
*/
- var $value;
+ var $value;
- /**
+ /**
* Constructor. Defaults to an empty array.
*
* @param array $value
* @access public
* @uses NeatArray::value
*/
- function NeatArray ($value=array())
- {
- $this->value = $value;
- }
+ function NeatArray ($value=array())
+ {
+ $this->value = $value;
+ }
- /**
+ /**
* Finds and returns records with $fieldName equal to $value from this NeatArray.
*
* @param string $fieldName
@@ -71,49 +71,49 @@ class NeatArray
* @access public
* @uses NeatArray::value
*/
- function findIn ($fieldName, $value)
- {
- if (!is_array($this->value))
- {
- return false;
- }
+ function findIn ($fieldName, $value)
+ {
+ if (!is_array($this->value))
+ {
+ return false;
+ }
- $out = false;
- foreach ($this->value as $k=>$v)
- {
- if (isset($v[$fieldName]) && ($v[$fieldName] == $value))
- {
- $out[$k] = $v;
- }
- }
+ $out = false;
+ foreach ($this->value as $k=>$v)
+ {
+ if (isset($v[$fieldName]) && ($v[$fieldName] == $value))
+ {
+ $out[$k] = $v;
+ }
+ }
- return $out;
- }
+ return $out;
+ }
- /**
+ /**
* Checks if $this->value is an array, and removes all empty elements.
*
* @access public
* @uses NeatArray::value
*/
- function cleanup ()
- {
- $out = is_array($this->value)? array(): null;
- foreach ($this->value as $k=>$v)
- {
- if ($v == "0")
- {
- $out[$k] = $v;
- }
- elseif ($v)
- {
- $out[$k] = $v;
- }
- }
- $this->value = $out;
- }
+ function cleanup ()
+ {
+ $out = is_array($this->value)? array(): null;
+ foreach ($this->value as $k=>$v)
+ {
+ if ($v == "0")
+ {
+ $out[$k] = $v;
+ }
+ elseif ($v)
+ {
+ $out[$k] = $v;
+ }
+ }
+ $this->value = $out;
+ }
- /**
+ /**
* Adds elements from given array to itself.
*
* @param string $value
@@ -121,12 +121,12 @@ class NeatArray
* @access public
* @uses NeatArray::value
*/
- function add ($value)
- {
- return ($this->value = $this->plus($value))? true: false;
- }
+ function add ($value)
+ {
+ return ($this->value = $this->plus($value))? true: false;
+ }
- /**
+ /**
* Returns itself merged with given array.
*
* @param array $value Array to add to NeatArray.
@@ -134,12 +134,12 @@ class NeatArray
* @access public
* @uses NeatArray::value
*/
- function plus ($value)
- {
- return array_merge($this->value, (is_array($value)? $value: array($value)));
- }
+ function plus ($value)
+ {
+ return array_merge($this->value, (is_array($value)? $value: array($value)));
+ }
- /**
+ /**
* Counts repeating strings and returns an array of totals.
*
* @param int $sortedBy A value of 1 sorts by values, a value of 2 sorts by keys. Defaults to null (no sorting).
@@ -147,39 +147,39 @@ class NeatArray
* @access public
* @uses NeatArray::value
*/
- function totals ($sortedBy=1,$reverse=true)
- {
- $out = array();
- foreach ($this->value as $val)
- {
- isset($out[$val])? $out[$val]++: $out[$val] = 1;
- }
+ function totals ($sortedBy=1,$reverse=true)
+ {
+ $out = array();
+ foreach ($this->value as $val)
+ {
+ isset($out[$val])? $out[$val]++: $out[$val] = 1;
+ }
- if ($sortedBy == 1)
- {
- $reverse? arsort($out, SORT_NUMERIC): asort($out, SORT_NUMERIC);
- }
+ if ($sortedBy == 1)
+ {
+ $reverse? arsort($out, SORT_NUMERIC): asort($out, SORT_NUMERIC);
+ }
- if ($sortedBy == 2)
- {
- $reverse? krsort($out, SORT_STRING): ksort($out, SORT_STRING);
- }
+ if ($sortedBy == 2)
+ {
+ $reverse? krsort($out, SORT_STRING): ksort($out, SORT_STRING);
+ }
- return $out;
- }
+ return $out;
+ }
- /**
+ /**
* Performs an array_filter() on the contents of this NeatArray.
*
* @param string $with Name of callback function to perform on each element of this NeatArray.
* @return array
*/
- function filter ($with)
- {
- return $this->value = array_filter($this->value, $with);
- }
+ function filter ($with)
+ {
+ return $this->value = array_filter($this->value, $with);
+ }
- /**
+ /**
* Passes each of its values through a specified function or method. Think of PHP's {@link http://php.net/array_walk array_walk()}.
*
* @param string $with Name of callback function
@@ -187,67 +187,67 @@ class NeatArray
* @access public
* @uses NeatArray::value
*/
- function walk ($with)
- {
- array_walk($this->value, $with);
- return $this->value;
- }
+ function walk ($with)
+ {
+ array_walk($this->value, $with);
+ return $this->value;
+ }
- /**
+ /**
* Apply $template to all elements of this NeatArray, and return the array itself.
*
* @param string $template {@link http://php.net/sprintf sprintf()}-compatible string to be applied to all values of this NeatArray.
* @return array
*/
- function sprintf($template)
- {
- for ($ii=0; $iivalue); $ii++)
- {
- $this->value[$ii] = sprintf($template, $this->value[$ii]);
- }
+ function sprintf($template)
+ {
+ for ($ii=0; $iivalue); $ii++)
+ {
+ $this->value[$ii] = sprintf($template, $this->value[$ii]);
+ }
- return $this->value;
- }
+ return $this->value;
+ }
- /**
+ /**
* Extracts a value from all array items.
*
* @return array
* @access public
* @uses NeatArray::value
*/
- function extract ($name)
- {
- $out = array();
- foreach ($this->value as $val)
- {
- if (isset($val[$name]))
- $out[] = $val[$name];
- }
- return $out;
- }
+ function extract ($name)
+ {
+ $out = array();
+ foreach ($this->value as $val)
+ {
+ if (isset($val[$name]))
+ $out[] = $val[$name];
+ }
+ return $out;
+ }
- /**
+ /**
* Returns a list of unique elements.
*
* @return array
*/
- function unique ()
- {
- return array_unique($this->value);
- }
+ function unique ()
+ {
+ return array_unique($this->value);
+ }
- /**
+ /**
* Removes duplicate elements from the value and returns it.
*
* @return array
*/
- function makeUnique ()
- {
- return $this->value = array_unique($this->value);
- }
+ function makeUnique ()
+ {
+ return $this->value = array_unique($this->value);
+ }
- /**
+ /**
* Joins an array with myself using a key (like a join between database tables).
*
* Example:
@@ -279,33 +279,33 @@ class NeatArray
* @param string $onHis Key to use on him.
* @return array
*/
- function joinWith ($his, $onMine, $onHis=null)
- {
- if (empty($onHis))
- {
- $onHis = $onMine;
- }
+ function joinWith ($his, $onMine, $onHis=null)
+ {
+ if (empty($onHis))
+ {
+ $onHis = $onMine;
+ }
- $his = new NeatArray($his);
+ $his = new NeatArray($his);
- $out = array();
- foreach ($this->value as $key=>$val)
- {
- if ($fromHis = $his->findIn($onHis, $val[$onMine]))
- {
- list($fromHis) = array_values($fromHis);
- $out[$key] = array_merge($val, $fromHis);
- }
- else
- {
- $out[$key] = $val;
- }
- }
+ $out = array();
+ foreach ($this->value as $key=>$val)
+ {
+ if ($fromHis = $his->findIn($onHis, $val[$onMine]))
+ {
+ list($fromHis) = array_values($fromHis);
+ $out[$key] = array_merge($val, $fromHis);
+ }
+ else
+ {
+ $out[$key] = $val;
+ }
+ }
- return $this->value = $out;
- }
+ return $this->value = $out;
+ }
- /**
+ /**
* Enter description here...
* @todo Explain this function. almost looks like it creates a tree
*
@@ -315,26 +315,71 @@ class NeatArray
* @param string $childrenKey
* @return array
*/
- function threaded ($root=null, $idKey='id', $parentIdKey='parent_id', $childrenKey='children')
- {
- $out = array();
+ function threaded ($root=null, $idKey='id', $parentIdKey='parent_id', $childrenKey='children')
+ {
+ $out = array();
- for ($ii=0; $iivalue); $ii++)
- {
- if ($this->value[$ii][$parentIdKey] == $root)
+ for ($ii=0; $iivalue); $ii++)
+ {
+ if ($this->value[$ii][$parentIdKey] == $root)
+ {
+ $tmp = $this->value[$ii];
+ $tmp[$childrenKey] = isset($this->value[$ii][$idKey])?
+ $this->threaded($this->value[$ii][$idKey], $idKey, $parentIdKey, $childrenKey):
+ null;
+ $out[] = $tmp;
+ }
+ }
+
+ return $out;
+ }
+
+
+ /**
+ * Array multi search
+ *
+ * @param string $search_value
+ * @param array $the_array
+ * @return array
+ * @link http://php.net/array_search#47116
+ */
+ function multi_search($search_value, $the_array=null)
+ {
+ if ( $the_array == null )
+ {
+ $the_array = $this->value;
+ }
+
+ if (is_array($the_array))
+ {
+ foreach ($the_array as $key => $value)
+ {
+ $result = $this->multi_search($search_value, $value);
+ if (is_array($result))
{
- $tmp = $this->value[$ii];
- $tmp[$childrenKey] = isset($this->value[$ii][$idKey])?
- $this->threaded($this->value[$ii][$idKey], $idKey, $parentIdKey, $childrenKey):
- null;
- $out[] = $tmp;
+ $return = $result;
+ array_unshift($return, $key);
+ return $return;
}
- }
-
- return $out;
- }
+ elseif ($result == true)
+ {
+ $return[] = $key;
+ return $return;
+ }
+ }
+ return false;
+ }
+ else
+ {
+ if ($search_value == $the_array)
+ {
+ return true;
+ }
+ else return false;
+ }
+ }
}
-?>
\ No newline at end of file
+?>
diff --git a/libs/neat_string.php b/cake/libs/neat_string.php
similarity index 100%
rename from libs/neat_string.php
rename to cake/libs/neat_string.php
diff --git a/cake/libs/new_inflector.php b/cake/libs/new_inflector.php
new file mode 100644
index 000000000..98fe2d1c4
--- /dev/null
+++ b/cake/libs/new_inflector.php
@@ -0,0 +1,142 @@
+
+ * Copyright (c) 2005, CakePHP Authors/Developers
+ *
+ * Author(s): Michal Tatarynowicz aka Pies
+ * Larry E. Masters aka PhpNut
+ * Kamil Dzielinski aka Brego
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @author CakePHP Authors/Developers
+ * @copyright Copyright (c) 2005, CakePHP Authors/Developers
+ * @link https://trac.cakephp.org/wiki/Authors Authors/Developers
+ * @package cake
+ * @subpackage cake.libs
+ * @since CakePHP v .0.10.x.x
+ * @version $Revision$
+ * @modifiedby $LastChangedBy$
+ * @lastmodified $Date$
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Short description for class
+ *
+ * Inflector pluralizes and singularizes English words.
+ *
+ * @package cake
+ * @subpackage cake.libs
+ * @since CakePHP v .0.10.x.x
+ */
+class Inflector
+{
+ var $classical = array();
+
+ function __construct()
+ {
+ }
+
+ function pluralize($text, $type = 'Noun' , $classical = false)
+ {
+ $this->classical = $classical;
+ $this->count = count($text);
+
+ return $this->_plural.$type($text);
+ }
+
+ function singularize($text, $type = 'Noun' , $classical = false)
+ {
+ $this->classical = $classical;
+ $this->count = count($text);
+
+ return $this->_singular.$type($text);
+ }
+
+ function _pluralNoun($text)
+ {
+ return $pluralText;
+ }
+
+ function _pluralVerb($text)
+ {
+ return $pluralText;
+ }
+
+ function _pluralAdjective($text)
+ {
+ return $pluralText;
+ }
+
+ function _pluralSpecialNoun($text)
+ {
+ return $pluralText;
+ }
+
+ function _pluralSpecialVerb($text)
+ {
+ return $pluralText;
+ }
+
+ function _pluralGeneralVerb($text)
+ {
+ return $pluralText;
+ }
+
+ function _pluralSpecialAdjective($text)
+ {
+ return $pluralText;
+ }
+
+ function _singularNoun($text)
+ {
+ return $text;
+ }
+
+ function _singularVerb($text)
+ {
+ return $singularText;
+ }
+
+ function _singularAdjective($text)
+ {
+ return $singularText;
+ }
+
+ function _singularSpecialNoun($text)
+ {
+ return $singularText;
+ }
+
+ function _singularSpecialVerb($text)
+ {
+ return $singularText;
+ }
+
+ function _singularGeneralVerb($text)
+ {
+ return $singularText;
+ }
+
+ function _singularSpecialAdjective($text)
+ {
+ return $singularText;
+ }
+
+ function _enclose($string)
+ {
+ return '"(?:'.$string.')"';
+ }
+}
+?>
\ No newline at end of file
diff --git a/libs/object.php b/cake/libs/object.php
similarity index 100%
rename from libs/object.php
rename to cake/libs/object.php
diff --git a/libs/router.php b/cake/libs/router.php
similarity index 100%
rename from libs/router.php
rename to cake/libs/router.php
diff --git a/libs/sanitize.php b/cake/libs/sanitize.php
similarity index 91%
rename from libs/sanitize.php
rename to cake/libs/sanitize.php
index e1f3eaac5..6935d8a8e 100644
--- a/libs/sanitize.php
+++ b/cake/libs/sanitize.php
@@ -1,198 +1,198 @@
-
- * Copyright (c) 2005, CakePHP Authors/Developers
- *
- * Author(s): Michal Tatarynowicz aka Pies
- * Larry E. Masters aka PhpNut
- * Kamil Dzielinski aka Brego
- *
- * Licensed under The MIT License
- * Redistributions of files must retain the above copyright notice.
- *
- * @filesource
- * @author CakePHP Authors/Developers
- * @copyright Copyright (c) 2005, CakePHP Authors/Developers
- * @link https://trac.cakephp.org/wiki/Authors Authors/Developers
- * @package cake
- * @subpackage cake.libs
- * @since CakePHP v 0.9.2
- * @version $Revision: 491 $
- * @modifiedby $LastChangedBy: phpnut $
- * @lastmodified $Date: 2005-07-31 13:31:45 -0500 (Sun, 31 Jul 2005) $
- * @license http://www.opensource.org/licenses/mit-license.php The MIT License
- */
-
-/**
- * Data Sanitization.
- *
- * Long description for class
- *
- * @package cake
- * @subpackage cake.libs
- * @since CakePHP v 0.9.2
- *
- */
-class Sanitize
-{
-
-/**
- * Removes any non-alphanumeric characters.
- *
- * @param string $string
- * @return string
- */
- function paranoid($string)
- {
- return preg_replace("/[^a-zA-Z0-9]/", "", $string);
- }
-
-/**
- * Makes a string SQL-safe by adding slashes (if needed).
- *
- * @param string $string
- * @return string
- */
- function sql($string)
- {
- if (!ini_get('magic_quotes_gpc'))
- {
- $string = addslashes($string);
- }
-
- return $string;
- }
-
-/**
- * Makes the string safe for display as HTML. Renders entities and converts newlines to .
- *
- * @param string $string
- * @param boolean $remove
- * @return string
- */
- function html($string, $remove = false)
- {
- if ($remove)
- {
- $string = strip_tags($string);
- }
- else
- {
- $patterns = array("/\&/", "/%/", "/", "/>/", '/"/', "/'/", "/\(/", "/\)/", "/\+/", "/-/", "/\n/");
- $replacements = array("&", "%", "<", ">", """, "'", "(", ")", "+", "-", " ");
- $string = preg_replace($patterns, $replacements, $string);
- }
-
- return $string;
- }
-
-/**
- * Recursively sanitizes an array of data for safe input.
- *
- * @param mixed $toClean
- * @return mixed
- */
- function cleanArray(&$toClean)
- {
- return $this->cleanArrayR($toClean);
- }
-
-/**
- * Private method used for recursion (see cleanArray()).
- *
- * @param array $toClean
- * @return array
- */
- function cleanArrayR(&$toClean)
- {
- if (is_array($toClean))
- {
- while(list($k, $v) = each($toClean))
- {
- if ( is_array($toClean[$k]) )
- {
- $this->cleanArray($toClean[$k]);
- }
- else
- {
- $toClean[$k] = $this->cleanValue($v);
- }
- }
- }
- else
- {
- return null;
- }
- }
-
-/**
- * Do we really need to sanitize array keys? If so, we can use this code...
-
- function cleanKey($key)
- {
- if ($key == "")
- {
- return "";
- }
-
- //URL decode and convert chars to HTML entities
- $key = htmlspecialchars(urldecode($key));
- //Remove ..
- $key = preg_replace( "/\.\./", "", $key );
- //Remove __FILE__, etc.
- $key = preg_replace( "/\_\_(.+?)\_\_/", "", $key );
- //Trim word chars, '.', '-', '_'
- $key = preg_replace( "/^([\w\.\-\_]+)$/", "$1", $key );
-
- return $key;
- }
- */
-
-/**
- * Method used by cleanArray() to sanitized array nodes.
- *
- * @param string $val
- * @return string
- */
- function cleanValue($val)
- {
- if ($val == "")
- {
- return "";
- }
-
- //Replace odd spaces with safe ones
- $val = str_replace(" ", " ", $val);
- $val = str_replace(chr(0xCA), "", $val);
-
- //Encode any HTML to entities (including \n --> )
- $val = $this->html($val);
-
- //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 (?)
- $val = preg_replace("/&#([0-9]+);/s", "\\1;", $val );
-
- //Add slashes for SQL
- $val = $this->sql($val);
-
- //Swap user-inputted backslashes (?)
- $val = preg_replace( "/\\\(?!&#|\?#)/", "\\", $val );
-
- return $val;
- }
-}
+
+ * Copyright (c) 2005, CakePHP Authors/Developers
+ *
+ * Author(s): Michal Tatarynowicz aka Pies
+ * Larry E. Masters aka PhpNut
+ * Kamil Dzielinski aka Brego
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @author CakePHP Authors/Developers
+ * @copyright Copyright (c) 2005, CakePHP Authors/Developers
+ * @link https://trac.cakephp.org/wiki/Authors Authors/Developers
+ * @package cake
+ * @subpackage cake.libs
+ * @since CakePHP v 0.9.2
+ * @version $Revision$
+ * @modifiedby $LastChangedBy$
+ * @lastmodified $Date$
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Data Sanitization.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.libs
+ * @since CakePHP v 0.9.2
+ *
+ */
+class Sanitize
+{
+
+/**
+ * Removes any non-alphanumeric characters.
+ *
+ * @param string $string
+ * @return string
+ */
+ function paranoid($string)
+ {
+ return preg_replace("/[^a-zA-Z0-9]/", "", $string);
+ }
+
+/**
+ * Makes a string SQL-safe by adding slashes (if needed).
+ *
+ * @param string $string
+ * @return string
+ */
+ function sql($string)
+ {
+ if (!ini_get('magic_quotes_gpc'))
+ {
+ $string = addslashes($string);
+ }
+
+ return $string;
+ }
+
+/**
+ * Makes the string safe for display as HTML. Renders entities and converts newlines to .
+ *
+ * @param string $string
+ * @param boolean $remove
+ * @return string
+ */
+ function html($string, $remove = false)
+ {
+ if ($remove)
+ {
+ $string = strip_tags($string);
+ }
+ else
+ {
+ $patterns = array("/\&/", "/%/", "/", "/>/", '/"/', "/'/", "/\(/", "/\)/", "/\+/", "/-/", "/\n/");
+ $replacements = array("&", "%", "<", ">", """, "'", "(", ")", "+", "-", " ");
+ $string = preg_replace($patterns, $replacements, $string);
+ }
+
+ return $string;
+ }
+
+/**
+ * Recursively sanitizes an array of data for safe input.
+ *
+ * @param mixed $toClean
+ * @return mixed
+ */
+ function cleanArray(&$toClean)
+ {
+ return $this->cleanArrayR($toClean);
+ }
+
+/**
+ * Private method used for recursion (see cleanArray()).
+ *
+ * @param array $toClean
+ * @return array
+ */
+ function cleanArrayR(&$toClean)
+ {
+ if (is_array($toClean))
+ {
+ while(list($k, $v) = each($toClean))
+ {
+ if ( is_array($toClean[$k]) )
+ {
+ $this->cleanArray($toClean[$k]);
+ }
+ else
+ {
+ $toClean[$k] = $this->cleanValue($v);
+ }
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+/**
+ * Do we really need to sanitize array keys? If so, we can use this code...
+
+ function cleanKey($key)
+ {
+ if ($key == "")
+ {
+ return "";
+ }
+
+ //URL decode and convert chars to HTML entities
+ $key = htmlspecialchars(urldecode($key));
+ //Remove ..
+ $key = preg_replace( "/\.\./", "", $key );
+ //Remove __FILE__, etc.
+ $key = preg_replace( "/\_\_(.+?)\_\_/", "", $key );
+ //Trim word chars, '.', '-', '_'
+ $key = preg_replace( "/^([\w\.\-\_]+)$/", "$1", $key );
+
+ return $key;
+ }
+ */
+
+/**
+ * Method used by cleanArray() to sanitized array nodes.
+ *
+ * @param string $val
+ * @return string
+ */
+ function cleanValue($val)
+ {
+ if ($val == "")
+ {
+ return "";
+ }
+
+ //Replace odd spaces with safe ones
+ $val = str_replace(" ", " ", $val);
+ $val = str_replace(chr(0xCA), "", $val);
+
+ //Encode any HTML to entities (including \n --> )
+ $val = $this->html($val);
+
+ //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 (?)
+ $val = preg_replace("/&#([0-9]+);/s", "\\1;", $val );
+
+ //Add slashes for SQL
+ $val = $this->sql($val);
+
+ //Swap user-inputted backslashes (?)
+ $val = preg_replace( "/\\\(?!&#|\?#)/", "\\", $val );
+
+ return $val;
+ }
+}
?>
\ No newline at end of file
diff --git a/libs/time.php b/cake/libs/time.php
similarity index 100%
rename from libs/time.php
rename to cake/libs/time.php
diff --git a/libs/validators.php b/cake/libs/validators.php
similarity index 100%
rename from libs/validators.php
rename to cake/libs/validators.php
diff --git a/libs/helper.php b/cake/libs/view/helper.php
similarity index 98%
rename from libs/helper.php
rename to cake/libs/view/helper.php
index 2ce1a1bc5..be07bd99e 100644
--- a/libs/helper.php
+++ b/cake/libs/view/helper.php
@@ -129,6 +129,12 @@ class Helper extends Object
$this->tags[$keyName]);
}
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $fileName
+ * @return unknown
+ */
function readConfigFile ($fileName)
{
$fileLineArray = file($fileName);
diff --git a/libs/helpers/acl.php b/cake/libs/view/helpers/acl.php
similarity index 100%
rename from libs/helpers/acl.php
rename to cake/libs/view/helpers/acl.php
diff --git a/libs/helpers/ajax.php b/cake/libs/view/helpers/ajax.php
similarity index 82%
rename from libs/helpers/ajax.php
rename to cake/libs/view/helpers/ajax.php
index c865bcbf7..1ec3eadc7 100644
--- a/libs/helpers/ajax.php
+++ b/cake/libs/view/helpers/ajax.php
@@ -43,12 +43,11 @@
*
*/
-uses('helpers/html', 'helpers/javascript');
-
class AjaxHelper extends Helper
{
+ var $helpers = array('html', 'javascript');
var $callbacks = array('uninitialized', 'loading', 'loaded', 'interactive', 'complete');
@@ -118,19 +117,22 @@ class AjaxHelper extends Helper
* - after:: Called immediately after request was
* initiated and before loading.
*
- * @param HtmlHelper $html The HtmlHelper object which is creating link.
* @param string $title Title of link
* @param array $options Options for JavaScript function
- * @param array $html_options Options for link
* @return string HTML code for link to remote action
*/
- function linkToRemote ($html, $title, $options = null, $html_options = null)
+ function linkToRemote ($title, $options = null, $html_options = null)
{
- $html_options['onclick'] = $this->remoteFunction($html, $options);
-
- $href = (!empty($options['fallback'])) ? $options['fallback'] : '#';
-
- return $html->link($title, $href, $html_options);
+ $href = (!empty($options['fallback'])) ? $options['fallback'] : '#';
+ if(isset($html_options['id']))
+ {
+ return $this->html->link($title, $href, $html_options) . $this->javascript->event("$('{$html_options['id']}')", "click", "function() {" . $this->remoteFunction($options) . "; return true; }");
+ }
+ else
+ {
+ $html_options['onclick'] = $this->remoteFunction($options);
+ return $this->html->link($title, $href, $html_options);
+ }
}
/**
@@ -144,12 +146,12 @@ class AjaxHelper extends Helper
* @param array $options options for javascript
* @return string html code for link to remote action
*/
- function remoteFunction ($html, $options = null)
+ function remoteFunction ($options = null)
{
$javascript_options = $this->_optionsForAjax($options);
$func = isset($options['update']) ? "new Ajax.Updater('{$options['update']}'," : "new Ajax.Request(";
- $func .= "'" . $html->url(isset($options['url']) ? $options['url'] : "") . "'";
+ $func .= "'" . $this->html->url(isset($options['url']) ? $options['url'] : "") . "'";
$func .= "$javascript_options)";
if (isset($options['before']))
@@ -166,8 +168,7 @@ class AjaxHelper extends Helper
}
if (isset($options['confirm']))
{
- $js = new JavascriptHelper;
- $func = "if (confirm('" . $js->escapeScript($options['confirm']) . "')) { $func; } else { return false; }";
+ $func = "if (confirm('" . $this->javascript->escapeScript($options['confirm']) . "')) { $func; } else { return false; }";
}
return $func;
}
@@ -179,15 +180,14 @@ class AjaxHelper extends Helper
* Usually used to update a specified div (options[update]) with the results of the remote call.
* The options for specifying the target with url and defining callbacks is the same as linkToRemote.
*
- * @param JavascriptHelper $script Script helper generating the block
* @param array $options Callback options
* @return string Javascript code
*/
- function remoteTimer ($script, $options = null)
+ function remoteTimer ($options = null)
{
$frequency = (isset($options['frequency']))? $options['frequency'] : 10;
$code = "new PeriodicalExecuter(function() {" . $this->remote_function($options) . "}, $frequency)";
- return $script->codeBlock($code);
+ return $this->javascript->codeBlock($code);
}
/**
@@ -198,17 +198,15 @@ class AjaxHelper extends Helper
* will work just like a regular submission as viewed by the receiving side (all elements available in params).
* The options for specifying the target with :url and defining callbacks is the same as link_to_remote.
*
- * @param HtmlHelper $html HtmlHelper creating this form
- * @param JavascriptHelper $script JavascriptHelper creating this form
* @param string $id Form id
* @param array $options Callback options
* @return string JavaScript code
*/
- function form($html, $script, $id, $options = null)
+ function form($id, $options = null)
{
$options['id'] = $id;
//$options['html']['onsubmit'] = $this->remoteFunction($options) . "; return false;";
- return $html->formTag(null, "post", $options) . $script->event("$('$id')", "submit", "function(){" . $this->remoteFunction($html, $options) . "; return false;}");
+ return $this->html->formTag(null, "post", $options) . $this->javascript->event("$('$id')", "submit", "function(){" . $this->remoteFunction($options) . "; return false;}");
}
/**
@@ -217,20 +215,19 @@ class AjaxHelper extends Helper
* Returns a button input tag that will submit form using XMLHttpRequest in the background instead of regular
* reloading POST arrangement. options argument is the same as in form_remote_tag
*
- * @param HtmlHelper $html HtmlHelper creating this form
* @param string $name Input button name
* @param string $value Input button value
* @param array $options Callback options
* @return string Ajaxed input button
*/
- function submit ($html, $name, $value, $options = null)
+ function submit ($name, $value, $options = null)
{
$options['with'] = 'Form.serialize(this.form)';
$options['html']['type'] = 'button';
- $options['html']['onclick'] = $this->remoteFunction($html, $options) . "; return false;";
+ $options['html']['onclick'] = $this->remoteFunction($options) . "; return false;";
$options['html']['name'] = $name;
$options['html']['value'] = $value;
- return $html->tag("input", $options['html'], false);
+ return $this->html->tag("input", $options['html'], false);
}
/**
@@ -257,18 +254,17 @@ class AjaxHelper extends Helper
* Additionally, you may specify any of the options documented in
* @see linkToRemote().
*
- * @param JavaScriptHelper $script
* @param string $field_id DOM ID of field to observe
* @param array $options ajax options
* @return string ajax script
*/
- function observeField ($html, $script, $field_id, $options = null)
+ function observeField ($field_id, $options = null)
{
if (!isset($options['with']))
{
$options['with'] = "Form.Element.serialize('$field_id')";
}
- return $script->codeBlock($this->_buildObserver($html, 'Form.Element.Observer', $field_id, $options));
+ return $this->javascript->codeBlock($this->_buildObserver('Form.Element.Observer', $field_id, $options));
}
/**
@@ -279,19 +275,17 @@ class AjaxHelper extends Helper
* the default value of the with option evaluates to the
* serialized (request string) value of the form.
*
- * @param HtmlHelper $html
- * @param JavaScriptHelper $script
* @param string $field_id DOM ID of field to observe
* @param array $options ajax options
* @return string ajax script
*/
- function observeForm ($html, $script, $field_id, $options = array())
+ function observeForm ($field_id, $options = array())
{
if (!isset($options['with']))
{
$options['with'] = 'Form.serialize(this.form)';
}
- return $script->codeBlock($this->_buildObserver($html, 'Form.Observer', $field_id, $options));
+ return $this->javascript->codeBlock($this->_buildObserver('Form.Observer', $field_id, $options));
}
/**
@@ -302,13 +296,11 @@ class AjaxHelper extends Helper
* options['with'] defaults to "Form.Element.serialize('$field_id')",
* but can be any valid javascript expression defining the
*
- * @param HtmlHelper $html
- * @param JavascriptHelper $script
* @param string $field_id DOM ID of field to observe
* @param array $options ajax options
* @return string ajax script
*/
- function autoComplete ($html, $script, $field, $url = "", $options = array())
+ function autoComplete ($field, $url = "", $options = array())
{
if (!isset($options['id']))
{
@@ -333,15 +325,17 @@ class AjaxHelper extends Helper
}
$divOptions = array('id' => $options['id'] . "_autoComplete", 'class' => "auto_complete");
- return $html->input($field, $htmlOptions) .
- $html->tag("div", $divOptions, true) . "" .
- $script->codeBlock("new Ajax.Autocompleter('" . $options['id'] . "', '" . $divOptions['id'] . "', '" . $html->url($url) . "', " . $this->_optionsForAjax($ajaxOptions) . ");");
+
+ return $this->html->input($field, $htmlOptions) .
+ $this->html->tag("div", $divOptions, true) . "" .
+ $this->javascript->codeBlock("new Ajax.Autocompleter('" . $options['id'] . "', '" .
+ $divOptions['id'] . "', '" . $this->html->url($url) . "', " . $this->_optionsForAjax($ajaxOptions) . ");");
}
- function drag($script, $id, $options = array())
+ function drag($id, $options = array())
{
$options = $this->_optionsForDraggable($options);
- return $script->codeBlock("new Draggable('$id'$options);");
+ return $this->javascript->codeBlock("new Draggable('$id'$options);");
}
function _optionsForDraggable ($options)
@@ -356,10 +350,10 @@ class AjaxHelper extends Helper
* http://wiki.script.aculo.us/scriptaculous/show/Droppables.add
*
*/
- function drop($html, $script, $id, $options = array())
+ function drop($id, $options = array())
{
$options = $this->_optionsForDroppable($options);
- return $script->codeBlock("Droppables.add('$id'$options);");
+ return $this->javascript->codeBlock("Droppables.add('$id'$options);");
}
function _optionsForDroppable ($options)
@@ -369,32 +363,29 @@ class AjaxHelper extends Helper
return $this->_buildOptions($options, $this->dropOptions);
}
- function dropRemote($html, $script, $id, $options = array(), $ajaxOptions = array())
+ function dropRemote($id, $options = array(), $ajaxOptions = array())
{
- $options['onDrop'] = "function(element){" . $this->remoteFunction($html, $ajaxOptions) . "}";
+ $options['onDrop'] = "function(element){" . $this->remoteFunction($ajaxOptions) . "}";
}
/**
* Makes a list or group of floated objects sortable.
*
*
- * @param HtmlHelper $html
- * @param JavaScriptHelper $script
* @param string $id DOM ID of parent
* @param array $options Array of options to control sort.http://wiki.script.aculo.us/scriptaculous/show/Sortable.create
* @link http://wiki.script.aculo.us/scriptaculous/show/Sortable.create
*/
- function sortable($html, $script, $id, $options = array())
+ function sortable($id, $options = array())
{
if (!empty($options['url']))
{
$options['with'] = "Sortable.serialize('$id')";
- $options['onUpdate'] = 'function(sortable){'.$this->remoteFunction($html, $options).'}';
+ $options['onUpdate'] = 'function(sortable){' . $this->remoteFunction($options).'}';
}
$options = $this->_optionsForSortable($options);
- return $script->codeBlock("Sortable.create('$id'$options);");
-
+ return $this->javascript->codeBlock("Sortable.create('$id'$options);");
}
function _optionsForSortable ($options)
@@ -462,14 +453,14 @@ class AjaxHelper extends Helper
}
}
- function _buildObserver ($html, $klass, $name, $options=null)
+ function _buildObserver ($klass, $name, $options=null)
{
if(!isset($options['with']) && isset($options['update']))
{
$options['with'] = 'value';
}
- $callback = $this->remoteFunction($html, $options);
+ $callback = $this->remoteFunction($options);
$javascript = "new $klass('$name', ";
$javascript .= (isset($options['frequency']) ? $options['frequency'] : 2) . ", function(element, value) {";
$javascript .= "$callback})";
diff --git a/libs/helpers/form.php b/cake/libs/view/helpers/form.php
similarity index 80%
rename from libs/helpers/form.php
rename to cake/libs/view/helpers/form.php
index dadaf77cb..230bc7c8f 100644
--- a/libs/helpers/form.php
+++ b/cake/libs/view/helpers/form.php
@@ -32,11 +32,6 @@
*/
-/**
- * Enter description here...
- */
-uses( 'helpers/html' );
-
/**
* Tag template for a div.
*/
@@ -67,9 +62,10 @@ define('TAG_FIELDSET', '