summaryrefslogtreecommitdiff
path: root/poc/poc02-compiling-cake/src
diff options
context:
space:
mode:
Diffstat (limited to 'poc/poc02-compiling-cake/src')
-rw-r--r--poc/poc02-compiling-cake/src/composer.json6
-rwxr-xr-xpoc/poc02-compiling-cake/src/get_deps.sh2
-rw-r--r--poc/poc02-compiling-cake/src/php-weave/main.php64
-rw-r--r--poc/poc02-compiling-cake/src/php-weave/visitors.inc.php91
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/.htaccess5
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/.htaccess5
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/acl.ini.php76
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/bootstrap.php46
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/core.php146
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/database.php.default74
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/inflections.php72
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/routes.php46
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/sql/db_acl.sql38
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/sql/sessions.sql16
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/controllers/components/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/index.php26
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/models/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/plugins/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/models/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/persistent/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/views/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/logs/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/sessions/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/tests/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/vendors/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/elements/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/errors/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/helpers/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/layouts/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/pages/empty0
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/.htaccess6
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/css.php102
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/css/cake.generic.css250
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/favicon.icobin0 -> 4973 bytes
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/cake.power.pngbin0 -> 3053 bytes
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/w3c_css.pngbin0 -> 299 bytes
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/w3c_xhtml10.pngbin0 -> 321 bytes
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/index.php87
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/js/vendors.php44
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/LICENSE.txt24
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/VERSION.txt9
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/app_controller.php42
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/app_model.php42
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/basics.php1156
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/bootstrap.php104
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/config/config.php28
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/config/paths.php175
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/dispatcher.php429
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/cache.php137
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/cake_log.php57
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/class_registry.php117
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/configure.php354
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/component.php139
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/acl.php196
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/acl_base.php63
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/db_acl.php310
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aclnode.php309
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aco.php52
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/acoaction.php56
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aro.php52
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aros_aco.php63
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/iniacl/ini_acl.php180
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/request_handler.php412
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/security.php202
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/session.php306
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/controller.php998
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/pages_controller.php105
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/scaffold.php432
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/error.php347
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/file.php293
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/flay.php278
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/folder.php328
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/inflector.php437
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/legacy.php70
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/connection_manager.php243
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/datasources/datasource.php519
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/datasources/dbo_source.php1967
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_adodb.php437
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mssql.php604
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mysql.php681
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mysqli.php441
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_odbc.php437
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_pear.php241
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_postgres.php595
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_sqlite.php409
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model.php42
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model_php4.php1719
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model_php5.php1716
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/neat_array.php318
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/neat_string.php88
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/object.php259
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/router.php230
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/sanitize.php245
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/security.php151
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/session.php757
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/set.php805
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/validators.php45
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helper.php167
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/ajax.php853
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/cache.php272
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/form.php491
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/html.php1257
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/javascript.php317
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/number.php88
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/session.php198
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/text.php238
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/time.php397
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/elements/dump.thtml32
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/error404.thtml28
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_action.thtml37
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_component_class.thtml36
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_component_file.thtml35
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_connection.thtml30
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_controller.thtml36
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_helper_class.thtml35
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_helper_file.thtml35
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_layout.thtml30
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_model.thtml36
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_scaffolddb.thtml30
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_table.thtml29
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_view.thtml30
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/private_action.thtml29
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/scaffold_error.thtml33
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/ajax.thtml27
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/default.thtml58
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/flash.thtml45
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/pages/home.thtml75
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/add.thtml40
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/edit.thtml56
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/index.thtml95
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/view.thtml166
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/view.php765
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/acl.php853
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/bake.php2635
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/.htaccess5
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_controller.php41
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_model.php43
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/acl.ini.php76
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/bootstrap.php46
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/core.php146
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/database.php.default74
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/inflections.php72
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/routes.php46
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/db_acl.sql30
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/sessions.sql11
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/controllers/pages_controller.php105
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/index.php26
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/ajax.thtml30
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/default.thtml30
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/flash.thtml50
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/.htaccess6
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css.php100
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css/cake.generic.css251
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/favicon.icobin0 -> 4973 bytes
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/img/cake.power.pngbin0 -> 3053 bytes
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/index.php87
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/js/vendors.php43
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/views/home.thtml16
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/CHANGELOG.txt13
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/COPYING.txt24
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/INSTALL.txt40
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/README.txt19
-rw-r--r--poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/index.php77
165 files changed, 33574 insertions, 0 deletions
diff --git a/poc/poc02-compiling-cake/src/composer.json b/poc/poc02-compiling-cake/src/composer.json
new file mode 100644
index 0000000..a366739
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/composer.json
@@ -0,0 +1,6 @@
+{
+ "require": {
+ "nikic/php-parser": "0.9.2"
+ }
+}
+
diff --git a/poc/poc02-compiling-cake/src/get_deps.sh b/poc/poc02-compiling-cake/src/get_deps.sh
new file mode 100755
index 0000000..67c84c3
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/get_deps.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+php ../../../composer.phar install
diff --git a/poc/poc02-compiling-cake/src/php-weave/main.php b/poc/poc02-compiling-cake/src/php-weave/main.php
new file mode 100644
index 0000000..2a4df55
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/php-weave/main.php
@@ -0,0 +1,64 @@
+<?php
+require '../vendor/nikic/php-parser/lib/bootstrap.php';
+require './visitors.inc.php';
+
+ini_set('xdebug.max_nesting_level', 2000);
+
+function dbg($indent, $text) {
+ for($i=0;$i<$indent;$i++) echo ".";
+ echo "$text\n";
+}
+
+function recursive_parse($src_filepath, $stmts1_filepath, $stmts2_filepath, $level=0) {
+ global $parser,$nodeDumper;
+
+ try {
+ dbg($level,"Parsing '$src_filepath'");
+ $stmts = $parser->parse(file_get_contents($src_filepath));
+
+ if (strlen($stmts1_filepath) > 0 ) {
+ dbg($level,"Dumping1 '$src_filepath' AST to '$stmts1_filepath'");
+ file_put_contents($stmts1_filepath, $nodeDumper->dump($stmts));
+ }
+
+ dbg($level,"Transforming '$src_filepath'");
+ $traverser = new PHPParser_NodeTraverser;
+/*
+ $traverser->addVisitor(new PHPParser_NodeVisitor_NameResolver);
+ $traverser->addVisitor(new NodeVisitor_NamespaceConverter);
+*/
+ // FIXME : getcwd is quick and dirty here
+ $traverser->addVisitor(new NodeVisitor_PreprocessInclude($level, getcwd(), $src_filepath));
+ $stmts = $traverser->traverse($stmts);
+ $traverser=null; //Destroy
+
+ if (strlen($stmts2_filepath) > 0) {
+ dbg($level,"Dumping2 '$src_filepath' AST to '$stmts2_filepath'");
+ file_put_contents($stmts2_filepath, $nodeDumper->dump($stmts));
+ }
+
+ } catch (PHPParser_Error $e) {
+ echo 'Parse Error: ', $e->getMessage();
+ }
+ return $stmts;
+}
+
+
+// Main
+$src_filepath = "./main.php";
+#$src_filepath = "./to_parse.php";
+$stmts1_filepath = "out/stmts1.ast";
+$stmts2_filepath = "out/stmts2.ast";
+$dest_filepath = "out/result.php";
+
+$parser = new PHPParser_Parser(new PHPParser_Lexer);
+$nodeDumper = new PHPParser_NodeDumper;
+
+$level=0;
+$stmts=recursive_parse($src_filepath, $stmts1_filepath, $stmts2_filepath);
+
+dbg(0,"Outputing '$dest_filepath'");
+$prettyPrinter = new PHPParser_PrettyPrinter_Zend;
+file_put_contents($dest_filepath, "<?php\n" . $prettyPrinter->prettyPrint($stmts) . "\n?>");
+
+?>
diff --git a/poc/poc02-compiling-cake/src/php-weave/visitors.inc.php b/poc/poc02-compiling-cake/src/php-weave/visitors.inc.php
new file mode 100644
index 0000000..3f997ad
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/php-weave/visitors.inc.php
@@ -0,0 +1,91 @@
+<?php
+/*
+class NodeVisitor_NamespaceConverter extends PHPParser_NodeVisitorAbstract
+{
+ public function leaveNode(PHPParser_Node $node) {
+ if ($node instanceof PHPParser_Node_Name) {
+ return new PHPParser_Node_Name($node->toString('_'));
+ } elseif ($node instanceof PHPParser_Node_Stmt_Class
+ || $node instanceof PHPParser_Node_Stmt_Interface
+ || $node instanceof PHPParser_Node_Stmt_Function) {
+ $node->name = $node->namespacedName->toString('_');
+ } elseif ($node instanceof PHPParser_Node_Stmt_Const) {
+ foreach ($node->consts as $const) {
+ $const->name = $const->namespacedName->toString('_');
+ }
+ } elseif ($node instanceof PHPParser_Node_Stmt_Namespace) {
+ // returning an array merges is into the parent array
+ return $node->stmts;
+ } elseif ($node instanceof PHPParser_Node_Stmt_Use) {
+ // returning false removed the node altogether
+ return false;
+ }
+ }
+}
+*/
+
+class NodeVisitor_PreprocessInclude extends PHPParser_NodeVisitorAbstract {
+ protected $level;
+ protected $cwd;
+ protected $filepath;
+ protected $prettyPrinter;
+
+ public function __construct($level, $cwd, $filepath) {
+ $this->level=$level;
+ $this->cwd=$cwd;
+ $this->filepath=$filepath;
+ $this->prettyPrinter = new PHPParser_PrettyPrinter_Zend;
+ }
+
+ protected function resolveIncludePath($node) {
+ //FIXME : Quick and dirty
+ // no classpath checks...
+ // no check if compound value like "dirname(__FILE__) . '/PHPParser/Autoloader.php'"
+ return $node->expr->value;
+ }
+
+ public function enterNode(PHPParser_Node $node) {
+ if ($node instanceof PHPParser_Node_Expr_Include) {
+ // Already processed, go out (occurs if an unresolved include has left as is in the previous recursion level)
+ if (is_array($node->attributes) && array_key_exists('NodeVisitor_PreprocessInclude', $node->attributes)) return $node;
+
+ switch($node->type) {
+ case PHPParser_Node_Expr_Include::TYPE_INCLUDE:
+ case PHPParser_Node_Expr_Include::TYPE_REQUIRE:
+ $once=0;
+ break;
+ case PHPParser_Node_Expr_Include::TYPE_INCLUDE_ONCE:
+ case PHPParser_Node_Expr_Include::TYPE_REQUIRE_ONCE:
+ $once=1;
+ echo "TODO : include_once or require_once\n";
+ break;
+ default:
+ echo "FIXME : BUG NodeVisitor_PreprocessInclude::enterNode !!\n";
+ return $node;
+ }
+
+ $path=$this->resolveIncludePath($node);
+
+ //FIXME : No infinite recursion check like test.php contains include('./test.php');
+ // Preprocess include if readable
+ $comment_suffix=" */";
+ if ( ($this->level < 3) && is_readable($path)) {
+ $comment_prefix="/* ";
+ //FIXME : use a closure or sort of here (dependancy injection)
+ //$stmts=recursive_parse($path, "out/rec.out1", "out/rec.out2", $this->level+1);
+ $stmts=recursive_parse($path, "", "", $this->level+1);
+ } else {
+ $comment_prefix="/* UNRESOLVED : ";
+ $node->attributes['NodeVisitor_PreprocessInclude']='unresolved';
+ $stmts=array($node); // Caution : can cause infinite loop (will be tried at the next step)
+ }
+
+ $comment= new PHPParser_Comment($comment_prefix . $this->prettyPrinter->prettyPrint(array($node)) . $comment_suffix);
+
+ // FIXME : Get out this if() that is a trick for not returning here an array instead of a node
+ return new PHPParser_Node_Stmt_If(new PHPParser_Node_Scalar_LNumber(1),array('stmts'=>$stmts),array('comments'=>array($comment)));
+ }
+
+ }
+}
+
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/.htaccess b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/.htaccess
new file mode 100644
index 0000000..f23dbaf
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/.htaccess
@@ -0,0 +1,5 @@
+<IfModule mod_rewrite.c>
+ RewriteEngine on
+ RewriteRule ^$ app/webroot/ [L]
+ RewriteRule (.*) app/webroot/$1 [L]
+</IfModule> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/.htaccess b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/.htaccess
new file mode 100644
index 0000000..0ed8662
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/.htaccess
@@ -0,0 +1,5 @@
+<IfModule mod_rewrite.c>
+ RewriteEngine on
+ RewriteRule ^$ webroot/ [L]
+ RewriteRule (.*) webroot/$1 [L]
+ </IfModule> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/acl.ini.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/acl.ini.php
new file mode 100644
index 0000000..486e790
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/acl.ini.php
@@ -0,0 +1,76 @@
+;<?php die() ?>
+; SVN FILE: $Id: acl.ini.php 6305 2008-01-02 02:33:56Z phpnut $
+;/**
+; * Short description for file.
+; *
+; *
+; * PHP versions 4 and 5
+; *
+; * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+; * Copyright 2005-2008, Cake Software Foundation, Inc.
+; * 1785 E. Sahara Avenue, Suite 490-204
+; * Las Vegas, Nevada 89104
+; *
+; * Licensed under The MIT License
+; * Redistributions of files must retain the above copyright notice.
+; *
+; * @filesource
+; * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+; * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+; * @package cake
+; * @subpackage cake.app.config
+; * @since CakePHP(tm) v 0.10.0.1076
+; * @version $Revision: 6305 $
+; * @modifiedby $LastChangedBy: phpnut $
+; * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+; * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+; */
+
+; acl.ini.php - Cake ACL Configuration
+; ---------------------------------------------------------------------
+; Use this file to specify user permissions.
+; aco = access control object (something in your application)
+; aro = access request object (something requesting access)
+;
+; User records are added as follows:
+;
+; [uid]
+; groups = group1, group2, group3
+; allow = aco1, aco2, aco3
+; deny = aco4, aco5, aco6
+;
+; Group records are added in a similar manner:
+;
+; [gid]
+; allow = aco1, aco2, aco3
+; deny = aco4, aco5, aco6
+;
+; The allow, deny, and groups sections are all optional.
+; NOTE: groups names *cannot* ever be the same as usernames!
+;
+; ACL permissions are checked in the following order:
+; 1. Check for user denies (and DENY if specified)
+; 2. Check for user allows (and ALLOW if specified)
+; 3. Gather user's groups
+; 4. Check group denies (and DENY if specified)
+; 5. Check group allows (and ALLOW if specified)
+; 6. If no aro, aco, or group information is found, DENY
+;
+; ---------------------------------------------------------------------
+
+;-------------------------------------
+;Users
+;-------------------------------------
+
+[username-goes-here]
+groups = group1, group2
+deny = aco1, aco2
+allow = aco3, aco4
+
+;-------------------------------------
+;Groups
+;-------------------------------------
+
+[groupname-goes-here]
+deny = aco5, aco6
+allow = aco7, aco8 \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/bootstrap.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/bootstrap.php
new file mode 100644
index 0000000..ef4cedf
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/bootstrap.php
@@ -0,0 +1,46 @@
+<?php
+/* SVN FILE: $Id: bootstrap.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.config
+ * @since CakePHP(tm) v 0.10.8.2117
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ *
+ * This file is loaded automatically by the app/webroot/index.php file after the core bootstrap.php is loaded
+ * This is an application wide file to load any function that is not used within a class define.
+ * You can also use this to include or require any files in your application.
+ *
+ */
+/**
+ * The settings below can be used to set additional paths to models, views and controllers.
+ * This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)
+ *
+ * $modelPaths = array('full path to models', 'second full path to models', 'etc...');
+ * $viewPaths = array('this path to views', 'second full path to views', 'etc...');
+ * $controllerPaths = array('this path to controllers', 'second full path to controllers', 'etc...');
+ *
+ */
+//EOF
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/core.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/core.php
new file mode 100644
index 0000000..77cf1ff
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/core.php
@@ -0,0 +1,146 @@
+<?php
+/* SVN FILE: $Id: core.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * This is core configuration file.
+ *
+ * Use it to configure core behaviour ofCake.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.config
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * If you do not have mod rewrite on your system
+ * or if you prefer to use CakePHP pretty urls.
+ * uncomment the line below.
+ * Note: If you do have mod rewrite but prefer the
+ * CakePHP pretty urls, you also have to remove the
+ * .htaccess files
+ * release/.htaccess
+ * release/app/.htaccess
+ * release/app/webroot/.htaccess
+ */
+// define ('BASE_URL', env('SCRIPT_NAME'));
+/**
+ * Set debug level here:
+ * - 0: production
+ * - 1: development
+ * - 2: full debug with sql
+ * - 3: full debug with sql and dump of the current object
+ *
+ * In production, the "flash messages" redirect after a time interval.
+ * With the other debug levels you get to click the "flash message" to continue.
+ *
+ */
+ define('DEBUG', 1);
+/**
+ * Turn of caching checking wide.
+ * You must still use the controller var cacheAction inside you controller class.
+ * You can either set it controller wide, or in each controller method.
+ * use var $cacheAction = true; or in the controller method $this->cacheAction = true;
+ */
+ define('CACHE_CHECK', false);
+/**
+ * Error constant. Used for differentiating error logging and debugging.
+ * Currently PHP supports LOG_DEBUG
+ */
+ define('LOG_ERROR', 2);
+/**
+ * CakePHP includes 3 types of session saves
+ * database or file. Set this to your preferred method.
+ * If you want to use your own save handler place it in
+ * app/config/name.php DO NOT USE file or database as the name.
+ * and use just the name portion below.
+ *
+ * Setting this to cake will save files to /cakedistro/tmp directory
+ * Setting it to php will use the php default save path
+ * Setting it to database will use the database
+ *
+ */
+ define('CAKE_SESSION_SAVE', 'php');
+/**
+ * If using you own table name for storing sessions
+ * set the table name here.
+ * DO NOT INCLUDE PREFIX IF YOU HAVE SET ONE IN database.php
+ *
+ */
+ define('CAKE_SESSION_TABLE', 'cake_sessions');
+/**
+ * Set a random string of used in session.
+ *
+ */
+ define('CAKE_SESSION_STRING', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
+/**
+ * Set the name of session cookie
+ *
+ */
+ define('CAKE_SESSION_COOKIE', 'CAKEPHP');
+/**
+ * Set level of Cake security.
+ *
+ */
+ define('CAKE_SECURITY', 'high');
+/**
+ * Set Cake Session time out.
+ * If CAKE_SECURITY define is set
+ * high: multiplied by 10
+ * medium: is multiplied by 100
+ * low is: multiplied by 300
+ *
+ * Number below is seconds.
+ */
+ define('CAKE_SESSION_TIMEOUT', '120');
+/**
+ * Uncomment the define below to use cake built in admin routes.
+ * You can set this value to anything you want.
+ * All methods related to the admin route should be prefixed with the
+ * name you set CAKE_ADMIN to.
+ * For example: admin_index, admin_edit
+ */
+// define('CAKE_ADMIN', 'admin');
+/**
+ * The define below is used to turn cake built webservices
+ * on or off. Default setting is off.
+ */
+ define('WEBSERVICES', 'off');
+/**
+ * Compress output CSS (removing comments, whitespace, repeating tags etc.)
+ * This requires a/var/cache directory to be writable by the web server (caching).
+ * To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use Controller::cssTag().
+ */
+ define('COMPRESS_CSS', false);
+/**
+ * If set to true, helpers would output data instead of returning it.
+ */
+ 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...
+ */
+ define('ACL_CLASSNAME', 'DB_ACL');
+ define('ACL_FILENAME', 'dbacl' . DS . 'db_acl');
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/database.php.default b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/database.php.default
new file mode 100644
index 0000000..4df48e1
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/database.php.default
@@ -0,0 +1,74 @@
+<?php
+/* SVN FILE: $Id: database.php.default 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * This is core configuration file.
+ *
+ * Use it to configure core behaviour ofCake.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.config
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * In this file you set up your database connection details.
+ *
+ * @package cake
+ * @subpackage cake.config
+ */
+/**
+ * Database configuration class.
+ * You can specify multiple configurations for production, development and testing.
+ *
+ * driver =>
+ * mysql, postgres, sqlite, adodb, pear-drivername
+ *
+ * connect =>
+ * MySQL set the connect to either mysql_pconnect of mysql_connect
+ * PostgreSQL set the connect to either pg_pconnect of pg_connect
+ * SQLite set the connect to sqlite_popen sqlite_open
+ * ADOdb set the connect to one of these
+ * (http://phplens.com/adodb/supported.databases.html) and
+ * append it '|p' for persistent connection. (mssql|p for example, or just mssql for not persistent)
+ *
+ * host =>
+ * the host you connect to the database
+ * MySQL 'localhost' to add a port number use 'localhost:port#'
+ * PostgreSQL 'localhost' to add a port number use 'localhost port=5432'
+ *
+ */
+class DATABASE_CONFIG
+{
+ var $default = array('driver' => 'mysql',
+ 'connect' => 'mysql_connect',
+ 'host' => 'localhost',
+ 'login' => 'user',
+ 'password' => 'password',
+ 'database' => 'project_name',
+ 'prefix' => '');
+
+ var $test = array('driver' => 'mysql',
+ 'connect' => 'mysql_connect',
+ 'host' => 'localhost',
+ 'login' => 'user',
+ 'password' => 'password',
+ 'database' => 'project_name-test',
+ 'prefix' => '');
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/inflections.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/inflections.php
new file mode 100644
index 0000000..e08a7d8
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/inflections.php
@@ -0,0 +1,72 @@
+<?php
+/* SVN FILE: $Id: inflections.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Custom Inflected Words.
+ *
+ * This file is used to hold words that are not matched in the normail Inflector::pluralize() and
+ * Inflector::singularize()
+ *
+ * PHP versions 4 and %
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.config
+ * @since CakePHP(tm) v 1.0.0.2312
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * This is a key => value array of regex used to match words.
+ * If key matches then the value is returned.
+ *
+ * $pluralRules = array('/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', '/([m|l])ouse$/i' => '\1ice');
+ */
+ $pluralRules = array();
+/**
+ * This is a key only array of plural words that should not be inflected.
+ * Notice the last comma
+ *
+ * $uninflectedPlural = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox');
+ */
+ $uninflectedPlural = array();
+/**
+ * This is a key => value array of plural irregular words.
+ * If key matches then the value is returned.
+ *
+ * $irregularPlural = array('atlas' => 'atlases', 'beef' => 'beefs', 'brother' => 'brothers')
+ */
+ $irregularPlural = array();
+/**
+ * This is a key => value array of regex used to match words.
+ * If key matches then the value is returned.
+ *
+ * $singularRules = array('/(s)tatuses$/i' => '\1\2tatus', '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i')
+ */
+ $singularRules = array();
+/**
+ * This is a key only array of singular words that should not be inflected.
+ * You should not have to change this value below if you do change it use same format
+ * as the $uninflectedPlural above.
+ */
+ $uninflectedSingular = $uninflectedPlural;
+/**
+ * This is a key => value array of singular irregular words.
+ * Most of the time this will be a reverse of the above $irregularPlural array
+ * You should not have to change this value below if you do change it use same format
+ *
+ * $irregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother')
+ */
+ $irregularSingular = array_flip($irregularPlural);
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/routes.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/routes.php
new file mode 100644
index 0000000..45ae36a
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/routes.php
@@ -0,0 +1,46 @@
+<?php
+/* SVN FILE: $Id: routes.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * In this file, you set up routes to your controllers and their actions.
+ * Routes are very important mechanism that allows you to freely connect
+ * different urls to chosen controllers and their actions (functions).
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.config
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Here, we are connecting '/' (base path) to controller called 'Pages',
+ * its action called 'display', and we pass a param to select the view file
+ * to use (in this case, /app/views/pages/home.thtml)...
+ */
+ $Route->connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
+/**
+ * ...and connect the rest of 'Pages' controller's urls.
+ */
+ $Route->connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
+/**
+ * Then we connect url '/test' to our test controller. This is helpfull in
+ * developement.
+ */
+ $Route->connect('/tests', array('controller' => 'tests', 'action' => 'index'));
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/sql/db_acl.sql b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/sql/db_acl.sql
new file mode 100644
index 0000000..be8f200
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/sql/db_acl.sql
@@ -0,0 +1,38 @@
+# $Id: db_acl.sql 6305 2008-01-02 02:33:56Z phpnut $
+#
+# Copyright 2005-2008, Cake Software Foundation, Inc.
+# 1785 E. Sahara Avenue, Suite 490-204
+# Las Vegas, Nevada 89104
+#
+# Licensed under The MIT License
+# Redistributions of files must retain the above copyright notice.
+# http://www.opensource.org/licenses/mit-license.php The MIT License
+
+CREATE TABLE acos (
+ id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ object_id INTEGER(10) NULL DEFAULT NULL,
+ alias VARCHAR(255) NOT NULL DEFAULT '',
+ lft INTEGER(10) NULL DEFAULT NULL,
+ rght INTEGER(10) NULL DEFAULT NULL,
+ PRIMARY KEY(id)
+);
+
+CREATE TABLE aros_acos (
+ id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ aro_id INTEGER(10) UNSIGNED NOT NULL,
+ aco_id INTEGER(10) UNSIGNED NOT NULL,
+ _create CHAR(2) NOT NULL DEFAULT 0,
+ _read CHAR(2) NOT NULL DEFAULT 0,
+ _update CHAR(2) NOT NULL DEFAULT 0,
+ _delete CHAR(2) NOT NULL DEFAULT 0,
+ PRIMARY KEY(id)
+);
+
+CREATE TABLE aros (
+ id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ foreign_key INTEGER(10) UNSIGNED NULL DEFAULT NULL,
+ alias VARCHAR(255) NOT NULL DEFAULT '',
+ lft INTEGER(10) NULL DEFAULT NULL,
+ rght INTEGER(10) NULL DEFAULT NULL,
+ PRIMARY KEY(id)
+); \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/sql/sessions.sql b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/sql/sessions.sql
new file mode 100644
index 0000000..14c0036
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/config/sql/sessions.sql
@@ -0,0 +1,16 @@
+# $Id: sessions.sql 6305 2008-01-02 02:33:56Z phpnut $
+#
+# Copyright 2005-2008, Cake Software Foundation, Inc.
+# 1785 E. Sahara Avenue, Suite 490-204
+# Las Vegas, Nevada 89104
+#
+# Licensed under The MIT License
+# Redistributions of files must retain the above copyright notice.
+# http://www.opensource.org/licenses/mit-license.php The MIT License
+
+CREATE TABLE cake_sessions (
+ id varchar(255) NOT NULL default '',
+ data text,
+ expires int(11) default NULL,
+ PRIMARY KEY (id)
+); \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/controllers/components/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/controllers/components/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/controllers/components/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/index.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/index.php
new file mode 100644
index 0000000..bd8993b
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/index.php
@@ -0,0 +1,26 @@
+<?php
+/* SVN FILE: $Id: index.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/models/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/models/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/models/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/plugins/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/plugins/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/plugins/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/models/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/models/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/models/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/persistent/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/persistent/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/persistent/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/views/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/views/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/cache/views/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/logs/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/logs/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/logs/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/sessions/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/sessions/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/sessions/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/tests/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/tests/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/tmp/tests/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/vendors/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/vendors/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/vendors/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/elements/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/elements/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/elements/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/errors/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/errors/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/errors/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/helpers/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/helpers/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/helpers/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/layouts/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/layouts/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/layouts/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/pages/empty b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/pages/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/views/pages/empty
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/.htaccess b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/.htaccess
new file mode 100644
index 0000000..f9d8b93
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/.htaccess
@@ -0,0 +1,6 @@
+<IfModule mod_rewrite.c>
+ RewriteEngine On
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
+</IfModule> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/css.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/css.php
new file mode 100644
index 0000000..dc87218
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/css.php
@@ -0,0 +1,102 @@
+<?php
+/* SVN FILE: $Id: css.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.webroot
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+if (!defined('CAKE_CORE_INCLUDE_PATH')) {
+ header('HTTP/1.1 404 Not Found');
+ exit('File Not Found');
+}
+/**
+ * Enter description here...
+ */
+ uses('file');
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $path
+ * @param unknown_type $name
+ * @return unknown
+ */
+ function make_clean_css($path, $name) {
+ require(VENDORS . 'csspp' . DS . 'csspp.php');
+ $data = file_get_contents($path);
+ $csspp = new csspp();
+ $output = $csspp->compress($data);
+ $ratio = 100 - (round(strlen($output) / strlen($data), 3) * 100);
+ $output = " /* file: $name, ratio: $ratio% */ " . $output;
+ return $output;
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $path
+ * @param unknown_type $content
+ * @return unknown
+ */
+ function write_css_cache($path, $content) {
+ if (!is_dir(dirname($path))) {
+ mkdir(dirname($path));
+ }
+ $cache = new File($path);
+ return $cache->write($content);
+ }
+
+ if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) {
+ die('Wrong file name.');
+ }
+
+ $filename = 'css/' . $regs[1];
+ $filepath = CSS . $regs[1];
+ $cachepath = CACHE . 'css' . DS . str_replace(array('/','\\'), '-', $regs[1]);
+
+ if (!file_exists($filepath)) {
+ die('Wrong file name.');
+ }
+
+ if (file_exists($cachepath)) {
+ $templateModified = filemtime($filepath);
+ $cacheModified = filemtime($cachepath);
+
+ if ($templateModified > $cacheModified) {
+ $output = make_clean_css($filepath, $filename);
+ write_css_cache($cachepath, $output);
+ } else {
+ $output = file_get_contents($cachepath);
+ }
+ } else {
+ $output = make_clean_css($filepath, $filename);
+ write_css_cache($cachepath, $output);
+ $templateModified = time();
+ }
+
+ header("Date: " . date("D, j M Y G:i:s ", $templateModified) . 'GMT');
+ header("Content-Type: text/css");
+ header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT");
+ header("Cache-Control: cache"); // HTTP/1.1
+ header("Pragma: cache"); // HTTP/1.0
+ print $output;
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/css/cake.generic.css b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/css/cake.generic.css
new file mode 100644
index 0000000..bc27d22
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/css/cake.generic.css
@@ -0,0 +1,250 @@
+*{
+margin:0;
+padding:0;
+}
+
+body{
+font-family:"frutiger linotype","lucida grande",helvetica,arial,sans-serif;
+text-align:center;
+color:#333;
+font-size: 76%;
+}
+
+/* General Style Info */
+a{
+color:#003d4c;
+text-decoration:underline;
+}
+a:hover{
+color:#003d4c;
+text-decoration:none;
+}
+
+a img{
+border:none;
+}
+
+h1, h2, h3, h4{
+font-weight:normal;
+}
+
+h1{
+color: #003d4c;
+margin:0.3em 0;
+font-size: 180%;
+}
+
+h2{
+color:#c6c65b;
+padding-top: 1em;
+margin:0.3em 0;
+font-size: 180%;
+}
+
+h3{
+color:#c6c65b;
+padding-top:2em;
+font-size: 140%;
+}
+
+h4{
+color:#c6c65b;
+padding-top:0.5em;
+font-weight:normal;
+}
+
+em {
+font-size: 12px;
+}
+
+ul, li {
+margin: 0 12px;
+}
+
+/* Layout */
+
+#container{
+text-align:left;
+}
+
+#header{
+margin-top: 1em;
+padding: 4px 20px;
+}
+
+#content{
+clear:both;
+padding: 0px 40px 10px 40px;
+background-color: #fff;
+color: #333;
+}
+#footer{
+clear:both;
+padding: 6px 10px;
+text-align: right;
+}
+
+/* tables */
+
+table {
+width: 100%;
+border-top: 1px solid #ccc;
+border-left: 1px solid #ccc;
+border-bottom: 1px solid #ccc;
+color:#333;
+background-color: #fff;
+clear:both;
+padding: 0;
+margin: 0 0 2em 0;
+white-space: normal;
+}
+th {
+background-color: #e2e2e2;
+border-top: 1px solid #fff;
+border-left: 1px solid #fff;
+border-right: 1px solid #003d4c;
+border-bottom: 1px solid #003d4c;
+text-align: center;
+padding:1px 4px;
+}
+table tr td {
+border-right: 1px solid #ddd;
+padding:4px 4px;
+vertical-align:top;
+text-align: center;
+}
+table tr.altRow td {
+background: #f4f4f4;
+}
+table td.actions {
+ white-space: nowrap;
+}
+#cakeSqlLog td {
+text-align: left;
+padding: 4px 8px;
+background: #fff;
+border-bottom: 2px solid #ccc;
+}
+
+/* scaffold show */
+
+div.related {
+clear:both;
+display:block;
+}
+dl {
+line-height:2em;
+margin:0em 1em;
+float:left;
+width: 400px;
+}
+dt {
+font-weight: bold;
+vertical-align:top;
+}
+dd {
+margin-left:10em;
+margin-top:-2em;
+vertical-align:top;
+}
+
+/* notices and errors */
+
+#flashMessage, .error, .error_message {
+color:#900;
+font-size: 16px;
+background-color: #fff;
+margin: 8px 0px;
+font-weight: bold;
+}
+.error_message {
+clear: both;
+}
+.error em {
+font-size: 18px;
+color: #003d4c;
+}
+.notice {
+color: #656565;
+font-size: 14px;
+background-color: #f4f4f4;
+padding: 0.5em;
+margin: 1em 0;
+display:block;
+}
+.tip {
+color: #656565;
+background-color: #ddd;
+}
+
+/* forms */
+
+form {
+margin-top: 2em;
+}
+form div{
+vertical-align: text-top;
+margin-left: 1em;
+margin-bottom:2em;
+}
+form div.date{
+margin-left: 0em;
+}
+label {
+display: block;
+width: 140px;
+font-size: 14px;
+padding-right: 20px;
+}
+input[type=checkbox] {
+float: left;
+clear: left;
+margin: 2px 6px 7px 2px;
+}
+input, textarea {
+clear: both;
+display:block;
+font-size: 14px;
+font-family: inherit;
+}
+select {
+clear: both;
+vertical-align: text-bottom;
+font-size: 14px;
+font-family: inherit;
+}
+option {
+font-size: 14px;
+font-family: inherit;
+padding: 0 0.3em;
+}
+input[type=submit] {
+display: inline;
+vertical-align: bottom;
+}
+div.required {
+clear: both;
+color:#222;
+font-weight:bold;
+}
+div.optional {
+clear: both;
+color:#555;
+}
+div.submit {
+clear: both;
+margin-top: 40px;
+margin-left: 140px;
+}
+/* action links */
+ul.actions {
+float: left;
+margin-left:20px;
+width: 200px;
+}
+ul.actions li {
+margin-top: 4px;
+}
+pre {
+padding: 1em;
+} \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/favicon.ico b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/favicon.ico
new file mode 100644
index 0000000..1bc32bd
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/favicon.ico
Binary files differ
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/cake.power.png b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/cake.power.png
new file mode 100644
index 0000000..699ef80
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/cake.power.png
Binary files differ
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/w3c_css.png b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/w3c_css.png
new file mode 100644
index 0000000..706325e
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/w3c_css.png
Binary files differ
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/w3c_xhtml10.png b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/w3c_xhtml10.png
new file mode 100644
index 0000000..ec68644
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/img/w3c_xhtml10.png
Binary files differ
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/index.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/index.php
new file mode 100644
index 0000000..48771ff
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/index.php
@@ -0,0 +1,87 @@
+<?php
+/* SVN FILE: $Id: index.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.webroot
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Do not change
+ */
+ if (!defined('DS')) {
+ define('DS', DIRECTORY_SEPARATOR);
+ }
+/**
+ * These defines should only be edited if you have cake installed in
+ * a directory layout other than the way it is distributed.
+ * Each define has a commented line of code that explains what you would change.
+ *
+ */
+ if (!defined('ROOT')) {
+ //define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
+ //You should also use the DS define to seperate your directories
+ define('ROOT', dirname(dirname(dirname(__FILE__))));
+ }
+ if (!defined('APP_DIR')) {
+ //define('APP_DIR', 'DIRECTORY NAME OF APPLICATION';
+ define('APP_DIR', basename(dirname(dirname(__FILE__))));
+ }
+/**
+ * This only needs to be changed if the cake installed libs are located
+ * outside of the distributed directory structure.
+ */
+ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
+ //define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
+ //You should also use the DS define to seperate your directories
+ define('CAKE_CORE_INCLUDE_PATH', ROOT);
+ }
+///////////////////////////////
+//DO NOT EDIT BELOW THIS LINE//
+///////////////////////////////
+ if (!defined('WEBROOT_DIR')) {
+ define('WEBROOT_DIR', basename(dirname(__FILE__)));
+ }
+ if (!defined('WWW_ROOT')) {
+ define('WWW_ROOT', dirname(__FILE__) . DS);
+ }
+ if (!defined('CORE_PATH')) {
+ if (function_exists('ini_set')) {
+ ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'));
+ define('APP_PATH', null);
+ define('CORE_PATH', null);
+ } else {
+ define('APP_PATH', ROOT . DS . APP_DIR . DS);
+ define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
+ }
+ }
+ require CORE_PATH . 'cake' . DS . 'bootstrap.php';
+ if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
+ } else {
+ $Dispatcher = new Dispatcher();
+ $Dispatcher->dispatch($url);
+ }
+ if (Configure::read() > 0) {
+ echo "<!-- " . round(getMicrotime() - $TIME_START, 4) . "s -->";
+ }
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/js/vendors.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/js/vendors.php
new file mode 100644
index 0000000..cee6b77
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/app/webroot/js/vendors.php
@@ -0,0 +1,44 @@
+<?php
+/* SVN FILE: $Id: vendors.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * Short description for file.
+ *
+ * This file includes js vendor-files from /vendor/ directory if they need to
+ * be accessible to the public.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.webroot.js
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Enter description here...
+ */
+if (isset($_GET['file'])) {
+ $file = $_GET['file'];
+ $pos = strpos($file, '..');
+ if ($pos === false) {
+ if (is_file('../../vendors/javascript/'.$file) && (preg_match('/(\/.+)\\.js/', $file))) {
+ readfile('../../vendors/javascript/'.$file);
+ return;
+ }
+ }
+}
+header('HTTP/1.1 404 Not Found');
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/LICENSE.txt b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/LICENSE.txt
new file mode 100644
index 0000000..4787242
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/LICENSE.txt
@@ -0,0 +1,24 @@
+The MIT License
+
+CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+Copyright 2005-2007, Cake Software Foundation, Inc.
+ 1785 E. Sahara Avenue, Suite 490-204
+ Las Vegas, Nevada 89104
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/VERSION.txt b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/VERSION.txt
new file mode 100644
index 0000000..75ad570
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/VERSION.txt
@@ -0,0 +1,9 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+// +---------------------------------------------------------------------------------------------------+ //
+// + $Id: VERSION.txt 7692 2008-10-02 05:06:48Z nate $
+// + Last Modified: $Date: 2008-10-02 01:06:48 -0400 (Thu, 02 Oct 2008) $
+// + Modified By: $LastChangedBy: nate $
+// +---------------------------------------------------------------------------------------------------+ //
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+1.1.20.7692 \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/app_controller.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/app_controller.php
new file mode 100644
index 0000000..24a501c
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/app_controller.php
@@ -0,0 +1,42 @@
+<?php
+/* SVN FILE: $Id: app_controller.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * This file is application-wide controller file. You can put all
+ * application-wide controller-related methods here.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * This is a placeholder class.
+ * Create the same file in app/app_controller.php
+ *
+ * Add your application-wide methods in the class below, your controllers
+ * will inherit them.
+ *
+ * @package cake
+ * @subpackage cake.cake
+ */
+class AppController extends Controller {
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/app_model.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/app_model.php
new file mode 100644
index 0000000..c20a518
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/app_model.php
@@ -0,0 +1,42 @@
+<?php
+/* SVN FILE: $Id: app_model.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Application model for Cake.
+ *
+ * This file is application-wide model file. You can put all
+ * application-wide model-related methods here.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Application model for Cake.
+ *
+ * This is a placeholder class.
+ * Create the same file in app/app_model.php
+ * Add your application-wide methods to the class, your models will inherit them.
+ *
+ * @package cake
+ * @subpackage cake.cake
+ */
+class AppModel extends Model {
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/basics.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/basics.php
new file mode 100644
index 0000000..486584f
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/basics.php
@@ -0,0 +1,1156 @@
+<?php
+/* SVN FILE: $Id: basics.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * Basic Cake functionality.
+ *
+ * Core functions for including other source files, loading models and so forth.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Basic defines for timing functions.
+ */
+ define('SECOND', 1);
+ define('MINUTE', 60 * SECOND);
+ define('HOUR', 60 * MINUTE);
+ define('DAY', 24 * HOUR);
+ define('WEEK', 7 * DAY);
+ define('MONTH', 30 * DAY);
+ define('YEAR', 365 * DAY);
+/**
+ * Patch for PHP < 4.3
+ */
+ if (!function_exists("ob_get_clean")) {
+ function ob_get_clean() {
+ $ob_contents = ob_get_contents();
+ ob_end_clean();
+ return $ob_contents;
+ }
+ }
+/**
+ * Patch for PHP < 4.3
+ */
+ if (version_compare(phpversion(), '5.0') < 0) {
+ eval ('
+ function clone($object) {
+ return $object;
+ }');
+ }
+/**
+ * Computes the difference of arrays using keys for comparison
+ *
+ * @param array
+ * @param array
+ * @return array
+ */
+ if (!function_exists('array_diff_key')) {
+ function array_diff_key() {
+ $valuesDiff = array();
+
+ if (func_num_args() < 2) {
+ return false;
+ }
+
+ foreach (func_get_args() as $param) {
+ if (!is_array($param)) {
+ return false;
+ }
+ }
+
+ $args = func_get_args();
+ foreach ($args[0] as $valueKey => $valueData) {
+ for ($i = 1; $i < func_num_args(); $i++) {
+ if (isset($args[$i][$valueKey])) {
+ continue 2;
+ }
+ }
+ $valuesDiff[$valueKey] = $valueData;
+ }
+ return $valuesDiff;
+ }
+ }
+/**
+ * Computes the intersection of arrays using keys for comparison
+ *
+ * @param array
+ * @param array
+ * @return array
+ */
+ if (!function_exists('array_intersect_key')) {
+ function array_intersect_key($arr1, $arr2) {
+ $res = array();
+ foreach ($arr1 as $key=>$value) {
+ if (array_key_exists($key, $arr2)) {
+ $res[$key] = $arr1[$key];
+ }
+ }
+ return $res;
+ }
+ }
+/**
+ * Loads all models.
+ */
+ function loadModels() {
+ if (!class_exists('Model')) {
+ require LIBS . 'model' . DS . 'model.php';
+ }
+ $path = Configure::getInstance();
+ if (!class_exists('AppModel')) {
+ if (file_exists(APP . 'app_model.php')) {
+ require(APP . 'app_model.php');
+ } else {
+ require(CAKE . 'app_model.php');
+ }
+ if (phpversion() < 5 && function_exists("overload")) {
+ overload('AppModel');
+ }
+ }
+
+ foreach ($path->modelPaths as $path) {
+ foreach (listClasses($path)as $model_fn) {
+ list($name) = explode('.', $model_fn);
+ $className = Inflector::camelize($name);
+
+ if (!class_exists($className)) {
+ require($path . $model_fn);
+
+ if (phpversion() < 5 && function_exists("overload")) {
+ overload($className);
+ }
+ }
+ }
+ }
+ }
+/**
+ * Loads all plugin models.
+ *
+ * @param string $plugin Name of plugin
+ * @return
+ */
+ function loadPluginModels($plugin) {
+ if (!class_exists('AppModel')) {
+ loadModel();
+ }
+ $pluginAppModel = Inflector::camelize($plugin . '_app_model');
+ $pluginAppModelFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_model.php';
+ if (!class_exists($pluginAppModel)) {
+ if (file_exists($pluginAppModelFile)) {
+ require($pluginAppModelFile);
+ } else {
+ die('Plugins must have a class named ' . $pluginAppModel);
+ }
+ if (phpversion() < 5 && function_exists("overload")) {
+ overload($pluginAppModel);
+ }
+ }
+
+ $pluginModelDir = APP . 'plugins' . DS . $plugin . DS . 'models' . DS;
+
+ foreach (listClasses($pluginModelDir)as $modelFileName) {
+ list($name) = explode('.', $modelFileName);
+ $className = Inflector::camelize($name);
+
+ if (!class_exists($className)) {
+ require($pluginModelDir . $modelFileName);
+
+ if (phpversion() < 5 && function_exists("overload")) {
+ overload($className);
+ }
+ }
+ }
+ }
+/**
+ * Loads custom view class.
+ *
+ */
+ function loadView($viewClass) {
+ if (!class_exists($viewClass . 'View')) {
+ $paths = Configure::getInstance();
+ $file = Inflector::underscore($viewClass) . '.php';
+
+ foreach ($paths->viewPaths as $path) {
+ if (file_exists($path . $file)) {
+ return require($path . $file);
+ }
+ }
+
+ if ($viewFile = fileExistsInPath(LIBS . 'view' . DS . $file)) {
+ if (file_exists($viewFile)) {
+ require($viewFile);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+/**
+ * Loads a model by CamelCase name.
+ */
+ function loadModel($name = null) {
+ if (!class_exists('Model')) {
+ require LIBS . 'model' . DS . 'model.php';
+ }
+ if (!class_exists('AppModel')) {
+ if (file_exists(APP . 'app_model.php')) {
+ require(APP . 'app_model.php');
+ } else {
+ require(CAKE . 'app_model.php');
+ }
+ if (phpversion() < 5 && function_exists("overload")) {
+ overload('AppModel');
+ }
+ }
+
+ if (!is_null($name) && !class_exists($name)) {
+ $className = $name;
+ $name = Inflector::underscore($name);
+ $paths = Configure::getInstance();
+
+ foreach ($paths->modelPaths as $path) {
+ if (file_exists($path . $name . '.php')) {
+ require($path . $name . '.php');
+ if (phpversion() < 5 && function_exists("overload")) {
+ overload($className);
+ }
+ return true;
+ }
+ }
+ return false;
+ } else {
+ return true;
+ }
+ }
+/**
+ * Loads all controllers.
+ */
+ function loadControllers() {
+ $paths = Configure::getInstance();
+ if (!class_exists('AppController')) {
+ if (file_exists(APP . 'app_controller.php')) {
+ require(APP . 'app_controller.php');
+ } else {
+ require(CAKE . 'app_controller.php');
+ }
+ }
+ $loadedControllers = array();
+
+ foreach ($paths->controllerPaths as $path) {
+ foreach (listClasses($path) as $controller) {
+ list($name) = explode('.', $controller);
+ $className = Inflector::camelize(str_replace('_controller', '', $name));
+
+ if (loadController($className)) {
+ $loadedControllers[$controller] = $className;
+ }
+ }
+ }
+ return $loadedControllers;
+ }
+/**
+ * Loads a controller and its helper libraries.
+ *
+ * @param string $name Name of controller
+ * @return boolean Success
+ */
+ function loadController($name) {
+ $paths = Configure::getInstance();
+ if (!class_exists('AppController')) {
+ if (file_exists(APP . 'app_controller.php')) {
+ require(APP . 'app_controller.php');
+ } else {
+ require(CAKE . 'app_controller.php');
+ }
+ }
+
+ if ($name === null) {
+ return true;
+ }
+
+ if (!class_exists($name . 'Controller')) {
+ $name = Inflector::underscore($name);
+
+ foreach ($paths->controllerPaths as $path) {
+ if (file_exists($path . $name . '_controller.php')) {
+ require($path . $name . '_controller.php');
+ return true;
+ }
+ }
+
+ if ($controller_fn = fileExistsInPath(LIBS . 'controller' . DS . $name . '_controller.php')) {
+ if (file_exists($controller_fn)) {
+ require($controller_fn);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+/**
+ * Loads a plugin's controller.
+ *
+ * @param string $plugin Name of plugin
+ * @param string $controller Name of controller to load
+ * @return boolean Success
+ */
+ function loadPluginController($plugin, $controller) {
+ $pluginAppController = Inflector::camelize($plugin . '_app_controller');
+ $pluginAppControllerFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_controller.php';
+ if (!class_exists($pluginAppController)) {
+ if (file_exists($pluginAppControllerFile)) {
+ require($pluginAppControllerFile);
+ } else {
+ return false;
+ }
+ }
+
+ if (empty($controller)) {
+ if (!class_exists($plugin . 'Controller')) {
+ if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) {
+ require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php');
+ return true;
+ }
+ }
+ }
+
+ if (!class_exists($controller . 'Controller')) {
+ $controller = Inflector::underscore($controller);
+ $file = APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $controller . '_controller.php';
+
+ if (file_exists($file)) {
+ require($file);
+ return true;
+ } elseif (!class_exists(Inflector::camelize($plugin . '_controller'))) {
+ if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) {
+ require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php');
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+/**
+ * Loads a helper
+ *
+ * @param string $name Name of helper
+ * @return boolean Success
+ */
+ function loadHelper($name) {
+ $paths = Configure::getInstance();
+
+ if ($name === null) {
+ return true;
+ }
+
+ if (!class_exists($name . 'Helper')) {
+ $name=Inflector::underscore($name);
+
+ foreach ($paths->helperPaths as $path) {
+ if (file_exists($path . $name . '.php')) {
+ require($path . $name . '.php');
+ return true;
+ }
+ }
+
+ if ($helper_fn = fileExistsInPath(LIBS . 'view' . DS . 'helpers' . DS . $name . '.php')) {
+ if (file_exists($helper_fn)) {
+ require($helper_fn);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return true;
+ }
+ }
+/**
+ * Loads a plugin's helper
+ *
+ * @param string $plugin Name of plugin
+ * @param string $helper Name of helper to load
+ * @return boolean Success
+ */
+ function loadPluginHelper($plugin, $helper) {
+ if (!class_exists($helper . 'Helper')) {
+ $helper = Inflector::underscore($helper);
+ $file = APP . 'plugins' . DS . $plugin . DS . 'views' . DS . 'helpers' . DS . $helper . '.php';
+ if (file_exists($file)) {
+ require($file);
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return true;
+ }
+ }
+/**
+ * Loads a component
+ *
+ * @param string $name Name of component
+ * @return boolean Success
+ */
+ function loadComponent($name) {
+ $paths = Configure::getInstance();
+
+ if ($name === null) {
+ return true;
+ }
+
+ if (!class_exists($name . 'Component')) {
+ $name=Inflector::underscore($name);
+
+ foreach ($paths->componentPaths as $path) {
+ if (file_exists($path . $name . '.php')) {
+ require($path . $name . '.php');
+ return true;
+ }
+ }
+
+ if ($component_fn = fileExistsInPath(LIBS . 'controller' . DS . 'components' . DS . $name . '.php')) {
+ if (file_exists($component_fn)) {
+ require($component_fn);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return true;
+ }
+ }
+/**
+ * Loads a plugin's component
+ *
+ * @param string $plugin Name of plugin
+ * @param string $helper Name of component to load
+ * @return boolean Success
+ */
+ function loadPluginComponent($plugin, $component) {
+ if (!class_exists($component . 'Component')) {
+ $component = Inflector::underscore($component);
+ $file = APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . 'components' . DS . $component . '.php';
+ if (file_exists($file)) {
+ require($file);
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return true;
+ }
+ }
+/**
+ * Returns an array of filenames of PHP files in given directory.
+ *
+ * @param string $path Path to scan for files
+ * @return array List of files in directory
+ */
+ function listClasses($path) {
+ $dir = opendir($path);
+ $classes=array();
+ while (false !== ($file = readdir($dir))) {
+ if ((substr($file, -3, 3) == 'php') && substr($file, 0, 1) != '.') {
+ $classes[] = $file;
+ }
+ }
+ closedir($dir);
+ return $classes;
+ }
+/**
+ * Loads configuration files
+ *
+ * @return boolean Success
+ */
+ function config() {
+ $args = func_get_args();
+ foreach ($args as $arg) {
+ if (('database' == $arg) && file_exists(CONFIGS . $arg . '.php')) {
+ include_once(CONFIGS . $arg . '.php');
+ } elseif (file_exists(CONFIGS . $arg . '.php')) {
+ include_once(CONFIGS . $arg . '.php');
+
+ if (count($args) == 1) {
+ return true;
+ }
+ } else {
+ if (count($args) == 1) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+/**
+ * Loads component/components from LIBS.
+ *
+ * Example:
+ * <code>
+ * uses('flay', 'time');
+ * </code>
+ *
+ * @uses LIBS
+ */
+ function uses() {
+ $args = func_get_args();
+ foreach ($args as $arg) {
+ require_once(LIBS . strtolower($arg) . '.php');
+ }
+ }
+/**
+ * Require given files in the VENDORS directory. Takes optional number of parameters.
+ *
+ * @param string $name Filename without the .php part.
+ *
+ */
+ function vendor($name) {
+ $args = func_get_args();
+ foreach ($args as $arg) {
+ if (file_exists(APP . 'vendors' . DS . $arg . '.php')) {
+ require_once(APP . 'vendors' . DS . $arg . '.php');
+ } else {
+ require_once(VENDORS . $arg . '.php');
+ }
+ }
+ }
+/**
+ * Prints out debug information about given variable.
+ *
+ * Only runs if DEBUG level is non-zero.
+ *
+ * @param boolean $var Variable to show debug information for.
+ * @param boolean $show_html If set to true, the method prints the debug data in a screen-friendly way.
+ */
+ function debug($var = false, $showHtml = false) {
+ if (Configure::read() > 0) {
+ print "\n<pre class=\"cake_debug\">\n";
+ ob_start();
+ print_r($var);
+ $var = ob_get_clean();
+
+ if ($showHtml) {
+ $var = str_replace('<', '&lt;', str_replace('>', '&gt;', $var));
+ }
+ print "{$var}\n</pre>\n";
+ }
+ }
+/**
+ * Returns microtime for execution time checking
+ *
+ * @return integer
+ */
+ if (!function_exists('getMicrotime')) {
+ function getMicrotime() {
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+ }
+ }
+/**
+ * Sorts given $array by key $sortby.
+ *
+ * @param array $array
+ * @param string $sortby
+ * @param string $order Sort order asc/desc (ascending or descending).
+ * @param integer $type
+ * @return mixed
+ */
+ if (!function_exists('sortByKey')) {
+ function sortByKey(&$array, $sortby, $order = 'asc', $type = SORT_NUMERIC) {
+ if (!is_array($array)) {
+ return null;
+ }
+
+ foreach ($array as $key => $val) {
+ $sa[$key] = $val[$sortby];
+ }
+
+ if ($order == 'asc') {
+ asort($sa, $type);
+ } else {
+ arsort($sa, $type);
+ }
+
+ foreach ($sa as $key => $val) {
+ $out[] = $array[$key];
+ }
+ return $out;
+ }
+ }
+/**
+ * Combines given identical arrays by using the first array's values as keys,
+ * and the second one's values as values. (Implemented for back-compatibility with PHP4)
+ *
+ * @param array $a1
+ * @param array $a2
+ * @return mixed Outputs either combined array or false.
+ */
+ if (!function_exists('array_combine')) {
+ function array_combine($a1, $a2) {
+ $a1 = array_values($a1);
+ $a2 = array_values($a2);
+ $c1 = count($a1);
+ $c2 = count($a2);
+
+ if ($c1 != $c2) {
+ return false;
+ }
+ if ($c1 <= 0) {
+ return false;
+ }
+
+ $output=array();
+ for ($i = 0; $i < $c1; $i++) {
+ $output[$a1[$i]] = $a2[$i];
+ }
+ return $output;
+ }
+ }
+/**
+ * Convenience method for htmlspecialchars.
+ *
+ * @param string $text
+ * @return string
+ */
+ function h($text) {
+ if (is_array($text)) {
+ return array_map('h', $text);
+ }
+ return htmlspecialchars($text);
+ }
+/**
+ * Returns an array of all the given parameters.
+ *
+ * Example:
+ * <code>
+ * a('a', 'b')
+ * </code>
+ *
+ * Would return:
+ * <code>
+ * array('a', 'b')
+ * </code>
+ *
+ * @return array
+ */
+ function a() {
+ $args = func_get_args();
+ return $args;
+ }
+/**
+ * Constructs associative array from pairs of arguments.
+ *
+ * Example:
+ * <code>
+ * aa('a','b')
+ * </code>
+ *
+ * Would return:
+ * <code>
+ * array('a'=>'b')
+ * </code>
+ *
+ * @return array
+ */
+ function aa() {
+ $args = func_get_args();
+ for ($l = 0, $c = count($args); $l < $c; $l++) {
+ if ($l + 1 < count($args)) {
+ $a[$args[$l]] = $args[$l + 1];
+ } else {
+ $a[$args[$l]] = null;
+ }
+ $l++;
+ }
+ return $a;
+ }
+/**
+ * Convenience method for echo().
+ *
+ * @param string $text String to echo
+ */
+ function e($text) {
+ echo $text;
+ }
+/**
+ * Convenience method for strtolower().
+ *
+ * @param string $str String to lowercase
+ */
+ function low($str) {
+ return strtolower($str);
+ }
+/**
+ * Convenience method for strtoupper().
+ *
+ * @param string $str String to uppercase
+ */
+ function up($str) {
+ return strtoupper($str);
+ }
+/**
+ * Convenience method for str_replace().
+ *
+ * @param string $search String to be replaced
+ * @param string $replace String to insert
+ * @param string $subject String to search
+ */
+ function r($search, $replace, $subject) {
+ return str_replace($search, $replace, $subject);
+ }
+/**
+ * Print_r convenience function, which prints out <PRE> tags around
+ * the output of given array. Similar to debug().
+ *
+ * @see debug()
+ * @param array $var
+ */
+ function pr($var) {
+ if (Configure::read() > 0) {
+ echo "<pre>";
+ print_r($var);
+ echo "</pre>";
+ }
+ }
+/**
+ * Display parameter
+ *
+ * @param mixed $p Parameter as string or array
+ * @return string
+ */
+ function params($p) {
+ if (!is_array($p) || count($p) == 0) {
+ return null;
+ } else {
+ if (is_array($p[0]) && count($p) == 1) {
+ return $p[0];
+ } else {
+ return $p;
+ }
+ }
+ }
+/**
+ * Merge a group of arrays
+ *
+ * @param array First array
+ * @param array Second array
+ * @param array Third array
+ * @param array Etc...
+ * @return array All array parameters merged into one
+ */
+ function am() {
+ $r = array();
+ foreach (func_get_args()as $a) {
+ if (!is_array($a)) {
+ $a = array($a);
+ }
+ $r = array_merge($r, $a);
+ }
+ return $r;
+ }
+/**
+ * Returns the REQUEST_URI from the server environment, or, failing that,
+ * constructs a new one, using the PHP_SELF constant and other variables.
+ *
+ * @return string URI
+ */
+ function setUri() {
+ if (env('HTTP_X_REWRITE_URL')) {
+ $uri = env('HTTP_X_REWRITE_URL');
+ } elseif (env('REQUEST_URI')) {
+ $uri = env('REQUEST_URI');
+ } else {
+ if (env('argv')) {
+ $uri = env('argv');
+
+ if (defined('SERVER_IIS')) {
+ $uri = BASE_URL . $uri[0];
+ } else {
+ $uri = env('PHP_SELF') . '/' . $uri[0];
+ }
+ } else {
+ $uri = env('PHP_SELF') . '/' . env('QUERY_STRING');
+ }
+ }
+ return $uri;
+ }
+/**
+ * Gets an environment variable from available sources.
+ * Used as a backup if $_SERVER/$_ENV are disabled.
+ *
+ * @param string $key Environment variable name.
+ * @return string Environment variable setting.
+ */
+ function env($key) {
+
+ if ($key == 'HTTPS') {
+ if (isset($_SERVER) && !empty($_SERVER)) {
+ return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on');
+ } else {
+ return (strpos(env('SCRIPT_URI'), 'https://') === 0);
+ }
+ }
+
+ if (isset($_SERVER[$key])) {
+ return $_SERVER[$key];
+ } elseif (isset($_ENV[$key])) {
+ return $_ENV[$key];
+ } elseif (getenv($key) !== false) {
+ return getenv($key);
+ }
+
+ if ($key == 'SCRIPT_FILENAME' && defined('SERVER_IIS') && SERVER_IIS === true) {
+ return str_replace('\\\\', '\\', env('PATH_TRANSLATED') );
+ }
+
+ if ($key == 'DOCUMENT_ROOT') {
+ $offset = 0;
+ if (!strpos(env('SCRIPT_NAME'), '.php')) {
+ $offset = 4;
+ }
+ return substr(env('SCRIPT_FILENAME'), 0, strlen(env('SCRIPT_FILENAME')) - (strlen(env('SCRIPT_NAME')) + $offset));
+ }
+ if ($key == 'PHP_SELF') {
+ return r(env('DOCUMENT_ROOT'), '', env('SCRIPT_FILENAME'));
+ }
+ return null;
+ }
+/**
+ * Returns contents of a file as a string.
+ *
+ * @param string $fileName Name of the file.
+ * @param boolean $useIncludePath Wheter the function should use the include path or not.
+ * @return mixed Boolean false or contents of required file.
+ */
+ if (!function_exists('file_get_contents')) {
+ function file_get_contents($fileName, $useIncludePath = false) {
+ $res=fopen($fileName, 'rb', $useIncludePath);
+
+ if ($res === false) {
+ trigger_error('file_get_contents() failed to open stream: No such file or directory', E_USER_WARNING);
+ return false;
+ }
+ clearstatcache();
+
+ if ($fileSize = @filesize($fileName)) {
+ $data = fread($res, $fileSize);
+ } else {
+ $data = '';
+
+ while (!feof($res)) {
+ $data .= fread($res, 8192);
+ }
+ }
+ return "$data\n";
+ }
+ }
+/**
+ * Writes data into file.
+ *
+ * If file exists, it will be overwritten. If data is an array, it will be join()ed with an empty string.
+ *
+ * @param string $fileName File name.
+ * @param mixed $data String or array.
+ */
+ if (!function_exists('file_put_contents')) {
+ function file_put_contents($fileName, $data) {
+ if (is_array($data)) {
+ $data = join('', $data);
+ }
+ $res = @fopen($fileName, 'w+b');
+ if ($res) {
+ $write = @fwrite($res, $data);
+ if ($write === false) {
+ return false;
+ } else {
+ return $write;
+ }
+ }
+ }
+ }
+/**
+ * Reads/writes temporary data to cache files or session.
+ *
+ * @param string $path File path within /tmp to save the file.
+ * @param mixed $data The data to save to the temporary file.
+ * @param mixed $expires A valid strtotime string when the data expires.
+ * @param string $target The target of the cached data; either 'cache' or 'public'.
+ * @return mixed The contents of the temporary file.
+ */
+ function cache($path, $data = null, $expires = '+1 day', $target = 'cache') {
+ $now = time();
+ if (!is_numeric($expires)) {
+ $expires = strtotime($expires, $now);
+ }
+
+ switch(strtolower($target)) {
+ case 'cache':
+ $filename = CACHE . $path;
+ break;
+ case 'public':
+ $filename = WWW_ROOT . $path;
+ break;
+ }
+
+ $timediff = $expires - $now;
+ $filetime = false;
+ if (file_exists($filename)) {
+ $filetime = @filemtime($filename);
+ }
+
+ if ($data === null) {
+ // Read data from file
+ if (file_exists($filename) && $filetime !== false) {
+ if ($filetime + $timediff < $now) {
+ // File has expired
+ @unlink($filename);
+ } else {
+ $data = file_get_contents($filename);
+ }
+ }
+ } else {
+ file_put_contents($filename, $data);
+ }
+ return $data;
+ }
+/**
+ * Used to delete files in the cache directories, or clear contents of cache directories
+ *
+ * @param mixed $params As String name to be searched for deletion, if name is a directory all files in directory will be deleted.
+ * If array, names to be searched for deletion.
+ * If clearCache() without params, all files in app/tmp/cache/views will be deleted
+ *
+ * @param string $type Directory in tmp/cache defaults to view directory
+ * @param string $ext The file extension you are deleting
+ * @return true if files found and deleted false otherwise
+ */
+ function clearCache($params = null, $type = 'views', $ext = '.php') {
+ if (is_string($params) || $params === null) {
+ $params = preg_replace('/\/\//', '/', $params);
+ $cache = CACHE . $type . DS . $params;
+
+ if (is_file($cache . $ext)) {
+ @unlink($cache . $ext);
+ return true;
+ } elseif (is_dir($cache)) {
+ $files = glob("$cache*");
+
+ if ($files === false) {
+ return false;
+ }
+
+ foreach ($files as $file) {
+ if (is_file($file)) {
+ @unlink($file);
+ }
+ }
+ return true;
+ } else {
+ $cache = CACHE . $type . DS . '*' . $params . $ext;
+ $files = glob($cache);
+
+ $cache = CACHE . $type . DS . '*' . $params . '_*' . $ext;
+ $files = array_merge($files, glob($cache));
+
+ if ($files === false) {
+ return false;
+ }
+
+ foreach ($files as $file) {
+ if (is_file($file)) {
+ @unlink($file);
+ }
+ }
+ return true;
+ }
+ } elseif (is_array($params)) {
+ foreach ($params as $key => $file) {
+ clearCache($file, $type, $ext);
+ }
+ return true;
+ }
+ return false;
+ }
+/**
+ * Recursively strips slashes from all values in an array
+ *
+ * @param unknown_type $value
+ * @return unknown
+ */
+ function stripslashes_deep($value) {
+ if (is_array($value)) {
+ $return = array_map('stripslashes_deep', $value);
+ return $return;
+ } else {
+ $return = stripslashes($value);
+ return $return ;
+ }
+ }
+/**
+ * Returns a translated string if one is found,
+ * or the submitted message if not found.
+ *
+ * @param unknown_type $msg
+ * @param unknown_type $return
+ * @return unknown
+ * @todo Not implemented fully till 2.0
+ */
+ function __($msg, $return = null) {
+ if (is_null($return)) {
+ echo($msg);
+ } else {
+ return $msg;
+ }
+ }
+/**
+ * Counts the dimensions of an array
+ *
+ * @param array $array
+ * @return int The number of dimensions in $array
+ */
+ function countdim($array) {
+ if (is_array(reset($array))) {
+ $return = countdim(reset($array)) + 1;
+ } else {
+ $return = 1;
+ }
+ return $return;
+ }
+/**
+ * Shortcut to Log::write.
+ */
+ function LogError($message) {
+ if (!class_exists('CakeLog')) {
+ uses('cake_log');
+ }
+ $bad = array("\n", "\r", "\t");
+ $good = ' ';
+ CakeLog::write('error', str_replace($bad, $good, $message));
+ }
+/**
+ * Searches include path for files
+ *
+ * @param string $file
+ * @return Full path to file if exists, otherwise false
+ */
+ function fileExistsInPath($file) {
+ $paths = explode(PATH_SEPARATOR, ini_get('include_path'));
+ foreach ($paths as $path) {
+ $fullPath = $path . DIRECTORY_SEPARATOR . $file;
+
+ if (file_exists($fullPath)) {
+ return $fullPath;
+ } elseif (file_exists($file)) {
+ return $file;
+ }
+ }
+ return false;
+ }
+/**
+ * Convert forward slashes to underscores and removes first and last underscores in a string
+ *
+ * @param string
+ * @return string with underscore remove from start and end of string
+ */
+ function convertSlash($string) {
+ $string = trim($string,"/");
+ $string = preg_replace('/\/\//', '/', $string);
+ $string = str_replace('/', '_', $string);
+ return $string;
+ }
+
+/**
+ * chmod recursively on a directory
+ *
+ * @param string $path
+ * @param int $mode
+ * @return boolean
+ */
+ function chmodr($path, $mode = 0755) {
+ if (!is_dir($path)) {
+ return chmod($path, $mode);
+ }
+ $dir = opendir($path);
+
+ while ($file = readdir($dir)) {
+ if ($file != '.' && $file != '..') {
+ $fullpath = $path . '/' . $file;
+
+ if (!is_dir($fullpath)) {
+ if (!chmod($fullpath, $mode)) {
+ return false;
+ }
+ } else {
+ if (!chmodr($fullpath, $mode)) {
+ return false;
+ }
+ }
+ }
+ }
+ closedir($dir);
+
+ if (chmod($path, $mode)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+/**
+ * removed the plugin name from the base url
+ *
+ * @param string $base
+ * @param string $plugin
+ * @return base url with plugin name removed if present
+ */
+ function strip_plugin($base, $plugin) {
+ if ($plugin != null) {
+ $base = preg_replace('/' . $plugin . '/', '', $base);
+ $base = str_replace('//', '', $base);
+ $pos1 = strrpos($base, '/');
+ $char = strlen($base) - 1;
+
+ if ($pos1 == $char) {
+ $base = substr($base, 0, $char);
+ }
+ }
+ return $base;
+ }
+/**
+ * Wraps ternary operations. If $condition is a non-empty value, $val1 is returned, otherwise $val2.
+ *
+ * @param mixed $condition Conditional expression
+ * @param mixed $val1
+ * @param mixed $val2
+ * @return mixed $val1 or $val2, depending on whether $condition evaluates to a non-empty expression.
+ */
+ function ife($condition, $val1 = null, $val2 = null) {
+ if (!empty($condition)) {
+ return $val1;
+ }
+ return $val2;
+ }
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/bootstrap.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/bootstrap.php
new file mode 100644
index 0000000..baed0e2
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/bootstrap.php
@@ -0,0 +1,104 @@
+<?php
+/* SVN FILE: $Id: bootstrap.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Basic Cake functionality.
+ *
+ * Core functions for including other source files, loading models and so forth.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Configuration, directory layout and standard libraries
+ */
+ if (!isset($bootstrap)) {
+ require CORE_PATH . 'cake' . DS . 'basics.php';
+ require APP_PATH . 'config' . DS . 'core.php';
+ require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
+ }
+ $TIME_START = getMicrotime();
+ require LIBS . 'object.php';
+ require LIBS . 'session.php';
+ require LIBS . 'security.php';
+ require LIBS . 'inflector.php';
+ require LIBS . 'configure.php';
+ $paths = Configure::getInstance();
+/**
+ * Enter description here...
+ */
+ if (empty($uri) && defined('BASE_URL')) {
+ $uri = setUri();
+
+ if ($uri === '/' || $uri === '/index.php' || $uri === '/'.APP_DIR.'/') {
+ $_GET['url'] = '/';
+ $url = '/';
+ } else {
+ if (strpos($uri, 'index.php') !== false) {
+ $uri = r('?', '', $uri);
+ $elements=explode('/index.php', $uri);
+ } else {
+ $elements = explode('/?', $uri);
+ }
+
+ if (!empty($elements[1])) {
+ $_GET['url'] = $elements[1];
+ $url = $elements[1];
+ } else {
+ $_GET['url'] = '/';
+ $url = '/';
+ }
+ }
+ } else {
+ if (empty($_GET['url'])) {
+ $url = null;
+ } else {
+ $url = $_GET['url'];
+ }
+ }
+
+ if (strpos($url, 'ccss/') === 0) {
+ include WWW_ROOT . DS . 'css.php';
+ die();
+ }
+
+ Configure::write('debug', DEBUG);
+
+ require CAKE . 'dispatcher.php';
+
+ if (defined('CACHE_CHECK') && CACHE_CHECK === true) {
+ if (empty($uri)) {
+ $uri = setUri();
+ }
+ $filename=CACHE . 'views' . DS . convertSlash($uri) . '.php';
+
+ if (file_exists($filename)) {
+ uses(DS . 'controller' . DS . 'component', DS . 'view' . DS . 'view');
+ $v = null;
+ $view = new View($v);
+ $view->renderCache($filename, $TIME_START);
+ } elseif (file_exists(CACHE . 'views' . DS . convertSlash($uri) . '_index.php')) {
+ uses(DS . 'controller' . DS . 'component', DS . 'view' . DS . 'view');
+ $v = null;
+ $view = new View($v);
+ $view->renderCache(CACHE . 'views' . DS . convertSlash($uri) . '_index.php', $TIME_START);
+ }
+ }
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/config/config.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/config/config.php
new file mode 100644
index 0000000..6d907df
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/config/config.php
@@ -0,0 +1,28 @@
+<?php
+/* SVN FILE: $Id: config.php 7692 2008-10-02 05:06:48Z nate $ */
+/**
+ * Core Configurations.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.config
+ * @since CakePHP(tm) v 1.1.11.4062
+ * @version $Revision: 7692 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 01:06:48 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+$config['Cake.version'] = '1.1.20.7692';
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/config/paths.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/config/paths.php
new file mode 100644
index 0000000..a2f9659
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/config/paths.php
@@ -0,0 +1,175 @@
+<?php
+/* SVN FILE: $Id: paths.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * In this file you set paths to different directories used by Cake.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.app.config
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * If the index.php file is used instead of an .htaccess file
+ * or if the user can not set the web root to use the public
+ * directory we will define ROOT there, otherwise we set it
+ * here.
+ */
+ if (!defined('ROOT')) {
+ define ('ROOT', '../');
+ }
+ if (!defined('WEBROOT_DIR')) {
+ define ('WEBROOT_DIR', 'webroot');
+ }
+/**
+ * Path to the application's directory.
+ */
+ define ('CAKE', CORE_PATH.'cake'.DS);
+/**
+ * Path to the application's directory.
+ */
+ define ('APP', ROOT.DS.APP_DIR.DS);
+/**
+ * Path to the application's models directory.
+ */
+ define ('MODELS', APP.'models'.DS);
+/**
+ * Path to the application's controllers directory.
+ */
+ define ('CONTROLLERS', APP.'controllers'.DS);
+/**
+ * Path to the application's controllers directory.
+ */
+ define ('COMPONENTS', CONTROLLERS.'components'.DS);
+/**
+ * Path to the application's views directory.
+ */
+ 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', VIEWS.'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', VIEWS.'elements'.DS);
+/**
+ * Path to the configuration files directory.
+ */
+ define ('CONFIGS', APP.'config'.DS);
+/**
+ * Path to the libs directory.
+ */
+ define ('INFLECTIONS', CAKE.'config'.DS.'inflections'.DS);
+/**
+ * Path to the libs directory.
+ */
+ define ('LIBS', CAKE.'libs'.DS);
+/**
+ * Path to the public directory.
+ */
+ define ('CSS', WWW_ROOT.'css'.DS);
+/**
+ * Path to the public directory.
+ */
+ define ('JS', WWW_ROOT.'js'.DS);
+/**
+ * Path to the scripts direcotry.
+ */
+ define('SCRIPTS', CAKE.'scripts'.DS);
+/**
+ * Path to the tests directory.
+ */
+ define ('TESTS', APP.'tests'.DS);
+/**
+ * Path to the controller test directory.
+ */
+ define ('CONTROLLER_TESTS', TESTS.'cases'.DS.'controllers'.DS);
+/**
+ * Path to the components test directory.
+ */
+ define ('COMPONENT_TESTS', TESTS.'cases'.DS.'components'.DS);
+/**
+ * Path to the helpers test directory.
+ */
+ define ('HELPER_TESTS', TESTS.'cases'.DS.'views'.DS.'helpers'.DS);
+/**
+ * Path to the models' test directory.
+ */
+ define ('MODEL_TESTS', TESTS.'cases'.DS.'models'.DS);
+/**
+ * Path to the lib test directory.
+ */
+ define ('LIB_TESTS', TESTS.'lib'.DS);
+/**
+ * Path to the temporary files directory.
+ */
+ define ('TMP', APP.'tmp'.DS);
+/**
+ * Path to the logs directory.
+ */
+ define ('LOGS', TMP.'logs'.DS);
+/**
+ * Path to the cache files directory. It can be shared between hosts in a multi-server setup.
+ */
+ define('CACHE', TMP.'cache'.DS);
+/**
+ * Path to the vendors directory.
+ */
+ define ('VENDORS', CAKE_CORE_INCLUDE_PATH.DS.'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);
+/**
+ * Full url prefix
+ */
+ $s = null;
+ if (env('HTTPS')) {
+ $s ='s';
+ }
+
+ $httpHost = env('HTTP_HOST');
+
+ if (isset($httpHost)) {
+ define('FULL_BASE_URL', 'http'.$s.'://'.$httpHost);
+ }
+ unset($httpHost, $s);
+/**
+ * Web path to the public images directory.
+ */
+ define ('IMAGES_URL', 'img/');
+/**
+ * Web path to the CSS files directory.
+ */
+ define ('CSS_URL', 'css/');
+/**
+ * Web path to the js files directory.
+ */
+ define ('JS_URL', 'js/');
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/dispatcher.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/dispatcher.php
new file mode 100644
index 0000000..c2325cf
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/dispatcher.php
@@ -0,0 +1,429 @@
+<?php
+/* SVN FILE: $Id: dispatcher.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Dispatcher takes the URL information, parses it for paramters and
+ * tells the involved controllers what to do.
+ *
+ * This is the heart of Cake's operation.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * List of helpers to include
+ */
+ uses('router', DS.'controller'.DS.'controller');
+/**
+ * Dispatcher translates URLs to controller-action-paramter triads.
+ *
+ * Dispatches the request, creating appropriate models and controllers.
+ *
+ * @package cake
+ * @subpackage cake.cake
+ */
+class Dispatcher extends Object {
+/**
+ * Base URL
+ * @var string
+ */
+ var $base = false;
+/**
+ * @var string
+ */
+ var $admin = false;
+/**
+ * @var string
+ */
+ var $webservices = null;
+/**
+ * @var string
+ */
+ var $plugin = null;
+/**
+ * Constructor.
+ */
+ function __construct() {
+ parent::__construct();
+ }
+/**
+ * Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set).
+ *
+ * If no controller of given name can be found, invoke() shows error messages in
+ * the form of Missing Controllers information. It does the same with Actions (methods of Controllers are called
+ * Actions).
+ *
+ * @param string $url URL information to work on.
+ * @param array $additionalParams Settings array ("bare", "return"),
+ * which is melded with the GET and POST params.
+ * @return boolean Success
+ */
+ function dispatch($url, $additionalParams=array()) {
+ $params = array_merge($this->parseParams($url), $additionalParams);
+ $missingController = false;
+ $missingAction = false;
+ $missingView = false;
+ $privateAction = false;
+ $this->base = $this->baseUrl();
+
+ if (empty($params['controller'])) {
+ $missingController = true;
+ } else {
+ $ctrlName = Inflector::camelize($params['controller']);
+ $ctrlClass = $ctrlName.'Controller';
+
+ if (!loadController($ctrlName)) {
+ $pluginName = Inflector::camelize($params['action']);
+ if (!loadPluginController(Inflector::underscore($ctrlName), $pluginName)) {
+ if (preg_match('/([\\.]+)/', $ctrlName)) {
+ return $this->cakeError('error404', array(
+ array('url' => strtolower($ctrlName),
+ 'message' => 'Was not found on this server',
+ 'base' => $this->base)));
+ } elseif (!class_exists($ctrlClass)) {
+ $missingController = true;
+ } else {
+ $params['plugin'] = null;
+ $this->plugin = null;
+ }
+ } else {
+ $params['plugin'] = Inflector::underscore($ctrlName);
+ }
+ } else {
+ $params['plugin'] = null;
+ $this->plugin = null;
+ }
+ }
+
+ if (isset($params['plugin'])) {
+ $plugin = $params['plugin'];
+ $pluginName = Inflector::camelize($params['action']);
+ $pluginClass = $pluginName.'Controller';
+ $ctrlClass = $pluginClass;
+ $oldAction = $params['action'];
+ $params = $this->_restructureParams($params);
+ $this->plugin = $plugin;
+ loadPluginModels($plugin);
+ $this->base = $this->base.'/'.Inflector::underscore($ctrlName);
+
+ if (empty($params['controller']) || !class_exists($pluginClass)) {
+ $params['controller'] = Inflector::underscore($ctrlName);
+ $ctrlClass = $ctrlName.'Controller';
+ if (!is_null($params['action'])) {
+ array_unshift($params['pass'], $params['action']);
+ }
+ $params['action'] = $oldAction;
+ }
+ }
+
+ if (empty($params['action'])) {
+ $params['action'] = 'index';
+ }
+
+ if (defined('CAKE_ADMIN')) {
+ if (isset($params[CAKE_ADMIN])) {
+ $this->admin = '/'.CAKE_ADMIN ;
+ $url = preg_replace('/'.CAKE_ADMIN.'(\/|$)/', '', $url);
+ $params['action'] = CAKE_ADMIN.'_'.$params['action'];
+ } elseif (strpos($params['action'], CAKE_ADMIN) === 0) {
+ $privateAction = true;
+ }
+ }
+
+ if ($missingController) {
+ return $this->cakeError('missingController', array(
+ array('className' => Inflector::camelize($params['controller']."Controller"),
+ 'webroot' => $this->webroot,
+ 'url' => $url,
+ 'base' => $this->base)));
+ } else {
+ $controller =& new $ctrlClass();
+ }
+
+ $classMethods = get_class_methods($controller);
+ $classVars = get_object_vars($controller);
+
+ if ((in_array($params['action'], $classMethods) || in_array(strtolower($params['action']), $classMethods)) && strpos($params['action'], '_', 0) === 0) {
+ $privateAction = true;
+ }
+
+ if (!in_array($params['action'], $classMethods) && !in_array(strtolower($params['action']), $classMethods)) {
+ $missingAction = true;
+ }
+
+ if (in_array(strtolower($params['action']), array('object', 'tostring', 'requestaction', 'log',
+ 'cakeerror', 'constructclasses', 'redirect',
+ 'set', 'setaction', 'validate', 'validateerrors',
+ 'render', 'referer', 'flash', 'flashout',
+ 'generatefieldnames', 'postconditions', 'cleanupfields',
+ 'beforefilter', 'beforerender', 'afterfilter'))) {
+ $missingAction = true;
+ }
+
+ if (in_array('return', array_keys($params)) && $params['return'] == 1) {
+ $controller->autoRender = false;
+ }
+
+ $controller->base = $this->base;
+ $base = strip_plugin($this->base, $this->plugin);
+ if (defined("BASE_URL")) {
+ $controller->here = $base . $this->admin . $url;
+ } else {
+ $controller->here = $base . $this->admin . '/' . $url;
+ }
+ $controller->webroot = $this->webroot;
+ $controller->params = $params;
+ $controller->action = $params['action'];
+
+ if (!empty($controller->params['data'])) {
+ $controller->data =& $controller->params['data'];
+ } else {
+ $controller->data = null;
+ }
+
+ if (!empty($controller->params['pass'])) {
+ $controller->passed_args =& $controller->params['pass'];
+ $controller->passedArgs =& $controller->params['pass'];
+ } else {
+ $controller->passed_args = null;
+ $controller->passedArgs = null;
+ }
+
+ if (!empty($params['bare'])) {
+ $controller->autoLayout = !$params['bare'];
+ } else {
+ $controller->autoLayout = $controller->autoLayout;
+ }
+
+ $controller->webservices = $params['webservices'];
+ $controller->plugin = $this->plugin;
+
+ if (!is_null($controller->webservices)) {
+ array_push($controller->components, $controller->webservices);
+ array_push($controller->helpers, $controller->webservices);
+ $component =& new Component($controller);
+ }
+ $controller->_initComponents();
+ $controller->constructClasses();
+
+ if ($missingAction && !in_array('scaffold', array_keys($classVars))) {
+ $this->start($controller);
+ return $this->cakeError('missingAction', array(
+ array('className' => Inflector::camelize($params['controller']."Controller"),
+ 'action' => $params['action'],
+ 'webroot' => $this->webroot,
+ 'url' => $url,
+ 'base' => $this->base)));
+ }
+
+ if ($privateAction) {
+ $this->start($controller);
+ return $this->cakeError('privateAction', array(
+ array('className' => Inflector::camelize($params['controller']."Controller"),
+ 'action' => $params['action'],
+ 'webroot' => $this->webroot,
+ 'url' => $url,
+ 'base' => $this->base)));
+ }
+ return $this->_invoke($controller, $params, $missingAction);
+ }
+/**
+ * Invokes given controller's render action if autoRender option is set. Otherwise the contents of the operation are returned as a string.
+ *
+ * @param object $controller
+ * @param array $params
+ * @param boolean $missingAction
+ * @return string
+ */
+ function _invoke (&$controller, $params, $missingAction = false) {
+ $this->start($controller);
+ $classVars = get_object_vars($controller);
+
+ if ($missingAction && in_array('scaffold', array_keys($classVars))) {
+ uses(DS.'controller'.DS.'scaffold');
+ return new Scaffold($controller, $params);
+ } else {
+ $output = call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? array(): $params['pass']);
+ }
+ if ($controller->autoRender) {
+ $output = $controller->render();
+ }
+ $controller->output =& $output;
+ $controller->afterFilter();
+ return $controller->output;
+ }
+/**
+ * Starts up a controller
+ *
+ * @param object $controller
+ */
+ function start(&$controller) {
+ if (!empty($controller->beforeFilter)) {
+ if (is_array($controller->beforeFilter)) {
+
+ foreach ($controller->beforeFilter as $filter) {
+ if (is_callable(array($controller,$filter)) && $filter != 'beforeFilter') {
+ $controller->$filter();
+ }
+ }
+ } else {
+ if (is_callable(array($controller, $controller->beforeFilter)) && $controller->beforeFilter != 'beforeFilter') {
+ $controller->{$controller->beforeFilter}();
+ }
+ }
+ }
+ $controller->beforeFilter();
+
+ foreach ($controller->components as $c) {
+ $path = preg_split('/\/|\./', $c);
+ $c = $path[count($path) - 1];
+ if (isset($controller->{$c}) && is_object($controller->{$c}) && is_callable(array($controller->{$c}, 'startup'))) {
+ $controller->{$c}->startup($controller);
+ }
+ }
+ }
+
+/**
+ * Returns array of GET and POST parameters. GET parameters are taken from given URL.
+ *
+ * @param string $from_url URL to mine for parameter information.
+ * @return array Parameters found in POST and GET.
+ */
+ function parseParams($from_url) {
+ $Route = new Router();
+ include CONFIGS.'routes.php';
+ $params = $Route->parse ($from_url);
+
+ if (ini_get('magic_quotes_gpc') == 1) {
+ if (!empty($_POST)) {
+ $params['form'] = stripslashes_deep($_POST);
+ }
+ } else {
+ $params['form'] = $_POST;
+ }
+
+ if (isset($params['form']['data'])) {
+ $params['data'] = $Route->stripEscape($params['form']['data']);
+ }
+
+ if (isset($_GET)) {
+ if (ini_get('magic_quotes_gpc') == 1) {
+ $params['url'] = stripslashes_deep($_GET);
+ } else {
+ $params['url'] = $_GET;
+ }
+ }
+
+ foreach ($_FILES as $name => $data) {
+ if ($name != 'data') {
+ $params['form'][$name] = $data;
+ }
+ }
+
+ if (isset($_FILES['data'])) {
+ foreach ($_FILES['data'] as $key => $data) {
+
+ foreach ($data as $model => $fields) {
+
+ foreach ($fields as $field => $value) {
+ $params['data'][$model][$field][$key] = $value;
+ }
+ }
+ }
+ }
+ $params['bare'] = empty($params['ajax'])? (empty($params['bare'])? 0: 1): 1;
+ $params['webservices'] = empty($params['webservices']) ? null : $params['webservices'];
+ return $params;
+ }
+/**
+ * Returns a base URL.
+ *
+ * @return string Base URL
+ */
+ function baseUrl() {
+ $htaccess = null;
+ $base = $this->admin;
+ $this->webroot = '';
+
+ if (defined('BASE_URL')) {
+ $base = BASE_URL.$this->admin;
+ }
+
+ $docRoot = env('DOCUMENT_ROOT');
+ $scriptName = env('PHP_SELF');
+ $r = null;
+ $appDirName = str_replace('/', '\/', preg_quote(APP_DIR));
+ $webrootDirName = str_replace('/', '\/', preg_quote(WEBROOT_DIR));
+
+ if (preg_match('/'.$appDirName.'\\'.DS.$webrootDirName.'/', $docRoot)) {
+ $this->webroot = '/';
+
+ if (preg_match('/^(.*)\/index\.php$/', $scriptName, $r)) {
+
+ if (!empty($r[1])) {
+ return $base.$r[1];
+ }
+ }
+ } else {
+ if (defined('BASE_URL')) {
+ $webroot = setUri();
+ $htaccess = preg_replace('/(?:'.APP_DIR.'\\/(.*)|index\\.php(.*))/i', '', $webroot).APP_DIR.'/'.$webrootDirName.'/';
+ }
+
+ if (preg_match('/^(.*)\\/'.$appDirName.'\\/'.$webrootDirName.'\\/index\\.php$/', $scriptName, $regs)) {
+
+ if (APP_DIR === 'app') {
+ $appDir = null;
+ } else {
+ $appDir = '/'.APP_DIR;
+ }
+ !empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[1].$appDir.'/';
+ return $base.$regs[1].$appDir;
+
+ } elseif (preg_match('/^(.*)\\/'.$webrootDirName.'([^\/i]*)|index\\\.php$/', $scriptName, $regs)) {
+ !empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[0].'/';
+ return $base.$regs[0];
+
+ } else {
+ !empty($htaccess)? $this->webroot = $htaccess : $this->webroot = '/';
+ return $base;
+ }
+ }
+ return $base;
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $params
+ * @return unknown
+ */
+ function _restructureParams($params) {
+ $params['controller'] = $params['action'];
+
+ if (isset($params['pass'][0])) {
+ $params['action'] = $params['pass'][0];
+ array_shift($params['pass']);
+ } else {
+ $params['action'] = null;
+ }
+ return $params;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/cache.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/cache.php
new file mode 100644
index 0000000..9d59ef6
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/cache.php
@@ -0,0 +1,137 @@
+<?php
+/* SVN FILE: $Id: cache.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Caching for Cake.
+ *
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Included libraries.
+ *
+ */
+ if (!class_exists('Model')) {
+ uses(DS . 'model' . DS . 'model');
+ }
+/**
+ * Caching for Cake.
+ *
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class Cache extends Model{
+/**
+ * Identifier. Either an MD5 string or NULL.
+ *
+ * @var string
+ */
+ var $id = null;
+/**
+ * Content container for cache data.
+ *
+ * @var unknown_type
+ */
+ var $data = null;
+/**
+ * Content to be cached.
+ *
+ * @var unknown_type
+ */
+ var $for_caching = null;
+/**
+ * Name of the database table used for caching.
+ *
+ * @var string
+ */
+ var $useTable = 'cache';
+/**
+ * Constructor. Generates an md5'ed id for internal use. Calls the constructor on Model as well.
+ *
+ * @param unknown_type $id
+ */
+ function __construct($id) {
+ $this->id = (md5($id));
+ parent::__construct($this->id);
+ }
+/**
+ * Returns this object's id after setting it. If called without parameters the current object's id is returned.
+ *
+ * @param unknown_type $id
+ * @return unknown
+ */
+ function id($id = null) {
+ if (!$id) {
+ return $this->id;
+ }
+ return ($this->id = $id);
+ }
+/**
+ * Store given content in cache database.
+ *
+ * @param string $content Content to keep in cache.
+ * @param int $keep_for Number of seconds to keep data in cache.
+ * @return boolean Success
+ */
+ function remember($content, $keep_for = CACHE_PAGES_FOR) {
+ $data = addslashes($this->for_caching . $content);
+ $expire = date("Y-m-d H:i:s", time() + ($keep_for > 0 ? $keep_for : 999999999));
+ return $this->query("REPLACE {$this->useTable} (id,data,expire) VALUES ('{$this->id}', '{$data}', '{$expire}')");
+ }
+/**
+ * Returns content from the Cache object itself, if the Cache object has a non-empty data property.
+ * Else from the database cache.
+ *
+ * @return unknown
+ */
+ function restore() {
+ if (empty($this->data['data'])) {
+ return $this->find("id='{$this->id}' AND expire>NOW()");
+ }
+ return $this->data['data'];
+ }
+/**
+ * Returns true if the cache data property has current (non-stale) content for given id.
+ *
+ * @return boolean
+ */
+ function has() {
+ return is_array($this->data = $this->find("id='{$this->id}' AND expire>NOW()"));
+ }
+/**
+ * Appends $string to the for_caching property of the Cache object.
+ *
+ * @param string $string
+ */
+ function append($string) {
+ $this->for_caching .= $string;
+ }
+/**
+ * Clears the cache database table.
+ *
+ * @return unknown
+ */
+ function clear() {
+ return $this->query("DELETE FROM {$this->useTable}");
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/cake_log.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/cake_log.php
new file mode 100644
index 0000000..7f6e7e0
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/cake_log.php
@@ -0,0 +1,57 @@
+<?php
+/* SVN FILE: $Id: cake_log.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Logging.
+ *
+ * Log messages to text files.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Included libraries.
+ *
+ */
+ if (!class_exists('File')) {
+ uses('file');
+ }
+/**
+ * Logs messages to text files
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class CakeLog{
+/**
+ * Writes given message to a log file in the logs directory.
+ *
+ * @param string $type Type of log, becomes part of the log's filename
+ * @param string $msg Message to log
+ * @return boolean Success
+ */
+ function write($type, $msg) {
+ $filename = LOGS . $type . '.log';
+ $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $msg . "\n";
+ $log = new File($filename);
+ return $log->append($output);
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/class_registry.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/class_registry.php
new file mode 100644
index 0000000..45b1822
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/class_registry.php
@@ -0,0 +1,117 @@
+<?php
+/* SVN FILE: $Id: class_registry.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * Class collections.
+ *
+ * A repository for class objects, each registered with a key.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.9.2
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Class Collections.
+ *
+ * A repository for class objects, each registered with a key.
+ * If you try to add an object with the same key twice, nothing will come of it.
+ * If you need a second instance of an object, give it another key.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class ClassRegistry{
+/**
+ * Names of classes with their objects.
+ *
+ * @var array
+ * @access private
+ */
+ var $_objects = array();
+/**
+ * Return a singleton instance of the ClassRegistry.
+ *
+ * @return ClassRegistry instance
+ */
+ function &getInstance() {
+ static $instance = array();
+ if (!$instance) {
+ $instance[0] = &new ClassRegistry;
+ }
+ return $instance[0];
+ }
+/**
+ * Add $object to the registry, associating it with the name $key.
+ *
+ * @param string $key
+ * @param mixed $object
+ */
+ function addObject($key, &$object) {
+ $_this =& ClassRegistry::getInstance();
+ $key = Inflector::underscore($key);
+ if (array_key_exists($key, $_this->_objects) === false) {
+ $_this->_objects[$key] = &$object;
+ }
+ }
+/**
+ * Remove object which corresponds to given key.
+ *
+ * @param string $key
+ * @return void
+ */
+ function removeObject($key) {
+ $_this =& ClassRegistry::getInstance();
+ $key = Inflector::underscore($key);
+ if (array_key_exists($key, $_this->_objects) === true) {
+ unset($_this->_objects[$key]);
+ }
+ }
+/**
+ * Returns true if given key is present in the ClassRegistry.
+ *
+ * @param string $key Key to look for
+ * @return boolean Success
+ */
+ function isKeySet($key) {
+ $_this =& ClassRegistry::getInstance();
+ $key = Inflector::underscore($key);
+ return array_key_exists($key, $_this->_objects);
+ }
+/**
+ * Get all keys from the regisrty.
+ *
+ * @return array
+ */
+ function keys() {
+ $_this =& ClassRegistry::getInstance();
+ return array_keys($_this->_objects);
+ }
+/**
+ * Return object which corresponds to given key.
+ *
+ * @param string $key
+ * @return mixed
+ */
+ function &getObject($key) {
+ $_this =& ClassRegistry::getInstance();
+ $key = Inflector::underscore($key);
+ return $_this->_objects[$key];
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/configure.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/configure.php
new file mode 100644
index 0000000..677db20
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/configure.php
@@ -0,0 +1,354 @@
+<?php
+/* SVN FILE: $Id: configure.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 1.0.0.2363
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class Configure extends Object {
+/**
+ * Hold array with paths to view files
+ *
+ * @var array
+ * @access public
+ */
+ var $viewPaths = array();
+/**
+ * Hold array with paths to controller files
+ *
+ * @var array
+ * @access public
+ */
+ var $controllerPaths = array();
+/**
+ * Enter description here...
+ *
+ * @var array
+ * @access public
+ */
+ var $modelPaths = array();
+/**
+ * Enter description here...
+ *
+ * @var array
+ * @access public
+ */
+ var $helperPaths = array();
+/**
+ * Enter description here...
+ *
+ * @var array
+ * @access public
+ */
+ var $componentPaths = array();
+/**
+ * Enter description here...
+ *
+ * @var integer
+ * @access public
+ */
+ var $debug = null;
+/**
+ * Return a singleton instance of Configure.
+ *
+ * @return Configure instance
+ * @access public
+ */
+ function &getInstance() {
+ static $instance = array();
+ if (!$instance) {
+ $instance[0] =& new Configure;
+ $instance[0]->__loadBootstrap();
+ }
+ return $instance[0];
+ }
+/**
+ * Used to write a dynamic var in the Configure instance.
+ *
+ * Usage
+ * Configure::write('One.key1', 'value of the Configure::One[key1]');
+ * Configure::write(array('One.key1' => 'value of the Configure::One[key1]'));
+ * Configure::write('One', array('key1'=>'value of the Configure::One[key1]', 'key2'=>'value of the Configure::One[key2]');
+ * Configure::write(array('One.key1' => 'value of the Configure::One[key1]', 'One.key2' => 'value of the Configure::One[key2]'));
+ *
+ * @param array $config
+ * @return void
+ * @access public
+ */
+ function write($config, $value = null) {
+ $_this =& Configure::getInstance();
+
+ if (!is_array($config) && $value !== null) {
+ $name = $_this->__configVarNames($config);
+
+ if (count($name) > 1) {
+ $_this->{$name[0]}[$name[1]] = $value;
+ } else {
+ $_this->{$name[0]} = $value;
+ }
+ } else {
+
+ foreach ($config as $names => $value) {
+ $name = $_this->__configVarNames($names);
+ if (count($name) > 1) {
+ $_this->{$name[0]}[$name[1]] = $value;
+ } else {
+ $_this->{$name[0]} = $value;
+ }
+ }
+ }
+
+ if ($config == 'debug' || (is_array($config) && in_array('debug', $config))) {
+ if ($_this->debug) {
+ error_reporting(E_ALL);
+
+ if (function_exists('ini_set')) {
+ ini_set('display_errors', 1);
+ }
+ } else {
+ error_reporting(0);
+ }
+ }
+ }
+/**
+ * Used to read Configure::$var
+ *
+ * Usage
+ * Configure::read('Name'); will return all values for Name
+ * Configure::read('Name.key'); will return only the value of Configure::Name[key]
+ *
+ * @param string $var
+ * @return string value of Configure::$var
+ * @access public
+ */
+ function read($var = 'debug') {
+ $_this =& Configure::getInstance();
+ if ($var === 'debug') {
+ if (!isset($_this->debug)) {
+ $_this->debug = DEBUG;
+ }
+ return $_this->debug;
+ }
+
+ $name = $_this->__configVarNames($var);
+ if (count($name) > 1) {
+ if (isset($_this->{$name[0]}[$name[1]])) {
+ return $_this->{$name[0]}[$name[1]];
+ }
+ return null;
+ } else {
+ if (isset($_this->{$name[0]})) {
+ return $_this->{$name[0]};
+ }
+ return null;
+ }
+ }
+/**
+ * Used to delete a var from the Configure instance.
+ *
+ * Usage:
+ * Configure::delete('Name'); will delete the entire Configure::Name
+ * Configure::delete('Name.key'); will delete only the Configure::Name[key]
+ *
+ * @param string $var the var to be deleted
+ * @return void
+ * @access public
+ */
+ function delete($var = null) {
+ $_this =& Configure::getInstance();
+
+ $name = $_this->__configVarNames($var);
+ if (count($name) > 1) {
+ unset($_this->{$name[0]}[$name[1]]);
+ } else {
+ unset($_this->{$name[0]});
+ }
+ }
+/**
+ * Will load a file from app/config/configure_file.php
+ * variables in the files should be formated like:
+ * $config['name'] = 'value';
+ * These will be used to create dynamic Configure vars.
+ *
+ * Usage Configure::load('configure_file');
+ *
+ * @param string $fileName name of file to load, extension must be .php and only the name should be used, not the extenstion
+ * @return Configure::write
+ * @access public
+ */
+ function load($fileName) {
+ $_this =& Configure::getInstance();
+
+ if (!file_exists(CONFIGS . $fileName . '.php')) {
+ trigger_error("Configure::load() - $fileName.php not found", E_USER_WARNING);
+ return false;
+ }
+ include(CONFIGS . $fileName . '.php');
+ if (!isset($config)) {
+ trigger_error("Configure::load() - no variable \$config found in $fileName.php", E_USER_WARNING);
+ return false;
+ }
+ return $_this->write($config);
+ }
+
+/**
+ * Used to determine the current version of CakePHP
+ *
+ * Usage Configure::version();
+ *
+ * @return string Current version of CakePHP
+ * @access public
+ */
+ function version() {
+ $_this =& Configure::getInstance();
+ if (!isset($_this->Cake['version'])) {
+ require(CORE_PATH . 'cake' . DS . 'config' . DS . 'config.php');
+ $_this->write($config);
+ }
+ return $_this->Cake['version'];
+ }
+/**
+ * Checks $name for dot notation to create dynamic Configure::$var as an array when needed.
+ *
+ * @param mixed $name
+ * @return array
+ * @access private
+ */
+ function __configVarNames($name) {
+ if (is_string($name)) {
+ if (strpos($name, ".")) {
+ $name = explode(".", $name);
+ } else {
+ $name = array($name);
+ }
+ }
+ return $name;
+ }
+/**
+ * Sets the var modelPaths
+ *
+ * @param array $modelPaths
+ * @access private
+ */
+ function __buildModelPaths($modelPaths) {
+ $_this =& Configure::getInstance();
+ $_this->modelPaths[] = MODELS;
+ if (isset($modelPaths)) {
+ foreach ($modelPaths as $value) {
+ $_this->modelPaths[] = $value;
+ }
+ }
+ }
+/**
+ * Sets the var viewPaths
+ *
+ * @param array $viewPaths
+ * @access private
+ */
+ function __buildViewPaths($viewPaths) {
+ $_this =& Configure::getInstance();
+ $_this->viewPaths[] = VIEWS;
+ if (isset($viewPaths)) {
+ foreach ($viewPaths as $value) {
+ $_this->viewPaths[] = $value;
+ }
+ }
+ }
+/**
+ * Sets the var controllerPaths
+ *
+ * @param array $controllerPaths
+ * @access private
+ */
+ function __buildControllerPaths($controllerPaths) {
+ $_this =& Configure::getInstance();
+ $_this->controllerPaths[] = CONTROLLERS;
+ if (isset($controllerPaths)) {
+ foreach ($controllerPaths as $value) {
+ $_this->controllerPaths[] = $value;
+ }
+ }
+ }
+/**
+ * Sets the var helperPaths
+ *
+ * @param array $helperPaths
+ * @access private
+ */
+ function __buildHelperPaths($helperPaths) {
+ $_this =& Configure::getInstance();
+ $_this->helperPaths[] = HELPERS;
+ if (isset($helperPaths)) {
+ foreach ($helperPaths as $value) {
+ $_this->helperPaths[] = $value;
+ }
+ }
+ }
+/**
+ * Sets the var componentPaths
+ *
+ * @param array $componentPaths
+ * @access private
+ */
+ function __buildComponentPaths($componentPaths) {
+ $_this =& Configure::getInstance();
+ $_this->componentPaths[] = COMPONENTS;
+ if (isset($componentPaths)) {
+ foreach ($componentPaths as $value) {
+ $_this->componentPaths[] = $value;
+ }
+ }
+ }
+/**
+ * Loads the app/config/bootstrap.php
+ * If the alternative paths are set in this file
+ * they will be added to the paths vars
+ *
+ * @access private
+ */
+ function __loadBootstrap() {
+ $_this =& Configure::getInstance();
+ $_this->write('Session.checkAgent', true);
+ $modelPaths = null;
+ $viewPaths = null;
+ $controllerPaths = null;
+ $helperPaths = null;
+ $componentPaths = null;
+ require APP_PATH . 'config' . DS . 'bootstrap.php';
+ $_this->__buildModelPaths($modelPaths);
+ $_this->__buildViewPaths($viewPaths);
+ $_this->__buildControllerPaths($controllerPaths);
+ $_this->__buildHelperPaths($helperPaths);
+ $_this->__buildComponentPaths($componentPaths);
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/component.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/component.php
new file mode 100644
index 0000000..d604269
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/component.php
@@ -0,0 +1,139 @@
+<?php
+/* SVN FILE: $Id: component.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller
+ * @since CakePHP(tm) v TBD
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Component
+ *
+ * Used to create instances of applications components
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller
+ */
+class Component extends Object {
+/**
+ * Instance Controller
+ *
+ * @var object
+ * @access private
+ */
+ var $__controller = null;
+/**
+ * Constructor
+ */
+ function __construct() {
+ }
+/**
+ * Used to initialize the components for current controller
+ *
+ * @param object $controller
+ * @access public
+ */
+ function init(&$controller) {
+ $this->__controller =& $controller;
+
+ if ($this->__controller->components !== false) {
+ $loaded = array();
+ $this->__controller->components = array_merge(array('Session'), $this->__controller->components);
+ $loaded = $this->__loadComponents($loaded, $this->__controller->components);
+
+ foreach (array_keys($loaded)as $component) {
+ $tempComponent =& $loaded[$component];
+
+ if (isset($tempComponent->components) && is_array($tempComponent->components)) {
+ foreach ($tempComponent->components as $subComponent) {
+ $this->__controller->{$component}->{$subComponent} =& $loaded[$subComponent];
+ }
+ }
+ if (is_callable(array($tempComponent, 'initialize'))) {
+ $tempComponent->initialize($controller);
+ }
+ }
+ }
+ }
+
+/**
+ * Enter description here...
+ *
+ * @param array $loaded
+ * @param array $components
+ * @return loaded components
+ * @access private
+ */
+ function &__loadComponents(&$loaded, $components) {
+ foreach ($components as $component) {
+ $parts = preg_split('/\/|\./', $component);
+
+ if (count($parts) === 1) {
+ $plugin = $this->__controller->plugin;
+ } else {
+ $plugin = Inflector::underscore($parts['0']);
+ $component = $parts[count($parts) - 1];
+ }
+
+ $componentCn = $component . 'Component';
+
+ if (in_array($component, array_keys($loaded)) !== true) {
+
+ if (!class_exists($componentCn)) {
+
+ if (is_null($plugin) || !loadPluginComponent($plugin, $component)) {
+
+ if (!loadComponent($component)) {
+ $this->cakeError('missingComponentFile', array(array(
+ 'className' => $this->__controller->name,
+ 'component' => $component,
+ 'file' => Inflector::underscore($component) . '.php',
+ 'base' => $this->__controller->base)));
+ exit();
+ }
+ }
+
+ if (!class_exists($componentCn)) {
+ $this->cakeError('missingComponentClass', array(array(
+ 'className' => $this->__controller->name,
+ 'component' => $component,
+ 'file' => Inflector::underscore($component) . '.php',
+ 'base' => $this->__controller->base)));
+ exit();
+ }
+ }
+
+ if ($componentCn == 'SessionComponent') {
+ $param = strip_plugin($this->__controller->base, $this->__controller->plugin) . '/';
+ } else {
+ $param = null;
+ }
+ $this->__controller->{$component} =& new $componentCn($param);
+ $loaded[$component] =& $this->__controller->{$component};
+
+ if (isset($this->__controller->{$component}->components) && is_array($this->__controller->{$component}->components)) {
+ $loaded =& $this->__loadComponents($loaded, $this->__controller->{$component}->components);
+ }
+ }
+ }
+ return $loaded;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/acl.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/acl.php
new file mode 100644
index 0000000..1c2792a
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/acl.php
@@ -0,0 +1,196 @@
+<?php
+/* SVN FILE: $Id: acl.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Access Control List factory class.
+ *
+ * Permissions system.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Access Control List factory class.
+ *
+ * Looks for ACL implementation class in core config, and returns an instance of that class.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components
+ */
+class AclComponent extends Object {
+/**
+ * Instance of ACL_CLASSNAME set in app/config/core.php
+ *
+ * @var object
+ */
+ var $_instance = null;
+/**
+ * Enter description here...
+ *
+ * @var boolean
+ */
+ var $controller = true;
+/**
+ * Constructor.
+ *
+ * Will return an instance of the correct ACL class.
+ */
+ function __construct() {
+ $this->getACL();
+ }
+/**
+ * Static function used to gain an instance of the correct ACL class.
+ *
+ * @return object instance of ACL_CLASSNAME set in app/config/core.php
+ * @access public
+ */
+ function &getACL() {
+ if ($this->_instance == null) {
+ uses('controller' . DS . 'components' . DS . ACL_FILENAME);
+ $classname = ACL_CLASSNAME;
+ $this->_instance = new $classname;
+ }
+
+ if ($classname == 'DB_ACL') {
+ $this->Aro = new Aro();
+ $this->Aco = new Aco();
+ }
+ return $this->_instance;
+ }
+/**
+ * Empty class defintion, to be overridden in subclasses.
+ *
+ * @access public
+ */
+ function _initACL() {
+ }
+/**
+ * Pass-thru function for ACL check instance.
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action : default = *
+ * @return boolean
+ * @access public
+ */
+ function check($aro, $aco, $action = "*") {
+ return $this->_instance->check($aro, $aco, $action);
+ }
+/**
+ * Pass-thru function for ACL allow instance.
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action : default = *
+ * @return boolean
+ * @access public
+ */
+ function allow($aro, $aco, $action = "*") {
+ return $this->_instance->allow($aro, $aco, $action);
+ }
+/**
+ * Pass-thru function for ACL deny instance.
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action : default = *
+ * @return boolean
+ * @abstract public
+ */
+ function deny($aro, $aco, $action = "*") {
+ return $this->_instance->deny($aro, $aco, $action);
+ }
+/**
+ * Pass-thru function for ACL inherit instance.
+ *
+ * @return boolean
+ * @abstract public
+ */
+ function inherit($aro, $aco, $action = "*") {
+ return $this->_instance->inherit($aro, $aco, $action);
+ }
+/**
+ * Pass-thru function for ACL grant instance.
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action : default = *
+ * @return boolean
+ * @access public
+ */
+ function grant($aro, $aco, $action = "*") {
+ return $this->_instance->grant($aro, $aco, $action);
+ }
+/**
+ * Pass-thru function for ACL grant instance.
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action : default = *
+ * @return boolean
+ * @access public
+ */
+ function revoke($aro, $aco, $action = "*") {
+ return $this->_instance->revoke($aro, $aco, $action);
+ }
+/**
+ * Sets the current ARO instance to object from getAro
+ *
+ * @param string $id
+ * @return boolean
+ * @access public
+ */
+ function setAro($id) {
+ return $this->Aro = $this->_instance->getAro($id);
+ }
+/**
+* Sets the current ACO instance to object from getAco
+ *
+ * @param string $id
+ * @return boolean
+ * @access public
+ */
+ function setAco($id) {
+ return $this->Aco = $this->_instance->getAco($id);
+ }
+/**
+ * Pass-thru function for ACL getAro instance
+ * that gets an ARO object from the given id or alias
+ *
+ * @param string $id
+ * @return object Aro
+ * @access public
+ */
+ function getAro($id) {
+ return $this->_instance->getAro($id);
+ }
+/**
+ * Pass-thru function for ACL getAco instance.
+ * that gets an ACO object from the given id or alias
+ *
+ * @param string $id
+ * @return object Aco
+ * @access public
+ */
+ function getAco($id) {
+ return $this->_instance->getAco($id);
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/acl_base.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/acl_base.php
new file mode 100644
index 0000000..82e162a
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/acl_base.php
@@ -0,0 +1,63 @@
+<?php
+/* SVN FILE: $Id: acl_base.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Access Control List abstract class.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components
+ * @since CakePHP(tm) v 0.10.0.1232
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Access Control List abstract class. Not to be instantiated.
+ * Subclasses of this class are used by AclComponent to perform ACL checks in Cake.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components
+ * @abstract
+ */
+class AclBase extends Object {
+/**
+ * This class should never be instantiated, just subclassed.
+ *
+ * No instantiations or constructor calls (even statically)
+ *
+ * @return AclBase
+ * @abstract
+ */
+ function __construct() {
+ if (strcasecmp(get_class($this), "AclBase") == 0 || !is_subclass_of($this, "AclBase")) {
+ trigger_error("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration.", E_USER_ERROR);
+ return null;
+ }
+ }
+/**
+ * Empty method to be overridden in subclasses
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action
+ * @abstract
+ */
+ function check($aro, $aco, $action = "*") {
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/db_acl.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/db_acl.php
new file mode 100644
index 0000000..f575a2a
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/db_acl.php
@@ -0,0 +1,310 @@
+<?php
+/* SVN FILE: $Id: db_acl.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * This is core configuration file.
+ *
+ * Use it to configure core behaviour ofCake.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.componenets.dbacl
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+if (!defined('ACL_DATABASE')) {
+ define('ACL_DATABASE', 'default');
+}
+uses('controller' . DS . 'components' . DS . 'acl_base');
+uses('controller' . DS . 'components' . DS . 'dbacl' . DS . 'models' . DS . 'aclnode');
+uses('controller' . DS . 'components' . DS . 'dbacl' . DS . 'models' . DS . 'aco');
+uses('controller' . DS . 'components' . DS . 'dbacl' . DS . 'models' . DS . 'acoaction');
+uses('controller' . DS . 'components' . DS . 'dbacl' . DS . 'models' . DS . 'aro');
+uses('controller' . DS . 'components' . DS . 'dbacl' . DS . 'models' . DS . 'aros_aco');
+/**
+ * In this file you can extend the AclBase.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components.dbacl
+ */
+class DB_ACL extends AclBase {
+/**
+ * Enter description here...
+ *
+ */
+ function __construct() {
+ }
+/**
+ * Enter description here...
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action
+ * @return boolean
+ * @access public
+ */
+ function check($aro, $aco, $action = "*") {
+ $Perms = new ArosAco();
+ $Aro = new Aro();
+ $Aco = new Aco();
+
+ if ($aro == null || $aco == null) {
+ return false;
+ }
+
+ $permKeys = $this->_getAcoKeys($Perms->loadInfo());
+ $aroPath = $Aro->getPath($aro);
+ $tmpAcoPath = $Aco->getPath($aco);
+
+ if ($tmpAcoPath === null) {
+ return false;
+ }
+ $tmpAcoPath = array_reverse($tmpAcoPath);
+ $acoPath = array();
+
+ if ($action != '*' && !in_array('_' . $action, $permKeys)) {
+ trigger_error('ACO permissions key "' . $action . '" does not exist in DB_ACL::check()', E_USER_NOTICE);
+ return false;
+ }
+
+ foreach ($tmpAcoPath as $a) {
+ $acoPath[] = $a['Aco']['id'];
+ }
+
+ for ($i = count($aroPath) - 1; $i >= 0; $i--) {
+ $perms = $Perms->findAll(array('ArosAco.aro_id' => $aroPath[$i]['Aro']['id'],
+ 'ArosAco.aco_id' => $acoPath), null,
+ 'Aco.lft desc');
+ if ($perms == null || count($perms) == 0) {
+ continue;
+ } else {
+ foreach ($perms as $perm) {
+ if ($action == '*') {
+ // ARO must be cleared for ALL ACO actions
+ foreach ($permKeys as $key) {
+ if (isset($perm['ArosAco'])) {
+ if ($perm['ArosAco'][$key] != 1) {
+ return false;
+ }
+ }
+ }
+ return true;
+
+ } else {
+ switch($perm['ArosAco']['_' . $action]) {
+ case -1:
+ return false;
+ case 0:
+ continue;
+ break;
+ case 1:
+ return true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+/**
+ * Enter description here...
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action
+ * @param integer $value
+ * @return boolean
+ * @access public
+ */
+ function allow($aro, $aco, $action = "*", $value = 1) {
+ $Perms = new ArosAco();
+ $perms = $this->getAclLink($aro, $aco);
+ $permKeys = $this->_getAcoKeys($Perms->loadInfo());
+ $save = array();
+
+ if ($perms == false) {
+ trigger_error('DB_ACL::allow() - Invalid node', E_USER_WARNING);
+ return false;
+ }
+
+ if (isset($perms[0])) {
+ $save = $perms[0]['ArosAco'];
+ }
+
+ if ($action == "*") {
+ $permKeys = $this->_getAcoKeys($Perms->loadInfo());
+
+ foreach ($permKeys as $key) {
+ $save[$key] = $value;
+ }
+ } else {
+ if (in_array('_' . $action, $permKeys)) {
+ $save['_' . $action] = $value;
+ } else {
+ trigger_error('DB_ACL::allow() - Invalid ACO action', E_USER_WARNING);
+ return false;
+ }
+ }
+
+ $save['aro_id'] = $perms['aro'];
+ $save['aco_id'] = $perms['aco'];
+
+ if ($perms['link'] != null && count($perms['link']) > 0) {
+ $save['id'] = $perms['link'][0]['ArosAco']['id'];
+ }
+ return $Perms->save(array('ArosAco' => $save));
+ }
+/**
+ * Enter description here...
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action
+ * @return boolean
+ * @access public
+ */
+ function deny($aro, $aco, $action = "*") {
+ return $this->allow($aro, $aco, $action, -1);
+ }
+/**
+ * Enter description here...
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action
+ * @return boolean
+ * @access public
+ */
+ function inherit($aro, $aco, $action = "*") {
+ return $this->allow($aro, $aco, $action, 0);
+ }
+/**
+ * Enter description here...
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action
+ * @return boolean
+ * @access public
+ */
+ function grant($aro, $aco, $action = "*") {
+ return $this->allow($aro, $aco, $action);
+ }
+/**
+ * Enter description here...
+ *
+ * @param string $aro
+ * @param string $aco
+ * @param string $action
+ * @return boolean
+ * @access public
+ */
+ function revoke($aro, $aco, $action = "*") {
+ return $this->deny($aro, $aco, $action);
+ }
+/**
+ * Get an ARO object from the given id or alias
+ *
+ * @param mixed $id
+ * @return object Aro
+ * @access public
+ */
+ function getAro($id = null) {
+ return $this->__getObject($id, 'Aro');
+ }
+/**
+ * Get an ACO object from the given id or alias
+ *
+ * @param mixed $id
+ * @return object Aco
+ * @access public
+ */
+ function getAco($id = null) {
+ return $this->__getObject($id, 'Aco');
+ }
+ function __getObject($id = null, $object) {
+ if ($id == null) {
+ trigger_error('Null id provided in DB_ACL::get' . $object, E_USER_WARNING);
+ return null;
+ }
+
+ $obj = new $object;
+
+ if (is_numeric($id)) {
+ $key = 'foreign_key';
+ if ($object == 'Aco') {
+ $key = 'object_id';
+ }
+
+ $conditions = array($object . '.' . $key => $id);
+ } else {
+ $conditions = array($object . '.alias' => $id);
+ }
+
+ $tmp = $obj->find($conditions);
+ $obj->id = $tmp[$object]['id'];
+ return $obj;
+ }
+/**
+ * Get an array of access-control links between the given Aro and Aco
+ *
+ * @param mixed $aro
+ * @param mixed $aco
+ * @return array
+ * @access public
+ */
+ function getAclLink($aro, $aco) {
+ $Aro = new Aro();
+ $Aco = new Aco();
+ $Link = new ArosAco();
+
+ $obj = array();
+ $obj['Aro'] = $Aro->find($Aro->_resolveID($aro));
+ $obj['Aco'] = $Aco->find($Aco->_resolveID($aco));
+ $obj['Aro'] = $obj['Aro']['Aro'];
+ $obj['Aco'] = $obj['Aco']['Aco'];
+
+ if ($obj['Aro'] == null || count($obj['Aro']) == 0 || $obj['Aco'] == null || count($obj['Aco']) == 0) {
+ return false;
+ }
+ return array('aro' => $obj['Aro']['id'],
+ 'aco' => $obj['Aco']['id'],
+ 'link' => $Link->findAll(array(
+ 'ArosAco.aro_id' => $obj['Aro']['id'],
+ 'ArosAco.aco_id' => $obj['Aco']['id'])));
+ }
+/**
+ * Enter description here...
+ *
+ * @param object $keys
+ * @return array
+ * @access protected
+ */
+ function _getAcoKeys($keys) {
+ $newKeys = array();
+ $keys = $keys->value;
+
+ foreach ($keys as $key) {
+ if ($key['name'] != 'id' && $key['name'] != 'aro_id' && $key['name'] != 'aco_id') {
+ $newKeys[] = $key['name'];
+ }
+ }
+ return $newKeys;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aclnode.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aclnode.php
new file mode 100644
index 0000000..6ea9753
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aclnode.php
@@ -0,0 +1,309 @@
+<?php
+/* SVN FILE: $Id: aclnode.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components.dbacl.models
+ * @since CakePHP(tm) v 0.10.0.1232
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Load AppModel class
+ */
+loadModel();
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components.dbacl.models
+ *
+ */
+class AclNode extends AppModel {
+/**
+ * Database configuration to use
+ *
+ * @var string
+ */
+ var $useDbConfig = ACL_DATABASE;
+/**
+ * Cache Queries
+ *
+ * @var boolean
+ */
+ var $cacheQueries = false;
+/**
+ * Creates a new ARO/ACO node
+ *
+ * @param int $linkId
+ * @param mixed $parentId
+ * @param string $alias
+ * @return boolean True on success, false on fail
+ * @access public
+ */
+ function create($linkId = 0, $parentId = null, $alias = '') {
+ parent::create();
+ if (strtolower(get_class($this)) == "aclnode") {
+ trigger_error("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration.", E_USER_ERROR);
+ return null;
+ }
+ extract ($this->__dataVars());
+
+ if ($parentId == null || $parentId === 0) {
+ $parent = $this->find(null, 'MAX(rght) as rght', null, -1);
+ $parent['lft'] = $parent[0]['rght'];
+
+ if ($parent[0]['rght'] == null || !$parent[0]['rght']) {
+ $parent['lft'] = 0;
+ }
+ } else {
+ $parent = $this->find($this->_resolveID($parentId), null, null, 0);
+ if ($parent == null || count($parent) == 0) {
+ trigger_error("Null parent in {$class}::create()", E_USER_WARNING);
+ return null;
+ }
+ $parent = $parent[$class];
+ $this->_syncTable(1, $parent['lft'], $parent['lft']);
+ }
+ $return = $this->save(array($class => array($secondary_id => $linkId,
+ 'alias' => $alias,
+ 'lft' => $parent['lft'] + 1,
+ 'rght' => $parent['lft'] + 2)));
+ $this->id = $this->getLastInsertID();
+ return $return;
+ }
+/**
+ * Get the ARO/ACO ID with the given alias
+ *
+ * @param mixed $alias The alias of an ARO/ACO node
+ * @return mixed The ID of an ARO/ACO node, or false if not found.
+ * @access public
+ */
+ function id($alias) {
+ extract($this->__dataVars());
+ return $this->find(array($this->name . '.alias' => $alias), array($secondary_id), null, -1);
+ }
+/**
+ * Deletes the ARO/ACO node with the given ID
+ *
+ * @param mixed $id The id or alias of an ARO/ACO node
+ * @return boolean True on success, false on fail
+ * @access public
+ */
+ function delete($id) {
+ extract ($this->__dataVars());
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+
+ $result = $this->find($this->_resolveID($id));
+ $object = $result[$class];
+ if ($object == null || count($object) == 0) {
+ return false;
+ }
+
+ $children = $this->findAll(array("{$class}.rght" => "< {$result[$class]['rght']}", "{$class}.lft" => "> {$result[$class]['lft']}"), 'id', null, null, null, -1);
+ $idList = Set::extract($children, '{n}.' . $class . '.id');
+ $idList[] = $result[$class]['id'];
+
+ $this->ArosAco->query('DELETE FROM ' . $db->fullTableName($this->ArosAco) . " WHERE {$class}_id in (" . implode(', ', $idList) . ')');
+
+ $table = $db->fullTableName($this);
+ $this->query("DELETE FROM {$table} WHERE {$table}.lft >= {$result[$class]['lft']} AND {$table}.rght <= {$result[$class]['rght']}");
+
+ $shift = 1 + $result[$class]['rght'] - $result[$class]['lft'];
+ $this->query('UPDATE ' . $table . ' SET ' . $db->name('rght') . ' = ' . $db->name('rght') . ' - ' . $shift . ' WHERE ' . $db->name('rght') . ' > ' . $result[$class]['rght']);
+ $this->query('UPDATE ' . $table . ' SET ' . $db->name('lft') . ' = ' . $db->name('lft') . ' - ' . $shift . ' WHERE ' . $db->name('lft') . ' > ' . $result[$class]['lft']);
+ return true;
+ }
+/**
+ * Sets the parent of the given node
+ *
+ * @param mixed $parentId
+ * @param mixed $id
+ * @return boolean True on success, false on failure
+ * @access public
+ */
+ function setParent($parentId = null, $id = null) {
+ if (strtolower(get_class($this)) == "aclnode") {
+ trigger_error("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration.", E_USER_ERROR);
+ return null;
+ }
+ extract ($this->__dataVars());
+
+ if ($id == null && $this->id == false) {
+ return false;
+ } elseif ($id == null) {
+ $id = $this->id;
+ }
+ $object = $this->find($this->_resolveID($id), null, null, 0);
+
+ if ($object == null || count($object) == 0) {
+ return false;
+ }
+ $object = $object[$class];
+ $parent = $this->getParent($id);
+
+ if (($parent == null && $parentId == null) || ($parentId == $parent[$class][$secondary_id] && $parentId != null) || ($parentId == $parent[$class]['alias'] && $parentId != null)) {
+ return false;
+ }
+
+ if ($parentId == null) {
+ $newParent = $this->find(null, 'MAX(rght) as lft', null, -1);
+ $newParent = $newParent[0];
+ $newParent['rght'] = $newParent['lft'];
+ } else {
+ $newParent = $this->find($this->_resolveID($parentId), null, null, 0);
+ $newParent = $newParent[$class];
+ }
+
+ if ($parentId != null && $newParent['lft'] <= $object['lft'] && $newParent['rght'] >= $object['rght']) {
+ return false;
+ }
+ $this->_syncTable(0, $object['lft'], $object['lft']);
+
+ if ($object['lft'] < $newParent['lft']) {
+ $newParent['lft'] = $newParent['lft'] - 2;
+ $newParent['rght'] = $newParent['rght'] - 2;
+ }
+
+ if ($parentId != null) {
+ $this->_syncTable(1, $newParent['lft'], $newParent['lft']);
+ }
+ $object['lft'] = $newParent['lft'] + 1;
+ $object['rght'] = $newParent['lft'] + 2;
+ $this->save(array($class => $object));
+
+ if ($newParent['lft'] == 0) {
+ $this->_syncTable(2, $newParent['lft'], $newParent['lft']);
+ }
+ return true;
+ }
+/**
+ * Get the parent node of the given Aro or Aco
+ *
+ * @param moxed $id
+ * @return array
+ * @access public
+ */
+ function getParent($id) {
+ $path = $this->getPath($id);
+ if ($path == null || count($path) < 2) {
+ return null;
+ } else {
+ return $path[count($path) - 2];
+ }
+ }
+/**
+ * Gets the path to the given Aro or Aco
+ *
+ * @param mixed $id
+ * @return array
+ * @access public
+ */
+ function getPath($id) {
+ if (strtolower(get_class($this)) == "aclnode") {
+ trigger_error("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration.", E_USER_ERROR);
+ return null;
+ }
+ extract ($this->__dataVars());
+ $item = $this->find($this->_resolveID($id), null, null, 0);
+
+ if ($item == null || count($item) == 0) {
+ return null;
+ }
+ return $this->findAll(array($class . '.lft' => '<= ' . $item[$class]['lft'], $class . '.rght' => '>= ' . $item[$class]['rght']), null, array($class . '.lft' => 'ASC'), null, null, 0);
+ }
+/**
+ * Get the child nodes of the given Aro or Aco
+ *
+ * @param mixed $id
+ * @return array
+ * @access public
+ */
+ function getChildren($id) {
+ if (strtolower(get_class($this)) == "aclnode") {
+ trigger_error("[acl_base] The AclBase class constructor has been called, or the class was instantiated. This class must remain abstract. Please refer to the Cake docs for ACL configuration.", E_USER_ERROR);
+ return null;
+ }
+
+ extract ($this->__dataVars());
+ $item = $this->find($this->_resolveID($id), null, null, 0);
+ return $this->findAll(array($class . '.lft' => '> ' . $item[$class]['lft'], $class . '.rght' => '< ' . $item[$class]['rght']), null, null, null, null, null, 0);
+ }
+/**
+ * Gets a conditions array to find an Aro or Aco, based on the given id or alias
+ *
+ * @param mixed $id
+ * @return array Conditions array for a find/findAll call
+ * @access public
+ */
+ function _resolveID($id) {
+ extract($this->__dataVars());
+ $key = (is_numeric($id) ? $secondary_id : 'alias');
+ return array($this->name . '.' . $key => $id);
+ }
+/**
+ * Shifts the left and right values of the aro/aco tables
+ * when a node is added or removed
+ *
+ * @param unknown_type $dir
+ * @param unknown_type $lft
+ * @param unknown_type $rght
+ * @access protected
+ */
+ function _syncTable($dir, $lft, $rght) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+
+ if ($dir == 2) {
+ $shift = 1;
+ $dir = '+';
+ } else {
+ $shift = 2;
+
+ if ($dir > 0) {
+ $dir = '+';
+ } else {
+ $dir = '-';
+ }
+ }
+ $db->query('UPDATE ' . $db->fullTableName($this) . ' SET ' . $db->name('rght') . ' = ' . $db->name('rght') . ' ' . $dir . ' ' . $shift . ' WHERE ' . $db->name('rght') . ' > ' . $rght);
+ $db->query('UPDATE ' . $db->fullTableName($this) . ' SET ' . $db->name('lft') . ' = ' . $db->name('lft') . ' ' . $dir . ' ' . $shift . ' WHERE ' . $db->name('lft') . ' > ' . $lft);
+ }
+/**
+ * Infers data based on the currently-intantiated subclass.
+ *
+ * @return array
+ * @access private
+ */
+ function __dataVars() {
+ $vars = array();
+ $class = strtolower(get_class($this));
+ if ($class == 'aro') {
+ $vars['secondary_id'] = 'foreign_key';
+ } else {
+ $vars['secondary_id'] = 'object_id';
+ }
+ $vars['class'] = ucwords($class);
+ return $vars;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aco.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aco.php
new file mode 100644
index 0000000..988f8b1
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aco.php
@@ -0,0 +1,52 @@
+<?php
+/* SVN FILE: $Id: aco.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components.dbacl.models
+ * @since CakePHP(tm) v 0.10.0.1232
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components.dbacl.models
+ *
+ */
+class Aco extends AclNode{
+/**
+ * Model name
+ *
+ * @var string
+ */
+ var $name = 'Aco';
+/**
+ * Has many association
+ *
+ * @var array
+ */
+ var $hasMany = array('ArosAco');
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/acoaction.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/acoaction.php
new file mode 100644
index 0000000..5e33b80
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/acoaction.php
@@ -0,0 +1,56 @@
+<?php
+/* SVN FILE: $Id: acoaction.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components.dbacl.models
+ * @since CakePHP(tm) v 0.10.0.1232
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Short description.
+ */
+loadModel();
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components.dbacl.models
+ *
+ */
+class AcoAction extends AppModel {
+/**
+ * Model name
+ *
+ * @var string
+ */
+ var $name = 'AcoAction';
+/**
+ * Belongs to association
+ *
+ * @var string
+ */
+ var $belongsTo = 'Aco';
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aro.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aro.php
new file mode 100644
index 0000000..1db67eb
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aro.php
@@ -0,0 +1,52 @@
+<?php
+/* SVN FILE: $Id: aro.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components.dbacl.models
+ * @since CakePHP(tm) v 0.10.0.1232
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components.dbacl.models
+ *
+ */
+class Aro extends AclNode {
+/**
+ * Model name
+ *
+ * @var string
+ */
+ var $name = 'Aro';
+/**
+ * Has many association
+ *
+ * @var array
+ */
+ var $hasMany = array('ArosAco');
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aros_aco.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aros_aco.php
new file mode 100644
index 0000000..dade2cc
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/dbacl/models/aros_aco.php
@@ -0,0 +1,63 @@
+<?php
+/* SVN FILE: $Id: aros_aco.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components.dbacl.models
+ * @since CakePHP(tm) v 0.10.0.1232
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components.dbacl.models
+ */
+class ArosAco extends AppModel {
+/**
+ * Cache Queries
+ *
+ * @var boolean
+ */
+ var $cacheQueries = false;
+/**
+ * Model name
+ *
+ * @var string
+ */
+ var $name = 'ArosAco';
+/**
+ * Table this model uses
+ *
+ * @var string
+ */
+ var $useTable = 'aros_acos';
+/**
+ * Belongs to association
+ *
+ * @var array
+ */
+ var $belongsTo = array('Aro', 'Aco');
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/iniacl/ini_acl.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/iniacl/ini_acl.php
new file mode 100644
index 0000000..e99de6f
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/iniacl/ini_acl.php
@@ -0,0 +1,180 @@
+<?php
+/* SVN FILE: $Id: ini_acl.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * This is core configuration file.
+ *
+ * Use it to configure core behaviour ofCake.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.componenets.iniacl
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * load AclBase
+ */
+uses('controller/components/acl_base');
+/**
+ * In this file you can extend the AclBase.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.componenets.iniacl
+ */
+class INI_ACL extends AclBase {
+/**
+ * Array with configuration, parsed from ini file
+ *
+ * @var array
+ */
+ var $config = null;
+/**
+ * Constructor
+ *
+ */
+ function __construct() {
+ }
+
+/**
+ * Main ACL check function. Checks to see if the ARO (access request object) has access to the ACO (access control object).
+ * Looks at the acl.ini.php file for permissions (see instructions in/config/acl.ini.php).
+ *
+ * @param string $aro
+ * @param string $aco
+ * @return boolean
+ * @access public
+ */
+ function check($aro, $aco, $acoAction = null) {
+ if ($this->config == null) {
+ $this->config = $this->readConfigFile(CONFIGS . 'acl.ini.php');
+ }
+ $aclConfig = $this->config;
+
+ //First, if the user is specifically denied, then DENY
+ if (isset($aclConfig[$aro]['deny'])) {
+ $userDenies = $this->arrayTrim(explode(",", $aclConfig[$aro]['deny']));
+
+ if (array_search($aco, $userDenies)) {
+ //echo "User Denied!";
+ return false;
+ }
+ }
+
+ //Second, if the user is specifically allowed, then ALLOW
+ if (isset($aclConfig[$aro]['allow'])) {
+ $userAllows = $this->arrayTrim(explode(",", $aclConfig[$aro]['allow']));
+
+ if (array_search($aco, $userAllows)) {
+ //echo "User Allowed!";
+ return true;
+ }
+ }
+
+ //Check group permissions
+ if (isset($aclConfig[$aro]['groups'])) {
+ $userGroups = $this->arrayTrim(explode(",", $aclConfig[$aro]['groups']));
+
+ foreach ($userGroups as $group) {
+ //If such a group exists,
+ if (array_key_exists($group, $aclConfig)) {
+ //If the group is specifically denied, then DENY
+ if (isset($aclConfig[$group]['deny'])) {
+ $groupDenies=$this->arrayTrim(explode(",", $aclConfig[$group]['deny']));
+
+ if (array_search($aco, $groupDenies)) {
+ //echo("Group Denied!");
+ return false;
+ }
+ }
+
+ //If the group is specifically allowed, then ALLOW
+ if (isset($aclConfig[$group]['allow'])) {
+ $groupAllows = $this->arrayTrim(explode(",", $aclConfig[$group]['allow']));
+
+ if (array_search($aco, $groupAllows)) {
+ //echo("Group Allowed!");
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ //Default, DENY
+ //echo("DEFAULT: DENY.");
+ return false;
+ }
+
+/**
+ * Parses an INI file and returns an array that reflects the INI file's section structure. Double-quote friendly.
+ *
+ * @param string $fileName
+ * @return array
+ */
+ function readConfigFile($fileName) {
+ $fileLineArray = file($fileName);
+
+ foreach ($fileLineArray as $fileLine) {
+ $dataLine = trim($fileLine);
+ $firstChar = substr($dataLine, 0, 1);
+
+ if ($firstChar != ';' && $dataLine != '') {
+ if ($firstChar == '[' && substr($dataLine, -1, 1) == ']') {
+ $sectionName = preg_replace('/[\[\]]/', '', $dataLine);
+ } else {
+ $delimiter = strpos($dataLine, '=');
+
+ if ($delimiter > 0) {
+ $key = strtolower(trim(substr($dataLine, 0, $delimiter)));
+ $value = trim(substr($dataLine, $delimiter + 1));
+
+ if (substr($value, 0, 1) == '"' && substr($value, -1) == '"') {
+ $value = substr($value, 1, -1);
+ }
+
+ $iniSetting[$sectionName][$key]=stripcslashes($value);
+ } else {
+ if (!isset($sectionName)) {
+ $sectionName = '';
+ }
+
+ $iniSetting[$sectionName][strtolower(trim($dataLine))]='';
+ }
+ }
+ } else {
+ }
+ }
+
+ return $iniSetting;
+ }
+/**
+ * Removes trailing spaces on all array elements (to prepare for searching)
+ *
+ * @param array $array Array to trim
+ * @return array Trimmed array
+ * @access public
+ */
+ function arrayTrim($array) {
+ foreach ($array as $key => $value) {
+ $array[$key] = trim($value);
+ }
+ array_unshift($array, "");
+ return $array;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/request_handler.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/request_handler.php
new file mode 100644
index 0000000..c307799
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/request_handler.php
@@ -0,0 +1,412 @@
+<?php
+/* SVN FILE: $Id: request_handler.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Request object for handling alternative HTTP requests
+ *
+ * Alternative HTTP requests can come from wireless units like mobile phones, palmtop computers, and the like.
+ * These units have no use for Ajax requests, and this Component can tell how Cake should respond to the different
+ * needs of a handheld computer and a desktop machine.
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components
+ * @since CakePHP(tm) v 0.10.4.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+if (!defined('REQUEST_MOBILE_UA')) {
+ define('REQUEST_MOBILE_UA',
+ '(AvantGo|BlackBerry|DoCoMo|NetFront|Nokia|PalmOS|PalmSource|portalmmm|Plucker|ReqwirelessWeb|SonyEricsson|Symbian|UP\.Browser|Windows CE|Xiino)');
+}
+/**
+ * Request object for handling alternative HTTP requests
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components
+ *
+ */
+class RequestHandlerComponent extends Object{
+/**
+ * Enter description here...
+ *
+ * @var object
+ * @access public
+ */
+ var $controller = true;
+/**
+ * The layout that will be switched to for Ajax requests
+ *
+ * @var string
+ * @access public
+ * @see RequestHandler::setAjax()
+ */
+ var $ajaxLayout = 'ajax';
+/**
+ * Determines whether or not callbacks will be fired on this component
+ *
+ * @var boolean
+ * @access public
+ */
+ var $disableStartup = false;
+/**
+ * Friendly content-type mappings used to set response types and determine
+ * request types. Can be modified with RequestHandler::setContent()
+ *
+ * @var array
+ * @access private
+ * @see RequestHandlerComponent::setContent
+ */
+ var $__requestContent = array(
+ 'js' => 'text/javascript',
+ 'css' => 'text/css',
+ 'html' => 'text/html',
+ 'form' => 'application/x-www-form-urlencoded',
+ 'file' => 'multipart/form-data',
+ 'xhtml' => array('application/xhtml+xml', 'application/xhtml', 'text/xhtml'),
+ 'xml' => array('application/xml', 'text/xml'),
+ 'rss' => 'application/rss+xml',
+ 'atom' => 'application/atom+xml'
+ );
+/**
+ * Content-types accepted by the client. If extension parsing is enabled in the
+ * Router, and an extension is detected, the corresponding content-type will be
+ * used as the overriding primary content-type accepted.
+ *
+ * @var array
+ * @access private
+ */
+ var $__acceptTypes = array();
+/**
+ * Constructor. Parses the accepted content types accepted by the client using
+ * HTTP_ACCEPT
+ *
+ * @access public
+ * @return void
+ */
+ function __construct() {
+ $this->__acceptTypes = explode(',', env('HTTP_ACCEPT'));
+
+ foreach ($this->__acceptTypes as $i => $type) {
+ if (strpos($type, ';')) {
+ $type = explode(';', $type);
+ $this->__acceptTypes[$i] = $type[0];
+ }
+ }
+ parent::__construct();
+ }
+/**
+ * Startup
+ *
+ * @param object A reference to the controller
+ * @return null
+ * @access public
+ */
+ function startup(&$controller) {
+ if ($this->disableStartup) {
+ return;
+ }
+ $this->setAjax($controller);
+ }
+/**
+ * Sets a controller's layout based on whether or not the current call is Ajax
+ *
+ * Add UTF-8 header for IE6 on XPsp2 bug if RequestHandlerComponent::isAjax()
+ *
+ * @param object The controller object
+ * @return null
+ * @access public
+ */
+ function setAjax(&$controller) {
+ if ($this->isAjax()) {
+ $controller->layout = $this->ajaxLayout;
+ // Add UTF-8 header for IE6 on XPsp2 bug
+ header ('Content-Type: text/html; charset=UTF-8');
+ }
+ }
+/**
+ * Returns true if the current call is from Ajax, false otherwise
+ *
+ * @return bool True if call is Ajax
+ * @access public
+ */
+ function isAjax() {
+ if (env('HTTP_X_REQUESTED_WITH') != null) {
+ return env('HTTP_X_REQUESTED_WITH') == "XMLHttpRequest";
+ } else {
+ return false;
+ }
+ }
+/**
+ * Returns true if the current call accepts an XML response, false otherwise
+ *
+ * @return bool True if client accepts an XML response
+ * @access public
+ */
+ function isXml() {
+ return $this->accepts('xml');
+ }
+/**
+ * Returns true if the current call accepts an RSS response, false otherwise
+ *
+ * @return bool True if client accepts an RSS response
+ * @access public
+ */
+ function isRss() {
+ return $this->accepts('rss');
+ }
+/**
+ * Returns true if the current call accepts an RSS response, false otherwise
+ *
+ * @return bool True if client accepts an RSS response
+ * @access public
+ */
+ function isAtom() {
+ return $this->accepts('atom');
+ }
+/**
+ * Returns true if the current call a POST request
+ *
+ * @return bool True if call is a POST
+ * @access public
+ */
+ function isPost() {
+ return (strtolower(env('REQUEST_METHOD')) == 'post');
+ }
+/**
+ * Returns true if the current call a PUT request
+ *
+ * @return bool True if call is a PUT
+ * @access public
+ */
+ function isPut() {
+ return (strtolower(env('REQUEST_METHOD')) == 'put');
+ }
+/**
+ * Returns true if the current call a GET request
+ *
+ * @return bool True if call is a GET
+ * @access public
+ */
+ function isGet() {
+ return (strtolower(env('REQUEST_METHOD')) == 'get');
+ }
+/**
+ * Returns true if the current call a DELETE request
+ *
+ * @return bool True if call is a DELETE
+ * @access public
+ */
+ function isDelete() {
+ return (strtolower(env('REQUEST_METHOD')) == 'delete');
+ }
+/**
+ * Gets Prototype version if call is Ajax, otherwise empty string.
+ * The Prototype library sets a special "Prototype version" HTTP header.
+ *
+ * @return string Prototype version of component making Ajax call
+ * @access public
+ */
+ function getAjaxVersion() {
+ if (env('HTTP_X_PROTOTYPE_VERSION') != null) {
+ return env('HTTP_X_PROTOTYPE_VERSION');
+ }
+ return false;
+ }
+/**
+ * Adds/sets the Content-type(s) for the given name
+ *
+ * @param string $name The name of the Content-type, i.e. "html", "xml", "css"
+ * @param mixed $type The Content-type or array of Content-types assigned to the name
+ * @return void
+ * @access public
+ */
+ function setContent($name, $type) {
+ $this->__requestContent[$name] = $type;
+ }
+/**
+ * Gets the server name from which this request was referred
+ *
+ * @return string Server address
+ * @access public
+ */
+ function getReferrer() {
+ if (env('HTTP_HOST') != null) {
+ $sess_host = env('HTTP_HOST');
+ }
+
+ if (env('HTTP_X_FORWARDED_HOST') != null) {
+ $sess_host = env('HTTP_X_FORWARDED_HOST');
+ }
+ return trim(preg_replace('/:.*/', '', $sess_host));
+ }
+/**
+ * Gets remote client IP
+ *
+ * @return string Client IP address
+ * @access public
+ */
+ function getClientIP() {
+ if (env('HTTP_X_FORWARDED_FOR') != null) {
+ $ipaddr = preg_replace('/,.*/', '', env('HTTP_X_FORWARDED_FOR'));
+ } else {
+ if (env('HTTP_CLIENT_IP') != null) {
+ $ipaddr = env('HTTP_CLIENT_IP');
+ } else {
+ $ipaddr = env('REMOTE_ADDR');
+ }
+ }
+
+ if (env('HTTP_CLIENTADDRESS') != null) {
+ $tmpipaddr = env('HTTP_CLIENTADDRESS');
+
+ if (!empty($tmpipaddr)) {
+ $ipaddr = preg_replace('/,.*/', '', $tmpipaddr);
+ }
+ }
+ return trim($ipaddr);
+ }
+/**
+ * Returns true if user agent string matches a mobile web browser
+ *
+ * @return bool True if user agent is a mobile web browser
+ * @access public
+ */
+ function isMobile() {
+ return (preg_match('/' . REQUEST_MOBILE_UA . '/i', env('HTTP_USER_AGENT')) > 0);
+ }
+/**
+ * Strips extra whitespace from output
+ *
+ * @param string $str
+ * @return string
+ * @access public
+ */
+ function stripWhitespace($str) {
+ $r = preg_replace('/[\n\r\t]+/', '', $str);
+ return preg_replace('/\s{2,}/', ' ', $r);
+ }
+/**
+ * Strips image tags from output
+ *
+ * @param string $str
+ * @return string
+ * @access public
+ */
+ function stripImages($str) {
+ $str = preg_replace('/(<a[^>]*>)(<img[^>]+alt=")([^"]*)("[^>]*>)(<\/a>)/i', '$1$3$5<br />', $str);
+ $str = preg_replace('/(<img[^>]+alt=")([^"]*)("[^>]*>)/i', '$2<br />', $str);
+ $str = preg_replace('/<img[^>]*>/i', '', $str);
+ return $str;
+ }
+/**
+ * Strips scripts and stylesheets from output
+ *
+ * @param string $str
+ * @return string
+ * @access public
+ */
+ function stripScripts($str) {
+ return preg_replace('/(<link[^>]+rel="[^"]*stylesheet"[^>]*>|<img[^>]*>|style="[^"]*")|<script[^>]*>.*?<\/script>|<style[^>]*>.*?<\/style>|<!--.*?-->/i', '', $str);
+ }
+/**
+ * Strips extra whitespace, images, scripts and stylesheets from output
+ *
+ * @param string $str
+ * @return string
+ * @access public
+ */
+ function stripAll($str) {
+ $str = $this->stripWhitespace($str);
+ $str = $this->stripImages($str);
+ $str = $this->stripScripts($str);
+ return $str;
+ }
+/**
+ * Strips the specified tags from output
+ *
+ * @return string
+ * @access public
+ */
+ function stripTags() {
+ $params = params(func_get_args());
+ $str = $params[0];
+
+ for ($i = 1; $i < count($params); $i++) {
+ $str = preg_replace('/<' . $params[$i] . '[^>]*>/i', '', $str);
+ $str = preg_replace('/<\/' . $params[$i] . '[^>]*>/i', '', $str);
+ }
+ return $str;
+ }
+
+/**
+ * Determines which content types the client accepts
+ *
+ * @param mixed $type Can be null (or no parameter), a string type name, or an
+ * array of types
+ * @return mixed If null or no parameter is passed, returns an array of content
+ * types the client accepts. If a string is passed, returns true
+ * if the client accepts it. If an array is passed, returns true
+ * if the client accepts one or more elements in the array.
+ * @access public
+ */
+ function accepts($type = null) {
+ if ($type == null) {
+ return $this->__acceptTypes;
+ } elseif (is_array($type)) {
+ foreach ($type as $t) {
+ if ($this->accepts($t) == true) {
+ return true;
+ }
+ }
+ return false;
+ } elseif (is_string($type)) {
+ // If client only accepts */*, then assume default HTML browser
+ if ($type == 'html' && $this->__acceptTypes === array('*/*')) {
+ return true;
+ }
+
+ if (!in_array($type, array_keys($this->__requestContent))) {
+ return false;
+ }
+
+ $content = $this->__requestContent[$type];
+
+ if (is_array($content)) {
+ foreach ($content as $c) {
+ if (in_array($c, $this->__acceptTypes)) {
+ return true;
+ }
+ }
+ } else {
+ if (in_array($content, $this->__acceptTypes)) {
+ return true;
+ }
+ }
+ }
+ }
+/**
+ * Determines which content types the client prefers
+ *
+ * @param mixed $type
+ * @returns mixed
+ * @access public
+ */
+ function prefers($type = null) {
+ if ($type == null) {
+ return $this->accepts(null);
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/security.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/security.php
new file mode 100644
index 0000000..52a8582
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/security.php
@@ -0,0 +1,202 @@
+<?php
+/* SVN FILE: $Id: security.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components
+ * @since CakePHP(tm) v 0.10.8.2156
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components
+ */
+class SecurityComponent extends Object {
+/**
+ * Holds an instance of the core Security object
+ *
+ * @var object Security
+ * @access public
+ */
+ var $Security = null;
+/**
+ * The controller method that will be called if this request is black-hole'd
+ *
+ * @var string
+ * @access public
+ */
+ var $blackHoleCallback = null;
+/**
+ * List of controller actions for which a POST request is required
+ *
+ * @var array
+ * @access public
+ * @see SecurityComponent::requirePost()
+ */
+ var $requirePost = array();
+/**
+ * List of actions that require a valid authentication key
+ *
+ * @var array
+ * @access public
+ * @see SecurityComponent::requireAuth()
+ */
+ var $requireAuth = array();
+/**
+ * Controllers from which actions of the current controller are allowed to receive
+ * requests.
+ *
+ * @var array
+ * @see SecurityComponent::requireAuth()
+ */
+ var $allowedControllers = array();
+/**
+ * Actions from which actions of the current controller are allowed to receive
+ * requests.
+ *
+ * @var array
+ * @see SecurityComponent::requireAuth()
+ */
+ var $allowedActions = array();
+/**
+ * Other components used by the Security component
+ *
+ * @var array
+ * @access public
+ */
+ var $components = array('RequestHandler', 'Session');
+/**
+ * Security class constructor
+ */
+ function __construct () {
+ $this->Security = Security::getInstance();
+ }
+/**
+ * Component startup. All security checking happens here.
+ *
+ * @param object $controller
+ * @return unknown
+ * @access public
+ */
+ function startup(&$controller) {
+ if (is_array($this->requirePost) && !empty($this->requirePost)) {
+
+ if (in_array($controller->action, $this->requirePost)) {
+
+ if (!$this->RequestHandler->isPost()) {
+
+ if (!$this->blackHole($controller)) {
+ return null;
+ }
+ }
+ }
+ }
+
+ if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($controller->params['form'])) {
+ if (in_array($controller->action, $this->requireAuth)) {
+
+ if (!isset($controller->params['data']['_Token'])) {
+
+ if (!$this->blackHole($controller)) {
+ return null;
+ }
+ }
+ $token = $controller->params['data']['_Token']['key'];
+
+ if ($this->Session->check('_Token')) {
+ $tData = $this->Session->read('_Token');
+ if (!(intval($tData['expires']) > strtotime('now')) || $tData['key'] !== $token) {
+
+ if (!$this->blackHole($controller)) {
+ return null;
+ }
+ }
+
+ if (!empty($tData['allowedControllers']) && !in_array($controller->params['controller'], $tData['allowedControllers']) ||!empty($tData['allowedActions']) && !in_array($controller->params['action'], $tData['allowedActions'])) {
+ if (!$this->blackHole($controller)) {
+ return null;
+ }
+ }
+ } else {
+ if (!$this->blackHole($controller)) {
+ return null;
+ }
+ }
+ }
+ }
+
+ if (!isset($controller->params['requested']) || $controller->params['requested'] != 1) {
+ // Add auth key for new form posts
+ $authKey = Security::generateAuthKey();
+ $expires = strtotime('+'.Security::inactiveMins().' minutes');
+ $token = array(
+ 'key' => $authKey,
+ 'expires' => $expires,
+ 'allowedControllers' => $this->allowedControllers,
+ 'allowedActions' => $this->allowedActions
+ );
+ if (!isset($controller->params['data'])) {
+ $controller->params['data'] = array();
+ }
+ $controller->params['_Token'] = $token;
+ $this->Session->write('_Token', $token);
+ }
+ }
+/**
+ * Black-hole an invalid request with a 404 error or custom callback
+ *
+ * @param object $controller
+ * @return callback in controller
+ * @access public
+ */
+ function blackHole(&$controller) {
+ if ($this->blackHoleCallback == null) {
+ header('HTTP/1.0 404 Not Found');
+ exit();
+ } elseif (method_exists($controller, $this->blackHoleCallback)) {
+ return $controller->{$this->blackHoleCallback}();
+ }
+ }
+/**
+ * Sets the actions that require a POST request, or empty for all actions
+ *
+ * @access public
+ * @return void
+ */
+ function requirePost() {
+ $this->requirePost = func_get_args();
+ }
+/**
+ * Sets the actions that require an authenticated request, or empty for all actions
+ *
+ * @access public
+ * @return void
+ */
+ function requireAuth() {
+ $this->requireAuth = func_get_args();
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/session.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/session.php
new file mode 100644
index 0000000..ce89ac9
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/components/session.php
@@ -0,0 +1,306 @@
+<?php
+/* SVN FILE: $Id: session.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components
+ * @since CakePHP(tm) v 0.10.0.1232
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Session Component.
+ *
+ * Session handling from the controller.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller.components
+ *
+ */
+class SessionComponent extends CakeSession {
+/**
+ * Used to determine if methods implementation is used, or bypassed
+ *
+ * @var boolean
+ * @access private
+ */
+ var $__active = true;
+/**
+ * Used to determine if Session has been started
+ *
+ * @var boolean
+ * @access private
+ */
+ var $__started = false;
+/**
+ * Used to determine if request are from an Ajax request
+ *
+ * @var boolean
+ * @access private
+ */
+ var $__bare = 0;
+/**
+ * Class constructor
+ *
+ * @param string $base The base path for the Session
+ */
+ function __construct($base = null) {
+ if (!defined('AUTO_SESSION') || AUTO_SESSION === true) {
+ parent::__construct($base);
+ } else {
+ $this->__active = false;
+ }
+ }
+/**
+ * Initializes the component, gets a reference to Controller::$param['bare'].
+ *
+ * @param object $controller A reference to the controller
+ * @access public
+ */
+ function initialize(&$controller) {
+ if (isset($controller->params['bare'])) {
+ $this->__bare = $controller->params['bare'];
+ }
+ }
+/**
+ * Startup method.
+ *
+ * @param object $controller Instantiating controller
+ * @access public
+ */
+ function startup(&$controller) {
+ if ($this->__started === false && $this->__active === true) {
+ $this->__start();
+ }
+ }
+/**
+ * Starts Session on if 'Session.start' is set to false in core.php
+ *
+ * @param string $base The base path for the Session
+ * @access public
+ */
+ function activate($base = null) {
+ if ($this->__active === true) {
+ return;
+ }
+ parent::__construct($base);
+ $this->__active = true;
+ }
+/**
+ * Used to write a value to a session key.
+ *
+ * In your controller: $this->Session->write('Controller.sessKey', 'session value');
+ *
+ * @param string $name The name of the key your are setting in the session.
+ * This should be in a Controller.key format for better organizing
+ * @param string $value The value you want to store in a session.
+ * @access public
+ */
+ function write($name, $value = null) {
+ if ($this->__active === true) {
+ $this->__start();
+ if (is_array($name)) {
+ foreach ($name as $key => $value) {
+ if (parent::write($key, $value) === false) {
+ return false;
+ }
+ }
+ return true;
+ }
+ if (parent::write($name, $value) === false) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+/**
+ * Used to read a session values for a key or return values for all keys.
+ *
+ * In your controller: $this->Session->read('Controller.sessKey');
+ * Calling the method without a param will return all session vars
+ *
+ * @param string $name the name of the session key you want to read
+ * @return mixed value from the session vars
+ * @access public
+ */
+ function read($name = null) {
+ if ($this->__active === true) {
+ $this->__start();
+ return parent::read($name);
+ }
+ return false;
+ }
+/**
+ * Used to delete a session variable.
+ *
+ * In your controller: $this->Session->del('Controller.sessKey');
+ *
+ * @param string $name the name of the session key you want to delete
+ * @return boolean true is session variable is set and can be deleted, false is variable was not set.
+ * @access public
+ */
+ function del($name) {
+ if ($this->__active === true) {
+ $this->__start();
+ return parent::del($name);
+ }
+ return false;
+ }
+/**
+ * Wrapper for SessionComponent::del();
+ *
+ * In your controller: $this->Session->delete('Controller.sessKey');
+ *
+ * @param string $name the name of the session key you want to delete
+ * @return boolean true is session variable is set and can be deleted, false is variable was not set.
+ * @access public
+ */
+ function delete($name) {
+ if ($this->__active === true) {
+ $this->__start();
+ return $this->del($name);
+ }
+ return false;
+ }
+/**
+ * Used to check if a session variable is set
+ *
+ * In your controller: $this->Session->check('Controller.sessKey');
+ *
+ * @param string $name the name of the session key you want to check
+ * @return boolean true is session variable is set, false if not
+ * @access public
+ */
+ function check($name) {
+ if ($this->__active === true) {
+ $this->__start();
+ return parent::check($name);
+ }
+ return false;
+ }
+/**
+ * Used to determine the last error in a session.
+ *
+ * In your controller: $this->Session->error();
+ *
+ * @return string Last session error
+ * @access public
+ */
+ function error() {
+ if ($this->__active === true) {
+ $this->__start();
+ return parent::error();
+ }
+ return false;
+ }
+/**
+ * Used to set a session variable that can be used to output messages in the view.
+ *
+ * In your controller: $this->Session->setFlash('This has been saved');
+ *
+ * Additional params below can be passed to customize the output, or the Message.[key]
+ *
+ * @param string $message Message to be flashed
+ * @param string $layout Layout to wrap flash message in
+ * @param array $params Parameters to be sent to layout as view variables
+ * @param string $key Message key, default is 'flash'
+ * @access public
+ */
+ function setFlash($message, $layout = 'default', $params = array(), $key = 'flash') {
+ if ($this->__active === true) {
+ $this->__start();
+ $this->write('Message.' . $key, compact('message', 'layout', 'params'));
+ }
+ }
+/**
+ * Used to renew a session id
+ *
+ * In your controller: $this->Session->renew();
+ *
+ * @access public
+ */
+ function renew() {
+ if ($this->__active === true) {
+ $this->__start();
+ parent::renew();
+ }
+ }
+/**
+ * Used to check for a valid session.
+ *
+ * In your controller: $this->Session->valid();
+ *
+ * @return boolean true is session is valid, false is session is invalid
+ * @access public
+ */
+ function valid() {
+ if ($this->__active === true) {
+ $this->__start();
+ return parent::valid();
+ }
+ return false;
+ }
+/**
+ * Used to destroy sessions
+ *
+ * In your controller: $this->Session->destroy();
+ *
+ * @access public
+ */
+ function destroy() {
+ if ($this->__active === true) {
+ $this->__start();
+ parent::destroy();
+ }
+ }
+/**
+ * Returns Session id
+ *
+ * If $id is passed in a beforeFilter, the Session will be started
+ * with the specified id
+ *
+ * @param $id string
+ * @return string
+ * @access public
+ */
+ function id($id = null) {
+ return parent::id($id);
+ }
+/**
+ * Starts Session if SessionComponent is used in Controller::beforeFilter(),
+ * or is called from
+ *
+ * @access private
+ */
+ function __start(){
+ if ($this->__started === false) {
+ if (!$this->id() && parent::start()) {
+ $this->__started = true;
+ parent::_checkValid();
+ } else {
+ $this->__started = parent::start();
+ }
+ }
+ return $this->__started;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/controller.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/controller.php
new file mode 100644
index 0000000..482100b
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/controller.php
@@ -0,0 +1,998 @@
+<?php
+/* SVN FILE: $Id: controller.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Base controller class.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Include files
+ */
+ uses(DS . 'controller' . DS . 'component', DS . 'view' . DS . 'view');
+/**
+ * Controller
+ *
+ * Application controller (controllers are where you put all the actual code)
+ * Provides basic functionality, such as rendering views (aka displaying templates).
+ * Automatically selects model name from on singularized object class name
+ * and creates the model object if proper class exists.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller
+ *
+ */
+class Controller extends Object{
+/**
+ * Name of the controller.
+ *
+ * @var string
+ * @access public
+ */
+ var $name = null;
+/**
+ * Stores the current URL (for links etc.)
+ *
+ * @var string
+ * @access public
+ */
+ var $here = null;
+/**
+ * The webroot of the application
+ *
+ * @var string
+ * @access public
+ */
+ var $webroot = null;
+/**
+ * Action to be performed.
+ *
+ * @var string
+ * @access public
+ */
+ var $action = null;
+/**
+ * An array of names of models the particular controller wants to use.
+ *
+ * @var mixed A single name as a string or a list of names as an array.
+ * @access protected
+ */
+ var $uses = false;
+/**
+ * An array of names of built-in helpers to include.
+ *
+ * @var mixed A single name as a string or a list of names as an array.
+ * @access protected
+ */
+ var $helpers = array('Html');
+/**
+ * Parameters received in the current request, i.e. GET and POST data
+ *
+ * @var array
+ * @access public
+ */
+ var $params = array();
+/**
+ * POST'ed model data
+ *
+ * @var array
+ * @access public
+ */
+ var $data = array();
+/**
+ * Directory where controllers views are stored
+ * Normaly this is automatically set
+ *
+ * @var string
+ * @access public
+ */
+ var $viewPath = null;
+/**
+ * Variables for the view
+ *
+ * @var array
+ * @access public
+ */
+ var $viewVars = array();
+/**
+ * Web page title
+ *
+ * @var boolean
+ * @access public
+ */
+ var $pageTitle = false;
+/**
+ * An array of model objects.
+ *
+ * @var array Array of model objects.
+ * @access public
+ */
+ var $modelNames = array();
+/**
+ * Base url path
+ *
+ * @var string
+ * @access public
+ */
+ var $base = null;
+/**
+ * Layout file to use (see /app/views/layouts/default.thtml)
+ *
+ * @var string
+ * @access public
+ */
+ var $layout = 'default';
+/**
+ * Automatically render the view (the dispatcher checks for this variable before running render())
+ *
+ * @var boolean
+ * @access public
+ */
+ var $autoRender = true;
+/**
+ * Automatically render the layout
+ *
+ * @var boolean
+ * @access public
+ */
+ var $autoLayout = true;
+/**
+ * Array of components a controller will use
+ *
+ * @var array
+ * @access public
+ */
+ var $components = array();
+/**
+ * The name of the View class a controller sends output to
+ *
+ * @var string
+ * @access public
+ */
+ var $view = 'View';
+/**
+ * File extension for view templates. Defaults to Cake's conventional ".thtml".
+ *
+ * @var string
+ * @access public
+ */
+ var $ext = '.thtml';
+/**
+ * Instance of $view class create by a controller
+ *
+ * @var object
+ * @access private
+ */
+ var $__viewClass = null;
+/**
+ * The output of the requested action. Contains either a variable
+ * returned from the action, or the data of the rendered view;
+ * You can use this var in Child classes afterFilter() to alter output.
+ *
+ * @var string
+ * @access public
+ */
+ var $output = null;
+/**
+ * Automatically set to the name of a plugin.
+ *
+ * @var string
+ * @access public
+ */
+ var $plugin = null;
+/**
+ * Used to set methods a controller will allow the View to cache
+ *
+ * @var mixed
+ * @access public
+ */
+ var $cacheAction = false;
+/**
+ * Used to create cached instances of models a controller uses.
+ * When set to true all models related to the controller will be cached,
+ * this can increase performance in many cases
+ *
+ * @var boolean
+ * @access public
+ */
+ var $persistModel = false;
+/**
+ * Replaced with Controller::beforeFilter();
+ *
+ * @deprecated will not be avialable after 1.1.x.x
+ */
+ var $beforeFilter = null;
+/**
+ * Replaced with Router::parseExtensions();
+ *
+ * @deprecated will not be avialable after 1.1.x.x
+ */
+ var $webservices = null;
+/**
+ * Constructor.
+ */
+ function __construct() {
+ if ($this->name === null) {
+ $r = null;
+
+ if (!preg_match('/(.*)Controller/i', get_class($this), $r)) {
+ die ("Controller::__construct() : Can't get or parse my own class name, exiting.");
+ }
+ $this->name = $r[1];
+ }
+
+ if ($this->viewPath == null) {
+ $this->viewPath = Inflector::underscore($this->name);
+ }
+
+ $this->modelClass = Inflector::classify($this->name);
+ $this->modelKey = Inflector::underscore($this->modelClass);
+
+ if (is_subclass_of($this, 'AppController')) {
+ $appVars = get_class_vars('AppController');
+ $uses = $appVars['uses'];
+ $merge = array('components', 'helpers');
+
+ if ($uses == $this->uses && !empty($this->uses)) {
+ array_unshift($this->uses, $this->modelClass);
+ } elseif ($this->uses !== null || $this->uses !== false) {
+ $merge[] = 'uses';
+ }
+
+ foreach ($merge as $var) {
+ if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
+ $this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
+ }
+ }
+ }
+ parent::__construct();
+ }
+
+ function _initComponents() {
+ $component = new Component();
+ $component->init($this);
+ }
+/**
+ * Loads and instantiates models required by this controller.
+ * If Controller::persistModel; is true, controller will create cached model instances on first request,
+ * additional request will used cached models
+ *
+ * @return mixed true when single model found and instance created error returned if models not found.
+ * @access public
+ */
+ function constructClasses() {
+ if ($this->uses === null || ($this->uses === array())) {
+ return false;
+ }
+ if (empty($this->passedArgs) || !isset($this->passedArgs['0'])) {
+ $id = false;
+ } else {
+ $id = $this->passedArgs['0'];
+ }
+ $cached = false;
+ $object = null;
+
+ if ($this->persistModel === true) {
+ uses('neat_array');
+ }
+ if ($this->uses === false) {
+ if (!class_exists($this->modelClass)) {
+ loadModel($this->modelClass);
+ }
+ }
+
+ if (class_exists($this->modelClass) && ($this->uses === false)) {
+ if ($this->persistModel === true) {
+ $cached = $this->_persist($this->modelClass, null, $object);
+ }
+
+ if (($cached === false)) {
+ $model =& new $this->modelClass($id);
+ $this->modelNames[] = $this->modelClass;
+ $this->{$this->modelClass} =& $model;
+
+ if ($this->persistModel === true) {
+ $this->_persist($this->modelClass, true, $model);
+ $registry = ClassRegistry::getInstance();
+ $this->_persist($this->modelClass . 'registry', true, $registry->_objects, 'registry');
+ }
+ } else {
+ $this->_persist($this->modelClass . 'registry', true, $object, 'registry');
+ $this->_persist($this->modelClass, true, $object);
+ $this->modelNames[] = $this->modelClass;
+ }
+ return true;
+ } elseif ($this->uses === false) {
+ return $this->cakeError('missingModel', array(array('className' => $this->modelClass, 'webroot' => '', 'base' => $this->base)));
+ }
+
+ if ($this->uses) {
+ $uses = is_array($this->uses) ? $this->uses : array($this->uses);
+ $this->modelClass = $uses[0];
+
+ foreach ($uses as $modelClass) {
+ $id = false;
+ $cached = false;
+ $object = null;
+ $modelKey = Inflector::underscore($modelClass);
+
+ if (!class_exists($modelClass)) {
+ loadModel($modelClass);
+ }
+
+ if (class_exists($modelClass)) {
+ if ($this->persistModel === true) {
+ $cached = $this->_persist($modelClass, null, $object);
+ }
+
+ if (($cached === false)) {
+ $model =& new $modelClass($id);
+ $this->modelNames[] = $modelClass;
+ $this->{$modelClass} =& $model;
+
+ if ($this->persistModel === true) {
+ $this->_persist($modelClass, true, $model);
+ $registry = ClassRegistry::getInstance();
+ $this->_persist($modelClass . 'registry', true, $registry->_objects, 'registry');
+ }
+ } else {
+ $this->_persist($modelClass . 'registry', true, $object, 'registry');
+ $this->_persist($modelClass, true, $object);
+ $this->modelNames[] = $modelClass;
+ }
+ } else {
+ return $this->cakeError('missingModel', array(array('className' => $modelClass, 'webroot' => '', 'base' => $this->base)));
+ }
+ }
+ return true;
+ }
+ }
+/**
+ * Redirects to given $url, after turning off $this->autoRender.
+ * Please notice that the script execution is not stopped after the redirect.
+ *
+ * @param string $url
+ * @param integer $status
+ * @access public
+ */
+ function redirect($url, $status = null) {
+ $this->autoRender = false;
+ $pos = strpos($url, '://');
+ $base = strip_plugin($this->base, $this->plugin);
+ if ($pos === false) {
+ if (strpos($url, '/') !== 0) {
+ $url = '/' . $url;
+ }
+ $url = FULL_BASE_URL . $base . $url;
+ }
+
+ if (function_exists('session_write_close')) {
+ session_write_close();
+ }
+
+ if (!empty($status)) {
+ $codes = array(
+ 100 => "HTTP/1.1 100 Continue",
+ 101 => "HTTP/1.1 101 Switching Protocols",
+ 200 => "HTTP/1.1 200 OK",
+ 201 => "HTTP/1.1 201 Created",
+ 202 => "HTTP/1.1 202 Accepted",
+ 203 => "HTTP/1.1 203 Non-Authoritative Information",
+ 204 => "HTTP/1.1 204 No Content",
+ 205 => "HTTP/1.1 205 Reset Content",
+ 206 => "HTTP/1.1 206 Partial Content",
+ 300 => "HTTP/1.1 300 Multiple Choices",
+ 301 => "HTTP/1.1 301 Moved Permanently",
+ 302 => "HTTP/1.1 302 Found",
+ 303 => "HTTP/1.1 303 See Other",
+ 304 => "HTTP/1.1 304 Not Modified",
+ 305 => "HTTP/1.1 305 Use Proxy",
+ 307 => "HTTP/1.1 307 Temporary Redirect",
+ 400 => "HTTP/1.1 400 Bad Request",
+ 401 => "HTTP/1.1 401 Unauthorized",
+ 402 => "HTTP/1.1 402 Payment Required",
+ 403 => "HTTP/1.1 403 Forbidden",
+ 404 => "HTTP/1.1 404 Not Found",
+ 405 => "HTTP/1.1 405 Method Not Allowed",
+ 406 => "HTTP/1.1 406 Not Acceptable",
+ 407 => "HTTP/1.1 407 Proxy Authentication Required",
+ 408 => "HTTP/1.1 408 Request Time-out",
+ 409 => "HTTP/1.1 409 Conflict",
+ 410 => "HTTP/1.1 410 Gone",
+ 411 => "HTTP/1.1 411 Length Required",
+ 412 => "HTTP/1.1 412 Precondition Failed",
+ 413 => "HTTP/1.1 413 Request Entity Too Large",
+ 414 => "HTTP/1.1 414 Request-URI Too Large",
+ 415 => "HTTP/1.1 415 Unsupported Media Type",
+ 416 => "HTTP/1.1 416 Requested range not satisfiable",
+ 417 => "HTTP/1.1 417 Expectation Failed",
+ 500 => "HTTP/1.1 500 Internal Server Error",
+ 501 => "HTTP/1.1 501 Not Implemented",
+ 502 => "HTTP/1.1 502 Bad Gateway",
+ 503 => "HTTP/1.1 503 Service Unavailable",
+ 504 => "HTTP/1.1 504 Gateway Time-out"
+ );
+ if (is_string($status)) {
+ $codes = array_combine(array_values($codes), array_keys($codes));
+ }
+ if (isset($codes[$status])) {
+ $code = ife(is_numeric($status), $status, $codes[$status]);
+ $msg = ife(is_string($status), $status, $codes[$status]);
+ $status = "HTTP/1.1 {$code} {$msg}";
+ } else {
+ $status = null;
+ }
+ }
+ if (!empty($status)) {
+ header($status);
+ }
+ header('Location: ' . $url);
+ if (!empty($status) && ($status >= 300 && $status < 400)) {
+ header($status);
+ }
+ }
+/**
+ * Saves a variable to use inside a template.
+ *
+ * @param mixed $one A string or an array of data.
+ * @param mixed $two Value in case $one is a string (which then works as the key). Unused if $one is an associative array, otherwise serves as the values to $one's keys.
+ * @return mixed string or array of variables set
+ * @access public
+ */
+ function set($one, $two = null) {
+ if (is_array($one)) {
+ if (is_array($two)) {
+ return $this->_setArray(array_combine($one, $two));
+ } else {
+ return $this->_setArray($one);
+ }
+ } else {
+ return $this->_setArray(array($one => $two));
+ }
+ }
+/**
+ * Internally redirects one action to another
+ *
+ * @param string $action The new action to be redirected to
+ * @param mixed Any other parameters passed to this method will be passed as
+ * parameters to the new action.
+ * @access public
+ */
+ function setAction($action) {
+ $this->action = $action;
+ $args = func_get_args();
+ unset($args[0]);
+ call_user_func_array(array(&$this, $action), $args);
+ }
+/**
+ * Returns number of errors in a submitted FORM.
+ *
+ * @return int Number of errors
+ * @access public
+ */
+ function validate() {
+ $args = func_get_args();
+ $errors = call_user_func_array(array(&$this, 'validateErrors'), $args);
+
+ if ($errors === false) {
+ return 0;
+ }
+ return count($errors);
+ }
+/**
+ * Validates a FORM according to the rules set up in the Model.
+ *
+ * @return int Number of errors
+ * @access public
+ */
+ function validateErrors() {
+ $objects = func_get_args();
+ if (!count($objects)) {
+ return false;
+ }
+
+ $errors = array();
+ foreach ($objects as $object) {
+ $errors = array_merge($errors, $this->{$object->name}->invalidFields($object->data));
+ }
+ return $this->validationErrors = (count($errors) ? $errors : false);
+ }
+/**
+ * Gets an instance of the view object and prepares it for rendering the output, then
+ * asks the view to actualy do the job.
+ *
+ * @param string $action
+ * @param string $layout
+ * @param string $file
+ * @return controllers related views
+ * @access public
+ */
+ function render($action = null, $layout = null, $file = null) {
+ $viewClass = $this->view;
+ if ($this->view != 'View') {
+ $viewClass = $this->view . 'View';
+ loadView($this->view);
+ }
+ $this->beforeRender();
+ $this->__viewClass =& new $viewClass($this);
+
+ if (!empty($this->modelNames)) {
+ $models = array();
+ foreach ($this->modelNames as $currentModel) {
+ if (isset($this->$currentModel) && is_a($this->$currentModel, 'Model')) {
+ $models[] = Inflector::underscore($currentModel);
+ }
+ if (isset($this->$currentModel) && is_a($this->$currentModel, 'Model') && !empty($this->$currentModel->validationErrors)) {
+ $this->__viewClass->validationErrors[Inflector::camelize($currentModel)] =& $this->$currentModel->validationErrors;
+ }
+ }
+ $models = array_diff(ClassRegistry::keys(), $models);
+ foreach ($models as $currentModel) {
+ if (ClassRegistry::isKeySet($currentModel)) {
+ $currentObject =& ClassRegistry::getObject($currentModel);
+ if (is_a($currentObject, 'Model') && !empty($currentObject->validationErrors)) {
+ $this->__viewClass->validationErrors[Inflector::camelize($currentModel)] =& $currentObject->validationErrors;
+ }
+ }
+ }
+ }
+ $this->autoRender = false;
+ return $this->__viewClass->render($action, $layout, $file);
+ }
+/**
+ * Gets the referring URL of this request
+ *
+ * @param string $default Default URL to use if HTTP_REFERER cannot be read from headers
+ * @param boolean $local If true, restrict referring URLs to local server
+ * @access public
+ */
+ function referer($default = null, $local = false) {
+ $ref = env('HTTP_REFERER');
+ $base = FULL_BASE_URL . $this->webroot;
+
+ if ($ref != null && (defined(FULL_BASE_URL) || FULL_BASE_URL)) {
+ if (strpos($ref, $base) === 0) {
+ return substr($ref, strlen($base) - 1);
+ } elseif (!$local) {
+ return $ref;
+ }
+ }
+
+ if ($default != null) {
+ return $default;
+ } else {
+ return '/';
+ }
+ }
+/**
+ * Sets data for this view. Will set title if the key "title" is in given $data array.
+ *
+ * @param array $data Array of
+ * @access protected
+ */
+ function _setArray($data) {
+ foreach ($data as $name => $value) {
+ if ($name == 'title') {
+ $this->_setTitle($value);
+ } else {
+ $this->viewVars[$name] = $value;
+ }
+ }
+ }
+/**
+ * Set the title element of the page.
+ *
+ * @param string $pageTitle Text for the title
+ * @access private
+ */
+ function _setTitle($pageTitle) {
+ $this->pageTitle = $pageTitle;
+ }
+/**
+ * Shows a message to the user $time seconds, then redirects to $url if DEBUG == 0. If DEBUG > 0, warnings and SQL output may halt redirection.
+ * Uses flash.thtml as a layout for the messages
+ *
+ * @param string $message Message to display to the user
+ * @param string $url Relative URL to redirect to after the time expires
+ * @param int $time seconds to show the message
+ * @access public
+ */
+ function flash($message, $url, $pause = 1) {
+ $this->autoRender = false;
+ $this->autoLayout = false;
+ $this->set('url', $this->base . $url);
+ $this->set('message', $message);
+ $this->set('pause', $pause);
+ $this->set('page_title', $message);
+
+ if (file_exists(VIEWS . 'layouts' . DS . 'flash.thtml')) {
+ $flash = VIEWS . 'layouts' . DS . 'flash.thtml';
+ } elseif ($flash = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . "layouts" . DS . 'flash.thtml')) {
+ }
+ $this->render(null, false, $flash);
+ }
+/**
+ * Replaced with Controller::flash();
+ * @deprecated will not be avialable after 1.1.x.x
+ */
+ function flashOut($message, $url, $pause = 1) {
+ trigger_error('(Controller::flashOut()) Deprecated: Use Controller::flash() instead', E_USER_WARNING);
+ $this->autoRender = false;
+ $this->autoLayout = false;
+ $this->set('url', $url);
+ $this->set('message', $message);
+ $this->set('pause', $pause);
+ $this->set('page_title', $message);
+
+ if (file_exists(VIEWS . 'layouts' . DS . 'flash.thtml')) {
+ $flash = VIEWS . 'layouts' . DS . 'flash.thtml';
+ } elseif ($flash = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . "layouts" . DS . 'flash.thtml')) {
+ }
+ $this->render(null, false, $flash);
+ }
+/**
+ * This function creates a $fieldNames array for the view to use.
+ *
+ * @param array $data
+ * @param boolean $doCreateOptions
+ * @return field name arrays for the view
+ * @access public
+ */
+ function generateFieldNames($data = null, $doCreateOptions = true) {
+ $fieldNames = array();
+ $model = $this->modelClass;
+ $modelKey = $this->modelKey;
+ $table = $this->{$model}->table;
+ $objRegistryModel =& ClassRegistry::getObject($modelKey);
+
+ foreach ($objRegistryModel->_tableInfo->value as $tabl) {
+ if ($objRegistryModel->isForeignKey($tabl['name'])) {
+ if (false !== strpos($tabl['name'], "_id")) {
+ $niceName = substr($tabl['name'], 0, strpos($tabl['name'], "_id" ));
+ } else {
+ $niceName = $niceName = $tabl['name'];
+ }
+ $fkNames = $this->{$model}->keyToTable[$tabl['name']];
+ $fieldNames[$tabl['name']]['table'] = $fkNames[0];
+ $fieldNames[$tabl['name']]['prompt'] = Inflector::humanize($niceName);
+ $fieldNames[$tabl['name']]['model'] = $fkNames[1];
+ $fieldNames[$tabl['name']]['modelKey'] = $this->{$model}->tableToModel[$fieldNames[$tabl['name']]['table']];
+ $fieldNames[$tabl['name']]['controller'] = Inflector::pluralize($this->{$model}->tableToModel[$fkNames[0]]);
+ $fieldNames[$tabl['name']]['foreignKey'] = true;
+
+ } elseif ('created' != $tabl['name'] && 'updated' != $tabl['name']) {
+ $fieldNames[$tabl['name']]['prompt'] = Inflector::humanize($tabl['name']);
+ } elseif ('created' == $tabl['name']) {
+ $fieldNames[$tabl['name']]['prompt'] = 'Created';
+ } elseif ('updated' == $tabl['name']) {
+ $fieldNames[$tabl['name']]['prompt'] = 'Modified';
+ }
+ $fieldNames[$tabl['name']]['tagName'] = $model . '/' . $tabl['name'];
+ $validationFields = $objRegistryModel->validate;
+
+ if (isset($validationFields[$tabl['name']])) {
+ if (VALID_NOT_EMPTY == $validationFields[$tabl['name']]) {
+ $fieldNames[$tabl['name']]['required'] = true;
+ $fieldNames[$tabl['name']]['errorMsg'] = "Required Field";
+ }
+ }
+ $lParenPos = strpos($tabl['type'], '(');
+ $rParenPos = strpos($tabl['type'], ')');
+
+ if (false != $lParenPos) {
+ $type = substr($tabl['type'], 0, $lParenPos);
+ $fieldLength = substr($tabl['type'], $lParenPos + 1, $rParenPos - $lParenPos - 1);
+ } else {
+ $type = $tabl['type'];
+ }
+
+ switch($type) {
+ case "text":
+ $fieldNames[$tabl['name']]['type'] = 'area';
+ break;
+ case "string":
+ if (isset($fieldNames[$tabl['name']]['foreignKey'])) {
+ $fieldNames[$tabl['name']]['type'] = 'select';
+ $fieldNames[$tabl['name']]['options'] = array();
+ $otherModel =& ClassRegistry::getObject(Inflector::underscore($fieldNames[$tabl['name']]['modelKey']));
+
+ if (is_object($otherModel)) {
+ if ($doCreateOptions) {
+ $otherDisplayField = $otherModel->getDisplayField();
+ $otherModel->recursive = 0;
+ $rec = $otherModel->findAll();
+
+ foreach ($rec as $pass) {
+ foreach ($pass as $key => $value) {
+ if ($key == $this->{$model}->tableToModel[$fieldNames[$tabl['name']]['table']] && isset($value[$otherModel->primaryKey]) && isset($value[$otherDisplayField])) {
+ $fieldNames[$tabl['name']]['options'][$value[$otherModel->primaryKey]] = $value[$otherDisplayField];
+ }
+ }
+ }
+ }
+ $fieldNames[$tabl['name']]['selected'] = $data[$model][$tabl['name']];
+ }
+ } else {
+ $fieldNames[$tabl['name']]['type'] = 'input';
+ }
+ break;
+ case "boolean":
+ $fieldNames[$tabl['name']]['type'] = 'checkbox';
+ break;
+ case "integer":
+ case "float":
+ if (strcmp($tabl['name'], $this->$model->primaryKey) == 0) {
+ $fieldNames[$tabl['name']]['type'] = 'hidden';
+ } elseif (isset($fieldNames[$tabl['name']]['foreignKey'])) {
+ $fieldNames[$tabl['name']]['type'] = 'select';
+ $fieldNames[$tabl['name']]['options'] = array();
+ $otherModel =& ClassRegistry::getObject(Inflector::underscore($fieldNames[$tabl['name']]['modelKey']));
+
+ if (is_object($otherModel)) {
+ if ($doCreateOptions) {
+ $otherDisplayField = $otherModel->getDisplayField();
+ $otherModel->recursive = 0;
+ $rec = $otherModel->findAll();
+
+ foreach ($rec as $pass) {
+ foreach ($pass as $key => $value) {
+ if ($key == $this->{$model}->tableToModel[$fieldNames[$tabl['name']]['table']] && isset($value[$otherModel->primaryKey]) && isset($value[$otherDisplayField])) {
+ $fieldNames[$tabl['name']]['options'][$value[$otherModel->primaryKey]] = $value[$otherDisplayField];
+ }
+ }
+ }
+ }
+ $fieldNames[$tabl['name']]['selected'] = $data[$model][$tabl['name']];
+ }
+ } else {
+ $fieldNames[$tabl['name']]['type'] = 'input';
+ }
+ break;
+ case "enum":
+ $fieldNames[$tabl['name']]['type'] = 'select';
+ $fieldNames[$tabl['name']]['options'] = array();
+ $enumValues = split(',', $fieldLength);
+
+ foreach ($enumValues as $enum) {
+ $enum = trim($enum, "'");
+ $fieldNames[$tabl['name']]['options'][$enum] = $enum;
+ }
+
+ $fieldNames[$tabl['name']]['selected'] = $data[$model][$tabl['name']];
+ break;
+ case "date":
+ case "datetime":
+ case "time":
+ case "year":
+ if (0 != strncmp("created", $tabl['name'], 7) && 0 != strncmp("modified", $tabl['name'], 8)) {
+ $fieldNames[$tabl['name']]['type'] = $type;
+ }
+
+ if (isset($data[$model][$tabl['name']])) {
+ $fieldNames[$tabl['name']]['selected'] = $data[$model][$tabl['name']];
+ } else {
+ $fieldNames[$tabl['name']]['selected'] = null;
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+
+ foreach ($objRegistryModel->hasAndBelongsToMany as $relation => $relData) {
+ $modelName = $relData['className'];
+ $manyAssociation = $relation;
+ $modelKeyM = Inflector::underscore($modelName);
+ $modelObject =& new $modelName();
+
+ if ($doCreateOptions) {
+ $otherDisplayField = $modelObject->getDisplayField();
+ $fieldNames[$relation]['model'] = $modelName;
+ $fieldNames[$relation]['prompt'] = "Related " . Inflector::humanize(Inflector::pluralize($relation));
+ $fieldNames[$relation]['type'] = "selectMultiple";
+ $fieldNames[$relation]['tagName'] = $manyAssociation . '/' . $manyAssociation;
+ $modelObject->recursive = 0;
+ $rec = $modelObject->findAll();
+
+ foreach ($rec as $pass) {
+ foreach ($pass as $key => $value) {
+ if ($key == $modelName && isset($value[$modelObject->primaryKey]) && isset($value[$otherDisplayField])) {
+ $fieldNames[$relation]['options'][$value[$modelObject->primaryKey]] = $value[$otherDisplayField];
+ }
+ }
+ }
+
+ if (isset($data[$manyAssociation])) {
+ foreach ($data[$manyAssociation] as $key => $row) {
+ $fieldNames[$relation]['selected'][$row[$modelObject->primaryKey]] = $row[$modelObject->primaryKey];
+ }
+ }
+ }
+ }
+ return $fieldNames;
+ }
+/**
+ * Converts POST'ed model data to a model conditions array, suitable for a find or findAll Model query
+ *
+ * @param array $data POST'ed data organized by model and field
+ * @return array An array of model conditions
+ * @access public
+ */
+ function postConditions($data) {
+ if (!is_array($data) || empty($data)) {
+ return null;
+ }
+ $conditions = array();
+
+ foreach ($data as $model => $fields) {
+ foreach ($fields as $field => $value) {
+ $conditions[$model . '.' . $field] = $value;
+ }
+ }
+ return $conditions;
+ }
+/**
+ * Cleans up the date fields of current Model.
+ *
+ * @param string $modelName
+ * @access public
+ */
+ function cleanUpFields($modelName = null) {
+ if ($modelName == null) {
+ $modelName = $this->modelClass;
+ }
+
+ foreach ($this->{$modelName}->_tableInfo->value as $field) {
+ if ('date' == $field['type'] && isset($this->params['data'][$modelName][$field['name'] . '_year'])) {
+ $newDate = $this->params['data'][$modelName][$field['name'] . '_year'] . '-';
+ $newDate .= $this->params['data'][$modelName][$field['name'] . '_month'] . '-';
+ $newDate .= $this->params['data'][$modelName][$field['name'] . '_day'];
+ unset($this->params['data'][$modelName][$field['name'] . '_year']);
+ unset($this->params['data'][$modelName][$field['name'] . '_month']);
+ unset($this->params['data'][$modelName][$field['name'] . '_day']);
+ unset($this->params['data'][$modelName][$field['name'] . '_hour']);
+ unset($this->params['data'][$modelName][$field['name'] . '_min']);
+ unset($this->params['data'][$modelName][$field['name'] . '_meridian']);
+ $this->params['data'][$modelName][$field['name']] = $newDate;
+ $this->data[$modelName][$field['name']] = $newDate;
+
+ } elseif ('datetime' == $field['type'] && isset($this->params['data'][$modelName][$field['name'] . '_year'])) {
+ $hour = $this->params['data'][$modelName][$field['name'] . '_hour'];
+
+ if ($hour != 12 && (isset($this->params['data'][$modelName][$field['name'] . '_meridian']) && 'pm' == $this->params['data'][$modelName][$field['name'] . '_meridian'])) {
+ $hour = $hour + 12;
+ }
+
+ $newDate = $this->params['data'][$modelName][$field['name'] . '_year'] . '-';
+ $newDate .= $this->params['data'][$modelName][$field['name'] . '_month'] . '-';
+ $newDate .= $this->params['data'][$modelName][$field['name'] . '_day'] . ' ';
+ $newDate .= $hour . ':' . $this->params['data'][$modelName][$field['name'] . '_min'] . ':00';
+ unset($this->params['data'][$modelName][$field['name'] . '_year']);
+ unset($this->params['data'][$modelName][$field['name'] . '_month']);
+ unset($this->params['data'][$modelName][$field['name'] . '_day']);
+ unset($this->params['data'][$modelName][$field['name'] . '_hour']);
+ unset($this->params['data'][$modelName][$field['name'] . '_min']);
+ unset($this->params['data'][$modelName][$field['name'] . '_meridian']);
+ $this->params['data'][$modelName][$field['name']] = $newDate;
+ $this->data[$modelName][$field['name']] = $newDate;
+
+ } elseif ('time' == $field['type'] && isset($this->params['data'][$modelName][$field['name'] . '_hour'])) {
+ $hour = $this->params['data'][$modelName][$field['name'] . '_hour'];
+
+ if ($hour != 12 && (isset($this->params['data'][$modelName][$field['name'] . '_meridian']) && 'pm' == $this->params['data'][$modelName][$field['name'] . '_meridian'])) {
+ $hour = $hour + 12;
+ }
+ if ($hour == 12 && (isset($this->params['data'][$modelName][$field['name'] . '_meridian']) && 'am' == $this->params['data'][$modelName][$field['name'] . '_meridian'])) {
+ $hour = '00';
+ }
+
+ $newDate = $hour . ':' . $this->params['data'][$modelName][$field['name'] . '_min'] . ':00';
+ unset($this->params['data'][$modelName][$field['name'] . '_hour']);
+ unset($this->params['data'][$modelName][$field['name'] . '_min']);
+ unset($this->params['data'][$modelName][$field['name'] . '_meridian']);
+ $this->params['data'][$modelName][$field['name']] = $newDate;
+ $this->data[$modelName][$field['name']] = $newDate;
+ }
+ }
+ }
+/**
+ * Called before the controller action. Overridden in subclasses.
+ *
+ * @access public
+ */
+ function beforeFilter() {
+ }
+/**
+ * Called after the controller action is run, but before the view is rendered. Overridden in subclasses.
+ *
+ * @access public
+ */
+ function beforeRender() {
+ }
+/**
+ * Called after the controller action is run and rendered. Overridden in subclasses.
+ *
+ * @access public
+ */
+ function afterFilter() {
+ }
+/**
+ * This method should be overridden in child classes.
+ *
+ * @param string $method name of method called example index, edit, etc.
+ * @return boolean
+ * @access protected
+ */
+ function _beforeScaffold($method) {
+ return true;
+ }
+/**
+ * This method should be overridden in child classes.
+ *
+ * @param string $method name of method called either edit or update.
+ * @return boolean
+ * @access protected
+ */
+ function _afterScaffoldSave($method) {
+ return true;
+ }
+/**
+ * This method should be overridden in child classes.
+ *
+ * @param string $method name of method called either edit or update.
+ * @return boolean
+ * @access protected
+ */
+ function _afterScaffoldSaveError($method) {
+ return true;
+ }
+/**
+ * This method should be overridden in child classes.
+ * If not it will render a scaffold error.
+ * Method MUST return true in child classes
+ *
+ * @param string $method name of method called example index, edit, etc.
+ * @return boolean
+ * @access protected
+ */
+ function _scaffoldError($method) {
+ return false;
+ }
+/**
+ * Used to convert HABTM data into an array for selectTag
+ *
+ * @param array $data
+ * @param string $key
+ * @return array
+ * @access protected
+ */
+ function _selectedArray($data, $key = 'id') {
+ $array = array();
+ if (!empty($data)) {
+ foreach ($data as $var) {
+ $array[$var[$key]] = $var[$key];
+ }
+ }
+ return $array;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/pages_controller.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/pages_controller.php
new file mode 100644
index 0000000..4182ba7
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/pages_controller.php
@@ -0,0 +1,105 @@
+<?php
+/* SVN FILE: $Id: pages_controller.php 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ * Short description for file.
+ *
+ * This file is application-wide controller file. You can put all
+ * application-wide controller-related methods here.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Short description for class.
+ *
+ * This file is application-wide controller file. You can put all
+ * application-wide controller-related methods here.
+ *
+ * Add your application-wide methods in the class below, your controllers
+ * will inherit them.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller
+ */
+class PagesController extends AppController{
+
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $name = 'Pages';
+
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $helpers = array('Html');
+
+/**
+ * This controller does not use a model
+ *
+ * @var $uses
+ */
+ var $uses = array();
+
+/**
+ * Displays a view
+ *
+ */
+ function display() {
+ if (!func_num_args()) {
+ $this->redirect('/');
+ }
+
+ $path=func_get_args();
+
+ if (!count($path)) {
+ $this->redirect('/');
+ }
+
+ $count =count($path);
+ $page =null;
+ $subpage=null;
+ $title =null;
+
+ if (!empty($path[0])) {
+ $page = $path[0];
+ }
+
+ if (!empty($path[1])) {
+ $subpage = $path[1];
+ }
+
+ if (!empty($path[$count - 1])) {
+ $title = ucfirst($path[$count - 1]);
+ }
+
+ $this->set('page', $page);
+ $this->set('subpage', $subpage);
+ $this->set('title', $title);
+ $this->render(join('/', $path));
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/scaffold.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/scaffold.php
new file mode 100644
index 0000000..e8d7037
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/controller/scaffold.php
@@ -0,0 +1,432 @@
+<?php
+/* SVN FILE: $Id: scaffold.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * Scaffold.
+ *
+ * Automatic forms and actions generation for rapid web application development.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.controller
+ * @since Cake v 0.10.0.1076
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Scaffolding is a set of automatic views, forms and controllers for starting web development work faster.
+ *
+ * Scaffold inspects your database tables, and making educated guesses, sets up a
+ * number of pages for each of your Models. These pages have data forms that work,
+ * and afford the web developer an early look at the data, and the possibility to over-ride
+ * scaffolded actions with custom-made ones.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.controller
+ */
+class Scaffold extends Object{
+/**
+ * Name of view to render
+ *
+ * @var string
+ */
+ var $actionView = null;
+/**
+ * Class name of model
+ *
+ * @var unknown_type
+ */
+ var $modelKey = null;
+/**
+ * Controller object
+ *
+ * @var Controller
+ */
+ var $controllerClass = null;
+/**
+ * Name of scaffolded Model
+ *
+ * @var string
+ */
+ var $modelName = null;
+/**
+ * Title HTML element for current scaffolded view
+ *
+ * @var string
+ */
+ var $scaffoldTitle = null;
+/**
+ * Base URL
+ *
+ * @var string
+ */
+ var $base = false;
+/**
+ * Construct and set up given controller with given parameters.
+ *
+ * @param object $controller instance of controller
+ * @param array $params
+ */
+ function __construct(&$controller, $params) {
+ $this->controllerClass =& $controller;
+ $this->actionView = $controller->action;
+ $this->modelKey = ucwords(Inflector::singularize($controller->name));
+ $this->scaffoldTitle = Inflector::humanize($this->modelKey);
+ $this->viewPath = Inflector::underscore($controller->name);
+ $this->controllerClass->pageTitle = $this->scaffoldTitle;
+ $this->controllerClass->pageTitle = 'Scaffold :: ' . Inflector::humanize($controller->action) . ' :: ' .
+ Inflector::humanize(Inflector::pluralize($this->modelKey));
+ $this->__scaffold($params);
+ }
+/**
+ * Renders a view view of scaffolded Model.
+ *
+ * @param array $params
+ * @return A rendered view of a row from Models database table
+ * @access private
+ */
+ function __scaffoldView($params) {
+ if ($this->controllerClass->_beforeScaffold('view')) {
+
+ if (isset($params['pass'][0])) {
+ $this->controllerClass->{$this->modelKey}->id = $params['pass'][0];
+
+ } elseif (isset($this->controllerClass->Session) && $this->controllerClass->Session->valid() != false) {
+ $this->controllerClass->Session->setFlash('No id set for ' . Inflector::humanize($this->modelKey) . '::view().');
+ $this->controllerClass->redirect('/' . Inflector::underscore($this->controllerClass->viewPath));
+
+ } else {
+ return $this->controllerClass->flash('No id set for ' . Inflector::humanize($this->modelKey) . '::view().',
+ '/' . Inflector::underscore($this->controllerClass->viewPath));
+ }
+
+ $this->controllerClass->params['data'] = $this->controllerClass->{$this->modelKey}->read();
+ $this->controllerClass->set('data', $this->controllerClass->params['data']);
+ $this->controllerClass->set('fieldNames',$this->controllerClass->generateFieldNames(
+ $this->controllerClass->params['data'], false));
+
+ if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffold.view.thtml')) {
+ return $this->controllerClass->render($this->actionView, '',
+ APP . 'views' . DS . $this->viewPath . DS . 'scaffold.view.thtml');
+
+ } elseif (file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.view.thtml')) {
+ return $this->controllerClass->render($this->actionView, '',
+ APP . 'views' . DS . 'scaffold' . DS . 'scaffold.view.thtml');
+ } else {
+ return $this->controllerClass->render($this->actionView, '',
+ LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'view.thtml');
+ }
+ } elseif ($this->controllerClass->_scaffoldError('view') === false) {
+ return $this->__scaffoldError();
+ }
+ }
+/**
+ * Renders List view of scaffolded Model.
+ *
+ * @param array $params
+ * @return A rendered view listing rows from Models database table
+ * @access private
+ */
+ function __scaffoldIndex($params) {
+ if ($this->controllerClass->_beforeScaffold('index')) {
+ $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(null, false));
+ $this->controllerClass->{$this->modelKey}->recursive = 0;
+ $this->controllerClass->set('data', $this->controllerClass->{$this->modelKey}->findAll());
+
+ if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffold.index.thtml')) {
+ return $this->controllerClass->render($this->actionView, '',
+ APP . 'views' . DS . $this->viewPath . DS . 'scaffold.index.thtml');
+
+ } elseif (file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.index.thtml')) {
+ return $this->controllerClass->render($this->actionView, '',
+ APP . 'views' . DS . 'scaffold' . DS . 'scaffold.index.thtml');
+ } else {
+ return $this->controllerClass->render($this->actionView, '',
+ LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'index.thtml');
+ }
+ } elseif ($this->controllerClass->_scaffoldError('index') === false) {
+ return $this->__scaffoldError();
+ }
+ }
+/**
+ * Renders an Add or Edit view for scaffolded Model.
+ *
+ * @param array $params
+ * @param string $params add or edit
+ * @return A rendered view with a form to edit or add a record in the Models database table
+ * @access private
+ */
+ function __scaffoldForm($params = array(), $type) {
+ $thtml = 'edit';
+ $form = 'Edit';
+
+ if ($type === 'add') {
+ $thtml = 'add';
+ $form = 'Add';
+ }
+
+ if ($this->controllerClass->_beforeScaffold($type)) {
+ if ($type == 'edit') {
+
+ if (isset($params['pass'][0])) {
+ $this->controllerClass->{$this->modelKey}->id = $params['pass'][0];
+
+ } elseif (isset($this->controllerClass->Session) && $this->controllerClass->Session->valid() != false) {
+ $this->controllerClass->Session->setFlash('No id set for ' . Inflector::humanize($this->modelKey) . '::edit().');
+ $this->controllerClass->redirect('/' . Inflector::underscore($this->controllerClass->viewPath));
+
+ } else {
+ return $this->controllerClass->flash('No id set for ' . Inflector::humanize($this->modelKey) . '::edit().',
+ '/' . Inflector::underscore($this->controllerClass->viewPath));
+ }
+
+ $this->controllerClass->params['data']=$this->controllerClass->{$this->modelKey}->read();
+ $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(
+ $this->controllerClass->params['data']));
+ $this->controllerClass->set('data', $this->controllerClass->params['data']);
+ } else {
+ $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames());
+ }
+ $this->controllerClass->set('type', $form);
+
+ if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffold.' . $thtml . '.thtml')) {
+ return $this->controllerClass->render($this->actionView, '',
+ APP . 'views' . DS . $this->viewPath . DS . 'scaffold.' . $thtml . '.thtml');
+ } elseif (file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $thtml . '.thtml')) {
+ return $this->controllerClass->render($this->actionView, '',
+ APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $thtml . '.thtml');
+ } else {
+ return $this->controllerClass->render($this->actionView, '',
+ LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'edit.thtml');
+ }
+ } elseif ($this->controllerClass->_scaffoldError($type) === false) {
+ return $this->__scaffoldError();
+ }
+ }
+/**
+ * Saves or updates a model.
+ *
+ * @param array $params
+ * @param string $type create or update
+ * @return success on save/update, add/edit form if data is empty or error if save or update fails
+ * @access private
+ */
+ function __scaffoldSave($params = array(), $type) {
+ $thtml = 'edit';
+ $form = 'Edit';
+ $success = 'updated';
+ $formError = 'edit';
+
+ if ($this->controllerClass->_beforeScaffold($type)) {
+ if (empty($this->controllerClass->params['data'])) {
+ if ($type === 'create') {
+ $formError = 'add';
+ }
+ return $this->__scaffoldForm($params, $formError);
+ }
+ $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames());
+ $this->controllerClass->cleanUpFields();
+
+ if ($type == 'create') {
+ $this->controllerClass->{$this->modelKey}->create();
+ $thtml = 'add';
+ $form = 'Add';
+ $success = 'saved';
+ }
+
+ if ($this->controllerClass->{$this->modelKey}->save($this->controllerClass->params['data'])) {
+
+ if ($this->controllerClass->_afterScaffoldSave($type)) {
+
+ if (isset($this->controllerClass->Session) && $this->controllerClass->Session->valid() != false) {
+ $this->controllerClass->Session->setFlash('The ' . Inflector::humanize($this->modelKey) . ' has been ' . $success . '.');
+ $this->controllerClass->redirect('/' . Inflector::underscore($this->controllerClass->viewPath));
+ } else {
+ return $this->controllerClass->flash('The ' . Inflector::humanize($this->modelKey) . ' has been ' . $success . '.',
+ '/' . Inflector::underscore($this->controllerClass->viewPath));
+ }
+ } else {
+ return $this->controllerClass->_afterScaffoldSaveError($type);
+ }
+ } else {
+ if (isset($this->controllerClass->Session) && $this->controllerClass->Session->valid() != false) {
+ $this->controllerClass->Session->setFlash('Please correct errors below.');
+ }
+ $this->controllerClass->set('data', $this->controllerClass->params['data']);
+ $this->controllerClass->set('fieldNames',
+ $this->controllerClass->generateFieldNames($this->__rebuild($this->controllerClass->params['data'])));
+ $this->controllerClass->validateErrors($this->controllerClass->{$this->modelKey});
+ $this->controllerClass->set('type', $form);
+
+ if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffold.' . $thtml . '.thtml')) {
+ return $this->controllerClass->render($this->actionView, '',
+ APP . 'views' . DS . $this->viewPath . DS . 'scaffold.' . $thtml . '.thtml');
+ } elseif (file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $thtml . '.thtml')) {
+ return $this->controllerClass->render($this->actionView, '',
+ APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $thtml . '.thtml');
+ } else {
+ return $this->controllerClass->render($this->actionView, '',
+ LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'edit.thtml');
+ }
+ }
+ } elseif ($this->controllerClass->_scaffoldError($type) === false) {
+ return $this->__scaffoldError();
+ }
+ }
+/**
+ * Performs a delete on given scaffolded Model.
+ *
+ * @param array $params
+ * @return success on delete error if delete fails
+ * @access private
+ */
+ function __scaffoldDelete($params = array()) {
+ if ($this->controllerClass->_beforeScaffold('delete')) {
+ $id = $params['pass'][0];
+
+ if ($this->controllerClass->{$this->modelKey}->del($id)) {
+
+ if (isset($this->controllerClass->Session) && $this->controllerClass->Session->valid() != false) {
+ $this->controllerClass->Session->setFlash('The ' . Inflector::humanize($this->modelKey) . ' with id: ' . $id . ' has been deleted.');
+ $this->controllerClass->redirect('/' . Inflector::underscore($this->controllerClass->viewPath));
+ } else {
+ return $this->controllerClass->flash('The ' . Inflector::humanize($this->modelKey) . ' with id: ' . $id . ' has been deleted.',
+ '/' . Inflector::underscore($this->controllerClass->viewPath));
+ }
+ } else {
+ if (isset($this->controllerClass->Session) && $this->controllerClass->Session->valid() != false) {
+ $this->controllerClass->Session->setFlash('There was an error deleting the ' . Inflector::humanize($this->modelKey) . ' with the id ' . $id);
+ $this->controllerClass->redirect('/' . Inflector::underscore($this->controllerClass->viewPath));
+ } else {
+ return $this->controllerClass->flash('There was an error deleting the ' . Inflector::humanize($this->modelKey) . ' with the id ' . $id,
+ '/' . Inflector::underscore($this->controllerClass->viewPath));
+ }
+ }
+ } elseif ($this->controllerClass->_scaffoldError('delete') === false) {
+ return $this->__scaffoldError();
+ }
+ }
+/**
+ * Enter description here...
+ *
+ * @return unknown
+ */
+ function __scaffoldError() {
+ if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffold.error.thtml')) {
+ return $this->controllerClass->render($this->actionView, '',
+ APP . 'views' . DS . $this->viewPath . DS . 'scaffold.error.thtml');
+ } elseif (file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.error.thtml')) {
+ return $this->controllerClass->render($this->actionView, '',
+ APP . 'views' . DS . 'scaffold' . DS . 'scaffold.error.thtml');
+ } else {
+ return $this->controllerClass->render($this->actionView, '',
+ LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . 'scaffold_error.thtml');
+ }
+ }
+/**
+ * When forms are submited the arrays need to be rebuilt if
+ * an error occured, here the arrays are rebuilt to structure needed
+ *
+ * @param array $params data passed to forms
+ * @return array rebuilds the association arrays to pass back to Controller::generateFieldNames()
+ */
+ function __rebuild($params) {
+ foreach ($params as $model => $field) {
+ if (!empty($field) && is_array($field)) {
+ $match = array_keys($field);
+
+ if ($model == $match[0]) {
+ $count = 0;
+
+ foreach ($field[$model] as $value) {
+ $params[$model][$count][$this->controllerClass->{$this->modelKey}->{$model}->primaryKey] = $value;
+ $count++;
+ }
+ unset ($params[$model][$model]);
+ }
+ }
+ }
+ return $params;
+ }
+/**
+ * When methods are now present in a controller
+ * scaffoldView is used to call default Scaffold methods if:
+ * <code>
+ * var $scaffold;
+ * </code>
+ * is placed in the controller's class definition.
+ *
+ * @param string $url
+ * @param string $controller_class
+ * @param array $params
+ * @since Cake v 0.10.0.172
+ * @access private
+ */
+ function __scaffold($params) {
+ if (!in_array('Form', $this->controllerClass->helpers)) {
+ $this->controllerClass->helpers[] = 'Form';
+ }
+ if ($this->controllerClass->constructClasses()) {
+ $db =& ConnectionManager::getDataSource($this->controllerClass->{$this->modelKey}->useDbConfig);
+
+ if (isset($db)) {
+ if ($params['action'] === 'index' || $params['action'] === 'list' || $params['action'] === 'view'
+ || $params['action'] === 'add' || $params['action'] === 'create'
+ || $params['action'] === 'edit' || $params['action'] === 'update'
+ || $params['action'] === 'delete') {
+
+ switch($params['action']) {
+ case 'index':
+ $this->__scaffoldIndex($params);
+ break;
+ case 'view':
+ $this->__scaffoldView($params);
+ break;
+ case 'list':
+ $this->__scaffoldIndex($params);
+ break;
+ case 'add':
+ $this->__scaffoldForm($params, 'add');
+ break;
+ case 'edit':
+ $this->__scaffoldForm($params, 'edit');
+ break;
+ case 'create':
+ $this->__scaffoldSave($params, 'create');
+ break;
+ case 'update':
+ $this->__scaffoldSave($params, 'update');
+ break;
+ case 'delete':
+ $this->__scaffoldDelete($params);
+ break;
+ }
+ } else {
+ return $this->cakeError('missingAction',
+ array(array('className' => Inflector::camelize($params['controller'] . "Controller"),
+ 'base' => $this->controllerClass->base,
+ 'action' => $params['action'],
+ 'webroot' => $this->controllerClass->webroot)));
+ }
+ } else {
+ return $this->cakeError('missingDatabase', array(array('webroot' => $this->controllerClass->webroot)));
+ }
+ } else {
+ return $this->cakeError('missingModel', array(array('className' => $this->modelKey, 'webroot' => '', 'base' => $this->base)));
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/error.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/error.php
new file mode 100644
index 0000000..852e6b4
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/error.php
@@ -0,0 +1,347 @@
+<?php
+/* SVN FILE: $Id: error.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.10.5.1732
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+uses('sanitize');
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class ErrorHandler extends Object {
+ var $controller = null;
+
+/**
+ * Class constructor.
+ *
+ * @param string $method
+ * @param array $messages
+ * @return unknown
+ */
+ function __construct($method, $messages) {
+ parent::__construct();
+ static $__previousError = null;
+ $allow = array('.', '/', '_', ' ', '-', '~');
+ if (substr(PHP_OS,0,3) == "WIN") {
+ $allow = array_merge($allow, array('\\', ':') );
+ }
+ $clean = new Sanitize();
+ $messages = $clean->paranoid($messages, $allow);
+ if (!class_exists('Dispatcher')) {
+ require CAKE . 'dispatcher.php';
+ }
+ $this->__dispatch =& new Dispatcher();
+
+ if ($__previousError != array($method, $messages)) {
+ $__previousError = array($method, $messages);
+
+ if (!class_exists('AppController')) {
+ loadController(null);
+ }
+
+ $this->controller =& new AppController();
+ if (!empty($this->controller->uses)) {
+ $this->controller->constructClasses();
+ }
+ $this->controller->_initComponents();
+ $this->controller->cacheAction = false;
+ $this->__dispatch->start($this->controller);
+
+ if (method_exists($this->controller, 'apperror')) {
+ return $this->controller->appError($method, $messages);
+ }
+ } else {
+ $this->controller =& new Controller();
+ $this->controller->cacheAction = false;
+ }
+ if (Configure::read() > 0 || $method == 'error') {
+ call_user_func_array(array(&$this, $method), $messages);
+ } else {
+ call_user_func_array(array(&$this, 'error404'), $messages);
+ }
+ }
+/**
+ * Displays an error page (e.g. 404 Not found).
+ *
+ * @param array $params
+ */
+ function error($params) {
+ extract($params);
+ $this->controller->base = $base;
+ $this->controller->webroot = $this->_webroot();
+ $this->controller->viewPath='errors';
+ $this->controller->set(array('code' => $code,
+ 'name' => $name,
+ 'message' => $message,
+ 'title' => $code . ' ' . $name));
+ $this->controller->render('error404');
+ exit();
+ }
+/**
+ * Convenience method to display a 404 page.
+ *
+ * @param array $params
+ */
+ function error404($params) {
+ extract($params);
+
+ if (!isset($url)) {
+ $url = $action;
+ }
+ if (!isset($message)) {
+ $message = '';
+ }
+ if (!isset($base)) {
+ $base = '';
+ }
+
+ header("HTTP/1.0 404 Not Found");
+ $this->error(array('code' => '404',
+ 'name' => 'Not found',
+ 'message' => sprintf("The requested address %s was not found on this server.", $url, $message),
+ 'base' => $base));
+ exit();
+ }
+/**
+ * Renders the Missing Controller web page.
+ *
+ * @param array $params
+ */
+ function missingController($params) {
+ extract($params);
+ $this->controller->base = $base;
+ $this->controller->webroot = $webroot;
+ $this->controller->viewPath ='errors';
+ $controllerName = str_replace('Controller', '', $className);
+ $this->controller->set(array('controller' => $className,
+ 'controllerName' => $controllerName,
+ 'title' => 'Missing Controller'));
+ $this->controller->render('missingController');
+ exit();
+ }
+/**
+ * Renders the Missing Action web page.
+ *
+ * @param array $params
+ */
+ function missingAction($params) {
+ extract($params);
+ $this->controller->base = $base;
+ $this->controller->webroot = $webroot;
+ $this->controller->viewPath = 'errors';
+ $this->controller->set(array('controller' => $className,
+ 'action' => $action,
+ 'title' => 'Missing Method in Controller'));
+ $this->controller->render('missingAction');
+ exit();
+ }
+/**
+ * Renders the Private Action web page.
+ *
+ * @param array $params
+ */
+ function privateAction($params) {
+ extract($params);
+ $this->controller->base = $base;
+ $this->controller->webroot = $webroot;
+ $this->controller->viewPath = 'errors';
+ $this->controller->set(array('controller' => $className,
+ 'action' => $action,
+ 'title' => 'Trying to access private method in class'));
+ $this->controller->render('privateAction');
+ exit();
+ }
+/**
+ * Renders the Missing Table web page.
+ *
+ * @param array $params
+ */
+ function missingTable($params) {
+ extract($params);
+ $this->controller->viewPath = 'errors';
+ $this->controller->webroot = $this->_webroot();
+ $this->controller->set(array('model' => $className,
+ 'table' => $table,
+ 'title' => 'Missing Database Table'));
+ $this->controller->render('missingTable');
+ exit();
+ }
+/**
+ * Renders the Missing Database web page.
+ *
+ * @param array $params
+ */
+ function missingDatabase($params = array()) {
+ extract($params);
+ $this->controller->viewPath = 'errors';
+ $this->controller->webroot = $this->_webroot();
+ $this->controller->set(array('title' => 'Scaffold Missing Database Connection'));
+ $this->controller->render('missingScaffolddb');
+ exit();
+ }
+/**
+ * Renders the Missing View web page.
+ *
+ * @param array $params
+ */
+ function missingView($params) {
+ extract($params);
+ $this->controller->base = $base;
+ $this->controller->viewPath = 'errors';
+ $this->controller->webroot = $this->_webroot();
+ $this->controller->set(array('controller' => $className,
+ 'action' => $action,
+ 'file' => $file,
+ 'title' => 'Missing View'));
+ $this->controller->render('missingView');
+ exit();
+ }
+/**
+ * Renders the Missing Layout web page.
+ *
+ * @param array $params
+ */
+ function missingLayout($params) {
+ extract($params);
+ $this->controller->base = $base;
+ $this->controller->viewPath = 'errors';
+ $this->controller->webroot = $this->_webroot();
+ $this->controller->layout = 'default';
+ $this->controller->set(array('file' => $file,
+ 'title' => 'Missing Layout'));
+ $this->controller->render('missingLayout');
+ exit();
+ }
+/**
+ * Renders the Database Connection web page.
+ *
+ * @param array $params
+ */
+ function missingConnection($params) {
+ extract($params);
+ $this->controller->viewPath = 'errors';
+ $this->controller->webroot = $this->_webroot();
+ $this->controller->set(array('model' => $className,
+ 'title' => 'Missing Database Connection'));
+ $this->controller->render('missingConnection');
+ exit();
+ }
+/**
+ * Renders the Missing Helper file web page.
+ *
+ * @param array $params
+ */
+ function missingHelperFile($params) {
+ extract($params);
+ $this->controller->base = $base;
+ $this->controller->viewPath = 'errors';
+ $this->controller->webroot = $this->_webroot();
+ $this->controller->set(array('helperClass' => Inflector::camelize($helper) . "Helper",
+ 'file' => $file,
+ 'title' => 'Missing Helper File'));
+ $this->controller->render('missingHelperFile');
+ exit();
+ }
+/**
+ * Renders the Missing Helper class web page.
+ *
+ * @param array $params
+ */
+ function missingHelperClass($params) {
+ extract($params);
+ $this->controller->base = $base;
+ $this->controller->viewPath = 'errors';
+ $this->controller->webroot = $this->_webroot();
+ $this->controller->set(array('helperClass' => Inflector::camelize($helper) . "Helper",
+ 'file' => $file,
+ 'title' => 'Missing Helper Class'));
+ $this->controller->render('missingHelperClass');
+ exit();
+ }
+/**
+ * Renders the Missing Component file web page.
+ *
+ * @param array $params
+ */
+ function missingComponentFile($params) {
+ extract($params);
+ $this->controller->base = $base;
+ $this->controller->viewPath = 'errors';
+ $this->controller->webroot = $this->_webroot();
+ $this->controller->set(array('controller' => $className,
+ 'component' => $component,
+ 'file' => $file,
+ 'title' => 'Missing Component File'));
+ $this->controller->render('missingComponentFile');
+ exit();
+ }
+/**
+ * Renders the Missing Component class web page.
+ *
+ * @param array $params
+ */
+ function missingComponentClass($params) {
+ extract($params);
+ $this->controller->base = $base;
+ $this->controller->viewPath = 'errors';
+ $this->controller->webroot = $this->_webroot();
+ $this->controller->set(array('controller' => $className,
+ 'component' => $component,
+ 'file' => $file,
+ 'title' => 'Missing Component Class'));
+ $this->controller->render('missingComponentClass');
+ exit();
+ }
+/**
+ * Renders the Missing Model class web page.
+ *
+ * @param unknown_type $params
+ */
+ function missingModel($params) {
+ extract($params);
+ $this->controller->base = $base;
+ $this->controller->viewPath = 'errors';
+ $this->controller->webroot = $this->_webroot();
+ $this->controller->set(array('model' => $className,
+ 'title' => 'Missing Model'));
+ $this->controller->render('missingModel');
+ exit();
+ }
+/**
+ * Path to the web root.
+ *
+ * @return string full web root path
+ */
+ function _webroot() {
+ $this->__dispatch->baseUrl();
+ return $this->__dispatch->webroot;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/file.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/file.php
new file mode 100644
index 0000000..4801226
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/file.php
@@ -0,0 +1,293 @@
+<?php
+/* SVN FILE: $Id: file.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Convenience class for reading, writing and appending to files.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Included libraries.
+ *
+ */
+ if (!class_exists('Object')) {
+ uses ('object');
+ }
+
+ if (!class_exists('Folder')) {
+ uses ('folder');
+ }
+/**
+ * Convenience class for reading, writing and appending to files.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+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 __construct($path, $create = false) {
+ parent::__construct();
+ $this->folder = new Folder(dirname($path), $create);
+ $this->name = basename($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() {
+ $contents = file_get_contents($this->getFullPath());
+ return $contents;
+ }
+/**
+ * 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;
+ }
+/**
+ * Returns the Filesize, either in bytes or in human-readable format.
+ *
+ * @param boolean $humanReadeble Data to write to this File.
+ * @return string|int filesize as int or as a human-readable string
+ */
+ function getSize() {
+ $size = filesize($this->getFullPath());
+ return $size;
+ }
+/**
+ * Returns the File extension.
+ *
+ * @return string The Fileextension
+ */
+ function getExt() {
+ $ext = '';
+ $parts = explode('.', $this->getName());
+
+ if (count($parts) > 1) {
+ $ext = array_pop($parts);
+ } else {
+ $ext = '';
+ }
+ return $ext;
+ }
+/**
+ * Returns the filename.
+ *
+ * @return string The Filename
+ */
+ function getName() {
+ return $this->name;
+ }
+/**
+ * Returns the File's owner.
+ *
+ * @return int the Fileowner
+ */
+ function getOwner() {
+ $fileowner = fileowner($this->getFullPath());
+ return $fileowner;
+ }
+/**
+ * Returns the File group.
+ *
+ * @return int the Filegroup
+ */
+ function getGroup() {
+ $filegroup = filegroup($this->getFullPath());
+ return $filegroup;
+ }
+/**
+ * Creates the File.
+ *
+ * @return boolean Success
+ */
+ 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;
+ }
+ }
+/**
+ * Returns true if the File exists.
+ *
+ * @return boolean
+ */
+ function exists() {
+ $exists = file_exists($this->getFullPath());
+ return $exists;
+ }
+/**
+ * Deletes the File.
+ *
+ * @return boolean
+ */
+ function delete() {
+ $unlink = unlink($this->getFullPath());
+ return $unlink;
+ }
+/**
+ * Returns true if the File is writable.
+ *
+ * @return boolean
+ */
+ function writable() {
+ $writable = is_writable($this->getFullPath());
+ return $writable;
+ }
+/**
+ * Returns true if the File is executable.
+ *
+ * @return boolean
+ */
+ function executable() {
+ $executable = is_executable($this->getFullPath());
+ return $executable;
+ }
+/**
+ * Returns true if the File is readable.
+ *
+ * @return boolean
+ */
+ function readable() {
+ $readable = is_readable($this->getFullPath());
+ return $readable;
+ }
+/**
+ * Returns last access time.
+ *
+ * @return int timestamp
+ */
+ function lastAccess() {
+ $fileatime = fileatime($this->getFullPath());
+ return $fileatime;
+ }
+/**
+ * Returns last modified time.
+ *
+ * @return int timestamp
+ */
+ function lastChange() {
+ $filemtime = filemtime($this->getFullPath());
+ return $filemtime;
+ }
+/**
+ * Returns the current folder.
+ *
+ * @return Folder
+ */
+ function getFolder() {
+ return $this->folder;
+ }
+/**
+ * Returns the "chmod" (permissions) of the File.
+ *
+ * @return string
+ */
+ function getChmod() {
+ $substr = substr(sprintf('%o', fileperms($this->getFullPath())), -4);
+ return $substr;
+ }
+/**
+ * Returns the full path of the File.
+ *
+ * @return string
+ */
+ function getFullPath() {
+ return $this->folder->slashTerm($this->folder->pwd()) . $this->getName();
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/flay.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/flay.php
new file mode 100644
index 0000000..dfe105f
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/flay.php
@@ -0,0 +1,278 @@
+<?php
+/* SVN FILE: $Id: flay.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Text-to-HTML parser.
+ *
+ * Text-to-html parser, similar to {@link http://textism.com/tools/textile/ Textile} or {@link http://www.whytheluckystiff.net/ruby/redcloth/ RedCloth}.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Included libraries.
+ *
+ */
+ if (!class_exists('Object')) {
+ uses ('object');
+ }
+/**
+ * Text-to-HTML parser.
+ *
+ * Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class Flay extends Object{
+/**
+ * Text to be parsed.
+ *
+ * @var string
+ */
+ var $text = null;
+/**
+ * Set this to allow HTML in the markup.
+ *
+ * @var boolean
+ */
+ var $allow_html = false;
+/**
+ * Constructor.
+ *
+ * @param string $text
+ */
+ function __construct($text = null) {
+ $this->text = $text;
+ parent::__construct();
+ }
+/**
+ * Returns given text translated to HTML using the Flay syntax.
+ *
+ * @param string $text String to format
+ * @param boolean $bare Set this to only do <p> transforms and > to &gt;, no typography additions.
+ * @param boolean $allowHtml Set this to trim whitespace and disable all HTML
+ * @return string Formatted text
+ */
+ function toHtml($text = null, $bare = false, $allowHtml = false) {
+ if (empty($text) && empty($this->text)) {
+ return false;
+ }
+ $text = $text ? $text : $this->text;
+ // trim whitespace and disable all HTML
+ if ($allowHtml) {
+ $text = trim($text);
+ } else {
+ $text = str_replace('<', '&lt;', str_replace('>', '&gt;', trim($text)));
+ }
+
+ if (!$bare) {
+ // multi-paragraph functions
+ $text=preg_replace('#(?:[\n]{0,2})"""(.*)"""(?:[\n]{0,2})#s', "\n\n%BLOCKQUOTE%\n\n\\1\n\n%ENDBLOCKQUOTE%\n\n", $text);
+ $text=preg_replace('#(?:[\n]{0,2})===(.*)===(?:[\n]{0,2})#s', "\n\n%CENTER%\n\n\\1\n\n%ENDCENTER%\n\n", $text);
+ }
+
+ // pre-parse newlines
+ $text=preg_replace("#\r\n#", "\n", $text);
+ $text=preg_replace("#[\n]{2,}#", "%PARAGRAPH%", $text);
+ $text=preg_replace('#[\n]{1}#', "%LINEBREAK%", $text);
+ $out ='';
+
+ foreach (split('%PARAGRAPH%', $text)as $line) {
+ if ($line) {
+ if (!$bare) {
+ $links = array();
+ $regs = null;
+
+ if (preg_match_all('#\[([^\[]{4,})\]#', $line, $regs)) {
+ foreach ($regs[1] as $reg) {
+ $links[] = $reg;
+ $line = str_replace("[{$reg}]", '%LINK' . (count($links) - 1) . '%', $line);
+ }
+ }
+ // bold
+ $line = ereg_replace("\*([^\*]*)\*", "<strong>\\1</strong>", $line);
+ // italic
+ $line = ereg_replace("_([^_]*)_", "<em>\\1</em>", $line);
+ }
+ // entities
+ $line = str_replace(' - ', ' &ndash; ', $line);
+ $line = str_replace(' -- ', ' &mdash; ', $line);
+ $line = str_replace('(C)', '&copy;', $line);
+ $line = str_replace('(R)', '&reg;', $line);
+ $line = str_replace('(TM)', '&trade;', $line);
+ // guess e-mails
+ $emails = null;
+ if (preg_match_all("#([_A-Za-z0-9+-+]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#", $line, $emails)) {
+ foreach ($emails[1] as $email) {
+ $line = str_replace($email, "<a href=\"mailto:{$email}\">{$email}</a>", $line);
+ }
+ }
+
+ if (!$bare) {
+ $urls = null;
+ if (preg_match_all("#((?:http|https|ftp|nntp)://[^ ]+)#", $line, $urls)) {
+ foreach ($urls[1] as $url) {
+ $line = str_replace($url, "<a href=\"{$url}\">{$url}</a>", $line);
+ }
+ }
+
+ if (preg_match_all("#(www\.[^\n\%\ ]+[^\n\%\,\.\ ])#", $line, $urls)) {
+ foreach ($urls[1] as $url) {
+ $line = str_replace($url, "<a href=\"http://{$url}\">{$url}</a>", $line);
+ }
+ }
+
+ if (count($links)) {
+ for ($ii = 0; $ii < count($links); $ii++) {
+ if (preg_match("#^(http|https|ftp|nntp)://#", $links[$ii])) {
+ $prefix = null;
+ } else {
+ $prefix = 'http://';
+ }
+ if (preg_match('#^[^\ ]+\.(jpg|jpeg|gif|png)$#', $links[$ii])) {
+ $with = "<img src=\"{$prefix}{$links[$ii]}\" alt=\"\" />";
+ } elseif (preg_match('#^([^\]\ ]+)(?:\ ([^\]]+))?$#', $links[$ii], $regs)) {
+ if (isset($regs[2])) {
+ if (preg_match('#\.(jpg|jpeg|gif|png)$#', $regs[2])) {
+ $body = "<img src=\"{$prefix}{$regs[2]}\" alt=\"\" />";
+ } else {
+ $body = $regs[2];
+ }
+ } else {
+ $body = $links[$ii];
+ }
+ $with = "<a href=\"{$prefix}{$regs[1]}\" target=\"_blank\">{$body}</a>";
+ } else {
+ $with = $prefix . $links[$ii];
+ }
+ $line = str_replace("%LINK{$ii}%", $with, $line);
+ }
+ }
+ }
+ $out .= str_replace('%LINEBREAK%', "<br />\n", "<p>{$line}</p>\n");
+ }
+ }
+
+ if (!$bare) {
+ $out = str_replace('<p>%BLOCKQUOTE%</p>', "<blockquote>", $out);
+ $out = str_replace('<p>%ENDBLOCKQUOTE%</p>', "</blockquote>", $out);
+ $out = str_replace('<p>%CENTER%</p>', "<center>", $out);
+ $out = str_replace('<p>%ENDCENTER%</p>', "</center>", $out);
+ }
+ return $out;
+ }
+/**
+ * Return the words of the string as an array.
+ *
+ * @param string $string
+ * @return array Array of words
+ */
+ function extractWords($string) {
+ $split = preg_split('/[\s,\.:\/="!\(\)<>~\[\]]+/', $string);
+ return $split;
+ }
+/**
+ * Return given string with words in array colorMarked, up to a number of times (defaults to 5).
+ *
+ * @param array $words Words to look for and markup
+ * @param string $string String to look in
+ * @param integer $max_snippets Max number of snippets to extract
+ * @return string
+ * @see colorMark
+ */
+ function markedSnippets($words, $string, $max_snippets = 5) {
+ $string = strip_tags($string);
+ $snips = array();
+ $rest = $string;
+ foreach ($words as $word) {
+ if (preg_match_all("/[\s,]+.{0,40}{$word}.{0,40}[\s,]+/i", $rest, $r)) {
+ foreach ($r as $result) {
+ $rest = str_replace($result, '', $rest);
+ }
+ $snips = array_merge($snips, $r[0]);
+ }
+ }
+
+ if (count($snips) > $max_snippets) {
+ $snips = array_slice($snips, 0, $max_snippets);
+ }
+ $joined = join(' <b>...</b> ', $snips);
+ $snips = $joined ? "<b>...</b> {$joined} <b>...</b>" : substr($string, 0, 80) . '<b>...</b>';
+ return $this->colorMark($words, $snips);
+ }
+/**
+ * Returns string with EM elements with color classes added.
+ *
+ * @param array $words Array of words to be colorized
+ * @param string $string Text in which the words might be found
+ * @return string
+ */
+ function colorMark($words, $string) {
+ $colors=array('yl', 'gr', 'rd', 'bl', 'fu', 'cy');
+ $nextColorIndex = 0;
+ foreach ($words as $word) {
+ $string = preg_replace("/({$word})/i", '<em class="' . $colors[$nextColorIndex % count($colors)] . "\">\\1</em>", $string);
+ $nextColorIndex++;
+ }
+ return $string;
+ }
+/**
+ * Returns given text with tags stripped out.
+ *
+ * @param string $text
+ * @return string
+ */
+ function toClean($text) {
+ $strip = strip_tags(html_entity_decode($text, ENT_QUOTES));
+ return $strip;
+ }
+/**
+ * Return parsed text with tags stripped out.
+ *
+ * @param string $text
+ * @return string
+ */
+ function toParsedAndClean($text) {
+ return $this->toClean(Flay::toHtml($text));
+ }
+/**
+ * Return a fragment of a text, up to $length characters long, with an ellipsis after it.
+ *
+ * @param string $text Text to be truncated.
+ * @param integer $length Max length of text.
+ * @param string $ellipsis Sign to print after truncated text.
+ * @return string
+ */
+ function fragment($text, $length, $ellipsis = '...') {
+ $soft = $length - 5;
+ $hard = $length + 5;
+ $rx = '/(.{' . $soft . ',' . $hard . '})[\s,\.:\/="!\(\)<>~\[\]]+.*/';
+
+ if (preg_match($rx, $text, $r)) {
+ $out = $r[1];
+ } else {
+ $out = substr($text, 0, $length);
+ }
+ $out = $out . (strlen($out) < strlen($text) ? $ellipsis : null);
+ return $out;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/folder.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/folder.php
new file mode 100644
index 0000000..331abee
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/folder.php
@@ -0,0 +1,328 @@
+<?php
+/* SVN FILE: $Id: folder.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Convenience class for handling directories.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Included libraries.
+ *
+ */
+ if (!class_exists('Object')) {
+ uses ('object');
+ }
+/**
+ * Folder structure browser, lists folders and files.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class Folder extends Object{
+/**
+ * Path to Folder.
+ *
+ * @var string
+ */
+ var $path = null;
+/**
+ * Sortedness.
+ *
+ * @var boolean
+ */
+ var $sort = false;
+/**
+ * Constructor.
+ *
+ * @param string $path
+ * @param boolean $path
+ */
+ function __construct($path = false, $create = false, $mode = false) {
+ parent::__construct();
+ if (empty($path)) {
+ $path = getcwd();
+ }
+
+ if (!file_exists($path) && $create == true) {
+ $this->mkdirr($path, $mode);
+ }
+ $this->cd($path);
+ }
+/**
+ * Return current path.
+ *
+ * @return string Current path
+ */
+ function pwd() {
+ return $this->path;
+ }
+/**
+ * Change directory to $desired_path.
+ *
+ * @param string $desired_path Path to the directory to change to
+ * @return string The new path. Returns false on failure
+ */
+ function cd($desiredPath) {
+ $desiredPath = realpath($desiredPath);
+ $newPath = $this->isAbsolute($desiredPath) ? $desiredPath : $this->addPathElement($this->path, $desiredPath);
+ $isDir = (is_dir($newPath) && file_exists($newPath)) ? $this->path = $newPath : false;
+ return $isDir;
+ }
+/**
+ * Returns an array of the contents of the current directory, or false on failure.
+ * The returned array holds two arrays: one of dirs and one of files.
+ *
+ * @param boolean $sort
+ * @param boolean $noDotFiles
+ * @return array
+ */
+ function ls($sort = true, $noDotFiles = false) {
+ $dirs = $files = array();
+ $dir = opendir($this->path);
+ if ($dir) {
+ while (false !== ($n = readdir($dir))) {
+ 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) {
+ sort ($dirs);
+ sort ($files);
+ }
+ closedir ($dir);
+ }
+ return array($dirs,$files);
+ }
+/**
+ * Returns an array of all matching files in current directory.
+ *
+ * @param string $pattern Preg_match pattern (Defaults to: .*)
+ * @return array
+ */
+ function find($regexp_pattern = '.*') {
+ $data = $this->ls();
+
+ if (!is_array($data)) {
+ return array();
+ }
+
+ list($dirs, $files) = $data;
+ $found = array();
+
+ foreach ($files as $file) {
+ if (preg_match("/^{$regexp_pattern}$/i", $file)) {
+ $found[] = $file;
+ }
+ }
+ return $found;
+ }
+/**
+ * Returns an array of all matching files in and below current directory.
+ *
+ * @param string $pattern Preg_match pattern (Defaults to: .*)
+ * @return array Files matching $pattern
+ */
+ function findRecursive($pattern = '.*') {
+ $startsOn = $this->path;
+ $out = $this->_findRecursive($pattern);
+ $this->cd($startsOn);
+ return $out;
+ }
+/**
+ * Private helper function for findRecursive.
+ *
+ * @param string $pattern
+ * @return array Files matching pattern
+ * @access private
+ */
+ function _findRecursive($pattern) {
+ list($dirs, $files) = $this->ls();
+
+ $found = array();
+ foreach ($files as $file) {
+ if (preg_match("/^{$pattern}$/i", $file)) {
+ $found[] = $this->addPathElement($this->path, $file);
+ }
+ }
+ $start = $this->path;
+ foreach ($dirs as $dir) {
+ $this->cd($this->addPathElement($start, $dir));
+ $found = array_merge($found, $this->findRecursive($pattern));
+ }
+ return $found;
+ }
+/**
+ * Returns true if given $path is a Windows path.
+ *
+ * @param string $path Path to check
+ * @return boolean
+ * @static
+ */
+ function isWindowsPath($path) {
+ $match = preg_match('#^[A-Z]:\\\#i', $path) ? true : false;
+ return $match;
+ }
+/**
+ * Returns true if given $path is an absolute path.
+ *
+ * @param string $path Path to check
+ * @return boolean
+ * @static
+ */
+ function isAbsolute($path) {
+ $match = preg_match('#^\/#', $path) || preg_match('#^[A-Z]:\\\#i', $path);
+ return $match;
+ }
+/**
+ * Returns true if given $path ends in a slash (i.e. is slash-terminated).
+ *
+ * @param string $path Path to check
+ * @return boolean
+ * @static
+ */
+ function isSlashTerm($path) {
+ $match = preg_match('#[\\\/]$#', $path) ? true : false;
+ return $match;
+ }
+/**
+ * Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.)
+ *
+ * @param string $path Path to check
+ * @return string Set of slashes ("\\" or "/")
+ * @static
+ */
+ function correctSlashFor($path) {
+ return $this->isWindowsPath($path) ? '\\' : '/';
+ }
+/**
+ * Returns $path with added terminating slash (corrected for Windows or other OS).
+ *
+ * @param string $path Path to check
+ * @return string
+ * @static
+ */
+function slashTerm($path) {
+ return $path . ($this->isSlashTerm($path) ? null : $this->correctSlashFor($path));
+ }
+/**
+ * Returns $path with $element added, with correct slash in-between.
+ *
+ * @param string $path
+ * @param string $element
+ * @return string
+ * @static
+ */
+ function addPathElement($path, $element) {
+ return $this->slashTerm($path) . $element;
+ }
+/**
+ * Returns true if the File is in a given CakePath.
+ *
+ * @return boolean
+ */
+ function inCakePath($path = '') {
+ $dir = substr($this->slashTerm(ROOT), 0, -1);
+ $newdir = $this->slashTerm($dir . $path);
+ return $this->inPath($newdir);
+ }
+/**
+ * Returns true if the File is in given path.
+ *
+ * @return boolean
+ */
+ function inPath($path = '') {
+ $dir = substr($this->slashTerm($path), 0, -1);
+ $return = preg_match('/^' . preg_quote($this->slashTerm($dir), '/') . '(.*)/', $this->slashTerm($this->pwd()));
+ if ($return == 1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+/**
+ * Create a directory structure recursively.
+ *
+ * @param string $pathname The directory structure to create
+ * @return bool Returns TRUE on success, FALSE on failure
+ */
+ function mkdirr($pathname, $mode = null) {
+ if (is_dir($pathname) || empty($pathname)) {
+ return true;
+ }
+
+ if (is_file($pathname)) {
+ trigger_error('mkdirr() File exists', E_USER_WARNING);
+ return false;
+ }
+ $nextPathname = substr($pathname, 0, strrpos($pathname, DIRECTORY_SEPARATOR));
+
+ if ($this->mkdirr($nextPathname, $mode)) {
+ if (!file_exists($pathname)) {
+ umask (0);
+ $mkdir = mkdir($pathname, $mode);
+ return $mkdir;
+ }
+ }
+ return false;
+ }
+/**
+ * Returns the size in bytes of this Folder.
+ *
+ * @param string $directory Path to directory
+ */
+ function dirsize() {
+ $size = 0;
+ $directory = $this->slashTerm($this->path);
+ $stack = array($directory);
+ $count = count($stack);
+ for ($i = 0, $j = $count; $i < $j; ++$i) {
+ if (is_file($stack[$i])) {
+ $size += filesize($stack[$i]);
+ } elseif (is_dir($stack[$i])) {
+ $dir = dir($stack[$i]);
+
+ while (false !== ($entry = $dir->read())) {
+ if ($entry == '.' || $entry == '..') {
+ continue;
+ }
+ $add = $stack[$i] . $entry;
+
+ if (is_dir($stack[$i] . $entry)) {
+ $add = $this->slashTerm($add);
+ }
+ $stack[ ]= $add;
+ }
+ $dir->close();
+ }
+ $j = count($stack);
+ }
+ return $size;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/inflector.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/inflector.php
new file mode 100644
index 0000000..edf91c5
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/inflector.php
@@ -0,0 +1,437 @@
+<?php
+/* SVN FILE: $Id: inflector.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * Pluralize and singularize English words.
+ *
+ * Used by Cake's naming conventions throughout the framework.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Included libraries.
+ *
+ */
+ if (!class_exists('Object')) {
+ uses('object');
+ }
+ uses('Set');
+/**
+ * Pluralize and singularize English words.
+ *
+ * Inflector pluralizes and singularizes English nouns.
+ * Used by Cake's naming conventions throughout the framework.
+ * Test with $i = new Inflector(); $i->test();
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class Inflector extends Object {
+/**
+ * Constructor.
+ *
+ */
+ function __construct() {
+ parent::__construct();
+ }
+/**
+ * Gets a reference to the Inflector object instance
+ *
+ * @return object
+ * @access public
+ */
+ function &getInstance() {
+ static $instance = array();
+
+ if (!isset($instance[0]) || !$instance[0]) {
+ $instance[0] =& new Inflector();
+ }
+
+ return $instance[0];
+ }
+/**
+ * Initializes plural inflection rules
+ *
+ * @access protected
+ */
+ function __initPluralRules() {
+ $_this =& Inflector::getInstance();
+ $corePluralRules = array('/(s)tatus$/i' => '\1\2tatuses',
+ '/(quiz)$/i' => '\1zes',
+ '/^(ox)$/i' => '\1\2en',
+ '/([m|l])ouse$/i' => '\1ice',
+ '/(matr|vert|ind)(ix|ex)$/i' => '\1ices',
+ '/(x|ch|ss|sh)$/i' => '\1es',
+ '/([^aeiouy]|qu)y$/i' => '\1ies',
+ '/(hive)$/i' => '\1s',
+ '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
+ '/sis$/i' => 'ses',
+ '/([ti])um$/i' => '\1a',
+ '/(p)erson$/i' => '\1eople',
+ '/(m)an$/i' => '\1en',
+ '/(c)hild$/i' => '\1hildren',
+ '/(buffal|tomat)o$/i' => '\1\2oes',
+ '/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i',
+ '/us$/' => 'uses',
+ '/(alias)$/i' => '\1es',
+ '/(ax|cri|test)is$/i' => '\1es',
+ '/s$/' => 's',
+ '/$/' => 's',);
+
+ $coreUninflectedPlural = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'Amoyese',
+ 'bison', 'Borghese', 'bream', 'breeches', 'britches', 'buffalo', 'cantus', 'carp', 'chassis', 'clippers',
+ 'cod', 'coitus', 'Congoese', 'contretemps', 'corps', 'debris', 'diabetes', 'djinn', 'eland', 'elk',
+ 'equipment', 'Faroese', 'flounder', 'Foochowese', 'gallows', 'Genevese', 'Genoese', 'Gilbertese', 'graffiti',
+ 'headquarters', 'herpes', 'hijinks', 'Hottentotese', 'information', 'innings', 'jackanapes', 'Kiplingese',
+ 'Kongoese', 'Lucchese', 'mackerel', 'Maltese', 'media', 'mews', 'moose', 'mumps', 'Nankingese', 'news',
+ 'nexus', 'Niasese', 'Pekingese', 'People', 'Piedmontese', 'pincers', 'Pistoiese', 'pliers', 'Portuguese', 'proceedings',
+ 'rabies', 'rice', 'rhinoceros', 'salmon', 'Sarawakese', 'scissors', 'sea[- ]bass', 'series', 'Shavese', 'shears',
+ 'siemens', 'species', 'swine', 'testes', 'trousers', 'trout', 'tuna', 'Vermontese', 'Wenchowese',
+ 'whiting', 'wildebeest', 'Yengeese',);
+
+ $coreIrregularPlural = array('atlas' => 'atlases',
+ 'beef' => 'beefs',
+ 'brother' => 'brothers',
+ 'child' => 'children',
+ 'corpus' => 'corpuses',
+ 'cow' => 'cows',
+ 'ganglion' => 'ganglions',
+ 'genie' => 'genies',
+ 'genus' => 'genera',
+ 'graffito' => 'graffiti',
+ 'hoof' => 'hoofs',
+ 'loaf' => 'loaves',
+ 'man' => 'men',
+ 'money' => 'monies',
+ 'mongoose' => 'mongooses',
+ 'move' => 'moves',
+ 'mythos' => 'mythoi',
+ 'numen' => 'numina',
+ 'occiput' => 'occiputs',
+ 'octopus' => 'octopuses',
+ 'opus' => 'opuses',
+ 'ox' => 'oxen',
+ 'penis' => 'penises',
+ 'person' => 'people',
+ 'sex' => 'sexes',
+ 'soliloquy' => 'soliloquies',
+ 'testis' => 'testes',
+ 'trilby' => 'trilbys',
+ 'turf' => 'turfs',);
+
+ $pluralRules = $corePluralRules;
+ $uninflected = $coreUninflectedPlural;
+ $irregular = $coreIrregularPlural;
+
+ if (file_exists(CONFIGS . 'inflections.php')) {
+ include(CONFIGS.'inflections.php');
+ $pluralRules = Set::pushDiff($pluralRules, $corePluralRules);
+ $uninflected = Set::pushDiff($uninflectedPlural, $coreUninflectedPlural);
+ $irregular = Set::pushDiff($irregularPlural, $coreIrregularPlural);
+ }
+ $_this->pluralRules = array('pluralRules' => $pluralRules, 'uninflected' => $uninflected, 'irregular' => $irregular);
+ $_this->pluralized = array();
+ }
+/**
+ * Return $word in plural form.
+ *
+ * @param string $word Word in singular
+ * @return string Word in plural
+ * @access public
+ * @static
+ */
+ function pluralize($word) {
+
+ $_this =& Inflector::getInstance();
+ if (!isset($_this->pluralRules) || empty($_this->pluralRules)) {
+ $_this->__initPluralRules();
+ }
+
+ if (isset($_this->pluralized[$word])) {
+ return $_this->pluralized[$word];
+ }
+
+ extract($_this->pluralRules);
+ if (!isset($regexUninflected) || !isset($regexIrregular)) {
+ $regexUninflected = __enclose(join( '|', $uninflected));
+ $regexIrregular = __enclose(join( '|', array_keys($irregular)));
+ $_this->pluralRules['regexUninflected'] = $regexUninflected;
+ $_this->pluralRules['regexIrregular'] = $regexIrregular;
+ }
+
+ if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) {
+ $_this->pluralized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
+ return $_this->pluralized[$word];
+ }
+
+ if (preg_match('/^(' . $regexUninflected . ')$/i', $word, $regs)) {
+ $_this->pluralized[$word] = $word;
+ return $word;
+ }
+
+ foreach ($pluralRules as $rule => $replacement) {
+ if (preg_match($rule, $word)) {
+ $_this->pluralized[$word] = preg_replace($rule, $replacement, $word);
+ return $_this->pluralized[$word];
+ }
+ }
+ $_this->pluralized[$word] = $word;
+ return $word;
+ }
+/**
+ * Initializes singular inflection rules
+ *
+ * @access protected
+ */
+ function __initSingularRules() {
+
+ $_this =& Inflector::getInstance();
+ $coreSingularRules = array('/(s)tatuses$/i' => '\1\2tatus',
+ '/^(.*)(menu)s$/i' => '\1\2',
+ '/(quiz)zes$/i' => '\\1',
+ '/(matr)ices$/i' => '\1ix',
+ '/(vert|ind)ices$/i' => '\1ex',
+ '/^(ox)en/i' => '\1',
+ '/(alias)(es)*$/i' => '\1',
+ '/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
+ '/(cris|ax|test)es$/i' => '\1is',
+ '/(shoe)s$/i' => '\1',
+ '/(o)es$/i' => '\1',
+ '/ouses$/' => 'ouse',
+ '/uses$/' => 'us',
+ '/([m|l])ice$/i' => '\1ouse',
+ '/(x|ch|ss|sh)es$/i' => '\1',
+ '/(m)ovies$/i' => '\1\2ovie',
+ '/(s)eries$/i' => '\1\2eries',
+ '/([^aeiouy]|qu)ies$/i' => '\1y',
+ '/([lr])ves$/i' => '\1f',
+ '/(tive)s$/i' => '\1',
+ '/(hive)s$/i' => '\1',
+ '/(drive)s$/i' => '\1',
+ '/([^f])ves$/i' => '\1fe',
+ '/(^analy)ses$/i' => '\1sis',
+ '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
+ '/([ti])a$/i' => '\1um',
+ '/(p)eople$/i' => '\1\2erson',
+ '/(m)en$/i' => '\1an',
+ '/(c)hildren$/i' => '\1\2hild',
+ '/(n)ews$/i' => '\1\2ews',
+ '/^(.*us)$/' => '\\1',
+ '/s$/i' => '');
+
+ $coreUninflectedSingular = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', '.*ss', 'Amoyese',
+ 'bison', 'Borghese', 'bream', 'breeches', 'britches', 'buffalo', 'cantus', 'carp', 'chassis', 'clippers',
+ 'cod', 'coitus', 'Congoese', 'contretemps', 'corps', 'debris', 'diabetes', 'djinn', 'eland', 'elk',
+ 'equipment', 'Faroese', 'flounder', 'Foochowese', 'gallows', 'Genevese', 'Genoese', 'Gilbertese', 'graffiti',
+ 'headquarters', 'herpes', 'hijinks', 'Hottentotese', 'information', 'innings', 'jackanapes', 'Kiplingese',
+ 'Kongoese', 'Lucchese', 'mackerel', 'Maltese', 'media', 'mews', 'moose', 'mumps', 'Nankingese', 'news',
+ 'nexus', 'Niasese', 'Pekingese', 'Piedmontese', 'pincers', 'Pistoiese', 'pliers', 'Portuguese', 'proceedings',
+ 'rabies', 'rice', 'rhinoceros', 'salmon', 'Sarawakese', 'scissors', 'sea[- ]bass', 'series', 'Shavese', 'shears',
+ 'siemens', 'species', 'swine', 'testes', 'trousers', 'trout', 'tuna', 'Vermontese', 'Wenchowese',
+ 'whiting', 'wildebeest', 'Yengeese',);
+
+ $coreIrregularSingular = array('atlases' => 'atlas',
+ 'beefs' => 'beef',
+ 'brothers' => 'brother',
+ 'children' => 'child',
+ 'corpuses' => 'corpus',
+ 'cows' => 'cow',
+ 'ganglions' => 'ganglion',
+ 'genies' => 'genie',
+ 'genera' => 'genus',
+ 'graffiti' => 'graffito',
+ 'hoofs' => 'hoof',
+ 'loaves' => 'loaf',
+ 'men' => 'man',
+ 'monies' => 'money',
+ 'mongooses' => 'mongoose',
+ 'moves' => 'move',
+ 'mythoi' => 'mythos',
+ 'numina' => 'numen',
+ 'occiputs' => 'occiput',
+ 'octopuses' => 'octopus',
+ 'opuses' => 'opus',
+ 'oxen' => 'ox',
+ 'penises' => 'penis',
+ 'people' => 'person',
+ 'sexes' => 'sex',
+ 'soliloquies' => 'soliloquy',
+ 'testes' => 'testis',
+ 'trilbys' => 'trilby',
+ 'turfs' => 'turf',);
+
+ $singularRules = $coreSingularRules;
+ $uninflected = $coreUninflectedSingular;
+ $irregular = $coreIrregularSingular;
+
+ if (file_exists(CONFIGS . 'inflections.php')) {
+ include(CONFIGS.'inflections.php');
+ $singularRules = Set::pushDiff($singularRules, $coreSingularRules);
+ $uninflected = Set::pushDiff($uninflectedSingular, $coreUninflectedSingular);
+ $irregular = Set::pushDiff($irregularSingular, $coreIrregularSingular);
+ }
+ $_this->singularRules = array('singularRules' => $singularRules, 'uninflected' => $uninflected, 'irregular' => $irregular);
+ $_this->singularized = array();
+ }
+/**
+ * Return $word in singular form.
+ *
+ * @param string $word Word in plural
+ * @return string Word in singular
+ * @access public
+ * @static
+ */
+ function singularize($word) {
+ $_this =& Inflector::getInstance();
+ if (!isset($_this->singularRules) || empty($_this->singularRules)) {
+ $_this->__initSingularRules();
+ }
+
+ if (isset($_this->singularized[$word])) {
+ return $_this->singularized[$word];
+ }
+
+ extract($_this->singularRules);
+ if (!isset($regexUninflected) || !isset($regexIrregular)) {
+ $regexUninflected = __enclose(join( '|', $uninflected));
+ $regexIrregular = __enclose(join( '|', array_keys($irregular)));
+ $_this->singularRules['regexUninflected'] = $regexUninflected;
+ $_this->singularRules['regexIrregular'] = $regexIrregular;
+ }
+
+ if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) {
+ $_this->singularized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
+ return $_this->singularized[$word];
+ }
+
+ if (preg_match('/^(' . $regexUninflected . ')$/i', $word, $regs)) {
+ $_this->singularized[$word] = $word;
+ return $word;
+ }
+
+ foreach ($singularRules as $rule => $replacement) {
+ if (preg_match($rule, $word)) {
+ $_this->singularized[$word] = preg_replace($rule, $replacement, $word);
+ return $_this->singularized[$word];
+ }
+ }
+ $_this->singularized[$word] = $word;
+ return $word;
+ }
+/**
+ * Returns given $lower_case_and_underscored_word as a camelCased word.
+ *
+ * @param string $lower_case_and_underscored_word Word to camelize
+ * @return string Camelized word. likeThis.
+ * @access public
+ * @static
+ */
+ function camelize($lowerCaseAndUnderscoredWord) {
+ $replace = str_replace(" ", "", ucwords(str_replace("_", " ", $lowerCaseAndUnderscoredWord)));
+ return $replace;
+ }
+/**
+ * Returns an underscore-syntaxed ($like_this_dear_reader) version of the $camel_cased_word.
+ *
+ * @param string $camel_cased_word Camel-cased word to be "underscorized"
+ * @return string Underscore-syntaxed version of the $camel_cased_word
+ * @access public
+ * @static
+ */
+ function underscore($camelCasedWord) {
+ $replace = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord));
+ return $replace;
+ }
+/**
+ * Returns a human-readable string from $lower_case_and_underscored_word,
+ * by replacing underscores with a space, and by upper-casing the initial characters.
+ *
+ * @param string $lower_case_and_underscored_word String to be made more readable
+ * @return string Human-readable string
+ * @access public
+ * @static
+ */
+ function humanize($lowerCaseAndUnderscoredWord) {
+ $replace = ucwords(str_replace("_", " ", $lowerCaseAndUnderscoredWord));
+ return $replace;
+ }
+/**
+ * Returns corresponding table name for given $class_name. ("posts" for the model class "Post").
+ *
+ * @param string $class_name Name of class to get database table name for
+ * @return string Name of the database table for given class
+ * @access public
+ * @static
+ */
+ function tableize($className) {
+ $replace = Inflector::pluralize(Inflector::underscore($className));
+ return $replace;
+ }
+/**
+ * Returns Cake model class name ("Post" for the database table "posts".) for given database table.
+ *
+ * @param string $tableName Name of database table to get class name for
+ * @return string
+ * @access public
+ * @static
+ */
+ function classify($tableName) {
+ $replace = Inflector::camelize(Inflector::singularize($tableName));
+ return $replace;
+ }
+/**
+ * Returns camelBacked version of a string.
+ *
+ * @param string $string
+ * @return string
+ * @access public
+ * @static
+ */
+ function variable($string) {
+ $string = Inflector::camelize(Inflector::underscore($string));
+ $replace = strtolower(substr($string, 0, 1));
+ $variable = preg_replace('/\\w/', $replace, $string, 1);
+ return $variable;
+ }
+/**
+ * Returns a string with all spaces converted to $replacement and non word characters removed.
+ *
+ * @param string $string
+ * @param string $replacement
+ * @return string
+ * @access public
+ * @static
+ */
+ function slug($string, $replacement = '_') {
+ $string = preg_replace(array('/[^\w\s]/', '/\\s+/') , array(' ', $replacement), $string);
+ return $string;
+ }
+}
+/**
+ * Enclose a string for preg matching.
+ *
+ * @param string $string String to enclose
+ * @return string Enclosed string
+ */
+ function __enclose($string) {
+ return '(?:' . $string . ')';
+ }
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/legacy.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/legacy.php
new file mode 100644
index 0000000..3c89b8c
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/legacy.php
@@ -0,0 +1,70 @@
+<?php
+/* SVN FILE: $Id: legacy.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Backwards compatibility functions.
+ *
+ * With this hack you can use clone() in PHP4 code
+ * use "clone($object)" not "clone $object"! the former works in both PHP4 and PHP5
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+ if (version_compare(phpversion(), '5.0') < 0) {
+ if (!function_exists("clone")) {
+ eval ('
+ function clone($object) {
+ return $object;
+ }');
+ }
+ }
+/**
+ * Replace file_get_contents()
+ *
+ * @internal resource_context is not supported
+ * @since PHP 5
+ * require PHP 4.0.0 (user_error)
+ *
+ * @param unknown_type $filename
+ * @param unknown_type $incpath
+ * @return unknown
+ */
+ if (!function_exists('file_get_contents')) {
+ function file_get_contents($filename, $incpath = false) {
+ if (false === $fh = fopen($filename, 'rb', $incpath)) {
+ user_error('file_get_contents() failed to open stream: No such file or directory', E_USER_WARNING);
+ return false;
+ }
+ clearstatcache();
+
+ if ($fsize = @filesize($filename)) {
+ $data = fread($fh, $fsize);
+ } else {
+ $data='';
+
+ while (!feof($fh)) {
+ $data .= fread($fh, 8192);
+ }
+ }
+ fclose ($fh);
+ return $data;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/connection_manager.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/connection_manager.php
new file mode 100644
index 0000000..946327e
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/connection_manager.php
@@ -0,0 +1,243 @@
+<?php
+/* SVN FILE: $Id: connection_manager.php 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model
+ * @since CakePHP(tm) v 0.10.x.1402
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Manages loaded instances of DataSource objects
+ *
+ * Long description for file
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model
+ */
+
+uses ('model' . DS . 'datasources' . DS . 'datasource');
+config('database');
+
+class ConnectionManager extends Object {
+
+/**
+ * Holds a loaded instance of the Connections object
+ *
+ * @var class:Connections
+ * @access public
+ */
+ var $config = null;
+/**
+ * Holds instances DataSource objects
+ *
+ * @var array
+ * @access private
+ */
+ var $_dataSources = array();
+/**
+ * Contains a list of all file and class names used in Connection settings
+ *
+ * @var array
+ * @access private
+ */
+ var $_connectionsEnum = array();
+/**
+ * Constructor.
+ *
+ */
+ function __construct() {
+ if (class_exists('DATABASE_CONFIG')) {
+ $this->config = new DATABASE_CONFIG();
+ }
+ }
+/**
+ * Gets a reference to the ConnectionManger object instance
+ *
+ * @return object
+ */
+ function &getInstance() {
+ static $instance = array();
+
+ if (!isset($instance[0]) || !$instance[0]) {
+ $instance[0] = &new ConnectionManager();
+ }
+
+ return $instance[0];
+ }
+/**
+ * Gets a reference to a DataSource object
+ *
+ * @param string $name The name of the DataSource, as defined in app/config/connections
+ * @return object
+ */
+ function &getDataSource($name) {
+ $_this =& ConnectionManager::getInstance();
+
+ if (in_array($name, array_keys($_this->_dataSources))) {
+ return $_this->_dataSources[$name];
+ }
+
+ $connections = $_this->enumConnectionObjects();
+ if (in_array($name, array_keys($connections))) {
+ $conn = $connections[$name];
+ $class = $conn['classname'];
+ $_this->loadDataSource($name);
+ $_this->_dataSources[$name] =& new $class($_this->config->{$name});
+ $_this->_dataSources[$name]->configKeyName = $name;
+ } else {
+ trigger_error(sprintf(__("ConnectionManager::getDataSource - Non-existent data source %s", true), $name), E_USER_ERROR);
+ return null;
+ }
+
+ return $_this->_dataSources[$name];
+ }
+/**
+ * Gets a DataSource name from an object reference
+ *
+ * @param object $source
+ * @return string
+ */
+ function getSourceName(&$source) {
+ $_this =& ConnectionManager::getInstance();
+
+ $names = array_keys($_this->_dataSources);
+ for ($i = 0; $i < count($names); $i++) {
+ if ($_this->_dataSources[$names[$i]] === $source) {
+ return $names[$i];
+ }
+ }
+ return null;
+ }
+/**
+ * Loads the DataSource class for the given connection name
+ *
+ * @param mixed $connName A string name of the connection, as defined in Connections config,
+ * or an array containing the file and class name of the object.
+ * @return boolean True on success, null on failure or false if the class is already loaded
+ */
+ function loadDataSource($connName) {
+ $_this =& ConnectionManager::getInstance();
+
+ if (is_array($connName)) {
+ $conn = $connName;
+ } else {
+ $connections = $_this->enumConnectionObjects();
+ $conn = $connections[$connName];
+ }
+
+ if (isset($conn['parent']) && !empty($conn['parent'])) {
+ $_this->loadDataSource($conn['parent']);
+ }
+
+ if (class_exists($conn['classname'])) {
+ return false;
+ }
+
+ if (file_exists(MODELS . DS . $conn['filename'] . '.php')) {
+ require (MODELS . DS . $conn['filename'] . '.php');
+ } elseif (fileExistsInPath(LIBS . 'model' . DS . $conn['filename'] . '.php')) {
+ require (LIBS . 'model' . DS . $conn['filename'] . '.php');
+ } else {
+ trigger_error(sprintf(__('Unable to load DataSource file %s.php', true), $conn['filename']), E_USER_ERROR);
+ return null;
+ }
+ }
+/**
+ * Gets a list of class and file names associated with the user-defined DataSource connections
+ *
+ * @return array An associative array of elements where the key is the connection name
+ * (as defined in Connections), and the value is an array with keys 'filename' and 'classname'.
+ */
+ function enumConnectionObjects() {
+ $_this =& ConnectionManager::getInstance();
+
+ if (!empty($_this->_connectionsEnum)) {
+ return $_this->_connectionsEnum;
+ }
+ $connections = get_object_vars($_this->config);
+
+ if ($connections != null) {
+ foreach ($connections as $name => $config) {
+ $_this->_connectionsEnum[$name] = $_this->__getDriver($config);
+ }
+ return $_this->_connectionsEnum;
+ } else {
+ $_this->cakeError('missingConnection', array(array('className' => 'ConnectionManager')));
+ }
+ }
+/**
+ * Dynamically creates a DataSource object at runtime, with the given name and settings
+ *
+ * @param string $name The DataSource name
+ * @param array $config The DataSource configuration settings
+ * @return object A reference to the DataSource object, or null if creation failed
+ */
+ function &create($name = '', $config = array()) {
+ $_this =& ConnectionManager::getInstance();
+
+ if (empty($name) || empty($config) || array_key_exists($name, $_this->_connectionsEnum)) {
+ $null = null;
+ return $null;
+ }
+
+ $_this->config->{$name} = $config;
+ $_this->_connectionsEnum[$name] = $_this->__getDriver($config);
+ return $_this->getDataSource($name);
+ }
+/**
+ * Private method
+ *
+ * Returns the file and class name for the given driver
+ */
+ function __getDriver($config) {
+ $_this =& ConnectionManager::getInstance();
+
+ if (!isset($config['datasource'])) {
+ $config['datasource'] = 'dbo';
+ }
+
+ if (isset($config['driver']) && $config['driver'] != null && !empty($config['driver'])) {
+ $filename = $config['datasource'] . DS . $config['datasource'] . '_' . $config['driver'];
+ $classname = Inflector::camelize(strtolower($config['datasource'] . '_' . $config['driver']));
+ $parent = $_this->__getDriver(array('datasource' => $config['datasource']));
+ } else {
+ $filename = 'datasources' . DS . $config['datasource'] . '_source';
+ $classname = Inflector::camelize(strtolower($config['datasource'] . '_source'));
+ $parent = null;
+ }
+ return array('filename' => $filename, 'classname' => $classname, 'parent' => $parent);
+ }
+/**
+ * Destructor.
+ *
+ */
+ function __destruct() {
+ if (CAKE_SESSION_SAVE == 'database' && function_exists('session_write_close')) {
+ session_write_close();
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/datasources/datasource.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/datasources/datasource.php
new file mode 100644
index 0000000..a055577
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/datasources/datasource.php
@@ -0,0 +1,519 @@
+<?php
+/* SVN FILE: $Id: datasource.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * DataSource base class
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model.datasources
+ * @since CakePHP(tm) v 0.10.5.1790
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * DataSource base class
+ *
+ * Long description for file
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model.datasources
+ */
+class DataSource extends Object {
+/**
+ * Are we connected to the DataSource?
+ *
+ * @var boolean
+ * @access public
+ */
+ var $connected = false;
+/**
+ * Print debug info?
+ *
+ * @var boolean
+ * @access public
+ */
+ var $debug = false;
+/**
+ * Print full query debug info?
+ *
+ * @var boolean
+ * @access public
+ */
+ var $fullDebug = false;
+/**
+ * Error description of last query
+ *
+ * @var unknown_type
+ * @access public
+ */
+ var $error = null;
+/**
+ * String to hold how many rows were affected by the last SQL operation.
+ *
+ * @var string
+ * @access public
+ */
+ var $affected = null;
+/**
+ * Number of rows in current resultset
+ *
+ * @var int
+ * @access public
+ */
+ var $numRows = null;
+/**
+ * Time the last query took
+ *
+ * @var int
+ * @access public
+ */
+ var $took = null;
+/**
+ * Enter description here...
+ *
+ * @var array
+ * @access private
+ */
+ var $_result = null;
+/**
+ * Queries count.
+ *
+ * @var int
+ * @access private
+ */
+ var $_queriesCnt = 0;
+/**
+ * Total duration of all queries.
+ *
+ * @var unknown_type
+ * @access private
+ */
+ var $_queriesTime = null;
+/**
+ * Log of queries executed by this DataSource
+ *
+ * @var unknown_type
+ * @access private
+ */
+ var $_queriesLog = array();
+/**
+ * Maximum number of items in query log, to prevent query log taking over
+ * too much memory on large amounts of queries -- I we've had problems at
+ * >6000 queries on one system.
+ *
+ * @var int Maximum number of queries in the queries log.
+ * @access private
+ */
+ var $_queriesLogMax = 200;
+/**
+ * Caches serialzed results of executed queries
+ *
+ * @var array Maximum number of queries in the queries log.
+ * @access private
+ */
+ var $_queryCache = array();
+/**
+ * The default configuration of a specific DataSource
+ *
+ * @var array
+ * @access public
+ */
+ var $_baseConfig = array();
+/**
+ * Holds references to descriptions loaded by the DataSource
+ *
+ * @var array
+ * @access private
+ */
+ var $__descriptions = array();
+/**
+ * Holds a list of sources (tables) contained in the DataSource
+ *
+ * @var array
+ * @access protected
+ */
+ var $_sources = null;
+/**
+ * A reference to the physical connection of this DataSource
+ *
+ * @var array
+ * @access public
+ */
+ var $connection = null;
+/**
+ * The DataSource configuration
+ *
+ * @var array
+ * @access public
+ */
+ var $config = array();
+/**
+ * The DataSource configuration key name
+ *
+ * @var string
+ * @access public
+ */
+ var $configKeyName = null;
+/**
+ * Whether or not this DataSource is in the middle of a transaction
+ *
+ * @var boolean
+ * @access protected
+ */
+ var $_transactionStarted = false;
+/**
+ * Enter description here...
+ *
+ * @var boolean
+ */
+ var $cacheSources = true;
+/**
+ * Constructor.
+ */
+ function __construct() {
+ parent::__construct();
+ if (func_num_args() > 0) {
+ $this->setConfig(func_get_arg(0));
+ }
+ }
+/**
+ * Caches/returns cached results for child instances
+ *
+ * @return array
+ */
+ function listSources($data = null) {
+ if ($this->cacheSources === false) {
+ return null;
+ }
+ if ($this->_sources != null) {
+ return $this->_sources;
+ }
+
+ if (Configure::read() > 0) {
+ $expires = "+30 seconds";
+ } else {
+ $expires = "+999 days";
+ }
+
+ if ($data != null) {
+ $data = serialize($data);
+ }
+ $filename = ConnectionManager::getSourceName($this) . '_' . preg_replace("/[^A-Za-z0-9_-]/", "_", $this->config['database']) . '_list';
+ $new = cache('models' . DS . $filename, $data, $expires);
+
+ if ($new != null) {
+ $new = unserialize($new);
+ $this->_sources = $new;
+ }
+ return $new;
+ }
+/**
+ * Convenience method for DboSource::listSources(). Returns source names in lowercase.
+ *
+ * @return array
+ */
+ function sources() {
+ $return = array_map('strtolower', $this->listSources());
+ return $return;
+ }
+/**
+ * Returns a Model description (metadata) or null if none found.
+ *
+ * @param Model $model
+ * @return mixed
+ */
+ function describe($model) {
+ if ($this->cacheSources === false) {
+ return null;
+ }
+ if (isset($this->__descriptions[$model->tablePrefix . $model->table])) {
+ return $this->__descriptions[$model->tablePrefix . $model->table];
+ }
+ $cache = $this->__cacheDescription($model->tablePrefix . $model->table);
+
+ if ($cache !== null) {
+ $this->__descriptions[$model->tablePrefix . $model->table] =& $cache;
+ return $cache;
+ }
+ return null;
+ }
+/**
+ * Begin a transaction to be overridden in subclasses
+ *
+ * @param unknown_type $model
+ * @return boolean True
+ */
+ function begin(&$model) {
+ return true;
+ }
+/**
+ * Commit a transaction to be overridden in subclasses
+ *
+ * @param unknown_type $model
+ * @return boolean True
+ */
+ function commit(&$model) {
+ return true;
+ }
+/**
+ * Rollback a transaction to be overridden in subclasses
+ *
+ * @param unknown_type $model
+ * @return boolean True
+ */
+ function rollback(&$model) {
+ return true;
+ }
+/**
+ * Converts column types to basic types
+ *
+ * @param string $real Real column type (i.e. "varchar(255)")
+ * @return string Abstract column type (i.e. "string")
+ */
+ function column($real) {
+ return false;
+ }
+/**
+ * To-be-overridden in subclasses.
+ *
+ * @param unknown_type $model
+ * @param unknown_type $fields
+ * @param unknown_type $values
+ * @return unknown
+ */
+ function create(&$model, $fields = null, $values = null) {
+ return false;
+ }
+/**
+ * To-be-overridden in subclasses.
+ *
+ * @param unknown_type $model
+ * @param unknown_type $queryData
+ * @return unknown
+ */
+ function read(&$model, $queryData = array()) {
+ return false;
+ }
+/**
+ * To-be-overridden in subclasses.
+ *
+ * @param unknown_type $model
+ * @param unknown_type $fields
+ * @param unknown_type $values
+ * @return unknown
+ */
+ function update(&$model, $fields = null, $values = null) {
+ return false;
+ }
+/**
+ * To-be-overridden in subclasses.
+ *
+ * @param unknown_type $model
+ * @param unknown_type $id
+ */
+ function delete(&$model, $id = null) {
+ if ($id == null) {
+ $id = $model->id;
+ }
+ }
+/**
+ * Returns the ID generated from the previous INSERT operation.
+ *
+ * @param unknown_type $source
+ * @return in
+ */
+ function lastInsertId($source = null) {
+ return false;
+ }
+/**
+ * Returns the ID generated from the previous INSERT operation.
+ *
+ * @param unknown_type $source
+ * @return in
+ */
+ function lastNumRows($source = null) {
+ return false;
+ }
+/**
+ * Returns the ID generated from the previous INSERT operation.
+ *
+ * @param unknown_type $source
+ * @return in
+ */
+ function lastAffected($source = null) {
+ return false;
+ }
+/**
+ * Returns true if the DataSource supports the given interface (method)
+ *
+ * @param string $interface The name of the interface (method)
+ * @return boolean True on success
+ */
+ function isInterfaceSupported($interface) {
+ $methods = get_class_methods(get_class($this));
+ $methods = strtolower(implode('|', $methods));
+ $methods = explode('|', $methods);
+ $return = in_array(strtolower($interface), $methods);
+ return $return;
+ }
+/**
+ * Sets the configuration for the DataSource
+ *
+ * @param array $config The configuration array
+ * @return void
+ */
+ function setConfig($config) {
+ if (is_array($this->_baseConfig)) {
+ $this->config = $this->_baseConfig;
+ foreach ($config as $key => $val) {
+ $this->config[$key] = $val;
+ }
+ }
+ }
+/**
+ * Cache the DataSource description
+ *
+ * @param string $object The name of the object (model) to cache
+ * @param mixed $data The description of the model, usually a string or array
+ * @return void
+ */
+ function __cacheDescription($object, $data = null) {
+ if ($this->cacheSources === false) {
+ return null;
+ }
+ if (Configure::read() > 0) {
+ $expires = "+15 seconds";
+ } else {
+ $expires = "+999 days";
+ }
+
+ if ($data !== null) {
+ $this->__descriptions[$object] =& $data;
+ $cache = serialize($data);
+ } else {
+ $cache = null;
+ }
+ $new = cache('models' . DS . ConnectionManager::getSourceName($this) . '_' . $object, $cache, $expires);
+
+ if ($new != null) {
+ $new = unserialize($new);
+ }
+ return $new;
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $query
+ * @param unknown_type $data
+ * @param unknown_type $association
+ * @param unknown_type $assocData
+ * @param Model $model
+ * @param Model $linkModel
+ * @param array $stack
+ * @return unknown
+ */
+ function insertQueryData($query, $data, $association, $assocData, &$model, &$linkModel, $stack) {
+ $keys = array('{$__cakeID__$}', '{$__cakeForeignKey__$}');
+
+ foreach ($keys as $key) {
+ $val = null;
+
+ if (strpos($query, $key) !== false) {
+ switch($key) {
+ case '{$__cakeID__$}':
+ if (isset($data[$model->name]) || isset($data[$association])) {
+ if (isset($data[$model->name][$model->primaryKey])) {
+ $val = $data[$model->name][$model->primaryKey];
+ } elseif (isset($data[$association][$model->primaryKey])) {
+ $val = $data[$association][$model->primaryKey];
+ }
+ } else {
+ $found = false;
+ foreach (array_reverse($stack) as $assoc) {
+ if (isset($data[$assoc]) && isset($data[$assoc][$model->primaryKey])) {
+ $val = $data[$assoc][$model->primaryKey];
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) {
+ $val = '';
+ }
+ }
+ break;
+ case '{$__cakeForeignKey__$}':
+ foreach ($model->__associations as $id => $name) {
+ foreach ($model->$name as $assocName => $assoc) {
+ if ($assocName === $association) {
+ if (isset($assoc['foreignKey'])) {
+ $foreignKey = $assoc['foreignKey'];
+
+ if (isset($data[$model->name][$foreignKey])) {
+ $val = $data[$model->name][$foreignKey];
+ } elseif (isset($data[$association][$foreignKey])) {
+ $val = $data[$association][$foreignKey];
+ } else {
+ $found = false;
+ foreach (array_reverse($stack) as $assoc) {
+ if (isset($data[$assoc]) && isset($data[$assoc][$foreignKey])) {
+ $val = $data[$assoc][$foreignKey];
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) {
+ $val = '';
+ }
+ }
+ }
+ break 3;
+ }
+ }
+ }
+ break;
+ }
+ if (empty($val) && $val !== '0') {
+ return false;
+ }
+ $query = r($key, $this->value($val, $model->getColumnType($model->primaryKey)), $query);
+ }
+ }
+ return $query;
+ }
+/**
+ * To-be-overridden in subclasses.
+ *
+ * @param unknown_type $model
+ * @param unknown_type $key
+ * @return unknown
+ */
+ function resolveKey($model, $key) {
+ return $model->name . $key;
+ }
+/**
+ * Closes the current datasource.
+ *
+ */
+ function __destruct() {
+ if ($this->connected) {
+ $this->close();
+ }
+ }
+}
+?>
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/datasources/dbo_source.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/datasources/dbo_source.php
new file mode 100644
index 0000000..8d42ce0
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/datasources/dbo_source.php
@@ -0,0 +1,1967 @@
+<?php
+/* SVN FILE: $Id: dbo_source.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model.datasources
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+uses('set');
+/**
+ * DboSource
+ *
+ * Creates DBO-descendant objects from a given db connection configuration
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model.datasources
+ */
+class DboSource extends DataSource {
+/**
+ * Description string for this Database Data Source.
+ *
+ * @var unknown_type
+ */
+ var $description = "Database Data Source";
+/**
+ * index definition, standard cake, primary, index, unique
+ *
+ * @var array
+ */
+ var $index = array('PRI'=> 'primary', 'MUL'=> 'index', 'UNI'=>'unique');
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $startQuote = null;
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $endQuote = null;
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $alias = 'AS ';
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $goofyLimit = false;
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $__bypass = false;
+/**
+ * The set of valid SQL operations usable in a WHERE statement
+ *
+ * @var array
+ */
+ var $__sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to');
+/**
+ * Constructor
+ */
+ function __construct($config = null, $autoConnect = true) {
+ $this->debug = Configure::read() > 0;
+ $this->fullDebug = Configure::read() > 1;
+ parent::__construct($config);
+
+ if ($autoConnect) {
+ return $this->connect();
+ } else {
+ return true;
+ }
+ }
+/**
+ * Reconnects to database server with optional new settings
+ *
+ * @param array $config An array defining the new configuration settings
+ * @return boolean True on success, false on failure
+ */
+ function reconnect($config = null) {
+ $this->disconnect();
+ if ($config != null) {
+ $this->config = array_merge($this->_baseConfig, $config);
+ }
+ return $this->connect();
+ }
+/**
+ * Prepares a value, or an array of values for database queries by quoting and escaping them.
+ *
+ * @param mixed $data A value or an array of values to prepare.
+ * @return mixed Prepared value or array of values.
+ */
+ function value($data, $column = null) {
+ if (is_array($data)) {
+ $out = array();
+ $keys = array_keys($data);
+ $count = count($data);
+ for ($i = 0; $i < $count; $i++) {
+ $out[$keys[$i]] = $this->value($data[$keys[$i]]);
+ }
+ return $out;
+ } elseif (in_array($data, array('{$__cakeID__$}', '{$__cakeForeignKey__$}'), true)) {
+ return $data;
+ }
+ return null;
+ }
+/**
+ * Executes given SQL statement.
+ *
+ * @param string $sql SQL statement
+ * @return unknown
+ */
+ function rawQuery($sql) {
+ $this->took = $this->error = $this->numRows = false;
+ return $this->execute($sql);
+ }
+/**
+ * Queries the database with given SQL statement, and obtains some metadata about the result
+ * (rows affected, timing, any errors, number of rows in resultset). The query is also logged.
+ * If DEBUG is set, the log is shown all the time, else it is only shown on errors.
+ *
+ * @param string $sql
+ * @return unknown
+ */
+ function execute($sql) {
+ $t = getMicrotime();
+ $this->_result = $this->_execute($sql);
+ $this->affected = $this->lastAffected();
+ $this->took = round((getMicrotime() - $t) * 1000, 0);
+ $this->error = $this->lastError();
+ $this->numRows = $this->lastNumRows($this->_result);
+
+ if ($this->fullDebug && Configure::read() > 1) {
+ $this->logQuery($sql);
+ }
+
+ if ($this->error) {
+ $this->showQuery($sql);
+ return false;
+ } else {
+ return $this->_result;
+ }
+ }
+/**
+ * DataSource Query abstraction
+ *
+ * @return resource Result resource identifier
+ */
+ function query() {
+ $args = func_get_args();
+ $fields = null;
+ $order = null;
+ $limit = null;
+ $page = null;
+ $recursive = null;
+
+ if (count($args) == 1) {
+ return $this->fetchAll($args[0]);
+
+ } elseif (count($args) > 1 && (strpos(strtolower($args[0]), 'findby') === 0 || strpos(strtolower($args[0]), 'findallby') === 0)) {
+ $params = $args[1];
+
+ if (strpos(strtolower($args[0]), 'findby') === 0) {
+ $all = false;
+ $field = Inflector::underscore(preg_replace('/findBy/i', '', $args[0]));
+ } else {
+ $all = true;
+ $field = Inflector::underscore(preg_replace('/findAllBy/i', '', $args[0]));
+ }
+
+ $or = (strpos($field, '_or_') !== false);
+ if ($or) {
+ $field = explode('_or_', $field);
+ } else {
+ $field = explode('_and_', $field);
+ }
+ $off = count($field) - 1;
+
+ if (isset($params[1 + $off])) {
+ $fields = $params[1 + $off];
+ }
+
+ if (isset($params[2 + $off])) {
+ $order = $params[2 + $off];
+ }
+
+ if (!array_key_exists(0, $params)) {
+ return false;
+ }
+
+ $c = 0;
+ $query = array();
+ foreach ($field as $f) {
+ if (!is_array($params[$c]) && !empty($params[$c]) && $params[$c] !== true && $params[$c] !== false) {
+ $query[$args[2]->alias . '.' . $f] = '= ' . $params[$c];
+ } else {
+ $query[$args[2]->alias . '.' . $f] = $params[$c];
+ }
+ $c++;
+ }
+
+ if ($or) {
+ $query = array('OR' => $query);
+ }
+
+ if ($all) {
+
+ if (isset($params[3 + $off])) {
+ $limit = $params[3 + $off];
+ }
+
+ if (isset($params[4 + $off])) {
+ $page = $params[4 + $off];
+ }
+
+ if (isset($params[5 + $off])) {
+ $recursive = $params[5 + $off];
+ }
+ return $args[2]->findAll($query, $fields, $order, $limit, $page, $recursive);
+ } else {
+ if (isset($params[3 + $off])) {
+ $recursive = $params[3 + $off];
+ }
+ return $args[2]->find($query, $fields, $order, $recursive);
+ }
+ } else {
+ if (isset($args[1]) && $args[1] === true) {
+ return $this->fetchAll($args[0], true);
+ }
+ return $this->fetchAll($args[0], false);
+ }
+ }
+/**
+ * Returns a row from current resultset as an array .
+ *
+ * @return array The fetched row as an array
+ */
+ function fetchRow($sql = null) {
+
+ if (!empty($sql) && is_string($sql) && strlen($sql) > 5) {
+ if (!$this->execute($sql)) {
+ return null;
+ }
+ }
+
+ if (is_resource($this->_result) || is_object($this->_result)) {
+ $this->resultSet($this->_result);
+ $resultRow = $this->fetchResult();
+ return $resultRow;
+ } else {
+ return null;
+ }
+ }
+/**
+ * Returns an array of all result rows for a given SQL query.
+ * Returns false if no rows matched.
+ *
+ * @param string $sql SQL statement
+ * @param boolean $cache Enables returning/storing cached query results
+ * @return array Array of resultset rows, or false if no rows matched
+ */
+ function fetchAll($sql, $cache = true, $modelName = null) {
+ if ($cache && isset($this->_queryCache[$sql])) {
+ if (preg_match('/^\s*select/i', $sql)) {
+ return $this->_queryCache[$sql];
+ }
+ }
+
+ if ($this->execute($sql)) {
+ $out = array();
+
+ while ($item = $this->fetchRow()) {
+ $out[] = $item;
+ }
+
+ if ($cache) {
+ if (strpos(trim(strtolower($sql)), 'select') !== false) {
+ $this->_queryCache[$sql] = $out;
+ }
+ }
+ return $out;
+
+ } else {
+ return false;
+ }
+ }
+/**
+ * Returns a single field of the first of query results for a given SQL query, or false if empty.
+ *
+ * @param string $name Name of the field
+ * @param string $sql SQL query
+ * @return unknown
+ */
+ function field($name, $sql) {
+ $data = $this->fetchRow($sql);
+
+ if (!isset($data[$name]) || empty($data[$name])) {
+ return false;
+ } else {
+ return $data[$name];
+ }
+ }
+/**
+ * Returns a quoted name of $data for use in an SQL statement.
+ * Strips fields out of SQL functions before quoting.
+ *
+ * @param string $data
+ * @return string SQL field
+ */
+ function name($data) {
+ if (preg_match_all('/([^(]*)\((.*)\)(.*)/', $data, $fields)) {
+ $fields = Set::extract($fields, '{n}.0');
+ if (!empty($fields[1])) {
+ if (!empty($fields[2])) {
+ return $fields[1] . '(' . $this->name($fields[2]) . ')' . $fields[3];
+ } else {
+ return $fields[1] . '()' . $fields[3];
+ }
+ }
+ }
+ if ($data == '*') {
+ return '*';
+ }
+ $data = $this->startQuote . str_replace('.', $this->endQuote . '.' . $this->startQuote, $data) . $this->endQuote;
+ $data = str_replace($this->startQuote . $this->startQuote, $this->startQuote, $data);
+
+ if (!empty($this->endQuote) && $this->endQuote == $this->startQuote) {
+ $oddMatches = substr_count($data, $this->endQuote);
+ if ($oddMatches % 2 == 1) {
+ $data = trim($data, $this->endQuote);
+ }
+ }
+ return str_replace($this->endQuote . $this->endQuote, $this->endQuote, $data);
+ }
+/**
+ * Checks if it's connected to the database
+ *
+ * @return boolean True if the database is connected, else false
+ */
+ function isConnected() {
+ return $this->connected;
+ }
+/**
+ * Outputs the contents of the queries log.
+ *
+ * @param boolean $sorted
+ */
+ function showLog($sorted = false) {
+ if ($sorted) {
+ $log = sortByKey($this->_queriesLog, 'took', 'desc', SORT_NUMERIC);
+ } else {
+ $log = $this->_queriesLog;
+ }
+
+ if ($this->_queriesCnt > 1) {
+ $text = 'queries';
+ } else {
+ $text = 'query';
+ }
+
+ if (php_sapi_name() != 'cli') {
+ print ("<table class=\"cakeSqlLog\" id=\"cakeSqlLog_" . preg_replace('/[^A-Za-z0-9_]/', '_', uniqid(time(), true)) . "\" summary=\"Cake SQL Log\" cellspacing=\"0\" border = \"0\">\n<caption>{$this->_queriesCnt} {$text} took {$this->_queriesTime} ms</caption>\n");
+ print ("<thead>\n<tr><th>Nr</th><th>Query</th><th>Error</th><th>Affected</th><th>Num. rows</th><th>Took (ms)</th></tr>\n</thead>\n<tbody>\n");
+
+ foreach ($log as $k => $i) {
+ print ("<tr><td>" . ($k + 1) . "</td><td>" . h($i['query']) . "</td><td>{$i['error']}</td><td style = \"text-align: right\">{$i['affected']}</td><td style = \"text-align: right\">{$i['numRows']}</td><td style = \"text-align: right\">{$i['took']}</td></tr>\n");
+ }
+ print ("</tbody></table>\n");
+ } else {
+ foreach ($log as $k => $i) {
+ print (($k + 1) . ". {$i['query']} {$i['error']}\n");
+ }
+ }
+ }
+/**
+ * Log given SQL query.
+ *
+ * @param string $sql SQL statement
+ * @todo: Add hook to log errors instead of returning false
+ */
+ function logQuery($sql) {
+ $this->_queriesCnt++;
+ $this->_queriesTime += $this->took;
+ $this->_queriesLog[] = array('query' => $sql,
+ 'error' => $this->error,
+ 'affected' => $this->affected,
+ 'numRows' => $this->numRows,
+ 'took' => $this->took
+ );
+ if (count($this->_queriesLog) > $this->_queriesLogMax) {
+ array_pop($this->_queriesLog);
+ }
+ if ($this->error) {
+ return false;
+ }
+ }
+/**
+ * Output information about an SQL query. The SQL statement, number of rows in resultset,
+ * and execution time in microseconds. If the query fails, an error is output instead.
+ *
+ * @param string $sql Query to show information on.
+ */
+ function showQuery($sql) {
+ $error = $this->error;
+ if (strlen($sql) > 200 && !$this->fullDebug && Configure::read() > 1) {
+ $sql = substr($sql, 0, 200) . '[...]';
+ }
+
+ if (($this->debug || $error) && Configure::read() > 0) {
+ e("<p style = \"text-align:left\"><b>Query:</b> {$sql} ");
+ if ($error) {
+ trigger_error("<span style = \"color:Red;text-align:left\"><b>SQL Error:</b> {$this->error}</span>", E_USER_WARNING);
+ } else {
+ e("<small>[Aff:{$this->affected} Num:{$this->numRows} Took:{$this->took}ms]</small>");
+ }
+ print ('</p>');
+ }
+ }
+/**
+ * Gets full table name including prefix
+ *
+ * @param mixed $model
+ * @param boolean $quote
+ * @return string Full quoted table name
+ */
+ function fullTableName($model, $quote = true) {
+ if (is_object($model)) {
+ $table = $model->tablePrefix . $model->table;
+ } elseif (isset($this->config['prefix'])) {
+ $table = $this->config['prefix'] . strval($model);
+ } else {
+ $table = strval($model);
+ }
+ if ($quote) {
+ return $this->name($table);
+ }
+ return $table;
+ }
+/**
+ * The "C" in CRUD
+ *
+ * @param Model $model
+ * @param array $fields
+ * @param array $values
+ * @return boolean Success
+ */
+ function create(&$model, $fields = null, $values = null) {
+ $fieldInsert = array();
+ $valueInsert = array();
+ $id = null;
+
+ if ($fields == null) {
+ unset($fields, $values);
+ $fields = array_keys($model->data);
+ $values = array_values($model->data);
+ }
+ $count = count($fields);
+
+ for ($i = 0; $i < $count; $i++) {
+ $fieldInsert[] = $this->name($fields[$i]);
+ if ($fields[$i] == $model->primaryKey) {
+ $id = $values[$i];
+ }
+ }
+ $count = count($values);
+
+ for ($i = 0; $i < $count; $i++) {
+ $valueInsert[] = $this->value($values[$i], $model->getColumnType($fields[$i]));
+ }
+
+ if ($this->execute('INSERT INTO ' . $this->fullTableName($model) . ' (' . join(',', $fieldInsert). ') VALUES (' . join(',', $valueInsert) . ')')) {
+ if (empty($id)) {
+ $id = $this->lastInsertId($this->fullTableName($model, false), $model->primaryKey);
+ }
+ $model->setInsertID($id);
+ $model->id = $id;
+ return true;
+ } else {
+ $model->onError();
+ return false;
+ }
+ }
+/**
+ * The "R" in CRUD
+ *
+ * @param Model $model
+ * @param array $queryData
+ * @param integer $recursive Number of levels of association
+ * @return unknown
+ */
+ function read(&$model, $queryData = array(), $recursive = null) {
+
+ $this->__scrubQueryData($queryData);
+ $null = null;
+ $array = array();
+ $linkedModels = array();
+ $this->__bypass = false;
+
+ if ($recursive === null && isset($queryData['recursive'])) {
+ $recursive = $queryData['recursive'];
+ }
+
+ if (!is_null($recursive)) {
+ $_recursive = $model->recursive;
+ $model->recursive = $recursive;
+ }
+
+ if (!empty($queryData['fields'])) {
+ $this->__bypass = true;
+ $queryData['fields'] = $this->fields($model, null, $queryData['fields']);
+ } else {
+ $queryData['fields'] = $this->fields($model);
+ }
+
+ foreach ($model->__associations as $type) {
+ foreach ($model->{$type} as $assoc => $assocData) {
+ if ($model->recursive > -1) {
+ $linkModel =& $model->{$assoc};
+
+ $external = isset($assocData['external']);
+ if ($model->alias == $linkModel->alias && $type != 'hasAndBelongsToMany' && $type != 'hasMany') {
+ if (true === $this->generateSelfAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null)) {
+ $linkedModels[] = $type . '/' . $assoc;
+ }
+ } else {
+ if ($model->useDbConfig == $linkModel->useDbConfig) {
+ if (true === $this->generateAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null)) {
+ $linkedModels[] = $type . '/' . $assoc;
+ }
+ }
+ }
+ }
+ }
+ }
+ // Build final query SQL
+ $query = $this->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null);
+ $resultSet = $this->fetchAll($query, $model->cacheQueries, $model->alias);
+
+ if ($resultSet === false) {
+ $model->onError();
+ return false;
+ }
+
+ $filtered = $this->__filterResults($resultSet, $model);
+
+ if ($model->recursive > 0) {
+ foreach ($model->__associations as $type) {
+ foreach ($model->{$type} as $assoc => $assocData) {
+ $db = null;
+ $linkModel =& $model->{$assoc};
+
+ if (!in_array($type . '/' . $assoc, $linkedModels)) {
+ if ($model->useDbConfig == $linkModel->useDbConfig) {
+ $db =& $this;
+ } else {
+ $db =& ConnectionManager::getDataSource($linkModel->useDbConfig);
+ }
+ } elseif ($model->recursive > 1 && ($type == 'belongsTo' || $type == 'hasOne')) {
+ // Do recursive joins on belongsTo and hasOne relationships
+ $db =& $this;
+ } else {
+ unset ($db);
+ }
+
+ if (isset($db) && $db != null) {
+ $stack = array($assoc);
+ $db->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive - 1, $stack);
+ unset($db);
+ }
+ }
+ }
+ $this->__filterResults($resultSet, $model, $filtered);
+ }
+
+ if (!is_null($recursive)) {
+ $model->recursive = $_recursive;
+ }
+ return $resultSet;
+ }
+/**
+ * Private method. Passes association results thru afterFind filter of corresponding model
+ *
+ * @param unknown_type $results
+ * @param unknown_type $model
+ * @param unknown_type $filtered
+ * @return unknown
+ */
+ function __filterResults(&$results, &$model, $filtered = array()) {
+
+ $filtering = array();
+ $associations = array_merge($model->belongsTo, $model->hasOne, $model->hasMany, $model->hasAndBelongsToMany);
+ $count = count($results);
+
+ for ($i = 0; $i < $count; $i++) {
+ if (is_array($results[$i])) {
+ $keys = array_keys($results[$i]);
+ $count2 = count($keys);
+
+ for ($j = 0; $j < $count2; $j++) {
+ $className = $key = $keys[$j];
+
+ if ($model->alias != $className && !in_array($key, $filtered)) {
+ if (!in_array($key, $filtering)) {
+ $filtering[] = $key;
+ }
+
+ if (isset($model->{$className}) && is_object($model->{$className})) {
+ $data = $model->{$className}->afterFind(array(array($key => $results[$i][$key])), false);
+ }
+ if (isset($data[0][$key])) {
+ $results[$i][$key] = $data[0][$key];
+ }
+ }
+ }
+ }
+ }
+ return $filtering;
+ }
+/**
+ * Enter description here...
+ *
+ * @param Model $model
+ * @param unknown_type $linkModel
+ * @param string $type Association type
+ * @param unknown_type $association
+ * @param unknown_type $assocData
+ * @param unknown_type $queryData
+ * @param unknown_type $external
+ * @param unknown_type $resultSet
+ * @param integer $recursive Number of levels of association
+ * @param array $stack
+ */
+ function queryAssociation(&$model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
+
+ if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
+ if (!isset($resultSet) || !is_array($resultSet)) {
+ if (Configure::read() > 0) {
+ e('<div style = "font: Verdana bold 12px; color: #FF0000">SQL Error in model ' . $model->alias . ': ');
+ if (isset($this->error) && $this->error != null) {
+ e($this->error);
+ }
+ e('</div>');
+ }
+ return null;
+ }
+ $count = count($resultSet);
+
+ if ($type === 'hasMany' && (!isset($assocData['limit']) || empty($assocData['limit']))) {
+ $ins = $fetch = array();
+ for ($i = 0; $i < $count; $i++) {
+ if ($in = $this->insertQueryData('{$__cakeID__$}', $resultSet[$i], $association, $assocData, $model, $linkModel, $stack)) {
+ $ins[] = $in;
+ }
+ }
+
+ if (!empty($ins)) {
+ $query = r('{$__cakeID__$}', join(', ', $ins), $query);
+ $fetch = $this->fetchAll($query, $model->cacheQueries, $model->alias);
+ }
+
+ if (!empty($fetch) && is_array($fetch)) {
+ if ($recursive > 0) {
+
+ foreach ($linkModel->__associations as $type1) {
+ foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
+
+ $deepModel =& $linkModel->{$assocData1['className']};
+ if ($deepModel->alias != $model->alias) {
+ $tmpStack = $stack;
+ $tmpStack[] = $assoc1;
+ if ($linkModel->useDbConfig == $deepModel->useDbConfig) {
+ $db =& $this;
+ } else {
+ $db =& ConnectionManager::getDataSource($deepModel->useDbConfig);
+ }
+ $db->queryAssociation($linkModel, $deepModel, $type1, $assoc1, $assocData1, $queryData, true, $fetch, $recursive - 1, $tmpStack);
+ }
+ }
+ }
+ }
+ }
+ return $this->__mergeHasMany($resultSet, $fetch, $association, $model, $linkModel, $recursive);
+ }
+ for ($i = 0; $i < $count; $i++) {
+
+ $row =& $resultSet[$i];
+ $q = $this->insertQueryData($query, $resultSet[$i], $association, $assocData, $model, $linkModel, $stack);
+
+ if ($q != false) {
+ $fetch = $this->fetchAll($q, $model->cacheQueries, $model->alias);
+ } else {
+ $fetch = null;
+ }
+
+ if (!empty($fetch) && is_array($fetch)) {
+ if ($recursive > 0) {
+
+ foreach ($linkModel->__associations as $type1) {
+ foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
+
+ $deepModel =& $linkModel->{$assocData1['className']};
+ if ($deepModel->alias != $model->alias) {
+ $tmpStack = $stack;
+ $tmpStack[] = $assoc1;
+ if ($linkModel->useDbConfig == $deepModel->useDbConfig) {
+ $db =& $this;
+ } else {
+ $db =& ConnectionManager::getDataSource($deepModel->useDbConfig);
+ }
+ $db->queryAssociation($linkModel, $deepModel, $type1, $assoc1, $assocData1, $queryData, true, $fetch, $recursive - 1, $tmpStack);
+ }
+ }
+ }
+ }
+ $this->__mergeAssociation($resultSet[$i], $fetch, $association, $type);
+ $resultSet[$i][$association] = $linkModel->afterfind($resultSet[$i][$association]);
+
+ } else {
+ $tempArray[0][$association] = false;
+ $this->__mergeAssociation($resultSet[$i], $tempArray, $association, $type);
+ }
+ }
+ }
+ }
+
+ function __mergeHasMany(&$resultSet, $merge, $association, &$model, &$linkModel) {
+ foreach ($resultSet as $i => $value) {
+ $count = 0;
+ $merged[$association] = array();
+ foreach ($merge as $j => $data) {
+ if (isset($value[$model->alias]) && $value[$model->alias][$model->primaryKey] === $data[$association][$model->hasMany[$association]['foreignKey']]) {
+ if (count($data) > 1) {
+ $data = array_merge($data[$association], $data);
+ unset($data[$association]);
+ foreach ($data as $key => $name) {
+ if (is_numeric($key)) {
+ $data[$association][] = $name;
+ unset($data[$key]);
+ }
+ }
+ $merged[$association][] = $data;
+ } else {
+ $merged[$association][] = $data[$association];
+ }
+ }
+ $count++;
+ }
+ if (isset($value[$model->alias])) {
+ $resultSet[$i] = Set::pushDiff($resultSet[$i], $merged);
+ unset($merged);
+ }
+ }
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $data
+ * @param unknown_type $merge
+ * @param unknown_type $association
+ * @param unknown_type $type
+ */
+ function __mergeAssociation(&$data, $merge, $association, $type) {
+
+ if (isset($merge[0]) && !isset($merge[0][$association])) {
+ $association = Inflector::pluralize($association);
+ }
+
+ if ($type == 'belongsTo' || $type == 'hasOne') {
+ if (isset($merge[$association])) {
+ $data[$association] = $merge[$association][0];
+ } else {
+ if (count($merge[0][$association]) > 1) {
+ foreach ($merge[0] as $assoc => $data2) {
+ if ($assoc != $association) {
+ $merge[0][$association][$assoc] = $data2;
+ }
+ }
+ }
+ if (!isset($data[$association])) {
+ if ($merge[0][$association] != null) {
+ $data[$association] = $merge[0][$association];
+ } else {
+ $data[$association] = array();
+ }
+ } else {
+ if (is_array($merge[0][$association])) {
+ foreach ($data[$association] as $k => $v) {
+ if (!is_array($v)) {
+ $dataAssocTmp[$k] = $v;
+ }
+ }
+
+ foreach ($merge[0][$association] as $k => $v) {
+ if (!is_array($v)) {
+ $mergeAssocTmp[$k] = $v;
+ }
+ }
+
+ if (array_keys($merge[0]) === array_keys($data)) {
+ $data[$association][$association] = $merge[0][$association];
+ } else {
+ $diff = Set::diff($dataAssocTmp, $mergeAssocTmp);
+ $data[$association] = array_merge($merge[0][$association], $diff);
+ }
+ }
+ }
+ }
+ } else {
+ if ($merge[0][$association] === false) {
+ if (!isset($data[$association])) {
+ $data[$association] = array();
+ }
+ } else {
+ foreach ($merge as $i => $row) {
+ if (count($row) == 1) {
+ $data[$association][] = $row[$association];
+ } else {
+ $tmp = array_merge($row[$association], $row);
+ unset($tmp[$association]);
+ $data[$association][] = $tmp;
+ }
+ }
+ }
+ }
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $model
+ * @param unknown_type $linkModel
+ * @param unknown_type $type
+ * @param unknown_type $association
+ * @param unknown_type $assocData
+ * @param unknown_type $queryData
+ * @param unknown_type $external
+ * @param unknown_type $resultSet
+ * @return unknown
+ */
+ function generateSelfAssociationQuery(&$model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
+ $alias = $association;
+ if (empty($alias) && !empty($linkModel)) {
+ $alias = $linkModel->alias;
+ }
+
+ if (!isset($queryData['selfJoin'])) {
+ $queryData['selfJoin'] = array();
+
+ $self = array(
+ 'fields' => $this->fields($model, null, $queryData['fields']),
+ 'joins' => array(array(
+ 'table' => $this->fullTableName($linkModel),
+ 'alias' => $alias,
+ 'type' => 'LEFT',
+ 'conditions' => array(
+ $model->escapeField($assocData['foreignKey']) => '{$__cakeIdentifier[' . "{$alias}.{$linkModel->primaryKey}" . ']__$}'))
+ ),
+ 'table' => $this->fullTableName($model),
+ 'alias' => $model->alias,
+ 'limit' => $queryData['limit'],
+ 'offset' => $queryData['offset'],
+ 'conditions'=> $queryData['conditions'],
+ 'order' => $queryData['order']
+ );
+
+ if (!empty($assocData['conditions'])) {
+ $self['joins'][0]['conditions'] = trim($this->conditions(array_merge($self['joins'][0]['conditions'], (array)$assocData['conditions']), true, false));
+ }
+
+ if (!empty($queryData['joins'])) {
+ foreach ($queryData['joins'] as $join) {
+ $self['joins'][] = $join;
+ }
+ }
+
+ if ($this->__bypass === false) {
+ $self['fields'] = array_merge($self['fields'], $this->fields($linkModel, $alias, (isset($assocData['fields']) ? $assocData['fields'] : '')));
+ }
+
+ if (!in_array($self, $queryData['selfJoin'])) {
+ $queryData['selfJoin'][] = $self;
+ return true;
+ }
+
+ } elseif (isset($linkModel)) {
+ return $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet);
+
+ } else {
+ $result = $queryData['selfJoin'][0];
+ if (!empty($queryData['joins'])) {
+ foreach ($queryData['joins'] as $join) {
+ if (!in_array($join, $result['joins'])) {
+ $result['joins'][] = $join;
+ }
+ }
+ }
+ if (!empty($queryData['conditions'])) {
+ $result['conditions'] = trim($this->conditions(array_merge((array)$result['conditions'], $assocData['conditions']), true, false));
+ }
+ if (!empty($queryData['fields'])) {
+ $result['fields'] = array_unique(array_merge($result['fields'], $queryData['fields']));
+ }
+ $sql = $this->buildStatement($result, $model);
+ return $sql;
+ }
+ }
+/**
+ * Enter description here...
+ *
+ * @param Model $model
+ * @param unknown_type $linkModel
+ * @param unknown_type $type
+ * @param unknown_type $association
+ * @param unknown_type $assocData
+ * @param unknown_type $queryData
+ * @param unknown_type $external
+ * @param unknown_type $resultSet
+ * @return unknown
+ */
+ function generateAssociationQuery(&$model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
+ $this->__scrubQueryData($queryData);
+ $this->__scrubQueryData($assocData);
+ $joinedOnSelf = false;
+
+ if (empty($queryData['fields'])) {
+ $queryData['fields'] = $this->fields($model, $model->alias);
+ } elseif (!empty($model->hasMany) && $model->recursive > -1) {
+ $assocFields = $this->fields($model, $model->alias, array("{$model->alias}.{$model->primaryKey}"));
+ $passedFields = $this->fields($model, $model->alias, $queryData['fields']);
+
+ if (count($passedFields) === 1) {
+ $match = strpos($passedFields[0], $assocFields[0]);
+ $match1 = strpos($passedFields[0], 'COUNT(');
+ if ($match === false && $match1 === false) {
+ $queryData['fields'] = array_unique(array_merge($passedFields, $assocFields));
+ } else {
+ $queryData['fields'] = $passedFields;
+ }
+ } else {
+ $queryData['fields'] = array_unique(array_merge($passedFields, $assocFields));
+ }
+ unset($assocFields, $passedFields);
+ }
+
+ if ($linkModel == null) {
+ if (array_key_exists('selfJoin', $queryData)) {
+ return $this->generateSelfAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet);
+ } else {
+ return $this->buildStatement(array(
+ 'fields' => array_unique($queryData['fields']),
+ 'table' => $this->fullTableName($model),
+ 'alias' => $model->alias,
+ 'limit' => $queryData['limit'],
+ 'offset' => $queryData['offset'],
+ 'joins' => $queryData['joins'],
+ 'conditions' => $queryData['conditions'],
+ 'order' => $queryData['order']), $model
+ );
+ }
+ }
+ $alias = $association;
+
+ if ($model->alias == $linkModel->alias) {
+ $joinedOnSelf = true;
+ }
+
+ if ($external && isset($assocData['finderQuery'])) {
+ if (!empty($assocData['finderQuery'])) {
+ return $assocData['finderQuery'];
+ }
+ }
+
+ if ((!$external && in_array($type, array('hasOne', 'belongsTo')) && $this->__bypass === false) || $external) {
+ $fields = $this->fields($linkModel, $alias, $assocData['fields']);
+ } else {
+ $fields = array();
+ }
+ $limit = '';
+
+ if (isset($assocData['limit'])) {
+ if ((!isset($assocData['offset']) || (empty($assocData['offset']))) && isset($assocData['page'])) {
+ $assocData['offset'] = ($assocData['page'] - 1) * $assocData['limit'];
+ } elseif (!isset($assocData['offset'])) {
+ $assocData['offset'] = null;
+ }
+ $limit = $this->limit($assocData['limit'], $assocData['offset']);
+ }
+
+ switch($type) {
+ case 'hasOne':
+ case 'belongsTo':
+ if ($external) {
+ if ($type == 'hasOne') {
+ $conditions = $this->__mergeConditions($assocData['conditions'], array("{$alias}.{$assocData['foreignKey']}" => '{$__cakeID__$}'));
+ } elseif ($type == 'belongsTo') {
+ $conditions = $this->__mergeConditions($assocData['conditions'], array("{$alias}.{$linkModel->primaryKey}" => '{$__cakeForeignKey__$}'));
+ }
+ $query = array_merge($assocData, array(
+ 'conditions' => $conditions,
+ 'table' => $this->fullTableName($linkModel),
+ 'fields' => $fields,
+ 'alias' => $alias
+ ));
+
+ if ($type == 'belongsTo') {
+ // Dunno if we should be doing this for hasOne also...?
+ // Or maybe not doing it at all...?
+ $query = array_merge($query, array('order' => $assocData['order'], 'limit' => $limit));
+ }
+ } else {
+ if ($type == 'hasOne') {
+ $conditions = $this->__mergeConditions($assocData['conditions'], array("{$alias}.{$assocData['foreignKey']}" => '{$__cakeIdentifier[' . "{$model->alias}.{$model->primaryKey}" . ']__$}'));
+ } elseif ($type == 'belongsTo') {
+ $conditions = $this->__mergeConditions($assocData['conditions'], array("{$model->alias}.{$assocData['foreignKey']}" => '{$__cakeIdentifier[' . "{$alias}.{$linkModel->primaryKey}" . ']__$}'));
+ }
+
+ $join = array(
+ 'table' => $this->fullTableName($linkModel),
+ 'alias' => $alias,
+ 'type' => 'LEFT',
+ 'conditions' => trim($this->conditions($conditions, true, false))
+ );
+
+ $queryData['fields'] = array_merge($queryData['fields'], $fields);
+
+ if (!empty($assocData['order'])) {
+ $hasCount = false;
+ foreach ($queryData['fields'] as $field) {
+ if (stripos($field, 'COUNT(*)') !== false) {
+ $hasCount = true;
+ break;
+ }
+ }
+
+ $putOrderByFields = true;
+ if ($hasCount) {
+ $orders = spliti(' ASC| DESC|,', $assocData['order']);
+ foreach ($orders as $order) {
+ $order = trim($order);
+ if (!empty($order) && !in_array($order, $queryData['fields'])) {
+ $putOrderByFields = false;
+ break;
+ }
+ }
+ }
+
+ if ($putOrderByFields) {
+ $queryData['order'][] = $assocData['order'];
+ }
+ }
+
+ if (!in_array($join, $queryData['joins'])) {
+ $queryData['joins'][] = $join;
+ }
+ return true;
+ }
+ break;
+ case 'hasMany':
+ $assocData['fields'] = array_unique(array_merge(
+ $this->fields($linkModel, $alias, $assocData['fields']),
+ $this->fields($linkModel, $alias, array("{$alias}.{$assocData['foreignKey']}"))
+ ));
+
+ $query = array(
+ 'conditions' => $this->__mergeConditions(array("{$alias}.{$assocData['foreignKey']}" => array('{$__cakeID__$}')), $assocData['conditions']),
+ 'fields' => $assocData['fields'],
+ 'table' => $this->fullTableName($linkModel),
+ 'alias' => $alias,
+ 'order' => $assocData['order'],
+ 'limit' => $limit
+ );
+ break;
+ case 'hasAndBelongsToMany':
+ $joinTbl = $this->fullTableName($assocData['joinTable']);
+ $joinFields = array();
+ $joinAssoc = null;
+ $joinAlias = $joinTbl;
+
+ if (isset($assocData['with']) && !empty($assocData['with'])) {
+ $joinAssoc = $joinAlias = $model->{$assocData['with']}->name;
+ $joinFields = $model->{$assocData['with']}->loadInfo();
+ $joinFields = $joinFields->extract('{n}.name');
+
+ if (is_array($joinFields) && !empty($joinFields) && count($joinFields) > 2) {
+ $joinFields = $this->fields($model->{$assocData['with']}, $model->{$assocData['with']}->name, $joinFields);
+ } else {
+ $joinFields = array();
+ $joinAssoc = null;
+ $joinAlias = $joinTbl;
+ }
+ }
+
+ $query = array(
+ 'conditions' => $assocData['conditions'],
+ 'limit' => $limit,
+ 'table' => $this->fullTableName($linkModel),
+ 'alias' => $alias,
+ 'fields' => array_merge($this->fields($linkModel, $alias, $assocData['fields']), $joinFields),
+ 'order' => $assocData['order'],
+ 'joins' => array(array(
+ 'table' => $joinTbl,
+ 'alias' => $joinAssoc,
+ 'conditions' => array(
+ array("{$joinAlias}.{$assocData['foreignKey']}" => '{$__cakeID__$}'),
+ array("{$joinAlias}.{$assocData['associationForeignKey']}" => '{$__cakeIdentifier['."{$alias}.{$linkModel->primaryKey}".']__$}')
+ ))
+ )
+ );
+ break;
+ }
+ if (isset($query)) {
+ return $this->buildStatement($query, $model);
+ }
+ return null;
+ }
+
+ function buildJoinStatement($join) {
+ $data = array_merge(array(
+ 'type' => null,
+ 'alias' => null,
+ 'table' => 'join_table',
+ 'conditions' => array()
+ ), $join);
+
+ if (!empty($data['alias'])) {
+ $data['alias'] = $this->alias . $this->name($data['alias']);
+ }
+ if (!empty($data['conditions'])) {
+ $data['conditions'] = trim($this->conditions($data['conditions'], true, false));
+ }
+ return $this->renderJoinStatement($data);
+ }
+
+ function buildStatement($query, $model) {
+ $query = array_merge(array('offset' => null, 'joins' => array()), $query);
+ if (!empty($query['joins'])) {
+ for ($i = 0; $i < count($query['joins']); $i++) {
+ if (is_array($query['joins'][$i])) {
+ $query['joins'][$i] = $this->buildJoinStatement($query['joins'][$i]);
+ }
+ }
+ }
+ return $this->renderStatement(array(
+ 'conditions' => $this->conditions($query['conditions']),
+ 'fields' => join(', ', $query['fields']),
+ 'table' => $query['table'],
+ 'alias' => $this->alias . $this->name($query['alias']),
+ 'order' => $this->order($query['order']),
+ 'limit' => $this->limit($query['limit'], $query['offset']),
+ 'joins' => join(' ', $query['joins'])
+ ));
+ }
+
+ function renderJoinStatement($data) {
+ extract($data);
+ return trim("{$type} JOIN {$table} {$alias} ON ({$conditions})");
+ }
+
+ function renderStatement($data) {
+ extract($data);
+ return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$order} {$limit}";
+ }
+/**
+ * Private method
+ *
+ * @return array
+ */
+ function __mergeConditions($query, $assoc) {
+ if (!empty($assoc)) {
+ if (is_array($query)) {
+ return array_merge((array)$assoc, $query);
+ } else {
+ if (!empty($query)) {
+ $query = array($query);
+ if (is_array($assoc)) {
+ $query = array_merge($query, $assoc);
+ } else {
+ $query[] = $assoc;
+ }
+ return $query;
+ } else {
+ return $assoc;
+ }
+ }
+ }
+ return $query;
+ }
+/**
+ * Generates and executes an SQL UPDATE statement for given model, fields, and values.
+ *
+ * @param Model $model
+ * @param array $fields
+ * @param array $values
+ * @param mixed $conditions
+ * @return array
+ */
+ function update(&$model, $fields = array(), $values = null, $conditions = null) {
+ $updates = array();
+
+ if ($values == null) {
+ $combined = $fields;
+ } else {
+ $combined = array_combine($fields, $values);
+ }
+
+ foreach ($combined as $field => $value) {
+ if ($value === null) {
+ $updates[] = $this->name($field) . ' = NULL';
+ } else {
+ $update = $this->name($field) . ' = ';
+ if ($conditions == null) {
+ $update .= $this->value($value, $model->getColumnType($field));
+ } else {
+ $update .= $value;
+ }
+ $updates[] = $update;
+ }
+ }
+ $conditions = $this->defaultConditions($model, $conditions);
+
+ if ($conditions === false) {
+ return false;
+ }
+
+ $fields = join(',', $updates);
+ $table = $this->fullTableName($model);
+
+ $conditions = $this->conditions($conditions);
+
+ if (!$this->execute("UPDATE {$table} SET {$fields} {$conditions}")) {
+ $model->onError();
+ return false;
+ }
+ return true;
+ }
+/**
+ * Generates and executes an SQL DELETE statement for given id on given model.
+ *
+ * @param Model $model
+ * @param mixed $conditions
+ * @return boolean Success
+ */
+ function delete(&$model, $conditions = null) {
+ $query = $this->defaultConditions($model, $conditions);
+
+ if ($query === false) {
+ return false;
+ }
+
+ $table = $this->fullTableName($model);
+ $conditions = $this->conditions($query);
+
+ if ($this->execute("DELETE FROM {$table} {$conditions}") === false) {
+ $model->onError();
+ return false;
+ }
+ return true;
+ }
+/**
+ * Creates a default set of conditions from the model if $conditions is null/empty.
+ *
+ * @param object $model
+ * @param mixed $conditions
+ * @return mixed
+ */
+ function defaultConditions(&$model, $conditions) {
+ if (!empty($conditions)) {
+ return $conditions;
+ }
+ if (!$model->exists()) {
+ return false;
+ }
+ return array($model->primaryKey => (array)$model->getID());
+ }
+/**
+ * Returns a key formatted like a string Model.fieldname(i.e. Post.title, or Country.name)
+ *
+ * @param unknown_type $model
+ * @param unknown_type $key
+ * @param unknown_type $assoc
+ * @return string
+ */
+ function resolveKey($model, $key, $assoc = null) {
+ if (empty($assoc)) {
+ $assoc = $model->alias;
+ }
+ if (!strpos('.', $key)) {
+ return $this->name($model->alias) . '.' . $this->name($key);
+ }
+ return $key;
+ }
+/**
+ * Returns the column type of a given
+ *
+ * @param Model $model
+ * @param string $field
+ */
+ function getColumnType(&$model, $field) {
+ return $model->getColumnType($field);
+ }
+/**
+ * Private helper method to remove query metadata in given data array.
+ *
+ * @param array $data
+ */
+ function __scrubQueryData(&$data) {
+ foreach (array('conditions', 'fields', 'joins', 'order', 'limit', 'offset') as $key) {
+ if (!isset($data[$key]) || empty($data[$key])) {
+ $data[$key] = array();
+ }
+ }
+ }
+/**
+ * Generates the fields list of an SQL query.
+ *
+ * @param Model $model
+ * @param string $alias Alias tablename
+ * @param mixed $fields
+ * @param boolean $quote If false, returns fields array unquoted
+ * @return array
+ */
+ function fields(&$model, $alias = null, $fields = array(), $quote = true) {
+ if (empty($alias)) {
+ $alias = $model->alias;
+ }
+
+ if (!is_array($fields)) {
+ if (!empty($fields)) {
+ $depth = 0;
+ $offset = 0;
+ $buffer = '';
+ $results = array();
+ $length = strlen($fields);
+
+ while ($offset <= $length) {
+ $tmpOffset = -1;
+ $offsets = array(strpos($fields, ',', $offset), strpos($fields, '(', $offset), strpos($fields, ')', $offset));
+ for ($i = 0; $i < 3; $i++) {
+ if ($offsets[$i] !== false && ($offsets[$i] < $tmpOffset || $tmpOffset == -1)) {
+ $tmpOffset = $offsets[$i];
+ }
+ }
+ if ($tmpOffset !== -1) {
+ $buffer .= substr($fields, $offset, ($tmpOffset - $offset));
+ if ($fields{$tmpOffset} == ',' && $depth == 0) {
+ $results[] = $buffer;
+ $buffer = '';
+ } else {
+ $buffer .= $fields{$tmpOffset};
+ }
+ if ($fields{$tmpOffset} == '(') {
+ $depth++;
+ }
+ if ($fields{$tmpOffset} == ')') {
+ $depth--;
+ }
+ $offset = ++$tmpOffset;
+ } else {
+ $results[] = $buffer . substr($fields, $offset);
+ $offset = $length + 1;
+ }
+ }
+ if (empty($results) && !empty($buffer)) {
+ $results[] = $buffer;
+ }
+
+ if (!empty($results)) {
+ $fields = array_map('trim', $results);
+ } else {
+ $fields = array();
+ }
+ }
+ }
+ if (empty($fields)) {
+ $fieldData = $model->loadInfo();
+ $fields = $fieldData->extract('{n}.name');
+ } else {
+ $fields = array_filter($fields);
+ }
+
+ if (!$quote) {
+ return $fields;
+ }
+ $count = count($fields);
+
+ if ($count >= 1 && !in_array($fields[0], array('*', 'COUNT(*)'))) {
+ for ($i = 0; $i < $count; $i++) {
+ if (!preg_match('/^.+\\(.*\\)/', $fields[$i])) {
+ $prepend = '';
+
+ if (strpos($fields[$i], 'DISTINCT') !== false) {
+ $prepend = 'DISTINCT ';
+ $fields[$i] = trim(str_replace('DISTINCT', '', $fields[$i]));
+ }
+ $dot = strpos($fields[$i], '.');
+
+ if ($dot === false) {
+ $fields[$i] = $prepend . $this->name($alias) . '.' . $this->name($fields[$i]);
+ } else {
+ $comma = strpos($fields[$i], ',');
+ if ($comma === false) {
+ $build = explode('.', $fields[$i]);
+ if (!Set::numeric($build)) {
+ $fields[$i] = $prepend . $this->name($build[0]) . '.' . $this->name($build[1]);
+ }
+ } else {
+ $comma = explode(',', $fields[$i]);
+ foreach ($comma as $string) {
+ $build = explode('.', $string);
+ if (!Set::numeric($build)) {
+ $value[] = $prepend . $this->name(trim($build[0])) . '.' . $this->name(trim($build[1]));
+ }
+ }
+ $fields[$i] = implode(', ', $value);
+ }
+ }
+ } elseif (preg_match('/\(([\.\w]+)\)/', $fields[$i], $field)) {
+ if (isset($field[1])) {
+ if (strpos($field[1], '.') === false) {
+ $field[1] = $this->name($alias) . '.' . $this->name($field[1]);
+ } else {
+ $field[0] = explode('.', $field[1]);
+ if (!Set::numeric($field[0])) {
+ $field[0] = join('.', array_map(array($this, 'name'), $field[0]));
+ $fields[$i] = preg_replace('/\(' . $field[1] . '\)/', '(' . $field[0] . ')', $fields[$i], 1);
+ }
+ }
+ }
+ }
+ }
+ }
+ return $fields;
+ }
+/**
+ * Creates a WHERE clause by parsing given conditions data.
+ *
+ * @param mixed $conditions Array or string of conditions
+ * @return string SQL fragment
+ */
+ function conditions($conditions, $quoteValues = true, $where = true) {
+ $clause = $out = '';
+ if (is_string($conditions) || empty($conditions) || $conditions === true) {
+ if (empty($conditions) || trim($conditions) == '' || $conditions === true) {
+ if ($where) {
+ return ' WHERE 1 = 1';
+ }
+ return '1 = 1';
+ }
+ if (!preg_match('/^WHERE\\x20|^GROUP\\x20BY\\x20|^HAVING\\x20|^ORDER\\x20BY\\x20/i', $conditions, $match)) {
+ if ($where) {
+ $clause = ' WHERE ';
+ }
+ }
+ if (trim($conditions) == '') {
+ $conditions = ' 1 = 1';
+ } else {
+ $conditions = $this->__quoteFields($conditions);
+ }
+ return $clause . $conditions;
+ } else {
+ if ($where) {
+ $clause = ' WHERE ';
+ }
+ if (!empty($conditions)) {
+ $out = $this->conditionKeysToString($conditions, $quoteValues);
+ }
+ if (empty($out) || empty($conditions)) {
+ return $clause . ' 1 = 1';
+ }
+ return $clause . join(' AND ', $out);
+ }
+ }
+/**
+ * Creates a WHERE clause by parsing given conditions array. Used by DboSource::conditions().
+ *
+ * @param array $conditions Array or string of conditions
+ * @return string SQL fragment
+ */
+ function conditionKeysToString($conditions, $quoteValues = true) {
+ $c = 0;
+ $data = $not = null;
+ $out = array();
+ $bool = array('and', 'or', 'not', 'and not', 'or not', 'xor', '||', '&&');
+ $join = ' AND ';
+
+ foreach ($conditions as $key => $value) {
+ if (is_numeric($key) && empty($value)) {
+ continue;
+ } elseif (is_numeric($key) && is_string($value)) {
+ $out[] = $not . $this->__quoteFields($value);
+ } elseif (in_array(strtolower(trim($key)), $bool)) {
+ $join = ' ' . strtoupper($key) . ' ';
+ $value = $this->conditionKeysToString($value, $quoteValues);
+ if (strpos($join, 'NOT') !== false) {
+ if (strtoupper(trim($key)) == 'NOT') {
+ $key = 'AND ' . $key;
+ }
+ $not = 'NOT ';
+ } else {
+ $not = null;
+ }
+ $out[] = $not . '((' . join(') ' . strtoupper($key) . ' (', $value) . '))';
+ } else {
+ if (is_string($value) && preg_match('/^\{\$__cakeIdentifier\[(.*)\]__\$}$/', $value, $identifier) && isset($identifier[1])) {
+ $data .= $this->name($key) . ' = ' . $this->name($identifier[1]);
+ } elseif (is_array($value) && !empty($value)) {
+ $keys = array_keys($value);
+ if ($keys[0] === 0) {
+ $data = $this->name($key) . ' IN (';
+ if (strpos($value[0], '-!') === 0) {
+ $value[0] = str_replace('-!', '', $value[0]);
+ $data .= $value[0];
+ $data .= ')';
+ } else {
+ if ($quoteValues) {
+ foreach ($value as $valElement) {
+ $data .= $this->value($valElement) . ', ';
+ }
+ }
+ $data[strlen($data) - 2] = ')';
+ }
+ } else {
+ $ret = $this->conditionKeysToString($value, $quoteValues);
+ if (count($ret) > 1) {
+ $out[] = '(' . join(') AND (', $ret) . ')';
+ } elseif (isset($ret[0])) {
+ $out[] = $ret[0];
+ }
+ }
+ } elseif (is_numeric($key) && !empty($value)) {
+ $data = $this->__quoteFields($value);
+ } elseif ($value === null || (is_array($value) && empty($value))) {
+ $data = $this->name($key) . ' IS NULL';
+ } elseif ($value === false || $value === true) {
+ $data = $this->name($key) . " = " . $this->value($value, 'boolean');
+ } elseif ($value === '') {
+ $data = $this->name($key) . " = ''";
+ } elseif (preg_match('/^([a-z]+\\([a-z0-9]*\\)\\x20+|(?:' . join('\\x20)|(?:', $this->__sqlOps) . '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)?(.*)/is', $value, $match)) {
+ if (preg_match('/(\\x20[\\w]*\\x20)/', $key, $regs)) {
+ $clause = $regs['1'];
+ $key = preg_replace('/' . $regs['1'] . '/', '', $key);
+ }
+
+ $not = false;
+ $mValue = trim($match['1']);
+ if (empty($match['1'])) {
+ $match['1'] = ' = ';
+ } elseif (empty($mValue)) {
+ $match['1'] = ' = ';
+ $match['2'] = $match['0'];
+ } elseif (!isset($match['2'])) {
+ $match['1'] = ' = ';
+ $match['2'] = $match['0'];
+ } elseif (strtolower($mValue) == 'not') {
+ $not = $this->conditionKeysToString(array($mValue => array($key => $match[2])), $quoteValues);
+ }
+
+ if ($not) {
+ $data = $not[0];
+ } elseif (strpos($match['2'], '-!') === 0) {
+ $match['2'] = str_replace('-!', '', $match['2']);
+ $data = $this->name($key) . ' ' . $match['1'] . ' ' . $match['2'];
+ } else {
+ if (!empty($match['2']) && $quoteValues) {
+ if (!preg_match('/[A-Za-z]+\\([a-z0-9]*\\),?\\x20+/', $match['2'])) {
+ $match['2'] = $this->value($match['2']);
+ }
+ $match['2'] = str_replace(' AND ', "' AND '", $match['2']);
+ }
+ $data = $this->__quoteFields($key);
+ if ($data === $key) {
+ $data = $this->name($key) . ' ' . $match['1'] . ' ' . $match['2'];
+ } else {
+ $data = $data . ' ' . $match['1'] . ' ' . $match['2'];
+ }
+ }
+ }
+
+ if ($data != null) {
+ $out[] = $data;
+ $data = null;
+ }
+ }
+ $c++;
+ }
+ return $out;
+ }
+/**
+ * Quotes Model.fields
+ *
+ * @param string $conditions
+ * @return string or false if no match
+ * @access private
+ */
+ function __quoteFields($conditions) {
+ $start = null;
+ $end = null;
+ $original = $conditions;
+
+ if (!empty($this->startQuote)) {
+ $start = preg_quote($this->startQuote);
+ }
+
+ if (!empty($this->endQuote)) {
+ $end = preg_quote($this->endQuote);
+ }
+ $conditions = str_replace(array($start, $end), '', $conditions);
+ preg_match_all('/(?:[\'\"][^\'\"\\\]*(?:\\\.[^\'\"\\\]*)*[\'\"])|([a-z0-9_' . $start . $end . ']*\\.[a-z0-9_' . $start . $end . ']*)/i', $conditions, $replace, PREG_PATTERN_ORDER);
+
+ if (isset($replace['1']['0'])) {
+ $pregCount = count($replace['1']);
+
+ for ($i = 0; $i < $pregCount; $i++) {
+ if (!empty($replace['1'][$i]) && !is_numeric($replace['1'][$i])) {
+ $conditions = preg_replace('/\b' . preg_quote($replace['1'][$i]) . '\b/', $this->name($replace['1'][$i]), $conditions);
+ }
+ }
+ return $conditions;
+ }
+ return $original;
+ }
+/**
+ * Returns a limit statement in the correct format for the particular database.
+ *
+ * @param integer $limit Limit of results returned
+ * @param integer $offset Offset from which to start results
+ * @return string SQL limit/offset statement
+ */
+ function limit($limit, $offset = null) {
+ if ($limit) {
+ $rt = '';
+ if (!strpos(strtolower($limit), 'limit') || strpos(strtolower($limit), 'limit') === 0) {
+ $rt = ' LIMIT';
+ }
+
+ if ($offset) {
+ $rt .= ' ' . $offset . ',';
+ }
+
+ $rt .= ' ' . $limit;
+ return $rt;
+ }
+ return null;
+ }
+/**
+ * Returns an ORDER BY clause as a string.
+ *
+ * @param string $key Field reference, as a key (i.e. Post.title)
+ * @param string $direction Direction (ASC or DESC)
+ * @return string ORDER BY clause
+ */
+ function order($keys, $direction = 'ASC') {
+ if (is_string($keys) && strpos($keys, ',') && !preg_match('/\(.+\,.+\)/', $keys)) {
+ $keys = explode(',', $keys);
+ array_map('trim', $keys);
+ }
+
+ if (is_array($keys)) {
+ foreach ($keys as $key => $val) {
+ if (is_numeric($key) && empty($val)) {
+ unset ($keys[$key]);
+ }
+ }
+ }
+
+ if (empty($keys) || (is_array($keys) && count($keys) && isset($keys[0]) && empty($keys[0]))) {
+ return '';
+ }
+
+ if (is_array($keys)) {
+ if (Set::countDim($keys) > 1) {
+ $new = array();
+
+ foreach ($keys as $val) {
+ $val = $this->order($val);
+ $new[] = $val;
+ }
+
+ $keys = $new;
+ }
+
+ foreach ($keys as $key => $value) {
+ if (is_numeric($key)) {
+ $value = ltrim(str_replace('ORDER BY ', '', $this->order($value)));
+ $key = $value;
+
+ if (!preg_match('/\\x20ASC|\\x20DESC/i', $key)) {
+ $value = ' ' . $direction;
+ } else {
+ $value = '';
+ }
+ } else {
+ $value = ' ' . $value;
+ }
+
+ if (!preg_match('/^.+\\(.*\\)/', $key) && !strpos($key, ',')) {
+ $dir = '';
+ $hasDir = preg_match('/\\x20ASC|\\x20DESC/i', $key, $dir);
+
+ if ($hasDir) {
+ $dir = $dir[0];
+ $key = preg_replace('/\\x20ASC|\\x20DESC/i', '', $key);
+ } else {
+ $dir = '';
+ }
+ $key = trim($this->name(trim($key)) . ' ' . trim($dir));
+ }
+ $order[] = $this->order($key . $value);
+ }
+
+ return ' ORDER BY ' . trim(str_replace('ORDER BY', '', join(',', $order)));
+ } else {
+ $keys = preg_replace('/ORDER\\x20BY/i', '', $keys);
+
+ if (strpos($keys, '.')) {
+ preg_match_all('/([a-zA-Z0-9_]{1,})\\.([a-zA-Z0-9_]{1,})/', $keys, $result,
+ PREG_PATTERN_ORDER);
+ $pregCount = count($result['0']);
+
+ for ($i = 0; $i < $pregCount; $i++) {
+ $keys = preg_replace('/' . $result['0'][$i] . '/', $this->name($result['0'][$i]), $keys);
+ }
+
+ if (preg_match('/\\x20ASC|\\x20DESC/i', $keys)) {
+ return ' ORDER BY ' . $keys;
+ } else {
+ return ' ORDER BY ' . $keys . ' ' . $direction;
+ }
+ } elseif (preg_match('/(\\x20ASC|\\x20DESC)/i', $keys, $match)) {
+ $direction = $match['1'];
+ $keys = preg_replace('/' . $match['1'] . '/', '', $keys);
+ return ' ORDER BY ' . $keys . $direction;
+ } else {
+ $direction = ' ' . $direction;
+ }
+ return ' ORDER BY ' . $keys . $direction;
+ }
+ }
+/**
+ * Disconnects database, kills the connection and says the connection is closed,
+ * and if DEBUG is turned on, the log for this object is shown.
+ *
+ */
+ function close() {
+ if (Configure::read() > 1) {
+ $this->showLog();
+ }
+ $this->disconnect();
+ }
+/**
+ * Checks if the specified table contains any record matching specified SQL
+ *
+ * @param Model $model Model to search
+ * @param string $sql SQL WHERE clause (condition only, not the "WHERE" part)
+ * @return boolean True if the table has a matching record, else false
+ */
+ function hasAny($model, $sql) {
+ $sql = $this->conditions($sql);
+ $out = $this->fetchRow("SELECT COUNT(" . $model->primaryKey . ") " . $this->alias . "count FROM " . $this->fullTableName($model) . ' ' . ($sql ? ' ' . $sql : 'WHERE 1 = 1'));
+
+ if (is_array($out)) {
+ return $out[0]['count'];
+ }
+ return false;
+ }
+/**
+ * Gets the length of a database-native column description, or null if no length
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ * @return integer An integer representing the length of the column
+ */
+ function length($real) {
+ $col = str_replace(array(')', 'unsigned'), '', $real);
+ $limit = null;
+
+ if (strpos($col, '(') !== false) {
+ list($col, $limit) = explode('(', $col);
+ }
+
+ if ($limit != null) {
+ return intval($limit);
+ }
+ return null;
+ }
+/**
+ * Translates between PHP boolean values and Database (faked) boolean values
+ *
+ * @param mixed $data Value to be translated
+ * @return mixed Converted boolean value
+ */
+ function boolean($data) {
+ if ($data === true || $data === false) {
+ if ($data === true) {
+ return 1;
+ }
+ return 0;
+ }
+
+ if (!empty($data)) {
+ return true;
+ }
+ return false;
+ }
+/**
+ * Destructor. Closes connection to the database.
+ *
+ */
+ function __destruct() {
+ if ($this->_transactionStarted) {
+ $null = null;
+ $this->rollback($null);
+ }
+ parent::__destruct();
+ }
+/**
+ * Inserts multiple values into a join table
+ *
+ * @param string $table
+ * @param string $fields
+ * @param array $values
+ */
+ function insertMulti($table, $fields, $values) {
+ $values = implode(', ', $values);
+ $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values}");
+ }
+/**
+ * Returns an array of the indexes in given datasource name.
+ *
+ * @param string $model Name of model to inspect
+ * @return array Fields in table. Keys are column and unique
+ */
+ function index($model) {
+ return false;
+ }
+/**
+ * Generate a create syntax from CakeSchema
+ *
+ * @param object $schema An instance of a subclass of CakeSchema
+ * @param string $table Optional. If specified only the table name given will be generated.
+ * Otherwise, all tables defined in the schema are generated.
+ * @return string
+ */
+ function createSchema($schema, $table = null) {
+ return false;
+ }
+/**
+ * Generate a alter syntax from CakeSchema::compare()
+ *
+ * @param unknown_type $schema
+ * @return unknown
+ */
+ function alterSchema($compare, $table = null) {
+ return false;
+ }
+/**
+ * Generate a drop syntax from CakeSchema
+ *
+ * @param object $schema An instance of a subclass of CakeSchema
+ * @param string $table Optional. If specified only the table name given will be generated.
+ * Otherwise, all tables defined in the schema are generated.
+ * @return string
+ */
+ function dropSchema($schema, $table = null) {
+ return false;
+ }
+/**
+ * Generate a column schema string
+ *
+ * @param array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]),
+ * where options can be 'default', 'length', or 'key'.
+ * @return string
+ */
+ function buildColumn($column) {
+ return false;
+ }
+/**
+ * Format indexes for create table
+ *
+ * @param array $indexes
+ * @return string
+ */
+ function buildIndex($indexes) {
+ return false;
+ }
+/**
+ * Guesses the data type of an array
+ *
+ * @param string $value
+ * @return void
+ * @access public
+ */
+ function introspectType($value) {
+ if (!is_array($value)) {
+ if ($value === true || $value === false) {
+ return 'boolean';
+ }
+ if (is_float($value) && floatval($value) === $value) {
+ return 'float';
+ }
+ if (is_int($value) && intval($value) === $value) {
+ return 'integer';
+ }
+ if (is_string($value) && strlen($value) > 255) {
+ return 'text';
+ }
+ return 'string';
+ }
+
+ $isAllFloat = $isAllInt = true;
+ $containsFloat = $containsInt = $containsString = false;
+ foreach ($value as $key => $valElement) {
+ $valElement = trim($valElement);
+ if (!is_float($valElement) && !preg_match('/^[\d]+\.[\d]+$/', $valElement)) {
+ $isAllFloat = false;
+ } else {
+ $containsFloat = true;
+ continue;
+ }
+ if (!is_int($valElement) && !preg_match('/^[\d]+$/', $valElement)) {
+ $isAllInt = false;
+ } else {
+ $containsInt = true;
+ continue;
+ }
+ $containsString = true;
+ }
+
+ if ($isAllFloat) {
+ return 'float';
+ }
+ if ($isAllInt) {
+ return 'integer';
+ }
+
+ if ($containsInt && !$containsString) {
+ return 'integer';
+ }
+ return 'string';
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_adodb.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_adodb.php
new file mode 100644
index 0000000..f9d58d7
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_adodb.php
@@ -0,0 +1,437 @@
+<?php
+/* SVN FILE: $Id: dbo_adodb.php 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ * AdoDB layer for DBO.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Include AdoDB files.
+ */
+vendor ('adodb' . DS . 'adodb.inc');
+
+/**
+ * AdoDB DBO implementation.
+ *
+ * Database abstraction implementation for the AdoDB library.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ */
+class DboAdodb extends DboSource {
+/**
+ * Enter description here...
+ *
+ * @var string
+ */
+ var $description = "ADOdb DBO Driver";
+
+/**
+ * ADOConnection object with which we connect.
+ *
+ * @var ADOConnection The connection object.
+ * @access private
+ */
+ var $_adodb = null;
+
+/**
+ * Array translating ADOdb column MetaTypes to cake-supported metatypes
+ *
+ * @var array
+ * @access private
+ */
+ var $_adodb_column_types = array(
+ 'C' => 'string',
+ 'X' => 'text',
+ 'D' => 'date',
+ 'T' => 'timestamp',
+ 'L' => 'boolean',
+ 'N' => 'float',
+ 'I' => 'integer',
+ 'R' => 'integer', // denotes auto-increment or counter field
+ 'B' => 'binary'
+ );
+
+/**
+ * Connects to the database using options in the given configuration array.
+ *
+ * @param array $config Configuration array for connecting
+ */
+ function connect() {
+ $config = $this->config;
+ $persistent = strrpos($config['connect'], '|p');
+
+ if ($persistent === false) {
+ $adodb_driver = $config['connect'];
+ $connect = 'Connect';
+ } else {
+ $adodb_driver = substr($config['connect'], 0, $persistent);
+ $connect = 'PConnect';
+ }
+
+ $this->_adodb = NewADOConnection($adodb_driver);
+
+ $this->startQuote = $this->_adodb->nameQuote;
+ $this->endQuote = $this->_adodb->nameQuote;
+
+ $this->connected = $this->_adodb->$connect($config['host'], $config['login'], $config['password'], $config['database']);
+ return $this->connected;
+ }
+/**
+ * Disconnects from database.
+ *
+ * @return boolean True if the database could be disconnected, else false
+ */
+ function disconnect() {
+ return $this->_adodb->Close();
+ }
+/**
+ * Executes given SQL statement.
+ *
+ * @param string $sql SQL statement
+ * @return resource Result resource identifier
+ */
+ function _execute($sql) {
+ global $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ return $this->_adodb->execute($sql);
+ }
+/**
+ * Returns a row from given resultset as an array .
+ *
+ * @return array The fetched row as an array
+ */
+/**
+ * Returns a row from current resultset as an array .
+ *
+ * @return array The fetched row as an array
+ */
+ function fetchRow($sql = null) {
+
+ if (!empty($sql) && is_string($sql) && strlen($sql) > 5) {
+ if (!$this->execute($sql)) {
+ return null;
+ }
+ }
+
+ if (!is_object($this->_result) || $this->_result->EOF) {
+ return null;
+ } else {
+ $resultRow = $this->_result->FetchRow();
+ $this->resultSet($resultRow);
+ return $this->fetchResult();
+ }
+ }
+/**
+ * Begin a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions).
+ */
+ function begin(&$model) {
+ if (parent::begin($model)) {
+ if ($this->_adodb->BeginTrans()) {
+ $this->_transactionStarted = true;
+ return true;
+ }
+ }
+ return false;
+ }
+/**
+ * Commit a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function commit(&$model) {
+ if (parent::commit($model)) {
+ $this->_transactionStarted = false;
+ return $this->_adodb->CommitTrans();
+ }
+ return false;
+ }
+/**
+ * Rollback a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function rollback(&$model) {
+ if (parent::rollback($model)) {
+ return $this->_adodb->RollbackTrans();
+ }
+ return false;
+ }
+/**
+ * Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
+ *
+ * @return array Array of tablenames in the database
+ */
+ function listSources() {
+ $tables = $this->_adodb->MetaTables('TABLES');
+
+ if (!sizeof($tables) > 0) {
+ trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE);
+ exit;
+ }
+
+ return $tables;
+ }
+/**
+ * Returns an array of the fields in the table used by the given model.
+ *
+ * @param AppModel $model Model object
+ * @return array Fields in table. Keys are name and type
+ */
+ function describe(&$model) {
+ $cache = parent::describe($model);
+ if ($cache != null) {
+ return $cache;
+ }
+
+ $fields = false;
+ $cols = $this->_adodb->MetaColumns($this->fullTableName($model, false));
+
+ foreach ($cols as $column) {
+ $fields[$column->name] = array(
+ 'type' => $this->column($column->type)
+ );
+ }
+
+ $this->__cacheDescription($this->fullTableName($model, false), $fields);
+ return $fields;
+ }
+/**
+ * Returns a formatted error message from previous database operation.
+ *
+ * @return string Error message
+ */
+ function lastError() {
+ return $this->_adodb->ErrorMsg();
+ }
+/**
+ * Returns number of affected rows in previous database operation, or false if no previous operation exists.
+ *
+ * @return int Number of affected rows
+ */
+ function lastAffected() {
+ return $this->_adodb->Affected_Rows();
+ }
+/**
+ * Returns number of rows in previous resultset, or false if no previous resultset exists.
+ *
+ * @return int Number of rows in resultset
+ */
+ function lastNumRows() {
+ return $this->_result ? $this->_result->RecordCount() : false;
+ }
+/**
+ * Returns the ID generated from the previous INSERT operation.
+ *
+ * @return int
+ *
+ * @Returns the last autonumbering ID inserted. Returns false if function not supported.
+ */
+ function lastInsertId() {
+ return $this->_adodb->Insert_ID();
+ }
+
+/**
+ * Returns a LIMIT statement in the correct format for the particular database.
+ *
+ * @param int $limit Limit of results returned
+ * @param int $offset Offset from which to start results
+ * @return string SQL limit/offset statement
+ * @todo Please change output string to whatever select your database accepts. adodb doesn't allow us to get the correct limit string out of it.
+ */
+ function limit($limit, $offset = null) {
+ if (empty($limit)) {
+ return null;
+ }
+ return " LIMIT {$limit}" . ($offset ? "{$offset}" : null);
+ // please change to whatever select your database accepts
+ // adodb doesn't allow us to get the correct limit string out of it
+ }
+
+/**
+ * Converts database-layer column types to basic types
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ * @return string Abstract column type (i.e. "string")
+ */
+ function column($real) {
+ if (isset($this->_result)) {
+ $adodb_metatyper = &$this->_result;
+ } else {
+ $adodb_metatyper = &$this->_adodb->execute('Select 1');
+ }
+
+ $interpreted_type = $adodb_metatyper->MetaType($real);
+ if (!isset($this->_adodb_column_types[$interpreted_type])) {
+ return 'text';
+ }
+
+ return $this->_adodb_column_types[$interpreted_type];
+ }
+/**
+ * Returns a quoted and escaped string of $data for use in an SQL statement.
+ *
+ * @param string $data String to be prepared for use in an SQL statement
+ * @param string $column_type The type of the column into which this data will be inserted
+ * @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided
+ * @return string Quoted and escaped data
+ */
+ function value($data, $column = null, $safe = false) {
+ $parent = parent::value($data, $column, $safe);
+ if ($parent != null) {
+ return $parent;
+ }
+
+ if ($data === null) {
+ return 'NULL';
+ }
+
+ if ($data === '') {
+ return "''";
+ }
+ return $this->_adodb->qstr($data);
+ }
+/**
+ * Generates the fields list of an SQL query.
+ *
+ * @param Model $model
+ * @param string $alias Alias tablename
+ * @param mixed $fields
+ * @return array
+ */
+ function fields(&$model, $alias = null, $fields = null, $quote = true) {
+ if (empty($alias)) {
+ $alias = $model->name;
+ }
+
+ if (!is_array($fields)) {
+ if ($fields != null) {
+ if (strpos($fields, ',')) {
+ $fields = explode(',', $fields);
+ } else {
+ $fields = array($fields);
+ }
+ $fields = array_map('trim', $fields);
+ } else {
+ foreach ($model->_tableInfo->value as $field) {
+ $fields[] = $field['name'];
+ }
+ }
+ }
+
+ $count = count($fields);
+
+ if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false) {
+ for ($i = 0; $i < $count; $i++) {
+ if (!preg_match('/^.+\\(.*\\)/', $fields[$i])) {
+ $prepend = '';
+ if (strpos($fields[$i], 'DISTINCT') !== false) {
+ $prepend = 'DISTINCT ';
+ $fields[$i] = trim(r('DISTINCT', '', $fields[$i]));
+ }
+
+ $dot = strrpos($fields[$i], '.');
+ if ($dot === false) {
+ $fields[$i] = $prepend . $this->name($alias) . '.' . $this->name($fields[$i]) . ' AS ' . $this->name($alias . '__' . $fields[$i]);
+ } else {
+ $build = explode('.', $fields[$i]);
+ $fields[$i] = $prepend . $this->name($build[0]) . '.' . $this->name($build[1]) . ' AS ' . $this->name($build[0] . '__' . $build[1]);
+ }
+ }
+ }
+ }
+ return $fields;
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $results
+ */
+ function resultSet(&$results) {
+ $num_fields = count($results);
+ $fields = array_keys($results);
+ $this->results =& $results;
+ $this->map = array();
+ $index = 0;
+ $j = 0;
+
+ while ($j < $num_fields) {
+ $columnName = $fields[$j];
+
+ if (strpos($columnName, '__')) {
+ $parts = explode('__', $columnName);
+ $this->map[$index++] = array($parts[0], $parts[1]);
+ } else {
+ $this->map[$index++] = array(0, $columnName);
+ }
+ $j++;
+ }
+ }
+/**
+ * Fetches the next row from the current result set
+ *
+ * @return unknown
+ */
+ function fetchResult() {
+ if (!empty($this->results) && $row = $this->results) {
+ $resultRow = array();
+ $fields = array_keys($row);
+ $count = count($fields);
+ $i = 0;
+ for ($i = 0; $i < $count; $i++) { //$row as $index => $field) {
+ list($table, $column) = $this->map[$i];
+ $resultRow[$table][$column] = $row[$fields[$i]];
+ }
+ return $resultRow;
+ } else {
+ return false;
+ }
+ }
+/**
+ * Inserts multiple values into a join table
+ *
+ * @param string $table
+ * @param string $fields
+ * @param array $values
+ */
+ function insertMulti($table, $fields, $values) {
+ $count = count($values);
+ for ($x = 0; $x < $count; $x++) {
+ $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mssql.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mssql.php
new file mode 100644
index 0000000..accff58
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mssql.php
@@ -0,0 +1,604 @@
+<?php
+/* SVN FILE: $Id: dbo_mssql.php 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ * MS SQL layer for DBO
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ * @since CakePHP(tm) v 0.10.5.1790
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Short description for class.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ */
+class DboMssql extends DboSource {
+/**
+ * Driver description
+ *
+ * @var string
+ */
+ var $description = "MS SQL DBO Driver";
+/**
+ * Starting quote character for quoted identifiers
+ *
+ * @var string
+ */
+ var $startQuote = "[";
+/**
+ * Ending quote character for quoted identifiers
+ *
+ * @var string
+ */
+ var $endQuote = "]";
+ /**
+ * Creates a map between field aliases and numeric indexes. Workaround for the
+ * SQL Server driver's 30-character column name limitation.
+ *
+ * @var array
+ */
+ var $__fieldMappings = array();
+/**
+ * Base configuration settings for MS SQL driver
+ *
+ * @var array
+ */
+ var $_baseConfig = array(
+ 'persistent' => true,
+ 'host' => 'localhost',
+ 'login' => 'root',
+ 'password' => '',
+ 'database' => 'cake',
+ 'port' => '1433',
+ 'connect' => 'mssql_pconnect'
+ );
+/**
+ * MS SQL column definition
+ *
+ * @var array
+ */
+ var $columns = array(
+ 'primary_key' => array('name' => 'int IDENTITY (1, 1) NOT NULL'),
+ 'string' => array('name' => 'varchar', 'limit' => '255'),
+ 'text' => array('name' => 'text'),
+ 'integer' => array('name' => 'int', 'formatter' => 'intval'),
+ 'float' => array('name' => 'float', 'formatter' => 'floatval'),
+ 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
+ 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
+ 'time' => array('name' => 'datetime', 'format' => 'H:i:s', 'formatter' => 'date'),
+ 'date' => array('name' => 'datetime', 'format' => 'Y-m-d', 'formatter' => 'date'),
+ 'binary' => array('name' => 'image'),
+ 'boolean' => array('name' => 'bit')
+ );
+/**
+ * MS SQL DBO driver constructor; sets SQL Server error reporting defaults
+ *
+ * @param array $config Configuration data from app/config/databases.php
+ * @return boolean True if connected successfully, false on error
+ */
+ function __construct($config, $autoConnect = true) {
+ if ($autoConnect) {
+ if (!function_exists('mssql_min_message_severity')) {
+ trigger_error("PHP SQL Server interface is not installed, cannot continue. For troubleshooting information, see http://php.net/mssql/", E_USER_WARNING);
+ }
+ mssql_min_message_severity(15);
+ mssql_min_error_severity(2);
+ }
+ return parent::__construct($config, $autoConnect);
+ }
+/**
+ * Connects to the database using options in the given configuration array.
+ *
+ * @return boolean True if the database could be connected, else false
+ */
+ function connect() {
+ $config = $this->config;
+
+ $os = env('OS');
+ if (!empty($os) && strpos($os, 'Windows') !== false) {
+ $sep = ',';
+ } else {
+ $sep = ':';
+ }
+ $connect = 'mssql_connect';
+ if ($config['persistent']) {
+ $connect = 'mssql_pconnect';
+ }
+ $this->connected = false;
+
+ if (is_numeric($config['port'])) {
+ $port = $sep . $config['port']; // Port number
+ } elseif ($config['port'] === null) {
+ $port = ''; // No port - SQL Server 2005
+ } else {
+ $port = '\\' . $config['port']; // Named pipe
+ }
+ $this->connection = $connect($config['host'] . $port, $config['login'], $config['password']);
+
+ if (mssql_select_db($config['database'], $this->connection)) {
+ $this->connected = true;
+ }
+ }
+/**
+ * Disconnects from database.
+ *
+ * @return boolean True if the database could be disconnected, else false
+ */
+ function disconnect() {
+ @mssql_free_result($this->results);
+ $this->connected = !@mssql_close($this->connection);
+ return !$this->connected;
+ }
+/**
+ * Executes given SQL statement.
+ *
+ * @param string $sql SQL statement
+ * @return resource Result resource identifier
+ * @access protected
+ */
+ function _execute($sql) {
+ return mssql_query($sql, $this->connection);
+ }
+/**
+ * Returns an array of sources (tables) in the database.
+ *
+ * @return array Array of tablenames in the database
+ */
+ function listSources() {
+ $cache = parent::listSources();
+
+ if ($cache != null) {
+ return $cache;
+ }
+
+ $result = $this->fetchAll('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES');
+
+ if (!$result || empty($result)) {
+ return array();
+ } else {
+ $tables = array();
+
+ foreach ($result as $table) {
+ $tables[] = $table[0]['TABLE_NAME'];
+ }
+
+ parent::listSources($tables);
+ return $tables;
+ }
+ }
+/**
+ * Returns an array of the fields in given table name.
+ *
+ * @param Model $model Model object to describe
+ * @return array Fields in table. Keys are name and type
+ */
+ function describe(&$model) {
+ $cache = parent::describe($model);
+
+ if ($cache != null) {
+ return $cache;
+ }
+
+ $fields = false;
+ $cols = $this->fetchAll("SELECT COLUMN_NAME as Field, DATA_TYPE as Type, COL_LENGTH('" . $this->fullTableName($model, false) . "', COLUMN_NAME) as Length, IS_NULLABLE As [Null], COLUMN_DEFAULT as [Default], COLUMNPROPERTY(OBJECT_ID('" . $this->fullTableName($model, false) . "'), COLUMN_NAME, 'IsIdentity') as [Key], NUMERIC_SCALE as Size FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . $this->fullTableName($model, false) . "'", false);
+
+ foreach ($cols as $column) {
+ $fields[$column[0]['Field']] = array(
+ 'type' => $this->column($column[0]['Type']),
+ 'null' => (strtoupper($column[0]['Null']) == 'YES'),
+ 'default' => $column[0]['Default'],
+ 'length' => $this->length($column[0]['Type']),
+ );
+ }
+ $this->__cacheDescription($this->fullTableName($model, false), $fields);
+ return $fields;
+ }
+/**
+ * Returns a quoted and escaped string of $data for use in an SQL statement.
+ *
+ * @param string $data String to be prepared for use in an SQL statement
+ * @param string $column The column into which this data will be inserted
+ * @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided
+ * @return string Quoted and escaped data
+ */
+ function value($data, $column = null, $safe = false) {
+ $parent = parent::value($data, $column, $safe);
+
+ if ($parent != null) {
+ return $parent;
+ }
+ if ($data === null) {
+ return 'NULL';
+ }
+ if ($data === '') {
+ return "''";
+ }
+
+ switch($column) {
+ case 'boolean':
+ $data = $this->boolean((bool)$data);
+ break;
+ case 'datetime':
+ if ($data && (($timestamp = strtotime($data)) !== false)) {
+ $data = date('Y-m-d\TH:i:s', $timestamp);
+ }
+ break;
+ default:
+ if (get_magic_quotes_gpc()) {
+ $data = stripslashes(str_replace("'", "''", $data));
+ } else {
+ $data = str_replace("'", "''", $data);
+ }
+ break;
+ }
+
+ if (in_array($column, array('integer', 'float')) && is_numeric($data)) {
+ return $data;
+ }
+ return "'" . $data . "'";
+ }
+/**
+ * Generates the fields list of an SQL query.
+ *
+ * @param Model $model
+ * @param string $alias Alias tablename
+ * @param mixed $fields
+ * @return array
+ */
+ function fields(&$model, $alias = null, $fields = array(), $quote = true) {
+ if (empty($alias)) {
+ $alias = $model->name;
+ }
+ $fields = parent::fields($model, $alias, $fields, false);
+ $count = count($fields);
+
+ if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false) {
+ for ($i = 0; $i < $count; $i++) {
+ $dot = strrpos($fields[$i], '.');
+ $fieldAlias = count($this->__fieldMappings);
+
+ if ($dot === false && !preg_match('/\s+AS\s+/i', $fields[$i])) {
+ $this->__fieldMappings[$alias . '__' . $fieldAlias] = $alias . '.' . $fields[$i];
+ $fields[$i] = $this->name($alias) . '.' . $this->name($fields[$i]) . ' AS ' . $this->name($alias . '__' . $fieldAlias);
+ } elseif (!preg_match('/\s+AS\s+/i', $fields[$i])) {
+ $build = explode('.', $fields[$i]);
+ $this->__fieldMappings[$build[0] . '__' . $fieldAlias] = $build[0] . '.' . $build[1];
+ $fields[$i] = $this->name($build[0]) . '.' . $this->name($build[1]) . ' AS ' . $this->name($build[0] . '__' . $fieldAlias);
+ }
+ }
+ }
+ return $fields;
+ }
+/**
+ * Begin a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions).
+ */
+ function begin(&$model) {
+ if (parent::begin($model)) {
+ if ($this->execute('BEGIN TRANSACTION')) {
+ $this->_transactionStarted = true;
+ return true;
+ }
+ }
+ return false;
+ }
+/**
+ * Commit a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function commit(&$model) {
+ if (parent::commit($model)) {
+ $this->_transactionStarted = false;
+ return $this->execute('COMMIT');
+ }
+ return false;
+ }
+/**
+ * Rollback a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function rollback(&$model) {
+ if (parent::rollback($model)) {
+ return $this->execute('ROLLBACK');
+ }
+ return false;
+ }
+/**
+ * Removes Identity (primary key) column from update data before returning to parent
+ *
+ * @param Model $model
+ * @param array $fields
+ * @param array $values
+ * @return array
+ */
+ function update(&$model, $fields = array(), $values = array()) {
+ foreach ($fields as $i => $field) {
+ if ($field == $model->primaryKey) {
+ unset ($fields[$i]);
+ unset ($values[$i]);
+ break;
+ }
+ }
+ return parent::update($model, $fields, $values);
+ }
+/**
+ * Returns a formatted error message from previous database operation.
+ *
+ * @return string Error message with error number
+ */
+ function lastError() {
+ $error = mssql_get_last_message($this->connection);
+
+ if ($error) {
+ if (strpos(strtolower($error), 'changed database') === false) {
+ return $error;
+ }
+ }
+ return null;
+ }
+/**
+ * Returns number of affected rows in previous database operation. If no previous operation exists,
+ * this returns false.
+ *
+ * @return int Number of affected rows
+ */
+ function lastAffected() {
+ if ($this->_result) {
+ return mssql_rows_affected($this->connection);
+ }
+ return null;
+ }
+/**
+ * Returns number of rows in previous resultset. If no previous resultset exists,
+ * this returns false.
+ *
+ * @return int Number of rows in resultset
+ */
+ function lastNumRows() {
+ if ($this->_result) {
+ return @mssql_num_rows($this->_result);
+ }
+ return null;
+ }
+/**
+ * Returns the ID generated from the previous INSERT operation.
+ *
+ * @param unknown_type $source
+ * @return in
+ */
+ function lastInsertId($source = null) {
+ $id = $this->fetchRow('SELECT SCOPE_IDENTITY() AS insertID', false);
+ return $id[0]['insertID'];
+ }
+/**
+ * Returns a limit statement in the correct format for the particular database.
+ *
+ * @param int $limit Limit of results returned
+ * @param int $offset Offset from which to start results
+ * @return string SQL limit/offset statement
+ */
+ function limit($limit, $offset = null) {
+ if ($limit) {
+ $rt = '';
+ if (!strpos(strtolower($limit), 'top') || strpos(strtolower($limit), 'top') === 0) {
+ $rt = ' TOP';
+ }
+ $rt .= ' ' . $limit;
+ if (is_int($offset) && $offset > 0) {
+ $rt .= ' OFFSET ' . $offset;
+ }
+ return $rt;
+ }
+ return null;
+ }
+/**
+ * Converts database-layer column types to basic types
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ * @return string Abstract column type (i.e. "string")
+ */
+ function column($real) {
+ if (is_array($real)) {
+ $col = $real['name'];
+
+ if (isset($real['limit'])) {
+ $col .= '(' . $real['limit'] . ')';
+ }
+ return $col;
+ }
+ $col = str_replace(')', '', $real);
+ $limit = null;
+ @list($col, $limit) = explode('(', $col);
+
+ if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
+ return $col;
+ }
+
+ if ($col == 'bit') {
+ return 'boolean';
+ }
+
+ if (strpos($col, 'int') !== false || $col == 'numeric') {
+ return 'integer';
+ }
+
+ if (strpos($col, 'char') !== false) {
+ return 'string';
+ }
+
+ if (strpos($col, 'text') !== false) {
+ return 'text';
+ }
+
+ if (strpos($col, 'binary') !== false || $col == 'image') {
+ return 'binary';
+ }
+
+ if (in_array($col, array('float', 'real', 'decimal'))) {
+ return 'float';
+ }
+ return 'text';
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $results
+ */
+ function resultSet(&$results) {
+ $this->results =& $results;
+ $this->map = array();
+ $num_fields = mssql_num_fields($results);
+ $index = 0;
+ $j = 0;
+
+ while ($j < $num_fields) {
+ $column = mssql_field_name($results, $j);
+
+ if (strpos($column, '__')) {
+ if (isset($this->__fieldMappings[$column]) && strpos($this->__fieldMappings[$column], '.')) {
+ $map = explode('.', $this->__fieldMappings[$column]);
+ } elseif (isset($this->__fieldMappings[$column])) {
+ $map = array(0, $this->__fieldMappings[$column]);
+ } else {
+ $map = array(0, $column);
+ }
+ $this->map[$index++] = $map;
+ } else {
+ $this->map[$index++] = array(0, $column);
+ }
+ $j++;
+ }
+ }
+/**
+ * Builds final SQL statement
+ *
+ * @param array $data Query data
+ * @return string
+ */
+ function renderStatement($data) {
+ extract($data);
+ if (preg_match('/offset\s+([0-9]+)/i', $limit, $offset)) {
+ $limit = preg_replace('/\s*offset.*$/i', '', $limit);
+ preg_match('/top\s+([0-9]+)/i', $limit, $limitVal);
+ $offset = intval($offset[1]) + intval($limitVal[1]);
+ $rOrder = $this->__switchSort($order);
+ list($order2, $rOrder) = array($this->__mapFields($order), $this->__mapFields($rOrder));
+ return "SELECT * FROM (SELECT {$limit} * FROM (SELECT TOP {$offset} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$order}) AS Set1 {$rOrder}) AS Set2 {$order2}";
+ } else {
+ return "SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$order}";
+ }
+ }
+/**
+ * Reverses the sort direction of ORDER statements to get paging offsets to work correctly
+ *
+ * @param string $order
+ * @return string
+ * @access private
+ */
+ function __switchSort($order) {
+ $order = preg_replace('/\s+ASC/i', '__tmp_asc__', $order);
+ $order = preg_replace('/\s+DESC/i', ' ASC', $order);
+ return preg_replace('/__tmp_asc__/', ' DESC', $order);
+ }
+/**
+ * Translates field names used for filtering and sorting to shortened names using the field map
+ *
+ * @param string $sql A snippet of SQL representing an ORDER or WHERE statement
+ * @return string The value of $sql with field names replaced
+ * @access private
+ */
+ function __mapFields($sql) {
+ if (empty($sql) || empty($this->__fieldMappings)) {
+ return $sql;
+ }
+ foreach ($this->__fieldMappings as $key => $val) {
+ $sql = preg_replace('/' . preg_quote($val) . '/', $this->name($key), $sql);
+ $sql = preg_replace('/' . preg_quote($this->name($val)) . '/', $this->name($key), $sql);
+ }
+ return $sql;
+ }
+/**
+ * Returns an array of all result rows for a given SQL query.
+ * Returns false if no rows matched.
+ *
+ * @param string $sql SQL statement
+ * @param boolean $cache Enables returning/storing cached query results
+ * @return array Array of resultset rows, or false if no rows matched
+ */
+ function read(&$model, $queryData = array(), $recursive = null) {
+ $results = parent::read($model, $queryData, $recursive);
+ $this->__fieldMappings = array();
+ $this->__fieldMapBase = null;
+ return $results;
+ }
+/**
+ * Fetches the next row from the current result set
+ *
+ * @return unknown
+ */
+ function fetchResult() {
+ if ($row = mssql_fetch_row($this->results)) {
+ $resultRow = array();
+ $i = 0;
+
+ foreach ($row as $index => $field) {
+ list($table, $column) = $this->map[$index];
+ $resultRow[$table][$column] = $row[$index];
+ $i++;
+ }
+ return $resultRow;
+ } else {
+ return false;
+ }
+ }
+/**
+ * Inserts multiple values into a join table
+ *
+ * @param string $table
+ * @param string $fields
+ * @param array $values
+ */
+ function insertMulti($table, $fields, $values) {
+ $count = count($values);
+ for ($x = 0; $x < $count; $x++) {
+ $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
+ }
+ }
+
+}
+?>
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mysql.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mysql.php
new file mode 100644
index 0000000..5774563
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mysql.php
@@ -0,0 +1,681 @@
+<?php
+/* SVN FILE: $Id: dbo_mysql.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * MySQL layer for DBO
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ * @since CakePHP(tm) v 0.10.5.1790
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Short description for class.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ */
+class DboMysql extends DboSource {
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $description = "MySQL DBO Driver";
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $startQuote = "`";
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $endQuote = "`";
+/**
+ * Base configuration settings for MySQL driver
+ *
+ * @var array
+ */
+ var $_baseConfig = array(
+ 'persistent' => true,
+ 'host' => 'localhost',
+ 'login' => 'root',
+ 'password' => '',
+ 'database' => 'cake',
+ 'port' => '3306',
+ 'connect' => 'mysql_pconnect'
+ );
+/**
+ * MySQL column definition
+ *
+ * @var array
+ */
+ var $columns = array(
+ 'primary_key' => array('name' => 'int(11) DEFAULT NULL auto_increment'),
+ 'string' => array('name' => 'varchar', 'limit' => '255'),
+ 'text' => array('name' => 'text'),
+ 'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
+ 'float' => array('name' => 'float', 'formatter' => 'floatval'),
+ 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
+ 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
+ 'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'),
+ 'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'),
+ 'binary' => array('name' => 'blob'),
+ 'boolean' => array('name' => 'tinyint', 'limit' => '1')
+ );
+/**
+ * Connects to the database using options in the given configuration array.
+ *
+ * @return boolean True if the database could be connected, else false
+ */
+ function connect() {
+ $config = $this->config;
+ $connect = $config['connect'];
+ $this->connected = false;
+
+ if (!$config['persistent'] || $config['connect'] === 'mysql_connect') {
+ $this->connection = mysql_connect($config['host'] . ':' . $config['port'], $config['login'], $config['password'], true);
+ } else {
+ $this->connection = $connect($config['host'] . ':' . $config['port'], $config['login'], $config['password']);
+ }
+
+ if (mysql_select_db($config['database'], $this->connection)) {
+ $this->connected = true;
+ }
+
+ if (isset($config['encoding']) && !empty($config['encoding'])) {
+ $this->setEncoding($config['encoding']);
+ }
+
+ return $this->connected;
+ }
+/**
+ * Disconnects from database.
+ *
+ * @return boolean True if the database could be disconnected, else false
+ */
+ function disconnect() {
+ @mysql_free_result($this->results);
+ $this->connected = !@mysql_close($this->connection);
+ return !$this->connected;
+ }
+/**
+ * Executes given SQL statement.
+ *
+ * @param string $sql SQL statement
+ * @return resource Result resource identifier
+ * @access protected
+ */
+ function _execute($sql) {
+ return mysql_query($sql, $this->connection);
+ }
+/**
+ * Returns an array of sources (tables) in the database.
+ *
+ * @return array Array of tablenames in the database
+ */
+ function listSources() {
+ $cache = parent::listSources();
+ if ($cache != null) {
+ return $cache;
+ }
+ $result = $this->_execute('SHOW TABLES FROM ' . $this->name($this->config['database']) . ';');
+
+ if (!$result) {
+ return array();
+ } else {
+ $tables = array();
+
+ while ($line = mysql_fetch_array($result)) {
+ $tables[] = $line[0];
+ }
+ parent::listSources($tables);
+ return $tables;
+ }
+ }
+/**
+ * Returns an array of the fields in given table name.
+ *
+ * @param string $tableName Name of database table to inspect
+ * @return array Fields in table. Keys are name and type
+ */
+ function describe(&$model) {
+ $cache = parent::describe($model);
+ if ($cache != null) {
+ return $cache;
+ }
+ $fields = false;
+ $cols = $this->query('DESCRIBE ' . $this->fullTableName($model));
+
+ foreach ($cols as $column) {
+ $colKey = array_keys($column);
+ if (isset($column[$colKey[0]]) && !isset($column[0])) {
+ $column[0] = $column[$colKey[0]];
+ }
+ if (isset($column[0])) {
+ $fields[$column[0]['Field']] = array(
+ 'type' => $this->column($column[0]['Type']),
+ 'null' => ($column[0]['Null'] == 'YES' ? true : false),
+ 'default' => $column[0]['Default'],
+ 'length' => $this->length($column[0]['Type']),
+ );
+ if(!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) {
+ $fields[$column[0]['Field']]['key'] = $this->index[$column[0]['Key']];
+ }
+ if(!empty($column[0]['Extra'])) {
+ $fields[$column[0]['Field']]['extra'] = $column[0]['Extra'];
+ }
+ }
+ }
+ $this->__cacheDescription($this->fullTableName($model, false), $fields);
+ return $fields;
+ }
+/**
+ * Returns a quoted and escaped string of $data for use in an SQL statement.
+ *
+ * @param string $data String to be prepared for use in an SQL statement
+ * @param string $column The column into which this data will be inserted
+ * @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided
+ * @return string Quoted and escaped data
+ */
+ function value($data, $column = null, $safe = false) {
+ $parent = parent::value($data, $column, $safe);
+
+ if ($parent != null) {
+ return $parent;
+ } elseif ($data === null || (is_array($data) && empty($data))) {
+ return 'NULL';
+ } elseif ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') {
+ return "''";
+ }
+ if (empty($column)) {
+ $column = $this->introspectType($data);
+ }
+
+ switch ($column) {
+ case 'boolean':
+ return $this->boolean((bool)$data);
+ break;
+ case 'integer':
+ case 'float':
+ if ($data === '') {
+ return 'NULL';
+ }
+ if ((is_int($data) || is_float($data) || $data === '0') || (
+ is_numeric($data) && strpos($data, ',') === false &&
+ $data[0] != '0' && strpos($data, 'e') === false)) {
+ return $data;
+ }
+ default:
+ $data = "'" . mysql_real_escape_string($data, $this->connection) . "'";
+ break;
+ }
+ return $data;
+ }
+/**
+ * Begin a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions).
+ */
+ function begin(&$model) {
+ if (parent::begin($model)) {
+ if ($this->execute('START TRANSACTION')) {
+ $this->_transactionStarted = true;
+ return true;
+ }
+ }
+ return false;
+ }
+/**
+ * Commit a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function commit(&$model) {
+ if (parent::commit($model)) {
+ $this->_transactionStarted = false;
+ return $this->execute('COMMIT');
+ }
+ return false;
+ }
+/**
+ * Rollback a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function rollback(&$model) {
+ if (parent::rollback($model)) {
+ return $this->execute('ROLLBACK');
+ }
+ return false;
+ }
+/**
+ * Returns a formatted error message from previous database operation.
+ *
+ * @return string Error message with error number
+ */
+ function lastError() {
+ if (mysql_errno($this->connection)) {
+ return mysql_errno($this->connection).': '.mysql_error($this->connection);
+ }
+ return null;
+ }
+/**
+ * Returns number of affected rows in previous database operation. If no previous operation exists,
+ * this returns false.
+ *
+ * @return int Number of affected rows
+ */
+ function lastAffected() {
+ if ($this->_result) {
+ return mysql_affected_rows($this->connection);
+ }
+ return null;
+ }
+/**
+ * Returns number of rows in previous resultset. If no previous resultset exists,
+ * this returns false.
+ *
+ * @return int Number of rows in resultset
+ */
+ function lastNumRows() {
+ if ($this->_result and is_resource($this->_result)) {
+ return @mysql_num_rows($this->_result);
+ }
+ return null;
+ }
+/**
+ * Returns the ID generated from the previous INSERT operation.
+ *
+ * @param unknown_type $source
+ * @return in
+ */
+ function lastInsertId($source = null) {
+ $id = $this->fetchRow('SELECT LAST_INSERT_ID() AS insertID', false);
+ if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0]['insertID'])) {
+ return $id[0]['insertID'];
+ }
+
+ return null;
+ }
+/**
+ * Converts database-layer column types to basic types
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ * @return string Abstract column type (i.e. "string")
+ */
+ function column($real) {
+ if (is_array($real)) {
+ $col = $real['name'];
+ if (isset($real['limit'])) {
+ $col .= '('.$real['limit'].')';
+ }
+ return $col;
+ }
+
+ $col = r(')', '', $real);
+ $limit = $this->length($real);
+ @list($col,$vals) = explode('(', $col);
+
+ if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
+ return $col;
+ }
+ if ($col == 'tinyint' && $limit == 1) {
+ return 'boolean';
+ }
+ if (strpos($col, 'int') !== false) {
+ return 'integer';
+ }
+ if (strpos($col, 'char') !== false || $col == 'tinytext') {
+ return 'string';
+ }
+ if (strpos($col, 'text') !== false) {
+ return 'text';
+ }
+ if (strpos($col, 'blob') !== false) {
+ return 'binary';
+ }
+ if (in_array($col, array('float', 'double', 'decimal'))) {
+ return 'float';
+ }
+ if (strpos($col, 'enum') !== false) {
+ return "enum($vals)";
+ }
+ if ($col == 'boolean') {
+ return $col;
+ }
+ return 'text';
+ }
+/**
+ * Gets the length of a database-native column description, or null if no length
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ * @return int An integer representing the length of the column
+ */
+ function length($real) {
+ $col = r(array(')', 'unsigned'), '', $real);
+ $limit = null;
+
+ if (strpos($col, '(') !== false) {
+ list($col, $limit) = explode('(', $col);
+ }
+
+ if ($limit != null) {
+ return intval($limit);
+ }
+ return null;
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $results
+ */
+ function resultSet(&$results) {
+ $this->results =& $results;
+ $this->map = array();
+ $num_fields = mysql_num_fields($results);
+ $index = 0;
+ $j = 0;
+
+ while ($j < $num_fields) {
+
+ $column = mysql_fetch_field($results,$j);
+ if (!empty($column->table)) {
+ $this->map[$index++] = array($column->table, $column->name);
+ } else {
+ $this->map[$index++] = array(0, $column->name);
+ }
+ $j++;
+ }
+ }
+/**
+ * Fetches the next row from the current result set
+ *
+ * @return unknown
+ */
+ function fetchResult() {
+ if ($row = mysql_fetch_row($this->results)) {
+ $resultRow = array();
+ $i = 0;
+ foreach ($row as $index => $field) {
+ list($table, $column) = $this->map[$index];
+ $resultRow[$table][$column] = $row[$index];
+ $i++;
+ }
+ return $resultRow;
+ } else {
+ return false;
+ }
+ }
+/**
+ * Sets the database encoding
+ *
+ * @param string $enc Database encoding
+ * @return void
+ */
+ function setEncoding($enc) {
+ return $this->_execute('SET NAMES ' . $enc) != false;
+ }
+/**
+ * Gets the database encoding
+ *
+ * @return string The database encoding
+ */
+ function getEncoding() {
+ return mysql_client_encoding($this->connection);
+ }
+/**
+ * Returns an array of the indexes in given table name.
+ *
+ * @param string $model Name of model to inspect
+ * @return array Fields in table. Keys are column and unique
+ */
+ function index($model) {
+ $index = array();
+ $table = $this->fullTableName($model, false);
+ if($table) {
+ $indexes = $this->query('SHOW INDEX FROM ' . $table);
+ $keys = Set::extract($indexes, '{n}.STATISTICS');
+ foreach ($keys as $i => $key) {
+ if(!isset($index[$key['Key_name']])) {
+ $index[$key['Key_name']]['column'] = $key['Column_name'];
+ $index[$key['Key_name']]['unique'] = ife($key['Non_unique'] == 0, 1, 0);
+ } else {
+ if(!is_array($index[$key['Key_name']]['column'])) {
+ $col[] = $index[$key['Key_name']]['column'];
+ }
+ $col[] = $key['Column_name'];
+ $index[$key['Key_name']]['column'] = $col;
+ }
+ }
+ }
+ return $index;
+ }
+/**
+ * Generate a MySQL schema for the given Schema object
+ *
+ * @param object $schema An instance of a subclass of CakeSchema
+ * @param string $table Optional. If specified only the table name given will be generated.
+ * Otherwise, all tables defined in the schema are generated.
+ * @return string
+ */
+ function createSchema($schema, $table = null) {
+ if (!is_a($schema, 'CakeSchema')) {
+ trigger_error(__('Invalid schema object', true), E_USER_WARNING);
+ return null;
+ }
+ $out = '';
+ foreach ($schema->tables as $curTable => $columns) {
+ if (!$table || $table == $curTable) {
+ $out .= 'CREATE TABLE ' . $this->fullTableName($curTable) . " (\n";
+ $cols = $colList = $index = array();
+ $primary = null;
+ foreach ($columns as $name => $col) {
+ if (is_string($col)) {
+ $col = array('type' => $col);
+ }
+ if (isset($col['key']) && $col['key'] == 'primary') {
+ $primary = $name;
+ }
+ if($name !== 'indexes') {
+ $col['name'] = $name;
+ if(!isset($col['type'])) {
+ $col['type'] = 'string';
+ }
+ $cols[] = $this->buildColumn($col);
+ } else {
+ $index[] = $this->buildIndex($col);
+ }
+
+ }
+ if(empty($index) && !empty($primary)) {
+ $col = array('PRIMARY' => array('column'=> $primary, 'unique' => 1));
+ $index[] = $this->buildIndex($col);
+ }
+ $out .= "\t" . join(",\n\t", $cols) . ",\n\t". join(",\n\t", $index) . "\n);\n\n";
+ }
+ }
+ return $out;
+ }
+/**
+ * Generate a MySQL Alter Table syntax for the given Schema comparison
+ *
+ * @param unknown_type $schema
+ * @return unknown
+ */
+ function alterSchema($compare, $table = null) {
+ if(!is_array($compare)) {
+ return false;
+ }
+ $out = '';
+ $colList = array();
+ foreach($compare as $curTable => $types) {
+ if (!$table || $table == $curTable) {
+ $out .= 'ALTER TABLE ' . $this->fullTableName($curTable) . " \n";
+ foreach($types as $type => $column) {
+ switch($type) {
+ case 'add':
+ foreach($column as $field => $col) {
+ $col['name'] = $field;
+ $alter = 'ADD '.$this->buildColumn($col);
+ if(isset($col['after'])) {
+ $alter .= ' AFTER '. $this->name($col['after']);
+ }
+ $colList[] = $alter;
+ }
+ break;
+ case 'drop':
+ foreach($column as $field => $col) {
+ $col['name'] = $field;
+ $colList[] = 'DROP '.$this->name($field);
+ }
+ break;
+ case 'change':
+ foreach($column as $field => $col) {
+ if(!isset($col['name'])) {
+ $col['name'] = $field;
+ }
+ $colList[] = 'CHANGE '. $this->name($field).' '.$this->buildColumn($col);
+ }
+ break;
+ }
+ }
+ $out .= "\t" . join(",\n\t", $colList) . ";\n\n";
+ }
+ }
+ return $out;
+ }
+/**
+ * Generate a MySQL Drop table for the given Schema object
+ *
+ * @param object $schema An instance of a subclass of CakeSchema
+ * @param string $table Optional. If specified only the table name given will be generated.
+ * Otherwise, all tables defined in the schema are generated.
+ * @return string
+ */
+ function dropSchema($schema, $table = null) {
+ if (!is_a($schema, 'CakeSchema')) {
+ trigger_error(__('Invalid schema object', true), E_USER_WARNING);
+ return null;
+ }
+ $out = '';
+ foreach ($schema->tables as $curTable => $columns) {
+ if (!$table || $table == $curTable) {
+ $out .= 'DROP TABLE IF EXISTS ' . $this->fullTableName($curTable) . ";\n";
+ }
+ }
+ return $out;
+ }
+/**
+ * Generate a MySQL-native column schema string
+ *
+ * @param array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]),
+ * where options can be 'default', 'length', or 'key'.
+ * @return string
+ */
+ function buildColumn($column) {
+ $name = $type = null;
+ $column = am(array('null' => true), $column);
+ extract($column);
+
+ if (empty($name) || empty($type)) {
+ trigger_error('Column name or type not defined in schema', E_USER_WARNING);
+ return null;
+ }
+
+ if (!isset($this->columns[$type])) {
+ trigger_error("Column type {$type} does not exist", E_USER_WARNING);
+ return null;
+ }
+
+ $real = $this->columns[$type];
+ $out = $this->name($name) . ' ' . $real['name'];
+
+ if (isset($real['limit']) || isset($real['length']) || isset($column['limit']) || isset($column['length'])) {
+ if (isset($column['length'])) {
+ $length = $column['length'];
+ } elseif (isset($column['limit'])) {
+ $length = $column['limit'];
+ } elseif (isset($real['length'])) {
+ $length = $real['length'];
+ } else {
+ $length = $real['limit'];
+ }
+ $out .= '(' . $length . ')';
+ }
+ if (isset($column['key']) && $column['key'] == 'primary' && (isset($column['extra']) && $column['extra'] == 'auto_increment')) {
+ $out .= ' NOT NULL AUTO_INCREMENT';
+ } elseif (isset($column['key']) && $column['key'] == 'primary') {
+ $out .= ' NOT NULL';
+ } elseif (isset($column['default']) && isset($column['null']) && $column['null'] == false) {
+ $out .= ' DEFAULT ' . $this->value($column['default'], $type) . ' NOT NULL';
+ } elseif (isset($column['default'])) {
+ $out .= ' DEFAULT ' . $this->value($column['default'], $type);
+ } elseif (isset($column['null']) && $column['null'] == true) {
+ $out .= ' DEFAULT NULL';
+ } elseif (isset($column['null']) && $column['null'] == false) {
+ $out .= ' NOT NULL';
+ }
+
+ return $out;
+ }
+/**
+ * Format indexes for create table
+ *
+ * @param array $indexes
+ * @return string
+ */
+ function buildIndex($indexes) {
+ $join = array();
+ foreach ($indexes as $name => $value) {
+ $out = '';
+ if ($name == 'PRIMARY') {
+ $out .= 'PRIMARY ';
+ $name = null;
+ } else {
+ if (!empty($value['unique'])) {
+ $out .= 'UNIQUE ';
+ }
+ }
+ if (is_array($value['column'])) {
+ $out .= 'KEY '. $name .' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
+ } else {
+ $out .= 'KEY '. $name .' (' . $this->name($value['column']) . ')';
+ }
+ $join[] = $out;
+ }
+ return join(",\n\t", $join);
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mysqli.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mysqli.php
new file mode 100644
index 0000000..e1156b8
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_mysqli.php
@@ -0,0 +1,441 @@
+<?php
+/* SVN FILE: $Id: dbo_mysqli.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * MySQLi layer for DBO
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ * @since CakePHP(tm) v 1.1.4.2974
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Short description for class.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ */
+class DboMysqli extends DboSource {
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $description = "Mysqli DBO Driver";
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $startQuote = "`";
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $endQuote = "`";
+/**
+ * Base configuration settings for Mysqli driver
+ *
+ * @var array
+ */
+ var $_baseConfig = array('persistent' => true,
+ 'host' => 'localhost',
+ 'login' => 'root',
+ 'password' => '',
+ 'database' => 'cake',
+ 'port' => '3306',
+ 'connect' => 'mysqli_connect');
+/**
+ * Mysqli column definition
+ *
+ * @var array
+ */
+ var $columns = array('primary_key' => array('name' => 'int(11) DEFAULT NULL auto_increment'),
+ 'string' => array('name' => 'varchar', 'limit' => '255'),
+ 'text' => array('name' => 'text'),
+ 'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
+ 'float' => array('name' => 'float', 'formatter' => 'floatval'),
+ 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
+ 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
+ 'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'),
+ 'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'),
+ 'binary' => array('name' => 'blob'),
+ 'boolean' => array('name' => 'tinyint', 'limit' => '1'));
+/**
+ * Connects to the database using options in the given configuration array.
+ *
+ * @return boolean True if the database could be connected, else false
+ */
+ function connect() {
+ $config = $this->config;
+ $this->connected = false;
+ $this->connection = mysqli_connect($config['host'], $config['login'], $config['password'], $config['database'], $config['port']);
+
+ if ($this->connection !== false) {
+ $this->connected = true;
+ }
+
+ if (!empty($config['encoding'])) {
+ $this->setEncoding($config['encoding']);
+ }
+ return $this->connected;
+ }
+/**
+ * Disconnects from database.
+ *
+ * @return boolean True if the database could be disconnected, else false
+ */
+ function disconnect() {
+ @mysqli_free_result($this->results);
+ $this->connected = !@mysqli_close($this->connection);
+ return !$this->connected;
+ }
+/**
+ * Executes given SQL statement.
+ *
+ * @param string $sql SQL statement
+ * @return resource Result resource identifier
+ * @access protected
+ */
+ function _execute($sql) {
+ return mysqli_query($this->connection, $sql);
+ }
+/**
+ * Returns an array of sources (tables) in the database.
+ *
+ * @return array Array of tablenames in the database
+ */
+ function listSources() {
+ $cache = parent::listSources();
+ if ($cache != null) {
+ return $cache;
+ }
+ $result = $this->_execute('SHOW TABLES FROM ' . $this->name($this->config['database']) . ';');
+
+ if (!$result) {
+ return array();
+ } else {
+ $tables = array();
+
+ while ($line = mysqli_fetch_array($result)) {
+ $tables[] = $line[0];
+ }
+ parent::listSources($tables);
+ return $tables;
+ }
+ }
+/**
+ * Returns an array of the fields in given table name.
+ *
+ * @param string $tableName Name of database table to inspect
+ * @return array Fields in table. Keys are name and type
+ */
+ function describe(&$model) {
+
+ $cache = parent::describe($model);
+ if ($cache != null) {
+ return $cache;
+ }
+
+ $fields = false;
+ $cols = $this->query('DESCRIBE ' . $this->fullTableName($model));
+
+ foreach ($cols as $column) {
+ $colKey = array_keys($column);
+ if (isset($column[$colKey[0]]) && !isset($column[0])) {
+ $column[0] = $column[$colKey[0]];
+ }
+ if (isset($column[0])) {
+ $fields[$column[0]['Field']] = array(
+ 'type' => $this->column($column[0]['Type']),
+ 'null' => ($column[0]['Null'] == 'YES' ? true : false),
+ 'default' => $column[0]['Default'],
+ 'length' => $this->length($column[0]['Type'])
+ );
+ }
+ }
+
+ $this->__cacheDescription($this->fullTableName($model, false), $fields);
+ return $fields;
+ }
+/**
+ * Returns a quoted and escaped string of $data for use in an SQL statement.
+ *
+ * @param string $data String to be prepared for use in an SQL statement
+ * @param string $column The column into which this data will be inserted
+ * @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided
+ * @return string Quoted and escaped data
+ */
+ function value($data, $column = null, $safe = false) {
+ $parent = parent::value($data, $column, $safe);
+
+ if ($parent != null) {
+ return $parent;
+ }
+
+ if ($data === null) {
+ return 'NULL';
+ }
+
+ if ($data === '') {
+ return "''";
+ }
+
+ switch ($column) {
+ case 'boolean':
+ $data = $this->boolean((bool)$data);
+ break;
+ case 'integer' :
+ case 'float' :
+ case null :
+ if (is_numeric($data) && strpos($data, ',') === false && $data[0] != '0' && strpos($data, 'e') === false) {
+ break;
+ }
+ default:
+ $data = "'" . mysqli_real_escape_string($this->connection, $data) . "'";
+ break;
+ }
+
+ return $data;
+ }
+/**
+ * Begin a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions).
+ */
+ function begin(&$model) {
+ if (parent::begin($model)) {
+ if ($this->execute('START TRANSACTION')) {
+ $this->_transactionStarted = true;
+ return true;
+ }
+ }
+ return false;
+ }
+/**
+ * Commit a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function commit(&$model) {
+ if (parent::commit($model)) {
+ $this->_transactionStarted = false;
+ return $this->execute('COMMIT');
+ }
+ return false;
+ }
+/**
+ * Rollback a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function rollback(&$model) {
+ if (parent::rollback($model)) {
+ return $this->execute('ROLLBACK');
+ }
+ return false;
+ }
+/**
+ * Returns a formatted error message from previous database operation.
+ *
+ * @return string Error message with error number
+ */
+ function lastError() {
+ if (mysqli_errno($this->connection)) {
+ return mysqli_errno($this->connection).': '.mysqli_error($this->connection);
+ }
+ return null;
+ }
+/**
+ * Returns number of affected rows in previous database operation. If no previous operation exists,
+ * this returns false.
+ *
+ * @return int Number of affected rows
+ */
+ function lastAffected() {
+ if ($this->_result) {
+ return mysqli_affected_rows($this->connection);
+ }
+ return null;
+ }
+/**
+ * Returns number of rows in previous resultset. If no previous resultset exists,
+ * this returns false.
+ *
+ * @return int Number of rows in resultset
+ */
+ function lastNumRows() {
+ if ($this->_result and is_object($this->_result)) {
+ return @mysqli_num_rows($this->_result);
+ }
+ return null;
+ }
+/**
+ * Returns the ID generated from the previous INSERT operation.
+ *
+ * @param unknown_type $source
+ * @return in
+ */
+ function lastInsertId($source = null) {
+ $id = $this->fetchRow('SELECT LAST_INSERT_ID() AS insertID', false);
+ if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0]['insertID'])) {
+ return $id[0]['insertID'];
+ }
+
+ return null;
+ }
+/**
+ * Converts database-layer column types to basic types
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ * @return string Abstract column type (i.e. "string")
+ */
+ function column($real) {
+ if (is_array($real)) {
+ $col = $real['name'];
+ if (isset($real['limit'])) {
+ $col .= '('.$real['limit'].')';
+ }
+ return $col;
+ }
+
+ $col = r(')', '', $real);
+ $limit = $this->length($real);
+ @list($col,$vals) = explode('(', $col);
+
+ if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
+ return $col;
+ }
+ if ($col == 'tinyint' && $limit == 1) {
+ return 'boolean';
+ }
+ if (strpos($col, 'int') !== false) {
+ return 'integer';
+ }
+ if (strpos($col, 'char') !== false || $col == 'tinytext') {
+ return 'string';
+ }
+ if (strpos($col, 'text') !== false) {
+ return 'text';
+ }
+ if (strpos($col, 'blob') !== false) {
+ return 'binary';
+ }
+ if (in_array($col, array('float', 'double', 'decimal'))) {
+ return 'float';
+ }
+ if (strpos($col, 'enum') !== false) {
+ return "enum($vals)";
+ }
+ if ($col == 'boolean') {
+ return $col;
+ }
+ return 'text';
+ }
+/**
+ * Gets the length of a database-native column description, or null if no length
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ * @return int An integer representing the length of the column
+ */
+ function length($real) {
+ $col = r(array(')', 'unsigned'), '', $real);
+ $limit = null;
+
+ if (strpos($col, '(') !== false) {
+ list($col, $limit) = explode('(', $col);
+ }
+
+ if ($limit != null) {
+ return intval($limit);
+ }
+ return null;
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $results
+ */
+ function resultSet(&$results) {
+ $this->results =& $results;
+ $this->map = array();
+ $num_fields = mysqli_num_fields($results);
+ $index = 0;
+ $j = 0;
+ while ($j < $num_fields) {
+ $column = mysqli_fetch_field_direct($results, $j);
+ if (!empty($column->table)) {
+ $this->map[$index++] = array($column->table, $column->name);
+ } else {
+ $this->map[$index++] = array(0, $column->name);
+ }
+ $j++;
+ }
+ }
+/**
+ * Fetches the next row from the current result set
+ *
+ * @return unknown
+ */
+ function fetchResult() {
+ if ($row = mysqli_fetch_row($this->results)) {
+ $resultRow = array();
+ $i = 0;
+ foreach ($row as $index => $field) {
+ @list($table, $column) = $this->map[$index];
+ $resultRow[$table][$column] = $row[$index];
+ $i++;
+ }
+ return $resultRow;
+ } else {
+ return false;
+ }
+ }
+/**
+ * Sets the database encoding
+ *
+ * @param string $enc Database encoding
+ * @return void
+ */
+ function setEncoding($enc) {
+ return $this->_execute('SET NAMES ' . $enc) != false;
+ }
+/**
+ * Gets the database encoding
+ *
+ * @return string The database encoding
+ */
+ function getEncoding() {
+ return mysqli_client_encoding($this->connection);
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_odbc.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_odbc.php
new file mode 100644
index 0000000..563627b
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_odbc.php
@@ -0,0 +1,437 @@
+<?php
+/* SVN FILE: $Id: dbo_odbc.php 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ * ODBC for DBO
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ * @since CakePHP(tm) v 0.10.5.1790
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Short description for class.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ */
+class DboOdbc extends DboSource{
+
+/**
+ * Driver description
+ *
+ * @var string
+ */
+ var $description = "ODBC DBO Driver";
+
+/**
+ * Table/column starting quote
+ *
+ * @var string
+ */
+ var $startQuote = "`";
+
+/**
+ * Table/column end quote
+ *
+ * @var string
+ */
+ var $endQuote = "`";
+
+/**
+ * Driver base configuration
+ *
+ * @var array
+ */
+ var $_baseConfig = array('persistent' => true,
+ 'login' => 'root',
+ 'password' => '',
+ 'database' => 'cake',
+ 'connect' => 'odbc_pconnect'
+ );
+
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+
+ var $columns = array();
+
+ // var $columns = array('primary_key' => array('name' => 'int(11) DEFAULT NULL auto_increment'),
+ // 'string' => array('name' => 'varchar', 'limit' => '255'),
+ // 'text' => array('name' => 'text'),
+ // 'integer' => array('name' => 'int', 'limit' => '11'),
+ // 'float' => array('name' => 'float'),
+ // 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s', 'formatter' => 'date'),
+ // 'timestamp' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s', 'formatter' => 'date'),
+ // 'time' => array('name' => 'time', 'format' => 'h:i:s', 'formatter' => 'date'),
+ // 'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'),
+ // 'binary' => array('name' => 'blob'),
+ // 'boolean' => array('name' => 'tinyint', 'limit' => '1'));
+
+/**
+ * Connects to the database using options in the given configuration array.
+ *
+ * @return boolean True if the database could be connected, else false
+ */
+ function connect() {
+ $config = $this->config;
+ $connect = $config['connect'];
+
+ $this->connected = false;
+ $this->connection = $connect($config['database'], $config['login'], $config['password']);
+
+ if ($this->connection) {
+ $this->connected = true;
+ }
+
+ return $this->connected;
+ }
+
+/**
+ * Disconnects from database.
+ *
+ * @return boolean True if the database could be disconnected, else false
+ */
+ function disconnect() {
+ return @odbc_close($this->connection);
+ }
+/**
+ * Executes given SQL statement.
+ *
+ * @param string $sql SQL statement
+ * @return resource Result resource identifier
+ * @access protected
+ */
+ function _execute($sql) {
+ return odbc_exec($this->connection, $sql);
+ }
+/**
+ * Returns an array of sources (tables) in the database.
+ *
+ * @return array Array of tablenames in the database
+ */
+ function listSources() {
+
+ $cache = parent::listSources();
+ if ($cache != null) {
+ return $cache;
+ }
+
+ /*$result = odbc_tables($this->connection);
+ if (function_exists('odbc_fetch_row')) {
+ echo 'GOOD';
+ } else {
+ echo 'BAD';
+ }*/
+
+ $result = odbc_tables($this->connection);
+
+ $tables = array();
+ while (odbc_fetch_row($result)) {
+ array_push($tables, odbc_result($result, "TABLE_NAME"));
+ }
+
+ parent::listSources($tables);
+ return $tables;
+ }
+/**
+ * Returns an array of the fields in given table name.
+ *
+ * @param Model $model Model object to describe
+ * @return array Fields in table. Keys are name and type
+ */
+ function &describe(&$model) {
+ $cache=parent::describe($model);
+
+ if ($cache != null) {
+ return $cache;
+ }
+
+ $fields = array();
+ $sql = 'SELECT * FROM ' . $this->fullTableName($model);
+ $result = odbc_exec($this->connection, $sql);
+
+ $count = odbc_num_fields($result);
+
+ for ($i = 1; $i <= $count; $i++) {
+ $cols[$i - 1] = odbc_field_name($result, $i);
+ }
+
+ foreach ($cols as $column) {
+ $type = odbc_field_type(odbc_exec($this->connection, "SELECT " . $column . " FROM " . $this->fullTableName($model)), 1);
+ $fields[$column] = array('type' => $type);
+ }
+
+ $this->__cacheDescription($model->tablePrefix . $model->table, $fields);
+ return $fields;
+ }
+
+ function name($data) {
+ if ($data == '*') {
+ return '*';
+ }
+
+ $pos = strpos($data, '`');
+
+ if ($pos === false) {
+ $data = '' . str_replace('.', '.', $data) . '';
+ //$data = '`'. str_replace('.', '`.`', $data) .'`';
+ }
+
+ return $data;
+ }
+
+/**
+ * Returns a quoted and escaped string of $data for use in an SQL statement.
+ *
+ * @param string $data String to be prepared for use in an SQL statement
+ * @param string $column The column into which this data will be inserted
+ * @return string Quoted and escaped
+ * @todo Add logic that formats/escapes data based on column type
+ */
+ function value($data, $column = null) {
+ $parent=parent::value($data, $column);
+
+ if ($parent != null) {
+ return $parent;
+ }
+
+ if ($data === null) {
+ return 'NULL';
+ }
+
+ // $data = mysql_real_escape_string($data, $this->connection);
+
+ if (!is_numeric($data)) {
+ $return = "'" . $data . "'";
+ } else {
+ $return = $data;
+ }
+
+ return $return;
+ }
+
+/**
+ * Not sure about this one, MySQL needs it but does ODBC? Safer just to leave it
+ * Translates between PHP boolean values and MySQL (faked) boolean values
+ *
+ * @param mixed $data Value to be translated
+ * @return mixed Converted boolean value
+ */
+ function boolean($data) {
+ if ($data === true || $data === false) {
+ if ($data === true) {
+ return 1;
+ }
+
+ return 0;
+ } else {
+ if (intval($data !== 0)) {
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+/**
+ * Begin a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions).
+ */
+ function begin(&$model) {
+ if (parent::begin($model)) {
+ if (odbc_autocommit($this->connection, false)) {
+ $this->_transactionStarted = true;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+/**
+ * Commit a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function commit(&$model) {
+ if (parent::commit($model)) {
+ if (odbc_commit($this->connection)) {
+ $this->_transactionStarted = false;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+/**
+ * Rollback a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function rollback(&$model) {
+ if (parent::rollback($model)) {
+ $this->_transactionStarted=false;
+ return odbc_rollback($this->connection);
+ }
+
+ return false;
+ }
+
+/**
+ * Returns a formatted error message from previous database operation.
+ *
+ * @return string Error message with error number
+ */
+ function lastError() {
+ if (odbc_error($this->connection)) {
+ return odbc_error($this->connection) . ': ' . odbc_errormsg($this->connection);
+ }
+
+ return null;
+ }
+
+/**
+ * Returns number of affected rows in previous database operation. If no previous operation exists,
+ * this returns false.
+ *
+ * @return int Number of affected rows
+ */
+ function lastAffected() {
+ if ($this->_result) {
+ return null;
+ }
+
+ return null;
+ }
+
+/**
+ * Returns number of rows in previous resultset. If no previous resultset exists,
+ * this returns false.
+ *
+ * @return int Number of rows in resultset
+ */
+ function lastNumRows() {
+ if ($this->_result) {
+ return@odbc_num_rows($this->_result);
+ }
+
+ return null;
+ }
+
+/**
+ * Returns the ID generated from the previous INSERT operation.
+ *
+ * @param unknown_type $source
+ * @return int
+ */
+ function lastInsertId($source = null) {
+ $result=$this->fetchRow('SELECT @@IDENTITY');
+ return $result[0];
+ }
+
+/**
+ * Enter description here...
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ */
+ function column($real) {
+ if (is_array($real)) {
+ $col=$real['name'];
+
+ if (isset($real['limit'])) {
+ $col .= '(' . $real['limit'] . ')';
+ }
+
+ return $col;
+ }
+
+ return $real;
+ }
+
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $results
+ */
+ function resultSet(&$results) {
+ $this->results=&$results;
+ $this->map=array();
+ $num_fields =odbc_num_fields($results);
+ $index =0;
+ $j =0;
+
+ while ($j < $num_fields) {
+ $column = odbc_fetch_array($results, $j);
+
+ if (!empty($column->table)) {
+ $this->map[$index++] = array($column->table,
+ $column->name);
+ } else {
+ echo array(0,
+ $column->name);
+
+ $this->map[$index++]=array(0,
+ $column->name);
+ }
+
+ $j++;
+ }
+ }
+
+/**
+ * Fetches the next row from the current result set
+ *
+ * @return unknown
+ */
+ function fetchResult() {
+ if ($row = odbc_fetch_row($this->results)) {
+ $resultRow=array();
+ $i=0;
+
+ foreach ($row as $index => $field) {
+ list($table, $column) = $this->map[$index];
+ $resultRow[$table][$column]=$row[$index];
+ $i++;
+ }
+
+ return $resultRow;
+ } else {
+ return false;
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_pear.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_pear.php
new file mode 100644
index 0000000..f5e57eb
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_pear.php
@@ -0,0 +1,241 @@
+<?php
+/* SVN FILE: $Id: dbo_pear.php 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ * {@link http://pear.php.net/package/DB PEAR::DB} layer for DBO.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Create an include path required PEAR libraries.
+ */
+ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . PEAR);
+vendor ('Pear/DB');
+
+/**
+ * {@link http://pear.php.net/package/DB PEAR::DB} layer for DBO.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ */
+class DboPear extends DboSource{
+
+/**
+ * PEAR::DB object with which we connect.
+ *
+ * @var DB The connection object.
+ * @access private
+ */
+ var $_pear = null;
+
+/**
+ * Connects to the database using options in the given configuration array.
+ *
+ * @param array $config Configuration array for connecting
+ * @return boolean True if the database could be connected, else false
+ */
+ function connect($config) {
+ $this->config =$config;
+ $dsn =$config['driver'] . '://' . $config['login'] . ':' . $config['password'] . '@'
+ . $config['host'] . '/' . $config['database'];
+ $options=array('debug' => Configure::read() - 1,
+ 'portability' => DB_PORTABILITY_ALL,);
+
+ $this->_pear =&DB::connect($dsn, $options);
+ $this->connected=$this->_pear ? true : false;
+ return !(PEAR::isError($this->_pear));
+ }
+
+/**
+ * Disconnects from database.
+ *
+ * @return boolean True if the database could be disconnected, else false
+ */
+ function disconnect() {
+ die (__('Please implement DBO::disconnect() first.'));
+ }
+
+/**
+ * Executes given SQL statement.
+ *
+ * @param string $sql SQL statement
+ * @return resource Result resource identifier
+ */
+ function execute($sql) {
+ return $this->_pear->query($sql);
+ }
+
+/**
+ * Returns a row from given resultset as an array .
+ *
+ * @return array The fetched row as an array
+ */
+ function fetchRow($sql = null) {
+ if (!empty($sql) && is_string($sql) && strlen($sql) > 5) {
+ if (!$this->execute($sql)) {
+ return null;
+ }
+ }
+ return $this->_result->fetchRow(DB_FETCHMODE_ASSOC);
+ }
+
+/**
+ * Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
+ * :WARNING: :TODO: POSTGRESQL & MYSQL ONLY! PEAR::DB doesn't support universal table listing.
+ *
+ * @return array Array of tablenames in the database
+ */
+ function tablesList() {
+ $driver=$this->config['driver'];
+ $tables=array();
+
+ if ('postgres' == $driver) {
+ $sql ="SELECT a.relname AS name
+ FROM pg_class a, pg_user b
+ WHERE ( relkind = 'r') and relname !~ '^pg_' AND relname !~ '^sql_'
+ AND relname !~ '^xin[vx][0-9]+' AND b.usesysid = a.relowner
+ AND NOT (EXISTS (SELECT viewname FROM pg_views WHERE viewname=a.relname));";
+
+ $result=$this->all($sql);
+
+ foreach ($result as $item) {
+ $tables[] = $item['name'];
+ }
+ } elseif ('mysql' == $driver) {
+ $result=array();
+ $result=mysql_list_tables($this->config['database']);
+
+ while ($item = mysql_fetch_array($result)) {
+ $tables[] = $item[0];
+ }
+ } else {
+ die (__('Please implement DBO_Pear::tablesList() for your database driver.'));
+ }
+
+ if (!$result) {
+ trigger_error(ERROR_NO_TABLE_LIST, E_USER_ERROR);
+ exit;
+ } else {
+ return $tables;
+ }
+ }
+
+/**
+ * Returns an array of the fields in given table name.
+ *
+ * @param string $tableName Name of database table to inspect
+ * @return array Fields in table. Keys are name and type
+ */
+ function fields($tableName) {
+ $data =$this->_pear->tableInfo($tableName);
+ $fields=false;
+
+ foreach ($data as $item) {
+ $fields[] = array('name' => $item['name'],
+ 'type' => $item['type']);
+ }
+
+ return $fields;
+ }
+
+/**
+ * Returns a quoted and escaped string of $data for use in an SQL statement.
+ *
+ * @param string $data String to be prepared for use in an SQL statement
+ * @return string Quoted and escaped
+ */
+ function prepareValue($data) {
+ return $this->_pear->quoteSmart($data);
+ }
+
+/**
+ * Returns a formatted error message from previous database operation.
+ *
+ * @return string Error message
+ */
+ function lastError() {
+ return PEAR::isError($this->_result) ? $this->_result->getMessage() : null;
+ }
+
+/**
+ * Returns number of affected rows in previous database operation. If no previous operation exists, this returns false.
+ *
+ * @return int Number of affected rows
+ */
+ function lastAffected() {
+ return $this->_pear->affectedRows();
+ }
+
+/**
+ * Returns number of rows in previous resultset. If no previous resultset exists,
+ * this returns false.
+ *
+ * @return int Number of rows in resultset
+ */
+ function lastNumRows() {
+ if (method_exists($this->_result, 'numRows')) {
+ return $this->_result->numRows();
+ } else {
+ return false;
+ }
+ }
+
+/**
+ * Returns the ID generated from the previous INSERT operation.
+ *
+ * @param string $table Name of the database table
+ * @return int
+ */
+ function lastInsertId($table) {
+ return $this->field('id', "SELECT MAX(id) FROM {$table}");
+ }
+
+/**
+ * Returns a limit statement in the correct format for the particular database.
+ *
+ * @param int $limit Limit of results returned
+ * @param int $offset Offset from which to start results
+ * @return string SQL limit/offset statement
+ */
+ function selectLimit($limit, $offset = '0') {
+ return ' ' . $this->_pear->modifyLimitQuery('', $offset, $limit);
+ }
+/**
+ * Inserts multiple values into a join table
+ *
+ * @param string $table
+ * @param string $fields
+ * @param array $values
+ */
+ function insertMulti($table, $fields, $values) {
+ $count = count($values);
+ for ($x = 0; $x < $count; $x++) {
+ $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_postgres.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_postgres.php
new file mode 100644
index 0000000..f77942c
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_postgres.php
@@ -0,0 +1,595 @@
+<?php
+/* SVN FILE: $Id: dbo_postgres.php 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ * PostgreSQL layer for DBO.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ * @since CakePHP(tm) v 0.9.1.114
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * PostgreSQL layer for DBO.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ */
+class DboPostgres extends DboSource {
+
+ var $description = "PostgreSQL DBO Driver";
+
+ var $_baseConfig = array(
+ 'connect' => 'pg_pconnect',
+ 'persistent' => true,
+ 'host' => 'localhost',
+ 'login' => 'root',
+ 'password' => '',
+ 'database' => 'cake',
+ 'schema' => 'public',
+ 'port' => 5432,
+ 'encoding' => ''
+ );
+
+ var $columns = array(
+ 'primary_key' => array('name' => 'serial NOT NULL'),
+ 'string' => array('name' => 'varchar', 'limit' => '255'),
+ 'text' => array('name' => 'text'),
+ 'integer' => array('name' => 'integer', 'formatter' => 'intval'),
+ 'float' => array('name' => 'float', 'formatter' => 'floatval'),
+ 'datetime' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
+ 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
+ 'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'),
+ 'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'),
+ 'binary' => array('name' => 'bytea'),
+ 'boolean' => array('name' => 'boolean'),
+ 'number' => array('name' => 'numeric'),
+ 'inet' => array('name' => 'inet')
+ );
+
+ var $startQuote = '"';
+
+ var $endQuote = '"';
+/**
+ * Contains mappings of custom auto-increment sequences, if a table uses a sequence name
+ * other than what is dictated by convention.
+ *
+ * @var array
+ */
+ var $_sequenceMap = array();
+/**
+ * Connects to the database using options in the given configuration array.
+ *
+ * @return True if successfully connected.
+ */
+ function connect() {
+
+ $config = $this->config;
+ $connect = $config['connect'];
+ $this->connection = $connect("host='{$config['host']}' port='{$config['port']}' dbname='{$config['database']}' user='{$config['login']}' password='{$config['password']}'");
+
+ if ($this->connection) {
+ $this->connected = true;
+ $this->_execute("SET search_path TO " . $config['schema']);
+ } else {
+ $this->connected = false;
+ }
+ if (!empty($config['encoding'])) {
+ $this->setEncoding($config['encoding']);
+ }
+
+ return $this->connected;
+ }
+
+/**
+ * Disconnects from database.
+ *
+ * @return boolean True if the database could be disconnected, else false
+ */
+ function disconnect() {
+ @pg_free_result($this->results);
+ $this->connected = !@pg_close($this->connection);
+ return !$this->connected;
+ }
+
+/**
+ * Executes given SQL statement.
+ *
+ * @param string $sql SQL statement
+ * @return resource Result resource identifier
+ */
+ function _execute($sql) {
+ return pg_query($this->connection, $sql);
+ }
+/**
+ * Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
+ *
+ * @return array Array of tablenames in the database
+ */
+ function listSources() {
+ $cache = parent::listSources();
+
+ if ($cache != null) {
+ return $cache;
+ }
+
+ $schema = $this->config['schema'];
+ $sql = "SELECT table_name as name FROM INFORMATION_SCHEMA.tables WHERE table_schema = '{$schema}';";
+ $result = $this->fetchAll($sql);
+
+ if (!$result) {
+ return array();
+ } else {
+ $tables = array();
+
+ foreach ($result as $item) {
+ $tables[] = $item[0]['name'];
+ }
+
+ parent::listSources($tables);
+ return $tables;
+ }
+ }
+
+/**
+ * Returns an array of the fields in given table name.
+ *
+ * @param string $tableName Name of database table to inspect
+ * @return array Fields in table. Keys are name and type
+ */
+ function &describe(&$model) {
+ if (isset($model->sequence)) {
+ $this->_sequenceMap[$this->fullTableName($model, false)] = $model->sequence;
+ }
+
+ $cache = parent::describe($model);
+ if ($cache != null) {
+ return $cache;
+ }
+
+ $fields = false;
+ $cols = $this->fetchAll("SELECT DISTINCT column_name AS name, data_type AS type, is_nullable AS null, column_default AS default, ordinal_position AS position, character_maximum_length AS char_length, character_octet_length AS oct_length FROM information_schema.columns WHERE table_name =" . $this->value($model->tablePrefix . $model->table) . " ORDER BY position");
+
+ foreach ($cols as $column) {
+ $colKey = array_keys($column);
+
+ if (isset($column[$colKey[0]]) && !isset($column[0])) {
+ $column[0] = $column[$colKey[0]];
+ }
+
+ if (isset($column[0])) {
+ $c = $column[0];
+ if (strpos($c['default'], 'nextval(') === 0) {
+ $c['default'] = null;
+ }
+ if (!empty($c['char_length'])) {
+ $length = intval($c['char_length']);
+ } elseif (!empty($c['oct_length'])) {
+ $length = intval($c['oct_length']);
+ } else {
+ $length = $this->length($c['type']);
+ }
+ $fields[$c['name']] = array(
+ 'type' => $this->column($c['type']),
+ 'null' => ($c['null'] == 'NO' ? false : true),
+ 'default' => $c['default'],
+ 'length' => $length
+ );
+ }
+ }
+ $this->__cacheDescription($model->tablePrefix . $model->table, $fields);
+ return $fields;
+ }
+/**
+ * Returns a quoted and escaped string of $data for use in an SQL statement.
+ *
+ * @param string $data String to be prepared for use in an SQL statement
+ * @param string $column The column into which this data will be inserted
+ * @return string Quoted and escaped
+ * @todo Add logic that formats/escapes data based on column type
+ */
+ function value($data, $column = null) {
+
+ $parent = parent::value($data, $column);
+ if ($parent != null) {
+ return $parent;
+ }
+
+ if ($data === null) {
+ return 'NULL';
+ }
+
+ switch($column) {
+ case 'inet':
+ if (!strlen($data)) {
+ return 'DEFAULT';
+ } else {
+ $data = pg_escape_string($data);
+ }
+ break;
+ case 'integer':
+ if ($data === '') {
+ return 'DEFAULT';
+ } else {
+ $data = pg_escape_string($data);
+ }
+ break;
+ case 'binary':
+ $data = pg_escape_bytea($data);
+
+ break;
+ case 'boolean':
+ default:
+ if ($data === true) {
+ return 'TRUE';
+ } elseif ($data === false) {
+ return 'FALSE';
+ }
+ $data = pg_escape_string($data);
+ break;
+ }
+ return "'" . $data . "'";
+ }
+
+/**
+ * Begin a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions).
+ */
+ function begin(&$model) {
+ if (parent::begin($model)) {
+ if ($this->execute('BEGIN')) {
+ $this->_transactionStarted = true;
+ return true;
+ }
+ }
+ return false;
+ }
+
+/**
+ * Commit a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function commit(&$model) {
+ if (parent::commit($model)) {
+ $this->_transactionStarted = false;
+ return $this->execute('COMMIT');
+ }
+ return false;
+ }
+
+/**
+ * Rollback a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function rollback(&$model) {
+ if (parent::rollback($model)) {
+ return $this->execute('ROLLBACK');
+ }
+ return false;
+ }
+
+/**
+ * Returns a formatted error message from previous database operation.
+ *
+ * @return string Error message
+ */
+ function lastError() {
+ $last_error = pg_last_error($this->connection);
+ if ($last_error) {
+ return $last_error;
+ }
+ return null;
+ }
+
+/**
+ * Returns number of affected rows in previous database operation. If no previous operation exists, this returns false.
+ *
+ * @return int Number of affected rows
+ */
+ function lastAffected() {
+ if ($this->_result) {
+ $return = pg_affected_rows($this->_result);
+ return $return;
+ }
+ return false;
+ }
+/**
+ * Returns number of rows in previous resultset. If no previous resultset exists,
+ * this returns false.
+ *
+ * @return int Number of rows in resultset
+ */
+ function lastNumRows() {
+ if ($this->_result) {
+ $return = pg_num_rows($this->_result);
+ return $return;
+ }
+ return false;
+ }
+/**
+ * Returns the ID generated from the previous INSERT operation.
+ *
+ * @param string $source Name of the database table
+ * @param string $field Name of the ID database field. Defaults to "id"
+ * @return int
+ */
+ function lastInsertId($source, $field = 'id') {
+ foreach ($this->__descriptions[$source] as $name => $sourceinfo) {
+ if (strcasecmp($name, $field) == 0) {
+ break;
+ }
+ }
+
+ if (isset($this->_sequenceMap[$source])) {
+ $seq = $this->_sequenceMap[$source];
+ } elseif (preg_match('/^nextval\(\'(\w+)\'/', $sourceinfo['default'], $matches)) {
+ $seq = $matches[1];
+ } else {
+ $seq = "{$source}_{$field}_seq";
+ }
+
+ $res = $this->rawQuery("SELECT last_value AS max FROM \"{$seq}\"");
+ $data = $this->fetchRow($res);
+ return $data[0]['max'];
+ }
+/**
+ * Generates the fields list of an SQL query.
+ *
+ * @param Model $model
+ * @param string $alias Alias tablename
+ * @param mixed $fields
+ * @return array
+ */
+ function fields(&$model, $alias = null, $fields = array(), $quote = true) {
+ if (empty($alias)) {
+ $alias = $model->name;
+ }
+ $fields = parent::fields($model, $alias, $fields, false);
+
+ if (!$quote) {
+ return $fields;
+ }
+ $count = count($fields);
+
+ if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false) {
+ for ($i = 0; $i < $count; $i++) {
+ if (!preg_match('/^.+\\(.*\\)/', $fields[$i]) && !preg_match('/\s+AS\s+/', $fields[$i])) {
+ $prepend = '';
+ if (strpos($fields[$i], 'DISTINCT') !== false) {
+ $prepend = 'DISTINCT ';
+ $fields[$i] = trim(r('DISTINCT', '', $fields[$i]));
+ }
+
+ $dot = strrpos($fields[$i], '.');
+ if ($dot === false) {
+ $fields[$i] = $prepend . $this->name($alias) . '.' . $this->name($fields[$i]) . ' AS ' . $this->name($alias . '__' . $fields[$i]);
+ } else {
+ $build = explode('.', $fields[$i]);
+ $fields[$i] = $prepend . $this->name($build[0]) . '.' . $this->name($build[1]) . ' AS ' . $this->name($build[0] . '__' . $build[1]);
+ }
+ }
+ }
+ }
+ return $fields;
+ }
+/**
+ * Returns a limit statement in the correct format for the particular database.
+ *
+ * @param int $limit Limit of results returned
+ * @param int $offset Offset from which to start results
+ * @return string SQL limit/offset statement
+ */
+ function limit($limit, $offset = null) {
+ if ($limit) {
+ $rt = '';
+ if (!strpos(strtolower($limit), 'limit') || strpos(strtolower($limit), 'limit') === 0) {
+ $rt = ' LIMIT';
+ }
+
+ $rt .= ' ' . $limit;
+ if ($offset) {
+ $rt .= ' OFFSET ' . $offset;
+ }
+
+ return $rt;
+ }
+ return null;
+ }
+/**
+ * Converts database-layer column types to basic types
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ * @return string Abstract column type (i.e. "string")
+ */
+ function column($real) {
+ if (is_array($real)) {
+ $col = $real['name'];
+ if (isset($real['limit'])) {
+ $col .= '(' . $real['limit'] . ')';
+ }
+ return $col;
+ }
+
+ $col = r(')', '', $real);
+ $limit = null;
+ @list($col, $limit) = explode('(', $col);
+
+ if (in_array($col, array('date', 'time'))) {
+ return $col;
+ }
+ if (strpos($col, 'timestamp') !== false) {
+ return 'datetime';
+ }
+ if ($col == 'inet') {
+ return('inet');
+ }
+ if ($col == 'boolean') {
+ return 'boolean';
+ }
+ if (strpos($col, 'int') !== false && $col != 'interval') {
+ return 'integer';
+ }
+ if (strpos($col, 'char') !== false) {
+ return 'string';
+ }
+ if (strpos($col, 'text') !== false) {
+ return 'text';
+ }
+ if (strpos($col, 'bytea') !== false) {
+ return 'binary';
+ }
+ if (in_array($col, array('float', 'float4', 'float8', 'double', 'double precision', 'decimal', 'real', 'numeric'))) {
+ return 'float';
+ }
+ return 'text';
+ }
+/**
+ * Gets the length of a database-native column description, or null if no length
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ * @return int An integer representing the length of the column
+ */
+ function length($real) {
+ $col = r(array(')', 'unsigned'), '', $real);
+ $limit = null;
+
+ if (strpos($col, '(') !== false) {
+ list($col, $limit) = explode('(', $col);
+ }
+
+ if ($limit != null) {
+ return intval($limit);
+ }
+ return null;
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $results
+ */
+ function resultSet(&$results) {
+ $this->results =& $results;
+ $this->map = array();
+ $num_fields = pg_num_fields($results);
+ $index = 0;
+ $j = 0;
+
+ while ($j < $num_fields) {
+ $columnName = pg_field_name($results, $j);
+
+ if (strpos($columnName, '__')) {
+ $parts = explode('__', $columnName);
+ $this->map[$index++] = array($parts[0], $parts[1]);
+ } else {
+ $this->map[$index++] = array(0, $columnName);
+ }
+ $j++;
+ }
+ }
+/**
+ * Fetches the next row from the current result set
+ *
+ * @return unknown
+ */
+ function fetchResult() {
+ if ($row = pg_fetch_row($this->results)) {
+ $resultRow = array();
+ $i = 0;
+
+ foreach ($row as $index => $field) {
+ list($table, $column) = $this->map[$index];
+ $resultRow[$table][$column] = $row[$index];
+ $i++;
+ }
+ return $resultRow;
+ } else {
+ return false;
+ }
+ }
+/**
+ * Translates between PHP boolean values and PostgreSQL boolean values
+ *
+ * @param mixed $data Value to be translated
+ * @param boolean $quote True to quote value, false otherwise
+ * @return mixed Converted boolean value
+ */
+ function boolean($data, $quote = true) {
+ $result = null;
+
+ if ($data === true || $data === false) {
+ $result = $data;
+ } elseif (is_string($data) && !is_numeric($data)) {
+ if (strpos(low($data), 't') !== false) {
+ $result = true;
+ } else {
+ $result = false;
+ }
+ } else {
+ $result = (bool)$data;
+ }
+ return $result;
+ }
+/**
+ * Sets the database encoding
+ *
+ * @param mixed $enc Database encoding
+ * @return boolean True on success, false on failure
+ */
+ function setEncoding($enc) {
+ return pg_set_client_encoding($this->connection, $enc) == 0;
+ }
+/**
+ * Gets the database encoding
+ *
+ * @return string The database encoding
+ */
+ function getEncoding() {
+ return pg_client_encoding($this->connection);
+ }
+/**
+ * Inserts multiple values into a join table
+ *
+ * @param string $table
+ * @param string $fields
+ * @param array $values
+ */
+ function insertMulti($table, $fields, $values) {
+ $count = count($values);
+ for ($x = 0; $x < $count; $x++) {
+ $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_sqlite.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_sqlite.php
new file mode 100644
index 0000000..26e6b1b
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/dbo/dbo_sqlite.php
@@ -0,0 +1,409 @@
+<?php
+/* SVN FILE: $Id: dbo_sqlite.php 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ * SQLite layer for DBO
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ * @since CakePHP(tm) v 0.9.0
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * DBO implementation for the SQLite DBMS.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model.dbo
+ */
+class DboSqlite extends DboSource {
+
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $description = "SQLite DBO Driver";
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $startQuote = '"';
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $endQuote = '"';
+/**
+ * Base configuration settings for SQLite driver
+ *
+ * @var array
+ */
+ var $_baseConfig = array(
+ 'persistent' => true,
+ 'database' => null,
+ 'connect' => 'sqlite_popen'
+ );
+/**
+ * SQLite column definition
+ *
+ * @var array
+ */
+ var $columns = array(
+ 'primary_key' => array('name' => 'integer primary key'),
+ 'string' => array('name' => 'varchar', 'limit' => '255'),
+ 'text' => array('name' => 'text'),
+ 'integer' => array('name' => 'integer', 'limit' => '11', 'formatter' => 'intval'),
+ 'float' => array('name' => 'float', 'formatter' => 'floatval'),
+ 'datetime' => array('name' => 'timestamp', 'format' => 'YmdHis', 'formatter' => 'date'),
+ 'timestamp' => array('name' => 'timestamp', 'format' => 'YmdHis', 'formatter' => 'date'),
+ 'time' => array('name' => 'timestamp', 'format' => 'His', 'formatter' => 'date'),
+ 'date' => array('name' => 'date', 'format' => 'Ymd', 'formatter' => 'date'),
+ 'binary' => array('name' => 'blob'),
+ 'boolean' => array('name' => 'integer', 'limit' => '1')
+ );
+/**
+ * Connects to the database using config['database'] as a filename.
+ *
+ * @param array $config Configuration array for connecting
+ * @return mixed
+ */
+ function connect() {
+ $config = $this->config;
+ $this->connection = $config['connect']($config['database']);
+ $this->connected = is_resource($this->connection);
+ return $this->connected;
+ }
+/**
+ * Disconnects from database.
+ *
+ * @return boolean True if the database could be disconnected, else false
+ */
+ function disconnect() {
+ @sqlite_close($this->connection);
+ $this->connected = false;
+ return $this->connected;
+ }
+/**
+ * Executes given SQL statement.
+ *
+ * @param string $sql SQL statement
+ * @return resource Result resource identifier
+ */
+ function _execute($sql) {
+ return sqlite_query($this->connection, $sql);
+ }
+/**
+ * Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
+ *
+ * @return array Array of tablenames in the database
+ */
+ function listSources() {
+ $db = $this->config['database'];
+ $this->config['database'] = basename($this->config['database']);
+
+ $cache = parent::listSources();
+ if ($cache != null) {
+ return $cache;
+ }
+
+ $result = $this->fetchAll("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;");
+
+ if (!$result || empty($result)) {
+ return array();
+ } else {
+ $tables = array();
+ foreach ($result as $table) {
+ $tables[] = $table[0]['name'];
+ }
+ parent::listSources($tables);
+
+ $this->config['database'] = $db;
+ return $tables;
+ }
+ $this->config['database'] = $db;
+ return array();
+ }
+/**
+ * Returns an array of the fields in given table name.
+ *
+ * @param string $tableName Name of database table to inspect
+ * @return array Fields in table. Keys are name and type
+ */
+ function describe(&$model) {
+ $cache = parent::describe($model);
+ if ($cache != null) {
+ return $cache;
+ }
+ $fields = array();
+ $result = $this->fetchAll('PRAGMA table_info(' . $model->tablePrefix . $model->table . ')');
+
+ foreach ($result as $column) {
+ $fields[$column[0]['name']] = array(
+ 'type' => $this->column($column[0]['type']),
+ 'null' => ! $column[0]['notnull'],
+ 'default' => $column[0]['dflt_value']
+ );
+ }
+
+ $this->__cacheDescription($model->tablePrefix . $model->table, $fields);
+ return $fields;
+ }
+/**
+ * Returns a quoted and escaped string of $data for use in an SQL statement.
+ *
+ * @param string $data String to be prepared for use in an SQL statement
+ * @return string Quoted and escaped
+ */
+ function value ($data, $column = null, $safe = false) {
+ $parent = parent::value($data, $column, $safe);
+
+ if ($parent != null) {
+ return $parent;
+ }
+
+ if ($data === null) {
+ return 'NULL';
+ }
+
+ if ($data === '') {
+ return "''";
+ }
+
+ switch ($column) {
+ case 'boolean':
+ $data = $this->boolean((bool)$data);
+ break;
+ default:
+ $data = sqlite_escape_string($data);
+ break;
+ }
+ return "'" . $data . "'";
+ }
+/**
+ * Begin a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions).
+ */
+ function begin (&$model) {
+ if (parent::begin($model)) {
+ if ($this->execute('BEGIN')) {
+ $this->_transactionStarted = true;
+ return true;
+ }
+ }
+ return false;
+ }
+/**
+ * Commit a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function commit (&$model) {
+ if (parent::commit($model)) {
+ $this->_transactionStarted = false;
+ return $this->execute('COMMIT');
+ }
+ return false;
+ }
+/**
+ * Rollback a transaction
+ *
+ * @param unknown_type $model
+ * @return boolean True on success, false on fail
+ * (i.e. if the database/model does not support transactions,
+ * or a transaction has not started).
+ */
+ function rollback (&$model) {
+ if (parent::rollback($model)) {
+ return $this->execute('ROLLBACK');
+ }
+ return false;
+ }
+/**
+ * Returns a formatted error message from previous database operation.
+ *
+ * @return string Error message
+ */
+ function lastError() {
+ $error = sqlite_last_error($this->connection);
+ if ($error) {
+ return $error.': '.sqlite_error_string($error);
+ }
+ return null;
+ }
+/**
+ * Returns number of affected rows in previous database operation. If no previous operation exists, this returns false.
+ *
+ * @return int Number of affected rows
+ */
+ function lastAffected() {
+ if ($this->_result) {
+ return sqlite_changes($this->connection);
+ }
+ return false;
+ }
+/**
+ * Returns number of rows in previous resultset. If no previous resultset exists,
+ * this returns false.
+ *
+ * @return int Number of rows in resultset
+ */
+ function lastNumRows() {
+ if ($this->_result) {
+ sqlite_num_rows($this->_result);
+ }
+ return false;
+ }
+/**
+ * Returns the ID generated from the previous INSERT operation.
+ *
+ * @return int
+ */
+ function lastInsertId() {
+ return sqlite_last_insert_rowid($this->connection);
+ }
+/**
+ * Converts database-layer column types to basic types
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ * @return string Abstract column type (i.e. "string")
+ */
+ function column($real) {
+ if (is_array($real)) {
+ $col = $real['name'];
+ if (isset($real['limit'])) {
+ $col .= '('.$real['limit'].')';
+ }
+ return $col;
+ }
+
+ $col = low(r(')', '', $real));
+ $limit = null;
+ @list($col, $limit) = explode('(', $col);
+
+ if (in_array($col, array('text', 'integer', 'float', 'boolean', 'timestamp', 'datetime'))) {
+ return $col;
+ }
+ if (strpos($col, 'varchar') !== false) {
+ return 'string';
+ }
+ if (in_array($col, array('blob', 'clob'))) {
+ return 'binary';
+ }
+ if (strpos($col, 'numeric') !== false) {
+ return 'float';
+ }
+
+ return 'text';
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $results
+ */
+ function resultSet(&$results) {
+ $this->results =& $results;
+ $this->map = array();
+ $num_fields = sqlite_num_fields($results);
+ $index = 0;
+ $j = 0;
+
+ while ($j < $num_fields) {
+ $columnName = str_replace('"', '', sqlite_field_name($results, $j));
+
+ if (strpos($columnName, '.')) {
+ $parts = explode('.', $columnName);
+ $this->map[$index++] = array($parts[0], $parts[1]);
+ } else {
+ $this->map[$index++] = array(0, $columnName);
+ }
+ $j++;
+ }
+ }
+/**
+ * Fetches the next row from the current result set
+ *
+ * @return unknown
+ */
+ function fetchResult() {
+ if ($row = sqlite_fetch_array($this->results, SQLITE_ASSOC)) {
+ $resultRow = array();
+ $i = 0;
+
+ foreach ($row as $index => $field) {
+ if (strpos($index, '.')) {
+ list($table, $column) = explode('.', str_replace('"', '', $index));
+ $resultRow[$table][$column] = $row[$index];
+ } else {
+ $resultRow[0][str_replace('"', '', $index)] = $row[$index];
+ }
+ $i++;
+ }
+ return $resultRow;
+ } else {
+ return false;
+ }
+ }
+/**
+ * Returns a limit statement in the correct format for the particular database.
+ *
+ * @param int $limit Limit of results returned
+ * @param int $offset Offset from which to start results
+ * @return string SQL limit/offset statement
+ */
+ function limit ($limit, $offset = null) {
+ if ($limit) {
+ $rt = '';
+ if (!strpos(strtolower($limit), 'limit') || strpos(strtolower($limit), 'limit') === 0) {
+ $rt = ' LIMIT';
+ }
+ $rt .= ' ' . $limit;
+ if ($offset) {
+ $rt .= ' OFFSET ' . $offset;
+ }
+ return $rt;
+ }
+ return null;
+ }
+/**
+ * Inserts multiple values into a join table
+ *
+ * @param string $table
+ * @param string $fields
+ * @param array $values
+ */
+ function insertMulti($table, $fields, $values) {
+ $count = count($values);
+ for ($x = 0; $x < $count; $x++) {
+ $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model.php
new file mode 100644
index 0000000..8e40eb5
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model.php
@@ -0,0 +1,42 @@
+<?php
+/* SVN FILE: $Id: model.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Object-relational mapper.
+ *
+ * DBO-backed object data model, for mapping database tables to Cake objects.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model
+ * @since CakePHP(tm) v 0.10.0.0
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Load the model class based on the version of PHP.
+ *
+ */
+if (phpversion() < 5) {
+ require(LIBS . 'model' . DS . 'model_php4.php');
+
+ if (function_exists("overload")) {
+ overload("Model");
+ }
+} else {
+ require(LIBS . 'model' . DS . 'model_php5.php');
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model_php4.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model_php4.php
new file mode 100644
index 0000000..9a24eee
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model_php4.php
@@ -0,0 +1,1719 @@
+<?php
+/* SVN FILE: $Id: model_php4.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * Object-relational mapper.
+ *
+ * DBO-backed object data model, for mapping database tables to Cake objects.
+ *
+ * PHP versions 4
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model
+ * @since CakePHP(tm) v 0.10.0.0
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Included libs
+ */
+uses('class_registry', 'validators', 'model' . DS . 'connection_manager', 'set');
+/**
+ * Object-relational mapper.
+ *
+ * DBO-backed object data model.
+ * Automatically selects a database table name based on a pluralized lowercase object class name
+ * (i.e. class 'User' => table 'users'; class 'Man' => table 'men')
+ * The table is required to have at least 'id auto_increment', 'created datetime',
+ * and 'modified datetime' fields.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model
+ */
+class Model extends Object{
+/**
+ * The name of the DataSource connection that this Model uses
+ *
+ * @var string
+ * @access public
+ */
+ var $useDbConfig = 'default';
+/**
+ * Custom database table name.
+ *
+ * @var string
+ * @access public
+ */
+ var $useTable = null;
+/**
+ * Custom display field name. Display fields are used by Scaffold, in SELECT boxes' OPTION elements.
+ *
+ * @var string
+ * @access public
+ */
+ var $displayField = null;
+
+/**
+ * Value of the primary key ID of the record that this model is currently pointing to
+ *
+ * @var string
+ * @access public
+ */
+ var $id = false;
+/**
+ * Container for the data that this model gets from persistent storage (the database).
+ *
+ * @var array
+ * @access public
+ */
+ var $data = array();
+/**
+ * Table name for this Model.
+ *
+ * @var string
+ * @access public
+ */
+ var $table = false;
+/**
+ * The name of the ID field for this Model.
+ *
+ * @var string
+ * @access public
+ */
+ var $primaryKey = null;
+/**
+ * Table metadata
+ *
+ * @var array
+ * @access protected
+ */
+ var $_tableInfo = null;
+/**
+ * List of validation rules. Append entries for validation as ('field_name' => '/^perl_compat_regexp$/')
+ * that have to match with preg_match(). Use these rules with Model::validate()
+ *
+ * @var array
+ * @access public
+ */
+ var $validate = array();
+/**
+ * Errors in validation
+ * @var array
+ * @access public
+ */
+ var $validationErrors = array();
+/**
+ * Database table prefix for tables in model.
+ *
+ * @var string
+ * @access public
+ */
+ var $tablePrefix = null;
+/**
+ * Name of the model.
+ *
+ * @var string
+ * @access public
+ */
+ var $name = null;
+/**
+ * Name of the current model.
+ *
+ * @var string
+ * @access public
+ */
+ var $currentModel = null;
+/**
+ * List of table names included in the Model description. Used for associations.
+ *
+ * @var array
+ * @access public
+ */
+ var $tableToModel = array();
+/**
+ * List of Model names by used tables. Used for associations.
+ *
+ * @var array
+ * @access public
+ */
+ var $modelToTable = array();
+/**
+ * List of Foreign Key names to used tables. Used for associations.
+ *
+ * @var array
+ * @access public
+ */
+ var $keyToTable = array();
+/**
+ * Alias name for model.
+ *
+ * @var array
+ * @access public
+ */
+ var $alias = null;
+/**
+ * Whether or not transactions for this model should be logged
+ *
+ * @var boolean
+ * @access public
+ */
+ var $logTransactions = false;
+/**
+ * Whether or not to enable transactions for this model (i.e. BEGIN/COMMIT/ROLLBACK)
+ *
+ * @var boolean
+ * @access public
+ */
+ var $transactional = false;
+/**
+ * Whether or not to cache queries for this model. This enables in-memory
+ * caching only, the results are not stored beyond this execution.
+ *
+ * @var boolean
+ * @access public
+ */
+ var $cacheQueries = true;
+/**
+ * belongsTo association
+ *
+ * @var array
+ * @access public
+ */
+ var $belongsTo = array();
+/**
+ * hasOne association
+ *
+ * @var array
+ * @access public
+ */
+ var $hasOne = array();
+/**
+ * hasMany association
+ *
+ * @var array
+ * @access public
+ */
+ var $hasMany = array();
+/**
+ * hasAndBelongsToMany association
+ *
+ * @var array
+ * @access public
+ */
+ var $hasAndBelongsToMany = array();
+/**
+ * Depth of recursive association
+ *
+ * @var int
+ * @access public
+ */
+ var $recursive = 1;
+/**
+ * Whitelist of fields allowed to be saved
+ *
+ * @var array
+ */
+ var $whitelist = array();
+/**
+ * Enter description here...
+ *
+ * @var boolean
+ */
+ var $cacheSources = true;
+/**
+ * Default association keys
+ *
+ * @var array
+ * @access private
+ */
+ var $__associationKeys = array('belongsTo' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'),
+ 'hasOne' => array('className', 'foreignKey','conditions', 'fields','order', 'dependent'),
+ 'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'),
+ 'hasAndBelongsToMany' => array('className', 'joinTable', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery'));
+/**
+ * Holds provided/generated association key names and other data for all associations
+ *
+ * @var array
+ * @access private
+ */
+ var $__associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
+/**
+ * The last inserted ID of the data that this model created
+ *
+ * @var int
+ * @access private
+ */
+ var $__insertID = null;
+/**
+ * The number of records returned by the last query
+ *
+ * @var int
+ * @access private
+ */
+ var $__numRows = null;
+/**
+ * The number of records affected by the last query
+ *
+ * @var int
+ * @access private
+ */
+ var $__affectedRows = null;
+/**
+ * Holds model associations temporarily to allow for dynamic (un)binding
+ *
+ * @var array
+ * @access private
+ */
+ var $__backAssociation = array();
+/**
+ * Constructor. Binds the Model's database table to the object.
+ *
+ * @param integer $id
+ * @param string $table Name of database table to use.
+ * @param DataSource $ds DataSource connection object.
+ */
+ function __construct($id = false, $table = null, $ds = null) {
+ parent::__construct();
+
+ if (is_array($id) && isset($id['name'])) {
+ $options = array_merge(array('id' => false, 'table' => null, 'ds' => null, 'alias' => null), $id);
+ list($id, $table, $ds) = array($options['id'], $options['table'], $options['ds']);
+ $this->name = $options['name'];
+ }
+
+ if ($this->name === null) {
+ $this->name = get_class($this);
+ }
+
+ if ($this->primaryKey === null) {
+ $this->primaryKey = 'id';
+ }
+
+ if (isset($options['alias']) || !empty($options['alias'])) {
+ $this->alias = $options['alias'];
+ unset($options);
+ } else {
+ $this->alias = $this->name;
+ }
+ ClassRegistry::addObject($this->alias, $this);
+
+ $this->id = $id;
+ unset($id);
+
+ if ($table === false) {
+ $this->useTable = false;
+ } elseif ($table) {
+ $this->useTable = $table;
+ }
+
+ if ($this->useTable !== false) {
+ $this->setDataSource($ds);
+
+ if ($this->useTable === null) {
+ $this->useTable = Inflector::tableize($this->name);
+ }
+
+ if (in_array('settableprefix', get_class_methods($this))) {
+ $this->setTablePrefix();
+ }
+
+ $this->setSource($this->useTable);
+ $this->__createLinks();
+
+ if ($this->displayField == null) {
+ if ($this->hasField('title')) {
+ $this->displayField = 'title';
+ }
+
+ if ($this->hasField('name')) {
+ $this->displayField = 'name';
+ }
+
+ if ($this->displayField == null) {
+ $this->displayField = $this->primaryKey;
+ }
+ }
+ }
+ }
+
+/**
+ * PHP4 Only
+ *
+ * Handles custom method calls, like findBy<field> for DB models,
+ * and custom RPC calls for remote data sources
+ *
+ * @param unknown_type $method
+ * @param unknown_type $params
+ * @param unknown_type $return
+ * @return unknown
+ * @access protected
+ */
+ function __call($method, $params, &$return) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $return = $db->query($method, $params, $this);
+ if (isset($this->__backAssociation)) {
+ $this->__resetAssociations();
+ }
+ return true;
+ }
+/**
+ * Bind model associations on the fly.
+ *
+ * @param array $params
+ * @return true
+ * @access public
+ */
+ function bindModel($params) {
+ foreach ($params as $assoc => $model) {
+ if(!isset($this->__backAssociation[$assoc])) {
+ $this->__backAssociation[$assoc] = $this->{$assoc};
+ }
+
+ foreach ($model as $key => $value) {
+ $assocName = $key;
+
+ if (is_numeric($key)) {
+ $assocName = $value;
+ $value = array();
+ }
+ $modelName = $assocName;
+ $this->{$assoc}[$assocName] = $value;
+ }
+ }
+ $this->__createLinks();
+ return true;
+ }
+/**
+ * Turn off associations on the fly.
+ *
+ * @param array $params
+ * @return true
+ * @access public
+ */
+ function unbindModel($params) {
+ foreach ($params as $assoc => $models) {
+ if(!isset($this->__backAssociation[$assoc])) {
+ $this->__backAssociation[$assoc] = $this->{$assoc};
+ }
+
+ foreach ($models as $model) {
+ $this->__backAssociation = array_merge($this->__backAssociation, $this->{$assoc});
+ unset ($this->{$assoc}[$model]);
+ }
+ }
+ return true;
+ }
+/**
+ * Private helper method to create a set of associations.
+ *
+ * @access private
+ */
+ function __createLinks() {
+
+ foreach ($this->__associations as $type) {
+ if (!is_array($this->{$type})) {
+ $this->{$type} = explode(',', $this->{$type});
+
+ foreach ($this->{$type} as $i => $className) {
+ $className = trim($className);
+ unset ($this->{$type}[$i]);
+ $this->{$type}[$className] = array();
+ }
+ }
+
+ foreach ($this->{$type} as $assoc => $value) {
+ if (is_numeric($assoc)) {
+ unset ($this->{$type}[$assoc]);
+ $assoc = $value;
+ $value = array();
+ $this->{$type}[$assoc] = $value;
+ }
+
+ $className = $assoc;
+
+ if (isset($value['className']) && !empty($value['className'])) {
+ $className = $value['className'];
+ }
+ $this->__constructLinkedModel($assoc, $className);
+ }
+ }
+
+ foreach ($this->__associations as $type) {
+ $this->__generateAssociation($type);
+ }
+ }
+
+/**
+ * Private helper method to create associated models of given class.
+ * @param string $assoc
+ * @param string $className Class name
+ * @param string $type Type of assocation
+ * @access private
+ */
+ function __constructLinkedModel($assoc, $className) {
+ if(empty($className)) {
+ $className = $assoc;
+ }
+
+ if (!class_exists($className)) {
+ loadModel($className);
+ }
+ $colKey = Inflector::underscore($className);
+ $model = array('name' => $className, 'alias' => $assoc);
+
+ if (ClassRegistry::isKeySet($colKey)) {
+ $this->{$assoc} =& ClassRegistry::getObject($colKey);
+ $this->{$className} =& $this->{$assoc};
+ } else {
+ $this->{$assoc} =& new $className($model);
+ $this->{$className} =& $this->{$assoc};
+ }
+ $this->tableToModel[$this->{$assoc}->table] = $className;
+ $this->modelToTable[$assoc] = $this->{$assoc}->table;
+ }
+/**
+ * Build array-based association from string.
+ *
+ * @param string $type "Belongs", "One", "Many", "ManyTo"
+ * @access private
+ */
+ function __generateAssociation($type) {
+ foreach ($this->{$type}as $assocKey => $assocData) {
+ $class = $assocKey;
+
+ foreach ($this->__associationKeys[$type] as $key) {
+ if (!isset($this->{$type}[$assocKey][$key]) || $this->{$type}[$assocKey][$key] == null) {
+ $data = '';
+
+ switch($key) {
+ case 'fields':
+ $data = '';
+ break;
+
+ case 'foreignKey':
+ $data = Inflector::singularize($this->table) . '_id';
+
+ if ($type == 'belongsTo') {
+ $data = Inflector::singularize($this->{$class}->table) . '_id';
+ }
+ break;
+
+ case 'associationForeignKey':
+ $data = Inflector::singularize($this->{$class}->table) . '_id';
+ break;
+
+ case 'joinTable':
+ $tables = array($this->table, $this->{$class}->table);
+ sort ($tables);
+ $data = $tables[0] . '_' . $tables[1];
+ break;
+
+ case 'className':
+ $data = $class;
+ break;
+ }
+
+ $this->{$type}[$assocKey][$key] = $data;
+ }
+
+ if ($key == 'foreignKey' && !isset($this->keyToTable[$this->{$type}[$assocKey][$key]])) {
+ $this->keyToTable[$this->{$type}[$assocKey][$key]][0] = $this->{$class}->table;
+ $this->keyToTable[$this->{$type}[$assocKey][$key]][1] = $this->{$class}->alias;
+ }
+ }
+ }
+ }
+/**
+ * Sets a custom table for your controller class. Used by your controller to select a database table.
+ *
+ * @param string $tableName Name of the custom table
+ * @access public
+ */
+ function setSource($tableName) {
+ $this->setDataSource($this->useDbConfig);
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $db->cacheSources = $this->cacheSources;
+
+ if ($db->isInterfaceSupported('listSources')) {
+ $sources = $db->listSources();
+ if (is_array($sources) && !in_array(low($this->tablePrefix . $tableName), array_map('low', $sources))) {
+ return $this->cakeError('missingTable', array(array(
+ 'className' => $this->alias,
+ 'table' => $this->tablePrefix . $tableName)));
+
+ }
+ $this->_tableInfo = null;
+ }
+ $this->table = $this->useTable = $tableName;
+ $this->tableToModel[$this->table] = $this->alias;
+ $this->loadInfo();
+ }
+/**
+ * This function does two things: 1) it scans the array $one for the primary key,
+ * and if that's found, it sets the current id to the value of $one[id].
+ * For all other keys than 'id' the keys and values of $one are copied to the 'data' property of this object.
+ * 2) Returns an array with all of $one's keys and values.
+ * (Alternative indata: two strings, which are mangled to
+ * a one-item, two-dimensional array using $one for a key and $two as its value.)
+ *
+ * @param mixed $one Array or string of data
+ * @param string $two Value string for the alternative indata method
+ * @return array
+ * @access public
+ */
+ function set($one, $two = null) {
+ if (is_array($one)) {
+ if (countdim($one) == 1) {
+ $data = array($this->alias => $one);
+ } else {
+ $data = $one;
+ }
+ } else {
+ $data = array($this->alias => array($one => $two));
+ }
+
+ foreach ($data as $n => $v) {
+ if (is_array($v)) {
+
+ foreach ($v as $x => $y) {
+ if (empty($this->whitelist) || (in_array($x, $this->whitelist) || $n !== $this->alias)) {
+ if (isset($this->validationErrors[$x])) {
+ unset ($this->validationErrors[$x]);
+ }
+
+ if ($n == $this->name || is_array($y)) {
+ if ($x === $this->primaryKey) {
+ $this->id = $y;
+ }
+ $this->data[$n][$x] = $y;
+ }
+ }
+ }
+ }
+ }
+ return $data;
+ }
+/**
+ * Returns an array of table metadata (column names and types) from the database.
+ *
+ * @return array Array of table metadata
+ * @access public
+ */
+ function loadInfo() {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $db->cacheSources = $this->cacheSources;
+
+ if (!is_object($this->_tableInfo) && $db->isInterfaceSupported('describe') && $this->useTable !== false) {
+ $info = new Set($db->describe($this));
+
+ foreach($info->value as $field => $value) {
+ $fields[] = am(array('name'=> $field), $value);
+ }
+ unset($info);
+ $this->_tableInfo = new Set($fields);
+ } elseif ($this->useTable === false) {
+ $this->_tableInfo = new Set();
+ }
+ return $this->_tableInfo;
+ }
+/**
+ * Returns an associative array of field names and column types.
+ *
+ * @return array
+ * @access public
+ */
+ function getColumnTypes() {
+ $columns = $this->loadInfo();
+ $columns = $columns->value;
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $cols = array();
+
+ foreach ($columns as $col) {
+ $cols[$col['name']] = $col['type'];
+ }
+ return $cols;
+ }
+/**
+ * Returns the column type of a column in the model
+ *
+ * @param string $column The name of the model column
+ * @return string
+ * @access public
+ */
+ function getColumnType($column) {
+ $columns = $this->loadInfo();
+ $columns = $columns->value;
+ $cols = array();
+
+ foreach ($columns as $col) {
+ if ($col['name'] == $column) {
+ return $col['type'];
+ }
+ }
+ return null;
+ }
+/**
+ * Returns true if this Model has given field in its database table.
+ *
+ * @param string $name Name of field to look for
+ * @return boolean
+ * @access public
+ */
+ function hasField($name) {
+ if (is_array($name)) {
+ foreach ($name as $n) {
+ if ($this->hasField($n)) {
+ return $n;
+ }
+ }
+ return false;
+ }
+
+ if (empty($this->_tableInfo)) {
+ $this->loadInfo();
+ }
+
+ if ($this->_tableInfo != null) {
+ return in_array($name, $this->_tableInfo->extract('{n}.name'));
+ }
+ return false;
+ }
+/**
+ * Initializes the model for writing a new record.
+ *
+ * @return boolean True
+ * @access public
+ */
+ function create() {
+ $this->id = false;
+ unset ($this->data);
+ $this->data = $this->validationErrors = array();
+ return true;
+ }
+/**
+ * @deprecated
+ */
+ function setId($id) {
+ $this->id = $id;
+ }
+/**
+ * Use query() instead.
+ * @deprecated
+ */
+ function findBySql($sql) {
+ return $this->query($sql);
+ }
+/**
+ * Returns a list of fields from the database
+ *
+ * @param mixed $id The ID of the record to read
+ * @param mixed $fields String of single fieldname, or an array of fieldnames.
+ * @return array Array of database fields
+ * @access public
+ */
+ function read($fields = null, $id = null) {
+ $this->validationErrors = array();
+
+ if ($id != null) {
+ $this->id = $id;
+ }
+
+ $id = $this->id;
+
+ if (is_array($this->id)) {
+ $id = $this->id[0];
+ }
+
+ if ($this->id !== null && $this->id !== false) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $field = $db->name($this->alias) . '.' . $db->name($this->primaryKey);
+ return $this->find($field . ' = ' . $db->value($id, $this->getColumnType($this->primaryKey)), $fields);
+ } else {
+ return false;
+ }
+ }
+/**
+ * Returns contents of a field in a query matching given conditions.
+ *
+ * @param string $name Name of field to get
+ * @param array $conditions SQL conditions (defaults to NULL)
+ * @param string $order SQL ORDER BY fragment
+ * @return field contents
+ * @access public
+ */
+ function field($name, $conditions = null, $order = null) {
+ if ($conditions === null && $this->id !== false) {
+ $conditions = array($this->alias . '.' . $this->primaryKey => $this->id);
+ }
+
+ if ($data = $this->find($conditions, $name, $order, 0)) {
+
+ if (strpos($name, '.') === false) {
+ if (isset($data[$this->alias][$name])) {
+ return $data[$this->alias][$name];
+ } else {
+ return false;
+ }
+ } else {
+ $name = explode('.', $name);
+
+ if (isset($data[$name[0]][$name[1]])) {
+ return $data[$name[0]][$name[1]];
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+/**
+ * Saves a single field to the database.
+ *
+ * @param string $name Name of the table field
+ * @param mixed $value Value of the field
+ * @param boolean $validate Whether or not this model should validate before saving (defaults to false)
+ * @return boolean True on success save
+ * @access public
+ */
+ function saveField($name, $value, $validate = false) {
+ return $this->save(array($this->alias => array($name => $value)), $validate);
+ }
+/**
+ * Saves model data to the database.
+ * By default, validation occurs before save.
+ *
+ * @param array $data Data to save.
+ * @param boolean $validate If set, validation will be done before the save
+ * @param array $fieldList List of fields to allow to be written
+ * @return boolean success
+ * @access public
+ */
+ function save($data = null, $validate = true, $fieldList = array()) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $_whitelist = $this->whitelist;
+
+ if (!empty($fieldList)) {
+ $this->whitelist = $fieldList;
+ } elseif ($fieldList === null) {
+ $this->whitelist = array();
+ }
+
+ if ($data) {
+ if (countdim($data) == 1) {
+ $this->set(array($this->alias => $data));
+ } else {
+ $this->set($data);
+ }
+ }
+
+ if ($validate && !$this->validates()) {
+ $this->whitelist = $_whitelist;
+ return false;
+ }
+
+ if (!$this->beforeSave()) {
+ $this->whitelist = $_whitelist;
+ return false;
+ }
+ $fields = $values = array();
+
+ if (isset($this->data[$this->alias][$this->primaryKey]) && empty($this->data[$this->alias][$this->primaryKey])) {
+ unset($this->data[$this->alias][$this->primaryKey]);
+ }
+
+ if (count($this->data) > 1) {
+ $weHaveMulti = true;
+ $joined = false;
+ } else {
+ $weHaveMulti = false;
+ }
+
+ foreach ($this->data as $n => $v) {
+ if (isset($weHaveMulti) && isset($v[$n]) && in_array($n, array_keys($this->hasAndBelongsToMany))) {
+ $joined[] = $v;
+ } else {
+ if ($n === $this->alias) {
+ foreach (array('created', 'updated', 'modified') as $field) {
+ if (array_key_exists($field, $v) && (empty($v[$field]) || $v[$field] === null)) {
+ unset($v[$field]);
+ }
+ }
+
+ foreach ($v as $x => $y) {
+ if ($this->hasField($x)) {
+ $fields[] = $x;
+ $values[] = $y;
+ }
+ }
+ }
+ }
+ }
+ $exists = $this->exists();
+
+ if (!$exists && $this->hasField('created') && !in_array('created', $fields)) {
+ $fields[] = 'created';
+ $values[] = date('Y-m-d H:i:s');
+ }
+
+ if ($this->hasField('modified') && !in_array('modified', $fields)) {
+ $fields[] = 'modified';
+ $values[] = date('Y-m-d H:i:s');
+ }
+
+ if ($this->hasField('updated') && !in_array('updated', $fields)) {
+ $fields[] = 'updated';
+ $values[] = date('Y-m-d H:i:s');
+ }
+
+ if (!$exists) {
+ $this->id = false;
+ }
+ $this->whitelist = $_whitelist;
+
+ if (count($fields)) {
+ if (!empty($this->id)) {
+ if ($db->update($this, $fields, $values)) {
+ if (!empty($joined)) {
+ $this->__saveMulti($joined, $this->id);
+ }
+
+ $this->afterSave();
+ $this->data = false;
+ $this->_clearCache();
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ if ($db->create($this, $fields, $values)) {
+ if (!empty($joined)) {
+ $this->__saveMulti($joined, $this->id);
+ }
+
+ $this->afterSave();
+ $this->data = false;
+ $this->_clearCache();
+ $this->validationErrors = array();
+ return true;
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+/**
+ * Saves model hasAndBelongsToMany data to the database.
+ *
+ * @param array $joined Data to save.
+ * @param string $id
+ * @return void
+ * @access private
+ */
+ function __saveMulti($joined, $id) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ foreach ($joined as $x => $y) {
+ foreach ($y as $assoc => $value) {
+ if (isset($this->hasAndBelongsToMany[$assoc])) {
+ $joinTable[$assoc] = $this->hasAndBelongsToMany[$assoc]['joinTable'];
+ $mainKey[$assoc] = $this->hasAndBelongsToMany[$assoc]['foreignKey'];
+ $keys[] = $this->hasAndBelongsToMany[$assoc]['foreignKey'];
+ $keys[] = $this->hasAndBelongsToMany[$assoc]['associationForeignKey'];
+ $fields[$assoc] = join(',', $keys);
+ unset($keys);
+
+ foreach ($value as $update) {
+ if (!empty($update)) {
+ $values[] = $db->value($id, $this->getColumnType($this->primaryKey));
+ $values[] = $db->value($update);
+ $values = join(',', $values);
+ $newValues[] = "({$values})";
+ unset ($values);
+ }
+ }
+
+ if (!empty($newValues)) {
+ $newValue[$assoc] = $newValues;
+ unset($newValues);
+ } else {
+ $newValue[$assoc] = array();
+ }
+ }
+ }
+ }
+
+ if (isset($joinTable)) {
+ $total = count($joinTable);
+
+ if (is_array($newValue)) {
+ foreach ($newValue as $loopAssoc => $val) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $table = $db->name($db->fullTableName($joinTable[$loopAssoc]));
+ $db->query("DELETE FROM {$table} WHERE {$mainKey[$loopAssoc]} = '{$id}'");
+
+ if (!empty($newValue[$loopAssoc])) {
+ $secondCount = count($newValue[$loopAssoc]);
+ for ($x = 0; $x < $secondCount; $x++) {
+ $db->query("INSERT INTO {$table} ({$fields[$loopAssoc]}) VALUES {$newValue[$loopAssoc][$x]}");
+ }
+ }
+ }
+ }
+ }
+ }
+/**
+ * Synonym for del().
+ *
+ * @param mixed $id
+ * @see function del
+ * @return boolean True on success
+ * @access public
+ */
+ function remove($id = null, $cascade = true) {
+ return $this->del($id, $cascade);
+ }
+/**
+ * Removes record for given id. If no id is given, the current id is used. Returns true on success.
+ *
+ * @param mixed $id Id of record to delete
+ * @return boolean True on success
+ * @access public
+ */
+ function del($id = null, $cascade = true) {
+ if ($id) {
+ $this->id = $id;
+ }
+ $id = $this->id;
+
+ if ($this->exists() && $this->beforeDelete()) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+
+ $this->_deleteMulti($id);
+ $this->_deleteHasMany($id, $cascade);
+ $this->_deleteHasOne($id, $cascade);
+ $this->id = $id;
+
+ if ($db->delete($this)) {
+ $this->afterDelete();
+ $this->_clearCache();
+ $this->id = false;
+ return true;
+ }
+ }
+
+ return false;
+ }
+/**
+ * Alias for del()
+ *
+ * @param mixed $id Id of record to delete
+ * @return boolean True on success
+ * @access public
+ */
+ function delete($id = null, $cascade = true) {
+ return $this->del($id, $cascade);
+ }
+/**
+ * Cascades model deletes to hasMany relationships.
+ *
+ * @param string $id
+ * @return null
+ * @access protected
+ */
+ function _deleteHasMany($id, $cascade) {
+ if (!empty($this->__backAssociation)) {
+ $savedAssociatons = $this->__backAssociation;
+ $this->__backAssociation = array();
+ }
+ foreach ($this->hasMany as $assoc => $data) {
+ if ($data['dependent'] === true && $cascade === true) {
+ $model =& $this->{$data['className']};
+ $field = $model->escapeField($data['foreignKey']);
+ $model->recursive = 0;
+ $records = $model->findAll("$field = '$id'", $model->primaryKey, null, null);
+
+ if ($records != false) {
+ foreach ($records as $record) {
+ $model->del($record[$data['className']][$model->primaryKey]);
+ }
+ }
+ }
+ }
+ if (isset($savedAssociatons)) {
+ $this->__backAssociation = $savedAssociatons;
+ }
+ }
+/**
+ * Cascades model deletes to hasOne relationships.
+ *
+ * @param string $id
+ * @return null
+ * @access protected
+ */
+ function _deleteHasOne($id, $cascade) {
+ if (!empty($this->__backAssociation)) {
+ $savedAssociatons = $this->__backAssociation;
+ $this->__backAssociation = array();
+ }
+ foreach ($this->hasOne as $assoc => $data) {
+ if ($data['dependent'] === true && $cascade === true) {
+ $model =& $this->{$data['className']};
+ $field = $model->escapeField($data['foreignKey']);
+ $model->recursive = 0;
+ $records = $model->findAll("$field = '$id'", $model->primaryKey, null, null);
+
+ if ($records != false) {
+ foreach ($records as $record) {
+ $model->del($record[$data['className']][$model->primaryKey]);
+ }
+ }
+ }
+ }
+ if (isset($savedAssociatons)) {
+ $this->__backAssociation = $savedAssociatons;
+ }
+ }
+/**
+ * Cascades model deletes to HABTM join keys.
+ *
+ * @param string $id
+ * @return null
+ * @access protected
+ */
+ function _deleteMulti($id) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ foreach ($this->hasAndBelongsToMany as $assoc => $data) {
+ $db->execute("DELETE FROM " . $db->name($db->fullTableName($data['joinTable'])) . " WHERE " . $db->name($data['foreignKey']) . " = '{$id}'");
+ }
+ }
+/**
+ * Returns true if a record with set id exists.
+ *
+ * @return boolean True if such a record exists
+ * @access public
+ */
+ function exists() {
+ if ($this->id) {
+ $id = $this->id;
+
+ if (is_array($id)) {
+ $id = $id[0];
+ }
+
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ return $db->hasAny($this, array($this->primaryKey => $id));
+ }
+ return false;
+ }
+/**
+ * Returns true if a record that meets given conditions exists
+ *
+ * @param array $conditions SQL conditions array
+ * @return boolean True if such a record exists
+ * @access public
+ */
+ function hasAny($conditions = null) {
+ return ($this->findCount($conditions) != false);
+ }
+/**
+ * Return a single row as a resultset array.
+ * By using the $recursive parameter, the call can access further "levels of association" than
+ * the ones this model is directly associated to.
+ *
+ * @param array $conditions SQL conditions array
+ * @param mixed $fields Either a single string of a field name, or an array of field names
+ * @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
+ * @param int $recursive The number of levels deep to fetch associated records
+ * @return array Array of records
+ * @access public
+ */
+ function find($conditions = null, $fields = null, $order = null, $recursive = null) {
+ $data = $this->findAll($conditions, $fields, $order, 1, null, $recursive);
+
+ if (empty($data[0])) {
+ return false;
+ }
+
+ return $data[0];
+ }
+/**
+ * Returns a resultset array with specified fields from database matching given conditions.
+ * By using the $recursive parameter, the call can access further "levels of association" than
+ * the ones this model is directly associated to.
+ *
+ * @param mixed $conditions SQL conditions as a string or as an array('field' =>'value',...)
+ * @param mixed $fields Either a single string of a field name, or an array of field names
+ * @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
+ * @param int $limit SQL LIMIT clause, for calculating items per page.
+ * @param int $page Page number, for accessing paged data
+ * @param int $recursive The number of levels deep to fetch associated records
+ * @return array Array of records
+ * @access public
+ */
+ function findAll($conditions = null, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
+
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $this->id = $this->getID();
+ $offset = null;
+
+ if ($page > 1 && $limit != null) {
+ $offset = ($page - 1) * $limit;
+ }
+
+ if ($order == null) {
+ $order = array();
+ } else {
+ $order = array($order);
+ }
+
+ $queryData = array('conditions' => $conditions,
+ 'fields' => $fields,
+ 'joins' => array(),
+ 'limit' => $limit,
+ 'offset' => $offset,
+ 'order' => $order
+ );
+
+ $ret = $this->beforeFind($queryData);
+ if (is_array($ret)) {
+ $queryData = $ret;
+ } elseif ($ret === false) {
+ return null;
+ }
+
+ $return = $this->afterFind($db->read($this, $queryData, $recursive));
+
+ if (!empty($this->__backAssociation)) {
+ $this->__resetAssociations();
+ }
+
+ return $return;
+ }
+/**
+ * Method is called only when bindTo<ModelName>() is used.
+ * This resets the association arrays for the model back
+ * to the original as set in the model.
+ *
+ * @return boolean
+ * @access private
+ */
+ function __resetAssociations() {
+ foreach ($this->__associations as $type) {
+ if (isset($this->__backAssociation[$type])) {
+ $this->{$type} = $this->__backAssociation[$type];
+ }
+ }
+
+ $this->__backAssociation = array();
+ return true;
+ }
+/**
+ * Runs a direct query against the bound DataSource, and returns the result.
+ *
+ * @param string $data Query data
+ * @return array
+ * @access public
+ */
+ function execute($data) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $data = $db->fetchAll($data, $this->cacheQueries);
+
+ foreach ($data as $key => $value) {
+ foreach ($this->tableToModel as $key1 => $value1) {
+ if (isset($data[$key][$key1])) {
+ $newData[$key][$value1] = $data[$key][$key1];
+ }
+ }
+ }
+
+ if (!empty($newData)) {
+ return $newData;
+ }
+
+ return $data;
+ }
+/**
+ * Returns number of rows matching given SQL condition.
+ *
+ * @param array $conditions SQL conditions array for findAll
+ * @param int $recursize The number of levels deep to fetch associated records
+ * @return int Number of matching rows
+ * @see Model::findAll
+ * @access public
+ */
+ function findCount($conditions = null, $recursive = 0) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+
+ list($data) = $this->findAll($conditions, 'COUNT(*) AS ' . $db->name('count'), null, null, 1, $recursive);
+
+ if (isset($data[0]['count'])) {
+ return $data[0]['count'];
+ } elseif (isset($data[$this->alias]['count'])) {
+ return $data[$this->alias]['count'];
+ }
+
+ return false;
+ }
+/**
+ * Special findAll variation for tables joined to themselves.
+ * The table needs the fields id and parent_id to work.
+ *
+ * @param array $conditions Conditions for the findAll() call
+ * @param array $fields Fields for the findAll() call
+ * @param string $sort SQL ORDER BY statement
+ * @return array
+ * @access public
+ * @todo Perhaps create a Component with this logic
+ */
+ function findAllThreaded($conditions = null, $fields = null, $sort = null) {
+ return $this->__doThread(Model::findAll($conditions, $fields, $sort), null);
+ }
+/**
+ * Private, recursive helper method for findAllThreaded.
+ *
+ * @param array $data
+ * @param string $root NULL or id for root node of operation
+ * @return array
+ * @access private
+ * @see findAllThreaded
+ */
+ function __doThread($data, $root) {
+ $out = array();
+ $sizeOf = sizeof($data);
+
+ for ($ii = 0; $ii < $sizeOf; $ii++) {
+ if (($data[$ii][$this->alias]['parent_id'] == $root) || (($root === null) && ($data[$ii][$this->alias]['parent_id'] == '0'))) {
+ $tmp = $data[$ii];
+
+ if (isset($data[$ii][$this->alias][$this->primaryKey])) {
+ $tmp['children'] = $this->__doThread($data, $data[$ii][$this->alias][$this->primaryKey]);
+ } else {
+ $tmp['children'] = null;
+ }
+
+ $out[] = $tmp;
+ }
+ }
+
+ return $out;
+ }
+/**
+ * Returns an array with keys "prev" and "next" that holds the id's of neighbouring data,
+ * which is useful when creating paged lists.
+ *
+ * @param string $conditions SQL conditions for matching rows
+ * @param string $field Field name (parameter for findAll)
+ * @param unknown_type $value
+ * @return array Array with keys "prev" and "next" that holds the id's
+ * @access public
+ */
+ function findNeighbours($conditions = null, $field, $value) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+
+ if (!is_null($conditions)) {
+ $conditions = $conditions . ' AND ';
+ }
+
+ @list($prev) = Model::findAll($conditions . $field . ' < ' . $db->value($value), $field, $field . ' DESC', 1, null, 0);
+ @list($next) = Model::findAll($conditions . $field . ' > ' . $db->value($value), $field, $field . ' ASC', 1, null, 0);
+
+ if (!isset($prev)) {
+ $prev = null;
+ }
+
+ if (!isset($next)) {
+ $next = null;
+ }
+
+ return array('prev' => $prev, 'next' => $next);
+ }
+/**
+ * Returns a resultset for given SQL statement. Generic SQL queries should be made with this method.
+ *
+ * @param string $sql SQL statement
+ * @return array Resultset
+ * @access public
+ */
+ function query() {
+ $params = func_get_args();
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ return call_user_func_array(array(&$db, 'query'), $params);
+ }
+/**
+ * Returns true if all fields pass validation, otherwise false.
+ *
+ * @param array $data POST data
+ * @return boolean True if there are no errors
+ * @access public
+ */
+ function validates($data = array()) {
+ $errors = $this->invalidFields($data);
+ return count($errors) == 0;
+ }
+/**
+ * Returns an array of invalid fields.
+ *
+ * @param array $data
+ * @return array Array of invalid fields or boolean case any error occurs
+ * @access public
+ */
+ function invalidFields($data = array()) {
+ if (empty($data)) {
+ $data = $this->data;
+ }
+
+ if (!$this->beforeValidate()) {
+ return $this->validationErrors;
+ }
+
+ if (!isset($this->validate)) {
+ return $this->validationErrors;
+ }
+
+ if (!empty($data)) {
+ $data = $data;
+ } elseif (isset($this->data)) {
+ $data = $this->data;
+ }
+
+ if (isset($data[$this->alias])) {
+ $data = $data[$this->alias];
+ }
+
+ foreach ($this->validate as $field_name => $validator) {
+ if (isset($data[$field_name]) && !preg_match($validator, $data[$field_name])) {
+ $this->invalidate($field_name);
+ }
+ }
+ return $this->validationErrors;
+ }
+/**
+ * Sets a field as invalid
+ *
+ * @param string $field The name of the field to invalidate
+ * @return void
+ * @access public
+ */
+ function invalidate($field) {
+ if (!is_array($this->validationErrors)) {
+ $this->validationErrors = array();
+ }
+ $this->validationErrors[$field] = 1;
+ }
+/**
+ * Returns true if given field name is a foreign key in this Model.
+ *
+ * @param string $field Returns true if the input string ends in "_id"
+ * @return True if the field is a foreign key listed in the belongsTo array.
+ * @access public
+ */
+ function isForeignKey($field) {
+ $foreignKeys = array();
+
+ if (count($this->belongsTo)) {
+ foreach ($this->belongsTo as $assoc => $data) {
+ $foreignKeys[] = $data['foreignKey'];
+ }
+ }
+ return (bool)(in_array($field, $foreignKeys));
+ }
+/**
+ * Gets the display field for this model
+ *
+ * @return string The name of the display field for this Model (i.e. 'name', 'title').
+ * @access public
+ */
+ function getDisplayField() {
+ return $this->displayField;
+ }
+/**
+ * Returns a resultset array with specified fields from database matching given conditions.
+ * Method can be used to generate option lists for SELECT elements.
+ *
+ * @param mixed $conditions SQL conditions as a string or as an array('field' =>'value',...)
+ * @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
+ * @param int $limit SQL LIMIT clause, for calculating items per page
+ * @param string $keyPath A string path to the key, i.e. "{n}.Post.id"
+ * @param string $valuePath A string path to the value, i.e. "{n}.Post.title"
+ * @return array An associative array of records, where the id is the key, and the display field is the value
+ * @access public
+ */
+ function generateList($conditions = null, $order = null, $limit = null, $keyPath = null, $valuePath = null) {
+ if ($keyPath == null && $valuePath == null && $this->hasField($this->displayField)) {
+ $fields = array($this->primaryKey, $this->displayField);
+ } else {
+ $fields = null;
+ }
+ $recursive = $this->recursive;
+
+ if ($recursive >= 1) {
+ $this->recursive = -1;
+ }
+ $result = $this->findAll($conditions, $fields, $order, $limit);
+ $this->recursive = $recursive;
+
+ if (!$result) {
+ return false;
+ }
+
+ if ($keyPath == null) {
+ $keyPath = '{n}.' . $this->alias . '.' . $this->primaryKey;
+ }
+
+ if ($valuePath == null) {
+ $valuePath = '{n}.' . $this->alias . '.' . $this->displayField;
+ }
+
+ $keys = Set::extract($result, $keyPath);
+ $vals = Set::extract($result, $valuePath);
+
+ if (!empty($keys) && !empty($vals)) {
+ $return = array_combine($keys, $vals);
+ return $return;
+ }
+ return null;
+ }
+/**
+ * Escapes the field name and prepends the model name. Escaping will be done according to the current database driver's rules.
+ *
+ * @param unknown_type $field
+ * @return string The name of the escaped field for this Model (i.e. id becomes `Post`.`id`).
+ * @access public
+ */
+ function escapeField($field) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ return $db->name($this->alias) . '.' . $db->name($field);
+ }
+/**
+ * Returns the current record's ID
+ *
+ * @param unknown_type $list
+ * @return mixed The ID of the current record
+ * @access public
+ */
+ function getID($list = 0) {
+ if (!is_array($this->id)) {
+ return $this->id;
+ }
+
+ if (count($this->id) == 0) {
+ return false;
+ }
+
+ if (isset($this->id[$list])) {
+ return $this->id[$list];
+ }
+
+ foreach ($this->id as $id) {
+ return $id;
+ }
+
+ return false;
+ }
+/**
+ * Returns the ID of the last record this Model inserted
+ *
+ * @return mixed
+ * @access public
+ */
+ function getLastInsertID() {
+ return $this->getInsertID();
+ }
+/**
+ * Returns the ID of the last record this Model inserted
+ *
+ * @return mixed
+ * @access public
+ */
+ function getInsertID() {
+ return $this->__insertID;
+ }
+/**
+ * Sets the ID of the last record this Model inserted
+ *
+ * @param mixed $id
+ * @return void
+ */
+ function setInsertID($id) {
+ $this->__insertID = $id;
+ }
+/**
+ * Returns the number of rows returned from the last query
+ *
+ * @return int
+ * @access public
+ */
+ function getNumRows() {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ return $db->lastNumRows();
+ }
+/**
+ * Returns the number of rows affected by the last query
+ *
+ * @return int
+ * @access public
+ */
+ function getAffectedRows() {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ return $db->lastAffected();
+ }
+/**
+ * Sets the DataSource to which this model is bound
+ *
+ * @param string $dataSource The name of the DataSource, as defined in Connections.php
+ * @return boolean True on success
+ * @access public
+ */
+ function setDataSource($dataSource = null) {
+ if ($dataSource != null) {
+ $this->useDbConfig = $dataSource;
+ }
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+
+ if (!empty($db->config['prefix']) && $this->tablePrefix === null) {
+ $this->tablePrefix = $db->config['prefix'];
+ }
+
+ if (empty($db) || $db == null || !is_object($db)) {
+ return $this->cakeError('missingConnection', array(array('className' => $this->alias)));
+ }
+ }
+/**
+ * Before find callback
+ *
+ * @param array $queryData Data used to execute this query, i.e. conditions, order, etc.
+ * @return boolean True if the operation should continue, false if it should abort
+ * @access public
+ */
+ function beforeFind(&$queryData) {
+ return true;
+ }
+/**
+ * After find callback. Can be used to modify any results returned by find and findAll.
+ *
+ * @param mixed $results The results of the find operation
+ * @return mixed Result of the find operation
+ * @access public
+ */
+ function afterFind($results) {
+ return $results;
+ }
+/**
+ * Before save callback
+ *
+ * @return boolean True if the operation should continue, false if it should abort
+ * @access public
+ */
+ function beforeSave() {
+ return true;
+ }
+/**
+ * After save callback
+ *
+ * @return boolean
+ * @access public
+ */
+ function afterSave() {
+ return true;
+ }
+/**
+ * Before delete callback
+ *
+ * @return boolean True if the operation should continue, false if it should abort
+ * @access public
+ */
+ function beforeDelete() {
+ return true;
+ }
+/**
+ * After delete callback
+ *
+ * @return boolean
+ * @access public
+ */
+ function afterDelete() {
+ return true;
+ }
+/**
+ * Before validate callback
+ *
+ * @return boolean
+ * @access public
+ */
+ function beforeValidate() {
+ return true;
+ }
+/**
+ * DataSource error callback
+ *
+ * @return void
+ */
+ function onError() {
+ }
+/**
+ * Private method. Clears cache for this model
+ *
+ * @param string $type If null this deletes cached views if CACHE_CHECK is true
+ * Will be used to allow deleting query cache also
+ * @return boolean true on delete
+ * @access protected
+ */
+ function _clearCache($type = null) {
+ if ($type === null) {
+ if (defined('CACHE_CHECK') && CACHE_CHECK === true) {
+ $assoc[] = strtolower(Inflector::pluralize($this->alias));
+
+ foreach ($this->__associations as $key => $association) {
+ foreach ($this->$association as $key => $className) {
+ $check = strtolower(Inflector::pluralize($className['className']));
+
+ if (!in_array($check, $assoc)) {
+ $assoc[] = strtolower(Inflector::pluralize($className['className']));
+ }
+ }
+ }
+ clearCache($assoc);
+ return true;
+ }
+ } else {
+ //Will use for query cache deleting
+ }
+ }
+/**
+ * Called when serializing a model
+ *
+ * @return array
+ * @access public
+ */
+ function __sleep() {
+ $return = array_keys(get_object_vars($this));
+ return $return;
+ }
+/**
+ * Called when unserializing a model
+ *
+ * @return void
+ * @access public
+ */
+ function __wakeup() {
+ }
+}
+// --- PHP4 Only
+overload ('Model');
+// --- PHP4 Only
+
+?>
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model_php5.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model_php5.php
new file mode 100644
index 0000000..55a4594
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/model/model_php5.php
@@ -0,0 +1,1716 @@
+<?php
+/* SVN FILE: $Id: model_php5.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * Object-relational mapper.
+ *
+ * DBO-backed object data model, for mapping database tables to Cake objects.
+ *
+ * PHP versions 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.model
+ * @since CakePHP(tm) v 0.10.0.0
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Included libs
+ */
+uses('class_registry', 'validators', 'model' . DS . 'connection_manager', 'set');
+/**
+ * Object-relational mapper.
+ *
+ * DBO-backed object data model.
+ * Automatically selects a database table name based on a pluralized lowercase object class name
+ * (i.e. class 'User' => table 'users'; class 'Man' => table 'men')
+ * The table is required to have at least 'id auto_increment', 'created datetime',
+ * and 'modified datetime' fields.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.model
+ */
+class Model extends Object{
+/**
+ * The name of the DataSource connection that this Model uses
+ *
+ * @var string
+ * @access public
+ */
+ var $useDbConfig = 'default';
+/**
+ * Custom database table name.
+ *
+ * @var string
+ * @access public
+ */
+ var $useTable = null;
+/**
+ * Custom display field name. Display fields are used by Scaffold, in SELECT boxes' OPTION elements.
+ *
+ * @var string
+ * @access public
+ */
+ var $displayField = null;
+
+/**
+ * Value of the primary key ID of the record that this model is currently pointing to
+ *
+ * @var string
+ * @access public
+ */
+ var $id = false;
+/**
+ * Container for the data that this model gets from persistent storage (the database).
+ *
+ * @var array
+ * @access public
+ */
+ var $data = array();
+/**
+ * Table name for this Model.
+ *
+ * @var string
+ * @access public
+ */
+ var $table = false;
+/**
+ * The name of the ID field for this Model.
+ *
+ * @var string
+ * @access public
+ */
+ var $primaryKey = null;
+/**
+ * Table metadata
+ *
+ * @var array
+ * @access protected
+ */
+ var $_tableInfo = null;
+/**
+ * List of validation rules. Append entries for validation as ('field_name' => '/^perl_compat_regexp$/')
+ * that have to match with preg_match(). Use these rules with Model::validate()
+ *
+ * @var array
+ * @access public
+ */
+ var $validate = array();
+/**
+ * Errors in validation
+ * @var array
+ * @access public
+ */
+ var $validationErrors = array();
+/**
+ * Database table prefix for tables in model.
+ *
+ * @var string
+ * @access public
+ */
+ var $tablePrefix = null;
+/**
+ * Name of the model.
+ *
+ * @var string
+ * @access public
+ */
+ var $name = null;
+/**
+ * Name of the current model.
+ *
+ * @var string
+ * @access public
+ */
+ var $currentModel = null;
+/**
+ * List of table names included in the Model description. Used for associations.
+ *
+ * @var array
+ * @access public
+ */
+ var $tableToModel = array();
+/**
+ * List of Model names by used tables. Used for associations.
+ *
+ * @var array
+ * @access public
+ */
+ var $modelToTable = array();
+/**
+ * List of Foreign Key names to used tables. Used for associations.
+ *
+ * @var array
+ * @access public
+ */
+ var $keyToTable = array();
+/**
+ * Alias name for model.
+ *
+ * @var array
+ * @access public
+ */
+ var $alias = null;
+/**
+ * Whether or not transactions for this model should be logged
+ *
+ * @var boolean
+ * @access public
+ */
+ var $logTransactions = false;
+/**
+ * Whether or not to enable transactions for this model (i.e. BEGIN/COMMIT/ROLLBACK)
+ *
+ * @var boolean
+ * @access public
+ */
+ var $transactional = false;
+/**
+ * Whether or not to cache queries for this model. This enables in-memory
+ * caching only, the results are not stored beyond this execution.
+ *
+ * @var boolean
+ * @access public
+ */
+ var $cacheQueries = true;
+/**
+ * belongsTo association
+ *
+ * @var array
+ * @access public
+ */
+ var $belongsTo = array();
+/**
+ * hasOne association
+ *
+ * @var array
+ * @access public
+ */
+ var $hasOne = array();
+/**
+ * hasMany association
+ *
+ * @var array
+ * @access public
+ */
+ var $hasMany = array();
+/**
+ * hasAndBelongsToMany association
+ *
+ * @var array
+ * @access public
+ */
+ var $hasAndBelongsToMany = array();
+/**
+ * Depth of recursive association
+ *
+ * @var int
+ * @access public
+ */
+ var $recursive = 1;
+/**
+ * Whitelist of fields allowed to be saved
+ *
+ * @var array
+ */
+ var $whitelist = array();
+/**
+ * Enter description here...
+ *
+ * @var boolean
+ */
+ var $cacheSources = true;
+/**
+ * Default association keys
+ *
+ * @var array
+ * @access private
+ */
+ var $__associationKeys = array('belongsTo' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'),
+ 'hasOne' => array('className', 'foreignKey','conditions', 'fields','order', 'dependent'),
+ 'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'),
+ 'hasAndBelongsToMany' => array('className', 'joinTable', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery'));
+/**
+ * Holds provided/generated association key names and other data for all associations
+ *
+ * @var array
+ * @access private
+ */
+ var $__associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
+/**
+ * The last inserted ID of the data that this model created
+ *
+ * @var int
+ * @access private
+ */
+ var $__insertID = null;
+/**
+ * The number of records returned by the last query
+ *
+ * @var int
+ * @access private
+ */
+ var $__numRows = null;
+/**
+ * The number of records affected by the last query
+ *
+ * @var int
+ * @access private
+ */
+ var $__affectedRows = null;
+/**
+ * Holds model associations temporarily to allow for dynamic (un)binding
+ *
+ * @var array
+ * @access private
+ */
+ var $__backAssociation = array();
+/**
+ * Constructor. Binds the Model's database table to the object.
+ *
+ * @param integer $id
+ * @param string $table Name of database table to use.
+ * @param DataSource $ds DataSource connection object.
+ */
+ function __construct($id = false, $table = null, $ds = null) {
+ parent::__construct();
+
+ if (is_array($id) && isset($id['name'])) {
+ $options = array_merge(array('id' => false, 'table' => null, 'ds' => null, 'alias' => null), $id);
+ list($id, $table, $ds) = array($options['id'], $options['table'], $options['ds']);
+ $this->name = $options['name'];
+ }
+
+ if ($this->name === null) {
+ $this->name = get_class($this);
+ }
+
+ if ($this->primaryKey === null) {
+ $this->primaryKey = 'id';
+ }
+
+ if (isset($options['alias']) || !empty($options['alias'])) {
+ $this->alias = $options['alias'];
+ unset($options);
+ } else {
+ $this->alias = $this->name;
+ }
+ ClassRegistry::addObject($this->alias, $this);
+
+ $this->id = $id;
+ unset($id);
+
+ if ($table === false) {
+ $this->useTable = false;
+ } elseif ($table) {
+ $this->useTable = $table;
+ }
+
+ if ($this->useTable !== false) {
+ $this->setDataSource($ds);
+
+ if ($this->useTable === null) {
+ $this->useTable = Inflector::tableize($this->name);
+ }
+
+ if (in_array('settableprefix', get_class_methods($this))) {
+ $this->setTablePrefix();
+ }
+
+ $this->setSource($this->useTable);
+ $this->__createLinks();
+
+ if ($this->displayField == null) {
+ if ($this->hasField('title')) {
+ $this->displayField = 'title';
+ }
+
+ if ($this->hasField('name')) {
+ $this->displayField = 'name';
+ }
+
+ if ($this->displayField == null) {
+ $this->displayField = $this->primaryKey;
+ }
+ }
+ }
+ }
+
+/**
+ * Handles custom method calls, like findBy<field> for DB models,
+ * and custom RPC calls for remote data sources
+ *
+ * @param unknown_type $method
+ * @param array $params
+ * @return unknown
+ * @access protected
+ */
+ function __call($method, $params) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ return $db->query($method, $params, $this);
+ }
+/**
+ * Bind model associations on the fly.
+ *
+ * @param array $params
+ * @return true
+ * @access public
+ */
+ function bindModel($params) {
+ foreach ($params as $assoc => $model) {
+ if(!isset($this->__backAssociation[$assoc])) {
+ $this->__backAssociation[$assoc] = $this->{$assoc};
+ }
+
+ foreach ($model as $key => $value) {
+ $assocName = $key;
+
+ if (is_numeric($key)) {
+ $assocName = $value;
+ $value = array();
+ }
+ $modelName = $assocName;
+ $this->{$assoc}[$assocName] = $value;
+ }
+ }
+ $this->__createLinks();
+ return true;
+ }
+/**
+ * Turn off associations on the fly.
+ *
+ * @param array $params
+ * @return true
+ * @access public
+ */
+ function unbindModel($params) {
+ foreach ($params as $assoc => $models) {
+ if(!isset($this->__backAssociation[$assoc])) {
+ $this->__backAssociation[$assoc] = $this->{$assoc};
+ }
+
+ foreach ($models as $model) {
+ $this->__backAssociation = array_merge($this->__backAssociation, $this->{$assoc});
+ unset ($this->{$assoc}[$model]);
+ }
+ }
+ return true;
+ }
+/**
+ * Private helper method to create a set of associations.
+ *
+ * @access private
+ */
+ function __createLinks() {
+
+ foreach ($this->__associations as $type) {
+ if (!is_array($this->{$type})) {
+ $this->{$type} = explode(',', $this->{$type});
+
+ foreach ($this->{$type} as $i => $className) {
+ $className = trim($className);
+ unset ($this->{$type}[$i]);
+ $this->{$type}[$className] = array();
+ }
+ }
+
+ foreach ($this->{$type} as $assoc => $value) {
+ if (is_numeric($assoc)) {
+ unset ($this->{$type}[$assoc]);
+ $assoc = $value;
+ $value = array();
+ $this->{$type}[$assoc] = $value;
+ }
+
+ $className = $assoc;
+
+ if (isset($value['className']) && !empty($value['className'])) {
+ $className = $value['className'];
+ }
+ $this->__constructLinkedModel($assoc, $className);
+ }
+ }
+
+ foreach ($this->__associations as $type) {
+ $this->__generateAssociation($type);
+ }
+ }
+
+/**
+ * Private helper method to create associated models of given class.
+ * @param string $assoc
+ * @param string $className Class name
+ * @param string $type Type of assocation
+ * @access private
+ */
+ function __constructLinkedModel($assoc, $className) {
+ if(empty($className)) {
+ $className = $assoc;
+ }
+
+ if (!class_exists($className)) {
+ loadModel($className);
+ }
+ $colKey = Inflector::underscore($className);
+ $model = array('name' => $className, 'alias' => $assoc);
+
+ if (ClassRegistry::isKeySet($colKey)) {
+ $this->{$assoc} = ClassRegistry::getObject($colKey);
+ $this->{$className} = $this->{$assoc};
+ } else {
+ $this->{$assoc} = new $className($model);
+ $this->{$className} = $this->{$assoc};
+ }
+ $this->tableToModel[$this->{$assoc}->table] = $className;
+ $this->modelToTable[$assoc] = $this->{$assoc}->table;
+ }
+/**
+ * Build array-based association from string.
+ *
+ * @param string $type "Belongs", "One", "Many", "ManyTo"
+ * @access private
+ */
+ function __generateAssociation($type) {
+ foreach ($this->{$type}as $assocKey => $assocData) {
+ $class = $assocKey;
+
+ foreach ($this->__associationKeys[$type] as $key) {
+ if (!isset($this->{$type}[$assocKey][$key]) || $this->{$type}[$assocKey][$key] == null) {
+ $data = '';
+
+ switch($key) {
+ case 'fields':
+ $data = '';
+ break;
+
+ case 'foreignKey':
+ $data = Inflector::singularize($this->table) . '_id';
+
+ if ($type == 'belongsTo') {
+ $data = Inflector::singularize($this->{$class}->table) . '_id';
+ }
+ break;
+
+ case 'associationForeignKey':
+ $data = Inflector::singularize($this->{$class}->table) . '_id';
+ break;
+
+ case 'joinTable':
+ $tables = array($this->table, $this->{$class}->table);
+ sort ($tables);
+ $data = $tables[0] . '_' . $tables[1];
+ break;
+
+ case 'className':
+ $data = $class;
+ break;
+ }
+
+ $this->{$type}[$assocKey][$key] = $data;
+ }
+
+ if ($key == 'foreignKey' && !isset($this->keyToTable[$this->{$type}[$assocKey][$key]])) {
+ $this->keyToTable[$this->{$type}[$assocKey][$key]][0] = $this->{$class}->table;
+ $this->keyToTable[$this->{$type}[$assocKey][$key]][1] = $this->{$class}->alias;
+ }
+ }
+ }
+ }
+/**
+ * Sets a custom table for your controller class. Used by your controller to select a database table.
+ *
+ * @param string $tableName Name of the custom table
+ * @access public
+ */
+ function setSource($tableName) {
+ $this->setDataSource($this->useDbConfig);
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $db->cacheSources = $this->cacheSources;
+
+ if ($db->isInterfaceSupported('listSources')) {
+ $sources = $db->listSources();
+ if (is_array($sources) && !in_array(low($this->tablePrefix . $tableName), array_map('low', $sources))) {
+ return $this->cakeError('missingTable', array(array(
+ 'className' => $this->alias,
+ 'table' => $this->tablePrefix . $tableName)));
+
+ }
+ $this->_tableInfo = null;
+ }
+ $this->table = $this->useTable = $tableName;
+ $this->tableToModel[$this->table] = $this->alias;
+ $this->loadInfo();
+ }
+/**
+ * This function does two things: 1) it scans the array $one for the primary key,
+ * and if that's found, it sets the current id to the value of $one[id].
+ * For all other keys than 'id' the keys and values of $one are copied to the 'data' property of this object.
+ * 2) Returns an array with all of $one's keys and values.
+ * (Alternative indata: two strings, which are mangled to
+ * a one-item, two-dimensional array using $one for a key and $two as its value.)
+ *
+ * @param mixed $one Array or string of data
+ * @param string $two Value string for the alternative indata method
+ * @return array
+ * @access public
+ */
+ function set($one, $two = null) {
+ if (is_array($one)) {
+ if (countdim($one) == 1) {
+ $data = array($this->alias => $one);
+ } else {
+ $data = $one;
+ }
+ } else {
+ $data = array($this->alias => array($one => $two));
+ }
+
+ foreach ($data as $n => $v) {
+ if (is_array($v)) {
+
+ foreach ($v as $x => $y) {
+ if (empty($this->whitelist) || (in_array($x, $this->whitelist) || $n !== $this->alias)) {
+ if (isset($this->validationErrors[$x])) {
+ unset ($this->validationErrors[$x]);
+ }
+
+ if ($n == $this->name || is_array($y)) {
+ if ($x === $this->primaryKey) {
+ $this->id = $y;
+ }
+ $this->data[$n][$x] = $y;
+ }
+ }
+ }
+ }
+ }
+ return $data;
+ }
+/**
+ * Returns an array of table metadata (column names and types) from the database.
+ *
+ * @return array Array of table metadata
+ * @access public
+ */
+ function loadInfo() {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $db->cacheSources = $this->cacheSources;
+
+ if (!is_object($this->_tableInfo) && $db->isInterfaceSupported('describe') && $this->useTable !== false) {
+ $info = new Set($db->describe($this));
+
+ foreach($info->value as $field => $value) {
+ $fields[] = am(array('name'=> $field), $value);
+ }
+ unset($info);
+ $this->_tableInfo = new Set($fields);
+ } elseif ($this->useTable === false) {
+ $this->_tableInfo = new Set();
+ }
+ return $this->_tableInfo;
+ }
+/**
+ * Returns an associative array of field names and column types.
+ *
+ * @return array
+ * @access public
+ */
+ function getColumnTypes() {
+ $columns = $this->loadInfo();
+ $columns = $columns->value;
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $cols = array();
+
+ foreach ($columns as $col) {
+ $cols[$col['name']] = $col['type'];
+ }
+ return $cols;
+ }
+/**
+ * Returns the column type of a column in the model
+ *
+ * @param string $column The name of the model column
+ * @return string
+ * @access public
+ */
+ function getColumnType($column) {
+ $columns = $this->loadInfo();
+ $columns = $columns->value;
+ $cols = array();
+
+ foreach ($columns as $col) {
+ if ($col['name'] == $column) {
+ return $col['type'];
+ }
+ }
+ return null;
+ }
+/**
+ * Returns true if this Model has given field in its database table.
+ *
+ * @param string $name Name of field to look for
+ * @return boolean
+ * @access public
+ */
+ function hasField($name) {
+ if (is_array($name)) {
+ foreach ($name as $n) {
+ if ($this->hasField($n)) {
+ return $n;
+ }
+ }
+ return false;
+ }
+
+ if (empty($this->_tableInfo)) {
+ $this->loadInfo();
+ }
+
+ if ($this->_tableInfo != null) {
+ return in_array($name, $this->_tableInfo->extract('{n}.name'));
+ }
+ return false;
+ }
+/**
+ * Initializes the model for writing a new record.
+ *
+ * @return boolean True
+ * @access public
+ */
+ function create() {
+ $this->id = false;
+ unset ($this->data);
+ $this->data = $this->validationErrors = array();
+ return true;
+ }
+/**
+ * @deprecated
+ */
+ function setId($id) {
+ $this->id = $id;
+ }
+/**
+ * Use query() instead.
+ * @deprecated
+ */
+ function findBySql($sql) {
+ return $this->query($sql);
+ }
+/**
+ * Returns a list of fields from the database
+ *
+ * @param mixed $id The ID of the record to read
+ * @param mixed $fields String of single fieldname, or an array of fieldnames.
+ * @return array Array of database fields
+ * @access public
+ */
+ function read($fields = null, $id = null) {
+ $this->validationErrors = array();
+
+ if ($id != null) {
+ $this->id = $id;
+ }
+
+ $id = $this->id;
+
+ if (is_array($this->id)) {
+ $id = $this->id[0];
+ }
+
+ if ($this->id !== null && $this->id !== false) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $field = $db->name($this->alias) . '.' . $db->name($this->primaryKey);
+ return $this->find($field . ' = ' . $db->value($id, $this->getColumnType($this->primaryKey)), $fields);
+ } else {
+ return false;
+ }
+ }
+/**
+ * Returns contents of a field in a query matching given conditions.
+ *
+ * @param string $name Name of field to get
+ * @param array $conditions SQL conditions (defaults to NULL)
+ * @param string $order SQL ORDER BY fragment
+ * @return field contents
+ * @access public
+ */
+ function field($name, $conditions = null, $order = null) {
+ if ($conditions === null && $this->id !== false) {
+ $conditions = array($this->alias . '.' . $this->primaryKey => $this->id);
+ }
+
+ if ($data = $this->find($conditions, $name, $order, 0)) {
+
+ if (strpos($name, '.') === false) {
+ if (isset($data[$this->alias][$name])) {
+ return $data[$this->alias][$name];
+ } else {
+ return false;
+ }
+ } else {
+ $name = explode('.', $name);
+
+ if (isset($data[$name[0]][$name[1]])) {
+ return $data[$name[0]][$name[1]];
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+/**
+ * Saves a single field to the database.
+ *
+ * @param string $name Name of the table field
+ * @param mixed $value Value of the field
+ * @param array $validate See $options param in Model::save(). Does not respect 'fieldList' key if passed
+ * @return boolean See Model::save()
+ * @access public
+ * @see Model::save()
+ */
+ function saveField($name, $value, $validate = false) {
+ $id = $this->id;
+ $this->create();
+
+ if (is_array($validate)) {
+ $options = array_merge(array('validate' => false, 'fieldList' => array($name)), $validate);
+ } else {
+ $options = array('validate' => $validate, 'fieldList' => array($name));
+ }
+
+ return $this->save(array($this->alias => array($this->primaryKey => $id, $name => $value)), $options);
+ }
+/**
+ * Saves model data to the database.
+ * By default, validation occurs before save.
+ *
+ * @param array $data Data to save.
+ * @param boolean $validate If set, validation will be done before the save
+ * @param array $fieldList List of fields to allow to be written
+ * @return boolean success
+ * @access public
+ */
+ function save($data = null, $validate = true, $fieldList = array()) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $_whitelist = $this->whitelist;
+
+ if (!empty($fieldList)) {
+ $this->whitelist = $fieldList;
+ } elseif ($fieldList === null) {
+ $this->whitelist = array();
+ }
+
+ if ($data) {
+ if (countdim($data) == 1) {
+ $this->set(array($this->alias => $data));
+ } else {
+ $this->set($data);
+ }
+ }
+
+ if ($validate && !$this->validates()) {
+ $this->whitelist = $_whitelist;
+ return false;
+ }
+
+ if (!$this->beforeSave()) {
+ $this->whitelist = $_whitelist;
+ return false;
+ }
+ $fields = $values = array();
+
+ if (isset($this->data[$this->alias][$this->primaryKey]) && empty($this->data[$this->alias][$this->primaryKey])) {
+ unset($this->data[$this->alias][$this->primaryKey]);
+ }
+
+ if (count($this->data) > 1) {
+ $weHaveMulti = true;
+ $joined = false;
+ } else {
+ $weHaveMulti = false;
+ }
+
+ foreach ($this->data as $n => $v) {
+ if (isset($weHaveMulti) && isset($v[$n]) && in_array($n, array_keys($this->hasAndBelongsToMany))) {
+ $joined[] = $v;
+ } else {
+ if ($n === $this->alias) {
+ foreach (array('created', 'updated', 'modified') as $field) {
+ if (array_key_exists($field, $v) && (empty($v[$field]) || $v[$field] === null)) {
+ unset($v[$field]);
+ }
+ }
+
+ foreach ($v as $x => $y) {
+ if ($this->hasField($x)) {
+ $fields[] = $x;
+ $values[] = $y;
+ }
+ }
+ }
+ }
+ }
+ $exists = $this->exists();
+
+ if (!$exists && $this->hasField('created') && !in_array('created', $fields)) {
+ $fields[] = 'created';
+ $values[] = date('Y-m-d H:i:s');
+ }
+
+ if ($this->hasField('modified') && !in_array('modified', $fields)) {
+ $fields[] = 'modified';
+ $values[] = date('Y-m-d H:i:s');
+ }
+
+ if ($this->hasField('updated') && !in_array('updated', $fields)) {
+ $fields[] = 'updated';
+ $values[] = date('Y-m-d H:i:s');
+ }
+
+ if (!$exists) {
+ $this->id = false;
+ }
+ $this->whitelist = $_whitelist;
+
+
+ if (count($fields)) {
+ if (!empty($this->id)) {
+ if ($db->update($this, $fields, $values)) {
+ if (!empty($joined)) {
+ $this->__saveMulti($joined, $this->id);
+ }
+
+ $this->afterSave();
+ $this->data = false;
+ $this->_clearCache();
+ return true;
+ }
+ return false;
+ }
+
+ if ($db->create($this, $fields, $values)) {
+ if (!empty($joined)) {
+ $this->__saveMulti($joined, $this->id);
+ }
+
+ $this->afterSave();
+ $this->data = false;
+ $this->_clearCache();
+ $this->validationErrors = array();
+ return true;
+ }
+ return false;
+ }
+ return false;
+ }
+/**
+ * Saves model hasAndBelongsToMany data to the database.
+ *
+ * @param array $joined Data to save.
+ * @param string $id
+ * @return void
+ * @access private
+ */
+ function __saveMulti($joined, $id) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ foreach ($joined as $x => $y) {
+ foreach ($y as $assoc => $value) {
+ if (isset($this->hasAndBelongsToMany[$assoc])) {
+ $joinTable[$assoc] = $this->hasAndBelongsToMany[$assoc]['joinTable'];
+ $mainKey[$assoc] = $this->hasAndBelongsToMany[$assoc]['foreignKey'];
+ $keys[] = $this->hasAndBelongsToMany[$assoc]['foreignKey'];
+ $keys[] = $this->hasAndBelongsToMany[$assoc]['associationForeignKey'];
+ $fields[$assoc] = join(',', $keys);
+ unset($keys);
+
+ foreach ($value as $update) {
+ if (!empty($update)) {
+ $values[] = $db->value($id, $this->getColumnType($this->primaryKey));
+ $values[] = $db->value($update);
+ $values = join(',', $values);
+ $newValues[] = "({$values})";
+ unset ($values);
+ }
+ }
+
+ if (!empty($newValues)) {
+ $newValue[$assoc] = $newValues;
+ unset($newValues);
+ } else {
+ $newValue[$assoc] = array();
+ }
+ }
+ }
+ }
+
+ if (isset($joinTable)) {
+ $total = count($joinTable);
+
+ if (is_array($newValue)) {
+ foreach ($newValue as $loopAssoc => $val) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $table = $db->name($db->fullTableName($joinTable[$loopAssoc]));
+ $db->query("DELETE FROM {$table} WHERE {$mainKey[$loopAssoc]} = '{$id}'");
+
+ if (!empty($newValue[$loopAssoc])) {
+ $secondCount = count($newValue[$loopAssoc]);
+ for ($x = 0; $x < $secondCount; $x++) {
+ $db->query("INSERT INTO {$table} ({$fields[$loopAssoc]}) VALUES {$newValue[$loopAssoc][$x]}");
+ }
+ }
+ }
+ }
+ }
+ }
+/**
+ * Synonym for del().
+ *
+ * @param mixed $id
+ * @see function del
+ * @return boolean True on success
+ * @access public
+ */
+ function remove($id = null, $cascade = true) {
+ return $this->del($id, $cascade);
+ }
+/**
+ * Removes record for given id. If no id is given, the current id is used. Returns true on success.
+ *
+ * @param mixed $id Id of record to delete
+ * @return boolean True on success
+ * @access public
+ */
+ function del($id = null, $cascade = true) {
+ if ($id) {
+ $this->id = $id;
+ }
+ $id = $this->id;
+
+ if ($this->exists() && $this->beforeDelete()) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+
+ $this->_deleteMulti($id);
+ $this->_deleteHasMany($id, $cascade);
+ $this->_deleteHasOne($id, $cascade);
+ $this->id = $id;
+
+ if ($db->delete($this)) {
+ $this->afterDelete();
+ $this->_clearCache();
+ $this->id = false;
+ return true;
+ }
+ }
+
+ return false;
+ }
+/**
+ * Alias for del()
+ *
+ * @param mixed $id Id of record to delete
+ * @return boolean True on success
+ * @access public
+ */
+ function delete($id = null, $cascade = true) {
+ return $this->del($id, $cascade);
+ }
+/**
+ * Cascades model deletes to hasMany relationships.
+ *
+ * @param string $id
+ * @return null
+ * @access protected
+ */
+ function _deleteHasMany($id, $cascade) {
+ if (!empty($this->__backAssociation)) {
+ $savedAssociatons = $this->__backAssociation;
+ $this->__backAssociation = array();
+ }
+ foreach ($this->hasMany as $assoc => $data) {
+ if ($data['dependent'] === true && $cascade === true) {
+ $model =& $this->{$data['className']};
+ $field = $model->escapeField($data['foreignKey']);
+ $model->recursive = 0;
+ $records = $model->findAll("$field = '$id'", $model->primaryKey, null, null);
+
+ if ($records != false) {
+ foreach ($records as $record) {
+ $model->del($record[$data['className']][$model->primaryKey]);
+ }
+ }
+ }
+ }
+ if (isset($savedAssociatons)) {
+ $this->__backAssociation = $savedAssociatons;
+ }
+ }
+/**
+ * Cascades model deletes to hasOne relationships.
+ *
+ * @param string $id
+ * @return null
+ * @access protected
+ */
+ function _deleteHasOne($id, $cascade) {
+ if (!empty($this->__backAssociation)) {
+ $savedAssociatons = $this->__backAssociation;
+ $this->__backAssociation = array();
+ }
+ foreach ($this->hasOne as $assoc => $data) {
+ if ($data['dependent'] === true && $cascade === true) {
+ $model =& $this->{$data['className']};
+ $field = $model->escapeField($data['foreignKey']);
+ $model->recursive = 0;
+ $records = $model->findAll("$field = '$id'", $model->primaryKey, null, null);
+
+ if ($records != false) {
+ foreach ($records as $record) {
+ $model->del($record[$data['className']][$model->primaryKey]);
+ }
+ }
+ }
+ }
+ if (isset($savedAssociatons)) {
+ $this->__backAssociation = $savedAssociatons;
+ }
+ }
+/**
+ * Cascades model deletes to HABTM join keys.
+ *
+ * @param string $id
+ * @return null
+ * @access protected
+ */
+ function _deleteMulti($id) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ foreach ($this->hasAndBelongsToMany as $assoc => $data) {
+ $db->execute("DELETE FROM " . $db->name($db->fullTableName($data['joinTable'])) . " WHERE " . $db->name($data['foreignKey']) . " = '{$id}'");
+ }
+ }
+/**
+ * Returns true if a record with set id exists.
+ *
+ * @return boolean True if such a record exists
+ * @access public
+ */
+ function exists() {
+ if ($this->id) {
+ $id = $this->id;
+
+ if (is_array($id)) {
+ $id = $id[0];
+ }
+
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ return $db->hasAny($this, array($this->primaryKey => $id));
+ }
+ return false;
+ }
+/**
+ * Returns true if a record that meets given conditions exists
+ *
+ * @param array $conditions SQL conditions array
+ * @return boolean True if such a record exists
+ * @access public
+ */
+ function hasAny($conditions = null) {
+ return ($this->findCount($conditions) != false);
+ }
+/**
+ * Return a single row as a resultset array.
+ * By using the $recursive parameter, the call can access further "levels of association" than
+ * the ones this model is directly associated to.
+ *
+ * @param array $conditions SQL conditions array
+ * @param mixed $fields Either a single string of a field name, or an array of field names
+ * @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
+ * @param int $recursive The number of levels deep to fetch associated records
+ * @return array Array of records
+ * @access public
+ */
+ function find($conditions = null, $fields = null, $order = null, $recursive = null) {
+ $data = $this->findAll($conditions, $fields, $order, 1, null, $recursive);
+
+ if (empty($data[0])) {
+ return false;
+ }
+
+ return $data[0];
+ }
+/**
+ * Returns a resultset array with specified fields from database matching given conditions.
+ * By using the $recursive parameter, the call can access further "levels of association" than
+ * the ones this model is directly associated to.
+ *
+ * @param mixed $conditions SQL conditions as a string or as an array('field' =>'value',...)
+ * @param mixed $fields Either a single string of a field name, or an array of field names
+ * @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
+ * @param int $limit SQL LIMIT clause, for calculating items per page.
+ * @param int $page Page number, for accessing paged data
+ * @param int $recursive The number of levels deep to fetch associated records
+ * @return array Array of records
+ * @access public
+ */
+ function findAll($conditions = null, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
+
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $this->id = $this->getID();
+ $offset = null;
+
+ if ($page > 1 && $limit != null) {
+ $offset = ($page - 1) * $limit;
+ }
+
+ if ($order == null) {
+ $order = array();
+ } else {
+ $order = array($order);
+ }
+
+ $queryData = array('conditions' => $conditions,
+ 'fields' => $fields,
+ 'joins' => array(),
+ 'limit' => $limit,
+ 'offset' => $offset,
+ 'order' => $order
+ );
+
+ $ret = $this->beforeFind($queryData);
+ if (is_array($ret)) {
+ $queryData = $ret;
+ } elseif ($ret === false) {
+ return null;
+ }
+
+ $return = $this->afterFind($db->read($this, $queryData, $recursive));
+
+ if (!empty($this->__backAssociation)) {
+ $this->__resetAssociations();
+ }
+
+ return $return;
+ }
+/**
+ * Method is called only when bindTo<ModelName>() is used.
+ * This resets the association arrays for the model back
+ * to the original as set in the model.
+ *
+ * @return boolean
+ * @access private
+ */
+ function __resetAssociations() {
+ foreach ($this->__associations as $type) {
+ if (isset($this->__backAssociation[$type])) {
+ $this->{$type} = $this->__backAssociation[$type];
+ }
+ }
+
+ $this->__backAssociation = array();
+ return true;
+ }
+/**
+ * Runs a direct query against the bound DataSource, and returns the result.
+ *
+ * @param string $data Query data
+ * @return array
+ * @access public
+ */
+ function execute($data) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $data = $db->fetchAll($data, $this->cacheQueries);
+
+ foreach ($data as $key => $value) {
+ foreach ($this->tableToModel as $key1 => $value1) {
+ if (isset($data[$key][$key1])) {
+ $newData[$key][$value1] = $data[$key][$key1];
+ }
+ }
+ }
+
+ if (!empty($newData)) {
+ return $newData;
+ }
+
+ return $data;
+ }
+/**
+ * Returns number of rows matching given SQL condition.
+ *
+ * @param array $conditions SQL conditions array for findAll
+ * @param int $recursize The number of levels deep to fetch associated records
+ * @return int Number of matching rows
+ * @see Model::findAll
+ * @access public
+ */
+ function findCount($conditions = null, $recursive = 0) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+
+ list($data) = $this->findAll($conditions, 'COUNT(*) AS ' . $db->name('count'), null, null, 1, $recursive);
+
+ if (isset($data[0]['count'])) {
+ return $data[0]['count'];
+ } elseif (isset($data[$this->alias]['count'])) {
+ return $data[$this->alias]['count'];
+ }
+
+ return false;
+ }
+/**
+ * Special findAll variation for tables joined to themselves.
+ * The table needs the fields id and parent_id to work.
+ *
+ * @param array $conditions Conditions for the findAll() call
+ * @param array $fields Fields for the findAll() call
+ * @param string $sort SQL ORDER BY statement
+ * @return array
+ * @access public
+ * @todo Perhaps create a Component with this logic
+ */
+ function findAllThreaded($conditions = null, $fields = null, $sort = null) {
+ return $this->__doThread(Model::findAll($conditions, $fields, $sort), null);
+ }
+/**
+ * Private, recursive helper method for findAllThreaded.
+ *
+ * @param array $data
+ * @param string $root NULL or id for root node of operation
+ * @return array
+ * @access private
+ * @see findAllThreaded
+ */
+ function __doThread($data, $root) {
+ $out = array();
+ $sizeOf = sizeof($data);
+
+ for ($ii = 0; $ii < $sizeOf; $ii++) {
+ if (($data[$ii][$this->alias]['parent_id'] == $root) || (($root === null) && ($data[$ii][$this->alias]['parent_id'] == '0'))) {
+ $tmp = $data[$ii];
+
+ if (isset($data[$ii][$this->alias][$this->primaryKey])) {
+ $tmp['children'] = $this->__doThread($data, $data[$ii][$this->alias][$this->primaryKey]);
+ } else {
+ $tmp['children'] = null;
+ }
+
+ $out[] = $tmp;
+ }
+ }
+
+ return $out;
+ }
+/**
+ * Returns an array with keys "prev" and "next" that holds the id's of neighbouring data,
+ * which is useful when creating paged lists.
+ *
+ * @param string $conditions SQL conditions for matching rows
+ * @param string $field Field name (parameter for findAll)
+ * @param unknown_type $value
+ * @return array Array with keys "prev" and "next" that holds the id's
+ * @access public
+ */
+ function findNeighbours($conditions = null, $field, $value) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+
+ if (!is_null($conditions)) {
+ $conditions = $conditions . ' AND ';
+ }
+
+ @list($prev) = Model::findAll($conditions . $field . ' < ' . $db->value($value), $field, $field . ' DESC', 1, null, 0);
+ @list($next) = Model::findAll($conditions . $field . ' > ' . $db->value($value), $field, $field . ' ASC', 1, null, 0);
+
+ if (!isset($prev)) {
+ $prev = null;
+ }
+
+ if (!isset($next)) {
+ $next = null;
+ }
+
+ return array('prev' => $prev, 'next' => $next);
+ }
+/**
+ * Returns a resultset for given SQL statement. Generic SQL queries should be made with this method.
+ *
+ * @param string $sql SQL statement
+ * @return array Resultset
+ * @access public
+ */
+ function query() {
+ $params = func_get_args();
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ return call_user_func_array(array(&$db, 'query'), $params);
+ }
+/**
+ * Returns true if all fields pass validation, otherwise false.
+ *
+ * @param array $data POST data
+ * @return boolean True if there are no errors
+ * @access public
+ */
+ function validates($data = array()) {
+ $errors = $this->invalidFields($data);
+ return count($errors) == 0;
+ }
+/**
+ * Returns an array of invalid fields.
+ *
+ * @param array $data
+ * @return array Array of invalid fields or boolean case any error occurs
+ * @access public
+ */
+ function invalidFields($data = array()) {
+ if (empty($data)) {
+ $data = $this->data;
+ }
+
+ if (!$this->beforeValidate()) {
+ return $this->validationErrors;
+ }
+
+ if (!isset($this->validate)) {
+ return $this->validationErrors;
+ }
+
+ if (!empty($data)) {
+ $data = $data;
+ } elseif (isset($this->data)) {
+ $data = $this->data;
+ }
+
+ if (isset($data[$this->alias])) {
+ $data = $data[$this->alias];
+ }
+
+ foreach ($this->validate as $field_name => $validator) {
+ if (isset($data[$field_name]) && !preg_match($validator, $data[$field_name])) {
+ $this->invalidate($field_name);
+ }
+ }
+ return $this->validationErrors;
+ }
+/**
+ * Sets a field as invalid
+ *
+ * @param string $field The name of the field to invalidate
+ * @return void
+ * @access public
+ */
+ function invalidate($field) {
+ if (!is_array($this->validationErrors)) {
+ $this->validationErrors = array();
+ }
+ $this->validationErrors[$field] = 1;
+ }
+/**
+ * Returns true if given field name is a foreign key in this Model.
+ *
+ * @param string $field Returns true if the input string ends in "_id"
+ * @return True if the field is a foreign key listed in the belongsTo array.
+ * @access public
+ */
+ function isForeignKey($field) {
+ $foreignKeys = array();
+
+ if (count($this->belongsTo)) {
+ foreach ($this->belongsTo as $assoc => $data) {
+ $foreignKeys[] = $data['foreignKey'];
+ }
+ }
+ return (bool)(in_array($field, $foreignKeys));
+ }
+/**
+ * Gets the display field for this model
+ *
+ * @return string The name of the display field for this Model (i.e. 'name', 'title').
+ * @access public
+ */
+ function getDisplayField() {
+ return $this->displayField;
+ }
+/**
+ * Returns a resultset array with specified fields from database matching given conditions.
+ * Method can be used to generate option lists for SELECT elements.
+ *
+ * @param mixed $conditions SQL conditions as a string or as an array('field' =>'value',...)
+ * @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
+ * @param int $limit SQL LIMIT clause, for calculating items per page
+ * @param string $keyPath A string path to the key, i.e. "{n}.Post.id"
+ * @param string $valuePath A string path to the value, i.e. "{n}.Post.title"
+ * @return array An associative array of records, where the id is the key, and the display field is the value
+ * @access public
+ */
+ function generateList($conditions = null, $order = null, $limit = null, $keyPath = null, $valuePath = null) {
+ if ($keyPath == null && $valuePath == null && $this->hasField($this->displayField)) {
+ $fields = array($this->primaryKey, $this->displayField);
+ } else {
+ $fields = null;
+ }
+ $recursive = $this->recursive;
+
+ if ($recursive >= 1) {
+ $this->recursive = -1;
+ }
+ $result = $this->findAll($conditions, $fields, $order, $limit);
+ $this->recursive = $recursive;
+
+ if (!$result) {
+ return false;
+ }
+
+ if ($keyPath == null) {
+ $keyPath = '{n}.' . $this->alias . '.' . $this->primaryKey;
+ }
+
+ if ($valuePath == null) {
+ $valuePath = '{n}.' . $this->alias . '.' . $this->displayField;
+ }
+
+ $keys = Set::extract($result, $keyPath);
+ $vals = Set::extract($result, $valuePath);
+
+ if (!empty($keys) && !empty($vals)) {
+ $return = array_combine($keys, $vals);
+ return $return;
+ }
+ return null;
+ }
+/**
+ * Escapes the field name and prepends the model name. Escaping will be done according to the current database driver's rules.
+ *
+ * @param unknown_type $field
+ * @return string The name of the escaped field for this Model (i.e. id becomes `Post`.`id`).
+ * @access public
+ */
+ function escapeField($field) {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ return $db->name($this->alias) . '.' . $db->name($field);
+ }
+/**
+ * Returns the current record's ID
+ *
+ * @param unknown_type $list
+ * @return mixed The ID of the current record
+ * @access public
+ */
+ function getID($list = 0) {
+ if (!is_array($this->id)) {
+ return $this->id;
+ }
+
+ if (count($this->id) == 0) {
+ return false;
+ }
+
+ if (isset($this->id[$list])) {
+ return $this->id[$list];
+ }
+
+ foreach ($this->id as $id) {
+ return $id;
+ }
+
+ return false;
+ }
+/**
+ * Returns the ID of the last record this Model inserted
+ *
+ * @return mixed
+ * @access public
+ */
+ function getLastInsertID() {
+ return $this->getInsertID();
+ }
+/**
+ * Returns the ID of the last record this Model inserted
+ *
+ * @return mixed
+ * @access public
+ */
+ function getInsertID() {
+ return $this->__insertID;
+ }
+/**
+ * Sets the ID of the last record this Model inserted
+ *
+ * @param mixed $id
+ * @return void
+ */
+ function setInsertID($id) {
+ $this->__insertID = $id;
+ }
+/**
+ * Returns the number of rows returned from the last query
+ *
+ * @return int
+ * @access public
+ */
+ function getNumRows() {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ return $db->lastNumRows();
+ }
+/**
+ * Returns the number of rows affected by the last query
+ *
+ * @return int
+ * @access public
+ */
+ function getAffectedRows() {
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ return $db->lastAffected();
+ }
+/**
+ * Sets the DataSource to which this model is bound
+ *
+ * @param string $dataSource The name of the DataSource, as defined in Connections.php
+ * @return boolean True on success
+ * @access public
+ */
+ function setDataSource($dataSource = null) {
+ if ($dataSource != null) {
+ $this->useDbConfig = $dataSource;
+ }
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+
+ if (!empty($db->config['prefix']) && $this->tablePrefix === null) {
+ $this->tablePrefix = $db->config['prefix'];
+ }
+
+ if (empty($db) || $db == null || !is_object($db)) {
+ return $this->cakeError('missingConnection', array(array('className' => $this->alias)));
+ }
+ }
+/**
+ * Before find callback
+ *
+ * @param array $queryData Data used to execute this query, i.e. conditions, order, etc.
+ * @return boolean True if the operation should continue, false if it should abort
+ * @access public
+ */
+ function beforeFind(&$queryData) {
+ return true;
+ }
+/**
+ * After find callback. Can be used to modify any results returned by find and findAll.
+ *
+ * @param mixed $results The results of the find operation
+ * @return mixed Result of the find operation
+ * @access public
+ */
+ function afterFind($results) {
+ return $results;
+ }
+/**
+ * Before save callback
+ *
+ * @return boolean True if the operation should continue, false if it should abort
+ * @access public
+ */
+ function beforeSave() {
+ return true;
+ }
+/**
+ * After save callback
+ *
+ * @return boolean
+ * @access public
+ */
+ function afterSave() {
+ return true;
+ }
+/**
+ * Before delete callback
+ *
+ * @return boolean True if the operation should continue, false if it should abort
+ * @access public
+ */
+ function beforeDelete() {
+ return true;
+ }
+/**
+ * After delete callback
+ *
+ * @return boolean
+ * @access public
+ */
+ function afterDelete() {
+ return true;
+ }
+/**
+ * Before validate callback
+ *
+ * @return boolean
+ * @access public
+ */
+ function beforeValidate() {
+ return true;
+ }
+/**
+ * DataSource error callback
+ *
+ * @return void
+ */
+ function onError() {
+ }
+/**
+ * Private method. Clears cache for this model
+ *
+ * @param string $type If null this deletes cached views if CACHE_CHECK is true
+ * Will be used to allow deleting query cache also
+ * @return boolean true on delete
+ * @access protected
+ */
+ function _clearCache($type = null) {
+ if ($type === null) {
+ if (defined('CACHE_CHECK') && CACHE_CHECK === true) {
+ $assoc[] = strtolower(Inflector::pluralize($this->alias));
+
+ foreach ($this->__associations as $key => $association) {
+ foreach ($this->$association as $key => $className) {
+ $check = strtolower(Inflector::pluralize($className['className']));
+
+ if (!in_array($check, $assoc)) {
+ $assoc[] = strtolower(Inflector::pluralize($className['className']));
+ }
+ }
+ }
+ clearCache($assoc);
+ return true;
+ }
+ } else {
+ //Will use for query cache deleting
+ }
+ }
+/**
+ * Called when serializing a model
+ *
+ * @return array
+ * @access public
+ */
+ function __sleep() {
+ $return = array_keys(get_object_vars($this));
+ return $return;
+ }
+/**
+ * Called when unserializing a model
+ *
+ * @return void
+ * @access public
+ */
+ function __wakeup() {
+ }
+}
+?>
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/neat_array.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/neat_array.php
new file mode 100644
index 0000000..fd04a6b
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/neat_array.php
@@ -0,0 +1,318 @@
+<?php
+/* SVN FILE: $Id: neat_array.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Library of array functions for Cake.
+ *
+ * Internal use only.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Class used for internal manipulation of multi-dimensional arrays (arrays of arrays).
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class NeatArray{
+/**
+ * Value of NeatArray.
+ *
+ * @var array
+ * @access public
+ */
+ var $value;
+/**
+ * Constructor. Defaults to an empty array.
+ *
+ * @param array $value
+ * @access public
+ * @uses NeatArray::value
+ */
+ function NeatArray($value = array()) {
+ $this->value = $value;
+ }
+/**
+ * Finds and returns records with $fieldName equal to $value from this NeatArray.
+ *
+ * @param string $fieldName
+ * @param string $value
+ * @return mixed
+ * @access public
+ * @uses NeatArray::value
+ */
+ function findIn($fieldName, $value) {
+ if (!is_array($this->value)) {
+ return false;
+ }
+ $out = false;
+ $keys = array_keys($this->value);
+ $count = sizeof($keys);
+
+ for ($i = 0; $i < $count; $i++) {
+ if (isset($this->value[$keys[$i]][$fieldName]) && ($this->value[$keys[$i]][$fieldName] == $value))
+ {
+ $out[$keys[$i]] = $this->value[$keys[$i]];
+ }
+ }
+ 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;
+ }
+/**
+ * Adds elements from given array to itself.
+ *
+ * @param string $value
+ * @return bool
+ * @access public
+ * @uses NeatArray::value
+ */
+ function add($value) {
+ return ($this->value = $this->plus($value)) ? true : false;
+ }
+/**
+ * Returns itself merged with given array.
+ *
+ * @param array $value Array to add to NeatArray.
+ * @return array
+ * @access public
+ * @uses NeatArray::value
+ */
+ function plus($value) {
+ $merge = array_merge($this->value, (is_array($value) ? $value : array($value)));
+ return $merge;
+ }
+/**
+ * Counts repeating strings and returns an array of totals.
+ *
+ * @param int $sortedBy A value of 1 sorts by values, a value of 2 sorts by keys. Defaults to null (no sorting).
+ * @return array
+ * @access public
+ * @uses NeatArray::value
+ */
+ function totals($sortedBy = 1, $reverse = true) {
+ $out = array();
+ 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 == 2) {
+ $reverse ? krsort($out, SORT_STRING) : ksort($out, SORT_STRING);
+ }
+ 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);
+ }
+/**
+ * Passes each of its values through a specified function or method.
+ * Think of PHP's {@link http://php.net/array_walk array_walk()}.
+ *
+ * @param string $with Name of callback function
+ * @return array Returns value of NeatArray::value
+ * @access public
+ * @uses NeatArray::value
+ */
+ function walk($with) {
+ array_walk($this->value, $with);
+ return $this->value;
+ }
+/**
+ * Apply $template to all elements of this NeatArray, and return the array itself.
+ *
+ * @param string $template {@link http://php.net/sprintf sprintf()}-compatible string to be applied to all values of this NeatArray.
+ * @return array
+ */
+ function sprintf($template) {
+ $count = count($this->value);
+ for ($ii = 0; $ii < $count; $ii++) {
+ $this->value[$ii] = sprintf($template, $this->value[$ii]);
+ }
+ 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;
+ }
+/**
+ * Returns a list of unique elements.
+ *
+ * @return array
+ */
+ function unique() {
+ $unique = array_unique($this->value);
+ return $unique;
+ }
+/**
+ * Removes duplicate elements from the value and returns it.
+ *
+ * @return array
+ */
+ function makeUnique() {
+ return $this->value = array_unique($this->value);
+ }
+/**
+ * Joins an array with myself using a key (like a join between database tables).
+ *
+ * Example:
+ *
+ * $alice = array('id'=>'1', 'name'=>'Alice');
+ * $bob = array('id'=>'2', 'name'=>'Bob');
+ *
+ * $users = new NeatArray(array($alice, $bob));
+ *
+ * $born = array
+ * (
+ * array('user_id'=>'1', 'born'=>'1980'),
+ * array('user_id'=>'2', 'born'=>'1976')
+ * );
+ *
+ * $users->joinWith($born, 'id', 'user_id');
+ *
+ * Result:
+ *
+ * $users->value == array
+ * (
+ * array('id'=>'1', 'name'=>'Alice', 'born'=>'1980'),
+ * array('id'=>'2', 'name'=>'Bob', 'born'=>'1976')
+ * );
+ *
+ * @param array $his The array to join with myself.
+ * @param string $onMine Key to use on myself.
+ * @param string $onHis Key to use on him.
+ * @return array
+ */
+ function joinWith($his, $onMine, $onHis = null) {
+ if (empty($onHis)) {
+ $onHis = $onMine;
+ }
+ $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;
+ }
+ }
+ return $this->value = $out;
+ }
+/**
+ * Enter description here...
+ * @todo Explain this function. almost looks like it creates a tree
+ *
+ * @param string $root
+ * @param string $idKey
+ * @param string $parentIdKey
+ * @param string $childrenKey
+ * @return array
+ */
+ function threaded($root = null, $idKey = 'id', $parentIdKey = 'parent_id', $childrenKey = 'children') {
+ $out = array();
+ $sizeof = sizeof($this->value);
+
+ for ($ii = 0; $ii < $sizeof; $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)) {
+ $return = $result;
+ array_unshift($return, $key);
+ return $return;
+ } 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/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/neat_string.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/neat_string.php
new file mode 100644
index 0000000..620e60b
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/neat_string.php
@@ -0,0 +1,88 @@
+<?php
+/* SVN FILE: $Id: neat_string.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * String handling methods.
+ *
+ * Random passwords, splitting strings into arrays, removing Cyrillic characters, stripping whitespace.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * String handling methods.
+ *
+ * Random passwords, splitting strings into arrays, removing Cyrillic characters, stripping whitespace.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class NeatString{
+/**
+ * Returns an array with each of the non-empty characters in $string as an element.
+ *
+ * @param string $string
+ * @return array
+ */
+ function toArray($string) {
+ $split = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
+ return $split;
+ }
+/**
+ * Returns string with Cyrillic characters translated to Roman ones.
+ *
+ * @param string $string
+ * @return string
+ */
+ function toRoman($string) {
+ $pl = array('ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','�?','Ń','Ó','Ś','Ź','Ż');
+ $ro = array('a','c','e','l','n','o','s','z','z','A','C','E','L','N','O','S','Z','Z');
+ $replace = str_replace($pl, $ro, $string);
+ return $replace;
+ }
+/**
+ * Returns string as lowercase with whitespace removed.
+ *
+ * @param string $string
+ * @return string
+ */
+ function toCompressed($string) {
+ $whitespace = array("\n", " ", "\r", "\0", "\x0B", " ");
+ $replace = strtolower(str_replace($whitespace, '', $string));
+ return $replace;
+ }
+/**
+ * Returns a random password.
+ *
+ * @param integer $length Length of generated password
+ * @param string $available_chars List of characters to use in password
+ * @return string Generated password
+ */
+ function randomPassword($length, $available_chars = 'ABDEFHKMNPRTWXYABDEFHKMNPRTWXY23456789') {
+ $chars = preg_split('//', $available_chars, -1, PREG_SPLIT_NO_EMPTY);
+ $char_count = count($chars);
+ $out = '';
+ for ($ii = 0; $ii < $length; $ii++) {
+ $out .= $chars[rand(1, $char_count)-1];
+ }
+ return $out;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/object.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/object.php
new file mode 100644
index 0000000..a23afc9
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/object.php
@@ -0,0 +1,259 @@
+<?php
+/* SVN FILE: $Id: object.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Object class, allowing __construct and __destruct in PHP4.
+ *
+ * Also includes methods for logging and the special method RequestAction,
+ * to call other Controllers' Actions from anywhere.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Object class, allowing __construct and __destruct in PHP4.
+ *
+ * Also includes methods for logging and the special method RequestAction,
+ * to call other Controllers' Actions from anywhere.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class Object{
+/**
+ * Log object
+ *
+ * @var object
+ * @access protected
+ */
+ var $_log = null;
+/**
+ * A hack to support __construct() on PHP 4
+ * Hint: descendant classes have no PHP4 class_name() constructors,
+ * so this constructor gets called first and calls the top-layer __construct()
+ * which (if present) should call parent::__construct()
+ *
+ * @return Object
+ * @access public
+ */
+ function Object() {
+ $args = func_get_args();
+ if (method_exists($this, '__destruct')) {
+ register_shutdown_function (array(&$this, '__destruct'));
+ }
+ call_user_func_array(array(&$this, '__construct'), $args);
+ }
+/**
+ * Class constructor, overridden in descendant classes.
+ *
+ * @abstract
+ * @access public
+ */
+ function __construct() {
+ }
+
+/**
+ * Object-to-string conversion.
+ * Each class can override this method as necessary.
+ *
+ * @return string The name of this class
+ * @access public
+ */
+ function toString() {
+ $class = get_class($this);
+ return $class;
+ }
+/**
+ * Calls a controller's method from any location. Allows for
+ * controllers to communicate with each other.
+ *
+ * @param string $url URL in the form of Cake URL ("/controller/method/parameter")
+ * @param array $extra If array includes the key "return" it sets the AutoRender to true.
+ * @return boolean Success
+ * @access public
+ */
+ function requestAction($url, $extra = array()) {
+ if (!empty($url)) {
+ $dispatcher =& new Dispatcher();
+ if (isset($this->plugin)) {
+ $extra['plugin'] = $this->plugin;
+ }
+ if (in_array('return', $extra, true)) {
+ $extra['return'] = 0;
+ $extra['bare'] = 1;
+ $extra['requested'] = 1;
+ ob_start();
+ $out = $dispatcher->dispatch($url, $extra);
+ $out = ob_get_clean();
+ return $out;
+ } else {
+ $extra['return'] = 1;
+ $extra['bare'] = 1;
+ $extra['requested'] = 1;
+ return $dispatcher->dispatch($url, $extra);
+ }
+ } else {
+ return false;
+ }
+ }
+/**
+ * API for logging events.
+ *
+ * @param string $msg Log message
+ * @param int $type Error type constant. Defined in app/config/core.php.
+ * @access
+ */
+ function log($msg, $type = LOG_ERROR) {
+ if (!class_exists('CakeLog')) {
+ uses('cake_log');
+ }
+
+ if (is_null($this->_log)) {
+ $this->_log = new CakeLog();
+ }
+
+ if (!is_string($msg)) {
+ ob_start();
+ print_r ($msg);
+ $msg=ob_get_contents();
+ ob_end_clean();
+ }
+
+ switch($type) {
+ case LOG_DEBUG:
+ return $this->_log->write('debug', $msg);
+ break;
+ default:
+ return $this->_log->write('error', $msg);
+ break;
+ }
+ }
+/**
+ * Used to report user friendly errors.
+ * If there is a file app/error.php this file will be loaded
+ * error.php is the AppError class it should extend ErrorHandler class.
+ *
+ * @param string $method Method to be called in the error class (AppError or ErrorHandler classes)
+ * @param array $messages Message that is to be displayed by the error class
+ * @return error message
+ * @access public
+ */
+ function cakeError($method, $messages) {
+ if (!class_exists('ErrorHandler')) {
+ uses('error');
+ if (file_exists(APP . 'error.php')) {
+ include_once (APP . 'error.php');
+ }
+ }
+
+ if (class_exists('AppError')) {
+ $error = new AppError($method, $messages);
+ } else {
+ $error = new ErrorHandler($method, $messages);
+ }
+ return $error;
+ }
+/**
+ * Checks for a persistent class file, if found file is opened and true returned
+ * If file is not found a file is created and false returned
+ *
+ * There are many uses for this method, see manual for examples also art of
+ * the cache system
+ *
+ * @param string $name name of class to persist
+ * @param boolean $return
+ * @param object $object
+ * @param string $type
+ * @return boolean
+ * @todo add examples to manual
+ * @access protected
+ */
+ function _persist($name, $return = null, &$object, $type = null) {
+ $file = CACHE . 'persistent' . DS . strtolower($name) . '.php';
+ if ($return === null) {
+ if (!file_exists($file)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ if (!file_exists($file)) {
+ $this->_savePersistent($name, $object);
+ return false;
+ } else {
+ $this->__openPersistent($name, $type);
+ return true;
+ }
+ }
+/**
+ * You should choose a unique name for the persistent file
+ *
+ * There are many uses for this method, see manual for examples also part of
+ * the cache system
+ *
+ * @param string $name name used for object to cache
+ * @param object $object the object to persist
+ * @return true on save, throws error if file can not be created
+ * @access protected
+ */
+ function _savePersistent($name, &$object) {
+ $file = 'persistent' . DS . strtolower($name) . '.php';
+ $objectArray = array(&$object);
+ $data = str_replace('\\', '\\\\', serialize($objectArray));
+ $data = '<?php $' . $name . ' = \'' . str_replace('\'', '\\\'', $data) . '\' ?>';
+ cache($file, $data, '+1 day');
+ }
+/**
+ * Open the persistent class file for reading
+ * Used by Object::_persist(), part of the cache
+ * system
+ *
+ * @param string $name Name of the persistant file
+ * @param string $type
+ * @access private
+ */
+ function __openPersistent($name, $type = null) {
+ $file = CACHE . 'persistent' . DS . strtolower($name) . '.php';
+ include($file);
+
+ switch($type) {
+ case 'registry':
+ $vars = unserialize(${$name});
+ foreach ($vars['0'] as $key => $value) {
+ loadModel(Inflector::classify($key));
+ }
+ unset($vars);
+ $vars = unserialize(${$name});
+ foreach ($vars['0'] as $key => $value) {
+ ClassRegistry::addObject($key, $value);
+ unset ($value);
+ }
+ unset($vars);
+ break;
+ default:
+ $vars = unserialize(${$name});
+ $this->{$name} = $vars['0'];
+ unset($vars);
+ break;
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/router.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/router.php
new file mode 100644
index 0000000..bf32954
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/router.php
@@ -0,0 +1,230 @@
+<?php
+/* SVN FILE: $Id: router.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Parses the request URL into controller, action, and parameters.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Included libraries.
+ *
+ */
+ if (!class_exists('Object')) {
+ uses ('object');
+ }
+/**
+ * Parses the request URL into controller, action, and parameters.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class Router extends Object {
+/**
+ * Array of routes
+ *
+ * @var array
+ * @access public
+ */
+ var $routes = array();
+/**
+ * CAKE_ADMIN route
+ *
+ * @var array
+ * @access private
+ */
+ var $__admin = null;
+/**
+ * Constructor
+ *
+ * @access public
+ */
+ function __construct() {
+ if (defined('CAKE_ADMIN')) {
+ $admin = CAKE_ADMIN;
+ if (!empty($admin)) {
+ $this->__admin = array('/:' . $admin . '/:controller/:action/* (default)',
+ '/^(?:\/(?:(' . $admin . ')(?:\\/([a-zA-Z0-9_\\-\\.\\;\\:]+)(?:\\/([a-zA-Z0-9_\\-\\.\\;\\:]+)(?:[\\/\\?](.*))?)?)?))[\/]*$/',
+ array($admin, 'controller', 'action'), array());
+ }
+ }
+ }
+/**
+ * Returns this object's routes array. Returns false if there are no routes available.
+ *
+ * @param string $route An empty string, or a route string "/"
+ * @param array $default NULL or an array describing the default route
+ * @return array Array of routes
+ */
+ function connect($route, $default = null) {
+ $parsed = $names = array();
+
+ if (defined('CAKE_ADMIN') && $default == null) {
+ if ($route == CAKE_ADMIN) {
+ $this->routes[] = $this->__admin;
+ $this->__admin = null;
+ }
+ }
+ $r = null;
+ if (($route == '') || ($route == '/')) {
+ $regexp='/^[\/]*$/';
+ $this->routes[] = array($route, $regexp, array(), $default);
+ } else {
+ $elements = array();
+
+ foreach (explode('/', $route)as $element) {
+ if (trim($element))
+ $elements[] = $element;
+ }
+
+ if (!count($elements)) {
+ return false;
+ }
+
+ foreach ($elements as $element) {
+
+ if (preg_match('/^:(.+)$/', $element, $r)) {
+ $parsed[]='(?:\/([^\/]+))?';
+ $names[] =$r[1];
+ } elseif (preg_match('/^\*$/', $element, $r)) {
+ $parsed[] = '(?:\/(.*))?';
+ } else {
+ $parsed[] = '/' . $element;
+ }
+ }
+
+ $regexp='#^' . join('', $parsed) . '[\/]*$#';
+ $this->routes[] = array($route, $regexp, $names, $default);
+ }
+ return $this->routes;
+ }
+/**
+ * Parses given URL and returns an array of controllers, action and parameters
+ * taken from that URL.
+ *
+ * @param string $url URL to be parsed
+ * @return array
+ * @access public
+ */
+ function parse($url) {
+ if (ini_get('magic_quotes_gpc') == 1) {
+ $url = stripslashes_deep($url);
+ }
+
+ if ($url && ('/' != $url[0])) {
+ if (!defined('SERVER_IIS')) {
+ $url = '/' . $url;
+ }
+ }
+ $out = array('pass'=>array());
+ $r = null;
+ $default_route = array('/:controller/:action/* (default)',
+ '/^(?:\/(?:([a-zA-Z0-9_\\-\\.\\;\\:]+)(?:\\/([a-zA-Z0-9_\\-\\.\\;\\:]+)(?:[\\/\\?](.*))?)?))[\\/]*$/',
+ array('controller', 'action'), array());
+
+ if (defined('CAKE_ADMIN') && $this->__admin != null) {
+ $this->routes[]=$this->__admin;
+ $this->__admin =null;
+ }
+ $this->connect('/bare/:controller/:action/*', array('bare' => '1'));
+ $this->connect('/ajax/:controller/:action/*', array('bare' => '1'));
+
+ if (defined('WEBSERVICES') && WEBSERVICES == 'on') {
+ $this->connect('/rest/:controller/:action/*', array('webservices' => 'Rest'));
+ $this->connect('/rss/:controller/:action/*', array('webservices' => 'Rss'));
+ $this->connect('/soap/:controller/:action/*', array('webservices' => 'Soap'));
+ $this->connect('/xml/:controller/:action/*', array('webservices' => 'Xml'));
+ $this->connect('/xmlrpc/:controller/:action/*', array('webservices' => 'XmlRpc'));
+ }
+ $this->routes[] = $default_route;
+
+ if (strpos($url, '?') !== false) {
+ $url = substr($url, 0, strpos($url, '?'));
+ }
+
+ foreach ($this->routes as $route) {
+ list($route, $regexp, $names, $defaults) = $route;
+
+ if (preg_match($regexp, $url, $r)) {
+ // remove the first element, which is the url
+ array_shift ($r);
+ // hack, pre-fill the default route names
+ foreach ($names as $name) {
+ $out[$name] = null;
+ }
+ $ii=0;
+
+ if (is_array($defaults)) {
+ foreach ($defaults as $name => $value) {
+ if (preg_match('#[a-zA-Z_\-]#i', $name)) {
+ $out[$name] = $this->stripEscape($value);
+ } else {
+ $out['pass'][] = $this->stripEscape($value);
+ }
+ }
+ }
+
+ foreach ($r as $found) {
+ // if $found is a named url element (i.e. ':action')
+ if (isset($names[$ii])) {
+ $out[$names[$ii]] = $found;
+ } else {
+ // unnamed elements go in as 'pass'
+ $found = explode('/', $found);
+ $pass = array();
+ foreach ($found as $key => $value) {
+ if ($value == "0") {
+ $pass[$key] = $this->stripEscape($value);
+ } elseif ($value) {
+ $pass[$key] = $this->stripEscape($value);
+ }
+ }
+ $out['pass'] = am($out['pass'], $pass);
+ }
+ $ii++;
+ }
+ break;
+ }
+ }
+ return $out;
+ }
+ function stripEscape($param) {
+ if (!is_array($param) || empty($param)) {
+ if (is_bool($param)) {
+ return $param;
+ }
+
+ $return = preg_replace('/^[\\t ]*(?:-!)+/', '', $param);
+ return $return;
+ }
+ foreach ($param as $key => $value) {
+ if (is_string($value)) {
+ $return[$key] = preg_replace('/^[\\t ]*(?:-!)+/', '', $value);
+ } else {
+ foreach ($value as $array => $string) {
+ $return[$key][$array] = $this->stripEscape($string);
+ }
+ }
+ }
+ return $return;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/sanitize.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/sanitize.php
new file mode 100644
index 0000000..ef818b0
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/sanitize.php
@@ -0,0 +1,245 @@
+<?php
+/* SVN FILE: $Id: sanitize.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Washes strings from unwanted noise.
+ *
+ * Helpful methods to make unsafe strings usable.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Data Sanitization.
+ *
+ * Removal of alpahnumeric characters, SQL-safe slash-added strings, HTML-friendly strings,
+ * and all of the above on arrays.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class Sanitize{
+/**
+ * Removes any non-alphanumeric characters.
+ *
+ * @param string $string
+ * @return string
+ * @access public
+ */
+ function paranoid($string, $allowed = array()) {
+ $allow = null;
+ if (!empty($allowed)) {
+ foreach ($allowed as $value) {
+ $allow .= "\\$value";
+ }
+ }
+
+ if (is_array($string)) {
+ foreach ($string as $key => $clean) {
+ $cleaned[$key] = preg_replace("/[^{$allow}a-zA-Z0-9]/", "", $clean);
+ }
+ } else {
+ $cleaned = preg_replace("/[^{$allow}a-zA-Z0-9]/", "", $string);
+ }
+ return $cleaned;
+ }
+/**
+ * Makes a string SQL-safe by adding slashes (if needed).
+ *
+ * @param string $string
+ * @return string
+ * @access public
+ */
+ function sql($string) {
+ if (!ini_get('magic_quotes_gpc')) {
+ $string = addslashes($string);
+ }
+ return $string;
+ }
+/**
+ * Returns given string safe for display as HTML. Renders entities.
+ *
+ * @param string $string
+ * @param boolean $remove If true, the string is stripped of all HTML tags
+ * @return string
+ * @access public
+ */
+ function html($string, $remove = false) {
+ if ($remove) {
+ $string = strip_tags($string);
+ } else {
+ $patterns = array("/\&/", "/%/", "/</", "/>/", '/"/', "/'/", "/\(/", "/\)/", "/\+/", "/-/");
+ $replacements = array("&amp;", "&#37;", "&lt;", "&gt;", "&quot;", "&#39;", "&#40;", "&#41;", "&#43;", "&#45;");
+ $string = preg_replace($patterns, $replacements, $string);
+ }
+ return $string;
+ }
+/**
+ * Recursively sanitizes given array of data for safe input.
+ *
+ * @param mixed $toClean
+ * @return mixed
+ * @access public
+ */
+ function cleanArray(&$toClean) {
+ return $this->cleanArrayR($toClean);
+ }
+/**
+ * Method used for recursively sanitizing arrays of data
+ * for safe input
+ *
+ * @param array $toClean
+ * @return array The clean array
+ * @access public
+ */
+ 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 sanitize array nodes.
+ *
+ * @param string $val
+ * @return string
+ * @access public
+ */
+ 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.
+ $val = $this->html($val);
+ //Double-check special chars and replace carriage returns with new lines
+ $val = preg_replace("/\\\$/", "$", $val);
+ $val = preg_replace("/\r\n/", "\n", $val);
+ $val = str_replace("!", "!", $val);
+ $val = str_replace("'", "'", $val);
+ //Allow unicode (?)
+ $val = preg_replace("/&amp;#([0-9]+);/s", "&#\\1;", $val);
+ //Add slashes for SQL
+ $val = $this->sql($val);
+ //Swap user-inputted backslashes (?)
+ $val = preg_replace("/\\\(?!&amp;#|\?#)/", "\\", $val);
+ return $val;
+ }
+
+/**
+ * Formats column data from definition in DBO's $columns array
+ *
+ * @param Model $model The model containing the data to be formatted
+ * @return void
+ * @access public
+ */
+ function formatColumns(&$model) {
+ foreach ($model->data as $name => $values) {
+ if ($name == $model->name) {
+ $curModel =& $model;
+ } elseif (isset($model->{$name}) && is_object($model->{$name}) && is_subclass_of($model->{$name}, 'Model')) {
+ $curModel =& $model->{$name};
+ } else {
+ $curModel = null;
+ }
+
+ if ($curModel != null) {
+ foreach ($values as $column => $data) {
+ $colType = $curModel->getColumnType($column);
+
+ if ($colType != null) {
+ $db =& ConnectionManager::getDataSource($curModel->useDbConfig);
+ $colData = $db->columns[$colType];
+
+ if (isset($colData['limit']) && strlen(strval($data)) > $colData['limit']) {
+ $data = substr(strval($data), 0, $colData['limit']);
+ }
+
+ if (isset($colData['formatter']) || isset($colData['format'])) {
+
+ switch(strtolower($colData['formatter'])) {
+ case 'date':
+ $data = date($colData['format'], strtotime($data));
+ break;
+ case 'sprintf':
+ $data = sprintf($colData['format'], $data);
+ break;
+ case 'intval':
+ $data = intval($data);
+ break;
+ case 'floatval':
+ $data = floatval($data);
+ break;
+ }
+ }
+ $model->data[$name][$column]=$data;
+ /*
+ switch($colType) {
+ case 'integer':
+ case 'int':
+ return $data;
+ break;
+ case 'string':
+ case 'text':
+ case 'binary':
+ case 'date':
+ case 'time':
+ case 'datetime':
+ case 'timestamp':
+ case 'date':
+ return "'" . $data . "'";
+ break;
+ }
+ */
+ }
+ }
+ }
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/security.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/security.php
new file mode 100644
index 0000000..c3a59b2
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/security.php
@@ -0,0 +1,151 @@
+<?php
+/* SVN FILE: $Id: security.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Security Class
+ *
+ * This class is a singleton class that contains
+ * functions for hasing and security.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v .0.10.0.1233
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Security Class
+ *
+ * This class is a singleton class that contains functions for hasing and security.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class Security extends Object {
+/**
+ * Singleton method to retrieve the instance of the Security class
+ *
+ * @return object Security
+ * @access public
+ */
+ function &getInstance() {
+ static $instance = array();
+ if (!$instance) {
+ $instance[0] = &new Security;
+ }
+ return $instance[0];
+ }
+/**
+ * Returns inactive minutes constant based on cake the security level
+ *
+ * @return integer
+ * @access public
+ */
+ function inactiveMins() {
+ switch(CAKE_SECURITY) {
+ case 'high':
+ return 10;
+ break;
+ case 'medium':
+ return 100;
+ break;
+ case 'low':
+ default:
+ return 300;
+ break;
+ }
+ }
+/**
+ * Generates a unique authkey
+ *
+ * @return mixed
+ * @access public
+ */
+ function generateAuthKey() {
+ $_this =& Security::getInstance();
+ return $_this->hash(uniqid(rand(), true));
+ }
+/**
+ * Validates the authkey
+ *
+ * @param mixed $authKey
+ * @return boolean
+ * @access public
+ */
+ function validateAuthKey($authKey) {
+ return true;
+ }
+/**
+ * Generates a hash of a string using a php built in hashing function
+ *
+ * @param string $string The string to be hashed
+ * @param string $type The hashing algorithm
+ * @return string
+ * @access public
+ */
+ function hash($string, $type = 'sha1') {
+ $type = strtolower($type);
+ if ($type == 'sha1') {
+ if (function_exists('sha1')) {
+ $return = sha1($string);
+ return $return;
+ } else {
+ $type = 'sha256';
+ }
+ }
+
+ if ($type == 'sha256') {
+ if (function_exists('mhash')) {
+ $return = bin2hex(mhash(MHASH_SHA256, $string));
+ return $return;
+ } else {
+ $type = 'md5';
+ }
+ }
+
+ if ($type == 'md5') {
+ $return = md5($string);
+ return $return;
+ }
+ }
+/**
+ * Function that ciphers a text using a key
+ *
+ * @param string $text
+ * @param string $key
+ * @return string
+ * @access public
+ */
+ function cipher($text, $key) {
+ if (!defined('CIPHER_SEED')) {
+ //This is temporary will change later
+ define('CIPHER_SEED', '76859309657453542496749683645');
+ }
+ srand (CIPHER_SEED);
+ $out = '';
+
+ for ($i = 0; $i < strlen($text); $i++) {
+ for ($j = 0; $j < ord(substr($key, $i % strlen($key), 1)); $j++) {
+ $toss = rand(0, 255);
+ }
+ $mask = rand(0, 255);
+ $out .= chr(ord(substr($text, $i, 1)) ^ $mask);
+ }
+ return $out;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/session.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/session.php
new file mode 100644
index 0000000..924b931
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/session.php
@@ -0,0 +1,757 @@
+<?php
+/* SVN FILE: $Id: session.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * Session class for Cake.
+ *
+ * Cake abstracts the handling of sessions.
+ * There are several convenient methods to access session information.
+ * This class is the implementation of those methods.
+ * They are mostly used by the Session Component.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v .0.10.0.1222
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Database name for cake sessions.
+ *
+ */
+ if (!defined('CAKE_SESSION_TABLE')) {
+ define('CAKE_SESSION_TABLE', 'cake_sessions');
+ }
+
+ if (CAKE_SESSION_SAVE === 'database') {
+ uses('model' . DS . 'connection_manager');
+ }
+ uses('set');
+/**
+ * Session class for Cake.
+ *
+ * Cake abstracts the handling of sessions. There are several convenient methods to access session information.
+ * This class is the implementation of those methods. They are mostly used by the Session Component.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class CakeSession extends Object {
+/**
+ * True if the Session is still valid
+ *
+ * @var boolean
+ * @access public
+ */
+ var $valid = false;
+/**
+ * Error messages for this session
+ *
+ * @var array
+ * @access public
+ */
+ var $error = false;
+/**
+ * User agent string
+ *
+ * @var string
+ * @access protected
+ */
+ var $_userAgent = '';
+/**
+ * Path to where the session is active.
+ *
+ * @var string
+ * @access public
+ */
+ var $path = '/';
+/**
+ * Error number of last occurred error
+ *
+ * @var integer
+ * @access public
+ */
+ var $lastError = null;
+/**
+ * CAKE_SECURITY setting, "high", "medium", or "low".
+ *
+ * @var string
+ * @access public
+ */
+ var $security = null;
+/**
+ * Start time for this session.
+ *
+ * @var integer
+ * @access public
+ */
+ var $time = false;
+/**
+ * Time when this session becomes invalid.
+ *
+ * @var integer
+ * @access public
+ */
+ var $sessionTime = false;
+/**
+ * Keeps track of keys to watch for writes on
+ *
+ * @var array
+ * @access public
+ */
+ var $watchKeys = array();
+/**
+ * Current Session id
+ *
+ * @var string
+ * @access public
+ */
+ var $id = null;
+/**
+ * Constructor.
+ *
+ * @param string $base The base path for the Session
+ * @param boolean $start Should session be started right now
+ * @access public
+ */
+ function __construct($base = null, $start = true) {
+ if (Configure::read('Session.checkAgent') === true) {
+ if (env('HTTP_USER_AGENT') != null) {
+ $this->_userAgent = md5(env('HTTP_USER_AGENT') . CAKE_SESSION_STRING);
+ }
+ }
+ $this->time = time();
+
+ if ($start === true) {
+ $this->host = env('HTTP_HOST');
+
+ if (empty($base) || strpos($base, '?') === 0 || strpos($base, 'index.php') === 0) {
+ $this->path = '/';
+ } else {
+ $this->path = $base;
+ }
+
+ if (strpos($this->host, ':') !== false) {
+ $this->host = substr($this->host, 0, strpos($this->host, ':'));
+ }
+
+ $this->sessionTime = $this->time + (Security::inactiveMins() * CAKE_SESSION_TIMEOUT);
+ $this->security = CAKE_SECURITY;
+ }
+ parent::__construct();
+ }
+/**
+ * Starts the Session.
+ *
+ * @param string $name Variable name to check for
+ * @return boolean True if variable is there
+ * @access public
+ */
+ function start() {
+ if (function_exists('session_write_close')) {
+ session_write_close();
+ }
+ $this->__initSession();
+ return $this->__startSession();
+ }
+/**
+ * Determine if Session has been started.
+ *
+ * @access public
+ */
+ function started(){
+ if (isset($_SESSION)) {
+ return true;
+ }
+ return false;
+ }
+/**
+ * Returns true if given variable is set in session.
+ *
+ * @param string $name Variable name to check for
+ * @return boolean True if variable is there
+ * @access public
+ */
+ function check($name) {
+ $var = $this->__validateKeys($name);
+ if (empty($var)) {
+ return false;
+ }
+ $result = Set::extract($_SESSION, $var);
+ return isset($result);
+ }
+/**
+ *
+ * @param id $name string
+ * @return string Session id
+ * @access public
+ */
+ function id($id = null) {
+ if ($id) {
+ $this->id = $id;
+ session_id($this->id);
+ }
+ if (isset($_SESSION)) {
+ return session_id();
+ } else {
+ return $this->id;
+ }
+ }
+/**
+ * Temp method until we are able to remove the last eval().
+ * Builds an expression to fetch a session variable with specified name.
+ *
+ * @param string $name Name of variable (in dot notation)
+ * @access private
+ */
+ function __sessionVarNames($name) {
+ if (is_string($name) && preg_match("/^[ 0-9a-zA-Z._-]*$/", $name)) {
+ if (strpos($name, ".")) {
+ $names = explode(".", $name);
+ } else {
+ $names = array($name);
+ }
+ $expression = "\$_SESSION";
+ foreach ($names as $item) {
+ $expression .= is_numeric($item) ? "[$item]" : "['$item']";
+ }
+ return $expression;
+ }
+ $this->__setError(3, "$name is not a string");
+ return false;
+ }
+/**
+ * Removes a variable from session.
+ *
+ * @param string $name Session variable to remove
+ * @return boolean Success
+ * @access public
+ */
+ function del($name) {
+ if ($this->check($name)) {
+ if ($var = $this->__validateKeys($name)) {
+ if (in_array($var, $this->watchKeys)) {
+ trigger_error('Deleting session key {' . $var . '}', E_USER_NOTICE);
+ }
+ $this->__overwrite($_SESSION, Set::remove($_SESSION, $var));
+ return ($this->check($var) == false);
+ }
+ }
+ $this->__setError(2, "$name doesn't exist");
+ return false;
+ }
+/**
+ * Used to write new data to _SESSION, since PHP doesn't like us setting the _SESSION var itself
+ *
+ * @param array $old Set of old variables => values
+ * @param array $new New set of variable => value
+ * @access private
+ */
+ function __overwrite(&$old, $new) {
+ if(!empty($old)) {
+ foreach ($old as $key => $var) {
+ if (!isset($new[$key])) {
+ unset($old[$key]);
+ }
+ }
+ }
+ foreach ($new as $key => $var) {
+ $old[$key] = $var;
+ }
+ }
+/**
+ * Return error description for given error number.
+ *
+ * @param integer $errorNumber Error to set
+ * @return string Error as string
+ * @access private
+ */
+ function __error($errorNumber) {
+ if (!is_array($this->error) || !array_key_exists($errorNumber, $this->error)) {
+ return false;
+ } else {
+ return $this->error[$errorNumber];
+ }
+ }
+/**
+ * Returns last occurred error as a string, if any.
+ *
+ * @return mixed Error description as a string, or false.
+ * @access public
+ */
+ function error() {
+ if ($this->lastError) {
+ return $this->__error($this->lastError);
+ } else {
+ return false;
+ }
+ }
+/**
+ * Returns true if session is valid.
+ *
+ * @return boolean Success
+ * @access public
+ */
+ function valid() {
+ if ($this->read('Config')) {
+ if (Configure::read('Session.checkAgent') === false || $this->_userAgent == $this->read("Config.userAgent") && $this->time <= $this->read("Config.time")) {
+ if ($this->error === false) {
+ $this->valid = true;
+ }
+ } else {
+ $this->valid = false;
+ $this->__setError(1, "Session Highjacking Attempted !!!");
+ }
+ }
+ return $this->valid;
+ }
+/**
+ * Returns given session variable, or all of them, if no parameters given.
+ *
+ * @param mixed $name The name of the session variable (or a path as sent to Set.extract)
+ * @return mixed The value of the session variable
+ * @access public
+ */
+ function read($name = null) {
+ if (is_null($name)) {
+ return $this->__returnSessionVars();
+ }
+ if (empty($name)) {
+ return false;
+ }
+ $result = Set::extract($_SESSION, $name);
+
+ if (!is_null($result)) {
+ return $result;
+ }
+ $this->__setError(2, "$name doesn't exist");
+ return null;
+ }
+/**
+ * Returns all session variables.
+ *
+ * @return mixed Full $_SESSION array, or false on error.
+ * @access private
+ */
+ function __returnSessionVars() {
+ if (!empty($_SESSION)) {
+ return $_SESSION;
+ }
+ $this->__setError(2, "No Session vars set");
+ return false;
+ }
+/**
+ * Tells Session to write a notification when a certain session path or subpath is written to
+ *
+ * @param mixed $var The variable path to watch
+ * @access public
+ */
+ function watch($var) {
+ $var = $this->__validateKeys($var);
+ if (empty($var)) {
+ return false;
+ }
+ $this->watchKeys[] = $var;
+ }
+/**
+ * Tells Session to stop watching a given key path
+ *
+ * @param mixed $var The variable path to watch
+ * @access public
+ */
+ function ignore($var) {
+ $var = $this->__validateKeys($var);
+ if (!in_array($var, $this->watchKeys)) {
+ return;
+ }
+ foreach ($this->watchKeys as $i => $key) {
+ if ($key == $var) {
+ unset($this->watchKeys[$i]);
+ $this->watchKeys = array_values($this->watchKeys);
+ return;
+ }
+ }
+ }
+/**
+ * Writes value to given session variable name.
+ *
+ * @param mixed $name Name of variable
+ * @param string $value Value to write
+ * @return boolean True if the write was successful, false if the write failed
+ * @access public
+ */
+ function write($name, $value) {
+ $var = $this->__validateKeys($name);
+
+ if (empty($var)) {
+ return false;
+ }
+ if (in_array($var, $this->watchKeys)) {
+ trigger_error('Writing session key {' . $var . '}: ' . print_r($value), E_USER_NOTICE);
+ }
+ $this->__overwrite($_SESSION, Set::insert($_SESSION, $var, $value));
+ return (Set::extract($_SESSION, $var) === $value);
+ }
+/**
+ * Helper method to destroy invalid sessions.
+ *
+ * @access public
+ */
+ function destroy() {
+ $sessionpath = session_save_path();
+ if (empty($sessionpath)) {
+ $sessionpath = "/tmp";
+ }
+
+ if (isset($_COOKIE[session_name()])) {
+ setcookie(CAKE_SESSION_COOKIE, '', time() - 42000, $this->path);
+ }
+
+ $_SESSION = array();
+ $file = $sessionpath . DS . "sess_" . session_id();
+ @session_destroy();
+ @unlink ($file);
+ $this->__construct($this->path);
+ $this->renew();
+ }
+/**
+ * Helper method to initialize a session, based on Cake core settings.
+ *
+ * @access private
+ */
+ function __initSession() {
+ switch($this->security) {
+ case 'high':
+ $this->cookieLifeTime = 0;
+ if (function_exists('ini_set')) {
+ ini_set('session.referer_check', $this->host);
+ }
+ break;
+ case 'medium':
+ $this->cookieLifeTime = 7 * 86400;
+ if (function_exists('ini_set')) {
+ ini_set('session.referer_check', $this->host);
+ }
+ break;
+ case 'low':
+ default:
+ $this->cookieLifeTime = 788940000;
+ break;
+ }
+
+ switch(CAKE_SESSION_SAVE) {
+ case 'cake':
+ if (!isset($_SESSION)) {
+ if (function_exists('ini_set')) {
+ ini_set('session.use_trans_sid', 0);
+ ini_set('url_rewriter.tags', '');
+ ini_set('session.serialize_handler', 'php');
+ ini_set('session.use_cookies', 1);
+ ini_set('session.name', CAKE_SESSION_COOKIE);
+ ini_set('session.cookie_lifetime', $this->cookieLifeTime);
+ ini_set('session.cookie_path', $this->path);
+ ini_set('session.auto_start', 0);
+ ini_set('session.save_path', TMP . 'sessions');
+ }
+ }
+ break;
+ case 'database':
+ if (!isset($_SESSION)) {
+ if (function_exists('ini_set')) {
+ ini_set('session.use_trans_sid', 0);
+ ini_set('url_rewriter.tags', '');
+ ini_set('session.save_handler', 'user');
+ ini_set('session.serialize_handler', 'php');
+ ini_set('session.use_cookies', 1);
+ ini_set('session.name', CAKE_SESSION_COOKIE);
+ ini_set('session.cookie_lifetime', $this->cookieLifeTime);
+ ini_set('session.cookie_path', $this->path);
+ ini_set('session.auto_start', 0);
+ }
+ }
+ session_set_save_handler(array('CakeSession','__open'),
+ array('CakeSession', '__close'),
+ array('CakeSession', '__read'),
+ array('CakeSession', '__write'),
+ array('CakeSession', '__destroy'),
+ array('CakeSession', '__gc'));
+ break;
+ case 'php':
+ if (!isset($_SESSION)) {
+ if (function_exists('ini_set')) {
+ ini_set('session.use_trans_sid', 0);
+ ini_set('session.name', CAKE_SESSION_COOKIE);
+ ini_set('session.cookie_lifetime', $this->cookieLifeTime);
+ ini_set('session.cookie_path', $this->path);
+ }
+ }
+ break;
+ default:
+ if (!isset($_SESSION)) {
+ $config = CONFIGS . CAKE_SESSION_SAVE . '.php';
+
+ if (is_file($config)) {
+ require_once ($config);
+ }
+ }
+ break;
+ }
+ }
+/**
+ * Helper method to start a session
+ *
+ * @access private
+ */
+ function __startSession() {
+ if (headers_sent()) {
+ if (!isset($_SESSION)) {
+ $_SESSION = array();
+ }
+ return false;
+ } elseif (!isset($_SESSION)) {
+ session_cache_limiter ("must-revalidate");
+ session_start();
+ header ('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
+ return true;
+ } else {
+ session_start();
+ return true;
+ }
+ }
+/**
+ * Helper method to create a new session.
+ *
+ * @access protected
+ */
+ function _checkValid() {
+ if ($this->read('Config')) {
+ if (Configure::read('Session.checkAgent') === false || $this->_userAgent == $this->read("Config.userAgent") && $this->time <= $this->read("Config.time")) {
+ $time = $this->read("Config.time");
+ $this->write("Config.time", $this->sessionTime);
+
+ if ($this->security === 'high') {
+ $check = $this->read("Config.timeout");
+ $check = $check - 1;
+ $this->write("Config.timeout", $check);
+
+ if (time() > ($time - (Security::inactiveMins() * CAKE_SESSION_TIMEOUT) + 2) || $check < 1) {
+ $this->renew();
+ $this->write('Config.timeout', 10);
+ }
+ }
+ $this->valid = true;
+ } else {
+ $this->destroy();
+ $this->valid = false;
+ $this->__setError(1, "Session Highjacking Attempted !!!");
+ }
+ } else {
+ srand ((double)microtime() * 1000000);
+ $this->write("Config.userAgent", $this->_userAgent);
+ $this->write("Config.time", $this->sessionTime);
+ $this->write('Config.rand', rand());
+ $this->write('Config.timeout', 10);
+ $this->valid = true;
+ $this->__setError(1, "Session is valid");
+ }
+ }
+/**
+ * Helper method to restart a session.
+ *
+ * @access private
+ */
+ function __regenerateId() {
+ $oldSessionId = session_id();
+ if ($oldSessionId) {
+ $sessionpath = session_save_path();
+ if (empty($sessionpath)) {
+ $sessionpath = "/tmp";
+ }
+
+ if (isset($_COOKIE[session_name()])) {
+ setcookie(CAKE_SESSION_COOKIE, '', time() - 42000, $this->path);
+ }
+ session_regenerate_id();
+ $newSessid = session_id();
+
+ if (function_exists('session_write_close')) {
+ session_write_close();
+ }
+ $this->__initSession();
+ session_id($oldSessionId);
+ session_start();
+ session_destroy();
+ $file = $sessionpath . DS . "sess_$oldSessionId";
+ @unlink($file);
+ $this->__initSession();
+ session_id($newSessid);
+ session_start();
+ }
+ }
+/**
+ * Restarts this session.
+ *
+ * @access public
+ */
+ function renew() {
+ $this->__regenerateId();
+ }
+/**
+ * Validate that the $name is in correct dot notation
+ * example: $name = 'ControllerName.key';
+ *
+ * @param string $name Session key names as string.
+ * @return mixed false is $name is not correct format, or $name if it is correct
+ * @access private
+ */
+ function __validateKeys($name) {
+ if (is_string($name) && preg_match("/^[ 0-9a-zA-Z._-]*$/", $name)) {
+ return $name;
+ }
+ $this->__setError(3, "$name is not a string");
+ return false;
+ }
+/**
+ * Helper method to set an internal error message.
+ *
+ * @param integer $errorNumber Number of the error
+ * @param string $errorMessage Description of the error
+ * @access private
+ */
+ function __setError($errorNumber, $errorMessage) {
+ if ($this->error === false) {
+ $this->error = array();
+ }
+ $this->error[$errorNumber] = $errorMessage;
+ $this->lastError = $errorNumber;
+ }
+/**
+ * Method called on open of a database session.
+ *
+ * @return boolean Success
+ * @access private
+ */
+ function __open() {
+ return true;
+ }
+/**
+ * Method called on close of a database session.
+ *
+ * @return boolean Success
+ * @access private
+ */
+ function __close() {
+ $probability = mt_rand(1, 150);
+ if ($probability <= 3) {
+ CakeSession::__gc();
+ }
+ return true;
+ }
+/**
+ * Method used to read from a database session.
+ *
+ * @param mixed $key The key of the value to read
+ * @return mixed The value of the key or false if it does not exist
+ * @access private
+ */
+ function __read($key) {
+ $db =& ConnectionManager::getDataSource('default');
+ $table = $db->fullTableName(CAKE_SESSION_TABLE, false);
+ $row = $db->query("SELECT " . $db->name($table.'.data') . " FROM " . $db->name($table) . " WHERE " . $db->name($table.'.id') . " = " . $db->value($key), false);
+
+ if ($row && !isset($row[0][$table]) && isset($row[0][0])) {
+ $table = 0;
+ }
+
+ if ($row && $row[0][$table]['data']) {
+ return $row[0][$table]['data'];
+ } else {
+ return false;
+ }
+ }
+/**
+ * Helper function called on write for database sessions.
+ *
+ * @param mixed $key The name of the var
+ * @param mixed $value The value of the var
+ * @return boolean Success
+ * @access private
+ */
+ function __write($key, $value) {
+ $db =& ConnectionManager::getDataSource('default');
+ $table = $db->fullTableName(CAKE_SESSION_TABLE);
+
+ switch(CAKE_SECURITY) {
+ case 'high':
+ $factor = 10;
+ break;
+ case 'medium':
+ $factor = 100;
+ break;
+ case 'low':
+ $factor = 300;
+ break;
+ default:
+ $factor = 10;
+ break;
+ }
+ $expires = time() + CAKE_SESSION_TIMEOUT * $factor;
+ $row = $db->query("SELECT COUNT(id) AS count FROM " . $db->name($table) . " WHERE "
+ . $db->name('id') . " = "
+ . $db->value($key), false);
+
+ if ($row[0][0]['count'] > 0) {
+ $db->execute("UPDATE " . $db->name($table) . " SET " . $db->name('data') . " = "
+ . $db->value($value) . ", " . $db->name('expires') . " = "
+ . $db->value($expires) . " WHERE " . $db->name('id') . " = "
+ . $db->value($key));
+ } else {
+ $db->execute("INSERT INTO " . $db->name($table) . " (" . $db->name('data') . ","
+ . $db->name('expires') . "," . $db->name('id')
+ . ") VALUES (" . $db->value($value) . ", " . $db->value($expires) . ", "
+ . $db->value($key) . ")");
+ }
+ return true;
+ }
+/**
+ * Method called on the destruction of a database session.
+ *
+ * @param int $key Key that uniquely identifies session in database
+ * @return boolean Success
+ * @access private
+ */
+ function __destroy($key) {
+ $db =& ConnectionManager::getDataSource('default');
+ $table = $db->fullTableName(CAKE_SESSION_TABLE);
+ $db->execute("DELETE FROM " . $db->name($table) . " WHERE " . $db->name($table.'.id') . " = " . $db->value($key, 'integer'));
+ return true;
+ }
+/**
+ * Helper function called on gc for database sessions.
+ *
+ * @param int $expires Timestamp (defaults to current time)
+ * @return boolean Success
+ * @access private
+ */
+ function __gc($expires = null) {
+ $db =& ConnectionManager::getDataSource('default');
+ $table = $db->fullTableName(CAKE_SESSION_TABLE);
+ $db->execute("DELETE FROM " . $db->name($table) . " WHERE " . $db->name($table.'.expires') . " < ". $db->value(time()));
+ return true;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/set.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/set.php
new file mode 100644
index 0000000..44147b9
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/set.php
@@ -0,0 +1,805 @@
+<?php
+/* SVN FILE: $Id: set.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Library of array functions for Cake.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 1.2.0
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Class used for manipulation of arrays.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.cake.libs
+ */
+class Set extends Object {
+/**
+ * Value of the Set object.
+ *
+ * @var array
+ * @access public
+ */
+ var $value = array();
+/**
+ * Constructor. Defaults to an empty array.
+ *
+ * @access public
+ */
+ function __construct() {
+ if (func_num_args() == 1 && is_array(func_get_arg(0))) {
+ $this->value = func_get_arg(0);
+ } else {
+ $this->value = func_get_args();
+ }
+ }
+/**
+ * Returns the contents of the Set object
+ *
+ * @return array
+ * @access public
+ */
+ function &get() {
+ return $this->value;
+ }
+/**
+ * This function can be thought of as a hybrid between PHP's array_merge and array_merge_recursive. The difference
+ * to the two is that if an array key contains another array then the function behaves recursive (unlike array_merge)
+ * but does not do if for keys containing strings (unlike array_merge_recursive). See the unit test for more information.
+ *
+ * Note: This function will work with an unlimited amount of arguments and typecasts non-array parameters into arrays.
+ *
+ * @param array $arr1 Array to be merged
+ * @param array $arr2 Array to merge with
+ * @return array Merged array
+ * @access public
+ */
+ function merge($arr1, $arr2 = null) {
+ $args = func_get_args();
+
+ if (is_a($this, 'set')) {
+ $backtrace = debug_backtrace();
+ $previousCall = strtolower($backtrace[1]['class'].'::'.$backtrace[1]['function']);
+ if ($previousCall != 'set::merge') {
+ $r =& $this->value;
+ array_unshift($args, null);
+ }
+ }
+ if (!isset($r)) {
+ $r = (array)current($args);
+ }
+
+ while (($arg = next($args)) !== false) {
+ if (is_a($arg, 'set')) {
+ $arg = $arg->get();
+ }
+
+ foreach ((array)$arg as $key => $val) {
+ if (is_array($val) && isset($r[$key]) && is_array($r[$key])) {
+ $r[$key] = Set::merge($r[$key], $val);
+ } elseif (is_int($key)) {
+ $r[] = $val;
+ } else {
+ $r[$key] = $val;
+ }
+ }
+ }
+ return $r;
+ }
+/**
+ * Filters empty elements out of a route array, excluding '0'.
+ *
+ * @param mixed $var Either an array to filter, or value when in callback
+ * @param boolean $isArray Force to tell $var is an array when $var is empty
+ * @return mixed Either filtered array, or true/false when in callback
+ * @access public
+ */
+ function filter($var, $isArray = false) {
+ if (is_array($var) && (!empty($var) || $isArray)) {
+ return array_filter($var, array('Set', 'filter'));
+ } else {
+ if ($var === 0 || $var === '0' || !empty($var)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+/**
+ * Pushes the differences in $array2 onto the end of $array
+ *
+ * @param mixed $array Original array
+ * @param mixed $array2 Differences to push
+ * @return array Combined array
+ * @access public
+ */
+ function pushDiff($array = null, $array2 = null) {
+ if ($array2 !== null && is_array($array2)) {
+ foreach ($array2 as $key => $value) {
+ if (!array_key_exists($key, $array)) {
+ $array[$key] = $value;
+ } else {
+ if (is_array($value)) {
+ $array[$key] = Set::pushDiff($array[$key], $array2[$key]);
+ }
+ }
+ }
+ return $array;
+ }
+
+ if (!isset($this->value)) {
+ $this->value = array();
+ }
+ $this->value = Set::pushDiff($this->value, Set::__array($array));
+ return $this->value;
+ }
+/**
+ * Maps the contents of the Set object to an object hierarchy.
+ * Maintains numeric keys as arrays of objects
+ *
+ * @param string $class A class name of the type of object to map to
+ * @param string $tmp A temporary class name used as $class if $class is an array
+ * @return object Hierarchical object
+ * @access public
+ */
+ function map($class = 'stdClass', $tmp = 'stdClass') {
+ if (is_array($class)) {
+ $val = $class;
+ $class = $tmp;
+ } elseif (is_a($this, 'set')) {
+ $val = $this->get();
+ }
+
+ if (empty($val) || $val == null) {
+ return null;
+ }
+ return Set::__map($val, $class);
+ }
+
+/**
+ * Get the array value of $array. If $array is null, it will return
+ * the current array Set holds. If it is an object of type Set, it
+ * will return its value. If it is another object, its object variables.
+ * If it is anything else but an array, it will return an array whose first
+ * element is $array.
+ *
+ * @param mixed $array Data from where to get the array.
+ * @return array Array from $array.
+ * @access private
+ */
+ function __array($array) {
+ if ($array == null) {
+ $array = $this->value;
+ } elseif (is_object($array) && (is_a($array, 'set'))) {
+ $array = $array->get();
+ } elseif (is_object($array)) {
+ $array = get_object_vars($array);
+ } elseif (!is_array($array)) {
+ $array = array($array);
+ }
+ return $array;
+ }
+
+/**
+ * Maps the given value as an object. If $value is an object,
+ * it returns $value. Otherwise it maps $value as an object of
+ * type $class, and if primary assign _name_ $key on first array.
+ * If $value is not empty, it will be used to set properties of
+ * returned object (recursively). If $key is numeric will maintain array
+ * structure
+ *
+ * @param mixed $value Value to map
+ * @param string $class Class name
+ * @param boolean $primary whether to assign first array key as the _name_
+ * @return mixed Mapped object
+ * @access private
+ */
+ function __map(&$array, $class, $primary = false) {
+ if ($class === true) {
+ $out = new stdClass;
+ } else {
+ $out = new $class;
+ }
+ if (is_array($array)) {
+ $keys = array_keys($array);
+ foreach ($array as $key => $value) {
+ if($keys[0] === $key && $class !== true) {
+ $primary = true;
+ }
+ if (is_numeric($key)) {
+ if (is_object($out) && is_array($value)) {
+ $out = get_object_vars($out);
+ }
+ $out[$key] = Set::__map($value, $class, true);
+ } elseif ($primary === true && is_array($value)) {
+ $out->_name_ = $key;
+ $primary = false;
+ foreach($value as $key2 => $value2) {
+ $out->{$key2} = Set::__map($value2, $class);
+ }
+ } else {
+ $out->{$key} = Set::__map($value, $class);
+ }
+ }
+ } else {
+ $out = $array;
+ }
+ return $out;
+ }
+/**
+ * Checks to see if all the values in the array are numeric
+ *
+ * @param array $array The array to check. If null, the value of the current Set object
+ * @return boolean true if values are numeric, false otherwise
+ * @access public
+ */
+ function numeric($array = null) {
+ if ($array == null && (is_a($this, 'set') || is_a($this, 'Set'))) {
+ $array = $this->get();
+ }
+
+ $numeric = true;
+ $keys = array_keys($array);
+ $count = count($keys);
+ for ($i = 0; $i < $count; $i++) {
+ if (!is_numeric($array[$keys[$i]])) {
+ $numeric = false;
+ break;
+ }
+ }
+ return $numeric;
+ }
+/**
+ * Return a value from an array list if the key exists.
+ *
+ * If a comma separated $list is passed arrays are numeric with the key of the first being 0
+ * $list = 'no, yes' would translate to $list = array(0 => 'no', 1 => 'yes');
+ *
+ * If an array is used, keys can be strings example: array('no' => 0, 'yes' => 1);
+ *
+ * $list defaults to 0 = no 1 = yes if param is not passed
+ *
+ * @param mixed $select Key in $list to return
+ * @param mixed $list can be an array or a comma-separated list.
+ * @return string the value of the array key or null if no match
+ * @access public
+ */
+ function enum($select, $list = null) {
+ if (empty($list) && is_a($this, 'Set')) {
+ $list = $this->get();
+ } elseif (empty($list)) {
+ $list = array('no', 'yes');
+ }
+
+ $return = null;
+ $list = Set::normalize($list, false);
+
+ if (array_key_exists($select, $list)) {
+ $return = $list[$select];
+ }
+ return $return;
+ }
+/**
+ * Returns a series of values extracted from an array, formatted in a format string.
+ *
+ * @param array $data Source array from which to extract the data
+ * @param string $format Format string into which values will be inserted, see sprintf()
+ * @param array $keys An array containing one or more Set::extract()-style key paths
+ * @return array An array of strings extracted from $keys and formatted with $format
+ * @access public
+ */
+ function format($data, $format, $keys) {
+
+ $extracted = array();
+ $count = count($keys);
+
+ if (!$count) {
+ return;
+ }
+
+ for ($i = 0; $i < $count; $i++) {
+ $extracted[] = Set::extract($data, $keys[$i]);
+ }
+ $out = array();
+ $data = $extracted;
+ $count = count($data[0]);
+
+ if (preg_match_all('/\{([0-9]+)\}/msi', $format, $keys2) && isset($keys2[1])) {
+ $keys = $keys2[1];
+ $format = preg_split('/\{([0-9]+)\}/msi', $format);
+ $count2 = count($format);
+
+ for ($j = 0; $j < $count; $j++) {
+ $formatted = '';
+ for ($i = 0; $i <= $count2; $i++) {
+ if (isset($format[$i])) {
+ $formatted .= $format[$i];
+ }
+ if (isset($keys[$i]) && isset($data[$keys[$i]][$j])) {
+ $formatted .= $data[$keys[$i]][$j];
+ }
+ }
+ $out[] = $formatted;
+ }
+ } else {
+ $count2 = count($data);
+ for ($j = 0; $j < $count; $j++) {
+ $args = array();
+ for ($i = 0; $i < $count2; $i++) {
+ if (isset($data[$i][$j])) {
+ $args[] = $data[$i][$j];
+ }
+ }
+ $out[] = vsprintf($format, $args);
+ }
+ }
+ return $out;
+ }
+/**
+ * Gets a value from an array or object that maps a given path.
+ * The special {n}, as seen in the Model::generateList method, is taken care of here.
+ *
+ * @param array $data Array from where to extract
+ * @param mixed $path As an array, or as a dot-separated string.
+ * @return array Extracted data
+ * @access public
+ */
+ function extract($data, $path = null) {
+ if ($path === null && is_a($this, 'set')) {
+ $path = $data;
+ $data = $this->get();
+ }
+ if (is_object($data)) {
+ $data = get_object_vars($data);
+ }
+
+ if (!is_array($path)) {
+ if (strpos($path, '/') !== 0 && strpos($path, './') === false) {
+ $path = explode('.', $path);
+ } else {
+ }
+ }
+ $tmp = array();
+ if (!is_array($path) || empty($path)) {
+ return null;
+ }
+
+ foreach ($path as $i => $key) {
+ if (is_numeric($key) && intval($key) > 0 || $key == '0') {
+ if (isset($data[intval($key)])) {
+ $data = $data[intval($key)];
+ } else {
+ return null;
+ }
+ } elseif ($key == '{n}') {
+ foreach ($data as $j => $val) {
+ if (is_int($j)) {
+ $tmpPath = array_slice($path, $i + 1);
+ if (empty($tmpPath)) {
+ $tmp[] = $val;
+ } else {
+ $tmp[] = Set::extract($val, $tmpPath);
+ }
+ }
+ }
+ return $tmp;
+ } else {
+ if (isset($data[$key])) {
+ $data = $data[$key];
+ } else {
+ return null;
+ }
+ }
+ }
+ return $data;
+ }
+/**
+ * Inserts $data into an array as defined by $path.
+ *
+ * @param mixed $list Where to insert into
+ * @param mixed $path A dot-separated string.
+ * @param array $data Data to insert
+ * @return array
+ * @access public
+ */
+ function insert($list, $path, $data = null) {
+ if (empty($data) && is_a($this, 'Set')) {
+ $data = $path;
+ $path = $list;
+ $list =& $this->get();
+ }
+ if (!is_array($path)) {
+ $path = explode('.', $path);
+ }
+ $_list =& $list;
+
+ foreach ($path as $i => $key) {
+ if (is_numeric($key) && intval($key) > 0 || $key == '0') {
+ $key = intval($key);
+ }
+ if ($i == count($path) - 1) {
+ $_list[$key] = $data;
+ } else {
+ if (!isset($_list[$key])) {
+ $_list[$key] = array();
+ }
+ $_list =& $_list[$key];
+ }
+ }
+ return $list;
+ }
+/**
+ * Removes an element from a Set or array as defined by $path.
+ *
+ * @param mixed $list From where to remove
+ * @param mixed $path A dot-separated string.
+ * @return array Array with $path removed from its value
+ * @access public
+ */
+ function remove($list, $path = null) {
+ if (empty($path) && is_a($this, 'Set')) {
+ $path = $list;
+ $list =& $this->get();
+ }
+ if (!is_array($path)) {
+ $path = explode('.', $path);
+ }
+ $_list =& $list;
+
+ foreach ($path as $i => $key) {
+ if (is_numeric($key) && intval($key) > 0 || $key == '0') {
+ $key = intval($key);
+ }
+ if ($i == count($path) - 1) {
+ unset($_list[$key]);
+ } else {
+ if (!isset($_list[$key])) {
+ return $list;
+ }
+ $_list =& $_list[$key];
+ }
+ }
+
+ if (is_a($this, 'Set')) {
+ $this->value = $list;
+ return $this;
+ } else {
+ return $list;
+ }
+ }
+/**
+ * Checks if a particular path is set in an array
+ *
+ * @param mixed $data Data to check on
+ * @param mixed $path A dot-separated string.
+ * @return boolean true if path is found, false otherwise
+ * @access public
+ */
+ function check($data, $path = null) {
+ if (empty($path) && is_a($this, 'Set')) {
+ $path = $data;
+ $data = $this->get();
+ }
+ if (!is_array($path)) {
+ $path = explode('.', $path);
+ }
+
+ foreach ($path as $i => $key) {
+ if (is_numeric($key) && intval($key) > 0 || $key == '0') {
+ $key = intval($key);
+ }
+ if ($i == count($path) - 1) {
+ return isset($data[$key]);
+ } else {
+ if (!isset($data[$key])) {
+ return false;
+ }
+ $data =& $data[$key];
+ }
+ }
+ return true;
+ }
+/**
+ * Computes the difference between a Set and an array, two Sets, or two arrays
+ *
+ * @param mixed $val1 First value
+ * @param mixed $val2 Second value
+ * @return array Computed difference
+ * @access public
+ */
+ function diff($val1, $val2 = null) {
+ if ($val2 == null && (is_a($this, 'set') || is_a($this, 'Set'))) {
+ $val2 = $val1;
+ $val1 = $this->get();
+ }
+
+ if (is_object($val2) && (is_a($val2, 'set') || is_a($val2, 'Set'))) {
+ $val2 = $val2->get();
+ }
+ $out = array();
+
+ if (empty($val1)) {
+ return (array)$val2;
+ } elseif (empty($val2)) {
+ return (array)$val1;
+ }
+
+ foreach ($val1 as $key => $val) {
+ if (array_key_exists($key, $val2) && $val2[$key] != $val) {
+ $out[$key] = $val;
+ } elseif (!array_key_exists($key, $val2)) {
+ $out[$key] = $val;
+ }
+ unset($val2[$key]);
+ }
+
+ foreach ($val2 as $key => $val) {
+ if (!array_key_exists($key, $out)) {
+ $out[$key] = $val;
+ }
+ }
+ return $out;
+ }
+/**
+ * Determines if two Sets or arrays are equal
+ *
+ * @param array $val1 First value
+ * @param array $val2 Second value
+ * @return boolean true if they are equal, false otherwise
+ * @access public
+ */
+ function isEqual($val1, $val2 = null) {
+ if ($val2 == null && (is_a($this, 'set') || is_a($this, 'Set'))) {
+ $val2 = $val1;
+ $val1 = $this->get();
+ }
+
+ return ($val1 == $val2);
+ }
+/**
+ * Determines if one Set or array contains the exact keys and values of another.
+ *
+ * @param array $val1 First value
+ * @param array $val2 Second value
+ * @return boolean true if $val1 contains $val2, false otherwise
+ * @access public
+ */
+ function contains($val1, $val2 = null) {
+ if ($val2 == null && is_a($this, 'set')) {
+ $val2 = $val1;
+ $val1 = $this->get();
+ } elseif ($val2 != null && is_object($val2) && is_a($val2, 'set')) {
+ $val2 = $val2->get();
+ }
+
+ foreach ($val2 as $key => $val) {
+ if (is_numeric($key)) {
+ if (!in_array($val, $val1)) {
+ return false;
+ }
+ } else {
+ if (!isset($val1[$key]) || $val1[$key] != $val) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+/**
+ * Counts the dimensions of an array. If $all is set to false (which is the default) it will
+ * only consider the dimension of the first element in the array.
+ *
+ * @param array $array Array to count dimensions on
+ * @param boolean $all Set to true to count the dimension considering all elements in array
+ * @param integer $count Start the dimension count at this number
+ * @return integer The number of dimensions in $array
+ * @access public
+ */
+ function countDim($array = null, $all = false, $count = 0) {
+ if ($array === null) {
+ $array = $this->get();
+ } elseif (is_object($array) && is_a($array, 'set')) {
+ $array = $array->get();
+ }
+ if ($all) {
+ $depth = array($count);
+ if (is_array($array) && reset($array) !== false) {
+ foreach ($array as $value) {
+ $depth[] = Set::countDim($value, true, $count + 1);
+ }
+ }
+ $return = max($depth);
+ } else {
+ if (is_array(reset($array))) {
+ $return = Set::countDim(reset($array)) + 1;
+ } else {
+ $return = 1;
+ }
+ }
+ return $return;
+ }
+/**
+ * Normalizes a string or array list.
+ *
+ * @param mixed $list List to normalize
+ * @param boolean $assoc If true, $list will be converted to an associative array
+ * @param string $sep If $list is a string, it will be split into an array with $sep
+ * @param boolean $trim If true, separated strings will be trimmed
+ * @return array
+ * @access public
+ */
+ function normalize($list, $assoc = true, $sep = ',', $trim = true) {
+ if (is_string($list)) {
+ $list = explode($sep, $list);
+ if ($trim) {
+ $list = array_map('trim', $list);
+ }
+ if ($assoc) {
+ return Set::normalize($list);
+ }
+ } elseif (is_array($list)) {
+ $keys = array_keys($list);
+ $count = count($keys);
+ $numeric = true;
+
+ if (!$assoc) {
+ for ($i = 0; $i < $count; $i++) {
+ if (!is_int($keys[$i])) {
+ $numeric = false;
+ break;
+ }
+ }
+ }
+ if (!$numeric || $assoc) {
+ $newList = array();
+ for ($i = 0; $i < $count; $i++) {
+ if (is_int($keys[$i])) {
+ $newList[$list[$keys[$i]]] = null;
+ } else {
+ $newList[$keys[$i]] = $list[$keys[$i]];
+ }
+ }
+ $list = $newList;
+ }
+ }
+ return $list;
+ }
+/**
+ * Creates an associative array using a $path1 as the path to build its keys, and optionally
+ * $path2 as path to get the values. If $path2 is not specified, all values will be initialized
+ * to null (useful for Set::merge). You can optionally group the values by what is obtained when
+ * following the path specified in $groupPath.
+ *
+ * @param array $data Array from where to extract keys and values
+ * @param mixed $path1 As an array, or as a dot-separated string.
+ * @param mixed $path2 As an array, or as a dot-separated string.
+ * @param string $groupPath As an array, or as a dot-separated string.
+ * @return array Combined array
+ * @access public
+ */
+ function combine($data, $path1 = null, $path2 = null, $groupPath = null) {
+ if (is_a($this, 'set') && is_string($data) && is_string($path1) && is_string($path2)) {
+ $groupPath = $path2;
+ $path2 = $path1;
+ $path1 = $data;
+ $data = $this->get();
+
+ } elseif (is_a($this, 'set') && is_string($data) && empty($path2)) {
+ $path2 = $path1;
+ $path1 = $data;
+ $data = $this->get();
+ }
+
+ if (is_object($data)) {
+ $data = get_object_vars($data);
+ }
+
+ if (is_array($path1)) {
+ $format = array_shift($path1);
+ $keys = Set::format($data, $format, $path1);
+ } else {
+ $keys = Set::extract($data, $path1);
+ }
+
+ if (!empty($path2) && is_array($path2)) {
+ $format = array_shift($path2);
+ $vals = Set::format($data, $format, $path2);
+
+ } elseif (!empty($path2)) {
+ $vals = Set::extract($data, $path2);
+
+ } else {
+ $count = count($keys);
+ for ($i = 0; $i < $count; $i++) {
+ $vals[$i] = null;
+ }
+ }
+
+ if ($groupPath != null) {
+ $group = Set::extract($data, $groupPath);
+ if (!empty($group)) {
+ $c = count($keys);
+ for ($i = 0; $i < $c; $i++) {
+ if (!isset($group[$i])) {
+ $group[$i] = 0;
+ }
+ if (!isset($out[$group[$i]])) {
+ $out[$group[$i]] = array();
+ }
+ $out[$group[$i]][$keys[$i]] = $vals[$i];
+ }
+ return $out;
+ }
+ }
+
+ return array_combine($keys, $vals);
+ }
+/**
+ * Converts an object into an array
+ *
+ * @param object $object
+ * @return array
+ */
+ function reverse($object) {
+ if (is_a($object, 'xmlnode') || is_a($object, 'XMLNode')) {
+ if ($object->name != Inflector::underscore($this->name)) {
+ if (is_object($object->child(Inflector::underscore($this->name)))) {
+ $object = $object->child(Inflector::underscore($this->name));
+ $object = $object->attributes;
+ } else {
+ return null;
+ }
+ }
+ } else {
+ $out = array();
+ if (is_object($object)) {
+ $keys = get_object_vars($object);
+ if (isset($keys['_name_'])) {
+ $identity = $keys['_name_'];
+ unset($keys['_name_']);
+ }
+ $new = array();
+ foreach ($keys as $key => $value) {
+ if (is_array($value)) {
+ $new[$key] = (array)Set::reverse($value);
+ } else {
+ $new[$key] = Set::reverse($value);
+ }
+ }
+ if (isset($identity)) {
+ $out[$identity] = $new;
+ } else {
+ $out = $new;
+ }
+ } elseif (is_array($object)) {
+ foreach ($object as $key => $value) {
+ $out[$key] = Set::reverse($value);
+ }
+ } else {
+ $out = $object;
+ }
+ return $out;
+ }
+ return $object;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/validators.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/validators.php
new file mode 100644
index 0000000..cbd7c03
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/validators.php
@@ -0,0 +1,45 @@
+<?php
+/* SVN FILE: $Id: validators.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Tort Validators
+ *
+ * Used to validate data in Models.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Not empty.
+ */
+ define('VALID_NOT_EMPTY', '/.+/');
+/**
+ * Numbers [0-9] only.
+ */
+ define('VALID_NUMBER', '/^[-+]?\\b[0-9]*\\.?[0-9]+\\b$/');
+/**
+ * A valid email address.
+ */
+ define('VALID_EMAIL', '/\\A(?:^([a-z0-9][a-z0-9_\\-\\.\\+]*)@([a-z0-9][a-z0-9\\.\\-]{0,63}\\.(com|org|net|biz|info|name|net|pro|aero|coop|museum|[a-z]{2,4}))$)\\z/i');
+/**
+ * A valid year (1000-2999).
+ */
+ define('VALID_YEAR', '/^[12][0-9]{3}$/');
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helper.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helper.php
new file mode 100644
index 0000000..99ec582
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helper.php
@@ -0,0 +1,167 @@
+<?php
+/* SVN FILE: $Id: helper.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Backend for helpers.
+ *
+ * Internal methods for the Helpers.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Backend for helpers.
+ *
+ * Long description for class
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.view
+ */
+class Helper extends Object {
+/**
+ * Holds tag templates.
+ *
+ * @access public
+ * @var array
+ */
+ var $tags = array('link' => '<a href="%s" %s>%s</a>',
+ 'mailto' => '<a href="mailto:%s" %s>%s</a>',
+ 'form' => '<form %s>',
+ 'input' => '<input name="data[%s][%s]" %s/>',
+ 'textarea' => '<textarea name="data[%s][%s]" %s>%s</textarea>',
+ 'hidden' => '<input type="hidden" name="data[%s][%s]" %s/>',
+ 'textarea' => '<textarea name="data[%s][%s]" %s>%s</textarea>',
+ 'checkbox' => '<input type="checkbox" name="data[%s][%s]" %s/>',
+ 'radio' => '<input type="radio" name="data[%s][%s]" id="%s" %s />%s',
+ 'selectstart' => '<select name="data[%s][%s]" %s>',
+ 'selectmultiplestart' => '<select name="data[%s][%s][]" %s>',
+ 'selectempty' => '<option value="" %s>&nbsp;</option>',
+ 'selectoption' => '<option value="%s" %s>%s</option>',
+ 'selectend' => '</select>',
+ 'password' => '<input type="password" name="data[%s][%s]" %s/>',
+ 'file' => '<input type="file" name="data[%s][%s]" %s/>',
+ 'file_no_model' => '<input type="file" name="%s" %s/>',
+ 'submit' => '<input type="submit" %s/>',
+ 'image' => '<img src="%s" %s/>',
+ 'tableheader' => '<th%s>%s</th>',
+ 'tableheaderrow' => '<tr%s>%s</tr>',
+ 'tablecell' => '<td%s>%s</td>',
+ 'tablerow' => '<tr%s>%s</tr>',
+ 'block' => '<div%s>%s</div>',
+ 'blockstart' => '<div%s>',
+ 'blockend' => '</div>',
+ 'css' => '<link rel="%s" type="text/css" href="%s" %s/>',
+ 'style' => '<style type="text/css"%s>%s</style>',
+ 'charset' => '<meta http-equiv="Content-Type" content="text/html; charset=%s" />',
+ 'javascriptblock' => '<script type="text/javascript">%s</script>',
+ 'javascriptlink' => '<script type="text/javascript" src="%s"></script>');
+/**
+ * Parses custom config/tags.ini.php and merges with $this->tags.
+ *
+ * @return html tags used by helpers
+ */
+ function loadConfig() {
+
+ if (file_exists(APP . 'config' . DS . 'tags.ini.php')) {
+ $tags = $this->readConfigFile(APP . 'config' . DS . 'tags.ini.php');
+ $this->tags = am($this->tags, $tags);
+ }
+ return $this->tags;
+ }
+/**
+ * Decides whether to output or return a string.
+ *
+ * Based on AUTO_OUTPUT and $return's value, this method decides whether to
+ * output a string, or return it.
+ *
+ * @param string $str String to be output or returned.
+ * @param boolean $return Whether this method should return a value or output it.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ */
+ function output($str, $return = false) {
+ if (AUTO_OUTPUT && $return === false) {
+ echo $str;
+ } else {
+ return $str;
+ }
+ }
+/**
+ * Assigns values to tag templates.
+ *
+ * Finds a tag template by $keyName, and replaces $values's keys with
+ * $values's keys.
+ *
+ * @param string $keyName Name of the key in the tag array.
+ * @param array $values Values to be inserted into tag.
+ * @return string Tag with inserted values.
+ */
+ function assign($keyName, $values) {
+ return str_replace('%%' . array_keys($values) . '%%', array_values($values), $this->tags[$keyName]);
+ }
+/**
+ * Returns an array of settings in given INI file.
+ *
+ * @param string $fileName ini file to read
+ * @return array of lines from the $fileName
+ */
+ function readConfigFile($fileName) {
+ $fileLineArray = file($fileName);
+
+ foreach ($fileLineArray as $fileLine) {
+ $dataLine = trim($fileLine);
+ $firstChar = substr($dataLine, 0, 1);
+
+ if ($firstChar != ';' && $dataLine != '') {
+ if ($firstChar == '[' && substr($dataLine, -1, 1) == ']') {
+ // [section block] we might use this later do not know for sure
+ // this could be used to add a key with the section block name
+ // but it adds another array level
+ } else {
+ $delimiter = strpos($dataLine, '=');
+
+ if ($delimiter > 0) {
+ $key = strtolower(trim(substr($dataLine, 0, $delimiter)));
+ $value = trim(stripcslashes(substr($dataLine, $delimiter + 1)));
+
+ if (substr($value, 0, 1) == '"' && substr($value, -1) == '"') {
+ $value = substr($value, 1, -1);
+ }
+
+ $iniSetting[$key] = $value;
+
+ } else {
+ $iniSetting[strtolower(trim($dataLine))] = '';
+ }
+ }
+ } else {
+ }
+ }
+
+ return $iniSetting;
+ }
+/**
+ * After render callback. Overridden in subclasses.
+ *
+ * @return void
+ */
+ function afterRender() {
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/ajax.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/ajax.php
new file mode 100644
index 0000000..9e14931
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/ajax.php
@@ -0,0 +1,853 @@
+<?php
+/* SVN FILE: $Id: ajax.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Helper for AJAX operations.
+ *
+ * Helps doing AJAX using the Prototype library.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * AjaxHelper library.
+ *
+ * Helps doing AJAX using the Prototype library.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ */
+class AjaxHelper extends Helper {
+/**
+ * Included helpers.
+ *
+ * @var array
+ * @access public
+ */
+ var $helpers = array('Html', 'Javascript');
+/**
+ * Names of Javascript callback functions.
+ *
+ * @var array
+ * @access public
+ */
+ var $callbacks = array('uninitialized', 'loading', 'loaded', 'interactive', 'complete', 'success', 'failure');
+/**
+ * Names of AJAX options.
+ *
+ * @var array
+ * @access public
+ */
+ var $ajaxOptions = array('type', 'confirm', 'condition', 'before', 'after', 'fallback', 'update', 'loading', 'loaded', 'interactive', 'complete', 'with', 'url', 'method', 'position', 'form', 'parameters', 'evalScripts', 'asynchronous', 'onComplete', 'onUninitialized', 'onLoading', 'onLoaded', 'onInteractive', 'success', 'failure', 'onSuccess', 'onFailure', 'insertion', 'requestHeaders');
+/**
+ * Options for draggable.
+ *
+ * @var array
+ * @access public
+ */
+ var $dragOptions = array('handle', 'revert', 'constraint', 'change', 'ghosting');
+/**
+ * Options for droppable.
+ *
+ * @var array
+ * @access public
+ */
+ var $dropOptions = array('accept', 'containment', 'overlap', 'greedy', 'hoverclass', 'onHover', 'onDrop');
+/**
+ * Options for sortable.
+ *
+ * @var array
+ * @access public
+ */
+ var $sortOptions = array('tag', 'only', 'overlap', 'constraint', 'containment', 'handle', 'hoverclass', 'ghosting', 'dropOnEmpty', 'onUpdate', 'onChange');
+/**
+ * Options for slider.
+ *
+ * @var array
+ * @access public
+ */
+ var $sliderOptions = array('axis', 'increment', 'maximum', 'minimum', 'alignX', 'alignY', 'sliderValue', 'disabled', 'handleImage', 'handleDisabled', 'values', 'onSlide', 'onChange');
+/**
+ * Options for in-place editor.
+ *
+ * @var array
+ * @access public
+ */
+ var $editorOptions = array('okText', 'cancelText', 'savingText', 'formId', 'externalControl', 'rows', 'cols', 'size', 'highlightcolor', 'highlightendcolor', 'savingClassName', 'formClassName', 'loadTextURL', 'loadingText', 'callback', 'ajaxOptions', 'clickToEditText');
+/**
+ * Options for auto-complete editor.
+ *
+ * @var array
+ * @access public
+ */
+ var $autoCompleteOptions = array('paramName', 'tokens', 'frequency', 'minChars', 'indicator', 'updateElement', 'afterUpdateElement', 'onShow', 'onHide');
+/**
+ * Output buffer for Ajax update content
+ *
+ * @var array
+ * @access private
+ */
+ var $__ajaxBuffer = array();
+/**
+ * Returns link to remote action
+ *
+ * Returns a link to a remote action defined by <i>options[url]</i>
+ * (using the urlFor format) that's called in the background using
+ * XMLHttpRequest. The result of that request can then be inserted into a
+ * DOM object whose id can be specified with <i>options[update]</i>.
+ *
+ * Examples:
+ * <code>
+ * $ajax->link("Delete this post", "/posts/delete/{$post['Post']['id']}"
+ * array("update" => "posts", "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');"),
+ * "Are you sure you want to delte this post?");
+ * $ajax->link($html->img("refresh"), '/emails/refresh',
+ * array("update" => "posts", "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');"),
+ * null, false);
+ * </code>
+ *
+ * By default, these remote requests are processed asynchronous during
+ * which various callbacks can be triggered (for progress indicators and
+ * the likes).
+ *
+ * The callbacks that may be specified are:
+ *
+ * - <i>loading</i>:: Called when the remote document is being
+ * loaded with data by the browser.
+ * - <i>loaded</i>:: Called when the browser has finished loading
+ * the remote document.
+ * - <i>interactive</i>:: Called when the user can interact with the
+ * remote document, even though it has not
+ * finished loading.
+ * - <i>complete</i>:: Called when the request is complete.
+ *
+ * If you for some reason or another need synchronous processing (that'll
+ * block the browser while the request is happening), you can specify
+ * <i>$options['type'] = synchronous</i>.
+ *
+ * You can customize further browser side call logic by passing
+ * in Javascript code snippets via some optional parameters. In
+ * their order of use these are:
+ *
+ * - <i>confirm</i> :: Adds confirmation dialog.
+ * - <i>condition</i> :: Perform remote request conditionally
+ * by this expression. Use this to
+ * describe browser-side conditions when
+ * request should not be initiated.
+ * - <i>before</i> :: Called before request is initiated.
+ * - <i>after</i> :: Called immediately after request was
+ * initiated and before <i>loading</i>.
+ *
+ * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater
+ * @param string $title Title of link
+ * @param string $href href string "/products/view/12"
+ * @param array $options Options for JavaScript function
+ * @param string $confirm Confirmation message. Calls up a JavaScript confirm() message.
+ * @param boolean $escapeTitle Escaping the title string to HTML entities
+ * @return HTML code for link to remote action
+ * @access public
+ */
+ function link($title, $href = null, $options = array(), $confirm = null, $escapeTitle = true) {
+ if (!isset($href)) {
+ $href = $title;
+ }
+
+ if (!isset($options['url'])) {
+ $options['url'] = $href;
+ }
+
+ if (isset($confirm)) {
+ $options['confirm'] = $confirm;
+ unset($confirm);
+ }
+ $htmlOptions = $this->__getHtmlOptions($options);
+
+ if (empty($options['fallback']) || !isset($options['fallback'])) {
+ $options['fallback'] = $href;
+ }
+
+ if (!isset($htmlOptions['id'])) {
+ $htmlOptions['id'] = 'link' . intval(rand());
+ }
+
+ if (!isset($htmlOptions['onclick'])) {
+ $htmlOptions['onclick'] = '';
+ }
+ $htmlOptions['onclick'] .= ' event.returnValue = false; return false;';
+ $return = $this->Html->link($title, $href, $htmlOptions, null, $escapeTitle);
+ $script = $this->Javascript->event("'{$htmlOptions['id']}'", "click", $this->remoteFunction($options));
+
+ if (is_string($script)) {
+ $return .= $script;
+ }
+ return $return;
+ }
+/**
+ * Creates JavaScript function for remote AJAX call
+ *
+ * This function creates the javascript needed to make a remote call
+ * it is primarily used as a helper for link.
+ *
+ * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater
+ * @see link() for docs on options parameter.
+ * @param array $options options for javascript
+ * @return string html code for link to remote action
+ * @access public
+ */
+ function remoteFunction($options = null) {
+ if (isset($options['update'])) {
+ if (!is_array($options['update'])) {
+ $func = "new Ajax.Updater('{$options['update']}',";
+ } else {
+ $func = "new Ajax.Updater(document.createElement('div'),";
+ }
+ if (!isset($options['requestHeaders'])) {
+ $options['requestHeaders'] = array();
+ }
+ if (is_array($options['update'])) {
+ $options['update'] = join(' ', $options['update']);
+ }
+ $options['requestHeaders']['X-Update'] = $options['update'];
+ } else {
+ $func = "new Ajax.Request(";
+ }
+
+ $func .= "'" . $this->Html->url(isset($options['url']) ? $options['url'] : "") . "'";
+ $func .= ", " . $this->__optionsForAjax($options) . ")";
+
+ if (isset($options['before'])) {
+ $func = "{$options['before']}; $func";
+ }
+
+ if (isset($options['after'])) {
+ $func = "$func; {$options['after']};";
+ }
+
+ if (isset($options['condition'])) {
+ $func = "if ({$options['condition']}) { $func; }";
+ }
+
+ if (isset($options['confirm'])) {
+ $func = "if (confirm('" . $this->Javascript->escapeString($options['confirm'])
+ . "')) { $func; } else { event.returnValue = false; return false; }";
+ }
+ return $func;
+ }
+/**
+ * Periodically call remote url via AJAX.
+ *
+ * Periodically calls the specified url (<i>options['url']</i>) every <i>options['frequency']</i> seconds (default is 10).
+ * Usually used to update a specified div (<i>options['update']</i>) with the results of the remote call.
+ * The options for specifying the target with url and defining callbacks is the same as link.
+ *
+ * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater
+ * @param array $options Callback options
+ * @return string Javascript codeblock
+ * @access public
+ */
+ function remoteTimer($options = null) {
+ $frequency=(isset($options['frequency'])) ? $options['frequency'] : 10;
+ $code="new PeriodicalExecuter(function() {" . $this->remoteFunction($options) . "}, $frequency)";
+ return $this->Javascript->codeBlock($code);
+ }
+/**
+ * Returns form tag that will submit using Ajax.
+ *
+ * Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular
+ * reloading POST arrangement. Even though it's using Javascript to serialize the form elements, the form submission
+ * will work just like a regular submission as viewed by the receiving side (all elements available in params).
+ * The options for defining callbacks is the same as link().
+ *
+ * @param array $params Form target
+ * @param array $type How form data is posted: 'get' or 'post'
+ * @param array $options Callback/HTML options
+ * @return string JavaScript/HTML code
+ * @access public
+ */
+ function form($params = null, $type = 'post', $options = array()) {
+ if (is_array($params)) {
+ extract($params, EXTR_OVERWRITE);
+
+ if (!isset($action)) {
+ $action = null;
+ }
+
+ if (!isset($type)) {
+ $type = 'post';
+ }
+
+ if (!isset($options)) {
+ $options = array();
+ }
+ } else {
+ $action = $params;
+ }
+ $htmlOptions = $this->__getHtmlOptions($options);
+ $htmlOptions['action'] = $action;
+
+ if (!isset($htmlOptions['id'])) {
+ $htmlOptions['id'] = 'form' . intval(rand());
+ }
+ $htmlOptions['onsubmit']="event.returnValue = false; return false;";
+
+ if (!isset($options['with'])) {
+ $options['with'] = "Form.serialize('{$htmlOptions['id']}')";
+ }
+ $options['url']=$action;
+
+ return $this->Html->formTag($htmlOptions['action'], $type, $htmlOptions)
+ . $this->Javascript->event("'" . $htmlOptions['id']. "'", "submit", $this->remoteFunction($options));
+ }
+/**
+ * Returns a button input tag that will submit using Ajax
+ *
+ * Returns a button input tag that will submit form using XMLHttpRequest in the background instead of regular
+ * reloading POST arrangement. <i>options</i> argument is the same as in <i>form_remote_tag</i>
+ *
+ * @param string $title Input button title
+ * @param array $options Callback options
+ * @return string Ajaxed input button
+ * @access public
+ */
+ function submit($title = 'Submit', $options = array()) {
+ $htmlOptions =$this->__getHtmlOptions($options);
+ $htmlOptions['value']=$title;
+
+ if (!isset($options['with'])) {
+ $options['with'] = 'Form.serialize(Event.element(event).form)';
+ }
+
+ if (!isset($htmlOptions['id'])) {
+ $htmlOptions['id'] = 'submit' . intval(rand());
+ }
+ $htmlOptions['onclick']="event.returnValue = false; return false;";
+ return $this->Html->submit($title, $htmlOptions)
+ . $this->Javascript->event('"' . $htmlOptions['id'] . '"', 'click', $this->remoteFunction($options));
+ }
+/**
+ * Observe field and call ajax on change.
+ *
+ * Observes the field with the DOM ID specified by <i>field_id</i> and makes
+ * an Ajax when its contents have changed.
+ *
+ * Required +options+ are:
+ * - <i>frequency</i>:: The frequency (in seconds) at which changes to
+ * this field will be detected.
+ * - <i>url</i>:: @see urlFor() -style options for the action to call
+ * when the field has changed.
+ *
+ * Additional options are:
+ * - <i>update</i>:: Specifies the DOM ID of the element whose
+ * innerHTML should be updated with the
+ * XMLHttpRequest response text.
+ * - <i>with</i>:: A Javascript expression specifying the
+ * parameters for the XMLHttpRequest. This defaults
+ * to Form.Element.serialize('$field_id'), which can be
+ * accessed from params['form']['field_id'].
+ *
+ * @see link().
+ * @param string $field_id DOM ID of field to observe
+ * @param array $options ajax options
+ * @return string ajax script
+ * @access public
+ */
+ function observeField($field_id, $options = array()) {
+ if (!isset($options['with'])) {
+ $options['with'] = "Form.Element.serialize('$field_id')";
+ }
+ return $this->Javascript->codeBlock($this->_buildObserver('Form.Element.Observer', $field_id, $options));
+ }
+/**
+ * Observe entire form and call ajax on change.
+ *
+ * Like @see observeField(), but operates on an entire form identified by the
+ * DOM ID <b>form_id</b>. <b>options</b> are the same as <b>observe_field</b>, except
+ * the default value of the <i>with</i> option evaluates to the
+ * serialized (request string) value of the form.
+ *
+ * @param string $field_id DOM ID of field to observe
+ * @param array $options ajax options
+ * @return string ajax script
+ * @access public
+ */
+ function observeForm($field_id, $options = array()) {
+ if (!isset($options['with'])) {
+ $options['with'] = 'Form.serialize("' . $field_id . '")';
+ }
+ return $this->Javascript->codeBlock($this->_buildObserver('Form.Observer', $field_id, $options));
+ }
+/**
+ * Create a text field with Autocomplete.
+ *
+ * Creates an autocomplete field with the given ID and options.
+ *
+ * options['with'] defaults to "Form.Element.serialize('$field_id')",
+ * but can be any valid javascript expression defining the
+ *
+ * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter
+ * @param string $field_id DOM ID of field to observe
+ * @param string $url URL for the autocomplete action
+ * @param array $options Ajax options
+ * @return string Ajax script
+ * @access public
+ */
+ function autoComplete($field, $url = "", $options = array()) {
+ $var = '';
+ if (isset($options['var'])) {
+ $var = 'var ' . $options['var'] . ' = ';
+ unset($options['var']);
+ }
+
+ if (!isset($options['id'])) {
+ $options['id'] = Inflector::camelize(r("/", "_", $field));
+ }
+ $divOptions = array('id' => $options['id'] . "_autoComplete", 'class' => isset($options['class']) ? $options['class'] : 'auto_complete');
+
+ if (isset($options['div_id'])) {
+ $divOptions['id'] = $options['div_id'];
+ unset($options['div_id']);
+ }
+ $htmlOptions = $this->__getHtmlOptions($options);
+ $htmlOptions['autocomplete'] = "off";
+
+ foreach ($this->autoCompleteOptions as $opt) {
+ unset($htmlOptions[$opt]);
+ }
+
+ if (isset($options['tokens'])) {
+ if (is_array($options['tokens'])) {
+ $options['tokens'] = $this->Javascript->object($options['tokens']);
+ } else {
+ $options['tokens'] = '"' . $options['tokens'] . '"';
+ }
+ }
+ $options = $this->_optionsToString($options, array('paramName', 'indicator'));
+ $options = $this->_buildOptions($options, $this->autoCompleteOptions);
+ return $this->Html->input($field, $htmlOptions) . "\n" .
+ $this->Html->tag('div', $divOptions, true) . "</div>\n" .
+ $this->Javascript->codeBlock("{$var}new Ajax.Autocompleter('" . $htmlOptions['id']
+ . "', '" . $divOptions['id'] . "', '" . $this->Html->url($url) . "', " .
+ $options . ");");
+ }
+/**
+ * Setup a Draggable Element.
+ * For a reference on the options for this function, check out
+ *
+ * @link http://wiki.script.aculo.us/scriptaculous/show/Draggable
+ * @param sting $id the DOM id to enable
+ * @param array $options a set of options
+ * @return string Javascript::codeBlock();
+ * @access public
+ */
+ function drag($id, $options = array()) {
+ return $this->Javascript->codeBlock("new Draggable('$id', " . $this->_optionsForDraggable($options) . ");");
+ }
+/**
+ * Creates an Ajax-updateable DIV element
+ *
+ * @param string $id options for javascript
+ * @param array $options a set of options
+ * @return string HTML code
+ * @access public
+ */
+ function div($id, $options = array()) {
+ if (env('HTTP_X_UPDATE') != null) {
+ $divs = explode(' ', env('HTTP_X_UPDATE'));
+ if (in_array($id, $divs)) {
+ @ob_end_clean();
+ ob_start();
+ return '';
+ }
+ }
+ $attr = $this->Html->_parseAttributes(am($options, array('id' => $id)));
+ return $this->output(sprintf($this->tags['blockstart'], $attr));
+ }
+/**
+ * Closes an Ajax-updateable DIV element
+ *
+ * @param string $id The DOM ID of the element
+ * @return string HTML code
+ * @access public
+ */
+ function divEnd($id) {
+ if (env('HTTP_X_UPDATE') != null) {
+ $divs = explode(' ', env('HTTP_X_UPDATE'));
+ if (in_array($id, $divs)) {
+ $this->__ajaxBuffer[$id] = ob_get_contents();
+ ob_end_clean();
+ return '';
+ }
+ }
+ return $this->output($this->tags['blockend']);
+ }
+/**
+ * Protectd helper method to return an array of options for draggable.
+ *
+ * @param array $options
+ * @return array
+ * @access protected
+ */
+ function _optionsForDraggable($options) {
+ $options = $this->_optionsToString($options, array('handle', 'constraint'));
+ return $this->_buildOptions($options, $this->dragOptions);
+ }
+/**
+ * Setup a droppable element
+ * For a reference on the options for this function, check out
+ *
+ * @link http://wiki.script.aculo.us/scriptaculous/show/Droppables.add
+ * @param string $id
+ * @param array $options
+ * @return array
+ * @access public
+ */
+ function drop($id, $options = array()) {
+ $options = $this->_optionsForDroppable($options);
+ return $this->Javascript->codeBlock("Droppables.add('$id', $options);");
+ }
+/**
+ * Protected helper method to return an array of options for droppable.
+ *
+ * @param string $options
+ * @return string String of Javascript array definition
+ * @access protected
+ */
+ function _optionsForDroppable($options) {
+ $options = $this->_optionsToString($options, array('accept', 'overlap', 'hoverclass'));
+ return $this->_buildOptions($options, $this->dropOptions);
+ }
+/**
+ * Setup a remote droppable element.
+ *
+ * @link http://wiki.script.aculo.us/scriptaculous/show/Droppables.add
+ * @see link() and remoteFunction()
+ * @param string $id DOM id of droppable
+ * @param array $options ame as drop()
+ * @param array $ajaxOptions same as remoteFunction()
+ * @return string Javascript::codeBlock()
+ * @access public
+ */
+ function dropRemote($id, $options = array(), $ajaxOptions = array()) {
+ $options['onDrop'] = "function(element) {" . $this->remoteFunction($ajaxOptions) . "}";
+ $options = $this->_optionsForDroppable($options);
+ return $this->Javascript->codeBlock("Droppables.add('$id', $options);");
+ }
+/**
+ * Makes a slider control.
+ *
+ * @link http://wiki.script.aculo.us/scriptaculous/show/Slider
+ * @param string $id DOM ID of slider handle
+ * @param string $track_id DOM ID of slider track
+ * @param array $options Array of options to control the slider
+ * @return string Javascript::codeBlock()
+ * @access public
+ */
+ function slider($id, $track_id, $options = array()) {
+ $options = $this->_optionsToString($options, array('axis', 'handleImage', 'handleDisabled'));
+
+ if (isset($options['change'])) {
+ $options['onChange'] = $options['change'];
+ unset($options['change']);
+ }
+
+ if (isset($options['slide'])) {
+ $options['onSlide'] = $options['slide'];
+ unset($options['slide']);
+ }
+
+ $options = $this->_buildOptions($options, $this->sliderOptions);
+ return $this->Javascript->codeBlock("var $id = new Control.Slider('$id', '$track_id', $options);");
+ }
+/**
+ * Makes an Ajax In Place editor control.
+ *
+ * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
+ * @param string $id DOM ID of input element
+ * @param string $url Postback URL of saved data
+ * @param array $options Array of options to control the editor, including ajaxOptions (see link).
+ * @return string Javascript::codeBlock()
+ * @access public
+ */
+ function editor($id, $url, $options = array()) {
+ $url = $this->Html->url($url);
+ $options['ajaxOptions'] = $this->__optionsForAjax($options);
+
+ foreach ($this->ajaxOptions as $opt) {
+ if (isset($options[$opt])) {
+ unset($options[$opt]);
+ }
+ }
+
+ if (isset($options['callback'])) {
+ $options['callback'] = 'function(form, value) {' . $options['callback'] . '}';
+ }
+
+ $options = $this->_optionsToString($options, array('okText', 'cancelText', 'savingText', 'formId', 'externalControl', 'highlightcolor', 'highlightendcolor', 'savingClassName', 'formClassName', 'loadTextURL', 'loadingText', 'clickToEditText'));
+ $options = $this->_buildOptions($options, $this->editorOptions);
+ return $this->Javascript->codeBlock("new Ajax.InPlaceEditor('{$id}', '{$url}', {$options});");
+ }
+/**
+ * Makes a list or group of floated objects sortable.
+ *
+ * @link http://wiki.script.aculo.us/scriptaculous/show/Sortable.create
+ * @param string $id DOM ID of parent
+ * @param array $options Array of options to control sort
+ * @return string Javascript::codeBlock()
+ * @access public
+ */
+ function sortable($id, $options = array()) {
+ if (!empty($options['url'])) {
+ $options['with'] = "Sortable.serialize('$id')";
+ $options['onUpdate'] = 'function(sortable) {' . $this->remoteFunction($options) . '}';
+ }
+
+ $options = $this->__optionsForSortable($options);
+ return $this->Javascript->codeBlock("Sortable.create('$id', $options);");
+ }
+/**
+ * Private method; generates sortables code from array options
+ *
+ * @param array $options
+ * @return string String of Javascript array definition
+ * @access private
+ */
+ function __optionsForSortable($options) {
+ $options = $this->_optionsToString($options, array('handle', 'tag', 'constraint', 'ghosting', 'only', 'hoverclass'));
+ return $this->_buildOptions($options, $this->sortOptions);
+ }
+/**
+ * Private helper function for Ajax.
+ *
+ * @param array $options
+ * @return string String of Javascript array definition
+ * @access private
+ */
+ function __optionsForAjax($options = array()) {
+
+ if (isset($options['indicator'])) {
+ if (isset($options['loading'])) {
+ $options['loading'] .= "Element.show('{$options['indicator']}');";
+ } else {
+ $options['loading'] = "Element.show('{$options['indicator']}');";
+ }
+ if (isset($options['complete'])) {
+ $options['complete'] .= "Element.hide('{$options['indicator']}');";
+ } else {
+ $options['complete'] = "Element.hide('{$options['indicator']}');";
+ }
+ unset($options['indicator']);
+ }
+
+ $jsOptions = am(
+ array('asynchronous' => 'true', 'evalScripts' => 'true'),
+ $this->_buildCallbacks($options)
+ );
+ $options = $this->_optionsToString($options, array('method'));
+
+ foreach ($options as $key => $value) {
+ switch($key) {
+ case 'type':
+ $jsOptions['asynchronous'] = ife(($value == 'synchronous'), 'false', 'true');
+ break;
+ case 'evalScripts':
+ $jsOptions['evalScripts'] = ife($value, 'true', 'false');
+ break;
+ case 'position':
+ $jsOptions['insertion'] = "Insertion." . Inflector::camelize($options['position']);
+ break;
+ case 'with':
+ $jsOptions['parameters'] = $options['with'];
+ break;
+ case 'form':
+ $jsOptions['parameters'] = 'Form.serialize(this)';
+ break;
+ case 'requestHeaders':
+ $keys = array();
+ foreach ($value as $key => $val) {
+ $keys[] = "'" . $key . "'";
+ $keys[] = "'" . $val . "'";
+ }
+ $jsOptions['requestHeaders'] = '[' . join(', ', $keys) . ']';
+ break;
+ }
+ }
+ return $this->_buildOptions($jsOptions, $this->ajaxOptions);
+ }
+/**
+ * Private Method to return a string of html options
+ * option data as a JavaScript options hash.
+ *
+ * @param array $options Options in the shape of keys and values
+ * @param array $extra Array of legal keys in this options context
+ * @return array Array of html options
+ * @access private
+ */
+ function __getHtmlOptions($options, $extra = array()) {
+ foreach ($this->ajaxOptions as $key) {
+ if (isset($options[$key])) {
+ unset($options[$key]);
+ }
+ }
+
+ foreach ($extra as $key) {
+ if (isset($options[$key])) {
+ unset($options[$key]);
+ }
+ }
+ return $options;
+ }
+/**
+ * Protected Method to return a string of JavaScript with the given
+ * option data as a JavaScript options hash.
+ *
+ * @param array $options Options in the shape of keys and values
+ * @param array $acceptable Array of legal keys in this options context
+ * @return string String of Javascript array definition
+ * @access protected
+ */
+ function _buildOptions($options, $acceptable) {
+ if (is_array($options)) {
+ $out = array();
+
+ foreach ($options as $k => $v) {
+ if (in_array($k, $acceptable)) {
+ $out[] = "$k:$v";
+ }
+ }
+
+ $out = join(', ', $out);
+ $out = '{' . $out . '}';
+ return $out;
+ } else {
+ return false;
+ }
+ }
+/**
+ * Protected Method to return JavaScript text for an observer...
+ *
+ * @param string $klass Name of JavaScript class
+ * @param string $name
+ * @param array $options Ajax options
+ * @return string Formatted JavaScript
+ * @access protected
+ */
+ function _buildObserver($klass, $name, $options = null) {
+ if (!isset($options['with']) && isset($options['update'])) {
+ $options['with'] = 'value';
+ }
+
+ $callback = $this->remoteFunction($options);
+ $javascript = "new $klass('$name', ";
+ $javascript .= (isset($options['frequency']) ? $options['frequency'] : 2) . ", function(element, value) {";
+ $javascript .= "$callback})";
+ return $javascript;
+ }
+/**
+ * Protected Method to return JavaScript text for all callbacks...
+ *
+ * @param array $options
+ * @return array
+ * @access protected
+ */
+ function _buildCallbacks($options) {
+ $callbacks = array();
+
+ foreach ($this->callbacks as $callback) {
+ if (isset($options[$callback])) {
+ $name = 'on' . ucfirst($callback);
+ $code = $options[$callback];
+ $callbacks[$name] = "function(request) {" . $code . "}";
+ }
+ }
+ return $callbacks;
+ }
+/**
+ * Protected Method to return a string of JavaScript with a string representation
+ * of given options array.
+ *
+ * @param array $options Ajax options array
+ * @param array $stringOpts Options as strings in an array
+ * @access private
+ * @return array
+ * @access protected
+ */
+ function _optionsToString($options, $stringOpts = array()) {
+ foreach ($stringOpts as $option) {
+ if (isset($options[$option]) && !$options[$option][0] != "'") {
+ if ($options[$option] === true || $options[$option] === 'true') {
+ $options[$option] = 'true';
+ } elseif ($options[$option] === false || $options[$option] === 'false') {
+ $options[$option] = 'false';
+ } else {
+ $options[$option] = "'{$options[$option]}'";
+ }
+ }
+ }
+ return $options;
+ }
+/**
+ * afterRender callback
+ *
+ * @return array
+ * @access public
+ */
+ function afterRender() {
+ if (env('HTTP_X_UPDATE') != null && count($this->__ajaxBuffer) > 0) {
+ $data = array();
+ $divs = explode(' ', env('HTTP_X_UPDATE'));
+
+ foreach ($this->__ajaxBuffer as $key => $val) {
+ if (in_array($key, $divs)) {
+ $data[] = $key . ':"' . rawurlencode($val) . '"';
+ }
+ }
+
+ $out = 'var __ajaxUpdater__ = {' . join(', ', $data) . '};' . "\n";
+ $out .= 'for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string" && $(n)) Element.update($(n), unescape(decodeURIComponent(__ajaxUpdater__[n]))); }';
+
+ @ob_end_clean();
+ e($this->Javascript->codeBlock($out));
+ exit();
+ }
+ }
+/**
+ * Replaced by AjaxHelper::link()
+ *
+ * @deprecated will not be avialable after 1.1.x.x
+ */
+ function linkToRemote($title, $options = array(), $html_options = array()) {
+ trigger_error('Deprecated function: use AjaxHelper::link', E_USER_WARNING);
+ $href = '#';
+
+ if (!empty($options['fallback']) && isset($options['fallback'])) {
+ $href = $options['fallback'];
+ }
+
+ if (isset($html_options['id'])) {
+ return $this->Html->link($title, $href, $html_options) .
+ $this->Javascript->event("$('{$html_options['id']}')", "click", $this->remoteFunction($options));
+ } else {
+ $html_options['onclick'] = $this->remoteFunction($options) . "; event.returnValue = false; return false;";
+ return $this->Html->link($title, $href, $html_options);
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/cache.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/cache.php
new file mode 100644
index 0000000..99d609f
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/cache.php
@@ -0,0 +1,272 @@
+<?php
+/* SVN FILE: $Id: cache.php 7691 2008-10-02 04:59:12Z nate $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ * @since CakePHP(tm) v 1.0.0.2277
+ * @version $Revision: 7691 $
+ * @modifiedby $LastChangedBy: nate $
+ * @lastmodified $Date: 2008-10-02 00:59:12 -0400 (Thu, 02 Oct 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ */
+class CacheHelper extends Helper{
+/**
+ * Array of strings replaced in cached views.
+ * The strings are found between <cake:nocache><cake:nocache> in views
+ *
+ * @var array
+ * @access private
+ */
+ var $__replace = array();
+/**
+ * Array of string that are replace with there var replace above.
+ * The strings are any content inside <cake:nocache><cake:nocache> and includes the tags in views
+ *
+ * @var array
+ * @access private
+ */
+ var $__match = array();
+/**
+ * holds the View object passed in final call to CacheHelper::cache()
+ *
+ * @var object
+ * @access public
+ */
+ var $view;
+/**
+ * Main method used to cache a view
+ *
+ * @param string $file File to cache
+ * @param string $out output to cache
+ * @param boolean $cache
+ * @return view ouput
+ */
+ function cache($file, $out, $cache = false) {
+ if (is_array($this->cacheAction)) {
+ $check = str_replace('/', '_', $this->here);
+ $replace = str_replace('/', '_', $this->base);
+ $match = str_replace($this->base, '', $this->here);
+ $match = str_replace('//', '/', $match);
+ $match = str_replace('/' . $this->controllerName . '/', '', $match);
+ $check = str_replace($replace, '', $check);
+ $check = str_replace('_' . $this->controllerName . '_', '', $check);
+ $check = convertSlash($check);
+ $check = preg_replace('/^_+/', '', $check);
+ $keys = str_replace('/', '_', array_keys($this->cacheAction));
+ $found = array_keys($this->cacheAction);
+ $index = null;
+ $count = 0;
+
+ foreach ($keys as $key => $value) {
+ if (strpos($check, $value) === 0) {
+ $index = $found[$count];
+ break;
+ }
+ $count++;
+ }
+
+ if (isset($index)) {
+ $pos1 = strrpos($match, '/');
+ $char = strlen($match) - 1;
+
+ if ($pos1 == $char) {
+ $match = substr($match, 0, $char);
+ }
+
+ $key = $match;
+ } elseif ($this->action == 'index') {
+ $index = 'index';
+ }
+ if (isset($this->cacheAction[$index])) {
+ $cacheTime = $this->cacheAction[$index];
+ } else {
+ $cacheTime = 0;
+ }
+ } else {
+ $cacheTime = $this->cacheAction;
+ }
+
+ if ($cacheTime != '' && $cacheTime > 0) {
+ $this->__parseFile($file, $out);
+
+ if ($cache === true) {
+ $cached = $this->__parseOutput($out);
+ $this->__writeFile($cached, $cacheTime);
+ }
+ }
+ return $out;
+ }
+/**
+ * Parse file searching for no cache tags
+ *
+ * @param string $file
+ * @param boolean $cache
+ * @access private
+ */
+ function __parseFile($file, $cache) {
+ if (is_file($file)) {
+ $file = file_get_contents($file);
+ } elseif ($file = fileExistsInPath($file)) {
+ $file = file_get_contents($file);
+ }
+
+ preg_match_all('/(<cake:nocache>(?<=<cake:nocache>)[\\s\\S]*?(?=<\/cake:nocache>)<\/cake:nocache>)/i', $cache, $oresult, PREG_PATTERN_ORDER);
+ preg_match_all('/(?<=<cake:nocache>)([\\s\\S]*?)(?=<\/cake:nocache>)/i', $file, $result, PREG_PATTERN_ORDER);
+
+ if (!empty($this->__replace)) {
+ foreach ($oresult['0'] as $k => $element) {
+ if (array_search($element, $this->__match) !== false) {
+ array_splice($oresult[0], $k, 1);
+ }
+ }
+ }
+
+ if (!empty($result['0'])) {
+ $count = 0;
+
+ foreach ($result['0'] as $block) {
+ if (isset($oresult['0'][$count])) {
+ $this->__replace[] = $block;
+ $this->__match[] = $oresult['0'][$count];
+ }
+ $count++;
+ }
+ }
+ }
+/**
+ * Parse the output and replace cache tags
+ *
+ * @param sting $cache
+ * @return string with all replacements made to <cake:nocache><cake:nocache>
+ * @access private
+ */
+ function __parseOutput($cache) {
+ $count = 0;
+ if (!empty($this->__match)) {
+
+ foreach ($this->__match as $found) {
+ $original = $cache;
+ $length = strlen($found);
+ $position = 0;
+
+ for ($i = 1; $i <= 1; $i++) {
+ $position = strpos($cache, $found, $position);
+
+ if ($position !== false) {
+ $cache = substr($original, 0, $position);
+ $cache .= $this->__replace[$count];
+ $cache .= substr($original, $position + $length);
+ } else {
+ break;
+ }
+ }
+ $count++;
+ }
+ return $cache;
+ }
+ return $cache;
+ }
+/**
+ * Write a cached version of the file
+ *
+ * @param string $content
+ * @param sting $timestamp
+ * @return cached view
+ * @access private
+ */
+ function __writeFile($content, $timestamp) {
+ $now = time();
+
+ if (is_numeric($timestamp)) {
+ $cacheTime = $now + $timestamp;
+ } else {
+ $cacheTime = strtotime($timestamp, $now);
+ }
+
+ $cache = convertSlash($this->here);
+ if (empty($cache)) {
+ return;
+ }
+
+ $cache = $cache . '.php';
+ $file = '<!--cachetime:' . $cacheTime . '--><?php';
+ if (empty($this->plugin)) {
+ $file .= '
+ loadController(\'' . $this->view->name. '\');
+ loadModels();
+ ';
+ } else {
+ $file .= '
+ if (!class_exists(\'AppController\')) {
+ if (file_exists(\'' . APP . 'app_controller.php\')) {
+ require(\''. APP . 'app_controller.php\');
+ } else {
+ require(\''.CAKE . 'app_controller.php\');
+ }
+ }
+ loadPluginController(\''.$this->plugin.'\',\''.$this->view->name.'\');
+ loadPluginModels(\''.$this->plugin.'\');
+ ';
+ }
+ $file .= '$this->controller = new ' . $this->view->name . 'Controller();
+ $this->controller->plugin = \''.$this->plugin.'\';
+ $this->controller->_initComponents();
+ $this->helpers = unserialize(\'' . serialize($this->view->helpers) . '\');
+ $this->base = \'' . $this->view->base . '\';
+ $this->layout = \'' . $this->view->layout. '\';
+ $this->webroot = \'' . $this->view->webroot . '\';
+ $this->here = \'' . $this->view->here . '\';
+ $this->params = unserialize(stripslashes(\'' . addslashes(serialize($this->view->params)) . '\'));
+ $this->action = unserialize(\'' . serialize($this->view->action) . '\');
+ $this->data = unserialize(stripslashes(\'' . addslashes(serialize($this->view->data)) . '\'));
+ $this->themeWeb = \'' . $this->view->themeWeb . '\';
+ $this->plugin = \'' . $this->view->plugin . '\';
+ $loadedHelpers = array();
+ $loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
+ foreach (array_keys($loadedHelpers) as $helper)
+ {
+ $replace = strtolower(substr($helper, 0, 1));
+ $camelBackedHelper = preg_replace(\'/\\w/\', $replace, $helper, 1);
+ ${$camelBackedHelper} =& $loadedHelpers[$helper];
+
+ if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers))
+ {
+ foreach (${$camelBackedHelper}->helpers as $subHelper)
+ {
+ ${$camelBackedHelper}->{$subHelper} =& $loadedHelpers[$subHelper];
+ }
+ }
+ $this->loaded[$camelBackedHelper] = (${$camelBackedHelper});
+ }
+ ?>';
+ $content = preg_replace("/(<\\?xml)/", "<?php echo '$1';?>",$content);
+ $file .= $content;
+ return cache('views' . DS . $cache, $file, $timestamp);
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/form.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/form.php
new file mode 100644
index 0000000..d2d58a4
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/form.php
@@ -0,0 +1,491 @@
+<?php
+/* SVN FILE: $Id: form.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Automatic generation of HTML FORMs from given data.
+ *
+ * Used for scaffolding.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Tag template for a div with a class attribute.
+ */
+ define('TAG_DIV', '<div class="%s">%s</div>');
+/**
+ * Tag template for a paragraph with a class attribute.
+ */
+ define('TAG_P_CLASS', '<p class="%s">%s</p>');
+/**
+ * Tag template for a label with a for attribute.
+ */
+ define('TAG_LABEL', '<label for="%s">%s</label>');
+/**
+ * Tag template for a fieldset with a legend tag inside.
+ */
+ define('TAG_FIELDSET', '<fieldset><legend>%s</legend>%s</label>');
+/**
+ * Form helper library.
+ *
+ * Automatic generation of HTML FORMs from given data.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ */
+class FormHelper extends Helper{
+/**
+ * Included helpers.
+ *
+ * @var array
+ * @access public
+ */
+ var $helpers = array('Html');
+/**
+ * Returns a formatted error message for given FORM field, NULL if no errors.
+ *
+ * @param string $field This should be "Modelname/fieldname"
+ * @return bool If there are errors this method returns true, else false.
+ * @access public
+ */
+ function isFieldError($field) {
+ $error=1;
+ $this->Html->setFormTag($field);
+
+ if ($error == $this->Html->tagIsInvalid($this->Html->model, $this->Html->field)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+/**
+ * Returns a formatted LABEL element for HTML FORMs.
+ *
+ * @param string $tagName This should be "Modelname/fieldname"
+ * @param string $text Text that will appear in the label field.
+ * @return string The formatted LABEL element
+ * @access public
+ */
+ function labelTag($tagName, $text) {
+ return sprintf(TAG_LABEL, Inflector::camelize(str_replace('/', '_', $tagName)), $text);
+ }
+/**
+ * Returns a formatted DIV tag for HTML FORMs.
+ *
+ * @param string $class CSS class name of the div element.
+ * @param string $text String content that will appear inside the div element.
+ * @return string The formatted DIV element
+ * @access public
+ */
+ function divTag($class, $text) {
+ return sprintf(TAG_DIV, $class, $text);
+ }
+/**
+ * Returns a formatted P tag with class for HTML FORMs.
+ *
+ * @param string $class CSS class name of the p element.
+ * @param string $text Text that will appear inside the p element.
+ * @return string The formatted P element
+ * @access public
+ */
+ function pTag($class, $text) {
+ return sprintf(TAG_P_CLASS, $class, $text);
+ }
+/**
+ * Returns a formatted INPUT tag for HTML FORMs.
+ *
+ * @param string $tagName This should be "Modelname/fieldname"
+ * @param string $prompt Text that will appear in the label field.
+ * @param bool $required True if this field is a required field.
+ * @param string $errorMsg Text that will appear if an error has occurred.
+ * @param int $size Size attribute for INPUT element
+ * @param array $htmlOptions HTML options array.
+ * @return string The formatted INPUT element, with a label and wrapped in a div.
+ * @access public
+ */
+ function generateInputDiv($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null) {
+ $htmlAttributes = $htmlOptions;
+ $htmlAttributes['size'] = $size;
+ $str = $this->Html->input($tagName, $htmlAttributes);
+ $strLabel = $this->labelTag($tagName, $prompt);
+ $divClass = "optional";
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+
+ if ($this->isFieldError($tagName)) {
+ $strError = $this->pTag('error', $errorMsg);
+ $divClass = sprintf("%s error", $divClass);
+ }
+ $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str);
+ return $this->divTag($divClass, $divTagInside);
+ }
+/**
+ * Returns a formatted CHECKBOX tag inside a DIV for HTML FORMs.
+ *
+ * @param string $tagName This should be "Modelname/fieldname"
+ * @param string $prompt Text that will appear in the label field.
+ * @param bool $required True if this field is a required field.
+ * @param string $errorMsg Text that will appear if an error has occurred.
+ * @param array $htmlOptions HTML options array.
+ * @return string The formatted checkbox div
+ * @access public
+ */
+ function generateCheckboxDiv($tagName, $prompt, $required = false, $errorMsg = null, $htmlOptions = null) {
+ $htmlOptions['class'] = "inputCheckbox";
+ $str = $this->Html->checkbox($tagName, null, $htmlOptions);
+ $strLabel = $this->labelTag($tagName, $prompt);
+ $divClass = "optional";
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+
+ if ($this->isFieldError($tagName)) {
+ $strError = $this->pTag('error', $errorMsg);
+ $divClass = sprintf("%s error", $divClass);
+ }
+ $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str);
+ return $this->divTag($divClass, $divTagInside);
+ }
+/**
+ * Returns a formatted date option element for HTML FORMs.
+ *
+ * @param string $tagName This should be "Modelname/fieldname"
+ * @param string $prompt Text that will appear in the label field.
+ * @param bool $required True if this field is a required field.
+ * @param string $errorMsg Text that will appear if an error has occurred.
+ * @param int $size Not used.
+ * @param array $htmlOptions HTML options array
+ * @return string Date option wrapped in a div.
+ * @todo Remove the $size parameter from this method.
+ * @access public
+ */
+ function generateDate($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) {
+ $str = $this->Html->dateTimeOptionTag($tagName, 'MDY', 'NONE', $selected, $htmlOptions);
+ $strLabel = $this->labelTag($tagName, $prompt);
+ $divClass = "optional";
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+
+ if ($this->isFieldError($tagName)) {
+ $strError = $this->pTag('error', $errorMsg);
+ $divClass = sprintf("%s error", $divClass);
+ }
+ $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str);
+ $requiredDiv = $this->divTag($divClass, $divTagInside);
+ return $this->divTag("date", $requiredDiv);
+ }
+/**
+ * Returns a formatted date option element for HTML FORMs.
+ *
+ * @param string $tagName This should be "Modelname/fieldname"
+ * @param string $prompt Text that will appear in the label field.
+ * @param bool $required True if this field is a required field.
+ * @param string $errorMsg Text that will appear if an error has occurred.
+ * @param int $size Not used.
+ * @param array $htmlOptions HTML options array
+ * @return string Date option wrapped in a div.
+ * @todo Remove the $size parameter from this method.
+ * @access public
+ */
+ function generateTime($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) {
+ $str = $this->Html->dateTimeOptionTag($tagName, 'NONE', '24', $selected, $htmlOptions);
+ $strLabel = $this->labelTag($tagName, $prompt);
+ $divClass = "optional";
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+
+ if ($this->isFieldError($tagName)) {
+ $strError = $this->pTag('error', $errorMsg);
+ $divClass = sprintf("%s error", $divClass);
+ }
+ $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str);
+ $requiredDiv = $this->divTag($divClass, $divTagInside);
+ return $this->divTag("time", $requiredDiv);
+ }
+/**
+ * Returns a formatted year option element for HTML FORMs.
+ *
+ * @param string $tagName This should be "Modelname/fieldname"
+ * @param string $prompt Text that will appear in the label field.
+ * @param bool $required True if this field is a required field.
+ * @param string $errorMsg Text that will appear if an error has occurred.
+ * @param int $size Not used.
+ * @param array $htmlOptions HTML options array
+ * @return string Date option wrapped in a div.
+ * @todo Remove the $size parameter from this method.
+ * @access public
+ */
+ function generateYear($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) {
+ $str = $this->Html->dateTimeOptionTag($tagName, 'Y', 'NONE', $selected, $htmlOptions);
+ $strLabel = $this->labelTag($tagName, $prompt);
+ $divClass = "optional";
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+
+ if ($this->isFieldError($tagName)) {
+ $strError = $this->pTag('error', $errorMsg);
+ $divClass = sprintf("%s error", $divClass);
+ }
+ $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str);
+ $requiredDiv = $this->divTag($divClass, $divTagInside);
+ return $this->divTag("year", $requiredDiv);
+ }
+/**
+ * Returns a formatted datetime option element for HTML FORMs.
+ *
+ * @param string $tagName This should be "Modelname/fieldname"
+ * @param string $prompt Text that will appear in the label field.
+ * @param bool $required True if this field is required.
+ * @param string $errorMsg Text that will appear if an error has occurred.
+ * @param int $size Not used.
+ * @param array $htmlOptions HTML options array
+ * @param array $selected Selected index in the dateTimeOption tag.
+ * @return string The formatted datetime option element wrapped in a div.
+ * @todo Remove the $size parameter from this method.
+ * @access public
+ */
+ function generateDateTime($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) {
+ $str = $this->Html->dateTimeOptionTag($tagName, 'MDY', '12', $selected, $htmlOptions);
+ $strLabel = $this->labelTag($tagName, $prompt);
+ $divClass = "optional";
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+
+ if ($this->isFieldError($tagName)) {
+ $strError = $this->pTag('error', $errorMsg);
+ $divClass = sprintf("%s error", $divClass);
+ }
+ $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str);
+ $requiredDiv = $this->divTag($divClass, $divTagInside);
+ return $this->divTag("date", $requiredDiv);
+ }
+/**
+ * Returns a formatted TEXTAREA inside a DIV for use with HTML forms.
+ *
+ * @param string $tagName This should be "Modelname/fieldname"
+ * @param string $prompt Text that will appear in the label field.
+ * @param boolean $required True if this field is required.
+ * @param string $errorMsg ext that will appear if an error has occurred.
+ * @param integer $cols Number of columns.
+ * @param integer $rows Number of rows.
+ * @param array $htmlOptions HTML options array.
+ * @return string The formatted TEXTAREA element, wrapped in a div.
+ * @access public
+ */
+ function generateAreaDiv($tagName, $prompt, $required = false, $errorMsg = null, $cols = 60, $rows = 10, $htmlOptions = null) {
+ $htmlAttributes = $htmlOptions;
+ $htmlAttributes['cols'] = $cols;
+ $htmlAttributes['rows'] = $rows;
+ $str = $this->Html->textarea($tagName, $htmlAttributes);
+ $strLabel = $this->labelTag($tagName, $prompt);
+ $divClass = "optional";
+
+ if ($required) {
+ $divClass="required";
+ }
+ $strError = "";
+
+ if ($this->isFieldError($tagName)) {
+ $strError = $this->pTag('error', $errorMsg);
+ $divClass = sprintf("%s error", $divClass);
+ }
+ $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str);
+ return $this->divTag($divClass, $divTagInside);
+ }
+/**
+ * Returns a formatted SELECT tag for HTML FORMs.
+ *
+ * @param string $tagName This should be "Modelname/fieldname"
+ * @param string $prompt Text that will appear in the label field
+ * @param array $options Options to be contained in SELECT element
+ * @param string $selected Currently selected item
+ * @param array $selectAttr Array of HTML attributes for the SELECT element
+ * @param array $optionAttr Array of HTML attributes for the OPTION elements
+ * @param bool $required True if this field is required
+ * @param string $errorMsg Text that will appear if an error has occurred
+ * @return string The formatted INPUT element, wrapped in a div
+ * @access public
+ */
+ function generateSelectDiv($tagName, $prompt, $options, $selected = null, $selectAttr = null, $optionAttr = null, $required = false, $errorMsg = null) {
+ $str = $this->Html->selectTag($tagName, $options, $selected, $selectAttr, $optionAttr);
+ $strLabel = $this->labelTag($tagName, $prompt);
+ $divClass = "optional";
+
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+
+ if ($this->isFieldError($tagName)) {
+ $strError=$this->pTag('error', $errorMsg);
+ $divClass=sprintf("%s error", $divClass);
+ }
+ $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str);
+ return $this->divTag($divClass, $divTagInside);
+ }
+/**
+ * Returns a formatted submit widget for HTML FORMs.
+ *
+ * @param string $displayText Text that will appear on the widget
+ * @param array $htmlOptions HTML options array
+ * @return string The formatted submit widget
+ * @access public
+ */
+ function generateSubmitDiv($displayText, $htmlOptions = null) {
+ return $this->divTag('submit', $this->Html->submit($displayText, $htmlOptions));
+ }
+/**
+ * Generates a form to go onto a HtmlHelper object.
+ *
+ * @param array $fields An array of form field definitions
+ * @param boolean $readOnly True if the form should be rendered as READONLY
+ * @return string The completed form specified by the $fields parameter
+ * @access public
+ */
+ function generateFields($fields, $readOnly = false) {
+ $strFormFields = '';
+
+ foreach ($fields as $field) {
+ if (isset($field['type'])) {
+
+ if (!isset($field['required'])) {
+ $field['required'] = false;
+ }
+
+ if (!isset($field['errorMsg'])) {
+ $field['errorMsg'] = null;
+ }
+
+ if (!isset($field['htmlOptions'])) {
+ $field['htmlOptions'] = array();
+ }
+
+ if ($readOnly) {
+ $field['htmlOptions']['READONLY'] = "readonly";
+ }
+
+ switch($field['type']) {
+ case "input":
+ if (!isset($field['size'])) {
+ $field['size'] = 40;
+ }
+ $strFormFields = $strFormFields . $this->generateInputDiv($field['tagName'], $field['prompt'],
+ $field['required'], $field['errorMsg'], $field['size'], $field['htmlOptions']);
+ break;
+ case "checkbox":
+ $strFormFields = $strFormFields . $this->generateCheckboxDiv($field['tagName'], $field['prompt'],
+ $field['required'], $field['errorMsg'], $field['htmlOptions']);
+ break;
+ case "select":
+ case "selectMultiple":
+ if ("selectMultiple" == $field['type']) {
+ $field['selectAttr']['multiple'] = 'multiple';
+ $field['selectAttr']['class'] = 'selectMultiple';
+ }
+
+ if (!isset($field['selected'])) {
+ $field['selected'] = null;
+ }
+
+ if (!isset($field['selectAttr'])) {
+ $field['selectAttr'] = null;
+ }
+
+ if (!isset($field['optionsAttr'])) {
+ $field['optionsAttr'] = null;
+ }
+
+ if ($readOnly) {
+ $field['selectAttr']['DISABLED'] = true;
+ }
+
+ if (!isset($field['options'])) {
+ $field['options'] = null;
+ }
+ $strFormFields = $strFormFields . $this->generateSelectDiv($field['tagName'], $field['prompt'], $field['options'],
+ $field['selected'], $field['selectAttr'], $field['optionsAttr'], $field['required'], $field['errorMsg']);
+ break;
+ case "area":
+ if (!isset($field['rows'])) {
+ $field['rows'] = 10;
+ }
+
+ if (!isset($field['cols'])) {
+ $field['cols'] = 60;
+ }
+ $strFormFields = $strFormFields . $this->generateAreaDiv($field['tagName'], $field['prompt'],
+ $field['required'], $field['errorMsg'], $field['cols'], $field['rows'], $field['htmlOptions']);
+ break;
+ case "fieldset":
+ $strFieldsetFields = $this->generateFields($field['fields']);
+ $strFieldSet = sprintf(' <fieldset><legend>%s</legend><div class="notes"><h4>%s</h4><p class="last">%s</p></div>%s</fieldset>',
+ $field['legend'], $field['noteHeading'], $field['note'], $strFieldsetFields);
+ $strFormFields = $strFormFields . $strFieldSet;
+ break;
+ case "hidden":
+ if (!isset($field['value'])) {
+ $field['value'] = null;
+ }
+ $strFormFields = $strFormFields . $this->Html->hidden($field['tagName'], $field['value']);
+ break;
+ case "date":
+ if (!isset($field['selected'])) {
+ $field['selected'] = null;
+ }
+ $strFormFields = $strFormFields . $this->generateDate($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']);
+ break;
+ case "datetime":
+ if (!isset($field['selected'])) {
+ $field['selected'] = null;
+ }
+ $strFormFields = $strFormFields . $this->generateDateTime($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']);
+ break;
+ case "time":
+ if (!isset($field['selected'])) {
+ $field['selected'] = null;
+ }
+ $strFormFields = $strFormFields . $this->generateTime($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']);
+ break;
+ case "year":
+ if (!isset($field['selected'])) {
+ $field['selected'] = null;
+ }
+ $strFormFields = $strFormFields . $this->generateYear($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ return $strFormFields;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/html.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/html.php
new file mode 100644
index 0000000..9b86c91
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/html.php
@@ -0,0 +1,1257 @@
+<?php
+/* SVN FILE: $Id: html.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Html Helper class file.
+ *
+ * Simplifies the construction of HTML elements.
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ * @since CakePHP(tm) v 0.9.1
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Html Helper class for easy use of HTML widgets.
+ *
+ * HtmlHelper encloses all methods needed while working with HTML pages.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ */
+class HtmlHelper extends Helper {
+/**
+ * Base URL
+ *
+ * @var string
+ * @access public
+ */
+ var $base = null;
+/**
+ * URL to current action.
+ *
+ * @var string
+ * @access public
+ */
+ var $here = null;
+/**
+ * Parameter array.
+ *
+ * @var array
+ * @access public
+ */
+ var $params = array();
+/**
+ * Current action.
+ *
+ * @var string
+ * @access public
+ */
+ var $action = null;
+/**
+ * Controller::data;
+ *
+ * @var array
+ * @access public
+ */
+ var $data = null;
+/**
+ * Name of model this helper is attached to.
+ *
+ * @var string
+ * @access public
+ */
+ var $model = null;
+/**
+ *
+ * @var string
+ * @access public
+ */
+ var $field = null;
+/**
+ * Breadcrumbs.
+ *
+ * @var array
+ * @access protected
+ */
+ var $_crumbs = array();
+/**
+ * Adds a link to the breadcrumbs array.
+ *
+ * @param string $name Text for link
+ * @param string $link URL for link
+ * @return void
+ * @access public
+ */
+ function addCrumb($name, $link) {
+ $this->_crumbs[] = array($name, $link);
+ }
+/**
+ * Returns a charset META-tag.
+ *
+ * @param string $charset
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function charset($charset = null, $return = false) {
+ if (is_null($charset)) {
+ $charset = 'utf-8';
+ }
+ return $this->output(sprintf($this->tags['charset'], $charset), $return);
+ }
+/**
+ * Finds URL for specified action.
+ *
+ * Returns an URL pointing to a combination of controller and action. Param
+ * $url can be:
+ * + Empty - the method will find adress to actuall controller/action.
+ * + '/' - the method will find base URL of application.
+ * + A combination of controller/action - the method will find url for it.
+ *
+ * @param string $url Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4"
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function url($url = null, $return = false) {
+ if (isset($this->plugin)) {
+ $base = strip_plugin($this->base, $this->plugin);
+ } else {
+ $base = $this->base;
+ }
+
+ if (empty($url)) {
+ return $this->here;
+ } elseif ($url{0} == '/') {
+ $output = $base . $url;
+ } else {
+ $output = $base . '/' . Inflector::underscore($this->params['controller']) . '/' . $url;
+ }
+
+ return $this->output($output, $return);
+ }
+/**
+ * Creates an HTML link.
+ *
+ * If $url starts with "http://" this is treated as an external link. Else,
+ * it is treated as a path to controller/action and parsed with the
+ * HtmlHelper::url() method.
+ *
+ * If the $url is empty, $title is used instead.
+ *
+ * @param string $title The content of the A tag.
+ * @param string $url Cake-relative URL, or external URL (starts with http://)
+ * @param array $htmlAttributes Array of HTML attributes.
+ * @param string $confirmMessage Confirmation message.
+ * @param boolean $escapeTitle Whether or not the text in the $title variable should be HTML escaped.
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true, $return = false) {
+ if ($escapeTitle === true) {
+ $title = htmlspecialchars($title, ENT_QUOTES);
+ } elseif (is_string($escapeTitle)) {
+ $title = htmlentities($title, ENT_QUOTES);
+ }
+ $url = $url ? $url : $title;
+
+ if ($confirmMessage) {
+ $confirmMessage = str_replace("'", "\'", $confirmMessage);
+ $confirmMessage = str_replace('"', '\"', $confirmMessage);
+ $htmlAttributes['onclick']="return confirm('{$confirmMessage}');";
+ }
+
+ if (((strpos($url, '://')) || (strpos($url, 'javascript:') === 0) || (strpos($url, 'mailto:') === 0) || substr($url,0,1) == '#')) {
+ $output = sprintf($this->tags['link'], $url, $this->_parseAttributes($htmlAttributes), $title);
+ } else {
+ $output = sprintf($this->tags['link'], $this->url($url, true), $this->_parseAttributes($htmlAttributes), $title);
+ }
+ return $this->output($output, $return);
+ }
+/**
+ * Creates a submit widget.
+ *
+ * @param string $caption Text on submit button
+ * @param array $htmlAttributes Array of HTML attributes.
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function submit($caption = 'Submit', $htmlAttributes = array(), $return = false) {
+ $htmlAttributes['value'] = $caption;
+ return $this->output(sprintf($this->tags['submit'], $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return);
+ }
+/**
+ * Creates a password input widget.
+ *
+ * @param string $fieldName Name of a field, like this "Modelname/fieldname"
+ * @param array $htmlAttributes Array of HTML attributes.
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function password($fieldName, $htmlAttributes = array(), $return = false) {
+ $this->setFormTag($fieldName);
+ if (!isset($htmlAttributes['value'])) {
+ $htmlAttributes['value'] = $this->tagValue($fieldName);
+ }
+ if (!isset($htmlAttributes['id'])) {
+ $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field);
+ }
+
+ if ($this->tagIsInvalid($this->model, $this->field)) {
+ if (isset($htmlAttributes['class']) && trim($htmlAttributes['class']) != "") {
+ $htmlAttributes['class'] .= ' form_error';
+ } else {
+ $htmlAttributes['class'] = 'form_error';
+ }
+ }
+ return $this->output(sprintf($this->tags['password'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return);
+ }
+/**
+ * Creates a textarea widget.
+ *
+ * @param string $fieldName Name of a field, like this "Modelname/fieldname"
+ * @param array $htmlAttributes Array of HTML attributes.
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function textarea($fieldName, $htmlAttributes = array(), $return = false) {
+ $this->setFormTag($fieldName);
+ $value = $this->tagValue($fieldName);
+ if (!empty($htmlAttributes['value'])) {
+ $value = $htmlAttributes['value'];
+ unset($htmlAttributes['value']);
+ }
+ if (!isset($htmlAttributes['id'])) {
+ $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field);
+ }
+
+ if ($this->tagIsInvalid($this->model, $this->field)) {
+ if (isset($htmlAttributes['class']) && trim($htmlAttributes['class']) != "") {
+ $htmlAttributes['class'] .= ' form_error';
+ } else {
+ $htmlAttributes['class'] = 'form_error';
+ }
+ }
+ return $this->output(sprintf($this->tags['textarea'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, ' '), $value), $return);
+ }
+/**
+ * Creates a checkbox widget.
+ *
+ * @param string $fieldName Name of a field, like this "Modelname/fieldname"
+ * @deprecated string $title
+ * @param array $htmlAttributes Array of HTML attributes.
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function checkbox($fieldName, $title = null, $htmlAttributes = array(), $return = false) {
+ $value = $this->tagValue($fieldName);
+ $notCheckedValue = 0;
+
+ if (!isset($htmlAttributes['id'])) {
+ $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field);
+ }
+
+ if (isset($htmlAttributes['checked'])) {
+ if ($htmlAttributes['checked'] == 'checked' || intval($htmlAttributes['checked']) === 1 || $htmlAttributes['checked'] === true) {
+ $htmlAttributes['checked'] = 'checked';
+ } else {
+ $htmlAttributes['checked'] = null;
+ $notCheckedValue = -1;
+ }
+ } else {
+ if (isset($htmlAttributes['value']) || (!class_exists($this->model) && !loadModel($this->model))) {
+ $htmlAttributes['checked'] = ($htmlAttributes['value'] == $value) ? 'checked' : null;
+
+ if ($htmlAttributes['value'] == '0') {
+ $notCheckedValue = -1;
+ }
+ } else {
+ $model = new $this->model;
+ $db =& ConnectionManager::getDataSource($model->useDbConfig);
+ $value = $db->boolean($value);
+ $htmlAttributes['checked'] = $value ? 'checked' : null;
+ $htmlAttributes['value'] = 1;
+ }
+ }
+
+ $output = $this->hidden($fieldName, array('value' => $notCheckedValue, 'id' => $htmlAttributes['id'] . '_'), true);
+ $output .= sprintf($this->tags['checkbox'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, '', ' '));
+ return $this->output($output, $return);
+ }
+/**
+ * Creates a link element for CSS stylesheets.
+ *
+ * @param string $path Path to CSS file
+ * @param string $rel Rel attribute. Defaults to "stylesheet".
+ * @param array $htmlAttributes Array of HTML attributes.
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function css($path, $rel = 'stylesheet', $htmlAttributes = array(), $return = false) {
+ $url = "{$this->webroot}" . (COMPRESS_CSS ? 'c' : '') . $this->themeWeb . CSS_URL . $path . ".css";
+
+ if ($rel == 'import') {
+ return $this->output(sprintf($this->tags['style'], $this->parseHtmlOptions($htmlAttributes, null, '', ' '), '@import url(' . $url . ');'), $return);
+ } else {
+ return $this->output(sprintf($this->tags['css'], $rel, $url, $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return);
+ }
+ }
+/**
+ * Creates file input widget.
+ *
+ * @param string $fieldName Name of a field, like this "Modelname/fieldname"
+ * @param array $htmlAttributes Array of HTML attributes.
+ * @param boolean $return Wheter this method should return a valueor output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function file($fieldName, $htmlAttributes = array(), $return = false) {
+ if (strpos($fieldName, '/')) {
+ $this->setFormTag($fieldName);
+ if (!isset($htmlAttributes['id'])) {
+ $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field);
+ }
+ return $this->output(sprintf($this->tags['file'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return);
+ }
+ return $this->output(sprintf($this->tags['file_no_model'], $fieldName, $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return);
+ }
+/**
+ * Returns the breadcrumb trail as a sequence of &raquo;-separated links.
+ *
+ * @param string $separator Text to separate crumbs.
+ * @param string $startText This will be the first crumb, if false it defaults to first crumb in array
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. If $this->_crumbs is empty, return null.
+ * @access public
+ */
+ function getCrumbs($separator = '&raquo;', $startText = false, $return = false) {
+ if (count($this->_crumbs)) {
+ $out = array();
+ if ($startText) {
+ $out[] = $this->link($startText, '/');
+ }
+
+ foreach ($this->_crumbs as $crumb) {
+ $out[] = $this->link($crumb[0], $crumb[1]);
+ }
+ return $this->output(join($separator, $out), $return);
+ } else {
+ return null;
+ }
+ }
+/**
+ * Creates a hidden input field.
+ *
+ * @param string $fieldName Name of a field, like this "Modelname/fieldname"
+ * @param array $htmlAttributes Array of HTML attributes.
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function hidden($fieldName, $htmlAttributes = array(), $return = false) {
+ $this->setFormTag($fieldName);
+ if (!isset($htmlAttributes['value'])) {
+ $htmlAttributes['value'] = $this->tagValue($fieldName);
+ }
+ if (!isset($htmlAttributes['id'])) {
+ $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field);
+ }
+ return $this->output(sprintf($this->tags['hidden'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return);
+ }
+/**
+ * Creates a formatted IMG element.
+ *
+ * @param string $path Path to the image file, relative to the webroot/img/ directory.
+ * @param array $htmlAttributes Array of HTML attributes.
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function image($path, $htmlAttributes = array(), $return = false) {
+ if (strpos($path, '://')) {
+ $url = $path;
+ } else {
+ $url = $this->webroot . $this->themeWeb . IMAGES_URL . $path;
+ }
+ return $this->output(sprintf($this->tags['image'], $url, $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return);
+ }
+/**
+ * Creates a text input widget.
+ *
+ * @param string $fieldNamem Name of a field, like this "Modelname/fieldname"
+ * @param array $htmlAttributes Array of HTML attributes.
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function input($fieldName, $htmlAttributes = array(), $return = false) {
+ $this->setFormTag($fieldName);
+ if (!isset($htmlAttributes['value'])) {
+ $htmlAttributes['value'] = $this->tagValue($fieldName);
+ }
+
+ if (!isset($htmlAttributes['type'])) {
+ $htmlAttributes['type'] = 'text';
+ }
+
+ if (!isset($htmlAttributes['id'])) {
+ $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field);
+ }
+
+ if ($this->tagIsInvalid($this->model, $this->field)) {
+ if (isset($htmlAttributes['class']) && trim($htmlAttributes['class']) != "") {
+ $htmlAttributes['class'] .= ' form_error';
+ } else {
+ $htmlAttributes['class'] = 'form_error';
+ }
+ }
+ return $this->output(sprintf($this->tags['input'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return);
+ }
+ /**
+ * Returns a formatted SELECT element.
+ *
+ * @param string $fieldName Name attribute of the SELECT
+ * @param array $optionElements Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the SELECT element
+ * @param mixed $selected Selected option
+ * @param array $selectAttr Array of HTML options for the opening SELECT element
+ * @param array $optionAttr Array of HTML options for the enclosed OPTION elements
+ * @param boolean $show_empty If true, the empty select option is shown
+ * @param boolean $return Whether this method should return a value
+ * @return string Formatted SELECT element
+ * @access public
+ */
+ function selectTag($fieldName, $optionElements, $selected = null, $selectAttr = array(), $optionAttr = null, $showEmpty = true, $return = false) {
+ $this->setFormTag($fieldName);
+ if ($this->tagIsInvalid($this->model, $this->field)) {
+ if (isset($selectAttr['class']) && trim($selectAttr['class']) != "") {
+ $selectAttr['class'] .= ' form_error';
+ } else {
+ $selectAttr['class'] = 'form_error';
+ }
+ }
+ if (!isset($selectAttr['id'])) {
+ $selectAttr['id'] = $this->model . Inflector::camelize($this->field);
+ }
+
+ if (!is_array($optionElements)) {
+ return null;
+ }
+
+ if (!isset($selected)) {
+ $selected = $this->tagValue($fieldName);
+ }
+
+ if (isset($selectAttr) && array_key_exists("multiple", $selectAttr)) {
+ $select[] = sprintf($this->tags['selectmultiplestart'], $this->model, $this->field, $this->parseHtmlOptions($selectAttr));
+ } else {
+ $select[] = sprintf($this->tags['selectstart'], $this->model, $this->field, $this->parseHtmlOptions($selectAttr));
+ }
+
+ if ($showEmpty == true) {
+ $select[] = sprintf($this->tags['selectempty'], $this->parseHtmlOptions($optionAttr));
+ }
+
+ foreach ($optionElements as $name => $title) {
+ $optionsHere = $optionAttr;
+
+ if (($selected != null) && ($selected == $name)) {
+ $optionsHere['selected'] = 'selected';
+ } elseif (is_array($selected) && in_array($name, $selected)) {
+ $optionsHere['selected'] = 'selected';
+ }
+
+ $select[] = sprintf($this->tags['selectoption'], $name, $this->parseHtmlOptions($optionsHere), h($title));
+ }
+
+ $select[] = sprintf($this->tags['selectend']);
+ return $this->output(implode("\n", $select), $return);
+ }
+/**
+ * Creates a set of radio widgets.
+ *
+ * @param string $fieldName Name of a field, like this "Modelname/fieldname"
+ * @param array $options Radio button options array
+ * @param array $inbetween String that separates the radio buttons.
+ * @param array $htmlAttributes Array of HTML attributes.
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return.
+ * @access public
+ */
+ function radio($fieldName, $options, $inbetween = null, $htmlAttributes = array(), $return = false) {
+
+ $this->setFormTag($fieldName);
+ $value = isset($htmlAttributes['value']) ? $htmlAttributes['value'] : $this->tagValue($fieldName);
+ $out = array();
+
+ foreach ($options as $optValue => $optTitle) {
+ $optionsHere = array('value' => $optValue);
+ if ($value !== false && $optValue == $value) {
+ $optionsHere['checked'] = 'checked';
+ }
+ $parsedOptions = $this->parseHtmlOptions(array_merge($htmlAttributes, $optionsHere), null, '', ' ');
+ $individualTagName = "{$this->field}_{$optValue}";
+ $out[] = sprintf($this->tags['radio'], $this->model, $this->field, $individualTagName, $parsedOptions, $optTitle);
+ }
+
+ $out = join($inbetween, $out);
+ return $this->output($out ? $out : null, $return);
+ }
+/**
+ * Returns a SELECT element for days.
+ *
+ * @param string $tagName Prefix name for the SELECT element
+ * @deprecated string $value
+ * @param string $selected Option which is selected.
+ * @param array $optionAttr Attribute array for the option elements.
+ * @param boolean $showEmpty Show/hide the empty select option
+ * @return mixed
+ * @access public
+ */
+ function dayOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
+ if (empty($selected) && $this->tagValue($tagName)) {
+ $selected = date('d', strtotime($this->tagValue($tagName)));
+ }
+ $dayValue = empty($selected) ? ($showEmpty == true ? NULL : date('d')) : $selected;
+ $days = array('01' => '1', '02' => '2', '03' => '3', '04' => '4', '05' => '5', '06' => '6', '07' => '7', '08' => '8', '09' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23', '24' => '24', '25' => '25', '26' => '26', '27' => '27', '28' => '28', '29' => '29', '30' => '30', '31' => '31');
+ $option = $this->selectTag($tagName . "_day", $days, $dayValue, $selectAttr, $optionAttr, $showEmpty);
+ return $option;
+ }
+/**
+ * Returns a SELECT element for years
+ *
+ * @param string $tagName Prefix name for the SELECT element
+ * @deprecated string $value
+ * @param integer $minYear First year in sequence
+ * @param integer $maxYear Last year in sequence
+ * @param string $selected Option which is selected.
+ * @param array $optionAttr Attribute array for the option elements.
+ * @param boolean $showEmpty Show/hide the empty select option
+ * @return mixed
+ * @access public
+ */
+ function yearOptionTag($tagName, $value = null, $minYear = null, $maxYear = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
+ if (empty($selected) && ($this->tagValue($tagName))) {
+ $selected = date('Y', strtotime($this->tagValue($tagName)));
+ }
+
+ $yearValue = empty($selected) ? ($showEmpty ? NULL : date('Y')) : $selected;
+ $currentYear = date('Y');
+ $maxYear = is_null($maxYear) ? $currentYear + 11 : $maxYear + 1;
+ $minYear = is_null($minYear) ? $currentYear - 60 : $minYear;
+
+ if ($minYear > $maxYear) {
+ $tmpYear = $minYear;
+ $minYear = $maxYear;
+ $maxYear = $tmpYear;
+ }
+
+ $minYear = $currentYear < $minYear ? $currentYear : $minYear;
+ $maxYear = $currentYear > $maxYear ? $currentYear : $maxYear;
+
+ for ($yearCounter = $minYear; $yearCounter < $maxYear; $yearCounter++) {
+ $years[$yearCounter] = $yearCounter;
+ }
+
+ return $this->selectTag($tagName . "_year", $years, $yearValue, $selectAttr, $optionAttr, $showEmpty);
+ }
+/**
+ * Returns a SELECT element for months.
+ *
+ * @param string $tagName Prefix name for the SELECT element
+ * @deprecated string $value
+ * @param string $selected Option which is selected.
+ * @param array $optionAttr Attribute array for the option elements.
+ * @param boolean $showEmpty Show/hide the empty select option
+ * @return mixed
+ * @access public
+ */
+ function monthOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
+ if (empty($selected) && ($this->tagValue($tagName))) {
+ $selected = date('m', strtotime($this->tagValue($tagName)));
+ }
+ $monthValue = empty($selected) ? ($showEmpty ? NULL : date('m')) : $selected;
+ $months = array('01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December');
+
+ return $this->selectTag($tagName . "_month", $months, $monthValue, $selectAttr, $optionAttr, $showEmpty);
+ }
+/**
+ * Returns a SELECT element for hours.
+ *
+ * @param string $tagName Prefix name for the SELECT element
+ * @deprecated string $value
+ * @param boolean $format24Hours True for 24 hours format
+ * @param string $selected Option which is selected.
+ * @param array $optionAttr Attribute array for the option elements.
+ * @return mixed
+ * @access public
+ */
+ function hourOptionTag($tagName, $value = null, $format24Hours = false, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
+ if (empty($selected) && ($this->tagValue($tagName))) {
+ if ($format24Hours) {
+ $selected = date('H', strtotime($this->tagValue($tagName)));
+ } else {
+ $selected = date('g', strtotime($this->tagValue($tagName)));
+ }
+ }
+ if ($format24Hours) {
+ $hourValue = empty($selected) ? ($showEmpty ? NULL : date('H')) : $selected;
+ } else {
+ $hourValue = empty($selected) ? ($showEmpty ? NULL : date('g')) : $selected;
+ if (isset($selected) && intval($hourValue) == 0 && !$showEmpty) {
+ $hourValue = 12;
+ }
+ }
+
+ if ($format24Hours) {
+ $hours = array('00' => '00', '01' => '01', '02' => '02', '03' => '03', '04' => '04', '05' => '05', '06' => '06', '07' => '07', '08' => '08', '09' => '09', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23');
+ } else {
+ $hours = array('01' => '1', '02' => '2', '03' => '3', '04' => '4', '05' => '5', '06' => '6', '07' => '7', '08' => '8', '09' => '9', '10' => '10', '11' => '11', '12' => '12');
+ }
+
+ $option = $this->selectTag($tagName . "_hour", $hours, $hourValue, $selectAttr, $optionAttr, $showEmpty);
+ return $option;
+ }
+/**
+ * Returns a SELECT element for minutes.
+ *
+ * @param string $tagName Prefix name for the SELECT element
+ * @deprecated string $value
+ * @param string $selected Option which is selected.
+ * @param array $optionAttr Attribute array for the option elements.
+ * @return mixed
+ * @access public
+ */
+ function minuteOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
+ if (empty($selected) && ($this->tagValue($tagName))) {
+ $selected = date('i', strtotime($this->tagValue($tagName)));
+ }
+ $minValue = empty($selected) ? ($showEmpty ? NULL : date('i')) : $selected;
+
+ for ($minCount = 0; $minCount < 60; $minCount++) {
+ $mins[sprintf('%02d', $minCount)] = sprintf('%02d', $minCount);
+ }
+ $option = $this->selectTag($tagName . "_min", $mins, $minValue, $selectAttr, $optionAttr, $showEmpty);
+ return $option;
+ }
+
+/**
+ * Returns a SELECT element for AM or PM.
+ *
+ * @param string $tagName Prefix name for the SELECT element
+ * @deprecated string $value
+ * @param string $selected Option which is selected.
+ * @param array $optionAttr Attribute array for the option elements.
+ * @return mixed
+ * @access public
+ */
+ function meridianOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
+ if (empty($selected) && ($this->tagValue($tagName))) {
+ $selected = date('a', strtotime($this->tagValue($tagName)));
+ }
+ $merValue = empty($selected) ? ($showEmpty ? NULL : date('a')) : $selected;
+ $meridians = array('am' => 'am', 'pm' => 'pm');
+
+ $option = $this->selectTag($tagName . "_meridian", $meridians, $merValue, $selectAttr, $optionAttr, $showEmpty);
+ return $option;
+ }
+/**
+ * Returns a set of SELECT elements for a full datetime setup: day, month and year, and then time.
+ *
+ * @param string $tagName Prefix name for the SELECT element
+ * @param string $dateFormat DMY, MDY, YMD or NONE.
+ * @param string $timeFormat 12, 24, NONE
+ * @param string $selected Option which is selected.
+ * @param array $optionAttr Attribute array for the option elements.
+ * @return string The HTML formatted OPTION element
+ * @access public
+ */
+ function dateTimeOptionTag($tagName, $dateFormat = 'DMY', $timeFormat = '12', $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
+ $day = null;
+ $month = null;
+ $year = null;
+ $hour = null;
+ $min = null;
+ $meridian = null;
+
+ if (empty($selected)) {
+ $selected = $this->tagValue($tagName);
+ }
+
+ if (!empty($selected)) {
+
+ if (is_int($selected)) {
+ $selected = strftime('%Y-%m-%d %H:%M:%S', $selected);
+ }
+
+ $meridian = 'am';
+ $pos = strpos($selected, '-');
+ if ($pos !== false) {
+ $date = explode('-', $selected);
+ $days = explode(' ', $date[2]);
+ $day = $days[0];
+ $month = $date[1];
+ $year = $date[0];
+ } else {
+ $days[1] = $selected;
+ }
+
+ if ($timeFormat != 'NONE' && !empty($timeFormat)) {
+ $time = explode(':', $days[1]);
+ $check = str_replace(':', '', $days[1]);
+
+ if (($check > 115959) && $timeFormat == '12') {
+ $time[0] = $time[0] - 12;
+ $meridian = 'pm';
+ } elseif ($time[0] > 12) {
+ $meridian = 'pm';
+ }
+
+ $hour = $time[0];
+ $min = $time[1];
+ }
+ }
+
+ $elements = array('Day','Month','Year','Hour','Minute','Meridian');
+ if (isset($selectAttr['id'])) {
+ if (is_string($selectAttr['id'])) {
+ // build out an array version
+ foreach ($elements as $element) {
+ $selectAttrName = 'select' . $element . 'Attr';
+ ${$selectAttrName} = $selectAttr;
+ ${$selectAttrName}['id'] = $selectAttr['id'] . $element;
+ }
+ } elseif (is_array($selectAttr['id'])) {
+ // check for missing ones and build selectAttr for each element
+ foreach ($elements as $element) {
+ $selectAttrName = 'select' . $element . 'Attr';
+ ${$selectAttrName} = $selectAttr;
+ ${$selectAttrName}['id'] = $selectAttr['id'][strtolower($element)];
+ }
+ }
+ } else {
+ // build the selectAttrName with empty id's to pass
+ foreach ($elements as $element) {
+ $selectAttrName = 'select' . $element . 'Attr';
+ ${$selectAttrName} = $selectAttr;
+ }
+ }
+
+ switch($dateFormat) {
+ case 'DMY': // so uses the new selex
+ $opt = $this->dayOptionTag($tagName, null, $day, $selectDayAttr, $optionAttr, $showEmpty) . '-' .
+ $this->monthOptionTag($tagName, null, $month, $selectMonthAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $selectYearAttr, $optionAttr, $showEmpty);
+ break;
+ case 'MDY':
+ $opt = $this->monthOptionTag($tagName, null, $month, $selectMonthAttr, $optionAttr, $showEmpty) . '-' .
+ $this->dayOptionTag($tagName, null, $day, $selectDayAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $selectYearAttr, $optionAttr, $showEmpty);
+ break;
+ case 'YMD':
+ $opt = $this->yearOptionTag($tagName, null, null, null, $year, $selectYearAttr, $optionAttr, $showEmpty) . '-' .
+ $this->monthOptionTag($tagName, null, $month, $selectMonthAttr, $optionAttr, $showEmpty) . '-' .
+ $this->dayOptionTag($tagName, null, $day, $selectDayAttr, $optionAttr, $showEmpty);
+ break;
+ case 'Y':
+ $opt = $this->yearOptionTag($tagName, null, null, null, $selected, $selectYearAttr, $optionAttr, $showEmpty);
+ break;
+ case 'NONE':
+ default:
+ $opt = '';
+ break;
+ }
+
+ switch($timeFormat) {
+ case '24':
+ $opt .= $this->hourOptionTag($tagName, null, true, $hour, $selectHourAttr, $optionAttr, $showEmpty) . ':' .
+ $this->minuteOptionTag($tagName, null, $min, $selectMinuteAttr, $optionAttr, $showEmpty);
+ break;
+ case '12':
+ $opt .= $this->hourOptionTag($tagName, null, false, $hour, $selectHourAttr, $optionAttr, $showEmpty) . ':' .
+ $this->minuteOptionTag($tagName, null, $min, $selectMinuteAttr, $optionAttr, $showEmpty) . ' ' .
+ $this->meridianOptionTag($tagName, null, $meridian, $selectMeridianAttr, $optionAttr, $showEmpty);
+ break;
+ case 'NONE':
+ default:
+ $opt .= '';
+ break;
+ }
+ return $opt;
+ }
+/**
+ * Returns a row of formatted and named TABLE headers.
+ *
+ * @param array $names Array of tablenames.
+ * @param array $trOptions HTML options for TR elements.
+ * @param array $thOptions HTML options for TH elements.
+ * @param boolean $return Wheter this method should return a value
+ * @return string
+ * @access public
+ */
+ function tableHeaders($names, $trOptions = null, $thOptions = null, $return = false) {
+ $out = array();
+ foreach ($names as $arg) {
+ $out[] = sprintf($this->tags['tableheader'], $this->parseHtmlOptions($thOptions), $arg);
+ }
+
+ $data = sprintf($this->tags['tablerow'], $this->parseHtmlOptions($trOptions), join(' ', $out));
+ return $this->output($data, $return);
+ }
+/**
+ * Returns a formatted string of table rows (TR's with TD's in them).
+ *
+ * @param array $data Array of table data
+ * @param array $oddTrOptionsHTML options for odd TR elements
+ * @param array $evenTrOptionsHTML options for even TR elements
+ * @param boolean $return Wheter this method should return a value
+ * @return string Formatted HTML
+ * @access public
+ */
+ function tableCells($data, $oddTrOptions = null, $evenTrOptions = null, $return = false) {
+ if (empty($data[0]) || !is_array($data[0])) {
+ $data = array($data);
+ }
+ static $count = 0;
+
+ foreach ($data as $line) {
+ $count++;
+ $cellsOut = array();
+
+ foreach ($line as $cell) {
+ $cellsOut[] = sprintf($this->tags['tablecell'], null, $cell);
+ }
+ $options = $this->parseHtmlOptions($count % 2 ? $oddTrOptions : $evenTrOptions);
+ $out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cellsOut));
+ }
+ return $this->output(join("\n", $out), $return);
+ }
+/**
+ * Generates a nested unordered list tree from an array.
+ *
+ * @param array $data
+ * @param array $htmlAttributes
+ * @param string $bodyKey
+ * @param string $childrenKey
+ * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. If $this->_crumbs is empty, return null.
+ * @access public
+ */
+ function guiListTree($data, $htmlAttributes = array(), $bodyKey = 'body', $childrenKey = 'children', $return = false) {
+ $out="<ul" . $this->_parseAttributes($htmlAttributes) . ">\n";
+ foreach ($data as $item) {
+ $out .= "<li>{$item[$bodyKey]}\n";
+ if (isset($item[$childrenKey]) && is_array($item[$childrenKey]) && count($item[$childrenKey])) {
+ $out .= $this->guiListTree($item[$childrenKey], $htmlAttributes, $bodyKey, $childrenKey);
+ }
+ $out .= "</li>\n";
+ }
+ $out .= "</ul>\n";
+ return $this->output($out, $return);
+ }
+/**
+ * Returns value of $fieldName. False if the tag does not exist.
+ *
+ * @param string $fieldName Fieldname as "Modelname/fieldname" string
+ * @return string htmlspecialchars Value of the named tag.
+ * @access public
+ */
+ function tagValue($fieldName, $escape = false) {
+ $this->setFormTag($fieldName);
+ if (isset($this->params['data'][$this->model][$this->field])) {
+ return ife($escape, h($this->params['data'][$this->model][$this->field]), $this->params['data'][$this->model][$this->field]);
+ } elseif (isset($this->data[$this->model][$this->field])) {
+ return ife($escape, h($this->data[$this->model][$this->field]), $this->data[$this->model][$this->field]);
+ }
+ return false;
+ }
+/**
+ * Returns false if given FORM field has no errors. Otherwise it returns the constant set in the array Model->validationErrors.
+ *
+ * @param string $model Model name as string
+ * @param string $field Fieldname as string
+ * @return boolean True on errors.
+ * @access public
+ */
+ function tagIsInvalid($model, $field) {
+ return empty($this->validationErrors[$model][$field]) ? 0 : $this->validationErrors[$model][$field];
+ }
+/**
+ * Returns number of errors in a submitted FORM.
+ *
+ * @return int Number of errors
+ * @access public
+ */
+ function validate() {
+ $args = func_get_args();
+ $errors = call_user_func_array(array(&$this, 'validateErrors'), $args);
+ return count($errors);
+ }
+/**
+ * Validates a FORM according to the rules set up in the Model.
+ *
+ * @return int Number of errors
+ * @access public
+ */
+ function validateErrors() {
+ $objects = func_get_args();
+ if (!count($objects)) {
+ return false;
+ }
+
+ $errors = array();
+ foreach ($objects as $object) {
+ $errors = array_merge($errors, $object->invalidFields($object->data));
+ }
+ return $this->validationErrors = (count($errors) ? $errors : false);
+ }
+/**
+ * Returns a formatted error message for given FORM field, NULL if no errors.
+ *
+ * @param string $field A field name, like "Modelname/fieldname"
+ * @param string $text Error message
+ * @return string If there are errors this method returns an error message, else NULL.
+ * @access public
+ */
+ function tagErrorMsg($field, $text) {
+ $error = 1;
+ $this->setFormTag($field);
+ if ($error == $this->tagIsInvalid($this->model, $this->field)) {
+ return sprintf('<div class="error_message">%s</div>', is_array($text) ? (empty($text[$error - 1]) ? 'Error in field' : $text[$error - 1]) : $text);
+ } else {
+ return null;
+ }
+ }
+/**
+ * Sets this helper's model and field properties to the slash-separated value-pair in $tagValue.
+ *
+ * @param string $tagValue A field name, like "Modelname/fieldname"
+ * @return
+ * @access public
+ */
+ function setFormTag($tagValue) {
+ return list($this->model, $this->field) = explode("/", $tagValue);
+ }
+/**
+ * Returns a space-delimited string with items of the $options array. If a
+ * key of $options array happens to be one of:
+ * + 'compact'
+ * + 'checked'
+ * + 'declare'
+ * + 'readonly'
+ * + 'disabled'
+ * + 'selected'
+ * + 'defer'
+ * + 'ismap'
+ * + 'nohref'
+ * + 'noshade'
+ * + 'nowrap'
+ * + 'multiple'
+ * + 'noresize'
+ *
+ * And its value is one of:
+ * + 1
+ * + true
+ * + 'true'
+ *
+ * Then the value will be reset to be identical with key's name.
+ * If the value is not one of these 3, the parameter is not output.
+ *
+ * @param array $options Array of options.
+ * @param array $exclude Array of options to be excluded.
+ * @param string $insertBefore String to be inserted before options.
+ * @param string $insertAfter String to be inserted ater options.
+ * @return string
+ * @access protected
+ */
+ function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
+ if (is_array($options)) {
+ $default = array (
+ 'escape' => true
+ );
+ $options = am($default, $options);
+ if (!is_array($exclude)) {
+ $exclude = array();
+ }
+ $exclude = am($exclude, array('escape'));
+ $keys = array_diff(array_keys($options), $exclude);
+ $values = array_intersect_key(array_values($options), $keys);
+ $escape = $options['escape'];
+ $attributes = array();
+ foreach ($keys as $index => $key) {
+ $attributes[] = $this->__formatAttribute($key, $values[$index], $escape);
+ }
+ $out = implode(' ', $attributes);
+ } else {
+ $out = $options;
+ }
+ return $out ? $insertBefore . $out . $insertAfter : '';
+ }
+/**
+ * @param string $key
+ * @param string $value
+ * @return string
+ * @access private
+ */
+ function __formatAttribute($key, $value, $escape = true) {
+ $attribute = '';
+ $attributeFormat = '%s="%s"';
+ $minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize');
+
+ if (in_array($key, $minimizedAttributes)) {
+ if ($value === 1 || $value === true || $value === 'true' || $value == $key) {
+ $attribute = sprintf($attributeFormat, $key, $key);
+ }
+ } else {
+ $attribute = sprintf($attributeFormat, $key, ife($escape, h($value), $value));
+ }
+ return $attribute;
+ }
+/**
+ * @deprecated Name changed to 'textarea'. Version 0.9.2.
+ * @see HtmlHelper::textarea()
+ */
+ function areaTag($tagName, $cols = 60, $rows = 10, $htmlAttributes = array(), $return = false) {
+ $htmlAttributes['cols']=$cols;
+ $htmlAttributes['rows']=$rows;
+ return $this->textarea($tagName, $htmlAttributes, $return);
+ }
+/**
+ * @deprecated Name changed to 'charset'. Version 0.9.2.
+ * @see HtmlHelper::charset()
+ */
+ function charsetTag($charset, $return = false) {
+ return $this->charset($charset, $return);
+ }
+/**
+ * @deprecated Name changed to 'checkbox'. Version 0.9.2.
+ * @see HtmlHelper::checkbox()
+ */
+ function checkboxTag($fieldName, $title = null, $htmlAttributes = array(), $return = false) {
+ return $this->checkbox($fieldName, $title, $htmlAttributes, $return);
+ }
+/**
+ * @deprecated Name changed to 'css'. Version 0.9.2.
+ * @see HtmlHelper::css()
+ */
+ function cssTag($path, $rel = 'stylesheet', $htmlAttributes = array(), $return = false) {
+ return $this->css($path, $rel, $htmlAttributes, $return);
+ }
+/**
+ * @deprecated Name changed to 'file'. Version 0.9.2.
+ * @see HtmlHelper::file()
+ */
+ function fileTag($fieldName, $htmlAttributes = array(), $return = false) {
+ return $this->file($fieldName, $htmlAttributes, $return);
+ }
+/**
+ * @deprecated Name changed to 'hidden'. Version 0.9.2.
+ * @see HtmlHelper::hidden()
+ */
+ function hiddenTag($tagName, $value = null, $htmlOptions = null) {
+ $this->setFormTag($tagName);
+ $htmlOptions['value'] = $value ? $value : $this->tagValue($tagName);
+ return $this->output(sprintf($this->tags['hidden'], $this->model, $this->field, $this->parseHtmlOptions($htmlOptions, null, '', ' ')));
+ }
+/**
+ * @deprecated Name changed to 'image'. Version 0.9.2.
+ * @see HtmlHelper::image()
+ */
+ function imageTag($path, $alt = null, $htmlAttributes = array(), $return = false) {
+ $htmlAttributes['alt'] = $alt;
+ return $this->image($path, $htmlAttributes, $return);
+ }
+/**
+ * @deprecated Name changed to 'input'. Version 0.9.2.
+ * @see HtmlHelper::input()
+ */
+ function inputTag($tagName, $size = 20, $htmlOptions = null) {
+ $this->setFormTag($tagName);
+ $htmlOptions['value'] = isset($htmlOptions['value']) ? $htmlOptions['value'] : $this->tagValue($tagName);
+ $this->tagIsInvalid($this->model, $this->field) ? $htmlOptions['class'] = 'form_error' : null;
+ return $this->output(sprintf($this->tags['input'], $this->model, $this->field, $this->parseHtmlOptions($htmlOptions, null, '', ' ')));
+ }
+/**
+ * @deprecated Unified with 'link'. Version 0.9.2.
+ * @see HtmlHelper::link()
+ */
+ function linkOut($title, $url = null, $htmlAttributes = array(), $escapeTitle = true, $return = false) {
+ return $this->link($title, $url, $htmlAttributes, false, $escapeTitle, $return);
+ }
+/**
+ * @deprecated Unified with 'link'. Version 0.9.2.
+ * @see HtmlHelper::link()
+ */
+ function linkTo($title, $url, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true, $return = false) {
+ return $this->link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle, $return);
+ }
+/**
+ * @deprecated Name changed to '_parseAttributes'. Version 0.9.2.
+ * @see HtmlHelper::_parseAttributes()
+ */
+ function parseHtmlOptions($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
+ if (!is_array($exclude))
+ $exclude=array();
+
+ if (is_array($options)) {
+ $out=array();
+
+ foreach ($options as $k => $v) {
+ if (!in_array($k, $exclude)) {
+ $out[] = "{$k}=\"{$v}\"";
+ }
+ }
+ $out = join(' ', $out);
+ return $out ? $insertBefore . $out . $insertAfter : null;
+ } else {
+ return $options ? $insertBefore . $options . $insertAfter : null;
+ }
+ }
+/**
+ * @deprecated Name changed to 'password'. Version 0.9.2.
+ * @see HtmlHelper::password()
+ */
+ function passwordTag($fieldName, $size = 20, $htmlAttributes = array(), $return = false) {
+ $args = func_get_args();
+ return call_user_func_array(array(&$this,
+ "password"), $args);
+ }
+/**
+ * @deprecated Name changed to 'radio'. Version 0.9.2.
+ * @see HtmlHelper::radio()
+ */
+ function radioTags($fieldName, $options, $inbetween = null, $htmlAttributes = array(), $return = false) {
+ return $this->radio($fieldName, $options, $inbetween, $htmlAttributes, $return);
+ }
+/**
+ * @deprecated Name changed to 'url'. Version 0.9.2.
+ * @see HtmlHelper::url()
+ */
+ function urlFor($url) {
+ return $this->url($url);
+ }
+/**
+ * @deprecated Name changed to 'submit'. Version 0.9.2.
+ * @see HtmlHelper::submit()
+ */
+ function submitTag() {
+ $args = func_get_args();
+ return call_user_func_array(array(&$this, "submit"), $args);
+ }
+/*************************************************************************
+ * Moved methods
+ *************************************************************************/
+/**
+ * @deprecated Moved to TextHelper. Version 0.9.2.
+ */
+ function trim() {
+ die("Method HtmlHelper::trim() was moved to TextHelper::trim().");
+ }
+/**
+ * @deprecated Moved to JavascriptHelper. Version 0.9.2.
+ */
+ function javascriptIncludeTag($url) {
+ die("Method HtmlHelper::javascriptIncludeTag() was moved to JavascriptHelper::link().");
+ }
+/**
+ * @deprecated Moved to JavascriptHelper. Version 0.9.2.
+ */
+ function javascriptTag($script) {
+ die("Method HtmlHelper::javascriptTag() was moved to JavascriptHelper::codeBlock().");
+ }
+/**
+ * This is very WYSIWYG unfriendly, use HtmlHelper::url() to get contents of "action" attribute. Version 0.9.2.
+ * @deprecated Version 0.9.2. Will not be available after 1.1.x.x
+ * @see FormHelper::create()
+ */
+ function formTag($target = null, $type = 'post', $htmlAttributes = array()) {
+ $htmlAttributes['action']=$this->urlFor ($target);
+ $htmlAttributes['method']=$type == 'get' ? 'get' : 'post';
+ $type == 'file' ? $htmlAttributes['enctype'] = 'multipart/form-data' : null;
+
+ $append = '';
+
+ if (isset($this->params['_Token']) && !empty($this->params['_Token'])) {
+ $append .= '<p style="display: inline; margin: 0px; padding: 0px;">';
+ $append .= $this->hidden('_Token/key', array('value' => $this->params['_Token']['key'], 'id' => '_TokenKey' . mt_rand()), true);
+ $append .= '</p>';
+ }
+
+ return sprintf($this->tags['form'], $this->parseHtmlOptions($htmlAttributes, null, '')) . $append;
+ }
+/**
+ * This should be done using a content filter.
+ * @deprecated Version 0.9.2. Will not be available after 1.1.x.x
+ */
+ function linkEmail($title, $email = null, $options = null) {
+ // if no $email, then title contains the email.
+ if (empty($email))
+ $email=$title;
+
+ $match=array();
+
+ // does the address contain extra attributes?
+ preg_match('!^(.*)(\?.*)$!', $email, $match);
+
+ // plaintext
+ if (empty($options['encode']) || !empty($match[2])) {
+ return sprintf($this->tags['mailto'], $email, $this->parseHtmlOptions($options), $title);
+ }
+ // encoded to avoid spiders
+ else {
+ $email_encoded=null;
+
+ for ($ii = 0; $ii < strlen($email); $ii++) {
+ if (preg_match('!\w!', $email[$ii])) {
+ $email_encoded .= '%' . bin2hex($email[$ii]);
+ } else {
+ $email_encoded .= $email[$ii];
+ }
+ }
+
+ $title_encoded=null;
+
+ for ($ii = 0; $ii < strlen($title); $ii++) {
+ $title_encoded .= preg_match('/^[A-Za-z0-9]$/', $title[$ii])
+ ? '&#x' . bin2hex($title[$ii]) . ';' : $title[$ii];
+ }
+
+ return sprintf($this->tags['mailto'], $email_encoded,
+ $this->parseHtmlOptions($options, array('encode')), $title_encoded);
+ }
+ }
+
+/**
+ * @deprecated Version 0.9.2. Will not be available after 1.1.x.x
+ */
+ function tag($name, $options = null, $open = false) {
+ $tag = "<$name " . $this->parseHtmlOptions($options);
+ $tag .= $open ? ">" : " />";
+ return $tag;
+ }
+/**
+ * @deprecated Version 0.9.2. Will not be available after 1.1.x.x
+ */
+ function contentTag($name, $content, $options = null) {
+ return "<$name " . $this->parseHtmlOptions($options) . ">$content</$name>";
+ }
+
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/javascript.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/javascript.php
new file mode 100644
index 0000000..1219987
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/javascript.php
@@ -0,0 +1,317 @@
+<?php
+/* SVN FILE: $Id: javascript.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Javascript Helper class file.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Javascript Helper class for easy use of JavaScript.
+ *
+ * JavascriptHelper encloses all methods needed while working with JavaScript.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ */
+class JavascriptHelper extends Helper{
+ var $_cachedEvents = array();
+ var $_cacheEvents = false;
+ var $_cacheToFile = false;
+ var $_cacheAll = false;
+ var $_rules = array();
+/**
+ * Returns a JavaScript script tag.
+ *
+ * @param string $script The JavaScript to be wrapped in SCRIPT tags.
+ * @param boolean $allowCache Allows the script to be cached if non-event caching is active
+ * @return string The full SCRIPT element, with the JavaScript inside it.
+ * @access public
+ */
+ function codeBlock($script, $allowCache = true) {
+ if ($this->_cacheEvents && $this->_cacheAll && $allowCache) {
+ $this->_cachedEvents[] = $script;
+ } else {
+ return sprintf($this->tags['javascriptblock'], $script);
+ }
+ }
+/**
+ * Returns a JavaScript include tag (SCRIPT element)
+ *
+ * @param string $url URL to JavaScript file.
+ * @return string
+ * @access public
+ */
+ function link($url) {
+ if (strpos($url, '.js') === false) {
+ $url .= ".js";
+ }
+ return sprintf($this->tags['javascriptlink'], $this->webroot . $this->themeWeb . JS_URL . $url);
+ }
+/**
+ * Returns a JavaScript include tag for an externally-hosted script
+ *
+ * @param string $url URL to JavaScript file.
+ * @return string
+ * @access public
+ */
+ function linkOut($url) {
+ if (strpos($url, '.js') === false && strpos($url, '?') === false) {
+ $url .= '.js';
+ }
+ return sprintf($this->tags['javascriptlink'], $url);
+ }
+/**
+ * Escape carriage returns and single and double quotes for JavaScript segments.
+ *
+ * @param string $script string that might have javascript elements
+ * @return string escaped string
+ * @access public
+ */
+ function escapeScript($script) {
+ $script = r(array("\r\n", "\n", "\r"), '\n', $script);
+ $script = r(array('"', "'"), array('\"', "\\'"), $script);
+ return $script;
+ }
+/**
+ * Escape a string to be JavaScript friendly.
+ *
+ * List of escaped ellements:
+ * + "\r\n" => '\n'
+ * + "\r" => '\n'
+ * + "\n" => '\n'
+ * + '"' => '\"'
+ * + "'" => "\\'"
+ *
+ * @param string $script String that needs to get escaped.
+ * @return string Escaped string.
+ * @access public
+ */
+ function escapeString($string) {
+ $escape = array("\r\n" => '\n', "\r" => '\n', "\n" => '\n', '"' => '\"', "'" => "\\'");
+ return r(array_keys($escape), array_values($escape), $string);
+ }
+/**
+ * Attach an event to an element. Used with the Prototype library.
+ *
+ * @param string $object Object to be observed
+ * @param string $event event to observe
+ * @param string $observer function to call
+ * @param boolean $useCapture default true
+ * @return boolean true on success
+ * @access public
+ */
+ function event($object, $event, $observer = null, $useCapture = false) {
+
+ if ($useCapture == true) {
+ $useCapture = "true";
+ } else {
+ $useCapture = "false";
+ }
+
+ if ($object == 'window' || strpos($object, '$(') !== false || strpos($object, '"') !== false || strpos($object, '\'') !== false) {
+ $b = "Event.observe($object, '$event', function(event) { $observer }, $useCapture);";
+ } else {
+ $chars = array('#', ' ', ', ', '.', ':');
+ $found = false;
+ foreach ($chars as $char) {
+ if (strpos($object, $char) !== false) {
+ $found = true;
+ break;
+ }
+ }
+ if ($found) {
+ $this->_rules[$object] = $event;
+ } else {
+ $b = "Event.observe(\$('$object'), '$event', function(event) { $observer }, $useCapture);";
+ }
+ }
+
+ if (isset($b) && !empty($b)) {
+ if ($this->_cacheEvents === true) {
+ $this->_cachedEvents[] = $b;
+ return;
+ } else {
+ return $this->codeBlock($b);
+ }
+ }
+ }
+/**
+ * Cache JavaScript events created with event()
+ *
+ * @param boolean $file If true, code will be written to a file
+ * @param boolean $all If true, all code written with JavascriptHelper will be sent to a file
+ * @return void
+ * @access public
+ */
+ function cacheEvents($file = false, $all = false) {
+ $this->_cacheEvents = true;
+ $this->_cacheToFile = $file;
+ $this->_cacheAll = $all;
+ }
+/**
+ * Write cached JavaScript events
+ *
+ * @return string
+ * @access public
+ */
+ function writeEvents() {
+
+ $rules = array();
+ if (!empty($this->_rules)) {
+ foreach ($this->_rules as $sel => $event) {
+ $rules[] = "\t'{$sel}': function(element, event) {\n\t\t{$event}\n\t}";
+ }
+ $this->_cacheEvents = true;
+ }
+
+ if ($this->_cacheEvents) {
+
+ $this->_cacheEvents = false;
+ $events = $this->_cachedEvents;
+ $data = implode("\n", $events);
+ $this->_cachedEvents = array();
+
+ if (!empty($rules)) {
+ $data .= "\n\nvar SelectorRules = {\n" . implode(",\n\n", $rules) . "\n}\n";
+ $data .= "\nEventSelectors.start(SelectorRules);\n";
+ }
+
+ if (!empty($events) || !empty($rules)) {
+ if ($this->_cacheToFile) {
+ $filename = md5($data);
+ if (!file_exists(JS . $filename . '.js')) {
+ cache(r(WWW_ROOT, '', JS) . $filename . '.js', $data, '+999 days', 'public');
+ }
+ return $this->link($filename);
+ } else {
+ return $this->codeBlock("\n" . $data . "\n");
+ }
+ }
+ }
+ }
+/**
+ * Includes the Prototype Javascript library (and anything else) inside a single script tag.
+ *
+ * Note: The recommended approach is to copy the contents of
+ * javascripts into your application's
+ * public/javascripts/ directory, and use @see javascriptIncludeTag() to
+ * create remote script links.
+ *
+ * @param string $script name of script to include
+ * @return string script with all javascript in/javascripts folder
+ * @access public
+ */
+ function includeScript($script = "") {
+ if ($script == "") {
+ $dh = opendir(JS);
+ while (false !== ($filename = readdir($dh))) {
+ $files[] = $filename;
+ }
+ sort($files);
+ $javascript = '';
+ foreach ($files as $file) {
+ if (substr($file, -3) == '.js') {
+ $javascript .= file_get_contents(JS . "{$file}") . "\n\n";
+ }
+ }
+ } else {
+ $javascript = file_get_contents(JS . "$script.js") . "\n\n";
+ }
+ return $this->codeBlock("\n\n" . $javascript);
+ }
+/**
+ * Generates a JavaScript object in JavaScript Object Notation (JSON)
+ * from an array
+ *
+ * @param array $data Data to be converted
+ * @param boolean $block Wraps return value in a <script/> block if true
+ * @param string $prefix Prepends the string to the returned data
+ * @param string $postfix Appends the string to the returned data
+ * @param array $stringKeys A list of array keys to be treated as a string
+ * @param boolean $quoteKeys If false, treats $stringKey as a list of keys *not* to be quoted
+ * @param string $q The type of quote to use
+ * @return string A JSON code block
+ * @access public
+ */
+ function object($data = array(), $block = false, $prefix = '', $postfix = '', $stringKeys = array(), $quoteKeys = true, $q = "\"") {
+ if (is_object($data)) {
+ $data = get_object_vars($data);
+ }
+
+ $out = array();
+ $key = array();
+
+ if (is_array($data)) {
+ $keys = array_keys($data);
+ }
+
+ $numeric = true;
+ if (!empty($keys)) {
+ $numeric = (array_values($keys) === array_keys(array_values($keys)));
+ }
+
+ foreach ($data as $key => $val) {
+ if (is_array($val) || is_object($val)) {
+ $val = $this->object($val, false, '', '', $stringKeys, $quoteKeys, $q);
+ } else {
+ if ((!count($stringKeys) && !is_numeric($val) && !is_bool($val)) || ($quoteKeys && in_array($key, $stringKeys, true)) || (!$quoteKeys && !in_array($key, $stringKeys, true))) {
+ $val = $q . $this->escapeString($val) . $q;
+ }
+ if ($val === null) {
+ $val = 'null';
+ }
+ if (is_bool($val)) {
+ $val = ife($val, 'true', 'false');
+ }
+ }
+
+ if (!$numeric) {
+ $val = $q . $key . $q . ':' . $val;
+ }
+
+ $out[] = $val;
+ }
+
+ if (!$numeric) {
+ $rt = '{' . join(', ', $out) . '}';
+ } else {
+ $rt = '[' . join(', ', $out) . ']';
+ }
+ $rt = $prefix . $rt . $postfix;
+
+ if ($block) {
+ $rt = $this->codeBlock($rt);
+ }
+
+ return $rt;
+ }
+/**
+ * AfterRender callback. Writes any cached events to the view, or to a temp file.
+ *
+ * @return void
+ * @access public
+ */
+ function afterRender() {
+ echo $this->writeEvents();
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/number.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/number.php
new file mode 100644
index 0000000..3d8ea8e
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/number.php
@@ -0,0 +1,88 @@
+<?php
+/* SVN FILE: $Id: number.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Number Helper.
+ *
+ * Methods to make numbers more readable.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Number helper library.
+ *
+ * Methods to make numbers more readable.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ */
+class NumberHelper extends Helper {
+/**
+ * Formats a number with a level of precision.
+ *
+ * @param float $number A floating point number.
+ * @param integer $precision The precision of the returned number.
+ * @return float Enter description here...
+ * @access public
+ */
+ function precision($number, $precision = 3) {
+ return sprintf("%01.{$precision}f", $number);
+ }
+
+/**
+ * Returns a formatted-for-humans file size.
+ *
+ * @param integer $length Size in bytes
+ * @return string Human readable size
+ * @access public
+ */
+ function toReadableSize($size) {
+ switch($size) {
+ case 0:
+ return '0 Bytes';
+ case 1:
+ return '1 Byte';
+ case $size < 1024:
+ return $size . ' Bytes';
+ 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';
+ }
+ }
+
+/**
+ * Formats a number into a percentage string.
+ *
+ * @param float $number A floating point number
+ * @param integer $precision The precision of the returned number
+ * @return string Percentage string
+ * @access public
+ */
+ function toPercentage($number, $precision = 2) {
+ return NumberHelper::precision($number, $precision) . '%';
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/session.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/session.php
new file mode 100644
index 0000000..77eee9a
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/session.php
@@ -0,0 +1,198 @@
+<?php
+/* SVN FILE: $Id: session.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ * @since CakePHP(tm) v 1.1.7.3328
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Session Helper.
+ *
+ * Session reading from the view.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ *
+ */
+if(!class_exists('cakesession')) {
+ uses('session');
+}
+class SessionHelper extends CakeSession {
+/**
+ * List of helpers used by this helper
+ *
+ * @var array
+ */
+ var $helpers = null;
+/**
+ * Used to determine if methods implementation is used, or bypassed
+ *
+ * @var boolean
+ */
+ var $__active = true;
+/**
+ * Class constructor
+ *
+ * @param string $base
+ */
+ function __construct($base = null) {
+ if (!defined('AUTO_SESSION') || AUTO_SESSION === true) {
+ parent::__construct($base, false);
+ } else {
+ $this->__active = false;
+ }
+ }
+/**
+ * Turn sessions on if 'Session.start' is set to false in core.php
+ *
+ * @param string $base
+ */
+ function activate($base = null) {
+ $this->__active = true;
+ }
+/**
+ * Used to read a session values set in a controller for a key or return values for all keys.
+ *
+ * In your view: $session->read('Controller.sessKey');
+ * Calling the method without a param will return all session vars
+ *
+ * @param string $name the name of the session key you want to read
+ *
+ * @return values from the session vars
+ * @access public
+ */
+ function read($name = null) {
+ if ($this->__active === true && $this->__start()) {
+ return parent::read($name);
+ }
+ return false;
+ }
+/**
+ * Used to check is a session key has been set
+ *
+ * In your view: $session->check('Controller.sessKey');
+ *
+ * @param string $name
+ * @return boolean
+ * @access public
+ */
+ function check($name) {
+ if ($this->__active === true && $this->__start()) {
+ return parent::check($name);
+ }
+ return false;
+ }
+/**
+ * Returns last error encountered in a session
+ *
+ * In your view: $session->error();
+ *
+ * @return string last error
+ * @access public
+ */
+ function error() {
+ if ($this->__active === true && $this->__start()) {
+ return parent::error();
+ }
+ return false;
+ }
+/**
+ * Used to render the message set in Controller::Session::setFlash()
+ *
+ * In your view: $session->flash('somekey');
+ * Will default to flash if no param is passed
+ *
+ * @param string $key The [Message.]key you are rendering in the view.
+ * @return string Will echo the value if $key is set, or false if not set.
+ * @access public
+ */
+ function flash($key = 'flash') {
+ if ($this->__active === true && $this->__start()) {
+ if (parent::check('Message.' . $key)) {
+ $flash = parent::read('Message.' . $key);
+
+ if ($flash['layout'] == 'default') {
+ $out = '<div id="' . $key . 'Message" class="message">' . $flash['message'] . '</div>';
+ } elseif ($flash['layout'] == '' || $flash['layout'] == null) {
+ $out = $flash['message'];
+ } else {
+ $view =& ClassRegistry::getObject('view');
+ list($tmpLayout, $tmpVars, $tmpTitle) = array($view->layout, $view->viewVars, $view->pageTitle);
+ list($view->layout, $view->viewVars, $view->pageTitle) = array($flash['layout'], $flash['params'], '');
+ $out = $view->renderLayout($flash['message']);
+ list($view->layout, $view->viewVars, $view->pageTitle) = array($tmpLayout, $tmpVars, $tmpTitle);
+ }
+ e($out);
+ parent::del('Message.' . $key);
+ return true;
+ }
+ }
+ return false;
+ }
+/**
+ * Used to check is a session is valid in a view
+ *
+ * @return boolean
+ * @access public
+ */
+ function valid() {
+ if ($this->__active === true && $this->__start()) {
+ return parent::valid();
+ }
+ }
+/**
+ * Override CakeSession::write().
+ * This method should not be used in a view
+ *
+ * @return boolean
+ * @access public
+ */
+ function write() {
+ trigger_error(__('You can not write to a Session from the view', true), E_USER_WARNING);
+ }
+/**
+ * Session id
+ *
+ * @return string Session id
+ * @access public
+ */
+ function id() {
+ return parent::id();
+ }
+/**
+ * Determine if Session has been started
+ * and attempt to start it if not
+ *
+ * @return boolean true if Session is already started, false if
+ * Session could not be started
+ * @access public
+ */
+ function __start() {
+ if(!parent::started()) {
+ parent::start();
+ }
+ return true;
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/text.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/text.php
new file mode 100644
index 0000000..c545f3c
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/text.php
@@ -0,0 +1,238 @@
+<?php
+/* SVN FILE: $Id: text.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Text Helper
+ *
+ * Text manipulations: Highlight, excerpt, truncate, strip of links, convert email addresses to mailto: links...
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Included libraries.
+ *
+ */
+if (!class_exists('Flay')) {
+ uses('flay');
+}
+if (!class_exists('HtmlHelper')) {
+ uses('view' . DS . 'helpers' . DS . 'html');
+}
+/**
+ * Text helper library.
+ *
+ * Text manipulations: Highlight, excerpt, truncate, strip of links, convert email addresses to mailto: links...
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ */
+class TextHelper extends Helper{
+/**
+ * Highlights a given phrase in a text.
+ *
+ * @param string $text Text to search the phrase in
+ * @param string $phrase The phrase that will be searched
+ * @param string $highlighter The piece of html with that the phrase will be highlighted
+ * @return string The highlighted text
+ * @access public
+ */
+ function highlight($text, $phrase, $highlighter = '<span class="highlight">\1</span>') {
+ if (empty($phrase))
+ return $text;
+
+ if (is_array($phrase)) {
+ $replace=array();
+ $with=array();
+
+ foreach ($phrase as $key => $value) {
+ if (empty($key)) {
+ $key =$value;
+ $value=$highlighter;
+ }
+
+ $replace[]='|(' . $key . ')|i';
+ $with[]=empty($value) ? $highlighter : $value;
+ }
+
+ return preg_replace($replace, $with, $text);
+ } else {
+ return preg_replace("|({$phrase})|i", $highlighter, $text);
+ }
+ }
+/**
+ * Strips given text of all links (<a href=....)
+ *
+ * @param string $text Text
+ * @return string The text without links
+ * @access public
+ */
+ function stripLinks($text) {
+ return preg_replace('|<a.*>(.*)<\/a>|im', '\1', $text);
+ }
+/**
+ * Adds links (<a href=....) to a given text, by finding text that begins with
+ * strings like http:// and ftp://.
+ *
+ * @param string $text Text to add links to
+ * @param array $htmlOptions Array of HTML options.
+ * @return string The text with links
+ * @access public
+ */
+ function autoLinkUrls($text, $htmlOptions = array()) {
+ $options='array(';
+
+ foreach ($htmlOptions as $option => $value) {
+ $options .= "'$option' => '$value', ";
+ }
+
+ $options .= ')';
+
+ $text = preg_replace_callback('#(?<!href="|">)((?:http|https|ftp|nntp)://[^ <]+)#i',
+ create_function('$matches',
+ '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], $matches[0],' . $options . ');'),
+ $text);
+ return preg_replace_callback('#(?<!href="|">)(?<!http://|https://|ftp://|nntp://)(www\.[^\n\%\ <]+[^<\n\%\,\.\ <])#i',
+ create_function('$matches',
+ '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], "http://" . $matches[0],' . $options . ');'),
+ $text);
+ }
+/**
+ * Adds email links (<a href="mailto:....) to a given text.
+ *
+ * @param string $text Text
+ * @param array $htmlOptions Array of HTML options.
+ * @return string The text with links
+ * @access public
+ */
+ function autoLinkEmails($text, $htmlOptions = array()) {
+ $options='array(';
+
+ foreach ($htmlOptions as $option => $value) {
+ $options .= "'$option' => '$value', ";
+ }
+
+ $options .= ')';
+
+ return preg_replace_callback(
+ '#([_A-Za-z0-9+-]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#',
+ create_function('$matches',
+ '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->linkEmail($matches[0], $matches[0],' . $options . ');'),
+ $text);
+ }
+/**
+ * Convert all links and email adresses to HTML links.
+ *
+ * @param string $text Text
+ * @param array $htmlOptions Array of HTML options.
+ * @return string The text with links
+ * @access public
+ */
+ function autoLink($text, $htmlOptions = array()) {
+ return $this->autoLinkEmails($this->autoLinkUrls($text, $htmlOptions), $htmlOptions);
+ }
+/**
+ * Truncates text.
+ *
+ * Cuts a string to the length of $length and replaces the last characters
+ * with the ending if the text is longer than length.
+ *
+ * @param string $text String to truncate.
+ * @param integer $length Length of returned string, including ellipsis.
+ * @param string $ending Ending to be appended to the trimmed string.
+ * @param boolean $exact If false, $test will not be cut mid-word
+ * @return string Trimmed string.
+ * @access public
+ */
+ function truncate($text, $length, $ending = '...', $exact = true) {
+ if (strlen($text) <= $length) {
+ return $text;
+ } else {
+ $truncate=substr($text, 0, $length - strlen($ending));
+
+ if (!$exact) {
+ $spacepos=strrpos($truncate, ' ');
+
+ if (isset($spacepos)) {
+ return substr($truncate, 0, $spacepos) . $ending;
+ }
+ }
+
+ return $truncate . $ending;
+ }
+ }
+/**
+ * Alias for truncate().
+ *
+ * @see TextHelper::truncate()
+ * @return Text::truncate()
+ * @access public
+ */
+ function trim() {
+ $args=func_get_args();
+ return call_user_func_array(array(&$this,
+ "truncate"), $args);
+ }
+/**
+ * Extracts an excerpt from the text surrounding the phrase with a number of characters on each side determined by radius.
+ *
+ * @param string $text String to search the phrase in
+ * @param string $phrase Phrase that will be searched for
+ * @param integer $radius The amount of characters that will be returned on each side of the founded phrase
+ * @param string $ending Ending that will be appended
+ * @return string
+ * @access public
+ */
+ function excerpt($text, $phrase, $radius = 100, $ending = "...") {
+ if (empty($text) or empty($phrase))
+ return $this->truncate($text, $radius * 2, $ending);
+
+ if ($radius < strlen($phrase))
+ $radius=strlen($phrase);
+
+ $pos =strpos($text, $phrase);
+ $startPos=$pos <= $radius ? 0 : $pos - $radius;
+ $endPos =$pos + strlen($phrase) + $radius >= strlen($text)
+ ? strlen($text) : $pos + strlen($phrase) + $radius;
+
+ $excerpt =substr($text, $startPos, $endPos - $startPos);
+
+ if ($startPos != 0)
+ $excerpt=substr_replace($excerpt, $ending, 0, strlen($phrase));
+
+ if ($endPos != strlen($text))
+ $excerpt=substr_replace($excerpt, $ending, -strlen($phrase));
+
+ return $excerpt;
+ }
+/**
+ * Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax.
+ *
+ * @param string $text String to "flay"
+ * @param boolean $allowHtml Set to true if if html is allowed
+ * @return string "Flayed" text
+ * @todo Change this. We need a real Textile parser.
+ * @access public
+ */
+ function flay($text, $allowHtml = false) {
+ return Flay::toHtml($text, false, $allowHtml);
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/time.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/time.php
new file mode 100644
index 0000000..f10cadb
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/helpers/time.php
@@ -0,0 +1,397 @@
+<?php
+/* SVN FILE: $Id: time.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Time Helper class file.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Time Helper class for easy use of time data.
+ *
+ * Manipulation of time data.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.view.helpers
+ */
+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
+ * @access public
+ */
+ 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
+ * @access public
+ */
+ function fromString($date_string) {
+ if (is_integer($date_string) || is_numeric($date_string)) {
+ return intval($date_string);
+ } else {
+ return strtotime($date_string);
+ }
+ }
+/**
+ * Returns a nicely formatted date string for given Datetime string.
+ *
+ * @param string $date_string Datetime string or Unix timestamp
+ * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return string Formatted date string
+ * @access public
+ */
+ function nice($date_string = null, $return = false) {
+ if ($date_string != null) {
+ $date = $this->fromString($date_string);
+ } else {
+ $date = time();
+ }
+
+ $ret = date("D, M jS Y, H:i", $date);
+ return $this->output($ret, $return);
+ }
+/**
+ * Returns a formatted descriptive date string for given datetime string.
+ *
+ * If the given date is today, the returned string could be "Today, 16:54".
+ * If the given date was yesterday, the returned string could be "Yesterday, 16:54".
+ * If $date_string's year is the current year, the returned string does not
+ * include mention of the year.
+ *
+ * @param string $date_string Datetime string or Unix timestamp
+ * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return string Described, relative date string
+ * @access public
+ */
+ 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
+ * @access public
+ */
+ function isToday($date_string, $return = false) {
+ $date = $this->fromString($date_string);
+ $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.
+ * @access public
+ */
+ 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';
+
+ return $this->output("($field_name >= '$begin') AND ($field_name <= '$end')", $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.
+ * @access public
+ */
+ 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
+ * @access public
+ */
+ 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
+ * @access public
+ */
+ function wasYesterday($date_string, $return = false) {
+ $date = $this->fromString($date_string);
+ $ret = date('Y-m-d', $date) == date('Y-m-d', strtotime('yesterday'));
+ return $this->output($ret, $return);
+ }
+/**
+ * Returns true if given datetime string is tomorrow.
+ *
+ * @param string $date_string Datetime string or Unix timestamp
+ * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return boolean True if datetime string was yesterday
+ * @access public
+ */
+ function isTomorrow($date_string, $return = false) {
+ $date = $this->fromString($date_string);
+ $ret = date('Y-m-d', $date) == date('Y-m-d', strtotime('tomorrow'));
+ return $this->output($ret, $return);
+ }
+/**
+ * Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime().
+ *
+ * @param string $date_string Datetime string to be represented as a Unix timestamp
+ * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return int Unix timestamp
+ * @access public
+ */
+ 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
+ * @access public
+ */
+ 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
+ * @access public
+ */
+ function toRSS($date_string, $return = false) {
+ $date = $this->fromString($date_string);
+ $ret = date("r", $date);
+ return $this->output($ret, $return);
+ }
+/**
+ * Returns either a relative date or a formatted date depending
+ * on the difference between the current time and given datetime.
+ * $datetime should be in a <i>strtotime</i>-parsable format, like MySQL's datetime datatype.
+ *
+ * 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 string $format Default format if timestamp is used in $date_string
+ * @param string $backwards False if $date_string is in the past, true if in the future
+ * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return string Relative time string.
+ * @access public
+ */
+ function timeAgoInWords($datetime_string, $format = 'j/n/y', $backwards = false, $return = false) {
+ $datetime = $this->fromString($datetime_string);
+
+ $in_seconds = $datetime;
+ if ($backwards) {
+ $diff = $in_seconds - time();
+ } else {
+ $diff = time() - $in_seconds;
+ }
+
+ $months = floor($diff / 2419200);
+ $diff -= $months * 2419200;
+ $weeks = floor($diff / 604800);
+ $diff -= $weeks * 604800;
+ $days = floor($diff / 86400);
+ $diff -= $days * 86400;
+ $hours = floor($diff / 3600);
+ $diff -= $hours * 3600;
+ $minutes = floor($diff / 60);
+ $diff -= $minutes * 60;
+ $seconds = $diff;
+
+ if ($months > 0) {
+ // over a month old, just show date (mm/dd/yyyy format)
+ $relative_date = 'on ' . date($format, $in_seconds);
+ $old = true;
+ } else {
+ $relative_date = '';
+ $old = false;
+
+ if ($weeks > 0) {
+ // weeks and days
+ $relative_date .= ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '');
+ $relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : '';
+ } elseif ($days > 0) {
+ // days and hours
+ $relative_date .= ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '');
+ $relative_date .= $hours > 0 ? ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '') : '';
+ } elseif ($hours > 0) {
+ // hours and minutes
+ $relative_date .= ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '');
+ $relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : '';
+ } elseif ($minutes > 0) {
+ // minutes only
+ $relative_date .= ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '');
+ } else {
+ // seconds only
+ $relative_date .= ($relative_date ? ', ' : '') . $seconds . ' second' . ($seconds != 1 ? 's' : '');
+ }
+ }
+
+ $ret = $relative_date;
+
+ // show relative date and add proper verbiage
+ if (!$backwards && !$old) {
+ $ret .= ' ago';
+ }
+ return $this->output($ret, $return);
+ }
+/**
+ * Alias for timeAgoInWords
+ *
+ * @param string $date_string Datetime string or Unix timestamp
+ * @param string $format Default format if timestamp is used in $date_string
+ * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT.
+ * @return string Relative time string.
+ * @see Time::timeAgoInWords()
+ * @access public
+ */
+ function relativeTime($datetime_string, $format = 'j/n/y', $return = false) {
+ $date = strtotime($datetime_string);
+
+ if (strtotime("now") > $date) {
+ $ret = $this->timeAgoInWords($datetime_string, $format, false);
+ } else {
+ $ret = $this->timeAgoInWords($datetime_string, $format, true);
+ }
+
+ return $this->output($ret, $return);
+ }
+/**
+ * Returns true if specified datetime was within the interval specified, else false.
+ *
+ * @param mixed $timeInterval the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute.
+ * @param mixed $date_string 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
+ * @access public
+ */
+ 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/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/elements/dump.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/elements/dump.thtml
new file mode 100644
index 0000000..3591bdb
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/elements/dump.thtml
@@ -0,0 +1,32 @@
+<?php
+/* SVN FILE: $Id: dump.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.elements
+ * @since CakePHP(tm) v 0.10.5.1782
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<div>
+ <h2>Controller dump:</h2>
+ <pre>
+ <?php print_r($this->controller); ?>
+ </pre>
+</div> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/error404.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/error404.thtml
new file mode 100644
index 0000000..cde78fd
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/error404.thtml
@@ -0,0 +1,28 @@
+<?php
+/* SVN FILE: $Id: error404.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1><?php echo $name; ?></h1>
+<p><?php echo $message; ?></p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_action.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_action.thtml
new file mode 100644
index 0000000..e04e94b
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_action.thtml
@@ -0,0 +1,37 @@
+<?php
+/* SVN FILE: $Id: missing_action.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Missing Method in <?php echo $controller;?></h1>
+<p class="error">You are seeing this error because the action <em><?php echo $action;?></em> is not defined in controller <em><?php echo $controller;?></em></p>
+<p><span class="notice">If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_action.thtml"; ?>.</span></p>
+<p><span class="notice"><strong>Fatal</strong>: Confirm you have created the <?php echo $controller;?>::<?php echo $action;?>() in file : <?php echo APP_DIR.DS."controllers".DS.Inflector::underscore($controller).".php"; ?></p>
+<p>&lt;?php<br />
+class <?php echo $controller;?> extends AppController {<br />
+&nbsp;&nbsp;&nbsp;<strong>function <?php echo $action;?>() {<br />
+&nbsp;&nbsp;&nbsp;}</strong><br />
+}<br />
+?&gt;<br />
+</p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_component_class.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_component_class.thtml
new file mode 100644
index 0000000..42c8783
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_component_class.thtml
@@ -0,0 +1,36 @@
+<?php
+/* SVN FILE: $Id: missing_component_class.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Missing Component Class</h1>
+<p class="error">You are seeing this error because the component class <em><?php echo $component."Component";?></em>
+you have set in <?php echo $controller."Controller";?> can't be found or doesn't exist.</em></p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_component_class.thtml"; ?>.</span></p>
+<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo APP_DIR.DS."controllers".DS."components".DS.$file; ?></p>
+<p>&lt;?php<br />
+class <?php echo $component;?>Component extends Object {<br />
+}<br />
+?&gt;<br />
+</p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_component_file.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_component_file.thtml
new file mode 100644
index 0000000..5ff57bd
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_component_file.thtml
@@ -0,0 +1,35 @@
+<?php
+/* SVN FILE: $Id: missing_component_file.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Missing Component File</h1>
+<p class="error">You are seeing this error because the component file can't be found or doesn't exist.</p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_component_file.thtml"; ?>.</span></p>
+<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo APP_DIR.DS."controllers".DS."components".DS.$file; ?></p>
+<p>&lt;?php<br />
+class <?php echo $component;?>Component extends Object {<br />
+
+}<br />
+?&gt;<br /> </p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_connection.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_connection.thtml
new file mode 100644
index 0000000..de859fb
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_connection.thtml
@@ -0,0 +1,30 @@
+<?php
+/* SVN FILE: $Id: missing_connection.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Requires a Database Connection</h1>
+<p class="error">Missing Database Connection: <?php echo $model;?> requires a database connection</p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_database.thtml"; ?>.</span></p>
+<p><span class="notice"><strong>Fatal</strong>: Confirm you have created the file : <?php echo APP_DIR.DS."config".DS."database.php"; ?></p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_controller.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_controller.thtml
new file mode 100644
index 0000000..535fb6a
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_controller.thtml
@@ -0,0 +1,36 @@
+<?php
+/* SVN FILE: $Id: missing_controller.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Missing controller</h1>
+<p class="error">You are seeing this error because controller <em><?php echo $controller;?></em> could not be found.</p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_controller.thtml"; ?>.</span></p>
+<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo APP_DIR.DS."controllers".DS.Inflector::underscore($controller).".php"; ?></p>
+<p>&lt;?php<br />
+class <?php echo $controller;?> extends AppController {<br />
+&nbsp;&nbsp;&nbsp;var $name = '<?php echo $controllerName;?>';<br />
+}<br />
+?&gt;<br />
+</p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_helper_class.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_helper_class.thtml
new file mode 100644
index 0000000..b7bb5a0
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_helper_class.thtml
@@ -0,0 +1,35 @@
+<?php
+/* SVN FILE: $Id: missing_helper_class.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Missing Helper Class</h1>
+<p class="error">You are seeing this error because the view helper class <?php echo $helperClass;?> can't be found or doesn't exist.</p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_helper_class.thtml"; ?>.</span></p>
+<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo APP_DIR.DS."views".DS."helpers".DS.$file; ?></p>
+<p>&lt;?php<br />
+class <?php echo $helperClass;?> extends Helper {<br />
+}<br />
+?&gt;<br />
+</p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_helper_file.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_helper_file.thtml
new file mode 100644
index 0000000..16c4e0c
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_helper_file.thtml
@@ -0,0 +1,35 @@
+<?php
+/* SVN FILE: $Id: missing_helper_file.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Missing Helper File</h1>
+<p class="error">You are seeing this error because the view helper file <?php echo APP_DIR.DS."views".DS."helpers".DS.$file; ?> can't be found or doesn't exist.</p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_helper_file.thtml"; ?>.</span></p>
+<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo APP_DIR.DS."views".DS."helpers".DS.$file; ?></p>
+<p>&lt;?php<br />
+class <?php echo $helperClass;?> extends Helper {<br />
+}<br />
+?&gt;<br />
+</p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_layout.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_layout.thtml
new file mode 100644
index 0000000..bfd991d
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_layout.thtml
@@ -0,0 +1,30 @@
+<?php
+/* SVN FILE: $Id: missing_layout.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Missing Layout</h1>
+<p class="error">You are seeing this error because the layout file <?php echo $file;?> can't be found or doesn't exist.</p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_layout.thtml"; ?>.</span></p>
+<p><span class="notice"><strong>Fatal</strong>: Confirm you have created the file : <?php echo $file;?></p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_model.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_model.thtml
new file mode 100644
index 0000000..ade0783
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_model.thtml
@@ -0,0 +1,36 @@
+<?php
+/* SVN FILE: $Id: missing_model.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Missing Model</h1>
+<p class="error">No class found for the <em><?php echo $model;?></em> model</p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_model.thtml"; ?>.</span></p>
+<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo "app".DS."models".DS.Inflector::underscore($model).".php"; ?></p>
+<p>&lt;?php<br />
+class <?php echo $model;?> extends AppModel {<br />
+&nbsp;&nbsp;&nbsp;var $name = '<?php echo $model;?>';<br />
+}<br />
+?&gt;<br />
+</p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_scaffolddb.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_scaffolddb.thtml
new file mode 100644
index 0000000..a680c2a
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_scaffolddb.thtml
@@ -0,0 +1,30 @@
+<?php
+/* SVN FILE: $Id: missing_scaffolddb.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Scaffold Requires a Database Connection</h1>
+<p class="error">Missing Database Connection: Scaffold Does not work without a database connection</p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_scaffolddb.thtml"; ?>.</span></p>
+<p><span class="notice"><strong>Fatal</strong>: Confirm you have created the file : <?php echo APP_DIR.DS."config".DS."database.php"; ?></p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_table.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_table.thtml
new file mode 100644
index 0000000..01d3049
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_table.thtml
@@ -0,0 +1,29 @@
+<?php
+/* SVN FILE: $Id: missing_table.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Missing Database Table</h1>
+<p class="error">No Database table for model <?php echo $model;?> (expected "<?php echo $table;?>"), create it first.</p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_table.thtml"; ?>.</span></p>
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_view.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_view.thtml
new file mode 100644
index 0000000..d5c2f1f
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/missing_view.thtml
@@ -0,0 +1,30 @@
+<?php
+/* SVN FILE: $Id: missing_view.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Missing view</h1>
+<p class="error">You are seeing this error because the view for <em><?php echo $controller.'Controller';?>::<?php echo $action;?>()</em> could not be found.</p>
+<p><span class="notice">If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_view.thtml"; ?>.</span></p>
+<p><span class="notice"><strong>Fatal</strong>: Confirm you have created the file : <?php echo $file;?></p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/private_action.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/private_action.thtml
new file mode 100644
index 0000000..6b9388f
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/private_action.thtml
@@ -0,0 +1,29 @@
+<?php
+/* SVN FILE: $Id: private_action.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Private Method in <?php echo $controller;?></h1>
+<p class="error">You are seeing this error because the private class method <em><?php echo $action;?></em> should not be accessed directly</p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/private_action.thtml"; ?>.</span></p>
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/scaffold_error.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/scaffold_error.thtml
new file mode 100644
index 0000000..919aa25
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/errors/scaffold_error.thtml
@@ -0,0 +1,33 @@
+<?php
+/* SVN FILE: $Id: scaffold_error.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.errors
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>Scaffold Error</h1>
+<p class="error">Your must implement the following method in your controller</p>
+<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/scaffold_error.thtml"; ?>.</span></p>
+<p>
+&nbsp;&nbsp;&nbsp;function _scaffoldError() {<br />
+&nbsp;&nbsp;&nbsp;}<br />
+</p> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/ajax.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/ajax.thtml
new file mode 100644
index 0000000..446beaa
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/ajax.thtml
@@ -0,0 +1,27 @@
+<?php
+/* SVN FILE: $Id: ajax.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.layouts
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<?php echo $content_for_layout; ?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/default.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/default.thtml
new file mode 100644
index 0000000..bb733c5
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/default.thtml
@@ -0,0 +1,58 @@
+<?php
+/* SVN FILE: $Id: default.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.pages
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>CakePHP(tm) : <?php echo $title_for_layout; ?></title>
+<?php echo $html->charset(); ?>
+<link rel="icon" href="<?php echo $this->webroot . 'favicon.ico'; ?>" type="image/x-icon" />
+<link rel="shortcut icon" href="<?php echo $this->webroot . 'favicon.ico'; ?>" type="image/x-icon" />
+<?php echo $html->css('cake.generic'); ?>
+</head>
+<body>
+ <div id="container">
+ <div id="header">
+ <h1>CakePHP Rapid Development</h1>
+ </div>
+ <div id="content">
+ <?php if ($session->check('Message.flash'))
+ {
+ $session->flash();
+ }
+ echo $content_for_layout;
+ ?>
+ </div>
+ <div id="footer">
+ &nbsp;
+ <a href="http://www.cakephp.org/" target="_new">
+ <?php echo $html->image('cake.power.png', array('alt'=>"CakePHP(tm) : Rapid Development Framework", 'border'=>"0")); ?>
+ </a>
+ </div>
+ </div>
+ <?php echo $cakeDebug; ?>
+</body>
+</html> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/flash.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/flash.thtml
new file mode 100644
index 0000000..1d7c808
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/layouts/flash.thtml
@@ -0,0 +1,45 @@
+<?php
+/* SVN FILE: $Id: flash.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.layouts
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title><?php echo $page_title; ?></title>
+<?php echo $html->charset(); ?>
+
+<?php if (Configure::read() == 0) { ?>
+<meta http-equiv="Refresh" content="<?php echo $pause; ?>;url=<?php echo $url; ?>"/>
+<?php } ?>
+<style><!--
+P { text-align:center; font:bold 1.1em sans-serif }
+A { color:#444; text-decoration:none }
+A:HOVER { text-decoration: underline; color:#44E }
+--></style>
+</head>
+<body>
+<p><a href="<?php echo $url; ?>"><?php echo $message; ?></a></p>
+</body>
+</html> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/pages/home.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/pages/home.thtml
new file mode 100644
index 0000000..a505e39
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/pages/home.thtml
@@ -0,0 +1,75 @@
+<?php
+/* SVN FILE: $Id: home.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.pages
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<p class="notice">Your database configuration file is <?php echo file_exists(CONFIGS.'database.php') ?' present.' . $filePresent = ' ' : ' not present.'; ?></p>
+<?php if (!empty($filePresent)):?>
+<?php uses('model' . DS . 'connection_manager'); $db = ConnectionManager::getInstance(); ?>
+<?php $connected = $db->getDataSource('default'); ?>
+<p class="notice">Cake<?php echo $connected->isConnected() ? ' is able to' : ' is not able to';?> connect to the database.</p>
+<br />
+<?php endif; ?>
+<h2>CakePHP release information is on CakeForge</h2>
+<a href="https://trac.cakephp.org/wiki/notes/1.1.x.x">Read the release notes and get the latest version</a>
+<h2>Editing this Page</h2>
+<p>
+To change the content of this page, create: /app/views/pages/home.thtml.<br />
+To change its layout, create: /app/views/layouts/default.thtml.<br />
+<a href="http://manual.cakephp.org/">See the views section of the manual for more info</a><br />
+You can also add some CSS styles for your pages at: app/webroot/css/.
+</p>
+<h2>More about Cake</h2>
+<p>
+CakePHP is a rapid development framework for PHP which uses commonly known design patterns like
+Active Record, Association Data Mapping, Front Controller and MVC.
+</p>
+<p>
+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.
+</p>
+<ul>
+ <li><a href="http://www.cakefoundation.org/">Cake Software Foundation</a>
+ <ul><li>Promoting development related to CakePHP</li></ul></li>
+ <li><a href="http://bakery.cakephp.org">The Bakery</a>
+ <ul><li>Everything CakePHP</li></ul></li>
+ <li><a href="http://astore.amazon.com/cakesoftwaref-20/">Book Store</a>
+ <ul><li>Recommended Software Books</li></ul></li>
+ <li><a href="http://www.cafepress.com/cakefoundation">CakeSchwag</a>
+ <ul><li>Get your own CakePHP gear - Doughnate to Cake</li></ul></li>
+ <li><a href="http://www.cakephp.org">CakePHP</a>
+ <ul><li>The Rapid Development Framework</li></ul></li>
+ <li><a href="http://manual.cakephp.org">CakePHP Manual</a>
+ <ul><li>Your Rapid Development Cookbook</li></ul></li>
+ <li><a href="http://api.cakephp.org">CakePHP API</a>
+ <ul><li>Docblock Your Best Friend</li></ul></li>
+ <li><a href="http://www.cakeforge.org">CakeForge</a>
+ <ul><li>Open Development for CakePHP</li></ul></li>
+ <li><a href="https://trac.cakephp.org/">CakePHP Trac</a>
+ <ul><li>For the Development of CakePHP (Tickets, SVN browser, Roadmap, Changelogs)</li></ul></li>
+ <li><a href="http://groups-beta.google.com/group/cake-php">CakePHP Google Group</a>
+ <ul><li>Community mailing list</li></ul></li>
+ <li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a>
+ <ul><li>Live chat about CakePHP</li></ul></li>
+</ul> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/add.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/add.thtml
new file mode 100644
index 0000000..5291ea9
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/add.thtml
@@ -0,0 +1,40 @@
+<?php
+/* SVN FILE: $Id: add.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.scaffolds
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>New <?php echo Inflector::humanize($this->name)?></h1>
+<?php
+if (is_null($this->plugin)) {
+ $path = '/';
+} else {
+ $path = '/'.$this->plugin.'/';
+}
+echo $html->formTag($path. Inflector::underscore($this->name).'/create');
+echo $form->generateFields( $fieldNames );
+echo $form->generateSubmitDiv( 'Add' );?>
+</form>
+<ul class='actions'>
+<?php echo "<li>".$html->link('List '.Inflector::humanize($this->name), $path.$this->viewPath.'/index')."</li>"; ?>
+</ul> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/edit.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/edit.thtml
new file mode 100644
index 0000000..bb259a4
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/edit.thtml
@@ -0,0 +1,56 @@
+<?php
+/* SVN FILE: $Id: edit.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.scaffolds
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+$modelName = ucwords(Inflector::singularize($this->name));
+$modelKey = $modelName;
+if (is_null($this->plugin)) {
+ $path = '/';
+} else {
+ $path = '/'.$this->plugin.'/';
+}?>
+<h1><?php echo $type.' '.Inflector::humanize($modelName);?></h1>
+<?php
+if ($type == 'Edit') {
+ echo $html->formTag($path . Inflector::underscore($this->name) .'/update');
+} else {
+ echo $html->formTag($path. Inflector::underscore($this->name).'/create');
+}
+echo $form->generateFields( $fieldNames );
+echo $form->generateSubmitDiv( 'Save' ); ?>
+</form>
+<ul class='actions'>
+<?php
+if ($type == 'Edit') {
+ echo "<li>".$html->link('Delete '.Inflector::humanize($modelName), $path.$this->viewPath.'/delete/'.$data[$modelKey][$this->controller->{$modelName}->primaryKey])."</li>";
+}
+echo "<li>".$html->link('List '.Inflector::humanize($modelName), $path.$this->viewPath.'/index')."</li>";
+if ($type == 'Edit') {
+ foreach ($fieldNames as $field => $value) {
+ if (isset($value['foreignKey'])) {
+ echo "<li>".$html->link( "View ".Inflector::humanize($value['controller']), $path.Inflector::underscore($value['controller'])."/view/".$data[$modelKey][$field] )."</li>";
+ }
+ }
+}?>
+</ul> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/index.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/index.thtml
new file mode 100644
index 0000000..3de10af
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/index.thtml
@@ -0,0 +1,95 @@
+<?php
+/* SVN FILE: $Id: index.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.scaffolds
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<h1>List <?php echo Inflector::humanize($this->name)?></h1>
+<?php
+$model = ucwords(Inflector::singularize($this->name));
+$modelKey = $model;
+$humanName = Inflector::humanize($this->name);
+$humanSingularName = Inflector::singularize( $humanName );
+if (is_null($this->plugin)) {
+ $path = '/';
+} else {
+ $path = '/'.$this->plugin.'/';
+}
+if (!empty($this->controller->{$model}->modelToTable)) {
+ foreach ($this->controller->{$model}->modelToTable as $key => $value) {
+ $alias[] = $key;
+ }
+}?>
+<table class="inav" cellpadding="0" cellspacing="0">
+<thead>
+<tr>
+<?php
+foreach ($fieldNames as $fieldName) {?>
+ <th><?php echo $fieldName['prompt'];?></th>
+<?php }?>
+<th>Actions</th>
+</tr>
+</thead>
+<tbody>
+<?php
+$iRowIndex = 0;
+if (is_array($data)) {
+ foreach ($data as $row) {
+ if ($iRowIndex++ % 2 == 0) {
+ echo "<tr>";
+ } else {
+ echo "<tr class='altRow'>";
+ }
+ $count = 0;
+ foreach ($fieldNames as $field=>$value) { ?>
+ <td>
+<?php
+ if (isset($value['foreignKey'])) {
+ $otherModelKey = Inflector::underscore($value['modelKey']);
+ $otherControllerName = $value['controller'];
+ $otherModelObject =& ClassRegistry::getObject( $otherModelKey );
+ if (is_object($otherModelObject)) {
+ $displayText = $row[$alias[$count]][ $otherModelObject->getDisplayField() ];
+ } else {
+ $displayText = $row[$alias[$count]][$field];
+ }
+ echo $html->link( $displayText, $path.Inflector::underscore($otherControllerName)."/view/".$row[$modelKey][$field] );
+ $count++;
+ } else {
+ echo $row[$modelKey][$field];
+ }?>
+ </td>
+<?php } ?>
+ <td class="listactions"><?php echo $html->link('View',$path.$this->viewPath."/view/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/")?>
+ <?php echo $html->link('Edit',$path.$this->viewPath."/edit/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/")?>
+ <?php echo $html->link('Delete',$path.$this->viewPath."/delete/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$modelKey][$this->controller->{$model}->primaryKey].' ?')?>
+ </td>
+ </tr>
+<?php
+ }
+}?>
+</tbody>
+</table>
+<ul class="actions">
+ <li><?php echo $html->link('New '.$humanSingularName, $path.$this->viewPath.'/add'); ?></li>
+</ul> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/view.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/view.thtml
new file mode 100644
index 0000000..9bc903b
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/templates/scaffolds/view.thtml
@@ -0,0 +1,166 @@
+<?php
+/* SVN FILE: $Id: view.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.scaffolds
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<?php
+$modelName = ucwords(Inflector::singularize($this->name));
+$modelKey = Inflector::underscore($modelName);
+$objModel =& ClassRegistry::getObject($modelKey);
+if (is_null($this->plugin)) {
+ $path = '/';
+} else {
+ $path = '/'.$this->plugin.'/';
+}
+if (!empty($objModel->modelToTable)) {
+ foreach ($objModel->modelToTable as $key => $value) {
+ $alias[] = $key;
+ }
+ $count = 0;
+}?>
+<h1>View
+<?php echo Inflector::humanize($modelName)?>
+</h1>
+<dl>
+<?php
+foreach ($fieldNames as $field => $value) {
+ echo "<dt>".$value['prompt']."</dt>";
+ if (isset($value['foreignKey'])) {
+ $otherModelObject =& ClassRegistry::getObject(Inflector::underscore($objModel->tableToModel[$value['table']]));
+ $displayField = $otherModelObject->getDisplayField();
+ $displayText = $data[$alias[$count]][$displayField];
+ if (!empty($data[$objModel->tableToModel[$objModel->table]][$field]) && (isset($displayText))) {
+ echo "<dd>".$html->link($displayText, $path.Inflector::underscore($value['controller']).'/view/'
+ .$data[$objModel->tableToModel[$objModel->table]][$field] )."</dd>";
+ } else {
+ echo "<dd>&nbsp;</dd>";
+ }
+ $count++;
+ } else {
+ if ( !empty($data[$objModel->tableToModel[$objModel->table]][$field])) {
+ echo "<dd>".$data[$objModel->tableToModel[$objModel->table]][$field]."</dd>";
+ } else {
+ echo "<dd>&nbsp;</dd>";
+ }
+ }
+}?>
+</dl>
+<ul class='actions'>
+<?php
+echo "<li>".$html->link('Edit '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/edit/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>";
+echo "<li>".$html->link('Delete '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/delete/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey], null, 'Are you sure you want to delete id '.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey].' ?')."</li>";
+echo "<li>".$html->link('List '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/index')."</li>";
+echo "<li>".$html->link('New '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/add')."</li>";
+
+foreach ( $fieldNames as $field => $value ) {
+ if ( isset( $value['foreignKey'] ) ) {
+ echo "<li>".$html->link( "List ".Inflector::humanize($value['controller']), $path.Inflector::underscore($value['controller'])."/index/")."</li>";
+ }
+}?>
+</ul>
+
+<!--hasOne relationships -->
+<?php
+foreach ($objModel->hasOne as $association => $relation) {
+ $model = $relation['className'];
+ $otherModelName = $objModel->tableToModel[$objModel->{$model}->table];
+ $controller = Inflector::pluralize($model);
+ $new = true;
+ echo "<div class='related'><H2>Related ".Inflector::humanize($association)."</H2>";
+ echo "<dl>";
+ if (isset($data[$association]) && is_array($data[$association])) {
+ foreach ($data[$association] as $field => $value) {
+ if (isset($value)) {
+ echo "<dt>".Inflector::humanize($field)."</dt>";
+ if (!empty($value)) {
+ echo "<dd>".$value."</dd>";
+ } else {
+ echo "<dd>&nbsp;</dd>";
+ }
+ $new = null;
+ }
+ }
+ echo "</dl>";
+ if ($new == null) {
+ echo "<ul class='actions'><li>".$html->link('Edit '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/edit/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>";
+ } else {
+ echo "<ul class='actions'><li>".$html->link('New '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/add/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>";
+ }
+ }
+}
+?>
+
+<!-- HAS MANY AND HASANDBELONGSTOMANY -->
+<?php
+$relations = array_merge($objModel->hasMany, $objModel->hasAndBelongsToMany);
+foreach ($relations as $association => $relation) {
+ $model = $relation['className'];
+ $count = 0;
+ $otherModelName = Inflector::singularize($model);
+ $controller = Inflector::pluralize($model);
+
+ echo "<div class='related'><H2>Related ".Inflector::humanize(Inflector::pluralize($association))."</H2>";
+ if (isset($data[$association][0]) && is_array($data[$association])) {?>
+ <table class="inav" cellspacing="0">
+ <tr>
+<?php
+ $bFound = false;
+ foreach ($data[$association][0] as $column=>$value) {
+ echo "<th>".Inflector::humanize($column)."</th>";
+ }?>
+ <th>Actions</th>
+ </tr>
+<?php
+ foreach ($data[$association] as $row) {
+ echo "<tr>";
+ foreach ($row as $column=>$value) {
+ echo "<td>".$value."</td>";
+ }
+ if (isset($this->controller->{$modelName}->{$association})) {?>
+ <td class="listactions"><?php echo $html->link('View',$path.Inflector::underscore($controller).
+ "/view/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
+ <?php echo $html->link('Edit',$path.Inflector::underscore($controller).
+ "/edit/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
+ <?php echo $html->link('Delete',$path.Inflector::underscore($controller).
+ "/delete/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$this->controller->{$modelName}->{$association}->primaryKey].' ?')?>
+ </td>
+<?php
+ } else {?>
+ <td class="listactions"><?php echo $html->link('View',$path.Inflector::underscore($controller).
+ "/view/{$row[$this->controller->{$modelName}->primaryKey]}/")?>
+ <?php echo $html->link('Edit',$path.Inflector::underscore($controller).
+ "/edit/{$row[$this->controller->{$modelName}->primaryKey]}/")?>
+ <?php echo $html->link('Delete',$path.Inflector::underscore($controller).
+ "/delete/{$row[$this->controller->{$modelName}->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$this->controller->{$modelName}->primaryKey].' ?')?>
+ </td>
+<?php
+ }
+ echo "</tr>";
+ }?>
+ </table>
+<?php }?>
+<ul class="actions">
+<?php echo "<li>".$html->link('New '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/add/")."</li>";?>
+</ul></div>
+<?php }?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/view.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/view.php
new file mode 100644
index 0000000..57365ab
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/libs/view/view.php
@@ -0,0 +1,765 @@
+<?php
+/* SVN FILE: $Id: view.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Methods for displaying presentation data in the view.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Included libraries.
+ */
+uses ('view' . DS . 'helper', 'class_registry');
+/**
+ * View, the V in the MVC triad.
+ *
+ * Class holding methods for displaying presentation data.
+ *
+ * @package cake
+ * @subpackage cake.cake.libs.view
+ */
+class View extends Object{
+/**
+ * Name of the controller.
+ *
+ * @var string Name of controller
+ * @access public
+ */
+ var $name = null;
+/**
+ * Stores the current URL (for links etc.)
+ *
+ * @var string Current URL
+ * @access public
+ */
+ var $here = null;
+/**
+ * Action to be performed.
+ *
+ * @var string Name of action
+ * @access public
+ */
+ var $action = null;
+/**
+ * An array of names of built-in helpers to include.
+ *
+ * @var mixed A single name as a string or a list of names as an array.
+ * @access public
+ */
+ var $helpers = array('Html');
+/**
+ * Path to View.
+ *
+ * @var string Path to View
+ * @access public
+ */
+ var $viewPath;
+/**
+ * Replaced with public var viewVars
+ * @access protected
+ * @deprecated
+ */
+ var $_viewVars = array();
+/**
+ * Variables for the view
+ *
+ * @var array
+ * @access public
+ */
+ var $viewVars = array();
+/**
+ * Title HTML element of this View.
+ *
+ * @var boolean
+ * @access public
+ */
+ var $pageTitle = false;
+/**
+ * Path parts for creating links in views.
+ *
+ * @var string Base URL
+ * @access public
+ */
+ var $base = null;
+/**
+ * Name of layout to use with this View.
+ *
+ * @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;
+/**
+ * Array of parameter data
+ *
+ * @var array Parameter data
+ * @access public
+ */
+ var $params;
+/**
+ * True when the view has been rendered.
+ *
+ * @var boolean
+ * @access protected
+ */
+ var $_hasRendered = null;
+/**
+ * @deprecated will not be avialable after 1.1.x.x
+ */
+ var $controller = null;
+/**
+ * Array of loaded view helpers.
+ *
+ * @var array
+ * @access public
+ */
+ var $loaded = array();
+/**
+ * File extension. Defaults to Cake's conventional ".thtml".
+ *
+ * @var array
+ * @access public
+ */
+ var $ext = '.thtml';
+/**
+ * Sub-directory for this view file.
+ *
+ * @var string
+ * @access public
+ */
+ var $subDir = null;
+/**
+ * The directory where theme web accessible content is stored
+ *
+ * @var array
+ * @access public
+ */
+ var $themeWeb = null;
+/**
+ * Plugin name. A Plugin is a sub-application.
+ * This is used to set the correct paths for views
+ *
+ * @var string
+ * @access public
+ */
+ var $plugin = null;
+/**
+ * Creates system path to plugin: plugins . DS . plugin_name . DS
+ *
+ * @var string
+ */
+ var $pluginPath = null;
+/**
+ * Holds an array of plugin paths.
+ * VIEWS . $this->pluginPath
+ * APP . $this->pluginPath . views . DS
+ *
+ * @var array
+ */
+ var $pluginPaths = array();
+/**
+ * List of variables to collect from the associated controller
+ *
+ * @var array
+ * @access protected
+ */
+ var $_passedVars = array('viewVars', 'action', 'autoLayout', 'autoRender', 'ext', 'base', 'webroot', 'helpers', 'here', 'layout', 'modelNames', 'name', 'pageTitle', 'viewPath', 'params', 'data', 'webservices', 'plugin');
+/**
+ * Constructor
+ *
+ * Instance is created in Controller::render() and is never called directly
+ *
+ * @var object instance of the calling controller
+ */
+ function __construct(&$controller) {
+ if (is_object($controller)) {
+ $this->controller =& $controller;
+ $c = count($this->_passedVars);
+
+ for ($j = 0; $j < $c; $j++) {
+ $var = $this->_passedVars[$j];
+ $this->{$var} = $controller->{$var};
+ }
+ $this->_viewVars =& $this->viewVars;
+ }
+ if (!is_null($this->plugin)) {
+ $this->pluginPath = 'plugins'. DS . $this->plugin . DS;
+ $this->pluginPaths = array(
+ VIEWS . $this->pluginPath,
+ APP . $this->pluginPath . 'views' . DS,
+ );
+
+ }
+ parent::__construct();
+ ClassRegistry::addObject('view', $this);
+ }
+/**
+ * Renders view for given action and layout. If $file is given, that is used
+ * for a view filename (e.g. customFunkyView.thtml).
+ *
+ * @param string $action Name of action to render for
+ * @param string $layout Layout to use
+ * @param string $file Custom filename for view
+ * @return mixed returns an error if View::render() fails to find a related template.
+ * boolean on successful render
+ * @access public
+ */
+ function render($action = null, $layout = null, $file = null) {
+
+ if (isset($this->_hasRendered) && $this->_hasRendered) {
+ return true;
+ } else {
+ $this->_hasRendered = false;
+ }
+
+ if (!$action) {
+ $action = $this->action;
+ }
+ $tempLayout = $this->layout;
+
+ if ($layout) {
+ $this->setLayout($layout);
+ }
+
+ if ($file) {
+ $viewFileName = $file;
+ } else {
+ $viewFileName = $this->_getViewFileName($action);
+ }
+
+ if (!is_null($this->plugin) && is_null($file)) {
+ return $this->pluginView($action, $layout);
+ }
+
+ if (!is_file($viewFileName) && !fileExistsInPath($viewFileName) || $viewFileName === '/' || $viewFileName === '\\') {
+ if (strpos($action, 'missingAction') !== false) {
+ $errorAction = 'missingAction';
+ } else {
+ $errorAction = 'missingView';
+ }
+
+ foreach (array($this->name, 'errors') as $viewDir) {
+ $errorAction = Inflector::underscore($errorAction);
+
+ if (file_exists(VIEWS . $viewDir . DS . $errorAction . $this->ext)) {
+ $missingViewFileName = VIEWS . $viewDir . DS . $errorAction . $this->ext;
+ } elseif ($missingViewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $viewDir . DS . $errorAction . '.thtml')) {
+ } else {
+ $missingViewFileName = false;
+ }
+
+ $missingViewExists = is_file($missingViewFileName);
+
+ if ($missingViewExists) {
+ break;
+ }
+ }
+
+ if (strpos($action, 'missingView') === false) {
+ return $this->cakeError('missingView', array(array('className' => $this->controller->name,
+ 'action' => $action,
+ 'file' => $viewFileName,
+ 'base' => $this->base)));
+
+ $isFatal = isset($this->isFatal) ? $this->isFatal : false;
+
+ if (!$isFatal) {
+ $viewFileName = $missingViewFileName;
+ }
+ } else {
+ $missingViewExists = false;
+ }
+
+ if (!$missingViewExists || $isFatal) {
+ if (Configure::read() > 0) {
+ trigger_error(sprintf("No template file for view %s (expected %s), create it first'", $action, $viewFileName), E_USER_ERROR);
+ } else {
+ $this->error('404', 'Not found', sprintf("The requested address %s was not found on this server.", '', "missing view \"{$action}\""));
+ }
+ die();
+ }
+ }
+
+ if ($viewFileName && !$this->_hasRendered) {
+ if (substr($viewFileName, -5) === 'thtml') {
+ $out = View::_render($viewFileName, $this->viewVars);
+ } else {
+ $out = $this->_render($viewFileName, $this->viewVars);
+ }
+
+ if ($out !== false) {
+ if ($this->layout && $this->autoLayout) {
+ $out = $this->renderLayout($out);
+ if (isset($this->loaded['cache']) && ((isset($this->controller) && $this->controller->cacheAction != false)) && (defined('CACHE_CHECK') && CACHE_CHECK === true)) {
+ $replace = array('<cake:nocache>', '</cake:nocache>');
+ $out = str_replace($replace, '', $out);
+ }
+ }
+
+ print $out;
+ $this->setLayout($tempLayout);
+ $this->_hasRendered = true;
+ } else {
+ $out = $this->_render($viewFileName, $this->viewVars);
+ trigger_error(sprintf("Error in view %s, got: <blockquote>%s</blockquote>", $viewFileName, $out), E_USER_ERROR);
+ }
+ return true;
+ }
+ }
+/**
+ * Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string.
+ *
+ * This realizes the concept of Elements, (or "partial layouts")
+ * and the $params array is used to send data to be used in the Element.
+ *
+ * @param string $name Name of template file in the/app/views/elements/ folder
+ * @param array $params Array of data to be made available to the for rendered view (i.e. the Element)
+ * @return string Rendered output
+ * @access public
+ */
+ function renderElement($name, $params = array()) {
+ if (isset($params['plugin'])) {
+ $this->plugin = $params['plugin'];
+ $this->pluginPath = 'plugins' . DS . $this->plugin . DS;
+ $this->pluginPaths = array(
+ VIEWS . $this->pluginPath,
+ APP . $this->pluginPath . 'views' . DS,
+ );
+ }
+
+ $paths = Configure::getInstance();
+ $viewPaths = am($this->pluginPaths, $paths->viewPaths);
+
+ $file = null;
+ foreach ($viewPaths as $path) {
+ if (file_exists($path . 'elements' . DS . $name . $this->ext)) {
+ $file = $path . 'elements' . DS . $name . $this->ext;
+ break;
+ } elseif (file_exists($path . 'elements' . DS . $name . '.ctp')) {
+ $file = $path . 'elements' . DS . $name . '.ctp';
+ break;
+ }
+ }
+
+ if (!is_null($file)) {
+ $params = array_merge_recursive($params, $this->loaded);
+ return $this->_render($file, array_merge($this->viewVars, $params), false);
+ }
+
+ if (!is_null($this->pluginPath)) {
+ $file = APP . $this->pluginPath . 'views' . DS . 'elements' . DS . $name . $this->ext;
+ } else {
+ $file = VIEWS . 'elements' . DS . $name . $this->ext;
+ }
+
+ if (Configure::read() > 0) {
+ return "Element Not Found: " . $file;
+ }
+ }
+/**
+ * Wrapper for View::renderElement();
+ *
+ * @param string $name Name of template file in the/app/views/elements/ folder
+ * @param array $params Array of data to be made available to the for rendered view (i.e. the Element)
+ * @return string View::renderElement()
+ * @access public
+ */
+ function element($name, $params = array()) {
+ return $this->renderElement($name, $params);
+ }
+/**
+ * Renders a layout. Returns output from _render(). Returns false on error.
+ *
+ * @param string $contentForLayout Content to render in a view, wrapped by the surrounding layout.
+ * @return mixed Rendered output, or false on error
+ * @access public
+ */
+ function renderLayout($contentForLayout) {
+ $layoutFilename = $this->_getLayoutFileName();
+
+ if (Configure::read() > 2 && $this->controller != null) {
+ $debug = View::_render(LIBS . 'view' . DS . 'templates' . DS . 'elements' . DS . 'dump.thtml', array('controller' => $this->controller), false);
+ } else {
+ $debug = '';
+ }
+
+ if ($this->pageTitle !== false) {
+ $pageTitle = $this->pageTitle;
+ } else {
+ $pageTitle = Inflector::humanize($this->viewPath);
+ }
+
+ $dataForLayout = array_merge($this->viewVars, array('title_for_layout' => $pageTitle,
+ 'content_for_layout' => $contentForLayout,
+ 'cakeDebug' => $debug));
+
+ if (is_file($layoutFilename)) {
+ if (empty($this->loaded) && !empty($this->helpers)) {
+ $loadHelpers = true;
+ } else {
+ $loadHelpers = false;
+ $dataForLayout = array_merge($dataForLayout, $this->loaded);
+ }
+
+ if (substr($layoutFilename, -5) === 'thtml') {
+ $out = View::_render($layoutFilename, $dataForLayout, $loadHelpers, true);
+ } else {
+ $out = $this->_render($layoutFilename, $dataForLayout, $loadHelpers);
+ }
+
+ if ($out === false) {
+ $out = $this->_render($layoutFilename, $dataForLayout);
+ trigger_error(sprintf("Error in layout %s, got: <blockquote>%s</blockquote>", $layoutFilename, $out), E_USER_ERROR);
+ return false;
+ } else {
+ return $out;
+ }
+ } else {
+ return $this->cakeError('missingLayout', array(array('layout' => $this->layout,
+ 'file' => $layoutFilename,
+ 'base' => $this->base)));
+ }
+ }
+/**
+ * Sets layout to be used when rendering.
+ *
+ * @param string $layout Name of layout.
+ * @return void
+ * @access public
+ * @deprecated in 1.2.x.x
+ */
+ function setLayout($layout) {
+ $this->layout = $layout;
+ }
+/**
+ * Displays an error page to the user. Uses layouts/error.html to render the page.
+ *
+ * @param int $code HTTP Error code (for instance: 404)
+ * @param string $name Name of the error (for instance: Not Found)
+ * @param string $message Error message as a web page
+ * @return rendered error message
+ * @access public
+ *
+ */
+ function error($code, $name, $message) {
+ header ("HTTP/1.0 {$code} {$name}");
+ print ($this->_render(VIEWS . 'layouts/error.thtml', array('code' => $code,
+ 'name' => $name,
+ 'message' => $message)));
+ }
+/**
+ * Returns filename of given action's template file (.thtml) as a string. CamelCased action names will be under_scored! This means that you can have LongActionNames that refer to long_action_names.thtml views.
+ *
+ * @param string $action Controller action to find template filename for
+ * @return string Template filename
+ * @access protected
+ */
+ function _getViewFileName($action) {
+ $action = Inflector::underscore($action);
+
+ if (!is_null($this->webservices)) {
+ $type = strtolower($this->webservices) . DS;
+ } else {
+ $type = null;
+ }
+
+ $position = strpos($action, '..');
+ if ($position !== false) {
+ $action = explode('/', $action);
+ $i = array_search('..', $action);
+ unset($action[$i - 1]);
+ unset($action[$i]);
+ $action = '..' . DS . implode(DS, $action);
+ }
+
+ $paths = Configure::getInstance();
+ $viewPaths = am($this->pluginPaths, $paths->viewPaths);
+
+ $name = $this->viewPath . DS . $this->subDir . $type . $action;
+ foreach ($viewPaths as $path) {
+ if (file_exists($path . $name . $this->ext)) {
+ return $path . $name . $this->ext;
+ } elseif (file_exists($path . $name . '.ctp')) {
+ return $path . $name . '.ctp';
+ }
+ }
+
+ if ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . $type . $action . '.thtml')) {
+ return $viewFileName;
+ } elseif ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $this->viewPath . DS . $type . $action . '.thtml')) {
+ return $viewFileName;
+ } else {
+ if (!is_null($this->pluginPath)) {
+ $viewFileName = APP . $this->pluginPath . 'views' . DS . $name . $this->ext;
+ } else {
+ $viewFileName = VIEWS . $name . $this->ext;
+ }
+ }
+ return $viewFileName;
+ }
+/**
+ * Returns layout filename for this template as a string.
+ *
+ * @return string Filename for layout file (.thtml).
+ * @access protected
+ */
+ function _getLayoutFileName() {
+ if (isset($this->webservices) && !is_null($this->webservices)) {
+ $type = strtolower($this->webservices) . DS;
+ } else {
+ $type = null;
+ }
+
+ $paths = Configure::getInstance();
+ $viewPaths = am($this->pluginPaths, $paths->viewPaths);
+
+ $name = $this->subDir . $type . $this->layout;
+ foreach ($viewPaths as $path) {
+ if (file_exists($path . 'layouts' . DS . $name . $this->ext)) {
+ return $path . 'layouts' . DS . $name . $this->ext;
+ } elseif (file_exists($path . 'layouts' . DS . $name . '.ctp')) {
+ return $path . 'layouts' . DS . $name . '.ctp';
+ }
+ }
+
+ if (!is_null($this->pluginPath)) {
+ $layoutFileName = APP . $this->pluginPath . 'views' . DS . 'layouts' . DS . $name . $this->ext;
+ } else {
+ $layoutFileName = VIEWS . 'layouts' . DS . $name . $this->ext;
+ }
+
+ $layoutFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . $this->layout . '.thtml');
+ if (empty($layoutFileName) && !empty($type)) {
+ $layoutFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . 'default.thtml');
+ }
+ return $layoutFileName;
+ }
+
+/**
+ * Renders and returns output for given view filename with its array of data.
+ *
+ * @param string $___viewFn Filename of the view
+ * @param array $___dataForView Data to include in rendered view
+ * @return string Rendered output
+ * @access protected
+ */
+ function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = false) {
+ if ($this->helpers != false && $loadHelpers === true) {
+ $loadedHelpers = array();
+ $loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
+
+ foreach (array_keys($loadedHelpers) as $helper) {
+ $replace = strtolower(substr($helper, 0, 1));
+ $camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1);
+
+ ${$camelBackedHelper} =& $loadedHelpers[$helper];
+
+ if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers)) {
+ foreach (${$camelBackedHelper}->helpers as $subHelper) {
+ ${$camelBackedHelper}->{$subHelper} =& $loadedHelpers[$subHelper];
+ }
+ }
+ $this->loaded[$camelBackedHelper] =& ${$camelBackedHelper};
+ }
+ }
+ extract($___dataForView, EXTR_SKIP);
+ $BASE = $this->base;
+ $params =& $this->params;
+
+ ob_start();
+
+ if (Configure::read() > 0) {
+ include ($___viewFn);
+ } else {
+ @include ($___viewFn);
+ }
+
+ if ($this->helpers != false && $loadHelpers === true) {
+ foreach ($loadedHelpers as $helper) {
+ if (is_object($helper)) {
+ if (is_subclass_of($helper, 'Helper') || is_subclass_of($helper, 'helper')) {
+ $helper->afterRender();
+ }
+ }
+ }
+ }
+ $out = ob_get_clean();
+
+ if (isset($this->loaded['cache']) && ((isset($this->controller) && $this->controller->cacheAction != false)) && (defined('CACHE_CHECK') && CACHE_CHECK === true)) {
+ if (is_a($this->loaded['cache'], 'CacheHelper')) {
+ $cache =& $this->loaded['cache'];
+
+ if ($cached === true) {
+ $cache->view = &$this;
+ }
+
+ $cache->base = $this->base;
+ $cache->here = $this->here;
+ $cache->action = $this->action;
+ $cache->controllerName = $this->params['controller'];
+ $cache->cacheAction = $this->controller->cacheAction;
+ $cache->cache($___viewFn, $out, $cached);
+ }
+ }
+ return $out;
+ }
+/**
+ * Loads helpers, with their dependencies.
+ *
+ * @param array $loaded List of helpers that are already loaded.
+ * @param array $helpers List of helpers to load.
+ * @return array
+ * @access protected
+ */
+ function &_loadHelpers(&$loaded, $helpers) {
+ static $tags;
+ $helpers[] = 'Session';
+ if (empty($tags)) {
+ $helperTags = new Helper();
+ $tags = $helperTags->loadConfig();
+ }
+
+ foreach ($helpers as $helper) {
+ $parts = preg_split('/\/|\./', $helper);
+
+ if (count($parts) === 1) {
+ $plugin = $this->plugin;
+ } else {
+ $plugin = Inflector::underscore($parts['0']);
+ $helper = $parts[count($parts) - 1];
+ }
+ $helperCn = $helper . 'Helper';
+
+ if (in_array($helper, array_keys($loaded)) !== true) {
+ if (!class_exists($helperCn)) {
+ if (is_null($plugin) || !loadPluginHelper($plugin, $helper)) {
+ if (!loadHelper($helper)) {
+ $this->cakeError('missingHelperFile', array(array(
+ 'helper' => $helper,
+ 'file' => Inflector::underscore($helper) . '.php',
+ 'base' => $this->base)));
+ exit();
+ }
+ }
+ if (!class_exists($helperCn)) {
+ $this->cakeError('missingHelperClass', array(array(
+ 'helper' => $helper,
+ 'file' => Inflector::underscore($helper) . '.php',
+ 'base' => $this->base)));
+ exit();
+ }
+ }
+
+ $camelBackedHelper = Inflector::variable($helper);
+
+ ${$camelBackedHelper} =& new $helperCn;
+ ${$camelBackedHelper}->view =& $this;
+ ${$camelBackedHelper}->tags = $tags;
+
+ $vars = array('base', 'webroot', 'here', 'params', 'action', 'data', 'themeWeb', 'plugin');
+ $c = count($vars);
+ for ($j = 0; $j < $c; $j++) {
+ ${$camelBackedHelper}->{$vars[$j]} = $this->{$vars[$j]};
+ }
+
+ if (!empty($this->validationErrors)) {
+ ${$camelBackedHelper}->validationErrors = $this->validationErrors;
+ }
+
+ $loaded[$helper] =& ${$camelBackedHelper};
+
+ if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers)) {
+ $loaded = &$this->_loadHelpers($loaded, ${$camelBackedHelper}->helpers);
+ }
+ }
+ }
+ return $loaded;
+ }
+/**
+ * Returns a plugin view
+ *
+ * @param string $action Name of action to render for
+ * @param string $layout Layout to use
+ * @return mixed View::render() if template is found, error if template is missing
+ * @access public
+ */
+ function pluginView($action, $layout) {
+ $viewFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . $this->ext;
+
+ if (file_exists($viewFileName)) {
+ $this->render($action, $layout, $viewFileName);
+ } else {
+ return $this->cakeError('missingView', array(array(
+ 'className' => $this->controller->name,
+ 'action' => $action,
+ 'file' => $viewFileName,
+ 'base' => $this->base)));
+ }
+ }
+/**
+ * Renders a cached view if timestamp in file is less or equal to current time.
+ *
+ * If $layout is xml content type will be set before rendering the cache
+ *
+ * @param string $filename
+ * @param int $timeStart
+ * @return mixed outputs view, or returns void if timestamp has expired
+ * @access public
+ */
+ function renderCache($filename, $timeStart) {
+ ob_start();
+ include ($filename);
+
+ if (Configure::read() > 0 && $this->layout != 'xml') {
+ echo "<!-- Cached Render Time: " . round(getMicrotime() - $timeStart, 4) . "s -->";
+ }
+ $out = ob_get_clean();
+
+ if (preg_match('/^<!--cachetime:(\\d+)-->/', $out, $match)) {
+ if (time() >= $match['1']) {
+ @unlink($filename);
+ unset ($out);
+ return;
+ } else {
+ if ($this->layout === 'xml') {
+ header('Content-type: text/xml');
+ }
+ $out = str_replace('<!--cachetime:'.$match['1'].'-->', '', $out);
+ e($out);
+ die();
+ }
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/acl.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/acl.php
new file mode 100644
index 0000000..b4c7669
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/acl.php
@@ -0,0 +1,853 @@
+#!/usr/bin/php -q
+<?php
+/* SVN FILE: $Id: acl.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.scripts
+ * @since CakePHP(tm) v 0.10.0.1232
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Enter description here...
+ */
+ define ('DS', DIRECTORY_SEPARATOR);
+ if (function_exists('ini_set')) {
+ ini_set('display_errors', '1');
+ ini_set('error_reporting', '7');
+ ini_set('max_execution_time',0);
+ }
+
+ $app = 'app';
+ $core = null;
+ $root = dirname(dirname(dirname(__FILE__)));
+ $here = $argv[0];
+ $dataSource = 'default';
+ $unset = array();
+ for ($i = 1; $i < count($argv); $i++) {
+ // Process command-line modifiers here
+ switch (strtolower($argv[$i])) {
+ case '-app':
+ $app = $argv[$i + 1];
+ $unset[$i] = $argv[$i];
+ $unset[$i + 1] = $argv[$i + 1];
+ break;
+ case '-core':
+ $core = $argv[$i + 1];
+ $unset[$i] = $argv[$i];
+ $unset[$i + 1] = $argv[$i + 1];
+ break;
+ case '-root':
+ $root = $argv[$i + 1];
+ $unset[$i] = $argv[$i];
+ $unset[$i + 1] = $argv[$i + 1];
+ break;
+ case '-datasource':
+ $dataSource = $argv[$i + 1];
+ $unset[$i] = $argv[$i];
+ $unset[$i + 1] = $argv[$i + 1];
+ break;
+ }
+ }
+
+ if (strlen($app) && $app[0] == DS) {
+ $cnt = substr_count($root, DS);
+ $app = str_repeat('..' . DS, $cnt) . $app;
+ }
+ define ('ROOT', $root.DS);
+ define ('APP_DIR', $app);
+ define ('DEBUG', 1);;
+ define('CAKE_CORE_INCLUDE_PATH', ROOT);
+ define('DATASOURCE', $dataSource);
+
+ if (function_exists('ini_set')) {
+ ini_set('include_path',ini_get('include_path').
+ PATH_SEPARATOR.CAKE_CORE_INCLUDE_PATH.DS.
+ PATH_SEPARATOR.CORE_PATH.DS.
+ PATH_SEPARATOR.ROOT.DS.APP_DIR.DS.
+ PATH_SEPARATOR.APP_DIR.DS.
+ PATH_SEPARATOR.APP_PATH);
+ define('APP_PATH', null);
+ define('CORE_PATH', null);
+ } else {
+ define('APP_PATH', ROOT . DS . APP_DIR . DS);
+ define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
+ }
+
+ require ('cake'.DS.'basics.php');
+ require ('cake'.DS.'config'.DS.'paths.php');
+ require (CONFIGS.'core.php');
+ uses ('object', 'configure', 'neat_array', 'session', 'security', 'inflector', 'model'.DS.'connection_manager',
+ 'model'.DS.'datasources'.DS.'dbo_source', 'model'.DS.'model');
+ require(CAKE.'app_model.php');
+ uses ('controller'.DS.'components'.DS.'acl', 'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aclnode',
+ 'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aco', 'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'acoaction',
+ 'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aro');
+ //Get and format args: first arg is the name of the script.
+ $serverArgs = $argv;
+ if (!empty($unset)) {
+ $serverArgs = array_values(array_diff($argv, $unset));
+ }
+
+ $wasted = array_shift($serverArgs);
+ $command = array_shift($serverArgs);
+ $args = $serverArgs;
+ $aclCLI = new AclCLI ($command, $args);
+/**
+ * @package cake
+ * @subpackage cake.cake.scritps
+ */
+class AclCLI {
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $stdin;
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $stdout;
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $stderr;
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $acl;
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $args;
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $dataSource = 'default';
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $command
+ * @param unknown_type $args
+ * @return AclCLI
+ */
+ function AclCLI($command, $args) {
+ $this->__construct($command, $args);
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $command
+ * @param unknown_type $args
+ */
+ function __construct ($command, $args) {
+ $this->stdin = fopen('php://stdin', 'r');
+ $this->stdout = fopen('php://stdout', 'w');
+ $this->stderr = fopen('php://stderr', 'w');
+
+ if (ACL_CLASSNAME != 'DB_ACL') {
+ $out = "--------------------------------------------------\n";
+ $out .= "Error: Your current Cake configuration is set to \n";
+ $out .= "an ACL implementation other than DB. Please change \n";
+ $out .= "your core config to reflect your decision to use \n";
+ $out .= "DB_ACL before attempting to use this script.\n";
+ $out .= "--------------------------------------------------\n";
+ $out .= "Current ACL Classname: " . ACL_CLASSNAME . "\n";
+ $out .= "--------------------------------------------------\n";
+ fwrite($this->stderr, $out);
+ exit();
+ }
+
+ if (!in_array($command, array('help'))) {
+ if (!file_exists(CONFIGS.'database.php')) {
+ $this->stdout('');
+ $this->stdout('Your database configuration was not found.');
+ $this->stdout('Take a moment to create one:');
+ $this->doDbConfig();
+ }
+ require_once (CONFIGS.'database.php');
+
+ if (!in_array($command, array('initdb'))) {
+ $this->dataSource = DATASOURCE;
+ $this->Acl = new AclComponent();
+ $this->args = $args;
+ $this->db =& ConnectionManager::getDataSource($this->dataSource);
+ }
+ }
+
+ switch ($command) {
+ case 'create':
+ $this->create();
+ break;
+ case 'delete':
+ $this->delete();
+ break;
+ case 'setParent':
+ $this->setParent();
+ break;
+ case 'getPath':
+ $this->getPath();
+ break;
+ case 'grant':
+ $this->grant();
+ break;
+ case 'deny':
+ $this->deny();
+ break;
+ case 'inherit':
+ $this->inherit();
+ break;
+ case 'view':
+ $this->view();
+ break;
+ case 'initdb':
+ $this->initdb();
+ break;
+ case 'upgrade':
+ $this->upgradedb();
+ break;
+ case 'help':
+ $this->help();
+ break;
+ default:
+ fwrite($this->stderr, "Unknown ACL command '$command'.\nFor usage, try 'php acl.php help'.\n\n");
+ break;
+ }
+ }
+/**
+ * Enter description here...
+ *
+ */
+ function create() {
+ $this->checkArgNumber(4, 'create');
+ $this->checkNodeType();
+ extract($this->__dataVars());
+
+ $parent = (is_numeric($this->args[2])) ? intval($this->args[2]) : $this->args[2];
+ if (!$this->Acl->{$class}->create(intval($this->args[1]), $parent, $this->args[3])) {
+ $this->displayError("Parent Node Not Found", "There was an error creating the ".$class.", probably couldn't find the parent node.\n If you wish to create a new root node, specify the <parent_id> as '0'.");
+ }
+ $this->stdout("New $class '".$this->args[3]."' created.\n\n");
+ }
+/**
+ * Enter description here...
+ *
+ */
+ function delete() {
+ $this->checkArgNumber(2, 'delete');
+ $this->checkNodeType();
+ extract($this->__dataVars());
+ if (!$this->Acl->{$class}->delete($this->args[1])) {
+ $this->displayError("Node Not Deleted", "There was an error deleting the ".$class.". Check that the node exists.\n");
+ }
+ $this->stdout("{$class} deleted.\n\n");
+ }
+
+/**
+ * Enter description here...
+ *
+ */
+ function setParent() {
+ $this->checkArgNumber(3, 'setParent');
+ $this->checkNodeType();
+ extract($this->__dataVars());
+ if (!$this->Acl->{$class}->setParent($this->args[2], $this->args[1])) {
+ $this->stdout("Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.\n");
+ } else {
+ $this->stdout("Node parent set to ".$this->args[2]."\n\n");
+ }
+ }
+/**
+ * Enter description here...
+ *
+ */
+ function getPath() {
+ $this->checkArgNumber(2, 'getPath');
+ $this->checkNodeType();
+ extract($this->__dataVars());
+ $id = (is_numeric($this->args[2])) ? intval($this->args[1]) : $this->args[1];
+ $nodes = $this->Acl->{$class}->getPath($id);
+ if (empty($nodes)) {
+ $this->displayError("Supplied Node '".$this->args[1]."' not found", "No tree returned.");
+ }
+ for ($i = 0; $i < count($nodes); $i++) {
+ $this->stdout(str_repeat(' ', $i) . "[" . $nodes[$i][$class]['id'] . "]" . $nodes[$i][$class]['alias'] . "\n");
+ }
+ }
+/**
+ * Enter description here...
+ *
+ */
+ function grant() {
+ $this->checkArgNumber(3, 'grant');
+ //add existence checks for nodes involved
+ $aro = $this->args[0];
+ if (is_numeric($aro)) {
+ $aro = intval($aro);
+ }
+ $aco = $this->args[1];
+ if (is_numeric($aco)) {
+ $aco = intval($aco);
+ }
+ if ($this->Acl->allow($aro, $aco, $this->args[2])) {
+ $this->stdout("Permission granted.\n");
+ } else {
+ $this->stdout("Permission could not be granted.\n");
+ }
+ }
+/**
+ * Enter description here...
+ *
+ */
+ function deny() {
+ $this->checkArgNumber(3, 'deny');
+ //add existence checks for nodes involved
+ $aro = (is_numeric($this->args[0])) ? intval($this->args[0]) : $this->args[0];
+ $aco = (is_numeric($this->args[1])) ? intval($this->args[1]) : $this->args[1];
+ $aro = $this->args[0];
+ if (is_numeric($aro)) {
+ $aro = intval($aro);
+ }
+ $aco = $this->args[1];
+ if (is_numeric($aco)) {
+ $aco = intval($aco);
+ }
+ if ($this->Acl->deny($aro, $aco, $this->args[2])) {
+ $this->stdout("Permission denied.\n");
+ } else {
+ $this->stdout("Permission could not be denied.\n");
+ }
+ }
+/**
+ * Enter description here...
+ *
+ */
+ function inherit() {
+ $this->checkArgNumber(3, 'inherit');
+ $aro = $this->args[0];
+ if (is_numeric($aro)) {
+ $aro = intval($aro);
+ }
+ $aco = $this->args[1];
+ if (is_numeric($aco)) {
+ $aco = intval($aco);
+ }
+ if ($this->Acl->inherit($aro, $aco, $this->args[2])) {
+ $this->stdout("Permission inherited.\n");
+ } else {
+ $this->stdout("Permission could not be inherited.\n");
+ }
+ }
+/**
+ * Enter description here...
+ *
+ */
+ function view() {
+ $this->checkArgNumber(1, 'view');
+ $this->checkNodeType();
+ extract($this->__dataVars());
+ if (!is_null($this->args[1])) {
+ $conditions = $this->Acl->{$class}->_resolveID($this->args[1]);
+ } else {
+ $conditions = null;
+ }
+ $nodes = $this->Acl->{$class}->findAll($conditions, null, 'lft ASC');
+ if (empty($nodes)) {
+ $this->displayError($this->args[1]." not found", "No tree returned.");
+ }
+ $right = array();
+
+ $this->stdout($class . " tree:\n");
+ $this->stdout("------------------------------------------------\n");
+
+ for ($i = 0; $i < count($nodes); $i++) {
+ if (count($right) > 0) {
+ while ($right[count($right)-1] < $nodes[$i][$class]['rght']) {
+ if ($right[count($right)-1]) {
+ array_pop($right);
+ } else {
+ break;
+ }
+ }
+ }
+ $this->stdout(str_repeat(' ',count($right)) . "[" . $nodes[$i][$class]['id'] . "]" . $nodes[$i][$class]['alias']."\n");
+ $right[] = $nodes[$i][$class]['rght'];
+ }
+ $this->stdout("------------------------------------------------\n");
+ }
+/**
+ * Enter description here...
+ *
+ */
+ function initdb() {
+ $db =& ConnectionManager::getDataSource($this->dataSource);
+ $this->stdout("Initializing Database...\n");
+ $this->stdout("Creating access control objects table (acos)...\n");
+ $sql = " CREATE TABLE ".$db->fullTableName('acos')." (
+ ".$db->name('id')." ".$db->column($db->columns['primary_key']).",
+ ".$db->name('object_id')." ".$db->column($db->columns['integer'])." default NULL,
+ ".$db->name('alias')." ".$db->column($db->columns['string'])." NOT NULL default '',
+ ".$db->name('lft')." ".$db->column($db->columns['integer'])." default NULL,
+ ".$db->name('rght')." ".$db->column($db->columns['integer'])." default NULL,
+ PRIMARY KEY (".$db->name('id').")
+ );";
+ if ($db->query($sql) === false) {
+ die("Error: " . $db->lastError() . "\n\n");
+ }
+
+ $this->stdout("Creating access request objects table (aros)...\n");
+ $sql2 = "CREATE TABLE ".$db->fullTableName('aros')." (
+ ".$db->name('id')." ".$db->column($db->columns['primary_key']).",
+ ".$db->name('foreign_key')." ".$db->column($db->columns['integer'])." default NULL,
+ ".$db->name('alias')." ".$db->column($db->columns['string'])." NOT NULL default '',
+ ".$db->name('lft')." ".$db->column($db->columns['integer'])." default NULL,
+ ".$db->name('rght')." ".$db->column($db->columns['integer'])." default NULL,
+ PRIMARY KEY (".$db->name('id').")
+ );";
+ if ($db->query($sql2) === false) {
+ die("Error: " . $db->lastError() . "\n\n");
+ }
+
+ $this->stdout("Creating relationships table (aros_acos)...\n");
+ $sql3 = "CREATE TABLE ".$db->fullTableName('aros_acos')." (
+ ".$db->name('id')." ".$db->column($db->columns['primary_key']).",
+ ".$db->name('aro_id')." ".$db->column($db->columns['integer'])." default NULL,
+ ".$db->name('aco_id')." ".$db->column($db->columns['integer'])." default NULL,
+ ".$db->name('_create')." ".$db->column($db->columns['integer'])." NOT NULL default '0',
+ ".$db->name('_read')." ".$db->column($db->columns['integer'])." NOT NULL default '0',
+ ".$db->name('_update')." ".$db->column($db->columns['integer'])." NOT NULL default '0',
+ ".$db->name('_delete')." ".$db->column($db->columns['integer'])." NOT NULL default '0',
+ PRIMARY KEY (".$db->name('id').")
+ );";
+ if ($db->query($sql3) === false) {
+ die("Error: " . $db->lastError() . "\n\n");
+ }
+
+ $this->stdout("\nDone.\n");
+ }
+
+/**
+ * Enter description here...
+ *
+ */
+ function upgradedb() {
+ $db =& ConnectionManager::getDataSource($this->dataSource);
+ $this->stdout("Initializing Database...\n");
+ $this->stdout("Upgrading table (aros)...\n");
+ $sql = "ALTER TABLE ".$db->fullTableName('aros')."
+ CHANGE ".$db->name('user_id')."
+ ".$db->name('foreign_key')."
+ INT( 10 ) UNSIGNED NULL DEFAULT NULL;";
+ $sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_create')
+ . " " . $db->name('_create') . " CHAR(2) NOT NULL DEFAULT '0';";
+ $sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_update')
+ . " " . $db->name('_update') . " CHAR(2) NOT NULL DEFAULT '0';";
+ $sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_read')
+ . " " . $db->name('_read') . " CHAR(2) NOT NULL DEFAULT '0';";
+ $sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_delete')
+ . " " . $db->name('_delete') . " CHAR(2) NOT NULL DEFAULT '0';";
+ if ($db->query($sql) === false) {
+ die("Error: " . $db->lastError() . "\n\n");
+ }
+ $this->stdout("\nDatabase upgrade is complete.\n");
+ }
+
+/**
+ * Enter description here...
+ *
+ */
+ function help() {
+ $out = "Usage: php acl.php <command> <arg1> <arg2>...\n";
+ $out .= "-----------------------------------------------\n";
+ $out .= "Commands:\n";
+ $out .= "\n";
+ $out .= "\tcreate aro|aco <link_id> <parent_id> <alias>\n";
+ $out .= "\t\tCreates a new ACL object under the parent specified by <parent_id>, an id/alias (see\n";
+ $out .= "\t\t'view'). The link_id allows you to link a user object to Cake's\n";
+ $out .= "\t\tACL structures. The alias parameter allows you to address your object\n";
+ $out .= "\t\tusing a non-integer ID. Example: \"\$php acl.php create aro 57 0 John\"\n";
+ $out .= "\t\twould create a new ARO object at the root of the tree, linked to 57\n";
+ $out .= "\t\tin your users table, with an internal alias 'John'.";
+ $out .= "\n";
+ $out .= "\n";
+ $out .= "\tdelete aro|aco <id>\n";
+ $out .= "\t\tDeletes the ACL object with the specified ID (see 'view').\n";
+ $out .= "\n";
+ $out .= "\n";
+ $out .= "\tsetParent aro|aco <id> <parent_id>\n";
+ $out .= "\t\tUsed to set the parent of the ACL object specified by <id> to the ID\n";
+ $out .= "\t\tspecified by <parent_id>.\n";
+ $out .= "\n";
+ $out .= "\n";
+ $out .= "\tgetPath aro|aco <id>\n";
+ $out .= "\t\tReturns the path to the ACL object specified by <id>. This command is\n";
+ $out .= "\t\tis useful in determining the inhertiance of permissions for a certain\n";
+ $out .= "\t\tobject in the tree.\n";
+ $out .= "\n";
+ $out .= "\n";
+ $out .= "\tgrant <Aro.alias|Aro.foreign_key> <Aco.alias|Aco.object_id> <aco_action>\n";
+ $out .= "\t\tUse this command to grant ACL permissions. Once executed, the ARO\n";
+ $out .= "\t\tspecified (and its children, if any) will have ALLOW access to the\n";
+ $out .= "\t\tspecified ACO action (and the ACO's children, if any).\n";
+ $out .= "\t\tIf an integer is passed permissions will be granted based on the foreign_key or object_id.\n";
+ $out .= "\n";
+ $out .= "\n";
+ $out .= "\tdeny <Aro.alias|Aro.foreign_key> <Aco.alias|Aco.object_id> <aco_action>\n";
+ $out .= "\t\tUse this command to deny ACL permissions. Once executed, the ARO\n";
+ $out .= "\t\tspecified (and its children, if any) will have DENY access to the\n";
+ $out .= "\t\tspecified ACO action (and the ACO's children, if any).\n";
+ $out .= "\t\tIf an integer is passed permissions will be denied based on the foreign_key or object_id.\n";
+ $out .= "\n";
+ $out .= "\n";
+ $out .= "\tinherit <Aro.alias|Aro.foreign_key> <Aco.alias|Aco.object_id> <aco_action>\n";
+ $out .= "\t\tUse this command to force a child ARO object to inherit its\n";
+ $out .= "\t\tpermissions settings from its parent.\n";
+ $out .= "\t\tIf an integer is passed permissions will be inherited based on the foreign_key or object_id.\n";
+ $out .= "\n";
+ $out .= "\n";
+ $out .= "\tview aro|aco [id]\n";
+ $out .= "\t\tThe view command will return the ARO or ACO tree. The optional\n";
+ $out .= "\t\tid/alias parameter allows you to return only a portion of the requested\n";
+ $out .= "\t\ttree.\n";
+ $out .= "\n";
+ $out .= "\n";
+ $out .= "\tinitdb\n";
+ $out .= "\t\tUse this command to create the database tables needed to use DB ACL.\n";
+ $out .= "\n";
+ $out .= "\n";
+ $out .= "\thelp\n";
+ $out .= "\t\tDisplays this help message.\n";
+ $out .= "\n";
+ $out .= "\n";
+ $this->stdout($out);
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $title
+ * @param unknown_type $msg
+ */
+ function displayError($title, $msg) {
+ $out = "\n";
+ $out .= "Error: $title\n";
+ $out .= "$msg\n";
+ $out .= "\n";
+ $this->stdout($out);
+ exit();
+ }
+
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $expectedNum
+ * @param unknown_type $command
+ */
+ function checkArgNumber($expectedNum, $command) {
+ if (count($this->args) < $expectedNum) {
+ $this->displayError('Wrong number of parameters: '.count($this->args), 'Please type \'php acl.php help\' for help on usage of the '.$command.' command.');
+ }
+ }
+/**
+ * Enter description here...
+ *
+ */
+ function checkNodeType() {
+ if ($this->args[0] != 'aco' && $this->args[0] != 'aro') {
+ $this->displayError("Missing/Unknown node type: '".$this->args[0]."'", 'Please specify which ACL object type you wish to create.');
+ }
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $type
+ * @param unknown_type $id
+ * @return unknown
+ */
+ function nodeExists($type, $id) {
+ //$this->stdout("Check to see if $type with ID = $id exists...\n");
+ extract($this->__dataVars($type));
+ $conditions = $this->Acl->{$class}->_resolveID($id);
+ $possibility = $this->Acl->{$class}->findAll($conditions);
+ return $possibility;
+ }
+
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $type
+ * @return unknown
+ */
+ function __dataVars($type = null) {
+ if ($type == null) {
+ $type = $this->args[0];
+ }
+
+ $vars = array();
+ $class = ucwords($type);
+ $vars['secondary_id'] = ($class == 'aro' ? 'foreign_key' : 'object_id');
+ $vars['data_name'] = $type;
+ $vars['table_name'] = $type . 's';
+ $vars['class'] = $class;
+ return $vars;
+ }
+/**
+ * Database configuration setup.
+ *
+ */
+ function doDbConfig() {
+ $this->hr();
+ $this->stdout('Database Configuration:');
+ $this->hr();
+
+ $driver = '';
+
+ while ($driver == '') {
+ $driver = $this->getInput('What database driver would you like to use?', array('mysql','mysqli','mssql','sqlite','postgres', 'odbc'), 'mysql');
+ if ($driver == '') {
+ $this->stdout('The database driver supplied was empty. Please supply a database driver.');
+ }
+ }
+
+ switch($driver) {
+ case 'mysql':
+ $connect = 'mysql_connect';
+ break;
+ case 'mysqli':
+ $connect = 'mysqli_connect';
+ break;
+ case 'mssql':
+ $connect = 'mssql_connect';
+ break;
+ case 'sqlite':
+ $connect = 'sqlite_open';
+ break;
+ case 'postgres':
+ $connect = 'pg_connect';
+ break;
+ case 'odbc':
+ $connect = 'odbc_connect';
+ break;
+ default:
+ $this->stdout('The connection parameter could not be set.');
+ break;
+ }
+
+ $host = '';
+
+ while ($host == '') {
+ $host = $this->getInput('What is the hostname for the database server?', null, 'localhost');
+ if ($host == '') {
+ $this->stdout('The host name you supplied was empty. Please supply a hostname.');
+ }
+ }
+ $login = '';
+
+ while ($login == '') {
+ $login = $this->getInput('What is the database username?', null, 'root');
+
+ if ($login == '') {
+ $this->stdout('The database username you supplied was empty. Please try again.');
+ }
+ }
+ $password = '';
+ $blankPassword = false;
+
+ while ($password == '' && $blankPassword == false) {
+ $password = $this->getInput('What is the database password?');
+ if ($password == '') {
+ $blank = $this->getInput('The password you supplied was empty. Use an empty password?', array('y', 'n'), 'n');
+ if ($blank == 'y')
+ {
+ $blankPassword = true;
+ }
+ }
+ }
+ $database = '';
+
+ while ($database == '') {
+ $database = $this->getInput('What is the name of the database you will be using?', null, 'cake');
+
+ if ($database == '') {
+ $this->stdout('The database name you supplied was empty. Please try again.');
+ }
+ }
+
+ $prefix = '';
+
+ while ($prefix == '') {
+ $prefix = $this->getInput('Enter a table prefix?', null, 'n');
+ }
+ if (low($prefix) == 'n') {
+ $prefix = '';
+ }
+
+ $this->stdout('');
+ $this->hr();
+ $this->stdout('The following database configuration will be created:');
+ $this->hr();
+ $this->stdout("Driver: $driver");
+ $this->stdout("Connection: $connect");
+ $this->stdout("Host: $host");
+ $this->stdout("User: $login");
+ $this->stdout("Pass: " . str_repeat('*', strlen($password)));
+ $this->stdout("Database: $database");
+ $this->stdout("Table prefix: $prefix");
+ $this->hr();
+ $looksGood = $this->getInput('Look okay?', array('y', 'n'), 'y');
+
+ if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
+ $this->bakeDbConfig($driver, $connect, $host, $login, $password, $database, $prefix);
+ } else {
+ $this->stdout('Bake Aborted.');
+ }
+ }
+/**
+ * Creates a database configuration file for Bake.
+ *
+ * @param string $host
+ * @param string $login
+ * @param string $password
+ * @param string $database
+ */
+ function bakeDbConfig( $driver, $connect, $host, $login, $password, $database, $prefix) {
+ $out = "<?php\n";
+ $out .= "class DATABASE_CONFIG {\n\n";
+ $out .= "\tvar \$default = array(\n";
+ $out .= "\t\t'driver' => '{$driver}',\n";
+ $out .= "\t\t'connect' => '{$connect}',\n";
+ $out .= "\t\t'host' => '{$host}',\n";
+ $out .= "\t\t'login' => '{$login}',\n";
+ $out .= "\t\t'password' => '{$password}',\n";
+ $out .= "\t\t'database' => '{$database}', \n";
+ $out .= "\t\t'prefix' => '{$prefix}' \n";
+ $out .= "\t);\n";
+ $out .= "}\n";
+ $out .= "?>";
+ $filename = CONFIGS.'database.php';
+ $this->__createFile($filename, $out);
+ }
+/**
+ * Prompts the user for input, and returns it.
+ *
+ * @param string $prompt Prompt text.
+ * @param mixed $options Array or string of options.
+ * @param string $default Default input value.
+ * @return Either the default value, or the user-provided input.
+ */
+ function getInput($prompt, $options = null, $default = null) {
+ if (!is_array($options)) {
+ $print_options = '';
+ } else {
+ $print_options = '(' . implode('/', $options) . ')';
+ }
+
+ if ($default == null) {
+ $this->stdout('');
+ $this->stdout($prompt . " $print_options \n" . '> ', false);
+ } else {
+ $this->stdout('');
+ $this->stdout($prompt . " $print_options \n" . "[$default] > ", false);
+ }
+ $result = trim(fgets($this->stdin));
+
+ if ($default != null && empty($result)) {
+ return $default;
+ } else {
+ return $result;
+ }
+ }
+/**
+ * Outputs to the stdout filehandle.
+ *
+ * @param string $string String to output.
+ * @param boolean $newline If true, the outputs gets an added newline.
+ */
+ function stdout($string, $newline = true) {
+ if ($newline) {
+ fwrite($this->stdout, $string . "\n");
+ } else {
+ fwrite($this->stdout, $string);
+ }
+ }
+/**
+ * Outputs to the stderr filehandle.
+ *
+ * @param string $string Error text to output.
+ */
+ function stderr($string) {
+ fwrite($this->stderr, $string);
+ }
+/**
+ * Outputs a series of minus characters to the standard output, acts as a visual separator.
+ *
+ */
+ function hr() {
+ $this->stdout('---------------------------------------------------------------');
+ }
+/**
+ * Creates a file at given path.
+ *
+ * @param string $path Where to put the file.
+ * @param string $contents Content to put in the file.
+ * @return Success
+ */
+ function __createFile ($path, $contents) {
+ $path = str_replace('//', '/', $path);
+ echo "\nCreating file $path\n";
+ if (is_file($path) && $this->interactive === true) {
+ fwrite($this->stdout, "File exists, overwrite?" . " {$path} (y/n/q):");
+ $key = trim(fgets($this->stdin));
+
+ if ($key=='q') {
+ fwrite($this->stdout, "Quitting.\n");
+ exit;
+ } elseif ($key == 'a') {
+ $this->dont_ask = true;
+ } elseif ($key == 'y') {
+ } else {
+ fwrite($this->stdout, "Skip" . " {$path}\n");
+ return false;
+ }
+ }
+
+ if ($f = fopen($path, 'w')) {
+ fwrite($f, $contents);
+ fclose($f);
+ fwrite($this->stdout, "Wrote" . "{$path}\n");
+ return true;
+ } else {
+ fwrite($this->stderr, "Error! Could not write to" . " {$path}.\n");
+ return false;
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/bake.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/bake.php
new file mode 100644
index 0000000..2365ee8
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/bake.php
@@ -0,0 +1,2635 @@
+#!/usr/bin/php -q
+<?php
+/* SVN FILE: $Id: bake.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Command-line code generation utility to automate programmer chores.
+ *
+ * Bake is CakePHP's code generation script, which can help you kickstart
+ * application development by writing fully functional skeleton controllers,
+ * models, and views. Going further, Bake can also write Unit Tests for you.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.scripts.bake
+ * @since CakePHP(tm) v 0.10.0.1232
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+ define ('DS', DIRECTORY_SEPARATOR);
+ if (function_exists('ini_set')) {
+ ini_set('display_errors', '1');
+ ini_set('error_reporting', '7');
+ ini_set('max_execution_time',0);
+ }
+
+ $app = null;
+ $root = dirname(dirname(dirname(__FILE__)));
+ $core = null;
+ $here = $argv[0];
+ $help = null;
+ $project = null;
+
+ for ($i = 1; $i < count($argv); $i += 2) {
+ switch ($argv[$i]) {
+ case '-a':
+ case '-app':
+ $app = $argv[$i + 1];
+ break;
+ case '-c':
+ case '-core':
+ $core = $argv[$i + 1];
+ break;
+ case '-r':
+ case '-root':
+ $root = $argv[$i + 1];
+ break;
+ case '-h':
+ case '-help':
+ $help = true;
+ break;
+ case '-p':
+ case '-project':
+ $project = true;
+ $projectPath = $argv[$i + 1];
+ $app = $argv[$i + 1];
+ break;
+ }
+ }
+
+ if (!$app && isset($argv[1])) {
+ $app = $argv[1];
+ } elseif (!$app) {
+ $app = 'app';
+ }
+ if (!is_dir($app)) {
+ $project = true;
+ $projectPath = $app;
+
+ }
+ if ($project) {
+ $app = $projectPath;
+ }
+
+ $shortPath = str_replace($root, '', $app);
+ $shortPath = str_replace('..'.DS, '', $shortPath);
+ $shortPath = str_replace(DS.DS, DS, $shortPath);
+
+ $pathArray = explode(DS, $shortPath);
+ if (end($pathArray) != '') {
+ $appDir = array_pop($pathArray);
+ } else {
+ array_pop($pathArray);
+ $appDir = array_pop($pathArray);
+ }
+ $rootDir = implode(DS, $pathArray);
+ $rootDir = str_replace(DS.DS, DS, $rootDir);
+
+ if (!$rootDir) {
+ $rootDir = $root;
+ $projectPath = $root.DS.$appDir;
+ }
+
+ define ('ROOT', $rootDir);
+ define ('APP_DIR', $appDir);
+ define ('DEBUG', 1);
+
+ if (!empty($core)) {
+ define('CAKE_CORE_INCLUDE_PATH', dirname($core));
+ } else {
+ define('CAKE_CORE_INCLUDE_PATH', $root);
+ }
+
+ if (function_exists('ini_set')) {
+ ini_set('include_path',ini_get('include_path').
+ PATH_SEPARATOR.CAKE_CORE_INCLUDE_PATH.DS.
+ PATH_SEPARATOR.ROOT.DS.APP_DIR.DS);
+ define('APP_PATH', null);
+ define('CORE_PATH', null);
+ } else {
+ define('APP_PATH', ROOT . DS . APP_DIR . DS);
+ define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
+ }
+
+ require_once (CORE_PATH.'cake'.DS.'basics.php');
+ require_once (CORE_PATH.'cake'.DS.'config'.DS.'paths.php');
+ require_once (CORE_PATH.'cake'.DS.'scripts'.DS.'templates'.DS.'skel'.DS.'config'.DS.'core.php');
+ require_once (CORE_PATH.'cake'.DS.'dispatcher.php');
+ uses('object', 'session', 'security', 'configure', 'inflector', 'model'.DS.'connection_manager');
+
+ $pattyCake = new Bake();
+ if ($help === true)
+ {
+ $pattyCake->help();
+ exit();
+ }
+ if ($project === true)
+ {
+ $pattyCake->project($projectPath);
+ exit();
+ }
+ $pattyCake->main();
+/**
+ * Bake is a command-line code generation utility for automating programmer chores.
+ *
+ * @package cake
+ * @subpackage cake.cake.scripts
+ */
+class Bake {
+
+/**
+ * Standard input stream.
+ *
+ * @var filehandle
+ */
+ var $stdin;
+/**
+ * Standard output stream.
+ *
+ * @var filehandle
+ */
+ var $stdout;
+/**
+ * Standard error stream.
+ *
+ * @var filehandle
+ */
+ var $stderr;
+/**
+ * Associated controller name.
+ *
+ * @var string
+ */
+ var $controllerName = null;
+/**
+ * If true, Bake will ask for permission to perform actions.
+ *
+ * @var boolean
+ */
+ var $interactive = false;
+
+ var $__modelAlias = false;
+/**
+ * Private helper function for constructor
+ * @access private
+ */
+ function __construct() {
+ $this->stdin = fopen('php://stdin', 'r');
+ $this->stdout = fopen('php://stdout', 'w');
+ $this->stderr = fopen('php://stderr', 'w');
+ $this->welcome();
+ }
+/**
+ * Constructor.
+ *
+ * @return Bake
+ */
+ function Bake() {
+ return $this->__construct();
+ }
+/**
+ * Main-loop method.
+ *
+ */
+ function main() {
+
+ $this->stdout('');
+ $this->stdout('');
+ $this->stdout('Baking...');
+ $this->hr();
+ $this->stdout('Name: '. APP_DIR);
+ $this->stdout('Path: '. ROOT.DS.APP_DIR);
+ $this->hr();
+
+ if (!file_exists(CONFIGS.'database.php')) {
+ $this->stdout('');
+ $this->stdout('Your database configuration was not found. Take a moment to create one:');
+ $this->doDbConfig();
+ }
+ require_once (CONFIGS.'database.php');
+ $this->stdout('[M]odel');
+ $this->stdout('[C]ontroller');
+ $this->stdout('[V]iew');
+ $invalidSelection = true;
+
+ while ($invalidSelection) {
+ $classToBake = strtoupper($this->getInput('What would you like to Bake?', array('M', 'V', 'C')));
+ switch($classToBake) {
+ case 'M':
+ $invalidSelection = false;
+ $this->doModel();
+ break;
+ case 'V':
+ $invalidSelection = false;
+ $this->doView();
+ break;
+ case 'C':
+ $invalidSelection = false;
+ $this->doController();
+ break;
+ default:
+ $this->stdout('You have made an invalid selection. Please choose a type of class to Bake by entering M, V, or C.');
+ }
+ }
+ }
+/**
+ * Database configuration setup.
+ *
+ */
+ function doDbConfig() {
+ $this->hr();
+ $this->stdout('Database Configuration:');
+ $this->hr();
+
+ $driver = '';
+
+ while ($driver == '') {
+ $driver = $this->getInput('What database driver would you like to use?', array('mysql','mysqli','mssql','sqlite','postgres', 'odbc'), 'mysql');
+ if ($driver == '') {
+ $this->stdout('The database driver supplied was empty. Please supply a database driver.');
+ }
+ }
+
+ switch($driver) {
+ case 'mysql':
+ $connect = 'mysql_connect';
+ break;
+ case 'mysqli':
+ $connect = 'mysqli_connect';
+ break;
+ case 'mssql':
+ $connect = 'mssql_connect';
+ break;
+ case 'sqlite':
+ $connect = 'sqlite_open';
+ break;
+ case 'postgres':
+ $connect = 'pg_connect';
+ break;
+ case 'odbc':
+ $connect = 'odbc_connect';
+ break;
+ default:
+ $this->stdout('The connection parameter could not be set.');
+ break;
+ }
+
+ $host = '';
+
+ while ($host == '') {
+ $host = $this->getInput('What is the hostname for the database server?', null, 'localhost');
+ if ($host == '') {
+ $this->stdout('The host name you supplied was empty. Please supply a hostname.');
+ }
+ }
+ $login = '';
+
+ while ($login == '') {
+ $login = $this->getInput('What is the database username?', null, 'root');
+
+ if ($login == '') {
+ $this->stdout('The database username you supplied was empty. Please try again.');
+ }
+ }
+ $password = '';
+ $blankPassword = false;
+
+ while ($password == '' && $blankPassword == false) {
+ $password = $this->getInput('What is the database password?');
+ if ($password == '') {
+ $blank = $this->getInput('The password you supplied was empty. Use an empty password?', array('y', 'n'), 'n');
+ if ($blank == 'y')
+ {
+ $blankPassword = true;
+ }
+ }
+ }
+ $database = '';
+
+ while ($database == '') {
+ $database = $this->getInput('What is the name of the database you will be using?', null, 'cake');
+
+ if ($database == '') {
+ $this->stdout('The database name you supplied was empty. Please try again.');
+ }
+ }
+
+ $prefix = '';
+
+ while ($prefix == '') {
+ $prefix = $this->getInput('Enter a table prefix?', null, 'n');
+ }
+ if (low($prefix) == 'n') {
+ $prefix = '';
+ }
+
+ $this->stdout('');
+ $this->hr();
+ $this->stdout('The following database configuration will be created:');
+ $this->hr();
+ $this->stdout("Driver: $driver");
+ $this->stdout("Connection: $connect");
+ $this->stdout("Host: $host");
+ $this->stdout("User: $login");
+ $this->stdout("Pass: " . str_repeat('*', strlen($password)));
+ $this->stdout("Database: $database");
+ $this->stdout("Table prefix: $prefix");
+ $this->hr();
+ $looksGood = $this->getInput('Look okay?', array('y', 'n'), 'y');
+
+ if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
+ $this->bakeDbConfig($driver, $connect, $host, $login, $password, $database, $prefix);
+ } else {
+ $this->stdout('Bake Aborted.');
+ }
+ }
+/**
+ * Action to create a Model.
+ *
+ */
+ function doModel()
+ {
+ $this->hr();
+ $this->stdout('Model Bake:');
+ $this->hr();
+ $this->interactive = true;
+
+ $useTable = null;
+ $primaryKey = 'id';
+ $validate = array();
+ $associations = array();
+ $useDbConfig = 'default';
+ $this->__doList($useDbConfig);
+
+
+ $enteredModel = '';
+
+ while ($enteredModel == '') {
+ $enteredModel = $this->getInput('Enter a number from the list above, or type in the name of another model.');
+
+ if ($enteredModel == '' || intval($enteredModel) > count($this->__modelNames)) {
+ $this->stdout('Error:');
+ $this->stdout("The model name you supplied was empty, or the number \nyou selected was not an option. Please try again.");
+ $enteredModel = '';
+ }
+ }
+
+ if (intval($enteredModel) > 0 && intval($enteredModel) <= count($this->__modelNames)) {
+ $currentModelName = $this->__modelNames[intval($enteredModel) - 1];
+ } else {
+ $currentModelName = $enteredModel;
+ }
+
+ $db =& ConnectionManager::getDataSource($useDbConfig);
+
+ $useTable = Inflector::tableize($currentModelName);
+ $fullTableName = $db->fullTableName($useTable, false);
+ if (array_search($useTable, $this->__tables) === false) {
+ $this->stdout("\nGiven your model named '$currentModelName', Cake would expect a database table named '" . $fullTableName . "'.");
+ $tableIsGood = $this->getInput('do you want to use this table?', array('y','n'), 'y');
+ }
+
+ if (low($tableIsGood) == 'n' || low($tableIsGood) == 'no') {
+ $useTable = $this->getInput('What is the name of the table (enter "null" to use NO table)?');
+ }
+ $tableIsGood = false;
+ while ($tableIsGood == false && low($useTable) != 'null') {
+ if (is_array($this->__tables) && !in_array($useTable, $this->__tables)) {
+ $fullTableName = $db->fullTableName($useTable, false);
+ $this->stdout($fullTableName . ' does not exist.');
+ $useTable = $this->getInput('What is the name of the table (enter "null" to use NO table)?');
+ $tableIsGood = false;
+ } else {
+ $tableIsGood = true;
+ }
+ }
+ $wannaDoValidation = $this->getInput('Would you like to supply validation criteria for the fields in your model?', array('y','n'), 'y');
+
+ if (in_array($useTable, $this->__tables)) {
+ loadModel();
+ $tempModel = new Model(false, $useTable);
+ $modelFields = $db->describe($tempModel);
+
+ if (!array_key_exists('id', $modelFields)) {
+ foreach ($modelFields as $name => $field) {
+ break;
+ }
+ $primaryKey = $this->getInput('What is the primaryKey?', null, $name);
+ }
+ }
+ $validate = array();
+
+ if (array_search($useTable, $this->__tables) !== false && (low($wannaDoValidation) == 'y' || low($wannaDoValidation) == 'yes')) {
+ foreach ($modelFields as $name => $field) {
+ $this->stdout('');
+ $prompt = 'Name: ' . $name . "\n";
+ $prompt .= 'Type: ' . $field['type'] . "\n";
+ $prompt .= '---------------------------------------------------------------'."\n";
+ $prompt .= 'Please select one of the following validation options:'."\n";
+ $prompt .= '---------------------------------------------------------------'."\n";
+ $prompt .= "1- VALID_NOT_EMPTY\n";
+ $prompt .= "2- VALID_EMAIL\n";
+ $prompt .= "3- VALID_NUMBER\n";
+ $prompt .= "4- VALID_YEAR\n";
+ $prompt .= "5- Do not do any validation on this field.\n\n";
+ $prompt .= "... or enter in a valid regex validation string.\n\n";
+
+ if ($field['null'] == 1 || $name == $primaryKey || $name == 'created' || $name == 'modified') {
+ $validation = $this->getInput($prompt, null, '5');
+ } else {
+ $validation = $this->getInput($prompt, null, '1');
+ }
+
+ switch ($validation) {
+ case '1':
+ $validate[$name] = 'VALID_NOT_EMPTY';
+ break;
+ case '2':
+ $validate[$name] = 'VALID_EMAIL';
+ break;
+ case '3':
+ $validate[$name] = 'VALID_NUMBER';
+ break;
+ case '4':
+ $validate[$name] = 'VALID_YEAR';
+ break;
+ case '5':
+ break;
+ default:
+ $validate[$name] = $validation;
+ break;
+ }
+ }
+ }
+
+ $wannaDoAssoc = $this->getInput('Would you like to define model associations (hasMany, hasOne, belongsTo, etc.)?', array('y','n'), 'y');
+
+ if ((low($wannaDoAssoc) == 'y' || low($wannaDoAssoc) == 'yes')) {
+ $this->stdout('One moment while I try to detect any associations...');
+ $possibleKeys = array();
+ $i = 0;
+ foreach ($modelFields as $name => $field) {
+ $offset = strpos($name, '_id');
+ if ($name != $primaryKey && $offset !== false) {
+ $tmpModelName = $this->__modelNameFromKey($name);
+ $associations['belongsTo'][$i]['alias'] = $tmpModelName;
+ $associations['belongsTo'][$i]['className'] = $tmpModelName;
+ $associations['belongsTo'][$i]['foreignKey'] = $name;
+ $i++;
+ }
+ }
+ $i = 0;
+ $j = 0;
+ foreach ($this->__tables as $otherTable) {
+ $tempOtherModel = & new Model(false, $otherTable);
+ $modelFieldsTemp = $db->describe($tempOtherModel);
+ foreach ($modelFieldsTemp as $name => $field) {
+ if ($field['type'] == 'integer' || $field['type'] == 'string') {
+ $possibleKeys[$otherTable][] = $name;
+ }
+ if ($name != $primaryKey && $name == $this->__modelKey($currentModelName)) {
+ $tmpModelName = $this->__modelName($otherTable);
+ $associations['hasOne'][$j]['alias'] = $tmpModelName;
+ $associations['hasOne'][$j]['className'] = $tmpModelName;
+ $associations['hasOne'][$j]['foreignKey'] = $name;
+
+ $associations['hasMany'][$j]['alias'] = $tmpModelName;
+ $associations['hasMany'][$j]['className'] = $tmpModelName;
+ $associations['hasMany'][$j]['foreignKey'] = $name;
+ $j++;
+ }
+ }
+ $offset = strpos($otherTable, $useTable . '_');
+ if ($offset !== false) {
+ $offset = strlen($useTable . '_');
+ $tmpModelName = $this->__modelName(substr($otherTable, $offset));
+ $associations['hasAndBelongsToMany'][$i]['alias'] = $tmpModelName;
+ $associations['hasAndBelongsToMany'][$i]['className'] = $tmpModelName;
+ $associations['hasAndBelongsToMany'][$i]['foreignKey'] = $this->__modelKey($currentModelName);
+ $associations['hasAndBelongsToMany'][$i]['associationForeignKey'] = $this->__modelKey($tmpModelName);
+ $associations['hasAndBelongsToMany'][$i]['joinTable'] = $otherTable;
+ $i++;
+ }
+ $offset = strpos($otherTable, '_' . $useTable);
+ if ($offset !== false) {
+ $tmpModelName = $this->__modelName(substr($otherTable, 0, $offset));
+ $associations['hasAndBelongsToMany'][$i]['alias'] = $tmpModelName;
+ $associations['hasAndBelongsToMany'][$i]['className'] = $tmpModelName;
+ $associations['hasAndBelongsToMany'][$i]['foreignKey'] = $this->__modelKey($currentModelName);
+ $associations['hasAndBelongsToMany'][$i]['associationForeignKey'] = $this->__modelKey($tmpModelName);
+ $associations['hasAndBelongsToMany'][$i]['joinTable'] = $otherTable;
+ $i++;
+ }
+ }
+ $this->stdout('Done.');
+ $this->hr();
+ if (empty($associations)) {
+ $this->stdout('None found.');
+ } else {
+ $this->stdout('Please confirm the following associations:');
+ $this->hr();
+ if (!empty($associations['belongsTo'])) {
+ $count = count($associations['belongsTo']);
+ for ($i = 0; $i < $count; $i++) {
+ if ($currentModelName == $associations['belongsTo'][$i]['alias']) {
+ $response = $this->getInput("{$currentModelName} belongsTo {$associations['belongsTo'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y');
+ if ('y' == low($response) || 'yes' == low($response)) {
+ $associations['belongsTo'][$i]['alias'] = $this->getInput("So what is the alias?", null, $associations['belongsTo'][$i]['alias']);
+ }
+ if ($currentModelName != $associations['belongsTo'][$i]['alias']) {
+ $response = $this->getInput("$currentModelName belongsTo {$associations['belongsTo'][$i]['alias']}?", array('y','n'), 'y');
+ } else {
+ $response = 'n';
+ }
+ } else {
+ $response = $this->getInput("$currentModelName belongsTo {$associations['belongsTo'][$i]['alias']}?", array('y','n'), 'y');
+ }
+ if ('n' == low($response) || 'no' == low($response)) {
+ unset($associations['belongsTo'][$i]);
+ }
+ }
+ $associations['belongsTo'] = array_merge($associations['belongsTo']);
+ }
+
+ if (!empty($associations['hasOne'])) {
+ $count = count($associations['hasOne']);
+ for ($i = 0; $i < $count; $i++) {
+ if ($currentModelName == $associations['hasOne'][$i]['alias']) {
+ $response = $this->getInput("{$currentModelName} hasOne {$associations['hasOne'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y');
+ if ('y' == low($response) || 'yes' == low($response)) {
+ $associations['hasOne'][$i]['alias'] = $this->getInput("So what is the alias?", null, $associations['hasOne'][$i]['alias']);
+ }
+ if ($currentModelName != $associations['hasOne'][$i]['alias']) {
+ $response = $this->getInput("$currentModelName hasOne {$associations['hasOne'][$i]['alias']}?", array('y','n'), 'y');
+ } else {
+ $response = 'n';
+ }
+ } else {
+ $response = $this->getInput("$currentModelName hasOne {$associations['hasOne'][$i]['alias']}?", array('y','n'), 'y');
+ }
+ if ('n' == low($response) || 'no' == low($response)) {
+ unset($associations['hasOne'][$i]);
+ }
+ }
+ $associations['hasOne'] = array_merge($associations['hasOne']);
+ }
+
+ if (!empty($associations['hasMany'])) {
+ $count = count($associations['hasMany']);
+ for ($i = 0; $i < $count; $i++) {
+ if ($currentModelName == $associations['hasMany'][$i]['alias']) {
+ $response = $this->getInput("{$currentModelName} hasMany {$associations['hasMany'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y');
+ if ('y' == low($response) || 'yes' == low($response)) {
+ $associations['hasMany'][$i]['alias'] = $this->getInput("So what is the alias?", null, $associations['hasMany'][$i]['alias']);
+ }
+ if ($currentModelName != $associations['hasMany'][$i]['alias']) {
+ $response = $this->getInput("$currentModelName hasMany {$associations['hasMany'][$i]['alias']}?", array('y','n'), 'y');
+ } else {
+ $response = 'n';
+ }
+ } else {
+ $response = $this->getInput("$currentModelName hasMany {$associations['hasMany'][$i]['alias']}?", array('y','n'), 'y');
+ }
+ if ('n' == low($response) || 'no' == low($response)) {
+ unset($associations['hasMany'][$i]);
+ }
+ }
+ $associations['hasMany'] = array_merge($associations['hasMany']);
+ }
+
+ if (!empty($associations['hasAndBelongsToMany'])) {
+ $count = count($associations['hasAndBelongsToMany']);
+ for ($i = 0; $i < $count; $i++) {
+ if ($currentModelName == $associations['hasAndBelongsToMany'][$i]['alias']) {
+ $response = $this->getInput("{$currentModelName} hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y');
+ if ('y' == low($response) || 'yes' == low($response)) {
+ $associations['hasAndBelongsToMany'][$i]['alias'] = $this->getInput("So what is the alias?", null, $associations['hasAndBelongsToMany'][$i]['alias']);
+ }
+ if ($currentModelName != $associations['hasAndBelongsToMany'][$i]['alias']) {
+ $response = $this->getInput("$currentModelName hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}?", array('y','n'), 'y');
+ } else {
+ $response = 'n';
+ }
+ } else {
+ $response = $this->getInput("$currentModelName hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}?", array('y','n'), 'y');
+ }
+ if ('n' == low($response) || 'no' == low($response)) {
+ unset($associations['hasAndBelongsToMany'][$i]);
+ }
+ }
+ $associations['hasAndBelongsToMany'] = array_merge($associations['hasAndBelongsToMany']);
+ }
+ }
+ $wannaDoMoreAssoc = $this->getInput('Would you like to define some additional model associations?', array('y','n'), 'y');
+
+ while ((low($wannaDoMoreAssoc) == 'y' || low($wannaDoMoreAssoc) == 'yes')) {
+ $assocs = array(1=>'belongsTo', 2=>'hasOne', 3=>'hasMany', 4=>'hasAndBelongsToMany');
+ $bad = true;
+ while ($bad) {
+ $this->stdout('What is the association type?');
+ $prompt = "1- belongsTo\n";
+ $prompt .= "2- hasOne\n";
+ $prompt .= "3- hasMany\n";
+ $prompt .= "4- hasAndBelongsToMany\n";
+ $assocType = intval($this->getInput($prompt, null, null));
+
+ if (intval($assocType) < 1 || intval($assocType) > 4) {
+ $this->stdout('The selection you entered was invalid. Please enter a number between 1 and 4.');
+ } else {
+ $bad = false;
+ }
+ }
+ $this->stdout('For the following options be very careful to match your setup exactly. Any spelling mistakes will cause errors.');
+ $this->hr();
+ $associationName = $this->getInput('What is the name of this association?');
+ $className = $this->getInput('What className will '.$associationName.' use?', null, $associationName );
+ $suggestedForeignKey = null;
+ if ($assocType == '1') {
+ $showKeys = $possibleKeys[$useTable];
+ $suggestedForeignKey = $this->__modelKey($associationName);
+ } else {
+ $otherTable = Inflector::tableize($className);
+ if (in_array($otherTable, $this->__tables)) {
+ if ($assocType < '4') {
+ $showKeys = $possibleKeys[$otherTable];
+ } else {
+ $showKeys = null;
+ }
+ } else {
+ $otherTable = $this->getInput('What is the table for this class?');
+ $showKeys = $possibleKeys[$otherTable];
+ }
+ $suggestedForeignKey = $this->__modelKey($currentModelName);
+ }
+ if (!empty($showKeys)) {
+ $this->stdout('A helpful List of possible keys');
+ for ($i = 0; $i < count($showKeys); $i++) {
+ $this->stdout($i + 1 . ". " . $showKeys[$i]);
+ }
+ $foreignKey = $this->getInput('What is the foreignKey? Choose a number.');
+ if (intval($foreignKey) > 0 && intval($foreignKey) <= $i ) {
+ $foreignKey = $showKeys[intval($foreignKey) - 1];
+ }
+ }
+ if (!isset($foreignKey)) {
+ $foreignKey = $this->getInput('What is the foreignKey? Specify your own.', null, $suggestedForeignKey);
+ }
+ if ($assocType == '4') {
+ $associationForeignKey = $this->getInput('What is the associationForeignKey?', null, $this->__modelKey($currentModelName));
+ $joinTable = $this->getInput('What is the joinTable?');
+ }
+ $associations[$assocs[$assocType]] = array_values($associations[$assocs[$assocType]]);
+ $count = count($associations[$assocs[$assocType]]);
+ $i = ($count > 0) ? $count : 0;
+ $associations[$assocs[$assocType]][$i]['alias'] = $associationName;
+ $associations[$assocs[$assocType]][$i]['className'] = $className;
+ $associations[$assocs[$assocType]][$i]['foreignKey'] = $foreignKey;
+ if ($assocType == '4') {
+ $associations[$assocs[$assocType]][$i]['associationForeignKey'] = $associationForeignKey;
+ $associations[$assocs[$assocType]][$i]['joinTable'] = $joinTable;
+ }
+ $wannaDoMoreAssoc = $this->getInput('Define another association?', array('y','n'), 'y');
+ }
+ }
+ $this->stdout('');
+ $this->hr();
+ $this->stdout('The following model will be created:');
+ $this->hr();
+ $this->stdout("Model Name: $currentModelName");
+ $this->stdout("DB Connection: " . ($usingDefault ? 'default' : $useDbConfig));
+ $this->stdout("DB Table: " . $fullTableName);
+ if ($primaryKey != 'id') {
+ $this->stdout("Primary Key: " . $primaryKey);
+ }
+ $this->stdout("Validation: " . print_r($validate, true));
+
+ if (!empty($associations)) {
+ $this->stdout("Associations:");
+
+ if (count($associations['belongsTo'])) {
+ for ($i = 0; $i < count($associations['belongsTo']); $i++) {
+ $this->stdout(" $currentModelName belongsTo {$associations['belongsTo'][$i]['alias']}");
+ }
+ }
+
+ if (count($associations['hasOne'])) {
+ for ($i = 0; $i < count($associations['hasOne']); $i++) {
+ $this->stdout(" $currentModelName hasOne {$associations['hasOne'][$i]['alias']}");
+ }
+ }
+
+ if (count($associations['hasMany'])) {
+ for ($i = 0; $i < count($associations['hasMany']); $i++) {
+ $this->stdout(" $currentModelName hasMany {$associations['hasMany'][$i]['alias']}");
+ }
+ }
+
+ if (count($associations['hasAndBelongsToMany'])) {
+ for ($i = 0; $i < count($associations['hasAndBelongsToMany']); $i++) {
+ $this->stdout(" $currentModelName hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}");
+ }
+ }
+ }
+ $this->hr();
+ $looksGood = $this->getInput('Look okay?', array('y','n'), 'y');
+
+ if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
+ if ($useTable == Inflector::tableize($currentModelName)) {
+ $useTable = null;
+ }
+ $this->bakeModel($currentModelName, $useDbConfig, $useTable, $primaryKey, $validate, $associations);
+
+ if ($this->doUnitTest()) {
+ $this->bakeUnitTest('model', $currentModelName);
+ }
+ } else {
+ $this->stdout('Bake Aborted.');
+ }
+ }
+/**
+ * Action to create a View.
+ *
+ */
+ function doView() {
+ $this->hr();
+ $this->stdout('View Bake:');
+ $this->hr();
+ $uses = array();
+ $wannaUseSession = 'y';
+ $wannaDoScaffold = 'y';
+
+
+ $useDbConfig = 'default';
+ $this->__doList($useDbConfig, 'Controllers');
+
+ $enteredController = '';
+
+ while ($enteredController == '') {
+ $enteredController = $this->getInput('Enter a number from the list above, or type in the name of another controller.');
+
+ if ($enteredController == '' || intval($enteredController) > count($this->__controllerNames)) {
+ $this->stdout('Error:');
+ $this->stdout("The Controller name you supplied was empty, or the number \nyou selected was not an option. Please try again.");
+ $enteredController = '';
+ }
+ }
+
+ if (intval($enteredController) > 0 && intval($enteredController) <= count($this->__controllerNames) ) {
+ $controllerName = $this->__controllerNames[intval($enteredController) - 1];
+ } else {
+ $controllerName = Inflector::camelize($enteredController);
+ }
+
+ $controllerPath = low(Inflector::underscore($controllerName));
+
+ $doItInteractive = $this->getInput("Would you like bake to build your views interactively?\nWarning: Choosing no will overwrite {$controllerClassName} views if it exist.", array('y','n'), 'y');
+
+ if (low($doItInteractive) == 'y' || low($doItInteractive) == 'yes') {
+ $this->interactive = true;
+ $wannaDoScaffold = $this->getInput("Would you like to create some scaffolded views (index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller and model classes (including associated models).", array('y','n'), 'n');
+ }
+
+ $admin = null;
+ $admin_url = null;
+ if (low($wannaDoScaffold) == 'y' || low($wannaDoScaffold) == 'yes') {
+ $wannaDoAdmin = $this->getInput("Would you like to create the views for admin routing?", array('y','n'), 'n');
+ }
+
+ if ((low($wannaDoAdmin) == 'y' || low($wannaDoAdmin) == 'yes')) {
+ require(CONFIGS.'core.php');
+ if (defined('CAKE_ADMIN')) {
+ $admin = CAKE_ADMIN . '_';
+ $admin_url = '/'.CAKE_ADMIN;
+ } else {
+ $adminRoute = '';
+ $this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
+ $this->stdout('What would you like the admin route to be?');
+ $this->stdout('Example: www.example.com/admin/controller');
+ while ($adminRoute == '') {
+ $adminRoute = $this->getInput("What would you like the admin route to be?", null, 'admin');
+ }
+ if ($this->__addAdminRoute($adminRoute) !== true) {
+ $this->stdout('Unable to write to /app/config/core.php.');
+ $this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
+ exit();
+ } else {
+ $admin = $adminRoute . '_';
+ $admin_url = '/'.$adminRoute;
+ }
+ }
+ }
+ if (low($wannaDoScaffold) == 'y' || low($wannaDoScaffold) == 'yes') {
+ $file = CONTROLLERS . $controllerPath . '_controller.php';
+
+ if (!file_exists($file)) {
+ $shortPath = str_replace(ROOT, null, $file);
+ $shortPath = str_replace('../', '', $shortPath);
+ $shortPath = str_replace('//', '/', $shortPath);
+ $this->stdout('');
+ $this->stdout("The file '$shortPath' could not be found.\nIn order to scaffold, you'll need to first create the controller. ");
+ $this->stdout('');
+ die();
+ } else {
+ uses('controller'.DS.'controller');
+ loadController($controllerName);
+ if ($admin) {
+ $this->__bakeViews($controllerName, $controllerPath, $admin, $admin_url);
+ }
+ $this->__bakeViews($controllerName, $controllerPath, null, null);
+
+ $this->hr();
+ $this->stdout('');
+ $this->stdout('View Scaffolding Complete.'."\n");
+ }
+ } else {
+ $actionName = '';
+
+ while ($actionName == '') {
+ $actionName = $this->getInput('Action Name? (use camelCased function name)');
+
+ if ($actionName == '') {
+ $this->stdout('The action name you supplied was empty. Please try again.');
+ }
+ }
+ $this->stdout('');
+ $this->hr();
+ $this->stdout('The following view will be created:');
+ $this->hr();
+ $this->stdout("Controller Name: $controllerName");
+ $this->stdout("Action Name: $actionName");
+ $this->stdout("Path: app/views/" . $controllerPath . DS . Inflector::underscore($actionName) . '.thtml');
+ $this->hr();
+ $looksGood = $this->getInput('Look okay?', array('y','n'), 'y');
+
+ if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
+ $this->bakeView($controllerName, $actionName);
+ } else {
+ $this->stdout('Bake Aborted.');
+ }
+ }
+ }
+
+ function __bakeViews($controllerName, $controllerPath, $admin= null, $admin_url = null) {
+ $controllerClassName = $controllerName.'Controller';
+ $controllerObj = & new $controllerClassName();
+
+ if (!in_array('Html', $controllerObj->helpers)) {
+ $controllerObj->helpers[] = 'Html';
+ }
+ if (!in_array('Form', $controllerObj->helpers)) {
+ $controllerObj->helpers[] = 'Form';
+ }
+
+ $controllerObj->constructClasses();
+ $currentModelName = $controllerObj->modelClass;
+ $this->__modelClass = $currentModelName;
+ $modelKey = Inflector::underscore($currentModelName);
+ $modelObj =& ClassRegistry::getObject($modelKey);
+ $singularName = $this->__singularName($currentModelName);
+ $pluralName = $this->__pluralName($currentModelName);
+ $singularHumanName = $this->__singularHumanName($currentModelName);
+ $pluralHumanName = $this->__pluralHumanName($controllerName);
+
+ $fieldNames = $controllerObj->generateFieldNames(null, false);
+ $indexView = null;
+
+ if (!empty($modelObj->alias)) {
+ foreach ($modelObj->alias as $key => $value) {
+ $alias[] = $key;
+ }
+ }
+ $indexView .= "<div class=\"{$pluralName}\">\n";
+ $indexView .= "<h2>List " . $pluralHumanName . "</h2>\n\n";
+ $indexView .= "<table cellpadding=\"0\" cellspacing=\"0\">\n";
+ $indexView .= "<tr>\n";
+
+ foreach ($fieldNames as $fieldName) {
+ $indexView .= "\t<th>".$fieldName['prompt']."</th>\n";
+ }
+ $indexView .= "\t<th>Actions</th>\n";
+ $indexView .= "</tr>\n";
+ $indexView .= "<?php foreach (\${$pluralName} as \${$singularName}): ?>\n";
+ $indexView .= "<tr>\n";
+ $count = 0;
+ foreach ($fieldNames as $field => $value) {
+ if (isset($value['foreignKey'])) {
+ $otherModelName = $this->__modelName($value['model']);
+ $otherModelKey = Inflector::underscore($otherModelName);
+ $otherModelObj =& ClassRegistry::getObject($otherModelKey);
+ $otherControllerName = $this->__controllerName($otherModelName);
+ $otherControllerPath = $this->__controllerPath($otherControllerName);
+ if (is_object($otherModelObj)) {
+ $displayField = $otherModelObj->getDisplayField();
+ $indexView .= "\t<td>&nbsp;<?php echo \$html->link(\$".$singularName."['{$alias[$count]}']['{$displayField}'], '{$admin_url}/" . $otherControllerPath . "/view/' .\$".$singularName."['{$alias[$count]}']['{$otherModelObj->primaryKey}'])?></td>\n";
+ } else {
+ $indexView .= "\t<td><?php echo \$".$singularName."['{$modelObj->name}']['{$field}']; ?></td>\n";
+ }
+ $count++;
+ } else {
+ $indexView .= "\t<td><?php echo \$".$singularName."['{$modelObj->name}']['{$field}']; ?></td>\n";
+ }
+ }
+ $indexView .= "\t<td class=\"actions\">\n";
+ $indexView .= "\t\t<?php echo \$html->link('View','{$admin_url}/{$controllerPath}/view/' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'])?>\n";
+ $indexView .= "\t\t<?php echo \$html->link('Edit','{$admin_url}/{$controllerPath}/edit/' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'])?>\n";
+ $indexView .= "\t\t<?php echo \$html->link('Delete','{$admin_url}/{$controllerPath}/delete/' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'], null, 'Are you sure you want to delete id ' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'])?>\n";
+ $indexView .= "\t</td>\n";
+ $indexView .= "</tr>\n";
+ $indexView .= "<?php endforeach; ?>\n";
+ $indexView .= "</table>\n\n";
+ $indexView .= "<ul class=\"actions\">\n";
+ $indexView .= "\t<li><?php echo \$html->link('New {$singularHumanName}', '{$admin_url}/{$controllerPath}/add'); ?></li>\n";
+ $indexView .= "</ul>\n";
+ $indexView .= "</div>";
+ $viewView = null;
+ $viewView .= "<div class=\"{$singularName}\">\n";
+ $viewView .= "<h2>View " . $singularHumanName . "</h2>\n\n";
+ $viewView .= "<dl>\n";
+ $count = 0;
+ foreach ($fieldNames as $field => $value) {
+ $viewView .= "\t<dt>" . $value['prompt'] . "</dt>\n";
+ if (isset($value['foreignKey'])) {
+ $otherModelName = $this->__modelName($value['model']);
+ $otherModelKey = Inflector::underscore($otherModelName);
+ $otherModelObj =& ClassRegistry::getObject($otherModelKey);
+ $otherControllerName = $this->__controllerName($otherModelName);
+ $otherControllerPath = $this->__controllerPath($otherControllerName);
+ $displayField = $otherModelObj->getDisplayField();
+ $viewView .= "\t<dd>&nbsp;<?php echo \$html->link(\$".$singularName."['{$alias[$count]}']['{$displayField}'], '{$admin_url}/" . $otherControllerPath . "/view/' .\$".$singularName."['{$alias[$count]}']['{$otherModelObj->primaryKey}'])?></dd>\n";
+ $count++;
+ } else {
+ $viewView .= "\t<dd>&nbsp;<?php echo \$".$singularName."['{$modelObj->name}']['{$field}']?></dd>\n";
+ }
+ }
+ $viewView .= "</dl>\n";
+ $viewView .= "<ul class=\"actions\">\n";
+ $viewView .= "\t<li><?php echo \$html->link('Edit " . $singularHumanName . "', '{$admin_url}/{$controllerPath}/edit/' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}']) ?> </li>\n";
+ $viewView .= "\t<li><?php echo \$html->link('Delete " . $singularHumanName . "', '{$admin_url}/{$controllerPath}/delete/' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'], null, 'Are you sure you want to delete: id ' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'] . '?') ?> </li>\n";
+ $viewView .= "\t<li><?php echo \$html->link('List " . $pluralHumanName ."', '{$admin_url}/{$controllerPath}/index') ?> </li>\n";
+ $viewView .= "\t<li><?php echo \$html->link('New " . $singularHumanName . "', '{$admin_url}/{$controllerPath}/add') ?> </li>\n";
+ foreach ( $fieldNames as $field => $value ) {
+ if ( isset( $value['foreignKey'] ) ) {
+ $otherModelName = $this->__modelName($value['model']);
+ if ($otherModelName != $currentModelName) {
+ $otherControllerName = $this->__controllerName($otherModelName);
+ $otherControllerPath = $this->__controllerPath($otherControllerName);
+ $otherSingularHumanName = $this->__singularHumanName($value['controller']);
+ $otherPluralHumanName = $this->__pluralHumanName($value['controller']);
+ $viewView .= "\t<li><?php echo \$html->link('List " . $otherSingularHumanName . "', '{$admin_url}/" . $otherControllerPath . "/index/')?> </li>\n";
+ $viewView .= "\t<li><?php echo \$html->link('New " . $otherPluralHumanName . "', '{$admin_url}/" . $otherControllerPath . "/add/')?> </li>\n";
+ }
+ }
+ }
+ $viewView .= "</ul>\n\n";
+
+ $viewView .= "</div>\n";
+
+
+ foreach ($modelObj->hasOne as $associationName => $relation) {
+ $new = true;
+
+ $otherModelName = $this->__modelName($relation['className']);
+ $otherControllerName = $this->__controllerName($otherModelName);
+ $otherControllerPath = $this->__controllerPath($otherControllerName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralHumanName = $this->__pluralHumanName($associationName);
+ $otherSingularHumanName = $this->__singularHumanName($associationName);
+
+ $viewView .= "<div class=\"related\">\n";
+ $viewView .= "<h3>Related " . $otherPluralHumanName . "</h3>\n";
+ $viewView .= "<?php if (!empty(\$".$singularName."['{$associationName}'])): ?>\n";
+ $viewView .= "<dl>\n";
+ $viewView .= "\t<?php foreach (\$".$singularName."['{$associationName}'] as \$field => \$value): ?>\n";
+ $viewView .= "\t\t<dt><?php echo \$field ?></dt>\n";
+ $viewView .= "\t\t<dd>&nbsp;<?php echo \$value ?></dd>\n";
+ $viewView .= "\t<?php endforeach; ?>\n";
+ $viewView .= "</dl>\n";
+ $viewView .= "<?php endif; ?>\n";
+ $viewView .= "<ul class=\"actions\">\n";
+ $viewView .= "\t<li><?php echo \$html->link('Edit " . $otherSingularHumanName . "', '{$admin_url}/" .$otherControllerPath."/edit/' . \$".$singularName."['{$associationName}']['" . $modelObj->{$otherModelName}->primaryKey . "']);?></li>\n";
+ $viewView .= "\t<li><?php echo \$html->link('New " . $otherSingularHumanName . "', '{$admin_url}/" .$otherControllerPath."/add/');?> </li>\n";
+ $viewView .= "</ul>\n";
+ $viewView .= "</div>\n";
+ }
+ $relations = array_merge($modelObj->hasMany, $modelObj->hasAndBelongsToMany);
+
+ foreach ($relations as $associationName => $relation) {
+ $otherModelName = $this->__modelName($relation['className']);
+ $otherControllerName = $this->__controllerName($otherModelName);
+ $otherControllerPath = $this->__controllerPath($otherControllerName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralHumanName = $this->__pluralHumanName($associationName);
+ $otherSingularHumanName = $this->__singularHumanName($associationName);
+ $otherModelKey = Inflector::underscore($otherModelName);
+ $otherModelObj =& ClassRegistry::getObject($otherModelKey);
+
+ $viewView .= "<div class=\"related\">\n";
+ $viewView .= "<h3>Related " . $otherPluralHumanName . "</h3>\n";
+ $viewView .= "<?php if (!empty(\$".$singularName."['{$associationName}'])):?>\n";
+ $viewView .= "<table cellpadding=\"0\" cellspacing=\"0\">\n";
+ $viewView .= "<tr>\n";
+ $viewView .= "<?php foreach (\$".$singularName."['{$associationName}']['0'] as \$column => \$value): ?>\n";
+ $viewView .= "<th><?php echo \$column?></th>\n";
+ $viewView .= "<?php endforeach; ?>\n";
+ $viewView .= "<th>Actions</th>\n";
+ $viewView .= "</tr>\n";
+ $viewView .= "<?php foreach (\$".$singularName."['{$associationName}'] as \$".$otherSingularName."):?>\n";
+ $viewView .= "<tr>\n";
+ $viewView .= "\t<?php foreach (\$".$otherSingularName." as \$column => \$value):?>\n";
+ $viewView .= "\t\t<td><?php echo \$value;?></td>\n";
+ $viewView .= "\t<?php endforeach;?>\n";
+ $viewView .= "\t<td class=\"actions\">\n";
+ $viewView .= "\t\t<?php echo \$html->link('View', '{$admin_url}/" . $otherControllerPath . "/view/' . \$".$otherSingularName."['{$otherModelObj->primaryKey}']);?>\n";
+ $viewView .= "\t\t<?php echo \$html->link('Edit', '{$admin_url}/" . $otherControllerPath . "/edit/' . \$".$otherSingularName."['{$otherModelObj->primaryKey}']);?>\n";
+ $viewView .= "\t\t<?php echo \$html->link('Delete', '{$admin_url}/" . $otherControllerPath . "/delete/' . \$".$otherSingularName."['{$otherModelObj->primaryKey}'], null, 'Are you sure you want to delete: id ' . \$".$otherSingularName."['{$otherModelObj->primaryKey}'] . '?');?>\n";
+ $viewView .= "\t</td>\n";
+ $viewView .= "</tr>\n";
+ $viewView .= "<?php endforeach; ?>\n";
+ $viewView .= "</table>\n";
+ $viewView .= "<?php endif; ?>\n\n";
+ $viewView .= "<ul class=\"actions\">\n";
+ $viewView .= "\t<li><?php echo \$html->link('New " . $otherSingularHumanName . "', '{$admin_url}/" .$otherControllerPath."/add/');?> </li>\n";
+ $viewView .= "</ul>\n";
+
+ $viewView .= "</div>\n";
+ }
+ $addView = null;
+ $addView .= "<h2>New " . $singularHumanName . "</h2>\n";
+ $addView .= "<form action=\"<?php echo \$html->url('{$admin_url}/{$controllerPath}/add'); ?>\" method=\"post\">\n";
+ $addView .= $this->generateFields($controllerObj->generateFieldNames(null, true));
+ $addView .= $this->generateSubmitDiv('Add');
+ $addView .= "</form>\n";
+ $addView .= "<ul class=\"actions\">\n";
+ $addView .= "<li><?php echo \$html->link('List {$pluralHumanName}', '{$admin_url}/{$controllerPath}/index')?></li>\n";
+ foreach ($modelObj->belongsTo as $associationName => $relation) {
+ $otherModelName = $this->__modelName($associationName);
+ if ($otherModelName != $currentModelName) {
+ $otherControllerName = $this->__controllerName($otherModelName);
+ $otherControllerPath = $this->__controllerPath($otherControllerName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralName = $this->__pluralHumanName($associationName);
+ $addView .= "<li><?php echo \$html->link('View " . $otherPluralName . "', '{$admin_url}/" .$otherControllerPath."/index/');?></li>\n";
+ $addView .= "<li><?php echo \$html->link('Add " . $otherPluralName . "', '{$admin_url}/" .$otherControllerPath."/add/');?></li>\n";
+ }
+ }
+ $addView .= "</ul>\n";
+ $editView = null;
+ $editView .= "<h2>Edit " . $singularHumanName . "</h2>\n";
+ $editView .= "<form action=\"<?php echo \$html->url('{$admin_url}/{$controllerPath}/edit/'.\$html->tagValue('{$modelObj->name}/{$modelObj->primaryKey}')); ?>\" method=\"post\">\n";
+ $editView .= $this->generateFields($controllerObj->generateFieldNames(null, true));
+ $editView .= "<?php echo \$html->hidden('{$modelObj->name}/{$modelObj->primaryKey}')?>\n";
+ $editView .= $this->generateSubmitDiv('Save');
+ $editView .= "</form>\n";
+ $editView .= "<ul class=\"actions\">\n";
+ $editView .= "<li><?php echo \$html->link('Delete','{$admin_url}/{$controllerPath}/delete/' . \$html->tagValue('{$modelObj->name}/{$modelObj->primaryKey}'), null, 'Are you sure you want to delete: id ' . \$html->tagValue('{$modelObj->name}/{$modelObj->primaryKey}'));?>\n";
+ $editView .= "<li><?php echo \$html->link('List {$pluralHumanName}', '{$admin_url}/{$controllerPath}/index')?></li>\n";
+ foreach ($modelObj->belongsTo as $associationName => $relation) {
+ $otherModelName = $this->__modelName($associationName);
+ if ($otherModelName != $currentModelName) {
+ $otherControllerName = $this->__controllerName($otherModelName);
+ $otherControllerPath = $this->__controllerPath($otherControllerName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralName = $this->__pluralHumanName($associationName);
+ $editView .= "<li><?php echo \$html->link('View " . $otherPluralName . "', '{$admin_url}/" .$otherControllerPath."/index/');?></li>\n";
+ $editView .= "<li><?php echo \$html->link('Add " . $otherPluralName . "', '{$admin_url}/" .$otherControllerPath."/add/');?></li>\n";
+ }
+ }
+ $editView .= "</ul>\n";
+
+ if (!file_exists(VIEWS.$controllerPath)) {
+ mkdir(VIEWS.$controllerPath);
+ }
+ $filename = VIEWS . $controllerPath . DS . $admin . 'index.thtml';
+ $this->__createFile($filename, $indexView);
+ $filename = VIEWS . $controllerPath . DS . $admin . 'view.thtml';
+ $this->__createFile($filename, $viewView);
+ $filename = VIEWS . $controllerPath . DS . $admin . 'add.thtml';
+ $this->__createFile($filename, $addView);
+ $filename = VIEWS . $controllerPath . DS . $admin . 'edit.thtml';
+ $this->__createFile($filename, $editView);
+ }
+/**
+ * Action to create a Controller.
+ *
+ */
+ function doController() {
+ $this->hr();
+ $this->stdout('Controller Bake:');
+ $this->hr();
+ $uses = array();
+ $helpers = array();
+ $components = array();
+ $wannaUseSession = 'y';
+ $wannaDoScaffolding = 'y';
+
+ $useDbConfig = 'default';
+ $this->__doList($useDbConfig, 'Controllers');
+
+ $enteredController = '';
+
+ while ($enteredController == '') {
+ $enteredController = $this->getInput('Enter a number from the list above, or type in the name of another controller.');
+
+ if ($enteredController == '' || intval($enteredController) > count($this->__controllerNames)) {
+ $this->stdout('Error:');
+ $this->stdout("The Controller name you supplied was empty, or the number \nyou selected was not an option. Please try again.");
+ $enteredController = '';
+ }
+ }
+
+ if (intval($enteredController) > 0 && intval($enteredController) <= count($this->__controllerNames) ) {
+ $controllerName = $this->__controllerNames[intval($enteredController) - 1];
+ } else {
+ $controllerName = Inflector::camelize($enteredController);
+ }
+
+ $controllerPath = low(Inflector::underscore($controllerName));
+
+ $doItInteractive = $this->getInput("Would you like bake to build your controller interactively?\nWarning: Choosing no will overwrite {$controllerClassName} controller if it exist.", array('y','n'), 'y');
+
+ if (low($doItInteractive) == 'y' || low($doItInteractive) == 'yes') {
+ $this->interactive = true;
+
+ $wannaUseScaffold = $this->getInput("Would you like to use scaffolding?", array('y','n'), 'y');
+
+ if (low($wannaUseScaffold) == 'n' || low($wannaUseScaffold) == 'no') {
+
+ $wannaDoScaffolding = $this->getInput("Would you like to include some basic class methods (index(), add(), view(), edit())?", array('y','n'), 'n');
+
+ if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
+ $wannaDoAdmin = $this->getInput("Would you like to create the methods for admin routing?", array('y','n'), 'n');
+ }
+
+ $wannaDoUses = $this->getInput("Would you like this controller to use other models besides '" . $this->__modelName($controllerName) . "'?", array('y','n'), 'n');
+
+ if (low($wannaDoUses) == 'y' || low($wannaDoUses) == 'yes') {
+ $usesList = $this->getInput("Please provide a comma separated list of the classnames of other models you'd like to use.\nExample: 'Author, Article, Book'");
+ $usesListTrimmed = str_replace(' ', '', $usesList);
+ $uses = explode(',', $usesListTrimmed);
+ }
+ $wannaDoHelpers = $this->getInput("Would you like this controller to use other helpers besides HtmlHelper and FormHelper?", array('y','n'), 'n');
+
+ if (low($wannaDoHelpers) == 'y' || low($wannaDoHelpers) == 'yes') {
+ $helpersList = $this->getInput("Please provide a comma separated list of the other helper names you'd like to use.\nExample: 'Ajax, Javascript, Time'");
+ $helpersListTrimmed = str_replace(' ', '', $helpersList);
+ $helpers = explode(',', $helpersListTrimmed);
+ }
+ $wannaDoComponents = $this->getInput("Would you like this controller to use any components?", array('y','n'), 'n');
+
+ if (low($wannaDoComponents) == 'y' || low($wannaDoComponents) == 'yes') {
+ $componentsList = $this->getInput("Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, MyNiftyHelper'");
+ $componentsListTrimmed = str_replace(' ', '', $componentsList);
+ $components = explode(',', $componentsListTrimmed);
+ }
+
+ $wannaUseSession = $this->getInput("Would you like to use Sessions?", array('y','n'), 'y');
+ } else {
+ $wannaDoScaffolding = 'n';
+ }
+ } else {
+ $wannaDoScaffolding = $this->getInput("Would you like to include some basic class methods (index(), add(), view(), edit())?", array('y','n'), 'y');
+
+ if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
+ $wannaDoAdmin = $this->getInput("Would you like to create the methods for admin routing?", array('y','n'), 'y');
+ }
+ }
+
+ $admin = null;
+ $admin_url = null;
+ if ((low($wannaDoAdmin) == 'y' || low($wannaDoAdmin) == 'yes')) {
+ require(CONFIGS.'core.php');
+ if (defined('CAKE_ADMIN')) {
+ $admin = CAKE_ADMIN.'_';
+ $admin_url = '/'.CAKE_ADMIN;
+ } else {
+ $adminRoute = '';
+ $this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
+ $this->stdout('What would you like the admin route to be?');
+ $this->stdout('Example: www.example.com/admin/controller');
+ while ($adminRoute == '') {
+ $adminRoute = $this->getInput("What would you like the admin route to be?", null, 'admin');
+ }
+ if ($this->__addAdminRoute($adminRoute) !== true) {
+ $this->stdout('Unable to write to /app/config/core.php.');
+ $this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
+ exit();
+ } else {
+ $admin = $adminRoute . '_';
+ $admin_url = '/'.$adminRoute;
+ }
+ }
+ }
+
+ if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
+ $actions = $this->__bakeActions($controllerName, null, null, $wannaUseSession);
+ if ($admin) {
+ $actions .= $this->__bakeActions($controllerName, $admin, $admin_url, $wannaUseSession);
+ }
+ }
+
+ if ($this->interactive === true) {
+ $this->stdout('');
+ $this->hr();
+ $this->stdout('The following controller will be created:');
+ $this->hr();
+ $this->stdout("Controller Name: $controllerName");
+ if (low($wannaUseScaffold) == 'y' || low($wannaUseScaffold) == 'yes') {
+ $this->stdout(" var \$scaffold;");
+ }
+ if (count($uses)) {
+ $this->stdout("Uses: ", false);
+
+ foreach ($uses as $use) {
+ if ($use != $uses[count($uses) - 1]) {
+ $this->stdout(ucfirst($use) . ", ", false);
+ } else {
+ $this->stdout(ucfirst($use));
+ }
+ }
+ }
+
+ if (count($helpers)) {
+ $this->stdout("Helpers: ", false);
+
+ foreach ($helpers as $help) {
+ if ($help != $helpers[count($helpers) - 1]) {
+ $this->stdout(ucfirst($help) . ", ", false);
+ } else {
+ $this->stdout(ucfirst($help));
+ }
+ }
+ }
+
+ if (count($components)) {
+ $this->stdout("Components: ", false);
+
+ foreach ($components as $comp) {
+ if ($comp != $components[count($components) - 1]) {
+ $this->stdout(ucfirst($comp) . ", ", false);
+ } else {
+ $this->stdout(ucfirst($comp));
+ }
+ }
+ }
+ $this->hr();
+ $looksGood = $this->getInput('Look okay?', array('y','n'), 'y');
+
+ if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
+ $this->bakeController($controllerName, $uses, $helpers, $components, $actions, $wannaUseScaffold);
+
+ if ($this->doUnitTest()) {
+ $this->bakeUnitTest('controller', $controllerName);
+ }
+ } else {
+ $this->stdout('Bake Aborted.');
+ }
+ } else {
+ $this->bakeController($controllerName, $uses, $helpers, $components, $actions, $wannaUseScaffold);
+ if ($this->doUnitTest()) {
+ $this->bakeUnitTest('controller', $controllerName);
+ }
+ exit();
+ }
+ }
+
+ function __bakeActions($controllerName, $admin = null, $admin_url = null, $wannaUseSession = 'y') {
+ $currentModelName = $this->__modelName($controllerName);
+ loadModel($currentModelName);
+ $modelObj =& new $currentModelName();
+ $controllerPath = $this->__controllerPath($controllerName);
+ $pluralName = $this->__pluralName($currentModelName);
+ $singularName = $this->__singularName($currentModelName);
+ $singularHumanName = $this->__singularHumanName($currentModelName);
+ $pluralHumanName = $this->__pluralHumanName($controllerName);
+ if (!class_exists($currentModelName)) {
+ $this->stdout('You must have a model for this class to build scaffold methods. Please try again.');
+ exit;
+ }
+ $actions .= "\n";
+ $actions .= "\tfunction {$admin}index() {\n";
+ $actions .= "\t\t\$this->{$currentModelName}->recursive = 0;\n";
+ $actions .= "\t\t\$this->set('{$pluralName}', \$this->{$currentModelName}->findAll());\n";
+ $actions .= "\t}\n";
+ $actions .= "\n";
+ $actions .= "\tfunction {$admin}view(\$id = null) {\n";
+ $actions .= "\t\tif (!\$id) {\n";
+ if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
+ $actions .= "\t\t\t\$this->Session->setFlash('Invalid id for {$singularHumanName}.');\n";
+ $actions .= "\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n";
+ } else {
+ $actions .= "\t\t\t\$this->flash('Invalid id for {$singularHumanName}', '{$admin_url}/{$controllerPath}/index');\n";
+ }
+ $actions .= "\t\t}\n";
+ $actions .= "\t\t\$this->set('".$singularName."', \$this->{$currentModelName}->read(null, \$id));\n";
+ $actions .= "\t}\n";
+ $actions .= "\n";
+ $actions .= "\tfunction {$admin}add() {\n";
+ $actions .= "\t\tif (empty(\$this->data)) {\n";
+
+ foreach ($modelObj->hasAndBelongsToMany as $associationName => $relation) {
+ if (!empty($associationName)) {
+ $otherModelName = $this->__modelName($associationName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralName = $this->__pluralName($associationName);
+ $selectedOtherPluralName = 'selected' . ucfirst($otherPluralName);
+ $actions .= "\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n";
+ $actions .= "\t\t\t\$this->set('{$selectedOtherPluralName}', null);\n";
+ }
+ }
+ foreach ($modelObj->belongsTo as $associationName => $relation) {
+ if (!empty($associationName)) {
+ $otherModelName = $this->__modelName($associationName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralName = $this->__pluralName($associationName);
+ $actions .= "\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n";
+ }
+ }
+ $actions .= "\t\t\t\$this->render();\n";
+ $actions .= "\t\t} else {\n";
+ $actions .= "\t\t\t\$this->cleanUpFields();\n";
+ $actions .= "\t\t\tif (\$this->{$currentModelName}->save(\$this->data)) {\n";
+ if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
+ $actions .= "\t\t\t\t\$this->Session->setFlash('The ".$this->__singularHumanName($currentModelName)." has been saved');\n";
+ $actions .= "\t\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n";
+ } else {
+ $actions .= "\t\t\t\t\$this->flash('{$currentModelName} saved.', '{$admin_url}/{$controllerPath}/index');\n";
+ }
+ $actions .= "\t\t\t} else {\n";
+ if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
+ $actions .= "\t\t\t\t\$this->Session->setFlash('Please correct errors below.');\n";
+ }
+
+ foreach ($modelObj->hasAndBelongsToMany as $associationName => $relation) {
+ if (!empty($associationName)) {
+ $otherModelName = $this->__modelName($associationName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralName = $this->__pluralName($associationName);
+ $selectedOtherPluralName = 'selected' . ucfirst($otherPluralName);
+ $actions .= "\t\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n";
+ $actions .= "\t\t\t\tif (empty(\$this->data['{$associationName}']['{$associationName}'])) { \$this->data['{$associationName}']['{$associationName}'] = null; }\n";
+ $actions .= "\t\t\t\t\$this->set('{$selectedOtherPluralName}', \$this->data['{$associationName}']['{$associationName}']);\n";
+ }
+ }
+ foreach ($modelObj->belongsTo as $associationName => $relation) {
+ if (!empty($associationName)) {
+ $otherModelName = $this->__modelName($associationName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralName = $this->__pluralName($associationName);
+ $actions .= "\t\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n";
+ }
+ }
+ $actions .= "\t\t\t}\n";
+ $actions .= "\t\t}\n";
+ $actions .= "\t}\n";
+ $actions .= "\n";
+ $actions .= "\tfunction {$admin}edit(\$id = null) {\n";
+ $actions .= "\t\tif (empty(\$this->data)) {\n";
+ $actions .= "\t\t\tif (!\$id) {\n";
+ if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
+ $actions .= "\t\t\t\t\$this->Session->setFlash('Invalid id for {$singularHumanName}');\n";
+ $actions .= "\t\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n";
+ } else {
+ $actions .= "\t\t\t\t\$this->flash('Invalid id for {$singularHumanName}', '{$admin_url}/{$controllerPath}/index');\n";
+ }
+ $actions .= "\t\t\t}\n";
+ $actions .= "\t\t\t\$this->data = \$this->{$currentModelName}->read(null, \$id);\n";
+
+ foreach ($modelObj->hasAndBelongsToMany as $associationName => $relation) {
+ if (!empty($associationName)) {
+ $otherModelName = $this->__modelName($associationName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralName = $this->__pluralName($associationName);
+ $otherModelKey = Inflector::underscore($otherModelName);
+ $otherModelObj =& ClassRegistry::getObject($otherModelKey);
+ $selectedOtherPluralName = 'selected' . ucfirst($otherPluralName);
+ $actions .= "\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n";
+ $actions .= "\t\t\tif (empty(\$this->data['{$associationName}'])) { \$this->data['{$associationName}'] = null; }\n";
+ $actions .= "\t\t\t\$this->set('{$selectedOtherPluralName}', \$this->_selectedArray(\$this->data['{$associationName}']));\n";
+ }
+ }
+ foreach ($modelObj->belongsTo as $associationName => $relation) {
+ if (!empty($associationName)) {
+ $otherModelName = $this->__modelName($associationName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralName = $this->__pluralName($associationName);
+ $actions .= "\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n";
+ }
+ }
+ $actions .= "\t\t} else {\n";
+ $actions .= "\t\t\t\$this->cleanUpFields();\n";
+ $actions .= "\t\t\tif (\$this->{$currentModelName}->save(\$this->data)) {\n";
+ if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
+ $actions .= "\t\t\t\t\$this->Session->setFlash('The ".Inflector::humanize($currentModelName)." has been saved');\n";
+ $actions .= "\t\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n";
+ } else {
+ $actions .= "\t\t\t\t\$this->flash('{$currentModelName} saved.', '{$admin_url}/{$controllerPath}/index');\n";
+ }
+ $actions .= "\t\t\t} else {\n";
+ if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
+ $actions .= "\t\t\t\t\$this->Session->setFlash('Please correct errors below.');\n";
+ }
+
+ foreach ($modelObj->hasAndBelongsToMany as $associationName => $relation) {
+ if (!empty($associationName)) {
+ $otherModelName = $this->__modelName($associationName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralName = $this->__pluralName($associationName);
+ $selectedOtherPluralName = 'selected' . ucfirst($otherPluralName);
+ $actions .= "\t\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n";
+ $actions .= "\t\t\t\tif (empty(\$this->data['{$associationName}']['{$associationName}'])) { \$this->data['{$associationName}']['{$associationName}'] = null; }\n";
+ $actions .= "\t\t\t\t\$this->set('{$selectedOtherPluralName}', \$this->data['{$associationName}']['{$associationName}']);\n";
+ }
+ }
+ foreach ($modelObj->belongsTo as $associationName => $relation) {
+ if (!empty($associationName)) {
+ $otherModelName = $this->__modelName($associationName);
+ $otherSingularName = $this->__singularName($associationName);
+ $otherPluralName = $this->__pluralName($associationName);
+ $actions .= "\t\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n";
+ }
+ }
+ $actions .= "\t\t\t}\n";
+ $actions .= "\t\t}\n";
+ $actions .= "\t}\n";
+ $actions .= "\n";
+ $actions .= "\tfunction {$admin}delete(\$id = null) {\n";
+ $actions .= "\t\tif (!\$id) {\n";
+ if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
+ $actions .= "\t\t\t\$this->Session->setFlash('Invalid id for {$singularHumanName}');\n";
+ $actions .= "\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n";
+ } else {
+ $actions .= "\t\t\t\$this->flash('Invalid id for {$singularHumanName}', '{$admin_url}/{$controllerPath}/index');\n";
+ }
+ $actions .= "\t\t}\n";
+ $actions .= "\t\tif (\$this->{$currentModelName}->del(\$id)) {\n";
+ if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
+ $actions .= "\t\t\t\$this->Session->setFlash('The ".$this->__singularHumanName($currentModelName)." deleted: id '.\$id.'');\n";
+ $actions .= "\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n";
+ } else {
+ $actions .= "\t\t\t\$this->flash('{$currentModelName} deleted: id '.\$id.'.', '{$admin_url}/{$controllerPath}/index');\n";
+ }
+ $actions .= "\t\t}\n";
+ $actions .= "\t}\n";
+ $actions .= "\n";
+ return $actions;
+ }
+/**
+ * Action to create a Unit Test.
+ *
+ * @return Success
+ */
+ function doUnitTest() {
+ if (is_dir(VENDORS.'simpletest') || is_dir(ROOT.DS.APP_DIR.DS.'vendors'.DS.'simpletest')) {
+ return true;
+ }
+ $unitTest = $this->getInput('Cake test suite not installed. Do you want to bake unit test files anyway?', array('y','n'), 'y');
+ $result = low($unitTest) == 'y' || low($unitTest) == 'yes';
+
+ if ($result) {
+ $this->stdout("\nYou can download the Cake test suite from http://cakeforge.org/projects/testsuite/", true);
+ }
+ return $result;
+ }
+/**
+ * Creates a database configuration file for Bake.
+ *
+ * @param string $host
+ * @param string $login
+ * @param string $password
+ * @param string $database
+ */
+ function bakeDbConfig( $driver, $connect, $host, $login, $password, $database, $prefix) {
+ $out = "<?php\n";
+ $out .= "class DATABASE_CONFIG {\n\n";
+ $out .= "\tvar \$default = array(\n";
+ $out .= "\t\t'driver' => '{$driver}',\n";
+ $out .= "\t\t'connect' => '{$connect}',\n";
+ $out .= "\t\t'host' => '{$host}',\n";
+ $out .= "\t\t'login' => '{$login}',\n";
+ $out .= "\t\t'password' => '{$password}',\n";
+ $out .= "\t\t'database' => '{$database}', \n";
+ $out .= "\t\t'prefix' => '{$prefix}' \n";
+ $out .= "\t);\n";
+ $out .= "}\n";
+ $out .= "?>";
+ $filename = CONFIGS.'database.php';
+ $this->__createFile($filename, $out);
+ }
+/**
+ * Assembles and writes a Model file.
+ *
+ * @param string $name
+ * @param object $useDbConfig
+ * @param string $useTable
+ * @param string $primaryKey
+ * @param array $validate
+ * @param array $associations
+ */
+ function bakeModel($name, $useDbConfig = 'default', $useTable = null, $primaryKey = 'id', $validate=array(), $associations=array()) {
+ $out = "<?php\n";
+ $out .= "class {$name} extends AppModel {\n\n";
+ $out .= "\tvar \$name = '{$name}';\n";
+
+ if ($useDbConfig != 'default') {
+ $out .= "\tvar \$useDbConfig = '$useDbConfig';\n";
+ }
+
+ if ($useTable != null) {
+ $out .= "\tvar \$useTable = '$useTable';\n";
+ }
+
+ if ($primaryKey != 'id') {
+ $out .= "\tvar \$primaryKey = '$primaryKey';\n";
+ }
+
+
+ if (count($validate)) {
+ $out .= "\tvar \$validate = array(\n";
+ $keys = array_keys($validate);
+ for ($i = 0; $i < count($validate); $i++) {
+ $out .= "\t\t'" . $keys[$i] . "' => " . $validate[$keys[$i]] . ",\n";
+ }
+ $out .= "\t);\n";
+ }
+ $out .= "\n";
+
+ if (!empty($associations)) {
+ $out.= "\t//The Associations below have been created with all possible keys, those that are not needed can be removed\n";
+ if (!empty($associations['belongsTo'])) {
+ $out .= "\tvar \$belongsTo = array(\n";
+
+ for ($i = 0; $i < count($associations['belongsTo']); $i++) {
+ $out .= "\t\t\t'{$associations['belongsTo'][$i]['alias']}' =>\n";
+ $out .= "\t\t\t\tarray('className' => '{$associations['belongsTo'][$i]['className']}',\n";
+ $out .= "\t\t\t\t\t\t'foreignKey' => '{$associations['belongsTo'][$i]['foreignKey']}',\n";
+ $out .= "\t\t\t\t\t\t'conditions' => '',\n";
+ $out .= "\t\t\t\t\t\t'fields' => '',\n";
+ $out .= "\t\t\t\t\t\t'order' => '',\n";
+ $out .= "\t\t\t\t\t\t'counterCache' => ''\n";
+ $out .= "\t\t\t\t),\n\n";
+ }
+ $out .= "\t);\n\n";
+ }
+
+ if (!empty($associations['hasOne'])) {
+ $out .= "\tvar \$hasOne = array(\n";
+
+ for ($i = 0; $i < count($associations['hasOne']); $i++) {
+ $out .= "\t\t\t'{$associations['hasOne'][$i]['alias']}' =>\n";
+ $out .= "\t\t\t\tarray('className' => '{$associations['hasOne'][$i]['className']}',\n";
+ $out .= "\t\t\t\t\t\t'foreignKey' => '{$associations['hasOne'][$i]['foreignKey']}',\n";
+ $out .= "\t\t\t\t\t\t'conditions' => '',\n";
+ $out .= "\t\t\t\t\t\t'fields' => '',\n";
+ $out .= "\t\t\t\t\t\t'order' => '',\n";
+ $out .= "\t\t\t\t\t\t'dependent' => ''\n";
+ $out .= "\t\t\t\t),\n\n";
+ }
+ $out .= "\t);\n\n";
+ }
+
+ if (!empty($associations['hasMany'])) {
+ $out .= "\tvar \$hasMany = array(\n";
+
+ for ($i = 0; $i < count($associations['hasMany']); $i++) {
+ $out .= "\t\t\t'{$associations['hasMany'][$i]['alias']}' =>\n";
+ $out .= "\t\t\t\tarray('className' => '{$associations['hasMany'][$i]['className']}',\n";
+ $out .= "\t\t\t\t\t\t'foreignKey' => '{$associations['hasMany'][$i]['foreignKey']}',\n";
+ $out .= "\t\t\t\t\t\t'conditions' => '',\n";
+ $out .= "\t\t\t\t\t\t'fields' => '',\n";
+ $out .= "\t\t\t\t\t\t'order' => '',\n";
+ $out .= "\t\t\t\t\t\t'limit' => '',\n";
+ $out .= "\t\t\t\t\t\t'offset' => '',\n";
+ $out .= "\t\t\t\t\t\t'dependent' => '',\n";
+ $out .= "\t\t\t\t\t\t'exclusive' => '',\n";
+ $out .= "\t\t\t\t\t\t'finderQuery' => '',\n";
+ $out .= "\t\t\t\t\t\t'counterQuery' => ''\n";
+ $out .= "\t\t\t\t),\n\n";
+ }
+ $out .= "\t);\n\n";
+ }
+
+ if (!empty($associations['hasAndBelongsToMany'])) {
+ $out .= "\tvar \$hasAndBelongsToMany = array(\n";
+
+ for ($i = 0; $i < count($associations['hasAndBelongsToMany']); $i++) {
+ $out .= "\t\t\t'{$associations['hasAndBelongsToMany'][$i]['alias']}' =>\n";
+ $out .= "\t\t\t\tarray('className' => '{$associations['hasAndBelongsToMany'][$i]['className']}',\n";
+ $out .= "\t\t\t\t\t\t'joinTable' => '{$associations['hasAndBelongsToMany'][$i]['joinTable']}',\n";
+ $out .= "\t\t\t\t\t\t'foreignKey' => '{$associations['hasAndBelongsToMany'][$i]['foreignKey']}',\n";
+ $out .= "\t\t\t\t\t\t'associationForeignKey' => '{$associations['hasAndBelongsToMany'][$i]['associationForeignKey']}',\n";
+ $out .= "\t\t\t\t\t\t'conditions' => '',\n";
+ $out .= "\t\t\t\t\t\t'fields' => '',\n";
+ $out .= "\t\t\t\t\t\t'order' => '',\n";
+ $out .= "\t\t\t\t\t\t'limit' => '',\n";
+ $out .= "\t\t\t\t\t\t'offset' => '',\n";
+ $out .= "\t\t\t\t\t\t'unique' => '',\n";
+ $out .= "\t\t\t\t\t\t'finderQuery' => '',\n";
+ $out .= "\t\t\t\t\t\t'deleteQuery' => '',\n";
+ $out .= "\t\t\t\t\t\t'insertQuery' => ''\n";
+ $out .= "\t\t\t\t),\n\n";
+ }
+ $out .= "\t);\n\n";
+ }
+ }
+ $out .= "}\n";
+ $out .= "?>";
+ $filename = MODELS.Inflector::underscore($name) . '.php';
+ $this->__createFile($filename, $out);
+ }
+/**
+ * Assembles and writes a View file.
+ *
+ * @param string $controllerName
+ * @param string $actionName
+ * @param string $content
+ */
+ function bakeView($controllerName, $actionName, $content = '') {
+ $out = "<h2>{$actionName}</h2>\n";
+ $out .= $content;
+ if (!file_exists(VIEWS.$this->__controllerPath($controllerName))) {
+ mkdir(VIEWS.$this->__controllerPath($controllerName));
+ }
+ $filename = VIEWS . $this->__controllerPath($controllerName) . DS . Inflector::underscore($actionName) . '.thtml';
+ $this->__createFile($filename, $out);
+ }
+/**
+ * Assembles and writes a Controller file.
+ *
+ * @param string $controllerName
+ * @param array $uses
+ * @param array $helpers
+ * @param array $components
+ * @param string $actions
+ */
+ function bakeController($controllerName, $uses, $helpers, $components, $actions = '', $wannaUseScaffold = 'y') {
+ $out = "<?php\n";
+ $out .= "class $controllerName" . "Controller extends AppController {\n\n";
+ $out .= "\tvar \$name = '$controllerName';\n";
+ if (low($wannaUseScaffold) == 'y' || low($wannaUseScaffold) == 'yes') {
+ $out .= "\tvar \$scaffold;\n";
+ } else {
+
+ if (count($uses)) {
+ $out .= "\tvar \$uses = array('" . $this->__modelName($controllerName) . "', ";
+
+ foreach ($uses as $use) {
+ if ($use != $uses[count($uses) - 1]) {
+ $out .= "'" . $this->__modelName($use) . "', ";
+ } else {
+ $out .= "'" . $this->__modelName($use) . "'";
+ }
+ }
+ $out .= ");\n";
+ }
+
+ $out .= "\tvar \$helpers = array('Html', 'Form' ";
+ if (count($helpers)) {
+ foreach ($helpers as $help) {
+ if ($help != $helpers[count($helpers) - 1]) {
+ $out .= ", '" . Inflector::camelize($help) . "'";
+ } else {
+ $out .= ", '" . Inflector::camelize($help) . "'";
+ }
+ }
+ }
+ $out .= ");\n";
+
+ if (count($components)) {
+ $out .= "\tvar \$components = array(";
+
+ foreach ($components as $comp) {
+ if ($comp != $components[count($components) - 1]) {
+ $out .= "'" . Inflector::camelize($comp) . "', ";
+ } else {
+ $out .= "'" . Inflector::camelize($comp) . "'";
+ }
+ }
+ $out .= ");\n";
+ }
+ }
+ $out .= $actions;
+ $out .= "}\n";
+ $out .= "?>";
+ $filename = CONTROLLERS . $this->__controllerPath($controllerName) . '_controller.php';
+ $this->__createFile($filename, $out);
+ }
+/**
+ * Assembles and writes a unit test file.
+ *
+ * @param string $type One of "model", and "controller".
+ * @param string $className
+ */
+ function bakeUnitTest($type, $className) {
+ $out = '<?php '."\n\n";
+ $error = false;
+ switch ($type) {
+ case 'model':
+ $out .= "loadModel('$className');\n\n";
+ $out .= "class {$className}TestCase extends UnitTestCase {\n";
+ $out .= "\tvar \$object = null;\n\n";
+ $out .= "\tfunction setUp() {\n\t\t\$this->object = new {$className}();\n";
+ $out .= "\t}\n\n\tfunction tearDown() {\n\t\tunset(\$this->object);\n\t}\n";
+ $out .= "\n\t/*\n\tfunction testMe() {\n";
+ $out .= "\t\t\$result = \$this->object->doSomething();\n";
+ $out .= "\t\t\$expected = 1;\n";
+ $out .= "\t\t\$this->assertEqual(\$result, \$expected);\n\t}\n\t*/\n}";
+ $path = MODEL_TESTS;
+ $filename = $this->__singularName($className).'.test.php';
+ break;
+ case 'controller':
+ $out .= "loadController('$className');\n\n";
+ $out .= "class {$className}ControllerTestCase extends UnitTestCase {\n";
+ $out .= "\tvar \$object = null;\n\n";
+ $out .= "\tfunction setUp() {\n\t\t\$this->object = new {$className}Controller();\n";
+ $out .= "\t}\n\n\tfunction tearDown() {\n\t\tunset(\$this->object);\n\t}\n";
+ $out .= "\n\t/*\n\tfunction testMe() {\n";
+ $out .= "\t\t\$result = \$this->object->doSomething();\n";
+ $out .= "\t\t\$expected = 1;\n";
+ $out .= "\t\t\$this->assertEqual(\$result, \$expected);\n\t}\n\t*/\n}";
+ $path = CONTROLLER_TESTS;
+ $filename = $this->__pluralName($className).'_controller.test.php';
+ break;
+ default:
+ $error = true;
+ break;
+ }
+ $out .= "\n?>";
+
+ if (!$error) {
+ $this->stdout("Baking unit test for $className...");
+ $path = explode(DS, $path);
+ foreach ($path as $i => $val) {
+ if ($val == '' || $val == '../') {
+ unset($path[$i]);
+ }
+ }
+ $path = implode(DS, $path);
+ $unixPath = DS;
+ if (strpos(PHP_OS, 'WIN') === 0) {
+ $unixPath = null;
+ }
+ if (!is_dir($unixPath.$path)) {
+ $create = $this->getInput("Unit test directory does not exist. Create it?", array('y','n'), 'y');
+ if (low($create) == 'y' || low($create) == 'yes') {
+ $build = array();
+
+ foreach (explode(DS, $path) as $i => $dir) {
+ $build[] = $dir;
+ if (!is_dir($unixPath.implode(DS, $build))) {
+ mkdir($unixPath.implode(DS, $build));
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+ $this->__createFile($unixPath.$path.DS.$filename, $out);
+ }
+ }
+/**
+ * Prompts the user for input, and returns it.
+ *
+ * @param string $prompt Prompt text.
+ * @param mixed $options Array or string of options.
+ * @param string $default Default input value.
+ * @return Either the default value, or the user-provided input.
+ */
+ function getInput($prompt, $options = null, $default = null) {
+ if (!is_array($options)) {
+ $print_options = '';
+ } else {
+ $print_options = '(' . implode('/', $options) . ')';
+ }
+
+ if ($default == null) {
+ $this->stdout('');
+ $this->stdout($prompt . " $print_options \n" . '> ', false);
+ } else {
+ $this->stdout('');
+ $this->stdout($prompt . " $print_options \n" . "[$default] > ", false);
+ }
+ $result = fgets($this->stdin);
+
+ if($result === false){
+ exit;
+ }
+ $result = trim($result);
+
+ if ($default != null && empty($result)) {
+ return $default;
+ } else {
+ return $result;
+ }
+ }
+/**
+ * Outputs to the stdout filehandle.
+ *
+ * @param string $string String to output.
+ * @param boolean $newline If true, the outputs gets an added newline.
+ */
+ function stdout($string, $newline = true) {
+ if ($newline) {
+ fwrite($this->stdout, $string . "\n");
+ } else {
+ fwrite($this->stdout, $string);
+ }
+ }
+/**
+ * Outputs to the stderr filehandle.
+ *
+ * @param string $string Error text to output.
+ */
+ function stderr($string) {
+ fwrite($this->stderr, $string, true);
+ }
+/**
+ * Outputs a series of minus characters to the standard output, acts as a visual separator.
+ *
+ */
+ function hr() {
+ $this->stdout('---------------------------------------------------------------');
+ }
+/**
+ * Creates a file at given path.
+ *
+ * @param string $path Where to put the file.
+ * @param string $contents Content to put in the file.
+ * @return Success
+ */
+ function __createFile ($path, $contents) {
+ $path = str_replace('//', '/', $path);
+ echo "\nCreating file $path\n";
+ if (is_file($path) && $this->interactive === true) {
+ fwrite($this->stdout, __("File exists, overwrite?", true). " {$path} (y/n/q):");
+ $key = trim(fgets($this->stdin));
+
+ if ($key=='q') {
+ fwrite($this->stdout, __("Quitting.", true) ."\n");
+ exit;
+ } elseif ($key == 'a') {
+ $this->dont_ask = true;
+ } elseif ($key == 'y') {
+ } else {
+ fwrite($this->stdout, __("Skip", true) ." {$path}\n");
+ return false;
+ }
+ }
+
+ if ($f = fopen($path, 'w')) {
+ fwrite($f, $contents);
+ fclose($f);
+ fwrite($this->stdout, __("Wrote", true) ."{$path}\n");
+ return true;
+ } else {
+ fwrite($this->stderr, __("Error! Could not write to", true)." {$path}.\n");
+ return false;
+ }
+ }
+/**
+ * Takes an array of database fields, and generates an HTML form for a View.
+ * This is an extraction from the Scaffold functionality.
+ *
+ * @param array $fields
+ * @param boolean $readOnly
+ * @return Generated HTML and PHP.
+ */
+ function generateFields( $fields, $readOnly = false ) {
+ $strFormFields = '';
+ foreach ( $fields as $field ) {
+ if (isset( $field['type'])) {
+ if (!isset($field['required'])) {
+ $field['required'] = false;
+ }
+
+ if (!isset( $field['errorMsg'])) {
+ $field['errorMsg'] = null;
+ }
+
+ if (!isset( $field['htmlOptions'])) {
+ $field['htmlOptions'] = array();
+ }
+
+ if ( $readOnly ) {
+ $field['htmlOptions']['READONLY'] = "readonly";
+ }
+
+ switch( $field['type'] ) {
+ case "input" :
+ if (!isset( $field['size'])) {
+ $field['size'] = 60;
+ }
+ $strFormFields = $strFormFields.$this->generateInputDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['size'], $field['htmlOptions'] );
+ break;
+ case "checkbox" :
+ $strFormFields = $strFormFields.$this->generateCheckboxDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['htmlOptions'] );
+ break;
+ case "select";
+ case "selectMultiple";
+ if ( "selectMultiple" == $field['type'] ) {
+ $field['selectAttr']['multiple'] = 'multiple';
+ $field['selectAttr']['class'] = 'selectMultiple';
+ }
+ if (!isset( $field['selected'])) {
+ $field['selected'] = null;
+ }
+ if (!isset( $field['selectAttr'])) {
+ $field['selectAttr'] = null;
+ }
+ if (!isset( $field['optionsAttr'])) {
+ $field['optionsAttr'] = null;
+ }
+ if ($readOnly) {
+ $field['selectAttr']['DISABLED'] = true;
+ }
+ if (!isset( $field['options'])) {
+ $field['options'] = null;
+ }
+ $this->__modelAlias = null;
+ if (isset($field['foreignKey'])) {
+ $modelKey = Inflector::underscore($this->__modelClass);
+ $modelObj =& ClassRegistry::getObject($modelKey);
+ foreach ($modelObj->belongsTo as $associationName => $value) {
+ if ($field['model'] == $value['className']) {
+ $this->__modelAlias = $this->__modelName($associationName);
+ break;
+ }
+ }
+ }
+ $strFormFields = $strFormFields.$this->generateSelectDiv( $field['tagName'], $field['prompt'], $field['options'], $field['selected'], $field['selectAttr'], $field['optionsAttr'], $field['required'], $field['errorMsg'] );
+ break;
+ case "area";
+ if (!isset( $field['rows'])) {
+ $field['rows'] = 10;
+ }
+ if (!isset( $field['cols'])) {
+ $field['cols'] = 60;
+ }
+ $strFormFields = $strFormFields.$this->generateAreaDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['cols'], $field['rows'], $field['htmlOptions'] );
+ break;
+ case "fieldset";
+ $strFieldsetFields = $this->generateFields( $field['fields'] );
+ $strFieldSet = sprintf( '
+ <fieldset><legend>%s</legend><div class="notes"><h4>%s</h4><p class="last">%s</p></div>%s</fieldset>',
+ $field['legend'], $field['noteHeading'], $field['note'], $strFieldsetFields );
+ $strFormFields = $strFormFields.$strFieldSet;
+ break;
+ case "hidden";
+ //$strFormFields = $strFormFields . $this->Html->hiddenTag( $field['tagName']);
+ break;
+ case "date":
+ if (!isset($field['selected'])) {
+ $field['selected'] = null;
+ }
+ $strFormFields = $strFormFields . $this->generateDate($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']);
+ break;
+ case "datetime":
+ if (!isset($field['selected'])) {
+ $field['selected'] = null;
+ }
+ $strFormFields = $strFormFields . $this->generateDateTime($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']);
+ break;
+ case "time":
+ if (!isset($field['selected'])) {
+ $field['selected'] = null;
+ }
+ $strFormFields = $strFormFields . $this->generateTime($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ return $strFormFields;
+ }
+/**
+ * Generates PHP code for a View file that makes a textarea.
+ *
+ * @param string $tagName
+ * @param string $prompt
+ * @param boolean $required
+ * @param string $errorMsg
+ * @param integer $cols
+ * @param integer $rows
+ * @param array $htmlOptions
+ * @return Generated HTML and PHP.
+ */
+ function generateAreaDiv($tagName, $prompt, $required=false, $errorMsg=null, $cols=60, $rows=10, $htmlOptions=null ) {
+ $htmlAttributes = $htmlOptions;
+ $htmlAttributes['cols'] = $cols;
+ $htmlAttributes['rows'] = $rows;
+ $str = "\t<?php echo \$html->textarea('{$tagName}', " . $this->__attributesToArray($htmlAttributes) . ");?>\n";
+ $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please enter the {$prompt}.');?>\n";
+ $strLabel = "\n\t<?php echo \$form->labelTag( '{$tagName}', '{$prompt}' );?>\n";
+ $divClass = "optional";
+
+ if ( $required ) {
+ $divClass = "required";
+ }
+ $strError = "";
+ $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str );
+ return $this->divTag( $divClass, $divTagInside );
+ }
+/**
+ * Generates PHP code for a View file that makes a checkbox, wrapped in a DIV.
+ *
+ * @param string $tagName
+ * @param string $prompt
+ * @param boolean $required
+ * @param string $errorMsg
+ * @param array $htmlOptions
+ * @return Generated HTML and PHP.
+ */
+ function generateCheckboxDiv($tagName, $prompt, $required=false, $errorMsg=null, $htmlOptions=null ) {
+ $htmlAttributes = $htmlOptions;
+ $strLabel = "\n\t<?php echo \$html->checkbox('{$tagName}', null, " . $this->__attributesToArray($htmlAttributes) . ");?>\n";
+ $strLabel .= "\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n";
+ $str = "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please check the {$prompt}.');?>\n";
+ $divClass = "optional";
+
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+ $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str);
+ return $this->divTag( $divClass, $divTagInside );
+ }
+/**
+ * Generates PHP code for a View file that makes a date-picker, wrapped in a DIV.
+ *
+ * @param string $tagName
+ * @param string $prompt
+ * @param boolean $required
+ * @param string $errorMsg
+ * @param integer $size
+ * @param array $htmlOptions
+ * @param string $selected
+ * @return Generated HTML and PHP.
+ */
+ function generateDate($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected=null ) {
+ $str = "\t<?php echo \$html->dateTimeOptionTag('{$tagName}', 'MDY' , 'NONE', \$html->tagValue('{$tagName}'), " . $this->__attributesToArray($htmlOptions) . ");?>\n";
+ $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please select the {$prompt}.');?>\n";
+ $strLabel = "\n\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n";
+ $divClass = "optional";
+
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+ $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str );
+ return $this->divTag( $divClass, $divTagInside );
+ }
+/**
+ * Generates PHP code for a View file that makes a time-picker, wrapped in a DIV.
+ *
+ * @param string $tagName
+ * @param string $prompt
+ * @param boolean $required
+ * @param string $errorMsg
+ * @param integer $size
+ * @param array $htmlOptions
+ * @param string $selected
+ * @return Generated HTML and PHP.
+ */
+ function generateTime($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) {
+ $str = "\n\t\<?php echo \$html->dateTimeOptionTag('{$tagName}', 'NONE', '24', \$html->tagValue('{$tagName}'), " . $this->__attributesToArray($htmlOptions) . ");?>\n";
+ $strLabel = "\n\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n";
+ $divClass = "optional";
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+ $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str);
+ return $this->divTag($divClass, $divTagInside);
+ }
+/**
+ * EGenerates PHP code for a View file that makes a datetime-picker, wrapped in a DIV.
+ *
+ * @param string $tagName
+ * @param string $prompt
+ * @param boolean $required
+ * @param string $errorMsg
+ * @param integer $size
+ * @param array $htmlOptions
+ * @param string $selected
+ * @return Generated HTML and PHP.
+ */
+ function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected = null ) {
+ $str = "\t<?php echo \$html->dateTimeOptionTag('{$tagName}', 'MDY' , '12', \$html->tagValue('{$tagName}'), " . $this->__attributesToArray($htmlOptions) . ");?>\n";
+ $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please select the {$prompt}.');?>\n";
+ $strLabel = "\n\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n";
+ $divClass = "optional";
+
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+ $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str );
+ return $this->divTag( $divClass, $divTagInside );
+ }
+/**
+ * Generates PHP code for a View file that makes an INPUT field, wrapped in a DIV.
+ *
+ * @param string $tagName
+ * @param string $prompt
+ * @param boolean $required
+ * @param string $errorMsg
+ * @param integer $size
+ * @param array $htmlOptions
+ * @return Generated HTML and PHP.
+ */
+ function generateInputDiv($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) {
+ $htmlAttributes = $htmlOptions;
+ $htmlAttributes['size'] = $size;
+ $str = "\t<?php echo \$html->input('{$tagName}', " . $this->__attributesToArray($htmlAttributes) . ");?>\n";
+ $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please enter the {$prompt}.');?>\n";
+ $strLabel = "\n\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n";
+ $divClass = "optional";
+
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+ $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str );
+ return $this->divTag( $divClass, $divTagInside );
+ }
+
+/**
+ * Generates PHP code for a View file that makes a SELECT box, wrapped in a DIV.
+ *
+ * @param string $tagName
+ * @param string $prompt
+ * @param array $options
+ * @param string $selected
+ * @param array $selectAttr
+ * @param array $optionAttr
+ * @param boolean $required
+ * @param string $errorMsg
+ * @return Generated HTML and PHP.
+ */
+ function generateSelectDiv($tagName, $prompt, $options, $selected=null, $selectAttr=null, $optionAttr=null, $required=false, $errorMsg=null) {
+
+ if ($this->__modelAlias) {
+ $pluralName = $this->__pluralName($this->__modelAlias);
+ } else {
+ $tagArray = explode('/', $tagName);
+ $pluralName = $this->__pluralName($this->__modelNameFromKey($tagArray[1]));
+ }
+ $showEmpty = 'true';
+ if ($required) {
+ $showEmpty = 'false';
+ }
+ if ($selectAttr['multiple'] != 'multiple') {
+ $str = "\t<?php echo \$html->selectTag('{$tagName}', " . "\${$pluralName}, \$html->tagValue('{$tagName}'), " . $this->__attributesToArray($selectAttr) . ", " . $this->__attributesToArray($optionAttr) . ", " . $showEmpty . ");?>\n";
+ $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please select the {$prompt}.') ?>\n";
+ } else {
+ $selectedPluralName = 'selected' . ucfirst($pluralName);
+ $selectAttr = am(array('multiple' => 'multiple', 'class' => 'selectMultiple'), $selectAttr);
+ $str = "\t<?php echo \$html->selectTag('{$tagName}', \${$pluralName}, \${$selectedPluralName}, " . $this->__attributesToArray($selectAttr) . ", " . $this->__attributesToArray($optionAttr) . ", " . $showEmpty . ");?>\n";
+ $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please select the {$prompt}.');?>\n";
+ }
+ $strLabel = "\n\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n";
+ $divClass = "optional";
+
+ if ($required) {
+ $divClass = "required";
+ }
+ $strError = "";
+ $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str );
+ return $this->divTag( $divClass, $divTagInside );
+ }
+/**
+ * Generates PHP code for a View file that makes a submit button, wrapped in a DIV.
+ *
+ * @param string $displayText
+ * @param array $htmlOptions
+ * @return Generated HTML.
+ */
+ function generateSubmitDiv($displayText, $htmlOptions = null) {
+ $str = "\n\t<?php echo \$html->submit('{$displayText}');?>\n";
+ $divTagInside = sprintf( "%s", $str );
+ return $this->divTag( 'submit', $divTagInside);
+ }
+/**
+ * Returns the text wrapped in an HTML DIV, followed by a newline.
+ *
+ * @param string $class
+ * @param string $text
+ * @return Generated HTML.
+ */
+ function divTag($class, $text) {
+ return sprintf('<div class="%s">%s</div>', $class, $text ) . "\n";
+ }
+/**
+ * Parses the HTML attributes array, which is a common data structure in View files.
+ * Returns PHP code for initializing this array in a View file.
+ *
+ * @param array $htmlAttributes
+ * @return Generated PHP code.
+ */
+ function __attributesToArray($htmlAttributes) {
+ if (is_array($htmlAttributes)) {
+ $keys = array_keys($htmlAttributes);
+ $vals = array_values($htmlAttributes);
+ $out = "array(";
+
+ for ($i = 0; $i < count($htmlAttributes); $i++) {
+ if (substr($vals[$i], 0, 1) != '$') {
+ $out .= "'{$keys[$i]}' => '{$vals[$i]}', ";
+ } else {
+ $out .= "'{$keys[$i]}' => {$vals[$i]}, ";
+ }
+ }
+ if (substr($out, -2, 1) == ',') {
+ $out = substr($out, 0, strlen($out) - 2);
+ }
+ $out .= ")";
+ return $out;
+ } else {
+ return 'array()';
+ }
+ }
+/**
+ * Outputs usage text on the standard output.
+ *
+ */
+ function help() {
+ $this->stdout('CakePHP Bake:');
+ $this->hr();
+ $this->stdout('The Bake script generates controllers, views and models for your application.');
+ $this->stdout('If run with no command line arguments, Bake guides the user through the class');
+ $this->stdout('creation process. You can customize the generation process by telling Bake');
+ $this->stdout('where different parts of your application are using command line arguments.');
+ $this->stdout('');
+ $this->hr('');
+ $this->stdout('usage: php bake.php [command] [path...]');
+ $this->stdout('');
+ $this->stdout('commands:');
+ $this->stdout(' -app [path...] Absolute path to Cake\'s app Folder.');
+ $this->stdout(' -core [path...] Absolute path to Cake\'s cake Folder.');
+ $this->stdout(' -help Shows this help message.');
+ $this->stdout(' -project [path...] Generates a new app folder in the path supplied.');
+ $this->stdout(' -root [path...] Absolute path to Cake\'s \app\webroot Folder.');
+ $this->stdout('');
+ }
+/**
+ * Checks that given project path does not already exist, and
+ * finds the app directory in it. Then it calls __buildDirLayout() with that information.
+ *
+ * @param string $projectPath
+ */
+ function project($projectPath = null) {
+ if ($projectPath != '') {
+ while ($this->__checkPath($projectPath) === true && $this->__checkPath(CONFIGS) === true) {
+ $response = $this->getInput('Bake -app in '.$projectPath, array('y','n'), 'y');
+ if (low($response) == 'y') {
+ $this->main();
+ exit();
+ } else {
+ $projectPath = $this->getInput("What is the full path for this app including the app directory name?\nExample: ".ROOT.DS."myapp", null, ROOT.DS.'myapp');
+ }
+ }
+ } else {
+ while ($projectPath == '') {
+ $projectPath = $this->getInput("What is the full path for this app including the app directory name?\nExample: ".ROOT.DS."myapp", null, ROOT.DS.'myapp');
+
+ if ($projectPath == '') {
+ $this->stdout('The directory path you supplied was empty. Please try again.');
+ }
+ }
+ }
+ while ($newPath != 'y' && ($this->__checkPath($projectPath) === true || $projectPath == '')) {
+ $newPath = $this->getInput('Directory '.$projectPath.' exists. Overwrite (y) or insert a new path', null, 'y');
+ if ($newPath != 'y') {
+ $projectPath = $newPath;
+ }
+ while ($projectPath == '') {
+ $projectPath = $this->getInput('The directory path you supplied was empty. Please try again.');
+ }
+ }
+ $parentPath = explode(DS, $projectPath);
+ $count = count($parentPath);
+ $appName = $parentPath[$count - 1];
+ if ($appName == '') {
+ $appName = $parentPath[$count - 2];
+ }
+ $this->__buildDirLayout($projectPath, $appName);
+ exit();
+ }
+/**
+ * Returns true if given path is a directory.
+ *
+ * @param string $projectPath
+ * @return True if given path is a directory.
+ */
+ function __checkPath($projectPath) {
+ if (is_dir($projectPath)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+/**
+ * Looks for a skeleton template of a Cake application,
+ * and if not found asks the user for a path. When there is a path
+ * this method will make a deep copy of the skeleton to the project directory.
+ * A default home page will be added, and the tmp file storage will be chmod'ed to 0777.
+ *
+ * @param string $projectPath
+ * @param string $appName
+ */
+ function __buildDirLayout($projectPath, $appName) {
+ $skel = '';
+ if ($this->__checkPath(CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'scripts'.DS.'templates'.DS.'skel') === true) {
+ $skel = CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'scripts'.DS.'templates'.DS.'skel';
+ } else {
+
+ while ($skel == '') {
+ $skel = $this->getInput("What is the full path for the cake install app directory?\nExample: ", null, ROOT.'myapp'.DS);
+
+ if ($skel == '') {
+ $this->stdout('The directory path you supplied was empty. Please try again.');
+ } else {
+ while ($this->__checkPath($skel) === false) {
+ $skel = $this->getInput('Directory path does not exist please choose another:');
+ }
+ }
+ }
+ }
+ $this->stdout('');
+ $this->hr();
+ $this->stdout("Skel Directory: $skel");
+ $this->stdout("Will be copied to:");
+ $this->stdout("New App Directory: $projectPath");
+ $this->hr();
+ $looksGood = $this->getInput('Look okay?', array('y', 'n', 'q'), 'y');
+
+ if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
+ $verboseOuptut = $this->getInput('Do you want verbose output?', array('y', 'n'), 'n');
+ $verbose = false;
+
+ if (low($verboseOuptut) == 'y' || low($verboseOuptut) == 'yes') {
+ $verbose = true;
+ }
+ $this->__copydirr($skel, $projectPath, 0755, $verbose);
+ $this->hr();
+ $this->stdout('Created: '.$projectPath);
+ $this->hr();
+ $this->stdout('Creating welcome page');
+ $this->hr();
+ $this->__defaultHome($projectPath, $appName);
+ $this->stdout('Welcome page created');
+ if (chmodr($projectPath.DS.'tmp', 0777) === false) {
+ $this->stdout('Could not set permissions on '. $projectPath.DS.'tmp'.DS.'*');
+ $this->stdout('You must manually check that these directories can be wrote to by the server');
+ }
+ return;
+ } elseif (low($looksGood) == 'q' || low($looksGood) == 'quit') {
+ $this->stdout('Bake Aborted.');
+ } else {
+ $this->project();
+ }
+ }
+/**
+ * Recursive directory copy.
+ *
+ * @param string $fromDir
+ * @param string $toDir
+ * @param octal $chmod
+ * @param boolean $verbose
+ * @return Success.
+ */
+ function __copydirr($fromDir, $toDir, $chmod = 0755, $verbose = false) {
+ $errors=array();
+ $messages=array();
+
+ uses('folder');
+ $folder = new Folder($toDir, true, 0755);
+
+ if (!is_writable($toDir)) {
+ $errors[]='target '.$toDir.' is not writable';
+ }
+
+ if (!is_dir($fromDir)) {
+ $errors[]='source '.$fromDir.' is not a directory';
+ }
+
+ if (!empty($errors)) {
+ if ($verbose) {
+ foreach ($errors as $err) {
+ $this->stdout('Error: '.$err);
+ }
+ }
+ return false;
+ }
+ $exceptions=array('.','..','.svn');
+ $handle = opendir($fromDir);
+
+ while (false!==($item = readdir($handle))) {
+ if (!in_array($item,$exceptions)) {
+ $from = $folder->addPathElement($fromDir, $item);
+ $to = $folder->addPathElement($toDir, $item);
+ if (is_file($from)) {
+ if (@copy($from, $to)) {
+ chmod($to, $chmod);
+ touch($to, filemtime($from));
+ $messages[]='File copied from '.$from.' to '.$to;
+ } else {
+ $errors[]='cannot copy file from '.$from.' to '.$to;
+ }
+ }
+
+ if (is_dir($from)) {
+ if (@mkdir($to)) {
+ chmod($to,$chmod);
+ $messages[]='Directory created: '.$to;
+ } else {
+ $errors[]='cannot create directory '.$to;
+ }
+ $this->__copydirr($from,$to,$chmod,$verbose);
+ }
+ }
+ }
+ closedir($handle);
+
+ if ($verbose) {
+ foreach ($errors as $err) {
+ $this->stdout('Error: '.$err);
+ }
+ foreach ($messages as $msg) {
+ $this->stdout($msg);
+ }
+ }
+ return true;
+ }
+
+ function __addAdminRoute($name) {
+ $file = file_get_contents(CONFIGS.'core.php');
+ if (preg_match('%([/\\t\\x20]*define\\(\'CAKE_ADMIN\',[\\t\\x20\'a-z]*\\);)%', $file, $match)) {
+ $result = str_replace($match[0], 'define(\'CAKE_ADMIN\', \''.$name.'\');', $file);
+
+ if (file_put_contents(CONFIGS.'core.php', $result)) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+/**
+ * Outputs an ASCII art banner to standard output.
+ *
+ */
+ function welcome()
+ {
+ $this->stdout('');
+ $this->stdout(' ___ __ _ _ ___ __ _ _ __ __ __ _ _ ___ ');
+ $this->stdout('| |__| |_/ |__ |__] |__| |__] |__] |__| |_/ |__ ');
+ $this->stdout('|___ | | | \_ |___ | | | | |__] | | | \_ |___ ');
+ $this->hr();
+ $this->stdout('');
+ }
+/**
+ * Writes a file with a default home page to the project.
+ *
+ * @param string $dir
+ * @param string $app
+ */
+ function __defaultHome($dir, $app) {
+ $path = $dir.DS.'views'.DS.'pages'.DS;
+ include(CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'scripts'.DS.'templates'.DS.'views'.DS.'home.thtml');
+ $this->__createFile($path.'home.thtml', $output);
+ }
+/**
+ * creates the proper pluralize controller for the url
+ *
+ * @param string $name must be a controller name in pluralized form
+ * @return string $name
+ */
+ function __controllerPath($name) {
+ return low(Inflector::underscore($name));
+ }
+/**
+ * creates the proper pluralize controller class name.
+ *
+ * @param string $name
+ * @return string $name
+ */
+ function __controllerName($name) {
+ return Inflector::pluralize(Inflector::camelize($name));
+ }
+/**
+ * creates the proper singular model name.
+ *
+ * @param string $name
+ * @return string $name
+ */
+ function __modelName($name) {
+ return Inflector::camelize(Inflector::singularize($name));
+ }
+/**
+ * creates the proper singular model key for associations.
+ *
+ * @param string $name
+ * @return string $name
+ */
+ function __modelKey($name) {
+ return Inflector::underscore(Inflector::singularize($name)).'_id';
+ }
+/**
+ * creates the proper model name from a foreign key.
+ *
+ * @param string $key
+ * @return string $name
+ */
+ function __modelNameFromKey($key) {
+ $name = str_replace('_id', '',$key);
+ return $this->__modelName($name);
+ }
+/**
+ * creates the singular name for use in views.
+ *
+ * @param string $name
+ * @return string $name
+ */
+ function __singularName($name) {
+ return Inflector::variable(Inflector::singularize($name));
+ }
+/**
+ * creates the plural name for views.
+ *
+ * @param string $name
+ * @return string $name
+ */
+ function __pluralName($name) {
+ return Inflector::variable(Inflector::pluralize($name));
+ }
+/**
+ * creates the singular human name used in views
+ *
+ * @param string $name
+ * @return string $name
+ */
+ function __singularHumanName($name) {
+ return Inflector::humanize(Inflector::underscore(Inflector::singularize($name)));
+ }
+/**
+ * creates the plural humna name used in views
+ *
+ * @param string $name
+ * @return string $name
+ */
+ function __pluralHumanName($name) {
+ return Inflector::humanize(Inflector::underscore(Inflector::pluralize($name)));
+ }
+/**
+ * outputs the a list of possible models or controllers from database
+ *
+ * @param string $useDbConfig
+ * @param string $type = Models or Controllers
+ * @return output
+ */
+ function __doList($useDbConfig = 'default', $type = 'Models') {
+ $db =& ConnectionManager::getDataSource($useDbConfig);
+ $usePrefix = empty($db->config['prefix']) ? '' : $db->config['prefix'];
+ if ($usePrefix) {
+ $tables = array();
+ foreach ($db->listSources() as $table) {
+ if (!strncmp($table, $usePrefix, strlen($usePrefix))) {
+ $tables[] = substr($table, strlen($usePrefix));
+ }
+ }
+ } else {
+ $tables = $db->listSources();
+ }
+ $this->__tables = $tables;
+ $this->stdout('Possible '.$type.' based on your current database:');
+ $this->__controllerNames = array();
+ $this->__modelNames = array();
+ $count = count($tables);
+ for ($i = 0; $i < $count; $i++) {
+ if (low($type) == 'controllers') {
+ $this->__controllerNames[] = $this->__controllerName($this->__modelName($tables[$i]));
+ $this->stdout($i + 1 . ". " . $this->__controllerNames[$i]);
+ } else {
+ $this->__modelNames[] = $this->__modelName($tables[$i]);
+ $this->stdout($i + 1 . ". " . $this->__modelNames[$i]);
+ }
+ }
+ }
+
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/.htaccess b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/.htaccess
new file mode 100644
index 0000000..00d12ab
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/.htaccess
@@ -0,0 +1,5 @@
+<IfModule mod_rewrite.c>
+ RewriteEngine on
+ RewriteRule ^$ webroot/ [L]
+ RewriteRule (.*) webroot/$1 [L]
+ </IfModule> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_controller.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_controller.php
new file mode 100644
index 0000000..411f7f0
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_controller.php
@@ -0,0 +1,41 @@
+<?php
+/* SVN FILE: $Id: app_controller.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * This file is application-wide controller file. You can put all
+ * application-wide controller-related methods here.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Short description for class.
+ *
+ * Add your application-wide methods in the class below, your controllers
+ * will inherit them.
+ *
+ * @package cake
+ * @subpackage cake.app
+ */
+class AppController extends Controller {
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_model.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_model.php
new file mode 100644
index 0000000..37eaecc
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_model.php
@@ -0,0 +1,43 @@
+<?php
+/* SVN FILE: $Id: app_model.php 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ * Application model for Cake.
+ *
+ * This file is application-wide model file. You can put all
+ * application-wide model-related methods here.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Application model for Cake.
+ *
+ * Add your application-wide methods in the class below, your models
+ * will inherit them.
+ *
+ * @package cake
+ * @subpackage cake.app
+ */
+class AppModel extends Model{
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/acl.ini.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/acl.ini.php
new file mode 100644
index 0000000..8179591
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/acl.ini.php
@@ -0,0 +1,76 @@
+;<?php die() ?>
+; SVN FILE: $Id: acl.ini.php 6305 2008-01-02 02:33:56Z phpnut $
+;/**
+; * Short description for file.
+; *
+; *
+; * PHP versions 4 and 5
+; *
+; * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+; * Copyright 2005-2008, Cake Software Foundation, Inc.
+; * 1785 E. Sahara Avenue, Suite 490-204
+; * Las Vegas, Nevada 89104
+; *
+; * Licensed under The MIT License
+; * Redistributions of files must retain the above copyright notice.
+; *
+; * @filesource
+; * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+; * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+; * @package cake
+; * @subpackage cake.app.config
+; * @since CakePHP(tm) v 0.10.0.1076
+; * @version $Revision: 6305 $
+; * @modifiedby $LastChangedBy: phpnut $
+; * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+; * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+; */
+
+; acl.ini.php - Cake ACL Configuration
+; ---------------------------------------------------------------------
+; Use this file to specify user permissions.
+; aco = access control object (something in your application)
+; aro = access request object (something requesting access)
+;
+; User records are added as follows:
+;
+; [uid]
+; groups = group1, group2, group3
+; allow = aco1, aco2, aco3
+; deny = aco4, aco5, aco6
+;
+; Group records are added in a similar manner:
+;
+; [gid]
+; allow = aco1, aco2, aco3
+; deny = aco4, aco5, aco6
+;
+; The allow, deny, and groups sections are all optional.
+; NOTE: groups names *cannot* ever be the same as usernames!
+;
+; ACL permissions are checked in the following order:
+; 1. Check for user denies (and DENY if specified)
+; 2. Check for user allows (and ALLOW if specified)
+; 3. Gather user's groups
+; 4. Check group denies (and DENY if specified)
+; 5. Check group allows (and ALLOW if specified)
+; 6. If no aro, aco, or group information is found, DENY
+;
+; ---------------------------------------------------------------------
+
+;-------------------------------------
+;Users
+;-------------------------------------
+
+[username-goes-here]
+groups = group1, group2
+deny = aco1, aco2
+allow = aco3, aco4
+
+;-------------------------------------
+;Groups
+;-------------------------------------
+
+[groupname-goes-here]
+deny = aco5, aco6
+allow = aco7, aco8 \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/bootstrap.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/bootstrap.php
new file mode 100644
index 0000000..ef4cedf
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/bootstrap.php
@@ -0,0 +1,46 @@
+<?php
+/* SVN FILE: $Id: bootstrap.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.config
+ * @since CakePHP(tm) v 0.10.8.2117
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ *
+ * This file is loaded automatically by the app/webroot/index.php file after the core bootstrap.php is loaded
+ * This is an application wide file to load any function that is not used within a class define.
+ * You can also use this to include or require any files in your application.
+ *
+ */
+/**
+ * The settings below can be used to set additional paths to models, views and controllers.
+ * This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)
+ *
+ * $modelPaths = array('full path to models', 'second full path to models', 'etc...');
+ * $viewPaths = array('this path to views', 'second full path to views', 'etc...');
+ * $controllerPaths = array('this path to controllers', 'second full path to controllers', 'etc...');
+ *
+ */
+//EOF
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/core.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/core.php
new file mode 100644
index 0000000..77cf1ff
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/core.php
@@ -0,0 +1,146 @@
+<?php
+/* SVN FILE: $Id: core.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * This is core configuration file.
+ *
+ * Use it to configure core behaviour ofCake.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.config
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * If you do not have mod rewrite on your system
+ * or if you prefer to use CakePHP pretty urls.
+ * uncomment the line below.
+ * Note: If you do have mod rewrite but prefer the
+ * CakePHP pretty urls, you also have to remove the
+ * .htaccess files
+ * release/.htaccess
+ * release/app/.htaccess
+ * release/app/webroot/.htaccess
+ */
+// define ('BASE_URL', env('SCRIPT_NAME'));
+/**
+ * Set debug level here:
+ * - 0: production
+ * - 1: development
+ * - 2: full debug with sql
+ * - 3: full debug with sql and dump of the current object
+ *
+ * In production, the "flash messages" redirect after a time interval.
+ * With the other debug levels you get to click the "flash message" to continue.
+ *
+ */
+ define('DEBUG', 1);
+/**
+ * Turn of caching checking wide.
+ * You must still use the controller var cacheAction inside you controller class.
+ * You can either set it controller wide, or in each controller method.
+ * use var $cacheAction = true; or in the controller method $this->cacheAction = true;
+ */
+ define('CACHE_CHECK', false);
+/**
+ * Error constant. Used for differentiating error logging and debugging.
+ * Currently PHP supports LOG_DEBUG
+ */
+ define('LOG_ERROR', 2);
+/**
+ * CakePHP includes 3 types of session saves
+ * database or file. Set this to your preferred method.
+ * If you want to use your own save handler place it in
+ * app/config/name.php DO NOT USE file or database as the name.
+ * and use just the name portion below.
+ *
+ * Setting this to cake will save files to /cakedistro/tmp directory
+ * Setting it to php will use the php default save path
+ * Setting it to database will use the database
+ *
+ */
+ define('CAKE_SESSION_SAVE', 'php');
+/**
+ * If using you own table name for storing sessions
+ * set the table name here.
+ * DO NOT INCLUDE PREFIX IF YOU HAVE SET ONE IN database.php
+ *
+ */
+ define('CAKE_SESSION_TABLE', 'cake_sessions');
+/**
+ * Set a random string of used in session.
+ *
+ */
+ define('CAKE_SESSION_STRING', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
+/**
+ * Set the name of session cookie
+ *
+ */
+ define('CAKE_SESSION_COOKIE', 'CAKEPHP');
+/**
+ * Set level of Cake security.
+ *
+ */
+ define('CAKE_SECURITY', 'high');
+/**
+ * Set Cake Session time out.
+ * If CAKE_SECURITY define is set
+ * high: multiplied by 10
+ * medium: is multiplied by 100
+ * low is: multiplied by 300
+ *
+ * Number below is seconds.
+ */
+ define('CAKE_SESSION_TIMEOUT', '120');
+/**
+ * Uncomment the define below to use cake built in admin routes.
+ * You can set this value to anything you want.
+ * All methods related to the admin route should be prefixed with the
+ * name you set CAKE_ADMIN to.
+ * For example: admin_index, admin_edit
+ */
+// define('CAKE_ADMIN', 'admin');
+/**
+ * The define below is used to turn cake built webservices
+ * on or off. Default setting is off.
+ */
+ define('WEBSERVICES', 'off');
+/**
+ * Compress output CSS (removing comments, whitespace, repeating tags etc.)
+ * This requires a/var/cache directory to be writable by the web server (caching).
+ * To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use Controller::cssTag().
+ */
+ define('COMPRESS_CSS', false);
+/**
+ * If set to true, helpers would output data instead of returning it.
+ */
+ 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...
+ */
+ define('ACL_CLASSNAME', 'DB_ACL');
+ define('ACL_FILENAME', 'dbacl' . DS . 'db_acl');
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/database.php.default b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/database.php.default
new file mode 100644
index 0000000..fbbb1a3
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/database.php.default
@@ -0,0 +1,74 @@
+<?php
+/* SVN FILE: $Id: database.php.default 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * This is core configuration file.
+ *
+ * Use it to configure core behaviour ofCake.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.config
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * In this file you set up your database connection details.
+ *
+ * @package cake
+ * @subpackage cake.config
+ */
+/**
+ * Database configuration class.
+ * You can specify multiple configurations for production, development and testing.
+ *
+ * driver =>
+ * mysql, postgres, sqlite, adodb-drivername, pear-drivername
+ *
+ * connect =>
+ * MySQL set the connect to either mysql_pconnect of mysql_connect
+ * PostgreSQL set the connect to either pg_pconnect of pg_connect
+ * SQLite set the connect to sqlite_popen sqlite_open
+ * ADOdb set the connect to one of these
+ * (http://phplens.com/adodb/supported.databases.html) and
+ * append it '|p' for persistent connection. (mssql|p for example, or just mssql for not persistent)
+ *
+ * host =>
+ * the host you connect to the database
+ * MySQL 'localhost' to add a port number use 'localhost:port#'
+ * PostgreSQL 'localhost' to add a port number use 'localhost port=5432'
+ *
+ */
+class DATABASE_CONFIG
+{
+ var $default = array('driver' => 'mysql',
+ 'connect' => 'mysql_connect',
+ 'host' => 'localhost',
+ 'login' => 'user',
+ 'password' => 'password',
+ 'database' => 'project_name',
+ 'prefix' => '');
+
+ var $test = array('driver' => 'mysql',
+ 'connect' => 'mysql_connect',
+ 'host' => 'localhost',
+ 'login' => 'user',
+ 'password' => 'password',
+ 'database' => 'project_name-test',
+ 'prefix' => '');
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/inflections.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/inflections.php
new file mode 100644
index 0000000..e08a7d8
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/inflections.php
@@ -0,0 +1,72 @@
+<?php
+/* SVN FILE: $Id: inflections.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Custom Inflected Words.
+ *
+ * This file is used to hold words that are not matched in the normail Inflector::pluralize() and
+ * Inflector::singularize()
+ *
+ * PHP versions 4 and %
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.config
+ * @since CakePHP(tm) v 1.0.0.2312
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * This is a key => value array of regex used to match words.
+ * If key matches then the value is returned.
+ *
+ * $pluralRules = array('/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', '/([m|l])ouse$/i' => '\1ice');
+ */
+ $pluralRules = array();
+/**
+ * This is a key only array of plural words that should not be inflected.
+ * Notice the last comma
+ *
+ * $uninflectedPlural = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox');
+ */
+ $uninflectedPlural = array();
+/**
+ * This is a key => value array of plural irregular words.
+ * If key matches then the value is returned.
+ *
+ * $irregularPlural = array('atlas' => 'atlases', 'beef' => 'beefs', 'brother' => 'brothers')
+ */
+ $irregularPlural = array();
+/**
+ * This is a key => value array of regex used to match words.
+ * If key matches then the value is returned.
+ *
+ * $singularRules = array('/(s)tatuses$/i' => '\1\2tatus', '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i')
+ */
+ $singularRules = array();
+/**
+ * This is a key only array of singular words that should not be inflected.
+ * You should not have to change this value below if you do change it use same format
+ * as the $uninflectedPlural above.
+ */
+ $uninflectedSingular = $uninflectedPlural;
+/**
+ * This is a key => value array of singular irregular words.
+ * Most of the time this will be a reverse of the above $irregularPlural array
+ * You should not have to change this value below if you do change it use same format
+ *
+ * $irregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother')
+ */
+ $irregularSingular = array_flip($irregularPlural);
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/routes.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/routes.php
new file mode 100644
index 0000000..45ae36a
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/routes.php
@@ -0,0 +1,46 @@
+<?php
+/* SVN FILE: $Id: routes.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * In this file, you set up routes to your controllers and their actions.
+ * Routes are very important mechanism that allows you to freely connect
+ * different urls to chosen controllers and their actions (functions).
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.config
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Here, we are connecting '/' (base path) to controller called 'Pages',
+ * its action called 'display', and we pass a param to select the view file
+ * to use (in this case, /app/views/pages/home.thtml)...
+ */
+ $Route->connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
+/**
+ * ...and connect the rest of 'Pages' controller's urls.
+ */
+ $Route->connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
+/**
+ * Then we connect url '/test' to our test controller. This is helpfull in
+ * developement.
+ */
+ $Route->connect('/tests', array('controller' => 'tests', 'action' => 'index'));
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/db_acl.sql b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/db_acl.sql
new file mode 100644
index 0000000..8c7aae8
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/db_acl.sql
@@ -0,0 +1,30 @@
+CREATE TABLE `acos` (
+ `id` int(11) NOT NULL auto_increment,
+ `model` varchar(255) NOT NULL default '',
+ `object_id` int(11) default NULL,
+ `alias` varchar(255) NOT NULL default '',
+ `lft` int(11) default NULL,
+ `rght` int(11) default NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `aros` (
+ `id` int(11) NOT NULL auto_increment,
+ `model` varchar(255) NOT NULL default '',
+ `user_id` int(11) default NULL,
+ `alias` varchar(255) NOT NULL default '',
+ `lft` int(11) default NULL,
+ `rght` int(11) default NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `aros_acos` (
+ `id` int(11) NOT NULL auto_increment,
+ `aro_id` int(11) default NULL,
+ `aco_id` int(11) default NULL,
+ `_create` int(1) NOT NULL default '0',
+ `_read` int(1) NOT NULL default '0',
+ `_update` int(1) NOT NULL default '0',
+ `_delete` int(11) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+);
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/sessions.sql b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/sessions.sql
new file mode 100644
index 0000000..7166ae4
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/sessions.sql
@@ -0,0 +1,11 @@
+-- @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
+-- @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+-- @since CakePHP v 0.10.8.1997
+-- @version $Revision: 4409 $
+
+CREATE TABLE cake_sessions (
+ id varchar(255) NOT NULL default '',
+ data text,
+ expires int(11) default NULL,
+ PRIMARY KEY (id)
+); \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/controllers/pages_controller.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/controllers/pages_controller.php
new file mode 100644
index 0000000..b308565
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/controllers/pages_controller.php
@@ -0,0 +1,105 @@
+<?php
+/* SVN FILE: $Id: pages_controller.php 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ * Short description for file.
+ *
+ * This file is application-wide controller file. You can put all
+ * application-wide controller-related methods here.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.controllers
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+/**
+ * Short description for class.
+ *
+ * This file is application-wide controller file. You can put all
+ * application-wide controller-related methods here.
+ *
+ * Add your application-wide methods in the class below, your controllers
+ * will inherit them.
+ *
+ * @package cake
+ * @subpackage cake.app.controllers
+ */
+class PagesController extends AppController{
+
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $name = 'Pages';
+
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ */
+ var $helpers = array('Html');
+
+/**
+ * This controller does not use a model
+ *
+ * @var $uses
+ */
+ var $uses = null;
+
+/**
+ * Displays a view
+ *
+ */
+ function display() {
+ if (!func_num_args()) {
+ $this->redirect('/');
+ }
+
+ $path=func_get_args();
+
+ if (!count($path)) {
+ $this->redirect('/');
+ }
+
+ $count =count($path);
+ $page =null;
+ $subpage=null;
+ $title =null;
+
+ if (!empty($path[0])) {
+ $page = $path[0];
+ }
+
+ if (!empty($path[1])) {
+ $subpage = $path[1];
+ }
+
+ if (!empty($path[$count - 1])) {
+ $title = ucfirst($path[$count - 1]);
+ }
+
+ $this->set('page', $page);
+ $this->set('subpage', $subpage);
+ $this->set('title', $title);
+ $this->render(join('/', $path));
+ }
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/index.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/index.php
new file mode 100644
index 0000000..bd8993b
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/index.php
@@ -0,0 +1,26 @@
+<?php
+/* SVN FILE: $Id: index.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/ajax.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/ajax.thtml
new file mode 100644
index 0000000..c6daffc
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/ajax.thtml
@@ -0,0 +1,30 @@
+<?php
+/* SVN FILE: $Id: ajax.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ *
+ *
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.layouts
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<?php echo $content_for_layout; ?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/default.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/default.thtml
new file mode 100644
index 0000000..0172200
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/default.thtml
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>CakePHP(tm) : <?php echo $title_for_layout;?></title>
+<link rel="icon" href="<?php echo $this->webroot . 'favicon.ico';?>" type="image/x-icon" />
+<link rel="shortcut icon" href="<?php echo $this->webroot . 'favicon.ico';?>" type="image/x-icon" />
+<?php echo $html->css('cake.generic');?>
+</head>
+<body>
+ <div id="container">
+ <div id="header">
+ <h1>CakePHP Rapid Development</h1>
+ </div>
+ <div id="content">
+ <?php if ($session->check('Message.flash'))
+ {
+ $session->flash();
+ }
+ echo $content_for_layout;
+ ?>
+ </div>
+ <div id="footer">
+ &nbsp;
+ <a href="http://www.cakephp.org/" target="_new">
+ <?php echo $html->image('cake.power.png', array('alt'=>"CakePHP(tm) : Rapid Development Framework", 'border'=>"0"));?>
+ </a>
+ </div>
+ </div>
+</body>
+</html> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/flash.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/flash.thtml
new file mode 100644
index 0000000..b1880c2
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/flash.thtml
@@ -0,0 +1,50 @@
+<?php
+/* SVN FILE: $Id: flash.thtml 6305 2008-01-02 02:33:56Z phpnut $ */
+
+/**
+ *
+ *
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.libs.view.templates.layouts
+ * @since CakePHP(tm) v 0.10.0.1076
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title><?php echo $page_title?></title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<?php if (Configure::read() == 0) { ?>
+<meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>"/>
+<?php } ?>
+<style><!--
+P { text-align:center; font:bold 1.1em sans-serif }
+A { color:#444; text-decoration:none }
+A:HOVER { text-decoration: underline; color:#44E }
+--></style>
+</head>
+
+<body>
+
+<p><a href="<?php echo $url?>"><?php echo $message?></a></p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/.htaccess b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/.htaccess
new file mode 100644
index 0000000..8ca27c0
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/.htaccess
@@ -0,0 +1,6 @@
+<IfModule mod_rewrite.c>
+ RewriteEngine On
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
+</IfModule> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css.php
new file mode 100644
index 0000000..23223a6
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css.php
@@ -0,0 +1,100 @@
+<?php
+/* SVN FILE: $Id: css.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.webroot
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Enter description here...
+ */
+ require(CONFIGS . 'paths.php');
+ require(CAKE . 'basics.php');
+ require(LIBS . 'folder.php');
+ require(LIBS . 'file.php');
+ require(LIBS . 'legacy.php');
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $path
+ * @param unknown_type $name
+ * @return unknown
+ */
+ function make_clean_css($path, $name) {
+ require(VENDORS . 'csspp' . DS . 'csspp.php');
+ $data =file_get_contents($path);
+ $csspp =new csspp();
+ $output=$csspp->compress($data);
+ $ratio =100 - (round(strlen($output) / strlen($data), 3) * 100);
+ $output=" /* file: $name, ratio: $ratio% */ " . $output;
+ return $output;
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $path
+ * @param unknown_type $content
+ * @return unknown
+ */
+ function write_css_cache($path, $content) {
+ if (!is_dir(dirname($path))) {
+ mkdir(dirname($path));
+ }
+ $cache=new File($path);
+ return $cache->write($content);
+ }
+
+ if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) {
+ die('Wrong file name.');
+ }
+
+ $filename = 'css/' . $regs[1];
+ $filepath = CSS . $regs[1];
+ $cachepath = CACHE . 'css' . DS . str_replace(array('/','\\'), '-', $regs[1]);
+
+ if (!file_exists($filepath)) {
+ die('Wrong file name.');
+ }
+
+ if (file_exists($cachepath)) {
+ $templateModified=filemtime($filepath);
+ $cacheModified =filemtime($cachepath);
+
+ if ($templateModified > $cacheModified) {
+ $output=make_clean_css($filepath, $filename);
+ write_css_cache($cachepath, $output);
+ } else {
+ $output = file_get_contents($cachepath);
+ }
+ } else {
+ $output=make_clean_css($filepath, $filename);
+ write_css_cache($cachepath, $output);
+ }
+ header("Date: " . date("D, j M Y G:i:s ", $templateModified) . 'GMT');
+ header("Content-Type: text/css");
+ header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT");
+ header("Cache-Control: cache"); // HTTP/1.1
+ header("Pragma: cache"); // HTTP/1.0
+ print $output;
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css/cake.generic.css b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css/cake.generic.css
new file mode 100644
index 0000000..491dc7a
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css/cake.generic.css
@@ -0,0 +1,251 @@
+*{
+margin:0;
+padding:0;
+}
+
+body{
+font-family:"frutiger linotype","lucida grande",helvetica,arial,sans-serif;
+text-align:center;
+color:#333;
+font-size: 76%;
+}
+
+/* General Style Info */
+a{
+color:#003d4c;
+text-decoration:underline;
+}
+a:hover{
+color:#003d4c;
+text-decoration:none;
+}
+
+a img{
+border:none;
+}
+
+h1, h2, h3, h4{
+font-weight:normal;
+}
+
+h1{
+color: #003d4c;
+margin:0.3em 0;
+font-size: 180%;
+}
+
+h2{
+color:#c6c65b;
+padding-top: 1em;
+margin:0.3em 0;
+font-size: 180%;
+}
+
+h3{
+color:#c6c65b;
+padding-top:2em;
+font-size: 140%;
+}
+
+h4{
+color:#c6c65b;
+padding-top:0.5em;
+font-weight:normal;
+}
+
+em {
+font-size: 12px;
+}
+
+ul, li {
+margin: 0 12px;
+}
+
+/* Layout */
+
+#container{
+text-align:left;
+}
+
+#header{
+margin-top: 1em;
+padding: 4px 20px;
+}
+
+#content{
+clear:both;
+padding: 0px 40px 10px 40px;
+background-color: #fff;
+color: #333;
+}
+#footer{
+clear:both;
+padding: 6px 10px;
+text-align: right;
+}
+
+/* tables */
+
+table {
+width: 100%;
+border-top: 1px solid #ccc;
+border-left: 1px solid #ccc;
+border-bottom: 1px solid #ccc;
+color:#333;
+background-color: #fff;
+clear:both;
+padding: 0;
+margin: 0 0 2em 0;
+white-space: normal;
+}
+th {
+background-color: #e2e2e2;
+border-top: 1px solid #fff;
+border-left: 1px solid #fff;
+border-right: 1px solid #003d4c;
+border-bottom: 1px solid #003d4c;
+text-align: center;
+padding:1px 4px;
+}
+table tr td {
+border-right: 1px solid #ddd;
+padding:4px 4px;
+vertical-align:top;
+text-align: center;
+}
+table tr.altRow td {
+background: #f4f4f4;
+}
+table td.actions {
+ white-space: nowrap;
+}
+#cakeSqlLog td {
+text-align: left;
+padding: 4px 8px;
+background: #fff;
+border-bottom: 2px solid #ccc;
+}
+
+/* scaffold show */
+
+div.related {
+clear:both;
+display:block;
+}
+dl {
+line-height:2em;
+margin:0em 1em;
+float:left;
+width: 400px;
+}
+dt {
+font-weight: bold;
+vertical-align:top;
+}
+dd {
+margin-left:10em;
+margin-top:-2em;
+vertical-align:top;
+}
+
+/* notices and errors */
+
+#flashMessage, .error, .error_message {
+color:#900;
+font-size: 16px;
+background-color: #fff;
+margin: 8px 0px;
+font-weight: bold;
+}
+.error_message {
+clear: both;
+}
+.error em {
+font-size: 18px;
+color: #003d4c;
+}
+.notice {
+color: #656565;
+font-size: 14px;
+background-color: #f4f4f4;
+padding: 0.5em;
+margin: 1em 0;
+display:block;
+}
+.tip {
+color: #656565;
+background-color: #ddd;
+}
+
+/* forms */
+
+form {
+margin-top: 2em;
+}
+form div{
+vertical-align: text-top;
+margin-left: 1em;
+margin-bottom:2em;
+}
+form div.date{
+margin-left: 0em;
+}
+label {
+display: block;
+float:left;
+width: 140px;
+font-size: 14px;
+padding-right: 20px;
+}
+input[type=checkbox] {
+float: left;
+clear: left;
+margin: 2px 6px 7px 2px;
+}
+input, textarea {
+clear: both;
+display:block;
+font-size: 14px;
+font-family: inherit;
+}
+select {
+clear: both;
+vertical-align: text-bottom;
+font-size: 14px;
+font-family: inherit;
+}
+option {
+font-size: 14px;
+font-family: inherit;
+padding: 0 0.3em;
+}
+input[type=submit] {
+display: inline;
+vertical-align: bottom;
+}
+div.required {
+clear: both;
+color:#222;
+font-weight:bold;
+}
+div.optional {
+clear: both;
+color:#555;
+}
+div.submit {
+clear: both;
+margin-top: 40px;
+margin-left: 140px;
+}
+/* action links */
+ul.actions {
+float: left;
+margin-left:20px;
+width: 200px;
+}
+ul.actions li {
+margin-top: 4px;
+}
+pre {
+padding: 1em;
+} \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/favicon.ico b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/favicon.ico
new file mode 100644
index 0000000..1bc32bd
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/favicon.ico
Binary files differ
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/img/cake.power.png b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/img/cake.power.png
new file mode 100644
index 0000000..699ef80
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/img/cake.power.png
Binary files differ
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/index.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/index.php
new file mode 100644
index 0000000..6874e2b
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/index.php
@@ -0,0 +1,87 @@
+<?php
+/* SVN FILE: $Id: index.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * Long description for file
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.webroot
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Do not change
+ */
+ if (!defined('DS')) {
+ define('DS', DIRECTORY_SEPARATOR);
+ }
+/**
+ * These defines should only be edited if you have cake installed in
+ * a directory layout other than the way it is distributed.
+ * Each define has a commented line of code that explains what you would change.
+ *
+ */
+ if (!defined('ROOT')) {
+ //define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
+ //You should also use the DS define to seperate your directories
+ define('ROOT', dirname(dirname(dirname(__FILE__))));
+ }
+ if (!defined('APP_DIR')) {
+ //define('APP_DIR', 'DIRECTORY NAME OF APPLICATION';
+ define('APP_DIR', basename(dirname(dirname(__FILE__))));
+ }
+/**
+ * This only needs to be changed if the cake installed libs are located
+ * outside of the distributed directory structure.
+ */
+ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
+ //define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
+ //You should also use the DS define to seperate your directories
+ define('CAKE_CORE_INCLUDE_PATH', ROOT);
+ }
+///////////////////////////////
+//DO NOT EDIT BELOW THIS LINE//
+///////////////////////////////
+ if (!defined('WEBROOT_DIR')) {
+ define('WEBROOT_DIR', basename(dirname(__FILE__)));
+ }
+ if (!defined('WWW_ROOT')) {
+ define('WWW_ROOT', dirname(__FILE__) . DS);
+ }
+ if (!defined('CORE_PATH')) {
+ if (function_exists('ini_set')) {
+ ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'));
+ define('APP_PATH', null);
+ define('CORE_PATH', null);
+ } else {
+ define('APP_PATH', ROOT . DS . APP_DIR . DS);
+ define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
+ }
+ }
+ require CORE_PATH . 'cake' . DS . 'bootstrap.php';
+ if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
+ } else {
+ $Dispatcher = new Dispatcher();
+ $Dispatcher->dispatch($url);
+ }
+ if (Configure::read() > 0) {
+ echo "<!-- " . round(getMicrotime() - $TIME_START, 4) . "s -->";
+ }
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/js/vendors.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/js/vendors.php
new file mode 100644
index 0000000..1075bfb
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/js/vendors.php
@@ -0,0 +1,43 @@
+<?php
+/* SVN FILE: $Id: vendors.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Short description for file.
+ *
+ * This file includes js vendor-files from /vendor/ directory if they need to
+ * be accessible to the public.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.webroot.js
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Enter description here...
+ */
+$file = $_GET['file'];
+$pos = strpos($file, '..');
+if ($pos === false) {
+ if (is_file('../../vendors/javascript/'.$file) && (preg_match('/(\/.+)\\.js/', $file)))
+ {
+ readfile('../../vendors/javascript/'.$file);
+ }
+} else {
+ header('HTTP/1.1 404 Not Found');
+}
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/views/home.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/views/home.thtml
new file mode 100644
index 0000000..d107e55
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/views/home.thtml
@@ -0,0 +1,16 @@
+<?php
+$output = "<p class=\"notice\">Your database configuration file is <?php echo file_exists(CONFIGS.'database.php') ?' present.' . \$filePresent = ' ' : ' not present.'; ?></p>\n";
+$output .= "<?php if (!empty(\$filePresent)):?>\n";
+$output .= "<?php uses('model' . DS . 'connection_manager'); \$db = ConnectionManager::getInstance(); ?>\n";
+$output .= "<?php \$connected = \$db->getDataSource('default'); ?>\n";
+$output .= "<p class=\"notice\">Cake<?php echo \$connected->isConnected() ? ' is able to' : ' is not able to';?> connect to the database.</p>\n";
+$output .= "<br />\n";
+$output .= "<?php endif; ?>\n";
+$output .= "<h1>Sweet, \"".Inflector::humanize($app)."\" got Baked by CakePHP!</h1>\n";
+$output .= "<h2>Editing this Page</h2>\n";
+$output .= "<p>\n";
+$output .= "To change the content of this page, edit: ".$dir.DS."views".DS."pages".DS."home.thtml.<br />\n";
+$output .= "To change its layout, edit: ".$dir.DS."views".DS."layouts".DS."default.thtml.<br />\n";
+$output .= "You can also add some CSS styles for your pages at: ".$dir.DS."webroot/css/.\n";
+$output .= "</p>\n";
+?> \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/CHANGELOG.txt b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/CHANGELOG.txt
new file mode 100644
index 0000000..7d1e628
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/CHANGELOG.txt
@@ -0,0 +1,13 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+// +---------------------------------------------------------------------------------------------------+//
+// + $Id: CHANGELOG.txt 4064 2006-12-04 05:29:12Z phpnut $
+// + Last Modified: $Date: 2006-12-04 00:29:12 -0500 (Mon, 04 Dec 2006) $
+// + Modified By: $LastChangedBy: phpnut $
+// +---------------------------------------------------------------------------------------------------+//
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Changelog:
+https://trac.cakephp.org/wiki/changelog/1.1.x.x
+
+Release Notes:
+https://trac.cakephp.org/wiki/notes/1.1.x.x \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/COPYING.txt b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/COPYING.txt
new file mode 100644
index 0000000..4787242
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/COPYING.txt
@@ -0,0 +1,24 @@
+The MIT License
+
+CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+Copyright 2005-2007, Cake Software Foundation, Inc.
+ 1785 E. Sahara Avenue, Suite 490-204
+ Las Vegas, Nevada 89104
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/INSTALL.txt b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/INSTALL.txt
new file mode 100644
index 0000000..47698fc
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/INSTALL.txt
@@ -0,0 +1,40 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+// +---------------------------------------------------------------------------------------------------+//
+// + $Id: INSTALL.txt 4409 2007-02-02 13:20:59Z phpnut $
+// + Last Modified: $Date: 2007-02-02 08:20:59 -0500 (Fri, 02 Feb 2007) $
+// + Modified By: $LastChangedBy: phpnut $
+// +---------------------------------------------------------------------------------------------------+//
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+In order use CakePHP you must first have a server that has all the required libraries and programs to run CakePHP:
+
+Here are the requirements for setting up a server to run CakePHP:
+
+ 1. An HTTP server (like Apache) with the following enabled.
+ 2. PHP 4.3.2 or greater. Yes, CakePHP works great in either PHP 4 or 5.
+ 3. A database engine (right now, there is support for MySQL, MsSQL, Oracle, Sqlite, PostgreSQL and a wrapper for ADODB).
+
+For development we can place the whole Cake installation directory inside the specified DocumentRoot.
+
+ 1. Unpack latest distribution in your DocumentRoot.
+ 2. Rename the directory to anything you like.
+ 3. Access the install.
+ a. If mod_rewrite is working then http://www.example.com/my_directory
+ 1. If you receive a "Bad Request" add the trailing slash, http://www.example.com/my_directory/
+ 4. If mod_rewrite is not working you will need to remove the comment from app/config/core.php
+ a. Around line 40: define ('BASE_URL', env('SCRIPT_NAME'));
+ b. Then access using http://www.example.com/my_directory/index.php/pages to verify installation is working
+
+For more information on installation see http://manual.cakephp.org/chapter/installing
+
+Good resources for help.
+* The Bakery :: Everything CakePHP (http://bakery.cakephp.org/)
+* CakePHP Manual :: Your Rapid Development Cookbook (http://manual.cakephp.org/)
+* CakePHP API :: Docblock Your Best Friend (http://api.cakephp.org/)
+* CakePHP Google Group :: Community mailing list (http://groups-beta.google.com/group/cake-php)
+* CakePHP(tm) :: The Rapid Development Framework (http://www.cakephp.org/)
+* CakeForge :: Open Development for CakePHP (http://cakeforge.org/)
+* CakePHP Trac :: For the Development of CakePHP (Tickets, SVN browser, Roadmap, Changelogs) (https://trac.cakephp.org/)
+* Live chat about CakePHP (irc.freenode.net #cakephp)
+ Web Interface to IRC (http://irc.cakephp.org/irc.htm) \ No newline at end of file
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/README.txt b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/README.txt
new file mode 100644
index 0000000..234e171
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/docs/README.txt
@@ -0,0 +1,19 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+// +---------------------------------------------------------------------------------------------------+//
+// + $Id: README.txt 4064 2006-12-04 05:29:12Z phpnut $
+// + Last Modified: $Date: 2006-12-04 00:29:12 -0500 (Mon, 04 Dec 2006) $
+// + Modified By: $LastChangedBy: phpnut $
+// +---------------------------------------------------------------------------------------------------+//
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+This README will be updated
+
+Home:
+http://www.cakephp.org/
+
+Documentation
+http://manual.cakephp.org/
+
+Development:
+https://trac.cakephp.org/
+
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/index.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/index.php
new file mode 100644
index 0000000..e78de13
--- /dev/null
+++ b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/index.php
@@ -0,0 +1,77 @@
+<?php
+/* SVN FILE: $Id: index.php 6305 2008-01-02 02:33:56Z phpnut $ */
+/**
+ * Requests collector.
+ *
+ * This file collects requests if:
+ * - no mod_rewrite is avilable or .htaccess files are not supported
+ * -/public is not set as a web root.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
+ * Copyright 2005-2008, Cake Software Foundation, Inc.
+ * 1785 E. Sahara Avenue, Suite 490-204
+ * Las Vegas, Nevada 89104
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @since CakePHP(tm) v 0.2.9
+ * @version $Revision: 6305 $
+ * @modifiedby $LastChangedBy: phpnut $
+ * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+/**
+ * Get Cake's root directory
+ */
+ define('APP_DIR', 'app');
+ define('DS', DIRECTORY_SEPARATOR);
+ define('ROOT', dirname(__FILE__));
+ define('WEBROOT_DIR', 'webroot');
+ define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);
+/**
+ * This only needs to be changed if the cake installed libs are located
+ * outside of the distributed directory structure.
+ */
+ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
+ //define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
+ define('CAKE_CORE_INCLUDE_PATH', ROOT);
+ }
+ if (function_exists('ini_set')) {
+ ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS);
+ define('APP_PATH', null);
+ define('CORE_PATH', null);
+ } else {
+ define('APP_PATH', ROOT . DS . APP_DIR . DS);
+ define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
+ }
+ require CORE_PATH . 'cake' . DS . 'basics.php';
+ require APP_PATH . 'config' . DS . 'core.php';
+ require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
+ $bootstrap=true;
+ $uri =setUri();
+/**
+ * As mod_rewrite (or .htaccess files) is not working, we need to take care
+ * of what would normally be rewritten, i.e. the static files in app/webroot/
+ */
+ if ($uri === '/' || $uri === '/index.php') {
+ $_GET['url'] = '/';
+ require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
+ } else {
+ $elements=explode('/index.php', $uri);
+
+ if (!empty($elements[1])) {
+ $path = $elements[1];
+ } else {
+ $path = '/';
+ }
+ $_GET['url']=$path;
+ require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
+ }
+?> \ No newline at end of file