-
- =$content_for_layout?>
-
+
+=$content_for_layout?>
diff --git a/app/views/pages/home.thtml b/app/views/pages/home.thtml
index 338238c34..ee3832d65 100644
--- a/app/views/pages/home.thtml
+++ b/app/views/pages/home.thtml
@@ -1,36 +1,29 @@
-
Cake PHP works!
+
CakePHP Works!
+
+Your database configuration file is = file_exists(CONFIGS.'database.php') ? 'present.'. $filePresent = ' ' : 'not present.';?>
+ $db = DboFactory::getInstance(); ?>
+ if (!empty($filePresent)):?>
+Cake =$db->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
.
+
-
Your installation of Cake PHP is functional. Edit /app/views/pages/home.thtml
to change the contents of this page.
+
Introducing Cake
-
Introducing Cake PHP
+
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.
-
Cake is a structure of libraries, classes and run-time infrastructure for PHP programmers. It's also what It's original author, Michal uses at work. It's based on certain conventions, so you may find it rigid at first. The directory structure is already laid out, and it's different from what most people use. From what We've experienced, a great many PHP programmers start as web- or graphic-designers, i.e. they are not university-educated programmers as many in C++ and Java-land. They invent their own, peculiar ways of solving problems and stick to them. Perhaps that's why so few people use =$html->linkOut('PEAR', 'http://pear.php.net')?> and =$html->linkOut('PECL', 'http://pecl.php.net')?> libraries – they don't usually re-use their code.
-
-
Cake PHP builds on a concept introduced in =$html->linkOut('Ruby on Rails', 'http://rubyonrails.com')?> – it enables rapid developement of feature-rich websites.
-
-
Features
-
-
- Compatibile with PHP4 and PHP5.
- Supplies integrated CRUD for databases.
- Pretty URL's that work with and without mod_rewrite.
- Fast, flexible templating (PHP syntax with helper methods).
- Suported database-types: MySQL, PostgreSQL and SQLIte
- Suported webservers: Apache (others will most likely also work)
-
-
-
Cake is still in its early infancy, but we are proceeding in good direction – table joins will most probably get added in 0.9.3 release, and better support for user-defined settings is also underway.
-
-
Getting involved
-
-
Cake PHP needs you! We have already quiet active user base, but we are allways open to new bug reports or feature ideas!
-
-
- =$html->linkOut('Google Group','http://groups-beta.google.com/group/cake-php')?> – for public discussions about everything Cake.
- =$html->linkOut('Wiki','https://trac.cakephp.org/wiki')?> – fastest way of getting newest information on Cake PHP.
- =$html->linkOut('Report a bug or feature request','https://trac.cakephp.org/newticket')?>.
- =$html->linkOut('Roadmap','https://trac.cakephp.org/roadmap')?> – check our plans for the bright future.
-
-
-
Soon there will be oficial =$html->linkOut('Cake PHP website','http://www.cakephp.org/')?>, so stay tuned.
-
Also see Cake PHP's original authors =$html->linkOut('Amazon wishlish','http://www.amazon.com/gp/registry/registry.html?id=NODP8QT6LFTO')?> if you want to show appreciation for his work on the project.
\ No newline at end of file
+
Get Involved
+
Cake PHP needs you! We have an active user base and are always open to new bug reports or feature ideas!
+=$html->linkOut('Google Group','http://groups-beta.google.com/group/cake-php')?> – for public discussions about everything Cake.
+=$html->linkOut('Wiki','https://trac.cakephp.org/wiki')?> – fastest way of getting newest information on Cake PHP.
+=$html->linkOut('Report a bug or feature request','https://trac.cakephp.org/newticket')?>.
+=$html->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/config/acl.ini.php b/config/acl.ini.php
new file mode 100644
index 000000000..0940ec8a8
--- /dev/null
+++ b/config/acl.ini.php
@@ -0,0 +1,50 @@
+ die(); ?>
+
+; acl.ini.php - Cake ACL Configuration
+; ---------------------------------------------------------------------
+; Use this file to specify user permissions.
+; aco = access control object (something in your application)
+; aro = access request object (something requesting access)
+;
+; User records are added as follows:
+;
+; [uid]
+; groups = group1, group2, group3
+; allow = aco1, aco2, aco3
+; deny = aco4, aco5, aco6
+;
+; Group records are added in a similar manner:
+;
+; [gid]
+; allow = aco1, aco2, aco3
+; deny = aco4, aco5, aco6
+;
+; The allow, deny, and groups sections are all optional.
+; NOTE: groups names *cannot* ever be the same as usernames!
+;
+; ACL permissions are checked in the following order:
+; 1. Check for user denies (and DENY if specified)
+; 2. Check for user allows (and ALLOW if specified)
+; 3. Gather user's groups
+; 4. Check group denies (and DENY if specified)
+; 5. Check group allows (and ALLOW if specified)
+; 6. If no aro, aco, or group information is found, DENY
+;
+; ---------------------------------------------------------------------
+
+;-------------------------------------
+;Users
+;-------------------------------------
+
+[username-goes-here]
+groups = group1, group2
+deny = aco1, aco2
+allow = aco3, aco4
+
+;-------------------------------------
+;Groups
+;-------------------------------------
+
+[groupname-goes-here]
+deny = aco5, aco6
+allow = aco7, aco8
\ No newline at end of file
diff --git a/config/core.php b/config/core.php
index 539096d08..7ffa6cb2a 100644
--- a/config/core.php
+++ b/config/core.php
@@ -1,19 +1,34 @@
+ //
-// + Copyright: (c) 2005, CakePHP Authors/Developers + //
-// +------------------------------------------------------------------+ //
-// + Licensed under The MIT License + //
-//////////////////////////////////////////////////////////////////////////
+/* SVN FILE: $Id$ */
/**
- * This is core configuration file. Use it to configure core behaviour of
- * Cake.
+ * This is core configuration file.
*
- * @package cake
- * @subpackage cake.config
+ * Use it to configure core behaviour ofCake.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP : Rapid Development Framework
+ * 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.config
+ * @since CakePHP v 0.2.9
+ * @version $Revision$
+ * @modifiedby $LastChangedBy$
+ * @lastmodified $Date$
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
@@ -22,13 +37,24 @@
* - 1: development
* - 2: full debug with sql
*/
-define ('DEBUG', 1);
+define('DEBUG', 1);
/**
* Compress output CSS (removing comments, whitespace, repeating tags etc.)
* 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);
+define('COMPRESS_CSS', false);
+
+/**
+ * If set to true, helpers would output data instead of returning it.
+ */
+define('AUTO_OUTPUT', false);
+
+/**
+ * To use Access Control Lists with Cake...
+ */
+define('ACL_CLASSNAME', 'MyACL');
+define('ACL_FILENAME', 'my_acl.php');
?>
\ No newline at end of file
diff --git a/config/paths.php b/config/paths.php
index b4a9f074a..9fef1f253 100644
--- a/config/paths.php
+++ b/config/paths.php
@@ -1,18 +1,34 @@
+ //
-// + Copyright: (c) 2005, CakePHP Authors/Developers + //
-// +------------------------------------------------------------------+ //
-// + Licensed under The MIT License + //
-//////////////////////////////////////////////////////////////////////////
+/* SVN FILE: $Id$ */
/**
- * In this file you set paths to different directories used by Cake.
+ * Short description for file.
*
- * @package cake
- * @subpackage cake.config
+ * In this file you set paths to different directories used by Cake.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP : Rapid Development Framework
+ * 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.config
+ * @since CakePHP v 0.2.9
+ * @version $Revision$
+ * @modifiedby $LastChangedBy$
+ * @lastmodified $Date$
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
diff --git a/config/routes.php b/config/routes.php
index bbb741a39..391cc8d9b 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -1,20 +1,36 @@
+ //
-// + Copyright: (c) 2005, CakePHP Authors/Developers + //
-// +------------------------------------------------------------------+ //
-// + Licensed under The MIT License + //
-//////////////////////////////////////////////////////////////////////////
+/* SVN FILE: $Id$ */
/**
+ * Short description for file.
+ *
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
- *
- * @package cake
- * @subpackage cake.config
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP : Rapid Development Framework
+ * 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.config
+ * @since CakePHP v 0.2.9
+ * @version $Revision$
+ * @modifiedby $LastChangedBy$
+ * @lastmodified $Date$
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
diff --git a/config/tags.ini.php b/config/tags.ini.php
new file mode 100644
index 000000000..ba5e491a3
--- /dev/null
+++ b/config/tags.ini.php
@@ -0,0 +1,108 @@
+;
+; SVN FILE: $Id$
+;/**
+; * Short description for file.
+; *
+; * In this file, you can set up 'templates' for every tag generated by the tag
+; * generator.
+; *
+; * PHP versions 4 and 5
+; *
+; * CakePHP : Rapid Development Framework
+; * 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.config
+; * @since CakePHP v 0.2.9
+; * @version $Revision$
+; * @modifiedby $LastChangedBy$
+; * @lastmodified $Date$
+; * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+; */
+
+
+; Tag template for a link.
+link = "%s "
+
+; Tag template for a mailto: link.
+mailto = "%s "
+
+; Tag template for opening form tag.
+form = "');
-
-/**
- * Tag template for an input type='text' tag.
- */
-define('TAG_INPUT', ' ');
-
-/**
- * Tag template for an input type='hidden' tag.
- */
-define('TAG_HIDDEN', ' ');
-
-/**
- * Tag template for a textarea tag.
- */
-define('TAG_AREA', '%s ');
-
-/**
- * Tag template for a input type='checkbox ' tag.
- */
-define('TAG_CHECKBOX', ' %s ');
-
-/**
- * Tag template for a input type='radio' tag.
- */
-define('TAG_RADIOS', ' %s ');
-
-/**
- * Tag template for a select opening tag.
- */
-define('TAG_SELECT_START', '');
-
-/**
- * Tag template for an empty select option tag.
- */
-define('TAG_SELECT_EMPTY', ' ');
-
-/**
- * Tag template for a select option tag.
- */
-define('TAG_SELECT_OPTION','%s ');
-
-/**
- * Tag template for a closing select tag.
- */
-define('TAG_SELECT_END', ' ');
-
-/**
- * Tag template for a password tag.
- */
-define('TAG_PASSWORD', ' ');
-
-/**
- * Tag template for a file input tag.
- */
-define('TAG_FILE', ' ');
-
-/**
- * Tag template for a submit button tag.
- */
-define('TAG_SUBMIT', ' ');
-
-/**
- * Tag template for an image tag.
- */
-define('TAG_IMAGE', ' ');
-
-/**
- * Tag template for a table header tag.
- */
-define('TAG_TABLE_HEADER', '%s ');
-
-/**
- * Tag template for table headers row tag.
- */
-define('TAG_TABLE_HEADERS','%s ');
-
-/**
- * Tag template for a table cell tag.
- */
-define('TAG_TABLE_CELL', '%s ');
-
-/**
- * Tag template for a table row tag.
- */
-define('TAG_TABLE_ROW', '%s ');
-
-/**
- * Tag template for a CSS link tag.
- */
-define('TAG_CSS', ' ');
-
-/**
- * Tag template for a charset meta-tag.
- */
-define('TAG_CHARSET', ' ');
-
-/**
- * Tag template for inline JavaScript.
- */
-define('TAG_JAVASCRIPT', '');
-
-/**
- * Tag template for included JavaScript.
- */
-define('TAG_JAVASCRIPT_INCLUDE', '');
-
-?>
diff --git a/index.php b/index.php
index 23bc190de..06176ca8d 100644
--- a/index.php
+++ b/index.php
@@ -1,33 +1,35 @@
+ //
-// + 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. + //
-// + See: http://www.opensource.org/licenses/mit-license.php + //
-//////////////////////////////////////////////////////////////////////////
+/* SVN FILE: $Id$ */
/**
+ * Short description for file.
+ *
* This file collects requests if:
* - no mod_rewrite is avilable or .htaccess files are not supported
* - /public is not set as a web root.
- *
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP : Rapid Development Framework
+ * 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
- * @since CakePHP v 0.2.9
- * @version $Revision$
- * @modifiedby $LastChangedBy$
+ * @author CakePHP Authors/Developers
+ * @copyright Copyright (c) 2005, CakePHP Authors/Developers
+ * @link https://trac.cakephp.org/wiki/Authors Authors/Developers
+ * @package cake
+ * @since CakePHP v 0.2.9
+ * @version $Revision$
+ * @modifiedby $LastChangedBy$
* @lastmodified $Date$
- * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
diff --git a/libs/acl.php b/libs/acl.php
new file mode 100644
index 000000000..a560b700a
--- /dev/null
+++ b/libs/acl.php
@@ -0,0 +1,62 @@
+
+ * 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.helpers
+ * @since CakePHP v 0.9.2
+ * @version $Revision$
+ * @modifiedby $LastChangedBy$
+ * @lastmodified $Date$
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Access Control List factory class.
+ *
+ * Looks for ACL implementation class in core config, and returns an instance of that class.
+ *
+ * @package cake
+ * @subpackage cake.libs
+ * @since CakePHP v 0.9.2
+ *
+ */
+class Acl
+{
+
+ /**
+ * Static function used to gain an instance of the correct ACL class.
+ *
+ * @return MyACL
+ */
+ function getACL()
+ {
+ require_once(CONFIGS.'core.php');
+ require_once(APP.'apis'.DS.ACL_FILENAME);
+
+ $myacl = ACL_CLASSNAME;
+ return new $myacl;
+ }
+
+}
+?>
diff --git a/libs/model_collection.php b/libs/acl_base.php
similarity index 71%
rename from libs/model_collection.php
rename to libs/acl_base.php
index 6b22be298..b0912a29c 100644
--- a/libs/model_collection.php
+++ b/libs/acl_base.php
@@ -14,7 +14,7 @@
//////////////////////////////////////////////////////////////////////////
/**
- * Model Collections.
+ * Access Control List.
*
* @filesource
* @author CakePHP Authors/Developers
@@ -30,24 +30,32 @@
*
*/
+uses('error_messages');
+
/**
- * Model Collections.
+ * Access Control List abstract class. Not to be instantiated.
+ * Subclasses of this class are used by AclHelper to perform ACL checks in Cake.
*
* @package cake
- * @subpackage cake.libs
+ * @subpackage libs
* @since CakePHP v 0.9.2
*
*/
- class ModelCollection
+class AclBase
+{
+
+ function AclBase()
{
-
-/**
- * Enter description here...
- *
- * @return ModelCollection
- */
- function ModelCollection()
+ //No instantiations or constructor calls (even statically)
+ if (strcasecmp(get_class($this), "AclBase") == 0 || !is_subclass_of($this, "AclBase"))
{
+ trigger_error(ERROR_ABSTRACT_CONSTRUCTION, E_USER_ERROR);
+ return NULL;
}
+
}
+
+ function check($aro, $aco) {}
+
+}
?>
\ No newline at end of file
diff --git a/libs/bake.php b/libs/bake.php
index 4af452680..909ee0a3f 100644
--- a/libs/bake.php
+++ b/libs/bake.php
@@ -1,33 +1,35 @@
+ //
-// + 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. + //
-// + See: http://www.opensource.org/licenses/mit-license.php + //
-//////////////////////////////////////////////////////////////////////////
+/* SVN FILE: $Id$ */
/**
+ * Short description for file.
+ *
* Creates controller, model, view files, and the required directories on demand.
* Used by /scripts/bake.php.
*
+ * PHP versions 4 and 5
+ *
+ * CakePHP : Rapid Development Framework
+ * 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$
+ * @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
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
@@ -36,12 +38,14 @@
uses('object', 'inflector');
/**
+ * Short description for class.
+ *
* Bake class creates files in configured application directories. This is a
* base class for /scripts/add.php.
*
- * @package cake
+ * @package cake
* @subpackage cake.libs
- * @since CakePHP v 0.2.9
+ * @since CakePHP v 0.2.9
*/
class Bake extends Object {
diff --git a/libs/basics.php b/libs/basics.php
index c131aca3a..191d7a368 100644
--- a/libs/basics.php
+++ b/libs/basics.php
@@ -1,33 +1,34 @@
+ //
-// + 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. + //
-// + See: http://www.opensource.org/licenses/mit-license.php + //
-//////////////////////////////////////////////////////////////////////////
+/* SVN FILE: $Id$ */
/**
* Basic Cake functionalities.
*
- * @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
+ * Long description for file
*
+ * PHP versions 4 and 5
+ *
+ * CakePHP : Rapid Development Framework
+ * 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
*/
/**
diff --git a/libs/cache.php b/libs/cache.php
index 45b22f4eb..921adf5b4 100644
--- a/libs/cache.php
+++ b/libs/cache.php
@@ -1,34 +1,36 @@
+ //
-// + 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. + //
-// + See: http://www.opensource.org/licenses/mit-license.php + //
-//////////////////////////////////////////////////////////////////////////
+/* SVN FILE: $Id$ */
/**
- * Purpose: Cache
- * Description:
- *
- * @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
- */
+ * Cache
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP : Rapid Development Framework
+ * 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...
@@ -37,12 +39,14 @@
uses('model');
/**
- * Enter description here...
- *
- * @package cake
- * @subpackage cake.libs
- * @since CakePHP v 0.2.9
- */
+ * Short description for class.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.libs
+ * @since CakePHP v 0.2.9
+ */
class Cache extends Model {
/**
diff --git a/libs/class_registry.php b/libs/class_registry.php
new file mode 100644
index 000000000..435a248d2
--- /dev/null
+++ b/libs/class_registry.php
@@ -0,0 +1,112 @@
+
+ * 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
+ */
+
+/**
+ * Class Collections.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.libs
+ * @since CakePHP v 0.9.2
+ */
+ class ClassRegistry
+ {
+
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ * @access private
+ */
+ var $_objects = array();
+
+/**
+ * Enter description here...
+ *
+ * @return ClassRegistry instance
+ */
+ function &getInstance() {
+
+ static $instance = array();
+ if (!$instance)
+ {
+ $instance[0] =& new ClassRegistry;
+ }
+ return $instance[0];
+ }
+
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $key
+ * @param unknown_type $object
+ */
+ function addObject($key, &$object)
+ {
+ $key = strtolower($key);
+
+ if (array_key_exists($key, $this->_objects) === false)
+ {
+ $this->_objects[$key] =& $object;
+ }
+ }
+
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $key
+ * @return unknown
+ */
+ function isKeySet($key)
+ {
+ $key = strtolower($key);
+ return array_key_exists($key, $this->_objects);
+ }
+
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $key
+ * @return unknown
+ */
+ function &getObject($key)
+ {
+ $key = strtolower($key);
+ return $this->_objects[$key];
+ }
+
+
+ }
+
+?>
\ No newline at end of file
diff --git a/libs/controller.php b/libs/controller.php
index 95234a54f..5fc4f7b12 100644
--- a/libs/controller.php
+++ b/libs/controller.php
@@ -1,397 +1,683 @@
+ //
-// + 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. + //
-// + See: http://www.opensource.org/licenses/mit-license.php + //
-//////////////////////////////////////////////////////////////////////////
+/* SVN FILE: $Id$ */
/**
- * Purpose: Controller
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP : Rapid Development Framework
+ * 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('model', 'inflector', 'folder', 'view', 'helper');
+
+
+/**
+ * Controller
+ *
* Application controller (controllers are where you put all the actual code)
* Provides basic functionality, such as rendering views (aka displaying templates).
* Automatically selects model name from on singularized object class name
* and creates the model object if proper class exists.
- *
- * @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('model', 'inflector', 'folder', 'view');
-
-/**
- * Enter description here...
- *
- * @package cake
+ * @package cake
* @subpackage cake.libs
- * @since CakePHP v 0.2.9
+ * @since CakePHP v 0.2.9
*
*/
class Controller extends Object
{
-/**
- * Name of the controller.
- *
- * @var unknown_type
- * @access public
- */
- var $name = null;
+ /**
+ * Name of the controller.
+ *
+ * @var unknown_type
+ * @access public
+ */
+ var $name = null;
-/**
- * Stores the current URL (for links etc.)
- *
- * @var string Current URL
- */
- var $here = null;
+ /**
+ * Stores the current URL (for links etc.)
+ *
+ * @var string Current URL
+ */
+ var $here = null;
-/**
- * Enter description here...
- *
- * @var unknown_type
- * @access public
- */
- var $parent = null;
+ /**
+ * Enter description here...
+ *
+ * @var unknown_type
+ * @access public
+ */
+ var $parent = null;
-/**
- * Action to be performed.
- *
- * @var string
- * @access public
- */
- var $action = null;
+ /**
+ * Action to be performed.
+ *
+ * @var string
+ * @access public
+ */
+ var $action = null;
-/**
- * An array of names of models the particular controller wants to use.
- *
- * @var mixed A single name as a string or a list of names as an array.
- * @access protected
- */
- var $uses = false;
+ /**
+ * An array of names of models the particular controller wants to use.
+ *
+ * @var mixed A single name as a string or a list of names as an array.
+ * @access protected
+ */
+ var $uses = false;
-/**
- * An array of names of built-in helpers to include.
- *
- * @var mixed A single name as a string or a list of names as an array.
- * @access protected
- */
- var $helpers = array('html');
+ /**
+ * An array of names of built-in helpers to include.
+ *
+ * @var mixed A single name as a string or a list of names as an array.
+ * @access protected
+ */
+ var $helpers = array('html');
- var $viewPath;
+ /**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $viewPath;
-/**
- * Variables for the view
- *
- * @var array
- * @access private
- */
- var $_viewVars = array();
+ /**
+ * Variables for the view
+ *
+ * @var array
+ * @access private
+ */
+ var $_viewVars = array();
-/**
- * Enter description here...
- *
- * @var boolean
- * @access private
- */
- var $pageTitle = false;
+ /**
+ * Enter description here...
+ *
+ * @var boolean
+ * @access private
+ */
+ var $pageTitle = false;
-/**
- * An array of model objects.
- *
- * @var array Array of model objects.
- * @access public
- */
- var $models = array();
+ /**
+ * An array of model objects.
+ *
+ * @var array Array of model objects.
+ * @access public
+ */
+ var $models = array();
-/**
- * Enter description here...
- *
- * @var unknown_type
- * @access public
- */
- var $base = null;
+ /**
+ * Enter description here...
+ *
+ * @var unknown_type
+ * @access public
+ */
+ var $base = null;
-/**
- * Enter description here...
- *
- * @var string
- * @access public
- */
- var $layout = 'default';
+ /**
+ * Enter description here...
+ *
+ * @var string
+ * @access public
+ */
+ var $layout = 'default';
-/**
- * Enter description here...
- *
- * @var boolean
- * @access public
- */
- var $autoRender = true;
+ /**
+ * Enter description here...
+ *
+ * @var boolean
+ * @access public
+ */
+ var $autoRender = true;
-/**
- * Enter description here...
- *
- * @var boolean
- * @access public
- */
- var $autoLayout = true;
+ /**
+ * Enter description here...
+ *
+ * @var boolean
+ * @access public
+ */
+ var $autoLayout = true;
+
+ /**
+ * Enter description here...
+ *
+ * @var string
+ * @access public
+ */
+ var $useDbConfig = 'default';
+
+ /**
+ * Enter description here...
+ *
+ * @var string
+ * @access public
+ */
+ var $beforeFilter = null;
+
+ /**
+ * Constructor.
+ *
+ */
+ function __construct ($params=null)
+ {
+ // parent::__construct();
+ $r = null;
+ if (!preg_match('/(.*)Controller/i', get_class($this), $r))
+ {
+ die("Controller::__construct() : Can't get or parse my own class name, exiting.");
+ }
+
+ $this->name = strtolower($r[1]);
+ $this->viewPath = Inflector::underscore($r[1]);
+
+ //Adding Before Filter check
+ if (!empty($this->beforeFilter))
+ {
+ if(is_array($this->beforeFilter))
+ {
+ // If is an array we will use a foreach and run these methods
+ }
+ else
+ {
+ // Run a single before filter
+ }
+ }
+
+ parent::__construct();
+ }
+
+ /**
+ * Enter description here...
+ *
+ */
+ function contructClasses(){
+
+ if(empty($this->params['pass']))
+ {
+ $id = false;
+ }
+ else
+ {
+ $id = $this->params['pass'];
+ }
-/**
- * Constructor.
- *
- */
- function __construct ($params=null)
- {
- // parent::__construct();
- $r = null;
- if (!preg_match('/(.*)Controller/i', get_class($this), $r))
- {
- die("Controller::__construct() : Can't get or parse my own class name, exiting.");
- }
+ $model_class = Inflector::singularize($this->name);
- $this->name = strtolower($r[1]);
- $this->viewPath = Inflector::underscore($r[1]);
-
- parent::__construct();
- }
-
- function contructClasses(){
-
- if(empty($this->params['pass']))
- {
- $id = false;
- }
- else
- {
- $id = $this->params['pass'];
- }
+ $this->db = DboFactory::getInstance($this->useDbConfig);
-
- $model_class = Inflector::singularize($this->name);
-
- //Is this needed?
- $this->db = DboFactory::getInstance();
-
- if (class_exists($model_class) && ($this->uses === false))
- {
- $this->models[$model_class] = new $model_class($id);
- }
- elseif ($this->uses)
- {
- if (!$this->db)
- {
- die("Controller::__construct() : ".$this->name." controller needs database access, exiting.");
- }
-
- $uses = is_array($this->uses)? $this->uses: array($this->uses);
-
- foreach ($uses as $model_name)
- {
- $model_class = ucfirst(strtolower($model_name));
-
- if (class_exists($model_class))
+ if (class_exists($model_class) && ($this->uses === false))
+ {
+ $this->models[$model_class] = new $model_class($id);
+ }
+ elseif ($this->uses)
+ {
+ if (!$this->db)
{
- $this->models[$model_name] = new $model_class($id);
+ die("Controller::__construct() : ".$this->name." controller needs database access, exiting.");
}
+
+ $uses = is_array($this->uses)? $this->uses: array($this->uses);
+
+ foreach ($uses as $model_name)
+ {
+ $model_class = ucfirst(strtolower($model_name));
+
+ if (class_exists($model_class))
+ {
+ $this->models[$model_name] = new $model_class($id);
+ }
+ else
+ {
+ die("Controller::__construct() : ".ucfirst($this->name)." requires missing model {$model_class}, exiting.");
+ }
+ }
+ }
+ }
+
+ /**
+ * Redirects to given $url, after turning off $this->autoRender.
+ *
+ * @param unknown_type $url
+ */
+ function redirect ($url)
+ {
+ $this->autoRender = false;
+ header ('Location: '.$this->base.$url);
+ }
+
+ /**
+ * Saves a variable to use inside a template.
+ *
+ * @param mixed $one A string or an array of data.
+ * @param string $two Value in case $one is a string (which then works as the key), otherwise unused.
+ * @return unknown
+ */
+ function set($one, $two=null)
+ {
+ return $this->_setArray(is_array($one)? $one: array($one=>$two));
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param unknown_type $action
+ */
+ function setAction ($action)
+ {
+ $this->action = $action;
+
+ $args = func_get_args();
+ call_user_func_array(array(&$this, $action), $args);
+ }
+
+ /**
+ * Returns number of errors in a submitted FORM.
+ *
+ * @return int Number of errors
+ */
+ function validate ()
+ {
+ $args = func_get_args();
+ $errors = call_user_func_array(array(&$this, 'validateErrors'), $args);
+
+ return count($errors);
+ }
+
+ /**
+ * Validates a FORM according to the rules set up in the Model.
+ *
+ * @return int Number of errors
+ */
+ function validateErrors ()
+ {
+ $objects = func_get_args();
+ if (!count($objects)) return false;
+
+ $errors = array();
+ foreach ($objects as $object)
+ {
+ $errors = array_merge($errors, $object->invalidFields($object->data));
+ }
+
+ return $this->validationErrors = (count($errors)? $errors: false);
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param unknown_type $action
+ * @param unknown_type $layout
+ * @param unknown_type $file
+ * @return unknown
+ */
+ function render($action=null, $layout=null, $file=null)
+ {
+ $view = View::getInstance();
+ $view->_viewVars =& $this->_viewVars;
+ $view->action =& $this->action;
+ $view->autoLayout =& $this->autoLayout;
+ $view->autoRender =& $this->autoRender;
+ $view->base =& $this->base;
+ $view->helpers =& $this->helpers;
+ $view->here =& $this->here;
+ $view->layout =& $this->layout;
+ $view->models =& $this->models;
+ $view->name =& $this->name;
+ $view->pageTitle =& $this->pageTitle;
+ $view->parent =& $this->parent;
+ $view->viewPath =& $this->viewPath;
+ $view->params =& $this->params;
+ $view->data =& $this->data;
+ $view->displayFields =& $this->displayFields;
+
+ if(!empty($this->models))
+ {
+ foreach ($this->models as $key => $value)
+ {
+ if(!empty($this->models[$key]->validationErrors))
+ {
+ $view->validationErrors[$key] =& $this->models[$key]->validationErrors;
+ }
+ }
+ }
+
+ return $view->render($action, $layout, $file);
+ }
+
+ /**
+ * Enter description here...
+ *
+ */
+ function missingController()
+ {
+ //We are simulating action call below, this is not a filename!
+ $this->render('../errors/missingController');
+ }
+
+ /**
+ * Enter description here...
+ *
+ */
+ function missingAction()
+ {
+ //We are simulating action call below, this is not a filename!
+ $this->render('../errors/missingAction');
+ }
+
+ /**
+ * Enter description here...
+ *
+ */
+ function missingView()
+ {
+ //We are simulating action call below, this is not a filename!
+ $this->render('../errors/missingView');
+ }
+
+ // /**
+ // * Displays an error page to the user. Uses layouts/error.html to render the page.
+ // *
+ // * @param int $code Error code (for instance: 404)
+ // * @param string $name Name of the error (for instance: Not Found)
+ // * @param string $message Error message
+ // */
+ // function error ($code, $name, $message)
+ // {
+ // header ("HTTP/1.0 {$code} {$name}");
+ // print ($this->_render(VIEWS.'layouts/error.thtml', array('code'=>$code,'name'=>$name,'message'=>$message)));
+ // }
+
+ /**
+ * Sets data for this view. Will set title if the key "title" is in given $data array.
+ *
+ * @param array $data Array of
+ * @access private
+ */
+ function _setArray($data)
+ {
+ foreach ($data as $name => $value)
+ {
+ if ($name == 'title')
+ $this->_setTitle($value);
else
- {
- die("Controller::__construct() : ".ucfirst($this->name)." requires missing model {$model_class}, exiting.");
- }
+ $this->_viewVars[$name] = $value;
+ }
+ }
+
+ /**
+ * Set the title element of the page.
+ *
+ * @param string $pageTitle Text for the title
+ * @access private
+ */
+ function _setTitle($pageTitle)
+ {
+ $this->pageTitle = $pageTitle;
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param unknown_type $message
+ * @param unknown_type $url
+ * @param unknown_type $time
+ */
+ function flash($message, $url, $time=1)
+ {
+ $this->autoRender = false;
+ $this->autoLayout = false;
+
+ $this->set('url', $this->base.$url);
+ $this->set('message', $message);
+ $this->set('time', $time);
+
+ $this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param unknown_type $message
+ * @param unknown_type $url
+ * @param unknown_type $time
+ */
+ function flashOut($message, $url, $time=1)
+ {
+ $this->autoRender = false;
+ $this->autoLayout = false;
+
+ $this->set('url', $url);
+ $this->set('message', $message);
+ $this->set('time', $time);
+
+ $this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
+ }
+
+ /**
+ * This function creates a $fieldNames array for the view to use.
+ * @todo Map more database field types to html form fields.
+ * @todo View the database field types from all the supported databases.
+ *
+ */
+ function generateFieldNames( $data = null, $doCreateOptions = true )
+ {
+ // Initialize the list array
+ $fieldNames = array();
+
+ // figure out what model and table we are working with
+ $model = Inflector::pluralize($this->name);
+ $table = Inflector::singularize($this->name);
+
+ // get all of the column names.
+ $classRegistry = ClassRegistry::getInstance();
+ foreach ($classRegistry->getObject($table)->_table_info as $tables)
+ {
+ foreach ($tables as $tabl)
+ {
+ // set up the prompt
+ if( Model::isForeignKey($tabl['name']) )
+ {
+ $niceName = substr( $tabl['name'], 0, strpos( $tabl['name'], "_id" ) );
+ $fieldNames[ $tabl['name'] ]['prompt'] = Inflector::humanize($niceName);
+ // this is a foreign key, also set up the other controller
+ $fieldNames[ $tabl['name'] ]['model'] = Inflector::singularize($niceName);
+ $fieldNames[ $tabl['name'] ]['controller'] = Inflector::pluralize($niceName);
+ $fieldNames[ $tabl['name'] ]['foreignKey'] = true;
+ }
+ else if( 'created' != $tabl['name'] && 'updated' != $tabl['name'] )
+ {
+ $fieldNames[$tabl['name']]['prompt'] = Inflector::humanize($tabl['name']);
+ }
+ else if( 'created' == $tabl['name'] )
+ {
+ $fieldNames[$tabl['name']]['prompt'] = 'Created';
+ }
+ else if( 'updated' == $tabl['name'] )
+ {
+ $fieldNames[$tabl['name']]['prompt'] = 'Modified';
+ }
+
+ // Now, set up some other attributes that will be useful for auto generating a form.
+ //tagName is in the format table/field "post/title"
+ $fieldNames[ $tabl['name']]['tagName'] = $table.'/'.$tabl['name'];
+
+ // Now, find out if this is a required field.
+ $validationFields = $classRegistry->getObject($table)->validate;
+
+ if( isset( $validationFields[ $tabl['name'] ] ) )
+ {
+ // Now, we know that this field has some validation set.
+ // find out if it is a required field.
+ if( VALID_NOT_EMPTY == $validationFields[ $tabl['name'] ] )
+ {
+ // this is a required field.
+ $fieldNames[$tabl['name']]['required'] = true;
+ $fieldNames[$tabl['name']]['errorMsg'] = "Required Field";
+ }
+ }
+
+ // now, determine what the input type should be for this database field.
+ $lParenPos = strpos( $tabl['type'], '(');
+ $rParenPos = strpos( $tabl['type'], ')');
+ if( false != $lParenPos )
+ {
+ $type = substr($tabl['type'], 0, $lParenPos );
+ $fieldLength = substr( $tabl['type'], $lParenPos+1, $rParenPos - $lParenPos -1 );
+ }
+ else
+ {
+ $type = $tabl['type'];
+ }
+ switch( $type )
+ {
+ case "text":
+ {
+ $fieldNames[ $tabl['name']]['type'] = 'area';
+ //$fieldNames[ $tabl['name']]['size'] = $fieldLength;
+ }
+ break;
+ case "varchar":
+ {
+ if( isset( $fieldNames[ $tabl['name']]['foreignKey'] ) )
+ {
+ $fieldNames[ $tabl['name']]['type'] = 'select';
+ // This is a foreign key select dropdown box. now, we have to add the options.
+ $fieldNames[ $tabl['name']]['options'] = array();
+
+ // get the list of options from the other model.
+ $registry = ClassRegistry::getInstance();
+ $otherModel = $registry->getObject($fieldNames[ $tabl['name']]['model']);
+
+ if( is_object($otherModel) )
+ {
+ if( $doCreateOptions )
+ {
+ $otherDisplayField = $otherModel->getDisplayField();
+ foreach( $otherModel->findAll() as $pass )
+ {
+ foreach( $pass as $key=>$value )
+ {
+ if( $key == $fieldNames[ $tabl['name']]['model'] && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
+ {
+ $fieldNames[ $tabl['name']]['options'][$value['id']] = $value[$otherDisplayField];
+ }
+ }
+ }
+ }
+ $fieldNames[ $tabl['name']]['selected'] = $data[$table][$tabl['name']];
+ }
+ }
+ else
+ {
+ $fieldNames[ $tabl['name']]['type'] = 'input';
+ }
+ }
+ break;
+ case "int":
+ case "decimal":
+ {
+ //BUGBUG: Need a better way to determine if this field is an auto increment foreign key.
+ // If it is a number, and it is a foreign key, we'll make a HUGE assumption that it is an auto increment field.
+ // for foreign key autonumber fields, we'll set the type to 'key' so that it does not display in the input form.
+ if( 0 == strncmp($tabl['name'], 'id', 2) )
+ {
+ $fieldNames[ $tabl['name']]['type'] = 'hidden';
+ }
+ else if( isset( $fieldNames[ $tabl['name']]['foreignKey'] ) )
+ {
+ $fieldNames[ $tabl['name']]['type'] = 'select';
+ // This is a foreign key select dropdown box. now, we have to add the options.
+ $fieldNames[ $tabl['name']]['options'] = array();
+
+ // get the list of options from the other model.
+ $registry = ClassRegistry::getInstance();
+ $otherModel = $registry->getObject($fieldNames[ $tabl['name']]['model']);
+
+ if( is_object($otherModel) )
+ {
+ if( $doCreateOptions )
+ {
+ $otherDisplayField = $otherModel->getDisplayField();
+ foreach( $otherModel->findAll() as $pass )
+ {
+ foreach( $pass as $key=>$value )
+ {
+ if( $key == $fieldNames[ $tabl['name']]['model'] && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
+ {
+ $fieldNames[ $tabl['name']]['options'][$value['id']] = $value[$otherDisplayField];
+ }
+ }
+ }
+ }
+ $fieldNames[ $tabl['name']]['selected'] = $data[$table][$tabl['name']];
+ }
+ }
+ else
+ {
+ $fieldNames[ $tabl['name']]['type'] = 'input';
+ }
+ }
+ break;
+ case "enum":
+ {
+ // for enums, the $fieldLength variable is actually the list of enums.
+ $fieldNames[ $tabl['name']]['type'] = 'select';
+ // This is a foreign key select dropdown box. now, we have to add the options.
+ $fieldNames[ $tabl['name']]['options'] = array();
+
+ $enumValues = split(',', $fieldLength );
+ $iCount = 1;
+ foreach ($enumValues as $enum )
+ {
+ $enum = trim( $enum, "'" );
+ $fieldNames[$tabl['name']]['options'][$enum] = $enum;
+ }
+ $fieldNames[ $tabl['name']]['selected'] = $data[$table][$tabl['name']];
+
+ }
+ break;
+ case "date":
+ case "datetime":
+ {
+ $fieldNames[ $tabl['name']]['type'] = $type;
+ }
+ break;
+ default:
+ //sorry, this database field type is not yet set up.
+ break;
+
+
+ } // end switch
}
- }
- }
-
-/**
- * Redirects to given $url, after turning off $this->autoRender.
- *
- * @param unknown_type $url
- */
- function redirect ($url)
- {
- $this->autoRender = false;
- header ('Location: '.$this->base.$url);
- }
-
-/**
- * Saves a variable to use inside a template.
- *
- * @param mixed $one A string or an array of data.
- * @param string $two Value in case $one is a string (which then works as the key), otherwise unused.
- * @return unknown
- */
- function set($one, $two=null)
- {
- return $this->_setArray(is_array($one)? $one: array($one=>$two));
- }
-
-/**
- * Enter description here...
- *
- * @param unknown_type $action
- */
- function setAction ($action)
- {
- $this->action = $action;
-
- $args = func_get_args();
- call_user_func_array(array(&$this, $action), $args);
- }
-
-/**
- * Returns number of errors in a submitted FORM.
- *
- * @return int Number of errors
- */
- function validate ()
- {
- $args = func_get_args();
- $errors = call_user_func_array(array(&$this, 'validateErrors'), $args);
-
- return count($errors);
- }
-
-/**
- * Validates a FORM according to the rules set up in the Model.
- *
- * @return int Number of errors
- */
- function validateErrors ()
- {
- $objects = func_get_args();
- if (!count($objects)) return false;
-
- $errors = array();
- foreach ($objects as $object)
- {
- $errors = array_merge($errors, $object->invalidFields($object->data));
- }
-
- return $this->validationErrors = (count($errors)? $errors: false);
- }
-
- function render($action=null, $layout=null, $file=null)
- {
- $view =& View::getInstance();
- $view->_viewVars =& $this->_viewVars;
- $view->action =& $this->action;
- $view->autoLayout =& $this->autoLayout;
- $view->autoRender =& $this->autoRender;
- $view->base =& $this->base;
- $view->helpers =& $this->helpers;
- $view->here =& $this->here;
- $view->layout =& $this->layout;
- $view->models =& $this->models;
- $view->name =& $this->name;
- $view->pageTitle =& $this->pageTitle;
- $view->parent =& $this->parent;
- $view->viewPath =& $this->viewPath;
- $view->params =& $this->params;
- $view->data =& $this->data;
-
- if(!empty($this->models))
- {
- foreach ($this->models as $key => $value)
- {
- if(!empty($this->models[$key]->validationErrors))
- {
- $view->validationErrors[$key] =& $this->models[$key]->validationErrors;
- }
- }
- }
-
- return $view->render($action, $layout, $file);
- }
-
- function missingController()
- {
- //We are simulating action call below, this is not a filename!
- $this->render('../errors/missingController');
- }
-
- function missingAction()
- {
- //We are simulating action call below, this is not a filename!
- $this->render('../errors/missingAction');
- }
-
- function missingView()
- {
- //We are simulating action call below, this is not a filename!
- $this->render('../errors/missingView');
- }
-
- // /**
- // * Displays an error page to the user. Uses layouts/error.html to render the page.
- // *
- // * @param int $code Error code (for instance: 404)
- // * @param string $name Name of the error (for instance: Not Found)
- // * @param string $message Error message
- // */
- // function error ($code, $name, $message)
- // {
- // header ("HTTP/1.0 {$code} {$name}");
- // print ($this->_render(VIEWS.'layouts/error.thtml', array('code'=>$code,'name'=>$name,'message'=>$message)));
- // }
-
-/**
- * Sets data for this view. Will set title if the key "title" is in given $data array.
- *
- * @param array $data Array of
- * @access private
- */
- function _setArray($data)
- {
- foreach ($data as $name => $value)
- {
- if ($name == 'title')
- $this->_setTitle($value);
- else
- $this->_viewVars[$name] = $value;
- }
- }
-
-/**
- * Set the title element of the page.
- *
- * @param string $pageTitle Text for the title
- * @access private
- */
- function _setTitle($pageTitle)
- {
- $this->pageTitle = $pageTitle;
- }
-
- function flash($message, $url, $time=1)
- {
- $this->autoRender = false;
- $this->autoLayout = false;
-
- $this->set('url', $this->base.$url);
- $this->set('message', $message);
- $this->set('time', $time);
-
- $this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
- }
+ }
+ return $fieldNames;
+ }
}
?>
\ No newline at end of file
diff --git a/tests/app/controllers/put_controller_tests_here b/libs/controllers/templates/rescues/_request_and_response.thtml
similarity index 100%
rename from tests/app/controllers/put_controller_tests_here
rename to libs/controllers/templates/rescues/_request_and_response.thtml
diff --git a/tests/app/helpers/put_helper_tests_here b/libs/controllers/templates/rescues/diagnostics.thtml
similarity index 100%
rename from tests/app/helpers/put_helper_tests_here
rename to libs/controllers/templates/rescues/diagnostics.thtml
diff --git a/tests/app/models/put_model_tests_here b/libs/controllers/templates/rescues/layout.thtml
similarity index 100%
rename from tests/app/models/put_model_tests_here
rename to libs/controllers/templates/rescues/layout.thtml
diff --git a/libs/controllers/templates/rescues/missing_template.thtml b/libs/controllers/templates/rescues/missing_template.thtml
new file mode 100644
index 000000000..e69de29bb
diff --git a/libs/controllers/templates/rescues/routing_error.thtml b/libs/controllers/templates/rescues/routing_error.thtml
new file mode 100644
index 000000000..e69de29bb
diff --git a/libs/controllers/templates/rescues/template_error.thtml b/libs/controllers/templates/rescues/template_error.thtml
new file mode 100644
index 000000000..e69de29bb
diff --git a/libs/controllers/templates/rescues/unknown_action.thtml b/libs/controllers/templates/rescues/unknown_action.thtml
new file mode 100644
index 000000000..e69de29bb
diff --git a/libs/controllers/templates/scaffolds/edit.thtml b/libs/controllers/templates/scaffolds/edit.thtml
index 63341d7e4..718113941 100644
--- a/libs/controllers/templates/scaffolds/edit.thtml
+++ b/libs/controllers/templates/scaffolds/edit.thtml
@@ -1,102 +1,25 @@
-Editing name); ?>
-formTag('/'.$this->viewPath.'/update');?>
-
-
- Column Type
- Column Name
- Value
-
name);
- $table = Inflector::singularize($this->name);
- $evenNum = 1;
- $css = false;
-
- foreach ($this->$table->_table_info as $tables) {
- $columnCount = 0;
- foreach ($tables as $tabl) {
- foreach ($this->_viewVars as $names) {?>
-formTag('/'.$this->name.'/update');
+
+ echo $form->generateFields( $html, $fieldNames );
+
+ echo $form->generateSubmitDiv( $html, 'Save' )
- if ($evenNum % 2 == 0 ){
- $css = ' class="or"';
- }else{
- $css = false;
- }
- $evenNum++;
- ?>
-
-";?>
-
-
-
-
-
-
-$table->joinedHasOne)){?>
-
-
-
-
-
- Joined Table
-
-
-
- Column Type
- Column Name
- Value
-
+
-
-
-
-
- submitTag('Save')?>
-
-
-
- linkTo('Back ', "/{$this->viewPath}/list/")?>
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/libs/controllers/templates/scaffolds/list.thtml b/libs/controllers/templates/scaffolds/list.thtml
index ed83cb6d6..76a2d09be 100644
--- a/libs/controllers/templates/scaffolds/list.thtml
+++ b/libs/controllers/templates/scaffolds/list.thtml
@@ -1,105 +1,66 @@
-Listing name); ?>
-
-
name);
+ $model = Inflector::pluralize($this->name);
$table = Inflector::singularize($this->name);
-
- foreach ($this->$table->_table_info as $tables) {
-
-
- foreach ($tables as $tabl) {
- $tableHeader = Inflector::humanize($tabl['name']);
-
+ $humanName = Inflector::humanize($this->name);
+ $humanSingularName = Inflector::singularize( $humanName );
+// var_dump( $data );
?>
-
-$table->joinedHasOne)){
-
-echo" Joined Table Actions ";
-}
-
-if(!empty($this->$table->_hasMany)){
-
-echo" Has Many ";
- for ($i = 0; $i <= count($this->$table->_hasMany)-1; $i++) {
- echo Inflector::humanize($this->$table->_hasMany[$i]);
- }
- echo " ";
-} ?>
-
- Actions for name);?>
-
-
-$table->findAll() as $columns){
- if ($evenNum % 2 == 0 ){
- $css = ' class="or"';
- }else{
- $css = false;
- }
- $evenNum++;
- ?>
-
-";?>
-
-
-$table->joinedHasOne)){echo" ";?>
-$table->joinedHasOne);
-
- for ($i = 0; $i <= $joinedCount-1; $i++) {
- foreach ($this->$table->joinedHasOne[$i]->_table_info as $tab) {
- foreach($tab as $test){
- if($test['name'] === 'id'){
- echo $html->linkTo('Edit: '. Inflector::humanize(Inflector::singularize($this->$table->joinedHasOne[$i]->table)) .' ',"/{$this->$table->joinedHasOne[$i]->table}/edit/{$columns[Inflector::singularize($this->$table->joinedHasOne[$i]->table)][$test['name']]}");
- echo '' . Inflector::humanize($test['name']) .': ' . $columns[Inflector::singularize($this->$table->joinedHasOne[$i]->table)][$test['name']] .' ';
- } else{
- echo '' . Inflector::humanize($test['name']) .': ' . $columns[Inflector::singularize($this->$table->joinedHasOne[$i]->table)][$test['name']] .' ';
- }
- }
- }
- }
- }
+
+
+
+
+
+ Actions
+
+ ";
+ } else {
+ echo "";
+ }
+ foreach( $fieldNames as $field=>$value ) { ?>
+
+ getObject( $otherModelName );
+ if( is_object($otherModelObject) )
+ {
+ $displayText = $row[$otherModelName][ $otherModelObject->getDisplayField() ];
+ } else{
+ $displayText = $row[$table][$field];
+ }
+ echo $html->linkTo( $displayText, "/".Inflector::underscore($otherControllerName)."/show/".$row[$table][$field] );
+
+ } else {
+ echo $row[$table ][$field];
+ } ?>
+
+ value ?>
+ linkTo('View',"/".$this->viewPath."/show/{$row[$table]['id']}/")?>
+ linkTo('Edit',"/".$this->viewPath."/edit/{$row[$table]['id']}/")?>
+ linkTo('Delete',"/".$this->viewPath."/destroy/{$row[$table]['id']}/")?>
+
-if(!empty($this->$table->joinedHasOne)){ echo" ";}?>
+
+
+
+
+
+
+ linkTo('New '.$humanSingularName, '/'.$this->viewPath.'/new'); ?>
+
-$table->_hasMany)){ echo" ";?>
-$table->_hasMany)-1; $i++) {
- for ($ia = 0; $ia <= count($columns)-2; $ia++) {
- foreach ($this->$table->joinedHasMany[0] as $tab) {
- foreach($tab as $test){
- if($test['name'] === 'id'){
- echo $html->linkTo('Edit: '. Inflector::humanize(Inflector::singularize($this->$table->_hasMany[$i])) .' ',"/{$this->$table->_hasMany[$i]}/edit/{$columns[$ia][Inflector::singularize($this->$table->_hasMany[$i])][$test['name']]}");
- echo '' . Inflector::humanize($test['name']) .': ' . $columns[$ia][Inflector::singularize($this->$table->_hasMany[$i])][$test['name']] .' ';
- } else{
- echo '' . Inflector::humanize($test['name']) .': ' . $columns[$ia][Inflector::singularize($this->$table->_hasMany[$i])][$test['name']] .' ';
- }
- }
- }
- }
- }
-}
-
-if(!empty($this->$table->hasMany)){ echo" ";}?>
-
- linkTo('Show ', "/{$this->viewPath}/show/{$columns[Inflector::singularize($this->name)]['id']}")?>
- linkTo('Edit ',"/{$this->viewPath}/edit/{$columns[Inflector::singularize($this->name)]['id']}")?>
- linkTo('Destroy ',"/{$this->viewPath}/destroy/{$columns[Inflector::singularize($this->name)]['id']}")?>
-
-
-
-
-
-
- linkTo('Add New '.Inflector::humanize(Inflector::singularize($this->viewPath)).'', "/{$this->viewPath}/new/") ?>
-
-
\ No newline at end of file
diff --git a/libs/controllers/templates/scaffolds/new.thtml b/libs/controllers/templates/scaffolds/new.thtml
index 34b7e79da..42382da69 100644
--- a/libs/controllers/templates/scaffolds/new.thtml
+++ b/libs/controllers/templates/scaffolds/new.thtml
@@ -1,94 +1,11 @@
-New name); ?>
-formTag('/'.$this->viewPath.'/create');?>
-
-
- Column Type
- Column Name
-
name);
- $table = Inflector::singularize($this->name);
- $columnCount = 0;
- $evenNum = 1;
- $css = false;
-
- foreach ($this->$table->_table_info as $tables) {
- foreach ($tables as $tabl) {?>
-
-
-";?>
-
-
-
-
-
-
-$table->joinedHasOne)){?>
-
-
- Joined Table
-
-
-
- Column Type
- Column Name
-
+$form = new FormHelper();
-formTag('/'.$this->name.'/create');
+ echo $form->generateFields( $html, $fieldNames );
- $joinedCount = count($this->$table->joinedHasOne);
- $count = $columnCount;
- $evenNum = 1;
- $css = false;
-
- for ($i = 0; $i <= $joinedCount-1; $i++) {
- foreach ($this->$table->joinedHasOne[$i]->_table_info as $tab) {
- foreach($tab as $test){?>
-
-";?>
-
-
-
-
-
-
-
-
-
-
- submitTag('Save')?>
-
-
-
- linkTo('Back ', "/{$this->viewPath}/list/")?>
-
-
-
\ No newline at end of file
+ echo $form->generateSubmitDiv( $html, 'Add' )
+?>
\ No newline at end of file
diff --git a/libs/controllers/templates/scaffolds/scaffold.thtml b/libs/controllers/templates/scaffolds/scaffold.thtml
index 99845cc6f..3f162ff92 100644
--- a/libs/controllers/templates/scaffolds/scaffold.thtml
+++ b/libs/controllers/templates/scaffolds/scaffold.thtml
@@ -4,13 +4,14 @@
=$title_for_layout?>
=$html->charsetTag('UTF-8')?>
=$html->cssTag('scaffold')?>
+ =$html->cssTag('forms')?>
-
+
=$title_for_layout?>
=$content_for_layout?>
-
+