From d44a364285f1797b165564449102cf525692c754 Mon Sep 17 00:00:00 2001 From: phpnut Date: Mon, 3 Oct 2005 04:48:00 +0000 Subject: [PATCH] merging all changes done in sandbox for next release into the trunk git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1057 3807eeeb-6ff5-0310-8944-8be069107fe0 --- .htaccess | 6 +- app/.htaccess | 5 + {config => app/config}/acl.ini.php | 0 {config => app/config}/core.php | 20 + {config => app/config}/database.php.default | 0 {config => app/config}/paths.php | 77 +- {config => app/config}/routes.php | 0 {config => app/config}/routes.php.default | 0 {config => app/config}/tags.ini.php | 0 .../components}/my_acl.php | 0 app/controllers/tests_controller.php | 67 -- app/helpers/tests_helper.php | 47 - app/{helpers/pages_helper.php => index.php} | 23 +- .../plugins/put_3rd_party_cake_apps_here | 0 app/views/layouts/ajax.thtml | 1 - app/views/layouts/default.thtml | 19 - app/views/layouts/error.thtml | 11 - app/views/layouts/test.thtml | 91 -- app/views/pages/home.thtml | 29 - app/views/tests/index.thtml | 4 - app/views/tests/test_all.thtml | 30 - app/webroot/.htaccess | 5 + {public => app/webroot}/css.php | 0 app/webroot/css/cake.default.css | 167 ++++ .../webroot/css/cake.forms.css | 54 +- app/webroot/css/cake.scaffold.css | 161 ++++ app/webroot/favicon.ico | Bin 0 -> 4286 bytes .../files/put_downloadable_files_here | 0 app/webroot/img/cake.bg.body.gif | Bin 0 -> 201 bytes .../webroot/img/cake.bg.header.gif | Bin .../logo.png => app/webroot/img/cake.logo.png | Bin .../webroot/img/cake.redbox.gif | Bin {public => app/webroot}/img/pbcake.gif | Bin {public => app/webroot}/index.php | 90 +- {public => app/webroot}/js/vendors.php | 0 {app => cake}/app_controller.php | 0 {app => cake}/app_model.php | 0 {libs => cake}/basics.php | 94 +- {libs => cake}/dispatcher.php | 84 +- {docs => cake/docs}/CHANGELOG.txt | 0 {docs => cake/docs}/COPYING.txt | 0 {docs => cake/docs}/CREDITS.txt | 0 {docs => cake/docs}/LICENSE.txt | 0 {docs => cake/docs}/README.txt | 0 {libs => cake/libs}/cache.php | 0 {libs => cake/libs}/class_registry.php | 0 .../libs/controller/components}/acl.php | 0 .../libs/controller/components}/acl_base.php | 0 {libs => cake/libs/controller}/controller.php | 48 +- .../libs/controller}/pages_controller.php | 3 +- {libs => cake/libs/controller}/scaffold.php | 17 +- .../templates/scaffolds/edit.thtml | 7 +- .../templates/scaffolds/list.thtml | 0 .../controller/templates/scaffolds/new.thtml | 7 + .../templates/scaffolds/scaffold.thtml | 15 + .../templates/scaffolds/show.thtml | 0 {libs => cake/libs}/error_messages.php | 2 +- cake/libs/file.php | 348 +++++++ {libs => cake/libs}/flay.php | 0 {libs => cake/libs}/folder.php | 220 ++++- {libs => cake/libs/generator}/bake.php | 0 {libs => cake/libs}/generator/base.php | 0 {libs => cake/libs}/generator/commands.php | 0 .../applications/app/app_generator.php | 0 .../controller/controller_generator.php | 0 .../controller/templates/controller.php | 0 .../controller/templates/functional_test.php | 0 .../controller/templates/helper.php | 0 .../controller/templates/view.thtml | 0 .../model/model_generator.php | 0 .../model/templates/fixtures.php | 0 .../model/templates/model.php | 0 .../model/templates/unit_test.php | 0 .../scaffold/scaffold_generator.php | 0 .../scaffold/templates/controller.php | 0 .../scaffold/templates/form.thtml | 0 .../scaffold/templates/form_scaffolding.thtml | 0 .../scaffold/templates/functional_test.php | 0 .../scaffold/templates/helper.php | 0 .../scaffold/templates}/layout.thtml | 0 .../scaffold/templates/style.css | 0 .../scaffold/templates/view_edit.thtml | 0 .../scaffold/templates/view_list.thtml | 0 .../scaffold/templates/view_new.thtml | 0 .../scaffold/templates/view_show.thtml | 0 .../web/templates/api_definition.php | 0 .../web/templates/controller.php | 0 .../web/templates/functional_test.php | 0 .../class_templates}/web/web_generator.php | 0 {libs => cake/libs}/generator/lookup.php | 0 {libs => cake/libs}/generator/manifest.php | 0 {libs => cake/libs}/generator/options.php | 0 {libs => cake/libs}/generator/scripts.php | 0 .../libs}/generator/scripts/destroy.php | 0 .../libs}/generator/scripts/generate.php | 0 .../libs}/generator/scripts/update.php | 0 .../libs}/generator/simple_logger.php | 0 {libs => cake/libs}/generator/spec.php | 0 {libs => cake/libs}/inflector.php | 0 {libs => cake/libs}/legacy.php | 0 {libs => cake/libs}/log.php | 0 {libs => cake/libs/model/dbo}/dbo.php | 0 {libs => cake/libs/model}/dbo/dbo_adodb.php | 0 {libs => cake/libs/model/dbo}/dbo_factory.php | 8 +- {libs => cake/libs/model}/dbo/dbo_generic.php | 0 {libs => cake/libs/model}/dbo/dbo_mysql.php | 2 +- {libs => cake/libs/model}/dbo/dbo_pear.php | 2 +- .../libs/model}/dbo/dbo_postgres.php | 2 +- {libs => cake/libs/model}/dbo/dbo_sqlite.php | 2 +- {libs => cake/libs/model}/model.php | 16 +- {libs => cake/libs}/neat_array.php | 345 ++++--- {libs => cake/libs}/neat_string.php | 0 cake/libs/new_inflector.php | 142 +++ {libs => cake/libs}/object.php | 0 {libs => cake/libs}/router.php | 0 {libs => cake/libs}/sanitize.php | 394 ++++---- {libs => cake/libs}/time.php | 0 {libs => cake/libs}/validators.php | 0 {libs => cake/libs/view}/helper.php | 6 + {libs => cake/libs/view}/helpers/acl.php | 0 {libs => cake/libs/view}/helpers/ajax.php | 95 +- {libs => cake/libs/view}/helpers/form.php | 81 +- {libs => cake/libs/view}/helpers/html.php | 6 +- .../libs/view}/helpers/javascript.php | 60 +- {libs => cake/libs/view}/helpers/number.php | 15 +- {libs => cake/libs/view}/helpers/text.php | 0 {libs => cake/libs/view}/helpers/time.php | 894 +++++++++--------- .../templates}/errors/missing_action.thtml | 0 .../errors/missing_controller.thtml | 0 .../templates}/errors/missing_database.thtml | 0 .../errors/missing_helper_class.thtml | 45 + .../errors/missing_helper_file.thtml | 45 + .../errors/missing_scaffolddb.thtml | 0 .../templates}/errors/missing_table.thtml | 0 .../view/templates}/errors/missing_view.thtml | 0 cake/libs/view/templates/layouts/ajax.thtml | 1 + .../libs/view/templates/layouts/default.thtml | 57 ++ cake/libs/view/templates/layouts/error.thtml | 12 + .../libs/view/templates}/layouts/flash.thtml | 0 cake/libs/view/templates/pages/home.thtml | 41 + {libs => cake/libs/view}/view.php | 163 +++- {scripts => cake/scripts}/bake.bat | 0 {scripts => cake/scripts}/bake.php | 0 {scripts => cake/scripts}/test.bat | 0 {scripts => cake/scripts}/test.php | 0 index.php | 53 +- .../templates/rescues/diagnostics.thtml | 0 .../templates/rescues/missing_template.thtml | 0 .../templates/rescues/routing_error.thtml | 0 .../templates/rescues/template_error.thtml | 0 .../templates/rescues/unknown_action.thtml | 0 .../controllers/templates/scaffolds/new.thtml | 11 - .../templates/scaffolds/scaffold.thtml | 17 - libs/file.php | 108 --- .../scaffold/templates/layout.thtml | 0 libs/template.php | 112 --- libs/web/templates/scaffolds/layout.thtml | 0 libs/web/templates/scaffolds/methods.thtml | 0 libs/web/templates/scaffolds/parameters.thtml | 0 libs/web/templates/scaffolds/result.thtml | 0 modules/put_modules_here | 0 public/.htaccess | 13 - public/500.html | 11 - public/css/default.css | 116 --- public/css/scaffold.css | 168 ---- public/img/bg_fade.gif | Bin 1147 -> 0 bytes public/img/put_images_here | 0 public/test/rss2html.xsl | 110 --- {logs => tmp/logs}/put_logs_here | 0 169 files changed, 2739 insertions(+), 2166 deletions(-) create mode 100644 app/.htaccess rename {config => app/config}/acl.ini.php (100%) rename {config => app/config}/core.php (81%) rename {config => app/config}/database.php.default (100%) rename {config => app/config}/paths.php (67%) rename {config => app/config}/routes.php (100%) rename {config => app/config}/routes.php.default (100%) rename {config => app/config}/tags.ini.php (100%) rename app/{apis => controllers/components}/my_acl.php (100%) delete mode 100644 app/controllers/tests_controller.php delete mode 100644 app/helpers/tests_helper.php rename app/{helpers/pages_helper.php => index.php} (72%) rename libs/controllers/templates/rescues/_request_and_response.thtml => app/plugins/put_3rd_party_cake_apps_here (100%) delete mode 100644 app/views/layouts/ajax.thtml delete mode 100644 app/views/layouts/default.thtml delete mode 100644 app/views/layouts/error.thtml delete mode 100644 app/views/layouts/test.thtml delete mode 100644 app/views/pages/home.thtml delete mode 100644 app/views/tests/index.thtml delete mode 100644 app/views/tests/test_all.thtml create mode 100644 app/webroot/.htaccess rename {public => app/webroot}/css.php (100%) create mode 100644 app/webroot/css/cake.default.css rename public/css/forms.css => app/webroot/css/cake.forms.css (89%) create mode 100644 app/webroot/css/cake.scaffold.css create mode 100644 app/webroot/favicon.ico rename {public => app/webroot}/files/put_downloadable_files_here (100%) create mode 100644 app/webroot/img/cake.bg.body.gif rename public/img/bg_header.gif => app/webroot/img/cake.bg.header.gif (100%) rename public/img/logo.png => app/webroot/img/cake.logo.png (100%) rename public/img/red_box.gif => app/webroot/img/cake.redbox.gif (100%) rename {public => app/webroot}/img/pbcake.gif (100%) rename {public => app/webroot}/index.php (54%) rename {public => app/webroot}/js/vendors.php (100%) rename {app => cake}/app_controller.php (100%) rename {app => cake}/app_model.php (100%) rename {libs => cake}/basics.php (77%) rename {libs => cake}/dispatcher.php (76%) rename {docs => cake/docs}/CHANGELOG.txt (100%) rename {docs => cake/docs}/COPYING.txt (100%) rename {docs => cake/docs}/CREDITS.txt (100%) rename {docs => cake/docs}/LICENSE.txt (100%) rename {docs => cake/docs}/README.txt (100%) rename {libs => cake/libs}/cache.php (100%) rename {libs => cake/libs}/class_registry.php (100%) rename {libs => cake/libs/controller/components}/acl.php (100%) rename {libs => cake/libs/controller/components}/acl_base.php (100%) rename {libs => cake/libs/controller}/controller.php (94%) rename {app/controllers => cake/libs/controller}/pages_controller.php (97%) rename {libs => cake/libs/controller}/scaffold.php (96%) rename {libs/controllers => cake/libs/controller}/templates/scaffolds/edit.thtml (81%) rename {libs/controllers => cake/libs/controller}/templates/scaffolds/list.thtml (100%) create mode 100644 cake/libs/controller/templates/scaffolds/new.thtml create mode 100644 cake/libs/controller/templates/scaffolds/scaffold.thtml rename {libs/controllers => cake/libs/controller}/templates/scaffolds/show.thtml (100%) rename {libs => cake/libs}/error_messages.php (98%) create mode 100644 cake/libs/file.php rename {libs => cake/libs}/flay.php (100%) rename {libs => cake/libs}/folder.php (54%) rename {libs => cake/libs/generator}/bake.php (100%) rename {libs => cake/libs}/generator/base.php (100%) rename {libs => cake/libs}/generator/commands.php (100%) rename {libs => cake/libs}/generator/generators/applications/app/app_generator.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/controller/controller_generator.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/controller/templates/controller.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/controller/templates/functional_test.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/controller/templates/helper.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/controller/templates/view.thtml (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/model/model_generator.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/model/templates/fixtures.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/model/templates/model.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/model/templates/unit_test.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/scaffold/scaffold_generator.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/scaffold/templates/controller.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/scaffold/templates/form.thtml (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/scaffold/templates/form_scaffolding.thtml (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/scaffold/templates/functional_test.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/scaffold/templates/helper.php (100%) rename {libs/controllers/templates/rescues => cake/libs/generator/generators/class_templates/scaffold/templates}/layout.thtml (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/scaffold/templates/style.css (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/scaffold/templates/view_edit.thtml (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/scaffold/templates/view_list.thtml (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/scaffold/templates/view_new.thtml (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/scaffold/templates/view_show.thtml (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/web/templates/api_definition.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/web/templates/controller.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/web/templates/functional_test.php (100%) rename {libs/generator/generators/components => cake/libs/generator/generators/class_templates}/web/web_generator.php (100%) rename {libs => cake/libs}/generator/lookup.php (100%) rename {libs => cake/libs}/generator/manifest.php (100%) rename {libs => cake/libs}/generator/options.php (100%) rename {libs => cake/libs}/generator/scripts.php (100%) rename {libs => cake/libs}/generator/scripts/destroy.php (100%) rename {libs => cake/libs}/generator/scripts/generate.php (100%) rename {libs => cake/libs}/generator/scripts/update.php (100%) rename {libs => cake/libs}/generator/simple_logger.php (100%) rename {libs => cake/libs}/generator/spec.php (100%) rename {libs => cake/libs}/inflector.php (100%) rename {libs => cake/libs}/legacy.php (100%) rename {libs => cake/libs}/log.php (100%) rename {libs => cake/libs/model/dbo}/dbo.php (100%) rename {libs => cake/libs/model}/dbo/dbo_adodb.php (100%) rename {libs => cake/libs/model/dbo}/dbo_factory.php (92%) rename {libs => cake/libs/model}/dbo/dbo_generic.php (100%) rename {libs => cake/libs/model}/dbo/dbo_mysql.php (99%) rename {libs => cake/libs/model}/dbo/dbo_pear.php (99%) rename {libs => cake/libs/model}/dbo/dbo_postgres.php (99%) rename {libs => cake/libs/model}/dbo/dbo_sqlite.php (99%) rename {libs => cake/libs/model}/model.php (99%) rename {libs => cake/libs}/neat_array.php (53%) rename {libs => cake/libs}/neat_string.php (100%) create mode 100644 cake/libs/new_inflector.php rename {libs => cake/libs}/object.php (100%) rename {libs => cake/libs}/router.php (100%) rename {libs => cake/libs}/sanitize.php (91%) rename {libs => cake/libs}/time.php (100%) rename {libs => cake/libs}/validators.php (100%) rename {libs => cake/libs/view}/helper.php (98%) rename {libs => cake/libs/view}/helpers/acl.php (100%) rename {libs => cake/libs/view}/helpers/ajax.php (82%) rename {libs => cake/libs/view}/helpers/form.php (80%) rename {libs => cake/libs/view}/helpers/html.php (99%) rename {libs => cake/libs/view}/helpers/javascript.php (76%) rename {libs => cake/libs/view}/helpers/number.php (81%) rename {libs => cake/libs/view}/helpers/text.php (100%) rename {libs => cake/libs/view}/helpers/time.php (95%) rename {app/views => cake/libs/view/templates}/errors/missing_action.thtml (100%) rename {app/views => cake/libs/view/templates}/errors/missing_controller.thtml (100%) rename {app/views => cake/libs/view/templates}/errors/missing_database.thtml (100%) create mode 100644 cake/libs/view/templates/errors/missing_helper_class.thtml create mode 100644 cake/libs/view/templates/errors/missing_helper_file.thtml rename {app/views => cake/libs/view/templates}/errors/missing_scaffolddb.thtml (100%) rename {app/views => cake/libs/view/templates}/errors/missing_table.thtml (100%) rename {app/views => cake/libs/view/templates}/errors/missing_view.thtml (100%) create mode 100644 cake/libs/view/templates/layouts/ajax.thtml create mode 100644 cake/libs/view/templates/layouts/default.thtml create mode 100644 cake/libs/view/templates/layouts/error.thtml rename {app/views => cake/libs/view/templates}/layouts/flash.thtml (100%) create mode 100644 cake/libs/view/templates/pages/home.thtml rename {libs => cake/libs/view}/view.php (71%) rename {scripts => cake/scripts}/bake.bat (100%) rename {scripts => cake/scripts}/bake.php (100%) rename {scripts => cake/scripts}/test.bat (100%) rename {scripts => cake/scripts}/test.php (100%) delete mode 100644 libs/controllers/templates/rescues/diagnostics.thtml delete mode 100644 libs/controllers/templates/rescues/missing_template.thtml delete mode 100644 libs/controllers/templates/rescues/routing_error.thtml delete mode 100644 libs/controllers/templates/rescues/template_error.thtml delete mode 100644 libs/controllers/templates/rescues/unknown_action.thtml delete mode 100644 libs/controllers/templates/scaffolds/new.thtml delete mode 100644 libs/controllers/templates/scaffolds/scaffold.thtml delete mode 100644 libs/file.php delete mode 100644 libs/generator/generators/components/scaffold/templates/layout.thtml delete mode 100644 libs/template.php delete mode 100644 libs/web/templates/scaffolds/layout.thtml delete mode 100644 libs/web/templates/scaffolds/methods.thtml delete mode 100644 libs/web/templates/scaffolds/parameters.thtml delete mode 100644 libs/web/templates/scaffolds/result.thtml delete mode 100644 modules/put_modules_here delete mode 100644 public/.htaccess delete mode 100644 public/500.html delete mode 100644 public/css/default.css delete mode 100644 public/css/scaffold.css delete mode 100644 public/img/bg_fade.gif delete mode 100644 public/img/put_images_here delete mode 100644 public/test/rss2html.xsl rename {logs => tmp/logs}/put_logs_here (100%) diff --git a/.htaccess b/.htaccess index d633eea04..a3860192c 100644 --- a/.htaccess +++ b/.htaccess @@ -1,5 +1,5 @@ RewriteEngine on - RewriteRule ^$ public/ [L] - RewriteRule (.*) public/$1 [L] - + RewriteRule ^$ app/webroot/ [L] + RewriteRule (.*) app/webroot/$1 [L] + \ No newline at end of file diff --git a/app/.htaccess b/app/.htaccess new file mode 100644 index 000000000..f7f835c56 --- /dev/null +++ b/app/.htaccess @@ -0,0 +1,5 @@ + + RewriteEngine on + RewriteRule ^$ webroot/ [L] + RewriteRule (.*) webroot/$1 [L] + \ No newline at end of file diff --git a/config/acl.ini.php b/app/config/acl.ini.php similarity index 100% rename from config/acl.ini.php rename to app/config/acl.ini.php diff --git a/config/core.php b/app/config/core.php similarity index 81% rename from config/core.php rename to app/config/core.php index 76dd1ce91..47d22b76b 100644 --- a/config/core.php +++ b/app/config/core.php @@ -31,6 +31,16 @@ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ + +if(function_exists('apache_get_modules')) +{ + $modules = apache_get_modules(); + if(!in_array('mod_rewrite', $modules) || !is_file('.htaccess')) + { + define ('BASE_URL', $_SERVER['SCRIPT_NAME']); + } +} + /** * Set debug level here: * - 0: production @@ -54,6 +64,16 @@ define('COMPRESS_CSS', false); */ define('AUTO_OUTPUT', false); +/** + * If set to false, session would not automatically be started. + */ +define('AUTO_SESSION', true); + +/** + * Set the max size of file to use md5() . + */ +define('MAX_MD5SIZE', (5*1024)*1024 ); + /** * To use Access Control Lists with Cake... */ diff --git a/config/database.php.default b/app/config/database.php.default similarity index 100% rename from config/database.php.default rename to app/config/database.php.default diff --git a/config/paths.php b/app/config/paths.php similarity index 67% rename from config/paths.php rename to app/config/paths.php index bfff566cd..ed818e5e0 100644 --- a/config/paths.php +++ b/app/config/paths.php @@ -39,110 +39,125 @@ */ if(!defined('ROOT')) { - define('ROOT', '../'); + define ('ROOT', '../'); +} + +if(!defined('WEBROOT_DIR')) +{ + define ('WEBROOT_DIR', 'webroot'); } /** * Path to the application's directory. */ -define('APP', ROOT.'app'.DS); +define ('CAKE', ROOT.'cake'.DS); + +/** + * Path to the application's directory. + */ +define ('APP', ROOT.APP_DIR.DS); /** * Path to the application's models directory. */ -define('MODELS', APP.'models'.DS); +define ('MODELS', APP.'models'.DS); /** * Path to the application's controllers directory. */ -define('CONTROLLERS', APP.'controllers'.DS); - -/** - * Path to the application's helpers directory. - */ -define('HELPERS', APP.'helpers'.DS); +define ('CONTROLLERS', APP.'controllers'.DS); /** * Path to the application's views directory. */ -define('VIEWS', APP.'views'.DS); +define ('VIEWS', APP.'views'.DS); + +/** + * Path to the application's helpers directory. + */ +define ('HELPERS', VIEWS.'helpers'.DS); /** * Path to the application's view's layouts directory. */ -define('LAYOUTS', APP.'views'.DS.'layouts'.DS); +define ('LAYOUTS', APP.'views'.DS.'layouts'.DS); /** * Path to the application's view's elements directory. * It's supposed to hold pieces of PHP/HTML that are used on multiple pages * and are not linked to a particular layout (like polls, footers and so on). */ -define('ELEMENTS', APP.'views'.DS.'elements'.DS); +define ('ELEMENTS', APP.'views'.DS.'elements'.DS); /** * Path to the configuration files directory. */ -define('CONFIGS', ROOT.'config'.DS); +define ('CONFIGS', APP.'config'.DS); /** * Path to the libs directory. */ -define ('LIBS', ROOT.'libs'.DS); +define ('LIBS', CAKE.'libs'.DS); /** * Path to the logs directory. */ -define('LOGS', ROOT.'logs'.DS); +define ('LOGS', ROOT.'logs'.DS); /** * Path to the modules directory. */ -define('MODULES', ROOT.'modules'.DS); +define ('MODULES', ROOT.'modules'.DS); /** * Path to the public directory. */ -define('WWW_ROOT', ROOT.'public'.DS); +define ('WWW_ROOT', APP.WEBROOT_DIR.DS); /** * Path to the public directory. */ -define('CSS', WWW_ROOT.'css'.DS); +define ('CSS', WWW_ROOT.'css'.DS); + +/** + * Path to the public directory. + */ +define ('JS', WWW_ROOT.'js'.DS); /** * Path to the scripts direcotry. */ -define('SCRIPTS', ROOT.'scripts'.DS); +define('SCRIPTS', CAKE.'scripts'.DS); /** * Path to the tests directory. */ -define('TESTS', ROOT.'tests'.DS); +define ('TESTS', ROOT.'tests'.DS); /** * Path to the controller test directory. */ -define('CONTROLLER_TESTS', TESTS.'app'.DS.'controllers'.DS); +define ('CONTROLLER_TESTS',TESTS.APP_DIR.'controllers'.DS); /** * Path to the helpers test directory. */ -define('HELPER_TESTS', TESTS.'app'.DS.'helpers'.DS); +define ('HELPER_TESTS', TESTS.APP_DIR.'helpers'.DS); /** * Path to the models' test directory. */ -define('MODEL_TESTS', TESTS.'app'.DS.'models'.DS); +define ('MODEL_TESTS', TESTS.APP_DIR.'models'.DS); /** * Path to the lib test directory. */ -define('LIB_TESTS', TESTS.'libs'.DS); +define ('LIB_TESTS', TESTS.'libs'.DS); /** * Path to the temporary files directory. */ -define('TMP', ROOT.'tmp'.DS); +define ('TMP', ROOT.'tmp'.DS); /** * Path to the cache files directory. It can be shared between hosts in a multi-server setup. @@ -152,15 +167,14 @@ define('CACHE', TMP.'cache'.DS); /** * Path to the vendors directory. */ -define('VENDORS', ROOT.'vendors'.DS); +define ('VENDORS', ROOT.'vendors'.DS); /** * Path to the Pear directory * The purporse is to make it easy porting Pear libs into Cake * without setting the include_path PHP variable. */ -define('PEAR', VENDORS.'Pear'.DS); - +define ('PEAR', VENDORS.'Pear'.DS); /** * Full url prefix @@ -170,16 +184,17 @@ define('FULL_BASE_URL', 'http://'.$_SERVER['HTTP_HOST']); /** * Web path to the public images directory. */ -define('IMAGES_URL', '/img/'); +define ('IMAGES_URL', 'img/'); /** * Web path to the CSS files directory. */ -define('CSS_URL', '/css/'); +define ('CSS_URL', 'css/'); /** * Web path to the js files directory. */ -define('JS_URL', '/js/'); +define ('JS_URL', 'js/'); + ?> \ No newline at end of file diff --git a/config/routes.php b/app/config/routes.php similarity index 100% rename from config/routes.php rename to app/config/routes.php diff --git a/config/routes.php.default b/app/config/routes.php.default similarity index 100% rename from config/routes.php.default rename to app/config/routes.php.default diff --git a/config/tags.ini.php b/app/config/tags.ini.php similarity index 100% rename from config/tags.ini.php rename to app/config/tags.ini.php diff --git a/app/apis/my_acl.php b/app/controllers/components/my_acl.php similarity index 100% rename from app/apis/my_acl.php rename to app/controllers/components/my_acl.php diff --git a/app/controllers/tests_controller.php b/app/controllers/tests_controller.php deleted file mode 100644 index 0cf5652c3..000000000 --- a/app/controllers/tests_controller.php +++ /dev/null @@ -1,67 +0,0 @@ - - * 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.app.controllers - * @since CakePHP v 0.2.9 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ - -/** - * Short description for class. - * - * Long description for class - * - * @package cake - * @subpackage cake.app.controllers - */ -class TestsController extends TestsHelper { - - function index () - { - $this->layout = null; - require_once TESTS.'index.php'; - } - - function groups () - { - $this->layout = null; - $_GET['show'] = 'groups'; - require_once TESTS.'index.php'; - exit(); - } - - function cases () - { - $this->layout = null; - $_GET['show'] = 'cases'; - require_once TESTS.'index.php'; - exit(); - } -} - -?> diff --git a/app/helpers/tests_helper.php b/app/helpers/tests_helper.php deleted file mode 100644 index 0a75dcae2..000000000 --- a/app/helpers/tests_helper.php +++ /dev/null @@ -1,47 +0,0 @@ - - * 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.app.helpers - * @since CakePHP v 0.2.9 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ - -/** - * Short description for class. - * - * Long description for class - * - * @package cake - * @subpackage cake.app.helpers - */ - -class TestsHelper extends AppController -{ -} - -?> \ No newline at end of file diff --git a/app/helpers/pages_helper.php b/app/index.php similarity index 72% rename from app/helpers/pages_helper.php rename to app/index.php index e0e28db00..529f88720 100644 --- a/app/helpers/pages_helper.php +++ b/app/index.php @@ -2,10 +2,6 @@ /* SVN FILE: $Id$ */ /** - * Short description for file. - * - * In this file you can extend the PagesController. - * * PHP versions 4 and 5 * * CakePHP : Rapid Development Framework @@ -23,25 +19,12 @@ * @copyright Copyright (c) 2005, CakePHP Authors/Developers * @link https://trac.cakephp.org/wiki/Authors Authors/Developers * @package cake - * @subpackage cake.app.helpers - * @since CakePHP v 0.2.9 + * @subpackage cake.libs + * @since CakePHP v 0.10.0.1036 * @version $Revision$ * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php The MIT License - * - -/** - * Short description for class. - * - * Long description for class - * - * @package cake - * @subpackage cake.app.helpers */ - -class PagesHelper extends AppController -{ -} - +include_once('webroot'.DIRECTORY_SEPARATOR.'index.php'); ?> \ No newline at end of file diff --git a/libs/controllers/templates/rescues/_request_and_response.thtml b/app/plugins/put_3rd_party_cake_apps_here similarity index 100% rename from libs/controllers/templates/rescues/_request_and_response.thtml rename to app/plugins/put_3rd_party_cake_apps_here diff --git a/app/views/layouts/ajax.thtml b/app/views/layouts/ajax.thtml deleted file mode 100644 index c5fb84980..000000000 --- a/app/views/layouts/ajax.thtml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/app/views/layouts/default.thtml b/app/views/layouts/default.thtml deleted file mode 100644 index 28b9d27de..000000000 --- a/app/views/layouts/default.thtml +++ /dev/null @@ -1,19 +0,0 @@ - - - - <?php echo $title_for_layout?> - charsetTag('UTF-8')?> - cssTag('default')?> - cssTag('forms')?> - - - - - - diff --git a/app/views/layouts/error.thtml b/app/views/layouts/error.thtml deleted file mode 100644 index 557fe8a86..000000000 --- a/app/views/layouts/error.thtml +++ /dev/null @@ -1,11 +0,0 @@ - - - -<?=$code?> <?=$name?> - - - -

-

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

PASSED

- -

FAILED

- - - - - - - - - - - - - -
test
::
-
- -
::
- diff --git a/app/webroot/.htaccess b/app/webroot/.htaccess new file mode 100644 index 000000000..608e639f0 --- /dev/null +++ b/app/webroot/.htaccess @@ -0,0 +1,5 @@ + + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] + diff --git a/public/css.php b/app/webroot/css.php similarity index 100% rename from public/css.php rename to app/webroot/css.php diff --git a/app/webroot/css/cake.default.css b/app/webroot/css/cake.default.css new file mode 100644 index 000000000..b55469d6e --- /dev/null +++ b/app/webroot/css/cake.default.css @@ -0,0 +1,167 @@ +body +{ + margin: 0; + font:small "Trebuchet MS",Verdana,Arial,Sans-serif; + background: #F2F5F5 url('../img/cake.bg.body.gif') top center repeat-y; +} + +h1 +{ + margin: 4px; + padding: 0; + color: #71300F; + font-size: 30px; +} + +h1 em { + color: #DBA941; + font-style: normal; + font-weight: normal; + font-variant: normal; +} + +h2 +{ + margin-top: 20px; + margin-bottom: 6px; + padding: 0; + color: #71300F; +} + +h2 em { + color: #DBA941; + font-style: normal; + font-weight: bold; + font-variant: normal; +} +h3 +{ + margin-top: 20px; + margin-bottom: 6px; + color: #71300F; +} +acronym +{ + border-bottom: 1px dotted #DBA941; +} + +ul +{ + font-family: Helvetica; + margin-top: 2px; + margin-bottom: 6px; + padding: 2px 30px; +} +ul li +{ + list-style-image: url(../img/cake.redbox.gif); + padding-bottom: 8px; + +} +p +{ + font-family: Helvetica; + margin-top: 2px; + margin-left: 4px; + margin-bottom: 6px; +} + +#main +{ + width: 752px; + margin-top: 0px; + margin-left: auto; + margin-right: auto; + padding-bottom: 20px; + background-color: #EFF1F1; + border-top: 4px solid #fff; + /*border-bottom: 1px solid #D2D7D8;*/ + /*border-top: 1px solid #C9CFD1; + border-bottom: 1px solid #C9CFD1; + border-left: 1px solid #C9CFD1; + border-right: 1px solid #C9CFD1;*/ +} + +#header +{ + padding: 0px; + height: 112px; + background: #fff url(../img/cake.bg.header.gif) repeat-x; + border-bottom: 1px solid #D2D7D8; +} + +#headerLogo +{ + float: left; +} + +#headerNav +{ + float: left; + margin-top: 56px; + margin-left: 10px; +} + +#headerNav a { + padding: 4px 10px; + font-weight: bold; +} +#headerSubNav +{ + float: left; + margin-top: 12px; + margin-left: 10px; +} + +#headerSubNav a { + padding: 4px 10px; + font-weight: bold; +} +#content +{ + margin: 20px 20px; + padding: 0px 28px 40px 22px; + background-color: #fff; + border-top: 1px solid #D2D7D8; + border-left: 1px solid #D2D7D8; + border-right: 1px solid #D2D7D8; + border-bottom: 1px solid #D2D7D8; +} +a +{ + color: #71300F; + text-decoration: none; + font-weight: bold; +} + +a:hover +{ + color: #71300F; + text-decoration: underline; + font-weight: bold; +} + +#footer +{ + padding-bottom: 40px; + +} + +.active { + background-color: #D2D7D8; + padding: 10px; +} + +***Please Leave Powered by Cake****/ + #pb-cake { + width: 752px; + margin-top: 0px; + margin-left: auto; + margin-right: auto; + padding-right: 6px; + text-align: right; + } + + #pb-cake a{ + padding: 0; + } \ No newline at end of file diff --git a/public/css/forms.css b/app/webroot/css/cake.forms.css similarity index 89% rename from public/css/forms.css rename to app/webroot/css/cake.forms.css index 0a098d095..08abaab44 100644 --- a/public/css/forms.css +++ b/app/webroot/css/cake.forms.css @@ -1,13 +1,6 @@ /* form.css */ -* { - margin: 0px; - padding: 0px; -} - form { - margin: 0px; - padding: 0px; font-size: 100%; min-width: 560px; max-width: 620px; @@ -20,14 +13,12 @@ form fieldset { border-width: 1px 0px 0px 0px; border-style: solid none none none; padding: 10px; - margin: 0px 0px 0px 0px; } form fieldset legend { font-size: 150%; font-weight: normal; - color: #000000; - margin: 0px 0px 0px 0px; + color: #000; padding: 0px 5px; } @@ -43,7 +34,7 @@ label u { input, select, textarea { font-family: Tahoma, Arial, sans-serif; font-size: 100%; - color: #000000; + color: #000; } textarea { @@ -65,9 +56,9 @@ form fieldset div.notes { height: auto; margin: 0px 0px 10px 10px; padding: 5px; - border: 1px solid #666666; + border: 1px solid #666; background-color: #ffffe1; - color: #666666; + color: #666; font-size: 88%; } @@ -78,14 +69,14 @@ form fieldset div.notes h4 { padding: 3px 0px 3px 27px; border-width: 0px 0px 1px 0px; border-style: solid; - border-color: #666666; - color: #666666; + border-color: #666; + color: #666; font-size: 110%; } form fieldset div.notes p { margin: 0em 0em 1.2em 0em; - color: #666666; + color: #666; } form fieldset div.notes p.last { @@ -96,7 +87,7 @@ form div fieldset { clear: none; border-width: 1px; border-style: solid; - border-color: #666666; + border-color: #666; margin: 0px 0px 0px 142px; padding: 0px 5px 5px 5px; width: 197px; @@ -133,7 +124,6 @@ form div label.labelCheckbox, form div label.labelRadio { display: block; width: 200px; height: expression('1%'); - padding: 0px; margin: 0px 0px 5px 142px; text-align: left; } @@ -144,13 +134,13 @@ form div fieldset label.labelCheckbox, form div fieldset label.labelRadio { } p.error { - background-color: #ff0000; + background-color: #f00; background-image: url(/images/icon_error.gif); background-repeat: no-repeat; background-position: 3px 3px; color: #ffffff; padding: 3px 3px 5px 27px; - border: 1px solid #000000; + border: 1px solid #000; margin: auto 100px; } @@ -159,8 +149,8 @@ form div.error { background-image: url(/images/required_bg.gif); background-repeat: no-repeat; background-position: top left; - color: #666666; - border: 1px solid #ff0000; + color: #666; + border: 1px solid #f00; } form div.error p.error { @@ -172,7 +162,7 @@ form div.error p.error { font-weight: bold; margin: 0px 0px 0px 118px; width: 200px; - color: #ff0000; + color: #f00; } form div input, form div select, form div textarea { @@ -196,8 +186,6 @@ form div input.inputCheckbox, form div input.inputRadio, input.inputCheckbox, in width: 14px; background-color: transparent; border-width: 0px; - padding: 0px; - margin: 0px 0px 0px 0px; } form div.submit { @@ -208,7 +196,6 @@ form div.submit { } div.submit input { - align:center; text-align:center; font-weight: bold; color: #fff; @@ -227,8 +214,6 @@ form div.submit div { float: left; text-align: left; width: auto; - padding: 0px; - margin: 0px; } form div input.inputSubmit, form div input.inputButton, input.inputSubmit, input.inputButton { @@ -236,7 +221,6 @@ form div input.inputSubmit, form div input.inputButton, input.inputSubmit, input color: #000000; width: auto; padding: 0px 6px; - margin: 0px; } form div.submit div input.inputSubmit, form div.submit div input.inputButton { @@ -259,7 +243,7 @@ form fieldset legend { } form input, form select, form textarea { - background-color: #ffffff; + background-color: #fff; } form textarea.expanding { @@ -286,7 +270,7 @@ form div label.labelCheckbox, form div label.labelRadio, label.labelCheckbox, la } form div label.labelCheckbox input.inputCheckbox, form div label.labelRadio input.inputRadio, label.labelCheckbox input.inputCheckbox, label.labelRadio input.inputRadio { - margin: 0px 0px 0px 0px; + margin: 0; } form div fieldset input.inputText, form div fieldset input.inputPassword, form div fieldset input.inputFile, form div fieldset textarea.inputTextarea { @@ -300,7 +284,7 @@ form div label.compact { width: auto; padding: 4px 10px 0px 0px; text-indent: 0px; - margin: 0px 0px 0px 0px; + margin: 0; } form div.wide label { @@ -314,7 +298,7 @@ form div label.wide { form div.wide input.inputText, form div.wide input.inputPassword, form div.wide input.inputFile, form div.wide select, form div.wide textarea { width: 344px; - margin: 0px; + margin: 0; } form div.notes p, form div small { @@ -334,5 +318,5 @@ select.autoWidth { } option { -padding-left:1em; -} \ No newline at end of file + padding-left:1em; +} diff --git a/app/webroot/css/cake.scaffold.css b/app/webroot/css/cake.scaffold.css new file mode 100644 index 000000000..1eec598bb --- /dev/null +++ b/app/webroot/css/cake.scaffold.css @@ -0,0 +1,161 @@ +/* CSS Document */ +* { + margin: 0; + padding: 0; +} +body { + color: #333; + font: 76% Verdana, Arial, Helvetica, sans-serif; +} +h1 { + color: #69c; + font-size:2.1em; +} +h2 { + color: #383; + clear: both; + display:block; + font-size:1.7em; + float:left; + margin-top:5px; +} +h3 { + color: #553; + font-size:1.4em; +} +h4 { + color: #338; + font-size:1.15em; +} +a { + text-decoration:underline; + white-space:nowrap; +} +a:hover { + background-color:#eee; +} +code, pre { + color:#44a; + font-family:monospace; + font-size:1.15em; +} +code { + color:#227; + margin:0 .2em; + white-space:nowrap; +} +pre { + margin-left:1em; +} +acronym { + border-bottom:1px dotted #666; +} +ul { + margin-top:1em; + list-style:none; +} +li { + margin-left:2em; +} +#container { + color: #333; + margin: 2em auto; + width:80%; +} +.notice { + background: #ffd; + border: solid 2px #eeb; + display: block; + font-family: Verdana; + padding: 1em; +} +.tip { + background: #efe; + border: solid 2px #cdc; + padding: 1em; +} +.error { + background: #fee; + border: solid 2px #dcc; + padding: 1em; +} +ul.actions { + float:left; + list-style: none; + text-align:right; + margin:2em 0; +} +ul.actions li { + border: 1px solid #333; + float:left; + margin-left:1em; + width:10em; +} +ul.actions li a, ul.actions li input { + background-color:#3297FC; + border:1px solid #3297FC; + clear: both; + color: #fff; + display:block; + font-weight: bold; + text-align:center; + text-decoration: none; +} +td.listactions { + width:17em; +} +td.listactions a { + text-align:center; + font-weight: bold; + color: #fff; + background-color:#3297FC; + display:block; + float:left; + text-decoration: none; + margin-bottom:3px; + margin-right: 3px; + border: 1px; + width:5em; +} +table { + background-color: #fff; + border: 1px solid #686E74; + clear:both; + margin: 1em 0 2em 0; + width: 100%; +} +th { + background-color: #ccc; + border-top: 1px solid #fff; + border-right: 1px solid #666; + border-bottom: 1px solid #666; + text-align: left; + padding:3px; + white-space:nowrap; +} +table tr td { + border-right: 1px solid #ccc; + padding:2px 0; + vertical-align:top; +} +table tr.altRow td { + background: #EBF4FD; +} +div.related { + clear:both; + display:block; + float:left; +} +dl { + line-height:2em; + margin:1em; +} +dt { + font-weight: bold; + vertical-align:top; +} +dd { + margin-left:10em; + margin-top:-2em; + vertical-align:top; +} \ No newline at end of file diff --git a/app/webroot/favicon.ico b/app/webroot/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..eb730159eb9e377e97b07002eca4c7112da368d7 GIT binary patch literal 4286 zcmb_g3pkW%8=n4l|7s6y{r}c(TU(+;A;d;uG1OhY7U>mrocwvrr+6gHvhsH}9_ zl(gwYTcmXesnJ2AVd&u4I1GcC@BW`}N>|rz`)_+)JFeUNeed_qbKlSXJm33$*Kjz4 z=ub(BLmws1$q^jRXgX3;oN+j2G}2Z2|LzX}&ikUXv-6`TPoD5fN=kUSxw*WYoE+ZO zt5d3n6j(o&vKD72JFB!k~K-utW*i^apTv$H*7cf_3b_F9D{i(TNnhzCap2iRI! z!{Xa{Ff}%T;Y8zVKSP63ac@vDDQCPP|2Mu(N}Wl@;b&Si+LDn9rFDBg0uxS5t?Dg+*INMn+Ii zPtV`-ggl}<>_|2eRp{|c_o4&;ji z>=)R=a^5RX^!4;HZR%9``S}%AS6AyZ4D*+@zJLF|b!>EWd(5_N2oDX0pU-z#>Fx+O zo;A3(bFskE1ZJ~mz}Qe1mUCypVy+rlySPT2r8!! zr@MFUYKe>pfzL`OtX|2ZTpZ!zI3IRaW|(VgfSGz)P*t6XDN~dcP*qjJq)FqUtUL}* z4&TCO#iG|5ey78oM}Bajqpb~3Pft91_DuP0ZuU6yY(_$O$VP1NTZZ*(+_Bcn1PQEOY$p#H*s27PwZVlhu6&31-twFvB+u()oeU@Sg*9N+} znwT*|3zJnNG;4ZG9xZmEOxZSECU^=s7%1O zoAEZ)3Nt!_I9RkQft$sE7@)r+YR%J-t9Kmk)Z`*7jlSwqWtmLvcvi7mb5STS-SS z+~_{j(3yoV&BHJ~lO~g$X_#txG+r3TLa~iA`@{zeS3%_hXglHkETsZBcbDMG_FQC!U&5))=WsOe z6t*mnf}S?@f$=Pun9io2nSrtDHc**nhC_Q}aQ@6;il3(7$vAb0_M|natgH;La`^`kOWJ-CI36@{o3l;K%XH6(>S=sga|4iNSNeSDx~M=Lh+&Y^>}w3CLm?LaeW z5Qaz);&vR$j$1Kv!%?Vk<1q4@K&UQGfMI9`!nY-(;`R+ZyjP^)sk~QAJ?M?5rlu*o z;&%w^>mEQPya!?RU9>)|f$WY9I048H5s1H^_*mj%UgOU>C z_tc9j@%&jenh1TB-M~588PZFR2e&$%Doi21)+cptfo+bk-fg z7sf%v`vXR32Vgw$^8>C!u%!XnfhDM|5Dlb#gPaF8@mO=G<6Mj2H$GZ@Tz z_t$g%P0Z8)=WK`{NU5=DrHH`lctp5ID5pIyyO*9tZP3v;4{gn}82mvXxK?M;dzC>S z)lEuulNJ-mJLw$)`PlP_LG|h9Eq&ttp%mp$`DJ|=bYjor)7=ey)MT`>jlk-7N~j}{ zH)R((aCpBMhYz>WyHqLdW4Dl%_5z(n{b0x|Iq8%?pnf6E4AoKcK#t4&$7sFX;Yktx zl>5!KPE0@*n$bZsWP?ISJB_V`7nBRdtiQ*gt`?}NW>8mt+t*YDo+jaT}_P(}?^pXKZ)kR9kDNC>R1mvs7+LGKHCCe_Mm6QsEo0=u5| zjIJ{@b_k?sE$Z4W>tQ~p*;ldOckIE~mRr3~N`9f>EGP3CG8$P;y#!X%@6k=R)ydF$ zQ_|X1DRqMEZ}PsSPgp4#apXY721bY^rV7;z^#DUPU?^8P<){GVETg$zszdif84@>D z;?|k^BmH9eSW@@*a{fQ-nO+Q*H$uC=7D3_?*^8vj0(6(l1(Msc3tbic3EegQD|(w` zicXAHWmvut|`S2V>o0@IPpnMDJ|fCLx*hM literal 0 HcmV?d00001 diff --git a/public/files/put_downloadable_files_here b/app/webroot/files/put_downloadable_files_here similarity index 100% rename from public/files/put_downloadable_files_here rename to app/webroot/files/put_downloadable_files_here diff --git a/app/webroot/img/cake.bg.body.gif b/app/webroot/img/cake.bg.body.gif new file mode 100644 index 0000000000000000000000000000000000000000..eed1a758ff074f00ca90084f8f1a0237d4b97272 GIT binary patch literal 201 zcmZ?wbhEHbRA6RgIKsg2|NsAoPoKW~^y$T$H*Y??fAs9x^H;Cme*F0O`HMRb9zK2f z>eJV+51u^v_~pyphmSsd{`};{%a?E8-h2G`^}BcPKYnB&1QdU=fR*TgNRXWjtZol3 z*&K58xtO3K5X92+M8$zOpkm$on)m+?EGY2Mk?KFOr08Uh)%*)9O1#!at-rCR?6mAH Z2F~^tK@9~3uEPpOiZU$y$COwYtO4Y{T;>1( literal 0 HcmV?d00001 diff --git a/public/img/bg_header.gif b/app/webroot/img/cake.bg.header.gif similarity index 100% rename from public/img/bg_header.gif rename to app/webroot/img/cake.bg.header.gif diff --git a/public/img/logo.png b/app/webroot/img/cake.logo.png similarity index 100% rename from public/img/logo.png rename to app/webroot/img/cake.logo.png diff --git a/public/img/red_box.gif b/app/webroot/img/cake.redbox.gif similarity index 100% rename from public/img/red_box.gif rename to app/webroot/img/cake.redbox.gif diff --git a/public/img/pbcake.gif b/app/webroot/img/pbcake.gif similarity index 100% rename from public/img/pbcake.gif rename to app/webroot/img/pbcake.gif diff --git a/public/index.php b/app/webroot/index.php similarity index 54% rename from public/index.php rename to app/webroot/index.php index cd9bdcd9e..b99d8dbc6 100644 --- a/public/index.php +++ b/app/webroot/index.php @@ -32,11 +32,6 @@ */ -/** - * Enter description here... - */ -$url = empty($_GET['url'])? null: $_GET['url']; - /** * Get Cake's root directory */ @@ -54,25 +49,70 @@ if (!defined('ROOT')) * Enter description here... * */ - define('ROOT', dirname(dirname(__FILE__)).DS); + define('ROOT', dirname(dirname(dirname(__FILE__))).DS); } +if (!defined('APP_DIR')) +{ + define ('APP_DIR', basename(dirname(dirname(__FILE__)))); +} + +if (!defined('WEBROOT_DIR')) +{ + define ('WEBROOT_DIR', basename(dirname(__FILE__))); +} + + +/** + * Configuration, directory layout and standard libraries + */ +require_once ROOT.APP_DIR.DS.'config'.DS.'core.php'; +require_once ROOT.APP_DIR.DS.'config'.DS.'paths.php'; +require_once CAKE.'basics.php'; +require_once LIBS.'log.php'; +require_once LIBS.'object.php'; +require_once LIBS.'neat_array.php'; +require_once LIBS.'inflector.php'; + +/** + * Enter description here... + */ + + if (empty($uri) && defined('BASE_URL')) + { + $uri = setUri(); + if ($uri === '/' || $uri === '/index.php' || $uri === '/app/') + { + $_GET['url'] = '/'; + $url = '/'; + } + else + { + $elements = explode('/index.php', $uri); + if(!empty($elements[1])) + { + $_GET['url'] = $elements[1]; + $url = $elements[1]; + } + else + { + $_GET['url'] = '/'; + $url = '/'; + } + } + } + else + { + $url = empty($_GET['url'])? null: $_GET['url']; + } + + if (strpos($url, 'ccss/') === 0) { include ROOT.'public'.DS.'css.php'; die; } -/** - * Configuration, directory layout and standard libraries - */ -require_once ROOT.'config/core.php'; -require_once ROOT.'config/paths.php'; -require_once ROOT.'libs/basics.php'; -require_once ROOT.'libs/log.php'; -require_once ROOT.'libs/object.php'; -require_once ROOT.'libs/neat_array.php'; -require_once ROOT.'libs/inflector.php'; DEBUG? error_reporting(E_ALL): error_reporting(0); if (DEBUG) @@ -82,9 +122,15 @@ if (DEBUG) $TIME_START = getMicrotime(); -uses('folder', 'dispatcher', 'dbo_factory'); +uses('folder'); +require_once CAKE.'dispatcher.php'; +require_once LIBS.'model'.DS.'dbo'.DS.'dbo_factory.php'; -session_start(); +if(!defined('AUTO_SESSION') || AUTO_SESSION == true) +{ + // Starts the session unless AUTO_SESSION is explicitly set to false in config/core + session_start(); +} config('database'); @@ -93,14 +139,16 @@ if (class_exists('DATABASE_CONFIG')) loadModels(); } + + //RUN THE SCRIPT if(isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { }else{ - $DISPATCHER = new Dispatcher (); - $DISPATCHER->dispatch($url); + $Dispatcher= new Dispatcher (); + $Dispatcher->dispatch($url); } -//CLEANUP + if (DEBUG) { echo ""; } diff --git a/public/js/vendors.php b/app/webroot/js/vendors.php similarity index 100% rename from public/js/vendors.php rename to app/webroot/js/vendors.php diff --git a/app/app_controller.php b/cake/app_controller.php similarity index 100% rename from app/app_controller.php rename to cake/app_controller.php diff --git a/app/app_model.php b/cake/app_model.php similarity index 100% rename from app/app_model.php rename to cake/app_model.php diff --git a/libs/basics.php b/cake/basics.php similarity index 77% rename from libs/basics.php rename to cake/basics.php index 4d0b98209..368699d7e 100644 --- a/libs/basics.php +++ b/cake/basics.php @@ -51,11 +51,18 @@ define('YEAR', 365 * DAY); */ function loadModels () { - require (APP.'app_model.php'); - foreach (listClasses(MODELS) as $model_fn) - { - require_once (MODELS.$model_fn); - } + if(file_exists(APP.'app_model.php')) + { + require_once(APP.'app_model.php'); + } + else + { + require_once(CAKE.'app_model.php'); + } + foreach (listClasses(MODELS) as $model_fn) + { + require_once (MODELS.$model_fn); + } } /** @@ -67,18 +74,20 @@ function loadModels () * @uses CONTROLLERS */ function loadControllers () -{ - require (APP.'app_controller.php'); - - foreach (listClasses(HELPERS) as $helper) - { - require_once (HELPERS.$helper.'.php'); - } - - foreach (listClasses(CONTROLLERS) as $controller) - { - require_once (CONTROLLERS.$controller.'.php'); - } +{ + if(file_exists(APP.'app_controller.php')) + { + require_once(APP.'app_controller.php'); + } + else + { + require_once(CAKE.'app_controller.php'); + } + + foreach (listClasses(CONTROLLERS) as $controller) + { + require_once (CONTROLLERS.$controller.'.php'); + } } /** @@ -89,15 +98,29 @@ function loadControllers () */ function loadController ($name) { - $controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php'; - $helper_fn = HELPERS.Inflector::underscore($name).'_helper.php'; - - require_once(APP.'app_controller.php'); - - if (file_exists($helper_fn)) - require_once($helper_fn); - - return file_exists($controller_fn)? require_once($controller_fn): false; + if(file_exists(CONTROLLERS.Inflector::underscore($name).'_controller.php')) + { + $controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php'; + } + elseif(file_exists(LIBS.'controller'.DS.Inflector::underscore($name).'_controller.php')) + { + $controller_fn = LIBS.'controller'.DS.Inflector::underscore($name).'_controller.php'; + } + else + { + $controller_fn = false; + } + + if(file_exists(APP.'app_controller.php')) + { + require_once(APP.'app_controller.php'); + } + else + { + require_once(CAKE.'app_controller.php'); + } + + return file_exists($controller_fn)? require_once($controller_fn): false; } /** @@ -335,4 +358,23 @@ function params($p) } +function setUri() { + if (isset($_SERVER['REQUEST_URI'])) + { + $uri = $_SERVER['REQUEST_URI']; + } + else + { + if (isset($_SERVER['argv'])) + { + $uri = $_SERVER['PHP_SELF'] .'/'. $_SERVER['argv'][0]; + } + else + { + $uri = $_SERVER['PHP_SELF'] .'/'. $_SERVER['QUERY_STRING']; + } + } + return $uri; +} + ?> \ No newline at end of file diff --git a/libs/dispatcher.php b/cake/dispatcher.php similarity index 76% rename from libs/dispatcher.php rename to cake/dispatcher.php index ae130068c..ec4b4bb96 100644 --- a/libs/dispatcher.php +++ b/cake/dispatcher.php @@ -35,7 +35,7 @@ /** * Add Description */ -uses('error_messages', 'object', 'router', 'controller', 'scaffold'); +uses('error_messages', 'object', 'router', '/controller/controller', '/controller/scaffold'); /** * Short description for class. @@ -85,7 +85,6 @@ class Dispatcher extends Object $params['render'] = 0; } - if (empty($params['controller'])) { $missingController = true; @@ -103,15 +102,16 @@ class Dispatcher extends Object if ($missingController) { - $ctrlClass = 'AppController'; - $controller = new $ctrlClass($this); + $controller =& new AppController(); $params['action'] = 'missingController'; $params['controller'] = Inflector::camelize($params['controller']."Controller"); $controller->missingController = $params['controller']; + $controller->webroot = $this->webroot; + return $this->_invoke($controller, $params ); } else { - $controller = new $ctrlClass($this); + $controller =& new $ctrlClass($this); } $classMethods = get_class_methods($controller); @@ -129,6 +129,7 @@ class Dispatcher extends Object $controller->base = $this->base; $controller->here = $this->base.'/'.$url; + $controller->webroot = $this->webroot; $controller->params = $params; $controller->action = $params['action']; $controller->data = empty($params['data'])? null: $params['data']; @@ -235,21 +236,76 @@ class Dispatcher extends Object */ function baseUrl() { - if (defined('BASE_URL')) - { - return BASE_URL; - } + $base = null; + if (defined('BASE_URL')) + { + $base = BASE_URL; + } $docRoot = $_SERVER['DOCUMENT_ROOT']; $scriptName = $_SERVER['PHP_SELF']; + - // if document root ends with 'public', it's probably correctly set + // if document root ends with 'webroot', it's probably correctly set $r = null; - if (ereg('/^.*/public(\/)?$/', $docRoot)) - return preg_match('/^(.*)\/index\.php$/', $scriptName, $r)? $r[1]: false; + if (preg_match('/\\/'.APP_DIR.'\/'.WEBROOT_DIR.'(\/)?$/i', $docRoot)) + { + $this->webroot = DS; + //return preg_match('/\\/index.php(\/)?$/i', $scriptName, $r)? $base.$r[1]: $base; + if (preg_match('/\\/index.php(\/)?$/i', $scriptName, $r)) + { + if(!empty($r[1])) + { + return $base.$r[1]; + } + else + { + return $base; + } + } + else + { + return $base; + } + } else - // document root is probably not set to Cake 'public' dir - return preg_match('/^(.*)\/public\/index\.php$/', $scriptName, $r)? $r[1]: false; + { + if(empty($base)){ + $isDir = explode('/', setUri()); + $first = $isDir[1]; + $webPath[] = DS.$first.DS; + foreach ($isDir as $dirName) + { + if(!empty($dirName) && is_dir($docRoot.$first.DS.$dirName)) + { + $webPath[] = $dirName.DS; + } + } + $webroot = implode('', $webPath); + $base = substr($webroot, 0, -1); + } + else + { + $webroot =setUri(); + } + $this->webroot = preg_replace('/(?:'.APP_DIR.'(.*)|index\\.php(.*))/i', '', $webroot).APP_DIR.DS.WEBROOT_DIR.DS; + // document root is probably not set to Cake 'webroot' dir + if (preg_match('/\\/index.php(\/)?$/i', $scriptName, $r)) + { + if(!empty($r[1])) + { + return $base.$r[1]; + } + else + { + return $base; + } + } + else + { + return $base; + } + } } diff --git a/docs/CHANGELOG.txt b/cake/docs/CHANGELOG.txt similarity index 100% rename from docs/CHANGELOG.txt rename to cake/docs/CHANGELOG.txt diff --git a/docs/COPYING.txt b/cake/docs/COPYING.txt similarity index 100% rename from docs/COPYING.txt rename to cake/docs/COPYING.txt diff --git a/docs/CREDITS.txt b/cake/docs/CREDITS.txt similarity index 100% rename from docs/CREDITS.txt rename to cake/docs/CREDITS.txt diff --git a/docs/LICENSE.txt b/cake/docs/LICENSE.txt similarity index 100% rename from docs/LICENSE.txt rename to cake/docs/LICENSE.txt diff --git a/docs/README.txt b/cake/docs/README.txt similarity index 100% rename from docs/README.txt rename to cake/docs/README.txt diff --git a/libs/cache.php b/cake/libs/cache.php similarity index 100% rename from libs/cache.php rename to cake/libs/cache.php diff --git a/libs/class_registry.php b/cake/libs/class_registry.php similarity index 100% rename from libs/class_registry.php rename to cake/libs/class_registry.php diff --git a/libs/acl.php b/cake/libs/controller/components/acl.php similarity index 100% rename from libs/acl.php rename to cake/libs/controller/components/acl.php diff --git a/libs/acl_base.php b/cake/libs/controller/components/acl_base.php similarity index 100% rename from libs/acl_base.php rename to cake/libs/controller/components/acl_base.php diff --git a/libs/controller.php b/cake/libs/controller/controller.php similarity index 94% rename from libs/controller.php rename to cake/libs/controller/controller.php index 34bcc6e45..e12e717e2 100644 --- a/libs/controller.php +++ b/cake/libs/controller/controller.php @@ -32,8 +32,7 @@ /** * Include files */ -uses('model', 'inflector', 'folder', 'view', 'helper'); - +uses('/model/model', 'inflector', 'folder', '/view/view', '/view/helper'); /** * Controller @@ -374,6 +373,7 @@ class Controller extends Object */ function missingController() { + $this->autoLayout = true; $this->pageTitle = 'Missing Controller'; $this->render('../errors/missingController'); } @@ -384,6 +384,7 @@ class Controller extends Object */ function missingAction() { + $this->autoLayout = true; $this->pageTitle = 'Missing Method in Controller'; $this->render('../errors/missingAction'); } @@ -394,6 +395,7 @@ class Controller extends Object */ function missingDatabase() { + $this->autoLayout = true; $this->pageTitle = 'Scaffold Missing Database Connection'; //We are simulating action call below, this is not a filename! $this->render('../errors/missingScaffolddb'); @@ -405,18 +407,47 @@ class Controller extends Object */ function missingTable($tableName) { + $this->autoLayout = true; $this->missingTableName = $tableName; $this->pageTitle = 'Missing Database Table'; //We are simulating action call below, this is not a filename! $this->render('../errors/missingTable'); } +/** + * Renders the Missing Helper file web page. + * + */ + function missingHelperFile($file) + { + $this->missingHelperFile = $file; + $this->missingHelperClass = Inflector::camelize($file) . "Helper"; + $this->pageTitle = 'Missing Helper File'; + //We are simulating action call below, this is not a filename! + $this->render('../errors/missingHelperFile'); + } + + +/** + * Renders the Missing Helper class web page. + * + */ + function missingHelperClass($class) + { + $this->missingHelperClass = Inflector::camelize($class) . "Helper"; + $this->missingHelperFile = Inflector::underscore($class); + $this->pageTitle = 'Missing Helper Class'; + //We are simulating action call below, this is not a filename! + $this->render('../errors/missingHelperClass'); + } + /** * Renders the Missing Table web page. * */ function missingConnection() { + $this->autoLayout = true; $this->pageTitle = 'Missing Database Connection'; //We are simulating action call below, this is not a filename! $this->render('../errors/missingDatabase'); @@ -480,7 +511,18 @@ class Controller extends Object $this->set('pause', $pause); $this->set('page_title', $message); - $this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml'); + if(file_exists(VIEWS.'layouts'.DS.'flash.thtml')) + { + $flash = VIEWS.'layouts'.DS.'flash.thtml'; + } + else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml')) + { + $flash = LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml'; + } + + + + $this->render(null,false,$flash); } /** diff --git a/app/controllers/pages_controller.php b/cake/libs/controller/pages_controller.php similarity index 97% rename from app/controllers/pages_controller.php rename to cake/libs/controller/pages_controller.php index 5788e33cf..021040e9b 100644 --- a/app/controllers/pages_controller.php +++ b/cake/libs/controller/pages_controller.php @@ -45,7 +45,7 @@ * @package cake * @subpackage cake.app.controllers */ -class PagesController extends PagesHelper{ +class PagesController extends AppController{ /** * Enter description here... @@ -72,7 +72,6 @@ class PagesController extends PagesHelper{ { $this->redirect('/'); } - $this->set('page', $path[0]); $this->set('subpage', empty($path[1])? null: $path[1]); $this->set('title', ucfirst($path[count($path)-1])); diff --git a/libs/scaffold.php b/cake/libs/controller/scaffold.php similarity index 96% rename from libs/scaffold.php rename to cake/libs/controller/scaffold.php index 4ca1e4269..22bb480a7 100644 --- a/libs/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -34,7 +34,7 @@ /** * Enter description here... */ -uses('model', 'template', 'inflector', 'object'); +uses('/model/model', 'inflector', 'object'); /** * Scaffolding is a set of automatic views, forms and controllers for starting web development work faster. @@ -145,7 +145,7 @@ class Scaffold extends Object { $this->controllerClass->params['data'] = $this->controllerClass->models[$this->modelKey]->read(); $this->controllerClass->set('data', $this->controllerClass->params['data'] ); $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames( $this->controllerClass->params['data'], false ) ); - $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'show.thtml'); + $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'show.thtml'); } /** @@ -157,7 +157,7 @@ class Scaffold extends Object { { $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(null,false) ); $this->controllerClass->set('data', $this->controllerClass->models[$this->modelKey]->findAll()); - $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml'); + $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml'); } /** @@ -168,7 +168,7 @@ class Scaffold extends Object { function _scaffoldNew($params) { $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() ); - $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); + $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); } /** @@ -182,7 +182,7 @@ class Scaffold extends Object { // generate the field names. $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames($this->controllerClass->params['data']) ); $this->controllerClass->set('data', $this->controllerClass->params['data']); - $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml'); + $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml'); } @@ -204,7 +204,7 @@ class Scaffold extends Object { { $this->controllerClass->set('data', $this->controllerClass->params['data']); $this->controllerClass->validateErrors($this->controllerClass->models[$this->modelKey]); - $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); + $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); } } @@ -263,6 +263,11 @@ class Scaffold extends Object { */ function _scaffoldView ($params) { + if(!in_array('form', $this->controllerClass->helpers)) + { + $this->controllerClass->helpers[] = 'form'; + } + $isDataBaseSet = DboFactory::getInstance($this->controllerClass->useDbConfig); if(!empty($isDataBaseSet)) { diff --git a/libs/controllers/templates/scaffolds/edit.thtml b/cake/libs/controller/templates/scaffolds/edit.thtml similarity index 81% rename from libs/controllers/templates/scaffolds/edit.thtml rename to cake/libs/controller/templates/scaffolds/edit.thtml index 898b41887..15b7ca607 100644 --- a/libs/controllers/templates/scaffolds/edit.thtml +++ b/cake/libs/controller/templates/scaffolds/edit.thtml @@ -1,13 +1,10 @@ formTag('/'.Inflector::underscore($this->name).'/update'); - echo $form->generateFields( $html, $fieldNames ); + echo $form->generateFields( $fieldNames ); - echo $form->generateSubmitDiv( $html, 'Save' ) + echo $form->generateSubmitDiv( 'Save' ) ?>
    diff --git a/libs/controllers/templates/scaffolds/list.thtml b/cake/libs/controller/templates/scaffolds/list.thtml similarity index 100% rename from libs/controllers/templates/scaffolds/list.thtml rename to cake/libs/controller/templates/scaffolds/list.thtml diff --git a/cake/libs/controller/templates/scaffolds/new.thtml b/cake/libs/controller/templates/scaffolds/new.thtml new file mode 100644 index 000000000..a17eeb62d --- /dev/null +++ b/cake/libs/controller/templates/scaffolds/new.thtml @@ -0,0 +1,7 @@ +formTag('/'.Inflector::underscore($this->name).'/create'); + + echo $form->generateFields( $fieldNames ); + + echo $form->generateSubmitDiv( 'Add' ) +?> diff --git a/cake/libs/controller/templates/scaffolds/scaffold.thtml b/cake/libs/controller/templates/scaffolds/scaffold.thtml new file mode 100644 index 000000000..9814bf8ef --- /dev/null +++ b/cake/libs/controller/templates/scaffolds/scaffold.thtml @@ -0,0 +1,15 @@ + + + + <?php echo $title_for_layout; ?> + charsetTag('UTF-8'); ?> + cssTag('cake.scaffold'); ?> + cssTag('cake.forms'); ?> + + +
    +

    + +
    + + 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', '
    %s%s'); * @since CakePHP v 0.9.2 * */ -class FormHelper +class FormHelper extends Helper { + var $helpers = array('html'); /** * Constructor which takes an instance of the HtmlHelper class. * @@ -86,11 +82,11 @@ class FormHelper * @param string $field If field is to be used for CRUD, this should be modelName/fieldName * @return bool If there are errors this method returns true, else false. */ - function isFieldError($html, $field ) + function isFieldError($field ) { $error = 1; - $html->setFormTag( $field ); - if( $error == $html->tagIsInvalid( $html->model, $html->field) ) + $this->html->setFormTag( $field ); + if( $error == $this->html->tagIsInvalid( $this->html->model, $this->html->field) ) { return true; } else { @@ -137,7 +133,6 @@ class FormHelper /** * Returns a formatted INPUT tag for HTML FORMs. * - * @param HtmlHelper $html The HtmlHelper object which is creating this form. * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName * @param string $prompt Text that will appear in the label field. * @param bool $required True if this field is required. @@ -146,9 +141,9 @@ class FormHelper * @param array $htmlOptions * @return string The formatted INPUT element */ - function generateInputDiv($html, $tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) + function generateInputDiv($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) { - $str = $html->inputTag( $tagName, $size, $htmlOptions ); + $str = $this->html->inputTag( $tagName, $size, $htmlOptions ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -158,7 +153,7 @@ class FormHelper $strError = ""; // initialize the error to empty. - if( $this->isFieldError( $html, $tagName ) ) + if( $this->isFieldError( $tagName ) ) { // if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); @@ -182,10 +177,10 @@ class FormHelper * @param array $htmlOptions * @return string The formatted INPUT element */ - function generateCheckboxDiv($html, $tagName, $prompt, $required=false, $errorMsg=null, $htmlOptions=null ) + function generateCheckboxDiv($tagName, $prompt, $required=false, $errorMsg=null, $htmlOptions=null ) { $htmlOptions['class'] = "inputCheckbox"; - $str = $html->checkbox( $tagName, null, $htmlOptions ); + $str = $this->html->checkbox( $tagName, null, $htmlOptions ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -195,7 +190,7 @@ class FormHelper $strError = ""; // initialize the error to empty. - if( $this->isFieldError( $html, $tagName ) ) + if( $this->isFieldError( $tagName ) ) { // if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); @@ -210,7 +205,6 @@ class FormHelper /** * Returns a formatted date option element for HTML FORMs. * - * @param HtmlHelper $html The HtmlHelper object which is creating this form. * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName * @param string $prompt Text that will appear in the label field. * @param bool $required True if this field is required. @@ -219,9 +213,9 @@ class FormHelper * @param array $htmlOptions * @return string The formatted INPUT element */ - function generateDate($html, $tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) + function generateDate($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) { - $str = $html->dateTimeOptionTag( $tagName, 'MDY' , 'NONE' ); + $str = $this->html->dateTimeOptionTag( $tagName, 'MDY' , 'NONE' ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -231,7 +225,7 @@ class FormHelper $strError = ""; // initialize the error to empty. - if( $this->isFieldError( $html, $tagName ) ) + if( $this->isFieldError( $tagName ) ) { // if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); @@ -247,7 +241,6 @@ class FormHelper /** * Returns a formatted datetime option element for HTML FORMs. * - * @param HtmlHelper $html The HtmlHelper object which is creating this form. * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName * @param string $prompt Text that will appear in the label field. * @param bool $required True if this field is required. @@ -256,9 +249,9 @@ class FormHelper * @param array $htmlOptions * @return string The formatted datetime option element */ - function generateDateTime($html, $tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) + function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) { - $str = $html->dateTimeOptionTag( $tagName, 'MDY' , '12' ); + $str = $this->html->dateTimeOptionTag( $tagName, 'MDY' , '12' ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -268,7 +261,7 @@ class FormHelper $strError = ""; // initialize the error to empty. - if( $this->isFieldError( $html, $tagName ) ) + if( $this->isFieldError( $tagName ) ) { // if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); @@ -284,7 +277,6 @@ class FormHelper /** * Returns a formatted TEXTAREA inside a DIV for use with HTML forms. * - * @param HtmlHelper $html The HtmlHelper object which is creating this form. * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName * @param string $prompt Text that will appear in the label field. * @param boolean $required True if this field is required. @@ -294,9 +286,9 @@ class FormHelper * @param array $htmlOptions * @return string The formatted TEXTAREA element */ - function generateAreaDiv($html, $tagName, $prompt, $required=false, $errorMsg=null, $cols=60, $rows=10, $htmlOptions=null ) + function generateAreaDiv($tagName, $prompt, $required=false, $errorMsg=null, $cols=60, $rows=10, $htmlOptions=null ) { - $str = $html->areaTag( $tagName, $cols, $rows, $htmlOptions ); + $str = $this->html->areaTag( $tagName, $cols, $rows, $htmlOptions ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -306,7 +298,7 @@ class FormHelper $strError = ""; // initialize the error to empty. - if( $this->isFieldError( $html, $tagName ) ) + if( $this->isFieldError( $tagName ) ) { // if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); @@ -321,7 +313,6 @@ class FormHelper /** * Returns a formatted SELECT tag for HTML FORMs. * - * @param HtmlHelper $html The HtmlHelper object which is creating this form * @param string $tagName If field is to be used for CRUD, this should be modelName/fieldName * @param string $prompt Text that will appear in the label field * @param array $options Options to be contained in SELECT element @@ -332,9 +323,9 @@ class FormHelper * @param string $errorMsg Text that will appear if an error has occurred * @return string The formatted INPUT element */ - function generateSelectDiv($html, $tagName, $prompt, $options, $selected=null, $selectAttr=null, $optionAttr=null, $required=false, $errorMsg=null) + function generateSelectDiv($tagName, $prompt, $options, $selected=null, $selectAttr=null, $optionAttr=null, $required=false, $errorMsg=null) { - $str = $html->selectTag( $tagName, $options, $selected, $selectAttr, $optionAttr ); + $str = $this->html->selectTag( $tagName, $options, $selected, $selectAttr, $optionAttr ); $strLabel = $this->labelTag( $tagName, $prompt ); $divClass = "optional"; @@ -344,7 +335,7 @@ class FormHelper $strError = ""; // initialize the error to empty. - if( $this->isFieldError( $html, $tagName ) ) + if( $this->isFieldError( $tagName ) ) { // if it was an error that occured, then add the error message, and append " error" to the div tag. $strError = $this->pTag( 'error', $errorMsg ); @@ -359,26 +350,24 @@ class FormHelper /** * Returns a formatted submit widget for HTML FORMs. * - * @param HtmlHelper $html The HtmlHelper object which is creating this form * @param string $prompt Text that will appear on the widget * @param array $htmlOptions * @return string The formatted submit widget */ - function generateSubmitDiv($html, $displayText, $htmlOptions = null) + function generateSubmitDiv($displayText, $htmlOptions = null) { - return $this->divTag( 'submit', $html->submitTag( $displayText, $htmlOptions) ); + return $this->divTag( 'submit', $this->html->submitTag( $displayText, $htmlOptions) ); } /** * Generates an form to go onto a HtmlHelper object. * - * @param HtmlHelper $html The HtmlHelper object which is creating this form * @param array $fields An array of form field definitions * @param boolean $readOnly True if the form should be rendered as READONLY * @return string The completed form specified by the $fields parameter */ - function generateFields( $html, $fields, $readOnly = false ) + function generateFields( $fields, $readOnly = false ) { $strFormFields = ''; @@ -392,7 +381,7 @@ class FormHelper if( !isset( $field['errorMsg'] ) ) $field['errorMsg'] = null; if( !isset( $field['htmlOptions'] ) ) - $field['htmlOptions'] = null; + $field['htmlOptions'] = array(); if( $readOnly ) { @@ -406,10 +395,10 @@ class FormHelper { $field['size'] = 40; } - $strFormFields = $strFormFields.$this->generateInputDiv( $html, $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['size'], $field['htmlOptions'] ); + $strFormFields = $strFormFields.$this->generateInputDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['size'], $field['htmlOptions'] ); break; case "checkbox" : - $strFormFields = $strFormFields.$this->generateCheckboxDiv( $html, $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['htmlOptions'] ); + $strFormFields = $strFormFields.$this->generateCheckboxDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['htmlOptions'] ); break; case "select"; case "selectMultiple"; @@ -430,7 +419,7 @@ class FormHelper if( $readOnly ) $field['selectAttr']['DISABLED'] = true; - $strFormFields = $strFormFields.$this->generateSelectDiv( $html, $field['tagName'], $field['prompt'], $field['options'], $field['selected'], $field['selectAttr'], $field['optionsAttr'], $field['required'], $field['errorMsg'] ); + $strFormFields = $strFormFields.$this->generateSelectDiv( $field['tagName'], $field['prompt'], $field['options'], $field['selected'], $field['selectAttr'], $field['optionsAttr'], $field['required'], $field['errorMsg'] ); } break; case "area"; @@ -439,11 +428,11 @@ class FormHelper $field['rows'] = 10; if( !isset( $field['cols'] ) ) $field['cols'] = 60; - $strFormFields = $strFormFields.$this->generateAreaDiv( $html, $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['cols'], $field['rows'], $field['htmlOptions'] ); + $strFormFields = $strFormFields.$this->generateAreaDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['cols'], $field['rows'], $field['htmlOptions'] ); } break; case "fieldset"; - $strFieldsetFields = $this->generateFields( $html, $field['fields'] ); + $strFieldsetFields = $this->generateFields( $field['fields'] ); $strFieldSet = sprintf( '
    @@ -457,13 +446,13 @@ class FormHelper $strFormFields = $strFormFields.$strFieldSet; break; case "hidden"; - $strFormFields = $strFormFields.$html->hiddenTag( $field['tagName']); + $strFormFields = $strFormFields . $this->html->hiddenTag( $field['tagName']); break; case "date": - $strFormFields = $strFormFields.$this->generateDate( $html, $field['tagName'], $field['prompt'] ); + $strFormFields = $strFormFields.$this->generateDate( $field['tagName'], $field['prompt'] ); break; case "datetime": - $strFormFields = $strFormFields.$this->generateDateTime( $html, $field['tagName'], $field['prompt'] ); + $strFormFields = $strFormFields.$this->generateDateTime( $field['tagName'], $field['prompt'] ); break; default: //bugbug: i don't know how to put out a notice that an unknown type was entered. diff --git a/libs/helpers/html.php b/cake/libs/view/helpers/html.php similarity index 99% rename from libs/helpers/html.php rename to cake/libs/view/helpers/html.php index 8b4c8cc06..3cefdc206 100644 --- a/libs/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -167,7 +167,7 @@ class HtmlHelper extends Helper $output = $this->base.'/'.strtolower($this->params['controller']).'/'.$url; } - return $this->output(ereg_replace('&([^a])', '&\1', $output), $return); + return $this->output(preg_replace('/&([^a])/', '&\1', $output), $return); } /** @@ -338,7 +338,7 @@ class HtmlHelper extends Helper */ function css($path, $rel = 'stylesheet', $htmlAttributes = null, $return = false) { - $url = "{$this->base}/".(COMPRESS_CSS? 'c': '')."css/{$path}.css"; + $url = "{$this->webroot}".(COMPRESS_CSS? 'c': '').CSS_URL.$path.".css"; return $this->output(sprintf($this->tags['css'], $rel, $url, $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return); } @@ -423,7 +423,7 @@ class HtmlHelper extends Helper function image($path, $htmlAttributes = null, $return = false) { - $url = $this->base.IMAGES_URL.$path; + $url = $this->webroot.IMAGES_URL.$path; $alt = isset($htmlAttributes['alt']) ? $htmlAttributes['alt'] : ""; return $this->output(sprintf($this->tags['image'], $url, $alt, $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return); } diff --git a/libs/helpers/javascript.php b/cake/libs/view/helpers/javascript.php similarity index 76% rename from libs/helpers/javascript.php rename to cake/libs/view/helpers/javascript.php index 0ea100d0f..aae18fd88 100644 --- a/libs/helpers/javascript.php +++ b/cake/libs/view/helpers/javascript.php @@ -42,6 +42,10 @@ class JavascriptHelper extends Helper { + + var $_cachedEvents = array(); + var $_cacheEvents = false; + /** * Returns a JavaScript script tag. * @@ -61,7 +65,7 @@ class JavascriptHelper extends Helper */ function link($url) { - if(strpos($url, ".") === false) $url .= ".js"; + if(strpos($url, ".") === false) $url .= ".js"; return sprintf($this->tags['javascriptlink'], $this->base . JS_URL . $url); } @@ -73,8 +77,8 @@ class JavascriptHelper extends Helper */ function linkOut($url) { - if(strpos($url, ".") === false) $url .= ".js"; - return sprintf($this->tags['javascriptlink'], $url); + if(strpos($url, ".") === false) $url .= ".js"; + return sprintf($this->tags['javascriptlink'], $url); } /** @@ -99,10 +103,50 @@ class JavascriptHelper extends Helper * @param boolean $useCapture default true * @return boolean true on success */ - function event ($object, $event, $observer, $useCapture = true) - { - return $this->codeBlock("Event.observe($object, '$event', $observer, $useCapture);"); - } + function event ($object, $event, $observer, $useCapture = true) + { + if($useCapture == true) + { + $useCapture = "true"; + } + else + { + $useCapture = "false"; + } + + $b = "Event.observe($object, '$event', $observer, $useCapture);"; + if($this->_cacheEvents === true) + { + $this->_cachedEvents[] = $b; + } + else + { + return $this->codeBlock($b); + } + } + + +/** + * Cache JavaScript events created with event() + * + * @return null + */ + function cacheEvents () + { + $this->_cacheEvents = true; + } + + +/** + * Write cached JavaScript events + * + * @return string A single code block of all cached JavaScript events created with event() + */ + function writeEvents () + { + $this->_cacheEvents = false; + return $this->codeBlock("\n" . implode("\n", $this->_cachedEvents) . "\n"); + } /** @@ -116,7 +160,7 @@ class JavascriptHelper extends Helper */ function includeScript ($script = "") { - $dir = VENDORS . "/javascript"; + $dir = substr(JS, 0, strlen(JS) - 1); if($script == "") { $files = scandir($dir); $javascript = ''; diff --git a/libs/helpers/number.php b/cake/libs/view/helpers/number.php similarity index 81% rename from libs/helpers/number.php rename to cake/libs/view/helpers/number.php index 4dd82f00e..230608198 100644 --- a/libs/helpers/number.php +++ b/cake/libs/view/helpers/number.php @@ -51,6 +51,7 @@ class NumberHelper extends Helper * @param float $number A floating point number. * @param integer $precision The precision of the returned number. * @return float Enter description here... + * @static */ function precision($number, $precision = 3) { @@ -62,6 +63,7 @@ class NumberHelper extends Helper * * @param integer $length Size in bytes * @return string Human readable size + * @static */ function toReadableSize($size) { @@ -69,10 +71,10 @@ class NumberHelper extends Helper { case 1: return '1 Byte'; case $size < 1024: return $size . ' Bytes'; - case $size < 1024 * 1024: return $this->precision($size / 1024, 0) . ' KB'; - case $size < 1024 * 1024 * 1024: return $this->precision($size / 1024 / 1024, 2) . ' MB'; - case $size < 1024 * 1024 * 1024 * 1024: return $this->precision($size / 1024 / 1024 / 1024, 2) . ' GB'; - case $size < 1024 * 1024 * 1024 * 1024 * 1024: return $this->precision($size / 1024 / 1024 / 1024 / 1024, 2) . ' TB'; + case $size < 1024 * 1024: return NumberHelper::precision($size / 1024, 0) . ' KB'; + case $size < 1024 * 1024 * 1024: return NumberHelper::precision($size / 1024 / 1024, 2) . ' MB'; + case $size < 1024 * 1024 * 1024 * 1024: return NumberHelper::precision($size / 1024 / 1024 / 1024, 2) . ' GB'; + case $size < 1024 * 1024 * 1024 * 1024 * 1024: return NumberHelper::precision($size / 1024 / 1024 / 1024 / 1024, 2) . ' TB'; } } @@ -82,11 +84,12 @@ class NumberHelper extends Helper * @param float $number A floating point number * @param integer $precision The precision of the returned number * @return string Percentage string + * @static */ function toPercentage($number, $precision = 2) { - return $this->precision($number, $precision) . '%'; + return NumberHelper::precision($number, $precision) . '%'; } } -?> \ No newline at end of file +?> diff --git a/libs/helpers/text.php b/cake/libs/view/helpers/text.php similarity index 100% rename from libs/helpers/text.php rename to cake/libs/view/helpers/text.php diff --git a/libs/helpers/time.php b/cake/libs/view/helpers/time.php similarity index 95% rename from libs/helpers/time.php rename to cake/libs/view/helpers/time.php index 6f50f03fc..b3c317288 100644 --- a/libs/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -1,448 +1,448 @@ - - * 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.1 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ - -/** - * Time Helper class for easy use of time data. - * - * Manipulation of time data. - * - * @package cake - * @subpackage cake.libs.helpers - * @since CakePHP v 0.9.2 - */ -class TimeHelper extends Helper -{ - /** - * Returns given string trimmed to given length, adding an ending (default: "..") if necessary. - * - * @param string $string String to trim - * @param integer $length Length of returned string, excluding ellipsis - * @param string $ending Ending to be appended after trimmed string - * @return string Trimmed string - */ - function trim($string, $length, $ending='..') - { - return substr($string, 0, $length).(strlen($string)>$length? $ending: null); - } - - - /** - * Returns a UNIX timestamp, given either a UNIX timestamp or a valid strtotime() date string. - * - * @param string $date_string Datetime string - * @return string Formatted date string - */ - function fromString ($date_string) - { - return is_integer($date_string) - ? $date_string - : strtotime($date_string); - } - - - /** - * Returns a nicely formatted date string for given Datetime string. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Formatted date string - */ - function nice ($date_string=null, $return = false) - { - $date = $date_string? strtotime($date_string): time(); - $date = $date_string? $this->fromString($date_string): time(); - $ret = date("D, M jS Y, H:i", $date); - - return $this->output($ret, $return); - } - - - /** - * Returns a formatted descriptive date string for given datetime string. - * - * If the given date is today, the returned string could be "Today, 16:54". - * If the given date was yesterday, the returned string could be "Yesterday, 16:54". - * If $date_string's year is the current year, the returned string does not - * include mention of the year. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Described, relative date string - */ - function niceShort ($date_string=null,$return = false) - { - $date = $date_string? $this->fromString($date_string): time(); - - $y = $this->isThisYear($date)? '': ' Y'; - - if ($this->isToday($date)) - { - $ret = "Today, ".date("H:i", $date); - } - elseif ($this->wasYesterday($date)) - { - $ret = "Yesterday, ".date("H:i", $date); - } - else - { - $ret = date("M jS{$y}, H:i", $date); - } - - return $this->output($ret, $return); - } - - - /** - * Returns true if given datetime string is today. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return boolean True if datetime string is today - */ - function isToday ($date_string) - { - $date = $this->fromString($date_string, $return = false); - $ret = date('Y-m-d', $date) == date('Y-m-d', time()); - - return $this->output($ret, $return); - } - - - /** - * Returns a partial SQL string to search for all records between two dates. - * - * @param string $date_string Datetime string or Unix timestamp - * @param string $end Datetime string or Unix timestamp - * @param string $field_name Name of database field to compare with - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Partial SQL string. - */ - function daysAsSql ($begin, $end, $field_name, $return = false) - { - $begin = $this->fromString($begin); - $end = $this->fromString($end); - $begin = date('Y-m-d', $begin).' 00:00:00'; - $end = date('Y-m-d', $end). ' 23:59:59'; - - $ret = "($field_name >= '$begin') AND ($field_name <= '$end')"; - - return $this->output($ret, $return); - } - - - /** - * Returns a partial SQL string to search for all records between two times - * occurring on the same day. - * - * @param string $date_string Datetime string or Unix timestamp - * @param string $field_name Name of database field to compare with - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Partial SQL string. - */ - function dayAsSql ($date_string, $field_name, $return = false) - { - $date = $this->fromString($date_string); - $ret = $this->daysAsSql($date_string, $date_string, $field_name); - - return $this->output($ret, $return); - } - - - /** - * Returns true if given datetime string is within current year. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return boolean True if datetime string is within current year - */ - function isThisYear ($date_string, $return = false) { - $date = $this->fromString($date_string); - $ret = date('Y', $date) == date('Y', time()); - - return $this->output($ret, $return); - } - - - /** - * Returns true if given datetime string was yesterday. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return boolean True if datetime string was yesterday - */ - function wasYesterday ($date_string, $return = false) { - $date = $this->fromString($date_string); - $ret = date('Y-m-d', $date) == date('Y-m-d', strtotime('yesterday')); - - return $this->output($ret, $return); - } - - - /** - * Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime(). - * - * @param string $date_string Datetime string to be represented as a Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return int Unix timestamp - */ - function toUnix ($date_string, $return = false) { - $ret = strtotime($date_string); - - return $this->output($ret, $return); - } - - /** - * Returns a date formatted for Atom RSS feeds. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Formatted date string - */ - function toAtom ($date_string, $return = false) { - $date = $this->fromString($date_string); - $ret = date('Y-m-d\TH:i:s\Z', $date); - - return $this->output($ret, $return); - } - - /** - * Formats date for RSS feeds - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Formatted date string - */ - function toRSS ($date_string, $return = false) { - $date = TimeHelper::fromString($date_string); - $ret = date("r", $date); - - return $this->output($ret, $return); - } - - - /** - * Returns either a relative date or a formatted date depending - * on the difference between the current time and given datetime. - * $datetime should be in a strtotime-parsable format like MySQL datetime. - * - * Relative dates look something like this: - * 3 weeks, 4 days ago - * 15 seconds ago - * Formatted dates look like this: - * on 02/18/2004 - * - * The returned string includes 'ago' or 'on' and assumes you'll properly add a word - * like 'Posted ' before the function output. - * - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Relative time string. - */ - function timeAgoInWords ($datetime_string, $return = false) - { - $datetime = $this->fromString($datetime_string); - - $in_seconds = $datetime; - $diff = time()-$in_seconds; - $months = floor($diff/2419200); - $diff -= $months*2419200; - $weeks = floor($diff/604800); - $diff -= $weeks*604800; - $days = floor($diff/86400); - $diff -= $days*86400; - $hours = floor($diff/3600); - $diff -= $hours*3600; - $minutes = floor($diff/60); - $diff -= $minutes*60; - $seconds = $diff; - - if ($months>0) - { - // over a month old, just show date (mm/dd/yyyy format) - $ret = 'on '.date("j/n/Y", $in_seconds); - } - else - { - $relative_date=''; - if ($weeks>0) - { - // weeks and days - $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':''); - $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):''; - } - elseif ($days>0) - { - // days and hours - $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':''); - $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):''; - } - elseif ($hours>0) - { - // hours and minutes - $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''); - $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):''; - } - elseif ($minutes>0) - { - // minutes only - $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''); - } - else - { - // seconds only - $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':''); - } - } - // show relative date and add proper verbiage - $ret = $relative_date.' ago'; - - return $this->output($ret, $return); - } - - - /** - * Alias for timeAgoInWords - * @param string $date_string Datetime string or Unix timestamp - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return string Relative time string. - */ - function relativeTime ($datetime_string, $return = false) - { - $ret = $this->timeAgoInWords ($datetime_string); - - return $this->output($ret, $return); - } - - /** - * Returns true if specified datetime was within the interval specified, else false. - * - * @param mixed $timeInterval the numeric value with space then time - * type. Example of valid types: 6 hours, 2 days, 1 minute. - * @param mixed $date the datestring or unix timestamp to compare - * @param boolean $return Whether this method should return a value - * or output it. This overrides AUTO_OUTPUT. - * @return boolean - */ - function wasWithinLast($timeInterval, $date_string, $return = false) - { - $date = $this->fromString($date_string); - - $result = preg_split('/\\s/', $timeInterval); - - $numInterval = $result[0]; - $textInterval = $result[1]; - $currentTime = floor(time()); - $seconds = ($currentTime - floor($date)); - - switch($textInterval) - { - - case "seconds": - case "second": - $timePeriod = $seconds; - $ret = $return; - break; - - case "minutes": - case "minute": - $minutes = floor($seconds / 60); - $timePeriod = $minutes; - break; - - - case "hours": - case "hour": - $hours = floor($seconds / 3600); - $timePeriod = $hours; - break; - - case "days": - case "day": - $days = floor($seconds / 86400); - $timePeriod = $days; - break; - - case "weeks": - case "week": - $weeks = floor($seconds / 604800); - $timePeriod = $weeks; - break; - - - case "months": - case "month": - $months = floor($seconds / 2629743.83); - $timePeriod = $months; - break; - - - case "years": - case "year": - $years = floor($seconds / 31556926); - $timePeriod = $years; - break; - - - default: - $days = floor($seconds / 86400); - $timePeriod = $days; - break; - } - - if ($timePeriod <= $numInterval) - { - $ret = true; - } - else - { - $ret = false; - } - - return $this->output($ret, $return); - - } - - -} - + + * Copyright (c) 2005, 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.1 + * @version $Revision: 578 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2005-08-11 22:09:07 -0600 (Thu, 11 Aug 2005) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ + +/** + * Time Helper class for easy use of time data. + * + * Manipulation of time data. + * + * @package cake + * @subpackage cake.libs.helpers + * @since CakePHP v 0.9.2 + */ +class TimeHelper extends Helper +{ + /** + * Returns given string trimmed to given length, adding an ending (default: "..") if necessary. + * + * @param string $string String to trim + * @param integer $length Length of returned string, excluding ellipsis + * @param string $ending Ending to be appended after trimmed string + * @return string Trimmed string + */ + function trim($string, $length, $ending='..') + { + return substr($string, 0, $length).(strlen($string)>$length? $ending: null); + } + + + /** + * Returns a UNIX timestamp, given either a UNIX timestamp or a valid strtotime() date string. + * + * @param string $date_string Datetime string + * @return string Formatted date string + */ + function fromString ($date_string) + { + return is_integer($date_string) + ? $date_string + : strtotime($date_string); + } + + + /** + * Returns a nicely formatted date string for given Datetime string. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Formatted date string + */ + function nice ($date_string=null, $return = false) + { + $date = $date_string? strtotime($date_string): time(); + $date = $date_string? $this->fromString($date_string): time(); + $ret = date("D, M jS Y, H:i", $date); + + return $this->output($ret, $return); + } + + + /** + * Returns a formatted descriptive date string for given datetime string. + * + * If the given date is today, the returned string could be "Today, 16:54". + * If the given date was yesterday, the returned string could be "Yesterday, 16:54". + * If $date_string's year is the current year, the returned string does not + * include mention of the year. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Described, relative date string + */ + function niceShort ($date_string=null,$return = false) + { + $date = $date_string? $this->fromString($date_string): time(); + + $y = $this->isThisYear($date)? '': ' Y'; + + if ($this->isToday($date)) + { + $ret = "Today, ".date("H:i", $date); + } + elseif ($this->wasYesterday($date)) + { + $ret = "Yesterday, ".date("H:i", $date); + } + else + { + $ret = date("M jS{$y}, H:i", $date); + } + + return $this->output($ret, $return); + } + + + /** + * Returns true if given datetime string is today. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return boolean True if datetime string is today + */ + function isToday ($date_string) + { + $date = $this->fromString($date_string, $return = false); + $ret = date('Y-m-d', $date) == date('Y-m-d', time()); + + return $this->output($ret, $return); + } + + + /** + * Returns a partial SQL string to search for all records between two dates. + * + * @param string $date_string Datetime string or Unix timestamp + * @param string $end Datetime string or Unix timestamp + * @param string $field_name Name of database field to compare with + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Partial SQL string. + */ + function daysAsSql ($begin, $end, $field_name, $return = false) + { + $begin = $this->fromString($begin); + $end = $this->fromString($end); + $begin = date('Y-m-d', $begin).' 00:00:00'; + $end = date('Y-m-d', $end). ' 23:59:59'; + + $ret = "($field_name >= '$begin') AND ($field_name <= '$end')"; + + return $this->output($ret, $return); + } + + + /** + * Returns a partial SQL string to search for all records between two times + * occurring on the same day. + * + * @param string $date_string Datetime string or Unix timestamp + * @param string $field_name Name of database field to compare with + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Partial SQL string. + */ + function dayAsSql ($date_string, $field_name, $return = false) + { + $date = $this->fromString($date_string); + $ret = $this->daysAsSql($date_string, $date_string, $field_name); + + return $this->output($ret, $return); + } + + + /** + * Returns true if given datetime string is within current year. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return boolean True if datetime string is within current year + */ + function isThisYear ($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y', $date) == date('Y', time()); + + return $this->output($ret, $return); + } + + + /** + * Returns true if given datetime string was yesterday. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return boolean True if datetime string was yesterday + */ + function wasYesterday ($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y-m-d', $date) == date('Y-m-d', strtotime('yesterday')); + + return $this->output($ret, $return); + } + + + /** + * Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime(). + * + * @param string $date_string Datetime string to be represented as a Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return int Unix timestamp + */ + function toUnix ($date_string, $return = false) { + $ret = strtotime($date_string); + + return $this->output($ret, $return); + } + + /** + * Returns a date formatted for Atom RSS feeds. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Formatted date string + */ + function toAtom ($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y-m-d\TH:i:s\Z', $date); + + return $this->output($ret, $return); + } + + /** + * Formats date for RSS feeds + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Formatted date string + */ + function toRSS ($date_string, $return = false) { + $date = TimeHelper::fromString($date_string); + $ret = date("r", $date); + + return $this->output($ret, $return); + } + + + /** + * Returns either a relative date or a formatted date depending + * on the difference between the current time and given datetime. + * $datetime should be in a strtotime-parsable format like MySQL datetime. + * + * Relative dates look something like this: + * 3 weeks, 4 days ago + * 15 seconds ago + * Formatted dates look like this: + * on 02/18/2004 + * + * The returned string includes 'ago' or 'on' and assumes you'll properly add a word + * like 'Posted ' before the function output. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Relative time string. + */ + function timeAgoInWords ($datetime_string, $return = false) + { + $datetime = $this->fromString($datetime_string); + + $in_seconds = $datetime; + $diff = time()-$in_seconds; + $months = floor($diff/2419200); + $diff -= $months*2419200; + $weeks = floor($diff/604800); + $diff -= $weeks*604800; + $days = floor($diff/86400); + $diff -= $days*86400; + $hours = floor($diff/3600); + $diff -= $hours*3600; + $minutes = floor($diff/60); + $diff -= $minutes*60; + $seconds = $diff; + + if ($months>0) + { + // over a month old, just show date (mm/dd/yyyy format) + $ret = 'on '.date("j/n/Y", $in_seconds); + } + else + { + $relative_date=''; + if ($weeks>0) + { + // weeks and days + $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':''); + $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):''; + } + elseif ($days>0) + { + // days and hours + $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':''); + $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):''; + } + elseif ($hours>0) + { + // hours and minutes + $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''); + $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):''; + } + elseif ($minutes>0) + { + // minutes only + $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''); + } + else + { + // seconds only + $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':''); + } + } + // show relative date and add proper verbiage + $ret = $relative_date.' ago'; + + return $this->output($ret, $return); + } + + + /** + * Alias for timeAgoInWords + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return string Relative time string. + */ + function relativeTime ($datetime_string, $return = false) + { + $ret = $this->timeAgoInWords ($datetime_string); + + return $this->output($ret, $return); + } + + /** + * Returns true if specified datetime was within the interval specified, else false. + * + * @param mixed $timeInterval the numeric value with space then time + * type. Example of valid types: 6 hours, 2 days, 1 minute. + * @param mixed $date the datestring or unix timestamp to compare + * @param boolean $return Whether this method should return a value + * or output it. This overrides AUTO_OUTPUT. + * @return boolean + */ + function wasWithinLast($timeInterval, $date_string, $return = false) + { + $date = $this->fromString($date_string); + + $result = preg_split('/\\s/', $timeInterval); + + $numInterval = $result[0]; + $textInterval = $result[1]; + $currentTime = floor(time()); + $seconds = ($currentTime - floor($date)); + + switch($textInterval) + { + + case "seconds": + case "second": + $timePeriod = $seconds; + $ret = $return; + break; + + case "minutes": + case "minute": + $minutes = floor($seconds / 60); + $timePeriod = $minutes; + break; + + + case "hours": + case "hour": + $hours = floor($seconds / 3600); + $timePeriod = $hours; + break; + + case "days": + case "day": + $days = floor($seconds / 86400); + $timePeriod = $days; + break; + + case "weeks": + case "week": + $weeks = floor($seconds / 604800); + $timePeriod = $weeks; + break; + + + case "months": + case "month": + $months = floor($seconds / 2629743.83); + $timePeriod = $months; + break; + + + case "years": + case "year": + $years = floor($seconds / 31556926); + $timePeriod = $years; + break; + + + default: + $days = floor($seconds / 86400); + $timePeriod = $days; + break; + } + + if ($timePeriod <= $numInterval) + { + $ret = true; + } + else + { + $ret = false; + } + + return $this->output($ret, $return); + + } + + +} + ?> \ No newline at end of file diff --git a/app/views/errors/missing_action.thtml b/cake/libs/view/templates/errors/missing_action.thtml similarity index 100% rename from app/views/errors/missing_action.thtml rename to cake/libs/view/templates/errors/missing_action.thtml diff --git a/app/views/errors/missing_controller.thtml b/cake/libs/view/templates/errors/missing_controller.thtml similarity index 100% rename from app/views/errors/missing_controller.thtml rename to cake/libs/view/templates/errors/missing_controller.thtml diff --git a/app/views/errors/missing_database.thtml b/cake/libs/view/templates/errors/missing_database.thtml similarity index 100% rename from app/views/errors/missing_database.thtml rename to cake/libs/view/templates/errors/missing_database.thtml diff --git a/cake/libs/view/templates/errors/missing_helper_class.thtml b/cake/libs/view/templates/errors/missing_helper_class.thtml new file mode 100644 index 000000000..501209a11 --- /dev/null +++ b/cake/libs/view/templates/errors/missing_helper_class.thtml @@ -0,0 +1,45 @@ +controller->missingHelperClass; + $missingFile = $this->controller->missingHelperFile; + +?> +

    Missing Helper Class

    + +

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

    + + +

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

    + +

    +Fatal: Create the Class: +

    +

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

    + +

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

    + +1):?> +

    Controller dump:

    +
    +db);
    +print_r($this); 
    +?>
    +
    + \ No newline at end of file diff --git a/cake/libs/view/templates/errors/missing_helper_file.thtml b/cake/libs/view/templates/errors/missing_helper_file.thtml new file mode 100644 index 000000000..5da3d76ff --- /dev/null +++ b/cake/libs/view/templates/errors/missing_helper_file.thtml @@ -0,0 +1,45 @@ +controller->missingHelperClass; + $missingFile = $this->controller->missingHelperFile; + +?> +

    Missing Helper File

    + +

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

    + + +

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

    + +

    +Fatal: Create the Class: +

    +

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

    + +

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

    + +1):?> +

    Controller dump:

    +
    +db);
    +print_r($this); 
    +?>
    +
    + \ No newline at end of file diff --git a/app/views/errors/missing_scaffolddb.thtml b/cake/libs/view/templates/errors/missing_scaffolddb.thtml similarity index 100% rename from app/views/errors/missing_scaffolddb.thtml rename to cake/libs/view/templates/errors/missing_scaffolddb.thtml diff --git a/app/views/errors/missing_table.thtml b/cake/libs/view/templates/errors/missing_table.thtml similarity index 100% rename from app/views/errors/missing_table.thtml rename to cake/libs/view/templates/errors/missing_table.thtml diff --git a/app/views/errors/missing_view.thtml b/cake/libs/view/templates/errors/missing_view.thtml similarity index 100% rename from app/views/errors/missing_view.thtml rename to cake/libs/view/templates/errors/missing_view.thtml diff --git a/cake/libs/view/templates/layouts/ajax.thtml b/cake/libs/view/templates/layouts/ajax.thtml new file mode 100644 index 000000000..3f290130e --- /dev/null +++ b/cake/libs/view/templates/layouts/ajax.thtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/cake/libs/view/templates/layouts/default.thtml b/cake/libs/view/templates/layouts/default.thtml new file mode 100644 index 000000000..3a82704fb --- /dev/null +++ b/cake/libs/view/templates/layouts/default.thtml @@ -0,0 +1,57 @@ + + + +CakePHP : a rapid development framework :: <?=$title_for_layout?> + +charsetTag('UTF-8')?> +cssTag('cake.default')?> + + +
    + +
    + +
    +
    + + + diff --git a/cake/libs/view/templates/layouts/error.thtml b/cake/libs/view/templates/layouts/error.thtml new file mode 100644 index 000000000..0cb53875e --- /dev/null +++ b/cake/libs/view/templates/layouts/error.thtml @@ -0,0 +1,12 @@ + + + + +<?php echo $code; ?> <?php echo $name; ?> + + + +

    +

    + + diff --git a/app/views/layouts/flash.thtml b/cake/libs/view/templates/layouts/flash.thtml similarity index 100% rename from app/views/layouts/flash.thtml rename to cake/libs/view/templates/layouts/flash.thtml diff --git a/cake/libs/view/templates/pages/home.thtml b/cake/libs/view/templates/pages/home.thtml new file mode 100644 index 000000000..cf0ad8245 --- /dev/null +++ b/cake/libs/view/templates/pages/home.thtml @@ -0,0 +1,41 @@ +
    +

    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, create /app/views/pages/home.thtml. To change it's layout, create /app/views/layouts/default.thtml. You can also add some CSS styles for your pages at /webroot/css/. +

    +

    Introducing Cake

    +

    +Cake is a rapid development framework for PHP which uses commonly known design patterns like +ActiveRecord, Association Data Mapping, Front Controller and MVC. +Our primary goal is to provide a structured framework that enables PHP users at all levels +to rapidly develop robust web applications, without any loss to flexibility. +

    +

    What's New

    +

    Release 0.10.0_dev with:

    +
      +
    • Scaffolding
    • +
    • Output Types
    • +
    • Standard Modules (ACL, etc.)
    • +
    • Associations
    • +
    • Evolved Directory Structure and API to make your life easier.
    • +
    +

    Getting Involved

    +

    We are always looking for people to help with tutorials, bug requests, and documenation. +Best place to get involved is IRC. We will be implementing some contributor guidlines shortly for those of you who would like to code for the project. +Obviously, everyone and anyone can always make a suggestion, raise a new idea, help us brainstorm, and all that stuff that makes this fun. +

    +

    +#cakephp at irc.freenode.net +· +Cake PHP Google Group +· +Cake TRAC (Wiki, SVN repository, etc.) +

    +
    +

    Cake 0.10.0.x

    diff --git a/libs/view.php b/cake/libs/view/view.php similarity index 71% rename from libs/view.php rename to cake/libs/view/view.php index 16c163c0d..e0b3bc39a 100644 --- a/libs/view.php +++ b/cake/libs/view/view.php @@ -196,6 +196,7 @@ class View extends Object $this->autoLayout =& $this->controller->autoLayout; $this->autoRender =& $this->controller->autoRender; $this->base =& $this->controller->base; + $this->webroot =& $this->controller->webroot; $this->helpers =& $this->controller->helpers; $this->here =& $this->controller->here; $this->layout =& $this->controller->layout; @@ -286,7 +287,20 @@ class View extends Object // check for controller-level view handler foreach(array($this->name, 'errors') as $viewDir) { - $missingViewFileName = VIEWS.$viewDir.DS.Inflector::underscore($errorAction).'.thtml'; + if(file_exists(VIEWS.$viewDir.DS.Inflector::underscore($errorAction).'.thtml')) + { + $missingViewFileName = VIEWS.$viewDir.DS.Inflector::underscore($errorAction).'.thtml'; + } + elseif(file_exists(LIBS.'view'.DS.'templates'.DS.$viewDir.DS.Inflector::underscore($errorAction).'.thtml')) + { + $missingViewFileName = LIBS.'view'.DS.'templates'.DS.$viewDir.DS.Inflector::underscore($errorAction).'.thtml'; + } + else + { + $missingViewFileName = false; + } + + $missingViewExists = is_file($missingViewFileName); if ($missingViewExists) { @@ -458,16 +472,29 @@ class View extends Object */ function _getViewFileName($action) { - $action = Inflector::underscore($action); - $viewFileName = VIEWS.$this->viewPath.DS."{$action}.thtml"; - $viewPath = explode(DS, $viewFileName); + $action = Inflector::underscore($action); - $i = array_search('..', $viewPath); - - unset($viewPath[$i-1]); - unset($viewPath[$i]); - - return '/'.implode('/', $viewPath); + if(file_exists(VIEWS.$this->viewPath.DS.$action.'.thtml')) + { + $viewFileName = VIEWS.$this->viewPath.DS.$action.'.thtml'; + } + elseif(file_exists(LIBS.'view'.DS.'templates'.DS.'errors'.DS.$action.'.thtml')) + { + $viewFileName = LIBS.'view'.DS.'templates'.DS.'errors'.DS.$action.'.thtml'; + } + elseif(file_exists(LIBS.'view'.DS.'templates'.DS.$this->viewPath.DS.$action.'.thtml')) + { + $viewFileName = LIBS.'view'.DS.'templates'.DS.$this->viewPath.DS.$action.'.thtml'; + } + + + $viewPath = explode(DS, $viewFileName); + $i = array_search('..', $viewPath); + unset($viewPath[$i-1]); + unset($viewPath[$i]); + + $return = '/'.implode('/', $viewPath); + return $return; } /** @@ -478,18 +505,21 @@ class View extends Object */ function _getLayoutFileName() { - if(file_exists(VIEWS."layouts".DS."{$this->layout}.thtml")){ - return VIEWS."layouts".DS."{$this->layout}.thtml"; + if(file_exists(VIEWS."layouts".DS."{$this->layout}.thtml")) + { + $layoutFileName = VIEWS."layouts".DS."{$this->layout}.thtml"; } - elseif(file_exists(LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS."{$this->layout}.thtml")){ - return LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS."{$this->layout}.thtml"; + else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS."{$this->layout}.thtml")) + { + $layoutFileName = LIBS.'view'.DS.'templates'.DS."layouts".DS."{$this->layout}.thtml"; } - else{//Let allows setting path to other layouts?? - return; + else if(file_exists(LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS."{$this->layout}.thtml")) + { + $layoutFileName = LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS."{$this->layout}.thtml"; } - } + return $layoutFileName; + } - /** * Renders and returns output for given view filename with its * array of data. @@ -507,27 +537,19 @@ class View extends Object */ if ($this->helpers !== false) { - foreach ($this->helpers as $helper) + $loadedHelpers = array(); + $loadedHelpers =& $this->_loadHelpers($loadedHelpers, $this->helpers); + + foreach(array_keys($loadedHelpers) as $helper) { - $helperFn = LIBS.'helpers'.DS.Inflector::underscore($helper).'.php'; - $helperCn = ucfirst($helper).'Helper'; - if (is_file($helperFn)) - { - require_once $helperFn; - if(class_exists($helperCn)===true); - { - ${$helper} = new $helperCn; - ${$helper}->base = $this->base; - ${$helper}->here = $this->here; - ${$helper}->params = $this->params; - ${$helper}->action = $this->action; - ${$helper}->data = $this->data; - if(!empty($this->validationErrors)) - { - ${$helper}->validationErrors = $this->validationErrors; - } - } - } + ${$helper} =& $loadedHelpers[$helper]; + if(isset(${$helper}->helpers) && is_array(${$helper}->helpers)) + { + foreach(${$helper}->helpers as $subHelper) + { + ${$helper}->{$subHelper} =& $loadedHelpers[$subHelper]; + } + } } } @@ -554,6 +576,71 @@ class View extends Object return $out; } + function &_loadHelpers(&$loaded, $helpers) { + + foreach ($helpers as $helper) + { + if(in_array($helper, array_keys($loaded)) !== true) + { + $helperFn = VIEWS.'helpers'.DS.Inflector::underscore($helper).'.php'; + if(file_exists(VIEWS.'helpers'.DS.Inflector::underscore($helper).'.php')) + { + $helperFn = VIEWS.'helpers'.DS.Inflector::underscore($helper).'.php'; + } + else if(file_exists(LIBS.'view'.DS.'helpers'.DS.Inflector::underscore($helper).'.php')) + { + $helperFn = LIBS.'view'.DS.'helpers'.DS.Inflector::underscore($helper).'.php'; + } + + $helperCn = ucfirst($helper).'Helper'; + + if (is_file($helperFn)) + { + require_once $helperFn; + if(class_exists($helperCn)===true) + { + ${$helper} = new $helperCn; + ${$helper}->base = $this->base; + ${$helper}->webroot = $this->webroot; + ${$helper}->here = $this->here; + ${$helper}->params = $this->params; + ${$helper}->action = $this->action; + ${$helper}->data = $this->data; + + if(!empty($this->validationErrors)) + { + ${$helper}->validationErrors = $this->validationErrors; + } + $loaded[$helper] =& ${$helper}; + + // Find and load helper dependencies + if (isset(${$helper}->helpers) && is_array(${$helper}->helpers)) + { + $loaded =& $this->_loadHelpers($loaded, ${$helper}->helpers); + } + } + else + { + $error = new AppController(); + $error->autoLayout = true; + $error->base = $this->base; + call_user_func_array(array(&$error, 'missingHelperClass'), $helper); + exit(); + } + } + else + { + $error = new AppController(); + $error->autoLayout = true; + $error->base = $this->base; + call_user_func_array(array(&$error, 'missingHelperFile'), Inflector::underscore($helper)); + exit(); + } + } + } + + return $loaded; + } } ?> \ No newline at end of file diff --git a/scripts/bake.bat b/cake/scripts/bake.bat similarity index 100% rename from scripts/bake.bat rename to cake/scripts/bake.bat diff --git a/scripts/bake.php b/cake/scripts/bake.php similarity index 100% rename from scripts/bake.php rename to cake/scripts/bake.php diff --git a/scripts/test.bat b/cake/scripts/test.bat similarity index 100% rename from scripts/test.bat rename to cake/scripts/test.bat diff --git a/scripts/test.php b/cake/scripts/test.php similarity index 100% rename from scripts/test.php rename to cake/scripts/test.php diff --git a/index.php b/index.php index 06176ca8d..dd1855e6d 100644 --- a/index.php +++ b/index.php @@ -35,54 +35,43 @@ /** * Get Cake's root directory */ +define ('APP_DIR', 'app'); define ('DS', DIRECTORY_SEPARATOR); define ('ROOT', dirname(__FILE__).DS); +require_once ROOT.APP_DIR.DS.'config'.DS.'core.php'; +require_once ROOT.APP_DIR.DS.'config'.DS.'paths.php'; +require_once CAKE.'basics.php'; /** * We need to redefine some constants and variables, so that Cake knows it is * working without mod_rewrite. */ -define ('BASE_URL', $_SERVER['SCRIPT_NAME'].'?url='); +//define ('BASE_URL', $_SERVER['SCRIPT_NAME']); + +$uri = setUri(); /** * As mod_rewrite (or .htaccess files) is not working, we need to take care * of what would normally be rewrited, i.e. the static files in /public */ - if (empty($_GET['url']) || ($_GET['url'] == '/')) + if ($uri === '/' || $uri === '/index.php') { - require (ROOT.'public/index.php'); + $_GET['url'] = '/'; + include_once (ROOT.APP_DIR.DS.WEBROOT_DIR.DS.'index.php'); } else { - $elements = explode('/index.php?url=', $_SERVER['REQUEST_URI']); - $base = $elements[0].'/public'; - $path = $elements[1]; - - $filename = ROOT.'public'.str_replace('/', DS, $path); - $url = $base.$path; + $elements = explode('/index.php', $uri); + if(!empty($elements[1])) + { + $path = $elements[1]; + } + else + { + $path = '/'; + } + $_GET['url'] = $path; - if (file_exists($filename)) - { - if (preg_match('/^.*\.([a-z]+)$/i', $filename, $ext)) - { - switch ($ext[1]) - { - case 'jpg': - case 'jpeg': - header('Content-type: image/jpeg'); - break; - - case 'css': - header('Content-type: text/css'); - } - } - - print (file_get_contents($filename)); - die(); - } - else - { - require (ROOT.'public/index.php'); - } + include_once (ROOT.APP_DIR.DS.WEBROOT_DIR.DS.'index.php'); } ?> \ No newline at end of file diff --git a/libs/controllers/templates/rescues/diagnostics.thtml b/libs/controllers/templates/rescues/diagnostics.thtml deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/controllers/templates/rescues/missing_template.thtml b/libs/controllers/templates/rescues/missing_template.thtml deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/controllers/templates/rescues/routing_error.thtml b/libs/controllers/templates/rescues/routing_error.thtml deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/controllers/templates/rescues/template_error.thtml b/libs/controllers/templates/rescues/template_error.thtml deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/controllers/templates/rescues/unknown_action.thtml b/libs/controllers/templates/rescues/unknown_action.thtml deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/controllers/templates/scaffolds/new.thtml b/libs/controllers/templates/scaffolds/new.thtml deleted file mode 100644 index 3c7a334c1..000000000 --- a/libs/controllers/templates/scaffolds/new.thtml +++ /dev/null @@ -1,11 +0,0 @@ -formTag('/'.Inflector::underscore($this->name).'/create'); - - echo $form->generateFields( $html, $fieldNames ); - - 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 deleted file mode 100644 index 3f162ff92..000000000 --- a/libs/controllers/templates/scaffolds/scaffold.thtml +++ /dev/null @@ -1,17 +0,0 @@ - - - - <?=$title_for_layout?> - charsetTag('UTF-8')?> - cssTag('scaffold')?> - cssTag('forms')?> - - - -
    -

    - - -
    - - diff --git a/libs/file.php b/libs/file.php deleted file mode 100644 index b55a7dd8d..000000000 --- a/libs/file.php +++ /dev/null @@ -1,108 +0,0 @@ - - * 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 - */ - - -/** - * Convenience class for reading, writing and appending to files. - * - * - * @package cake - * @subpackage cake.libs - * @since CakePHP v 0.2.9 - */ -class File -{ -/** - * Path to file - * - * @var string - */ - var $path = null; - -/** - * Constructor - * - * @param string $path - * @return File - */ - function File ($path) - { - $this->path = $path; - } - -/** - * Return the contents of this File as a string. - * - * @return string Contents - */ - function read () - { - return file_get_contents($this->path); - } - -/** - * 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') - { - if (!($handle = fopen($this->path, $mode))) - { - print ("[File] Could not open {$this->path} with mode $mode!"); - return false; - } - - if (!fwrite($handle, $data)) - return false; - - if (!fclose($handle)) - return false; - - return true; - } -} - -?> \ No newline at end of file diff --git a/libs/generator/generators/components/scaffold/templates/layout.thtml b/libs/generator/generators/components/scaffold/templates/layout.thtml deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/template.php b/libs/template.php deleted file mode 100644 index 9dea15892..000000000 --- a/libs/template.php +++ /dev/null @@ -1,112 +0,0 @@ - - * 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'); - -/** - * Templating for Controller class. Takes care of rendering views. - * - * Long description for class - * - * @package cake - * @subpackage cake.libs - * @since CakePHP v 0.2.9 - */ -class Template extends Object -{ - -/** - * Base URL part - * - * @var string - * @access public - */ - var $base = null; - -/** - * Layout name - * - * @var string - * @access public - */ - var $layout = 'default'; - -/** - * Turns on or off Cake's conventional mode of rendering views. On by default. - * - * @var boolean - * @access public - */ - var $autoRender = true; - -/** - * Turns on or off Cake's conventional mode of finding layout files. On by default. - * - * @var boolean - * @access public - */ - var $autoLayout = true; - -/** - * Variables for the view - * - * @var array - * @access private - */ - var $_viewVars = array(); - -/** - * Title HTML element of current View. - * - * @var boolean - * @access private - */ - var $pageTitle = false; - -/** - * Set the title element of the page. - * - * @param string $pageTitle Text for the title - */ - function setTitle($pageTitle) - { - $this->pageTitle = $pageTitle; - } - - -} - -?> diff --git a/libs/web/templates/scaffolds/layout.thtml b/libs/web/templates/scaffolds/layout.thtml deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/web/templates/scaffolds/methods.thtml b/libs/web/templates/scaffolds/methods.thtml deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/web/templates/scaffolds/parameters.thtml b/libs/web/templates/scaffolds/parameters.thtml deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/web/templates/scaffolds/result.thtml b/libs/web/templates/scaffolds/result.thtml deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/put_modules_here b/modules/put_modules_here deleted file mode 100644 index e69de29bb..000000000 diff --git a/public/.htaccess b/public/.htaccess deleted file mode 100644 index d62ca53b7..000000000 --- a/public/.htaccess +++ /dev/null @@ -1,13 +0,0 @@ -# Based on Rails 0.10.0 .htaccess (www.rubyonrails.com) - - - -# Redirect all requests not available on the filesystem to Cake -RewriteEngine On -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] - -# In case Cake experiences terminal errors -ErrorDocument 500 500.html - - diff --git a/public/500.html b/public/500.html deleted file mode 100644 index 1eddd44c1..000000000 --- a/public/500.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -500 Server error - - - -

    Server error

    -

    Cake has experienced a terminal error and it cannot continue. Please check your web server configuration.

    - - diff --git a/public/css/default.css b/public/css/default.css deleted file mode 100644 index 3b7badc32..000000000 --- a/public/css/default.css +++ /dev/null @@ -1,116 +0,0 @@ -body -{ - font:small "Trebuchet MS",Verdana,Arial,Sans-serif; - background: #E5EDEC url(../img/bg_fade.gif) bottom left fixed repeat-x; -} - -ul{} -li{} - -h1 -{ - color: #71300F; - font-size: 30px; -} - -h1 em { - color: #DBA941; - font-style: normal; - font-weight: normal; - font-variant: normal; -} - -h2 -{ - color: #71300F; -} - -h2 em { - color: #DBA941; - font-style: normal; - font-weight: normal; - font-variant: normal; -} - -hr -{ - border-top: 1px dotted #FF96F3; - height: 0px; -} - -ul -{ - list-style-image: url(../img/red_box.gif); -} - -#main -{ - position: absolute; - width: 605px; - margin-left: -302.5px; - left: 50%; - top: 0px; - background-color: #fff; - border-left: 1px solid #516067; - border-right: 1px solid #516067; - border-bottom: 1px solid #516067; - padding: 15px; -} - -#header -{ - position: relative; - top: -15px; - left: -15px; - width: 635px; - height: 131px; - background: #fff url(../img/bg_header.gif) repeat-x; - margin-bottom: -20px; -} - -#headerLogo -{ - position: absolute; - top: 0px; - left: -30px; -} - -#headerNav -{ - position: absolute; - right: 15px; - top: 63px; -} - -#headerNav a { - padding: 10px; -} - -a -{ - color: #A20B10; - text-decoration: none; -} - -a:hover -{ - color: #D33C47; - text-decoration: underline; - -} - -#footer -{ - position: relative; - bottom: -15px; - left: -15px; - width: 615px; - background-color: #71300F; - color: #fff; - font-size: 75%; - padding: 10px; -} - -.navActive { - background-color: #D2D7D8; -} \ No newline at end of file diff --git a/public/css/scaffold.css b/public/css/scaffold.css deleted file mode 100644 index 92463363d..000000000 --- a/public/css/scaffold.css +++ /dev/null @@ -1,168 +0,0 @@ -/* CSS Document */ -* { - margin: 0; - padding: 0; -} -body { - font: 76% Verdana, Arial, Helvetica, sans-serif; - color: #333; -} -h1 { -font-size:2.1em; -color: #69c; -} -h2 { -margin-top:5px; -display:block; -float:left; -font-size:1.7em; -color: #383; -clear: both; -} - -h3 { -font-size:1.4em; -color: #553; -} -h4 { -font-size:1.15em; -color: #338; -} -a { -white-space:nowrap; -text-decoration:underline; -} -a:hover { -background-color:#EEE; -} -code, pre { -font-family:monospace; -font-size:1.15em; -color:#44A; -} -code { -color:#227; -white-space:nowrap; -margin:0 .2em; -} -pre { -margin-left:1em; -} -acronym { -border-bottom:1px dotted #666; -} -ul { -margin-top:1em; -list-style:none; -} -li { -margin-left:2em; -} -#container { -margin: 2em auto; -color: #333; -width:80%; -} -.notice { -padding: 1em; -background: #ffd; -border: solid 2px #eeb; -display: block; -font-family: Verdana; -} - -.tip { -background: #efe; -padding: 1em; -border: solid 2px #cdc; -} -.error { -background: #fee; -padding: 1em; -border: solid 2px #dcc; -} -ul.actions { - list-style: none; - text-align:right; - margin:2em 0; - float:left; -} - -ul.actions li { - border: 1px solid #333; - width:10em; - float:left; - margin-left:1em; -} - -ul.actions li a, ul.actions li input { - text-align:center; - font-weight: bold; - color: #fff; - background-color:#3297FC; - display:block; - clear: both; - text-decoration: none; - border:1px solid #3297FC; -} - -td.listactions { - width:17em; -} - -td.listactions a { - text-align:center; - font-weight: bold; - color: #fff; - background-color:#3297FC; - display:block; - float:left; - text-decoration: none; - margin-bottom:3px; - margin-right: 3px; - border: 1px; - width:5em; -} - -table { - width: 100%; - border: 1px solid #686E74; - margin: 1em 0 2em 0; - background-color: #fff; -} -th { - background-color: #ccc; - text-align: left; - border-top: 1px solid #fff; - border-right: 1px solid #666; - border-bottom: 1px solid #666; - padding:3px; -} -table tr td { - padding:2px 0; - border-right: 1px solid #ccc; - vertical-align:top; -} -table tr.altRow td { - background: #EBF4FD; -} - -div.related { - display:block; - float:left; - clear:both; -} - -dl { -line-height:2em; -margin:1em; -} -dt { -font-weight: bold; -vertical-align:top; -} -dd { -margin-left:10em; -margin-top:-2em; -vertical-align:top; -} \ No newline at end of file diff --git a/public/img/bg_fade.gif b/public/img/bg_fade.gif deleted file mode 100644 index 2e9585083bd6827c9cc231d4eb03716c283f8211..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1147 zcmV->1cduXNk%w1VF3Uv0rvm^e29&ChKqTHig0~{Z+wDib$eN7Zc|}sFA4>o8s!}8hbgZ_xlb@o%%FA48aBX^kg^`xn;NaQe;aFyE zx52|@b9rZVdv}D1q_48W&CYRtgx==nkDH&!(b8IJZ*+l%S!i!lVrk*(>7S~sV{&(Y zi;πJCuWYIlCX$;*_Wq{h$CjG3Ln%gut1lf1>pRAOmXWov7Cf6CL;QDJ9QV`_wu zmB`Z4pR28glb5-}#DR{J;OXbk+1a+i!knk7VQ_VnpQGaG=)cLz+T-Kj=;zDS)YsqN zUTkyD*Vxb4*qEcIo2IJP-`~#I*rTnmY{#(as5Xm)&oj*^g^pyTZ8fQ^xZkCcIplAx@v z)ZX2ep{2FJ!QJNOeu|IY=H;NPuCctnbAg80;^Erj;)|G^+T-HeC<>FKh(zRJ_nv%SBEl$Wr&y{WXe)ZE;Ikd)Nj-Obk4&DPh=*Vm1jou#m| z)!yE2dx5OCxmRXwj+&lia(HBOc#)o=uDH6cxx1>hwu+URsl(H#<|1Adx(s5frqBDw5PJPYk7WYcYKzjrkA3om7t`N zoS=S-kg&SEA^8LV00000EC2ui0096j0RRa903kqNP=^6IRDTdCeDFYpl2i>E5NSdN z)0Yt=5*?bfK+=L^ksvW~)JTH{7a1~qdQwFcE<&=x!8&Iy4YO^{ikOmOB}y$?v));% zHPhTN^ zGLlfBknC4KKO{)-vSo(GBL@zk4eQ2DS*sv-FktWzE0B#LeFOo**1{hmGnR z009C%e1Ov>)QNg074lMZGz_^r;51#@aJW%V-_8&*0I68qVO5f&vF9 NfDSr5B%oqI06S5@e`^2$ diff --git a/public/img/put_images_here b/public/img/put_images_here deleted file mode 100644 index e69de29bb..000000000 diff --git a/public/test/rss2html.xsl b/public/test/rss2html.xsl deleted file mode 100644 index 6a12565b6..000000000 --- a/public/test/rss2html.xsl +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - -<xsl:for-each select="rdf:RDF/rss:channel"> -<xsl:value-of select="rss:description"/> -</xsl:for-each> - - - - - -
    - - - - - - 0 - - -
    -
    - -
    -
    - - -
    - - - - ( - - ) - -
    -
    - -
      -
      - -
    • - - - - - ( - -) -
    • -
      -
      -
      -
    - - -
    - - - POST -
    - - - text - - - - - submit - -
    -
    -
    - - - -
    - -
    \ No newline at end of file diff --git a/logs/put_logs_here b/tmp/logs/put_logs_here similarity index 100% rename from logs/put_logs_here rename to tmp/logs/put_logs_here