From aad807eb4b6275f5e7245bdd79ee7a3d374da013 Mon Sep 17 00:00:00 2001 From: AD7six Date: Fri, 21 Jan 2011 22:47:17 +0100 Subject: [PATCH] adding source generated from the import branch --- source/appendices.rst | 11 + .../migrating-from-cakephp-1-2-to-1-3.rst | 1641 +++++++ .../new-features-in-cakephp-1-3.rst | 1287 ++++++ source/basic-principles-of-cakephp.rst | 29 + .../a-typical-cakephp-request.rst | 103 + .../cakephp-conventions.rst | 31 + .../controller-conventions.rst | 163 + .../file-and-classname-conventions.rst | 53 + .../model-and-database-conventions.rst | 111 + .../cakephp-conventions/view-conventions.rst | 73 + .../cakephp-folder-structure.rst | 154 + .../cakephp-structure.rst | 21 + .../application-extensions.rst | 45 + ...roller-extensions-quot-components-quot.rst | 49 + .../model-extensions-quot-behaviors-quot.rst | 65 + .../view-extensions-quot-helpers-quot.rst | 27 + source/beginning-with-cakephp.rst | 25 + .../understanding-model-view-controller.rst | 138 + .../what-is-cakephp-why-use-it.rst | 115 + .../where-to-get-help.rst | 207 +- source/common-tasks-with-cakephp.rst | 5 + source/common-tasks-with-cakephp/caching.rst | 21 + .../data-sanitization.rst | 71 + .../data-sanitization/clean.rst | 87 + .../data-sanitization/escape.rst | 17 + .../data-sanitization/html.rst | 49 + .../data-sanitization/paranoid.rst | 47 + .../data-validation.rst | 323 ++ .../data-validation/core-validation-rules.rst | 1419 ++++++ .../custom-validation-rules.rst | 321 ++ .../multiple-rules-per-field.rst | 249 ++ .../data-validation/one-rule-per-field.rst | 351 ++ .../data-validation/simple-rules.rst | 55 + .../validating-data-from-the-controller.rst | 221 + .../common-tasks-with-cakephp/debugging.rst | 17 + .../debugging/basic-debugging.rst | 29 + .../debugging/debugger-class.rst | 39 + .../debugging/using-the-debugger-class.rst | 307 ++ .../error-handling.rst | 223 + .../internationalization-and-localization.rst | 31 + .../internationalizing-your-application.rst | 265 ++ .../localization-in-cakephp.rst | 229 + source/common-tasks-with-cakephp/logging.rst | 41 + .../creating-and-configuring-log-streams.rst | 149 + .../logging/error-logging.rst | 35 + .../logging/interacting-with-log-streams.rst | 17 + .../using-the-default-filelog-class.rst | 139 + .../logging/writing-to-logs.rst | 65 + .../common-tasks-with-cakephp/pagination.rst | 39 + .../pagination/ajax-pagination.rst | 59 + .../pagination/controller-setup.rst | 307 ++ .../pagination/custom-query-pagination.rst | 235 + .../pagination/pagination-in-views.rst | 309 ++ source/common-tasks-with-cakephp/rest.rst | 29 + .../rest/custom-rest-routing.rst | 71 + .../rest/the-simple-setup.rst | 427 ++ source/common-tasks-with-cakephp/testing.rst | 15 + .../testing/creating-tests.rst | 103 + .../testing/miscellaneous.rst | 233 + .../testing/preparing-for-testing.rst | 149 + .../testing/preparing-test-data.rst | 547 +++ .../running-tests-in-the-command-line.rst | 115 + .../testing/test-suite-changes-in-1-3.rst | 159 + .../testing/testing-components.rst | 233 + .../testing/testing-controllers.rst | 425 ++ .../testing/testing-helpers.rst | 247 + .../testing/testing-models.rst | 315 ++ ...g-overview-unit-testing-vs-web-testing.rst | 19 + .../testing/testing-plugins.rst | 133 + .../testing/web-testing-testing-views.rst | 213 + source/core-behaviors.rst | 11 + source/core-behaviors/acl.rst | 91 + source/core-behaviors/acl/node.rst | 61 + .../acl/using-the-aclbehavior.rst | 157 + source/core-behaviors/containable.rst | 879 ++++ .../using-containable-with-pagination.rst | 57 + source/core-behaviors/translate.rst | 21 + ...-the-translate-behavior-to-your-models.rst | 63 + .../core-behaviors/translate/conclusion.rst | 31 + .../translate/defining-the-fields.rst | 129 + .../initializing-the-i18n-database-tables.rst | 41 + .../translate/multiple-translation-tables.rst | 263 ++ ...ve-all-translation-records-for-a-field.rst | 413 ++ .../translate/saving-in-another-language.rst | 177 + source/core-behaviors/tree.rst | 35 + source/core-behaviors/tree/advanced-usage.rst | 453 ++ source/core-behaviors/tree/basic-usage.rst | 1105 +++++ source/core-behaviors/tree/data-integrity.rst | 319 ++ source/core-behaviors/tree/requirements.rst | 47 + source/core-components.rst | 183 + .../core-components/access-control-lists.rst | 23 + ...ng-permissions-cake-039-s-database-acl.rst | 1301 ++++++ ...g-permissions-cake-039-s-ini-based-acl.rst | 201 + .../understanding-how-acl-works.rst | 546 +++ source/core-components/authentication.rst | 327 ++ .../authentication/authcomponent-methods.rst | 721 +++ .../authcomponent-variables.rst | 943 ++++ .../authentication/change-hash-function.rst | 147 + .../displaying-auth-error-messages.rst | 81 + .../setting-auth-component-variables.rst | 193 + .../troubleshooting-auth-problems.rst | 85 + source/core-components/cookies.rst | 17 + .../cookies/controller-setup.rst | 147 + .../cookies/using-the-component.rst | 263 ++ source/core-components/email.rst | 23 + .../email/class-attributes-and-variables.rst | 173 + .../email/sending-a-basic-message.rst | 409 ++ .../email/sending-a-message-using-smtp.rst | 157 + source/core-components/request-handling.rst | 85 + ...btaining-additional-client-information.rst | 25 + .../obtaining-request-information.rst | 275 ++ .../request-type-detection.rst | 37 + .../responding-to-requests.rst | 177 + source/core-components/security-component.rst | 85 + .../basic-http-authentication.rst | 159 + .../security-component/configuration.rst | 93 + .../security-component/methods.rst | 143 + .../security-component/usage.rst | 207 + source/core-components/sessions.rst | 171 + source/core-components/sessions/methods.rst | 311 ++ source/core-console-applications.rst | 30 + .../code-generation-with-bake.rst | 125 + .../bake-improvements-in-1-3.rst | 247 + ...-produced-by-quot-baked-quot-templates.rst | 91 + .../schema-management-and-migrations.rst | 13 + .../generating-and-using-schema-files.rst | 79 + .../migrations-with-cakephp-schema-shell.rst | 81 + source/core-helpers.rst | 25 + source/core-helpers/ajax.rst | 151 + .../core-helpers/ajax/ajaxhelper-options.rst | 211 + source/core-helpers/ajax/methods.rst | 1505 +++++++ source/core-helpers/cache.rst | 37 + .../cache/cache-engines-in-cake.rst | 62 + .../cache/cache-helper-configuration.rst | 21 + .../cache/caching-in-the-controller.rst | 182 + .../core-helpers/cache/clearing-the-cache.rst | 27 + source/core-helpers/cache/general-caching.rst | 23 + .../marking-non-cached-content-in-views.rst | 69 + source/core-helpers/form.rst | 21 + source/core-helpers/form/1-3-improvements.rst | 273 ++ .../form/automagic-form-elements.rst | 1827 ++++++++ source/core-helpers/form/closing-the-form.rst | 155 + source/core-helpers/form/creating-forms.rst | 543 +++ source/core-helpers/form/file-fields.rst | 197 + .../form/form-element-specific-methods.rst | 1309 ++++++ source/core-helpers/html.rst | 109 + ...changing-the-tags-output-by-htmlhelper.rst | 53 + ...ting-breadcrumb-trails-with-htmlhelper.rst | 57 + .../inserting-well-formatted-elements.rst | 1787 ++++++++ source/core-helpers/javascript.rst | 25 + source/core-helpers/javascript/methods.rst | 301 ++ source/core-helpers/js.rst | 41 + source/core-helpers/js/ajax-pagination.rst | 293 ++ .../js/creating-a-javascript-engine.rst | 17 + .../js/javascript-engine-usage.rst | 285 ++ source/core-helpers/js/methods.rst | 1307 ++++++ .../js/using-a-specific-javascript-engine.rst | 237 + source/core-helpers/number.rst | 23 + source/core-helpers/number/currency.rst | 135 + source/core-helpers/number/format.rst | 119 + source/core-helpers/number/precision.rst | 43 + source/core-helpers/number/topercentage.rst | 45 + source/core-helpers/number/toreadablesize.rst | 47 + source/core-helpers/paginator.rst | 19 + source/core-helpers/paginator/methods.rst | 191 + source/core-helpers/rss.rst | 9 + ...reating-an-rss-feed-with-the-rsshelper.rst | 560 +++ source/core-helpers/session.rst | 75 + source/core-helpers/session/flash.rst | 183 + source/core-helpers/session/methods.rst | 32 + source/core-helpers/text.rst | 395 ++ source/core-helpers/time.rst | 21 + source/core-helpers/time/formatting.rst | 216 + source/core-helpers/time/testing-time.rst | 47 + source/core-helpers/xml.rst | 9 + source/core-helpers/xml/elem.rst | 59 + source/core-helpers/xml/header.rst | 67 + source/core-helpers/xml/serialize.rst | 223 + source/core-utility-libraries.rst | 13 + source/core-utility-libraries/app.rst | 61 + source/core-utility-libraries/cache.rst | 13 + .../cache/cache-config.rst | 151 + .../cache/cache-delete.rst | 15 + .../cache/cache-read.rst | 79 + .../cache/cache-set.rst | 65 + .../cache/cache-write.rst | 55 + source/core-utility-libraries/httpsocket.rst | 11 + .../core-utility-libraries/httpsocket/get.rst | 51 + .../httpsocket/post.rst | 53 + .../httpsocket/request.rst | 139 + source/core-utility-libraries/inflector.rst | 15 + .../inflector/class-methods.rst | 78 + source/core-utility-libraries/router.rst | 25 + source/core-utility-libraries/security.rst | 13 + source/core-utility-libraries/set.rst | 21 + source/core-utility-libraries/set/check.rst | 117 + .../set/classicextract.rst | 767 ++++ source/core-utility-libraries/set/combine.rst | 767 ++++ .../core-utility-libraries/set/contains.rst | 91 + .../core-utility-libraries/set/countdim.rst | 193 + source/core-utility-libraries/set/diff.rst | 291 ++ source/core-utility-libraries/set/enum.rst | 71 + source/core-utility-libraries/set/extract.rst | 125 + source/core-utility-libraries/set/filter.rst | 85 + source/core-utility-libraries/set/format.rst | 261 ++ source/core-utility-libraries/set/insert.rst | 263 ++ source/core-utility-libraries/set/map.rst | 305 ++ source/core-utility-libraries/set/matches.rst | 161 + source/core-utility-libraries/set/merge.rst | 197 + .../core-utility-libraries/set/normalize.rst | 425 ++ source/core-utility-libraries/set/numeric.rst | 219 + .../core-utility-libraries/set/pushdiff.rst | 169 + source/core-utility-libraries/set/remove.rst | 83 + source/core-utility-libraries/set/reverse.rst | 415 ++ .../set/set-compatible-path-syntax.rst | 156 + source/core-utility-libraries/set/sort.rst | 403 ++ source/core-utility-libraries/string.rst | 13 + .../string/cleaninsert.rst | 63 + .../core-utility-libraries/string/insert.rst | 31 + .../string/tokenize.rst | 17 + source/core-utility-libraries/string/uuid.rst | 29 + source/core-utility-libraries/xml.rst | 17 + .../xml/xml-parsing.rst | 153 + source/deployment.rst | 9 + source/developing-with-cakephp.rst | 9 + source/developing-with-cakephp/behaviors.rst | 73 + .../behaviors/behavior-callbacks.rst | 41 + .../creating-a-behavior-callback.rst | 95 + .../behaviors/creating-behavior-methods.rst | 96 + .../behaviors/creating-behaviors.rst | 147 + .../behaviors/using-behaviors.rst | 423 ++ source/developing-with-cakephp/components.rst | 5 + .../components/configuring-components.rst | 139 + .../components/creating-components.rst | 657 +++ .../components/introduction.rst | 49 + .../developing-with-cakephp/configuration.rst | 25 + .../configuration/bootstrapping-cakephp.rst | 53 + .../configuration/core-configuration.rst | 19 + .../configuration/database-configuration.rst | 171 + .../configuration/inflections.rst | 95 + .../configuration/routes-configuration.rst | 1339 ++++++ .../configuration/the-app-class.rst | 401 ++ .../configuration/the-configuration-class.rst | 530 +++ .../developing-with-cakephp/controllers.rst | 163 + .../controllers/controller-attributes.rst | 575 +++ .../controllers/controller-methods.rst | 1349 ++++++ .../controllers/the-app-controller.rst | 119 + .../controllers/the-pages-controller.rst | 34 + .../developing-with-cakephp/datasources.rst | 75 + .../datasources/an-example.rst | 537 +++ .../datasources/basic-api-for-datasources.rst | 77 + ...gin-datasources-and-datasource-drivers.rst | 237 + .../global-constants-and-functions.rst | 29 + .../core-definition-constants.rst | 229 + .../global-functions.rst | 426 ++ source/developing-with-cakephp/helpers.rst | 21 + .../helpers/core-helpers.rst | 90 + ...creating-functionality-for-all-helpers.rst | 49 + .../helpers/creating-helpers.rst | 227 + .../helpers/using-helpers.rst | 215 + .../installation-preparation.rst | 31 + .../getting-cakephp.rst | 43 + .../installation-preparation/permissions.rst | 19 + .../developing-with-cakephp/installation.rst | 35 + .../installation/advanced-installation.rst | 275 ++ .../apache-and-mod_rewrite-and-htaccess.rst | 337 ++ .../installation/development.rst | 63 + .../installation/fire-it-up.rst | 59 + .../installation/pretty-urls-and-lighttpd.rst | 251 ++ .../installation/pretty-urls-on-nginx.rst | 149 + .../installation/production.rst | 79 + .../url-rewrites-on-iis7-windows-hosts.rst | 199 + source/developing-with-cakephp/models.rst | 35 + .../additional-methods-and-properties.rst | 311 ++ .../associations-linking-models-together.rst | 3955 +++++++++++++++++ .../models/callback-methods.rst | 501 +++ .../models/creating-database-tables.rst | 853 ++++ .../models/deleting-data.rst | 75 + .../models/model-attributes.rst | 641 +++ .../models/retrieving-your-data.rst | 2567 +++++++++++ .../models/saving-your-data.rst | 1592 +++++++ .../models/transactions.rst | 89 + .../models/understanding-models.rst | 317 ++ .../models/virtual-fields.rst | 417 ++ source/developing-with-cakephp/plugins.rst | 29 + .../components,-helpers-and-behaviors.rst | 87 + .../plugins/creating-a-plugin.rst | 167 + .../plugins/plugin-assets.rst | 83 + .../plugins/plugin-controllers.rst | 103 + .../plugins/plugin-models.rst | 155 + .../plugins/plugin-tips.rst | 69 + .../plugins/plugin-views.rst | 89 + .../developing-with-cakephp/requirements.rst | 37 + .../developing-with-cakephp/scaffolding.rst | 229 + ...imple-admin-interface-with-scaffolding.rst | 103 + .../customizing-scaffold-views.rst | 55 + .../the-cakephp-console.rst | 189 + .../creating-shells-and-tasks.rst | 437 ++ .../running-shells-as-cronjobs.rst | 109 + .../vendor-packages.rst | 9 + .../vendor-packages/vendor-assets.rst | 15 + source/developing-with-cakephp/views.rst | 17 + .../views/elements.rst | 465 ++ .../developing-with-cakephp/views/layouts.rst | 319 ++ .../views/media-views.rst | 208 + .../developing-with-cakephp/views/themes.rst | 257 ++ .../views/view-methods.rst | 211 + .../views/view-templates.rst | 69 + source/errors.err | 208 + source/index.rst | 154 +- source/tutorials-and-examples.rst | 23 + source/tutorials-and-examples/blog.rst | 67 + .../blog/a-note-on-mod_rewrite.rst | 141 + .../blog/adding-posts.rst | 183 + .../blog/cake-database-configuration.rst | 99 + .../blog/conclusion.rst | 31 + .../blog/create-a-post-model.rst | 93 + .../blog/create-a-posts-controller.rst | 157 + .../blog/creating-post-views.rst | 417 ++ .../blog/creating-the-blog-database.rst | 117 + .../blog/data-validation.rst | 255 ++ .../blog/deleting-posts.rst | 185 + .../blog/editing-posts.rst | 297 ++ .../blog/getting-cake.rst | 85 + .../blog/optional-configuration.rst | 139 + source/tutorials-and-examples/blog/routes.rst | 99 + .../simple-acl-controlled-application.rst | 57 + .../acts-as-a-requester.rst | 293 ++ .../all-done.rst | 19 + .../an-automated-tool-for-creating-acos.rst | 811 ++++ .../creating-acos-access-control-objects.rst | 99 + .../initialize-the-db-acl-tables.rst | 49 + .../logging-in.rst | 129 + .../logout.rst | 43 + .../preparing-our-application.rst | 165 + .../preparing-to-add-auth.rst | 249 ++ .../setting-up-permissions.rst | 273 ++ 337 files changed, 76815 insertions(+), 46 deletions(-) create mode 100644 source/appendices.rst create mode 100644 source/appendices/migrating-from-cakephp-1-2-to-1-3.rst create mode 100644 source/appendices/new-features-in-cakephp-1-3.rst create mode 100644 source/basic-principles-of-cakephp.rst create mode 100644 source/basic-principles-of-cakephp/a-typical-cakephp-request.rst create mode 100644 source/basic-principles-of-cakephp/cakephp-conventions.rst create mode 100644 source/basic-principles-of-cakephp/cakephp-conventions/controller-conventions.rst create mode 100644 source/basic-principles-of-cakephp/cakephp-conventions/file-and-classname-conventions.rst create mode 100644 source/basic-principles-of-cakephp/cakephp-conventions/model-and-database-conventions.rst create mode 100644 source/basic-principles-of-cakephp/cakephp-conventions/view-conventions.rst create mode 100644 source/basic-principles-of-cakephp/cakephp-folder-structure.rst create mode 100644 source/basic-principles-of-cakephp/cakephp-structure.rst create mode 100644 source/basic-principles-of-cakephp/cakephp-structure/application-extensions.rst create mode 100644 source/basic-principles-of-cakephp/cakephp-structure/controller-extensions-quot-components-quot.rst create mode 100644 source/basic-principles-of-cakephp/cakephp-structure/model-extensions-quot-behaviors-quot.rst create mode 100644 source/basic-principles-of-cakephp/cakephp-structure/view-extensions-quot-helpers-quot.rst create mode 100644 source/beginning-with-cakephp.rst create mode 100644 source/beginning-with-cakephp/understanding-model-view-controller.rst create mode 100644 source/beginning-with-cakephp/what-is-cakephp-why-use-it.rst create mode 100644 source/common-tasks-with-cakephp.rst create mode 100644 source/common-tasks-with-cakephp/caching.rst create mode 100644 source/common-tasks-with-cakephp/data-sanitization.rst create mode 100644 source/common-tasks-with-cakephp/data-sanitization/clean.rst create mode 100644 source/common-tasks-with-cakephp/data-sanitization/escape.rst create mode 100644 source/common-tasks-with-cakephp/data-sanitization/html.rst create mode 100644 source/common-tasks-with-cakephp/data-sanitization/paranoid.rst create mode 100644 source/common-tasks-with-cakephp/data-validation.rst create mode 100644 source/common-tasks-with-cakephp/data-validation/core-validation-rules.rst create mode 100644 source/common-tasks-with-cakephp/data-validation/custom-validation-rules.rst create mode 100644 source/common-tasks-with-cakephp/data-validation/multiple-rules-per-field.rst create mode 100644 source/common-tasks-with-cakephp/data-validation/one-rule-per-field.rst create mode 100644 source/common-tasks-with-cakephp/data-validation/simple-rules.rst create mode 100644 source/common-tasks-with-cakephp/data-validation/validating-data-from-the-controller.rst create mode 100644 source/common-tasks-with-cakephp/debugging.rst create mode 100644 source/common-tasks-with-cakephp/debugging/basic-debugging.rst create mode 100644 source/common-tasks-with-cakephp/debugging/debugger-class.rst create mode 100644 source/common-tasks-with-cakephp/debugging/using-the-debugger-class.rst create mode 100644 source/common-tasks-with-cakephp/error-handling.rst create mode 100644 source/common-tasks-with-cakephp/internationalization-and-localization.rst create mode 100644 source/common-tasks-with-cakephp/internationalization-and-localization/internationalizing-your-application.rst create mode 100644 source/common-tasks-with-cakephp/internationalization-and-localization/localization-in-cakephp.rst create mode 100644 source/common-tasks-with-cakephp/logging.rst create mode 100644 source/common-tasks-with-cakephp/logging/creating-and-configuring-log-streams.rst create mode 100644 source/common-tasks-with-cakephp/logging/error-logging.rst create mode 100644 source/common-tasks-with-cakephp/logging/interacting-with-log-streams.rst create mode 100644 source/common-tasks-with-cakephp/logging/using-the-default-filelog-class.rst create mode 100644 source/common-tasks-with-cakephp/logging/writing-to-logs.rst create mode 100644 source/common-tasks-with-cakephp/pagination.rst create mode 100644 source/common-tasks-with-cakephp/pagination/ajax-pagination.rst create mode 100644 source/common-tasks-with-cakephp/pagination/controller-setup.rst create mode 100644 source/common-tasks-with-cakephp/pagination/custom-query-pagination.rst create mode 100644 source/common-tasks-with-cakephp/pagination/pagination-in-views.rst create mode 100644 source/common-tasks-with-cakephp/rest.rst create mode 100644 source/common-tasks-with-cakephp/rest/custom-rest-routing.rst create mode 100644 source/common-tasks-with-cakephp/rest/the-simple-setup.rst create mode 100644 source/common-tasks-with-cakephp/testing.rst create mode 100644 source/common-tasks-with-cakephp/testing/creating-tests.rst create mode 100644 source/common-tasks-with-cakephp/testing/miscellaneous.rst create mode 100644 source/common-tasks-with-cakephp/testing/preparing-for-testing.rst create mode 100644 source/common-tasks-with-cakephp/testing/preparing-test-data.rst create mode 100644 source/common-tasks-with-cakephp/testing/running-tests-in-the-command-line.rst create mode 100644 source/common-tasks-with-cakephp/testing/test-suite-changes-in-1-3.rst create mode 100644 source/common-tasks-with-cakephp/testing/testing-components.rst create mode 100644 source/common-tasks-with-cakephp/testing/testing-controllers.rst create mode 100644 source/common-tasks-with-cakephp/testing/testing-helpers.rst create mode 100644 source/common-tasks-with-cakephp/testing/testing-models.rst create mode 100644 source/common-tasks-with-cakephp/testing/testing-overview-unit-testing-vs-web-testing.rst create mode 100644 source/common-tasks-with-cakephp/testing/testing-plugins.rst create mode 100644 source/common-tasks-with-cakephp/testing/web-testing-testing-views.rst create mode 100644 source/core-behaviors.rst create mode 100644 source/core-behaviors/acl.rst create mode 100644 source/core-behaviors/acl/node.rst create mode 100644 source/core-behaviors/acl/using-the-aclbehavior.rst create mode 100644 source/core-behaviors/containable.rst create mode 100644 source/core-behaviors/containable/using-containable-with-pagination.rst create mode 100644 source/core-behaviors/translate.rst create mode 100644 source/core-behaviors/translate/attaching-the-translate-behavior-to-your-models.rst create mode 100644 source/core-behaviors/translate/conclusion.rst create mode 100644 source/core-behaviors/translate/defining-the-fields.rst create mode 100644 source/core-behaviors/translate/initializing-the-i18n-database-tables.rst create mode 100644 source/core-behaviors/translate/multiple-translation-tables.rst create mode 100644 source/core-behaviors/translate/retrieve-all-translation-records-for-a-field.rst create mode 100644 source/core-behaviors/translate/saving-in-another-language.rst create mode 100644 source/core-behaviors/tree.rst create mode 100644 source/core-behaviors/tree/advanced-usage.rst create mode 100644 source/core-behaviors/tree/basic-usage.rst create mode 100644 source/core-behaviors/tree/data-integrity.rst create mode 100644 source/core-behaviors/tree/requirements.rst create mode 100644 source/core-components.rst create mode 100644 source/core-components/access-control-lists.rst create mode 100644 source/core-components/access-control-lists/defining-permissions-cake-039-s-database-acl.rst create mode 100644 source/core-components/access-control-lists/defining-permissions-cake-039-s-ini-based-acl.rst create mode 100644 source/core-components/access-control-lists/understanding-how-acl-works.rst create mode 100644 source/core-components/authentication.rst create mode 100644 source/core-components/authentication/authcomponent-methods.rst create mode 100644 source/core-components/authentication/authcomponent-variables.rst create mode 100644 source/core-components/authentication/change-hash-function.rst create mode 100644 source/core-components/authentication/displaying-auth-error-messages.rst create mode 100644 source/core-components/authentication/setting-auth-component-variables.rst create mode 100644 source/core-components/authentication/troubleshooting-auth-problems.rst create mode 100644 source/core-components/cookies.rst create mode 100644 source/core-components/cookies/controller-setup.rst create mode 100644 source/core-components/cookies/using-the-component.rst create mode 100644 source/core-components/email.rst create mode 100644 source/core-components/email/class-attributes-and-variables.rst create mode 100644 source/core-components/email/sending-a-basic-message.rst create mode 100644 source/core-components/email/sending-a-message-using-smtp.rst create mode 100644 source/core-components/request-handling.rst create mode 100644 source/core-components/request-handling/obtaining-additional-client-information.rst create mode 100644 source/core-components/request-handling/obtaining-request-information.rst create mode 100644 source/core-components/request-handling/request-type-detection.rst create mode 100644 source/core-components/request-handling/responding-to-requests.rst create mode 100644 source/core-components/security-component.rst create mode 100644 source/core-components/security-component/basic-http-authentication.rst create mode 100644 source/core-components/security-component/configuration.rst create mode 100644 source/core-components/security-component/methods.rst create mode 100644 source/core-components/security-component/usage.rst create mode 100644 source/core-components/sessions.rst create mode 100644 source/core-components/sessions/methods.rst create mode 100644 source/core-console-applications.rst create mode 100644 source/core-console-applications/code-generation-with-bake.rst create mode 100644 source/core-console-applications/code-generation-with-bake/bake-improvements-in-1-3.rst create mode 100644 source/core-console-applications/modify-default-html-produced-by-quot-baked-quot-templates.rst create mode 100644 source/core-console-applications/schema-management-and-migrations.rst create mode 100644 source/core-console-applications/schema-management-and-migrations/generating-and-using-schema-files.rst create mode 100644 source/core-console-applications/schema-management-and-migrations/migrations-with-cakephp-schema-shell.rst create mode 100644 source/core-helpers.rst create mode 100644 source/core-helpers/ajax.rst create mode 100644 source/core-helpers/ajax/ajaxhelper-options.rst create mode 100644 source/core-helpers/ajax/methods.rst create mode 100644 source/core-helpers/cache.rst create mode 100644 source/core-helpers/cache/cache-engines-in-cake.rst create mode 100644 source/core-helpers/cache/cache-helper-configuration.rst create mode 100644 source/core-helpers/cache/caching-in-the-controller.rst create mode 100644 source/core-helpers/cache/clearing-the-cache.rst create mode 100644 source/core-helpers/cache/general-caching.rst create mode 100644 source/core-helpers/cache/marking-non-cached-content-in-views.rst create mode 100644 source/core-helpers/form.rst create mode 100644 source/core-helpers/form/1-3-improvements.rst create mode 100644 source/core-helpers/form/automagic-form-elements.rst create mode 100644 source/core-helpers/form/closing-the-form.rst create mode 100644 source/core-helpers/form/creating-forms.rst create mode 100644 source/core-helpers/form/file-fields.rst create mode 100644 source/core-helpers/form/form-element-specific-methods.rst create mode 100644 source/core-helpers/html.rst create mode 100644 source/core-helpers/html/changing-the-tags-output-by-htmlhelper.rst create mode 100644 source/core-helpers/html/creating-breadcrumb-trails-with-htmlhelper.rst create mode 100644 source/core-helpers/html/inserting-well-formatted-elements.rst create mode 100644 source/core-helpers/javascript.rst create mode 100644 source/core-helpers/javascript/methods.rst create mode 100644 source/core-helpers/js.rst create mode 100644 source/core-helpers/js/ajax-pagination.rst create mode 100644 source/core-helpers/js/creating-a-javascript-engine.rst create mode 100644 source/core-helpers/js/javascript-engine-usage.rst create mode 100644 source/core-helpers/js/methods.rst create mode 100644 source/core-helpers/js/using-a-specific-javascript-engine.rst create mode 100644 source/core-helpers/number.rst create mode 100644 source/core-helpers/number/currency.rst create mode 100644 source/core-helpers/number/format.rst create mode 100644 source/core-helpers/number/precision.rst create mode 100644 source/core-helpers/number/topercentage.rst create mode 100644 source/core-helpers/number/toreadablesize.rst create mode 100644 source/core-helpers/paginator.rst create mode 100644 source/core-helpers/paginator/methods.rst create mode 100644 source/core-helpers/rss.rst create mode 100644 source/core-helpers/rss/creating-an-rss-feed-with-the-rsshelper.rst create mode 100644 source/core-helpers/session.rst create mode 100644 source/core-helpers/session/flash.rst create mode 100644 source/core-helpers/session/methods.rst create mode 100644 source/core-helpers/text.rst create mode 100644 source/core-helpers/time.rst create mode 100644 source/core-helpers/time/formatting.rst create mode 100644 source/core-helpers/time/testing-time.rst create mode 100644 source/core-helpers/xml.rst create mode 100644 source/core-helpers/xml/elem.rst create mode 100644 source/core-helpers/xml/header.rst create mode 100644 source/core-helpers/xml/serialize.rst create mode 100644 source/core-utility-libraries.rst create mode 100644 source/core-utility-libraries/app.rst create mode 100644 source/core-utility-libraries/cache.rst create mode 100644 source/core-utility-libraries/cache/cache-config.rst create mode 100644 source/core-utility-libraries/cache/cache-delete.rst create mode 100644 source/core-utility-libraries/cache/cache-read.rst create mode 100644 source/core-utility-libraries/cache/cache-set.rst create mode 100644 source/core-utility-libraries/cache/cache-write.rst create mode 100644 source/core-utility-libraries/httpsocket.rst create mode 100644 source/core-utility-libraries/httpsocket/get.rst create mode 100644 source/core-utility-libraries/httpsocket/post.rst create mode 100644 source/core-utility-libraries/httpsocket/request.rst create mode 100644 source/core-utility-libraries/inflector.rst create mode 100644 source/core-utility-libraries/inflector/class-methods.rst create mode 100644 source/core-utility-libraries/router.rst create mode 100644 source/core-utility-libraries/security.rst create mode 100644 source/core-utility-libraries/set.rst create mode 100644 source/core-utility-libraries/set/check.rst create mode 100644 source/core-utility-libraries/set/classicextract.rst create mode 100644 source/core-utility-libraries/set/combine.rst create mode 100644 source/core-utility-libraries/set/contains.rst create mode 100644 source/core-utility-libraries/set/countdim.rst create mode 100644 source/core-utility-libraries/set/diff.rst create mode 100644 source/core-utility-libraries/set/enum.rst create mode 100644 source/core-utility-libraries/set/extract.rst create mode 100644 source/core-utility-libraries/set/filter.rst create mode 100644 source/core-utility-libraries/set/format.rst create mode 100644 source/core-utility-libraries/set/insert.rst create mode 100644 source/core-utility-libraries/set/map.rst create mode 100644 source/core-utility-libraries/set/matches.rst create mode 100644 source/core-utility-libraries/set/merge.rst create mode 100644 source/core-utility-libraries/set/normalize.rst create mode 100644 source/core-utility-libraries/set/numeric.rst create mode 100644 source/core-utility-libraries/set/pushdiff.rst create mode 100644 source/core-utility-libraries/set/remove.rst create mode 100644 source/core-utility-libraries/set/reverse.rst create mode 100644 source/core-utility-libraries/set/set-compatible-path-syntax.rst create mode 100644 source/core-utility-libraries/set/sort.rst create mode 100644 source/core-utility-libraries/string.rst create mode 100644 source/core-utility-libraries/string/cleaninsert.rst create mode 100644 source/core-utility-libraries/string/insert.rst create mode 100644 source/core-utility-libraries/string/tokenize.rst create mode 100644 source/core-utility-libraries/string/uuid.rst create mode 100644 source/core-utility-libraries/xml.rst create mode 100644 source/core-utility-libraries/xml/xml-parsing.rst create mode 100644 source/deployment.rst create mode 100644 source/developing-with-cakephp.rst create mode 100644 source/developing-with-cakephp/behaviors.rst create mode 100644 source/developing-with-cakephp/behaviors/behavior-callbacks.rst create mode 100644 source/developing-with-cakephp/behaviors/creating-a-behavior-callback.rst create mode 100644 source/developing-with-cakephp/behaviors/creating-behavior-methods.rst create mode 100644 source/developing-with-cakephp/behaviors/creating-behaviors.rst create mode 100644 source/developing-with-cakephp/behaviors/using-behaviors.rst create mode 100644 source/developing-with-cakephp/components.rst create mode 100644 source/developing-with-cakephp/components/configuring-components.rst create mode 100644 source/developing-with-cakephp/components/creating-components.rst create mode 100644 source/developing-with-cakephp/components/introduction.rst create mode 100644 source/developing-with-cakephp/configuration.rst create mode 100644 source/developing-with-cakephp/configuration/bootstrapping-cakephp.rst create mode 100644 source/developing-with-cakephp/configuration/core-configuration.rst create mode 100644 source/developing-with-cakephp/configuration/database-configuration.rst create mode 100644 source/developing-with-cakephp/configuration/inflections.rst create mode 100644 source/developing-with-cakephp/configuration/routes-configuration.rst create mode 100644 source/developing-with-cakephp/configuration/the-app-class.rst create mode 100644 source/developing-with-cakephp/configuration/the-configuration-class.rst create mode 100644 source/developing-with-cakephp/controllers.rst create mode 100644 source/developing-with-cakephp/controllers/controller-attributes.rst create mode 100644 source/developing-with-cakephp/controllers/controller-methods.rst create mode 100644 source/developing-with-cakephp/controllers/the-app-controller.rst create mode 100644 source/developing-with-cakephp/controllers/the-pages-controller.rst create mode 100644 source/developing-with-cakephp/datasources.rst create mode 100644 source/developing-with-cakephp/datasources/an-example.rst create mode 100644 source/developing-with-cakephp/datasources/basic-api-for-datasources.rst create mode 100644 source/developing-with-cakephp/datasources/plugin-datasources-and-datasource-drivers.rst create mode 100644 source/developing-with-cakephp/global-constants-and-functions.rst create mode 100644 source/developing-with-cakephp/global-constants-and-functions/core-definition-constants.rst create mode 100644 source/developing-with-cakephp/global-constants-and-functions/global-functions.rst create mode 100644 source/developing-with-cakephp/helpers.rst create mode 100644 source/developing-with-cakephp/helpers/core-helpers.rst create mode 100644 source/developing-with-cakephp/helpers/creating-functionality-for-all-helpers.rst create mode 100644 source/developing-with-cakephp/helpers/creating-helpers.rst create mode 100644 source/developing-with-cakephp/helpers/using-helpers.rst create mode 100644 source/developing-with-cakephp/installation-preparation.rst create mode 100644 source/developing-with-cakephp/installation-preparation/getting-cakephp.rst create mode 100644 source/developing-with-cakephp/installation-preparation/permissions.rst create mode 100644 source/developing-with-cakephp/installation.rst create mode 100644 source/developing-with-cakephp/installation/advanced-installation.rst create mode 100644 source/developing-with-cakephp/installation/apache-and-mod_rewrite-and-htaccess.rst create mode 100644 source/developing-with-cakephp/installation/development.rst create mode 100644 source/developing-with-cakephp/installation/fire-it-up.rst create mode 100644 source/developing-with-cakephp/installation/pretty-urls-and-lighttpd.rst create mode 100644 source/developing-with-cakephp/installation/pretty-urls-on-nginx.rst create mode 100644 source/developing-with-cakephp/installation/production.rst create mode 100644 source/developing-with-cakephp/installation/url-rewrites-on-iis7-windows-hosts.rst create mode 100644 source/developing-with-cakephp/models.rst create mode 100644 source/developing-with-cakephp/models/additional-methods-and-properties.rst create mode 100644 source/developing-with-cakephp/models/associations-linking-models-together.rst create mode 100644 source/developing-with-cakephp/models/callback-methods.rst create mode 100644 source/developing-with-cakephp/models/creating-database-tables.rst create mode 100644 source/developing-with-cakephp/models/deleting-data.rst create mode 100644 source/developing-with-cakephp/models/model-attributes.rst create mode 100644 source/developing-with-cakephp/models/retrieving-your-data.rst create mode 100644 source/developing-with-cakephp/models/saving-your-data.rst create mode 100644 source/developing-with-cakephp/models/transactions.rst create mode 100644 source/developing-with-cakephp/models/understanding-models.rst create mode 100644 source/developing-with-cakephp/models/virtual-fields.rst create mode 100644 source/developing-with-cakephp/plugins.rst create mode 100644 source/developing-with-cakephp/plugins/components,-helpers-and-behaviors.rst create mode 100644 source/developing-with-cakephp/plugins/creating-a-plugin.rst create mode 100644 source/developing-with-cakephp/plugins/plugin-assets.rst create mode 100644 source/developing-with-cakephp/plugins/plugin-controllers.rst create mode 100644 source/developing-with-cakephp/plugins/plugin-models.rst create mode 100644 source/developing-with-cakephp/plugins/plugin-tips.rst create mode 100644 source/developing-with-cakephp/plugins/plugin-views.rst create mode 100644 source/developing-with-cakephp/requirements.rst create mode 100644 source/developing-with-cakephp/scaffolding.rst create mode 100644 source/developing-with-cakephp/scaffolding/creating-a-simple-admin-interface-with-scaffolding.rst create mode 100644 source/developing-with-cakephp/scaffolding/customizing-scaffold-views.rst create mode 100644 source/developing-with-cakephp/the-cakephp-console.rst create mode 100644 source/developing-with-cakephp/the-cakephp-console/creating-shells-and-tasks.rst create mode 100644 source/developing-with-cakephp/the-cakephp-console/running-shells-as-cronjobs.rst create mode 100644 source/developing-with-cakephp/vendor-packages.rst create mode 100644 source/developing-with-cakephp/vendor-packages/vendor-assets.rst create mode 100644 source/developing-with-cakephp/views.rst create mode 100644 source/developing-with-cakephp/views/elements.rst create mode 100644 source/developing-with-cakephp/views/layouts.rst create mode 100644 source/developing-with-cakephp/views/media-views.rst create mode 100644 source/developing-with-cakephp/views/themes.rst create mode 100644 source/developing-with-cakephp/views/view-methods.rst create mode 100644 source/developing-with-cakephp/views/view-templates.rst create mode 100644 source/errors.err create mode 100644 source/tutorials-and-examples.rst create mode 100644 source/tutorials-and-examples/blog.rst create mode 100644 source/tutorials-and-examples/blog/a-note-on-mod_rewrite.rst create mode 100644 source/tutorials-and-examples/blog/adding-posts.rst create mode 100644 source/tutorials-and-examples/blog/cake-database-configuration.rst create mode 100644 source/tutorials-and-examples/blog/conclusion.rst create mode 100644 source/tutorials-and-examples/blog/create-a-post-model.rst create mode 100644 source/tutorials-and-examples/blog/create-a-posts-controller.rst create mode 100644 source/tutorials-and-examples/blog/creating-post-views.rst create mode 100644 source/tutorials-and-examples/blog/creating-the-blog-database.rst create mode 100644 source/tutorials-and-examples/blog/data-validation.rst create mode 100644 source/tutorials-and-examples/blog/deleting-posts.rst create mode 100644 source/tutorials-and-examples/blog/editing-posts.rst create mode 100644 source/tutorials-and-examples/blog/getting-cake.rst create mode 100644 source/tutorials-and-examples/blog/optional-configuration.rst create mode 100644 source/tutorials-and-examples/blog/routes.rst create mode 100644 source/tutorials-and-examples/simple-acl-controlled-application.rst create mode 100644 source/tutorials-and-examples/simple-acl-controlled-application/acts-as-a-requester.rst create mode 100644 source/tutorials-and-examples/simple-acl-controlled-application/all-done.rst create mode 100644 source/tutorials-and-examples/simple-acl-controlled-application/an-automated-tool-for-creating-acos.rst create mode 100644 source/tutorials-and-examples/simple-acl-controlled-application/creating-acos-access-control-objects.rst create mode 100644 source/tutorials-and-examples/simple-acl-controlled-application/initialize-the-db-acl-tables.rst create mode 100644 source/tutorials-and-examples/simple-acl-controlled-application/logging-in.rst create mode 100644 source/tutorials-and-examples/simple-acl-controlled-application/logout.rst create mode 100644 source/tutorials-and-examples/simple-acl-controlled-application/preparing-our-application.rst create mode 100644 source/tutorials-and-examples/simple-acl-controlled-application/preparing-to-add-auth.rst create mode 100644 source/tutorials-and-examples/simple-acl-controlled-application/setting-up-permissions.rst diff --git a/source/appendices.rst b/source/appendices.rst new file mode 100644 index 000000000..93486c943 --- /dev/null +++ b/source/appendices.rst @@ -0,0 +1,11 @@ +12 Appendices +------------- + +Appendices contain information regarding the new features +introduced in 1.3 and migration path from 1.2 to 1.3 + +12 Appendices +------------- + +Appendices contain information regarding the new features +introduced in 1.3 and migration path from 1.2 to 1.3 diff --git a/source/appendices/migrating-from-cakephp-1-2-to-1-3.rst b/source/appendices/migrating-from-cakephp-1-2-to-1-3.rst new file mode 100644 index 000000000..8a5465ec2 --- /dev/null +++ b/source/appendices/migrating-from-cakephp-1-2-to-1-3.rst @@ -0,0 +1,1641 @@ +12.1 Migrating from CakePHP 1.2 to 1.3 +-------------------------------------- + +This guide summarizes many of the changes necessary when migrating +from a 1.2 to 1.3 Cake core. Each section contains relevant +information for the modifications made to existing methods as well +as any methods that have been removed/renamed. + +**App File Replacements (important)** + + +- webroot/index.php: Must be replaced due to changes in + bootstrapping process. +- config/core.php: Additional settings have been put in place + which are required for PHP 5.3. +- webroot/test.php: Replace if you want to run unit tests. + +Removed Constants +~~~~~~~~~~~~~~~~~ + +The following constants have been removed from CakePHP. If your +application depends on them you must define them in +``app/config/bootstrap.php`` + + +- ``CIPHER_SEED`` - It has been replaced with Configure class var + ``Security.cipherSeed`` which should be changed in + ``app/config/core.php`` +- ``PEAR`` +- ``INFLECTIONS`` +- ``VALID_NOT_EMPTY`` +- ``VALID_EMAIL`` +- ``VALID_NUMBER`` +- ``VALID_YEAR`` + +Configuration and application bootstrapping +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +**Bootstrapping Additional Paths.** + +In your app/config/bootstrap.php you may have variables like +``$pluginPaths`` or ``$controllerPaths``. +There is a new way to add those paths. As of 1.3 RC1 the +``$pluginPaths`` variables will no longer work. You must use +``App::build()`` to modify paths. + +:: + + App::build(array( + 'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'), + 'models' => array('/full/path/to/models/', '/next/full/path/to/models/'), + 'views' => array('/full/path/to/views/', '/next/full/path/to/views/'), + 'controllers' => array('/full/path/to/controllers/', '/next/full/path/to/controllers/'), + 'datasources' => array('/full/path/to/datasources/', '/next/full/path/to/datasources/'), + 'behaviors' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'), + 'components' => array('/full/path/to/components/', '/next/full/path/to/components/'), + 'helpers' => array('/full/path/to/helpers/', '/next/full/path/to/helpers/'), + 'vendors' => array('/full/path/to/vendors/', '/next/full/path/to/vendors/'), + 'shells' => array('/full/path/to/shells/', '/next/full/path/to/shells/'), + 'locales' => array('/full/path/to/locale/', '/next/full/path/to/locale/'), + 'libs' => array('/full/path/to/libs/', '/next/full/path/to/libs/') + )); + + +#. ``App::build(array(`` +#. ``'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'),`` +#. ``'models' => array('/full/path/to/models/', '/next/full/path/to/models/'),`` +#. ``'views' => array('/full/path/to/views/', '/next/full/path/to/views/'),`` +#. ``'controllers' => array('/full/path/to/controllers/', '/next/full/path/to/controllers/'),`` +#. ``'datasources' => array('/full/path/to/datasources/', '/next/full/path/to/datasources/'),`` +#. ``'behaviors' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'),`` +#. ``'components' => array('/full/path/to/components/', '/next/full/path/to/components/'),`` +#. ``'helpers' => array('/full/path/to/helpers/', '/next/full/path/to/helpers/'),`` +#. ``'vendors' => array('/full/path/to/vendors/', '/next/full/path/to/vendors/'),`` +#. ``'shells' => array('/full/path/to/shells/', '/next/full/path/to/shells/'),`` +#. ``'locales' => array('/full/path/to/locale/', '/next/full/path/to/locale/'),`` +#. ``'libs' => array('/full/path/to/libs/', '/next/full/path/to/libs/')`` +#. ``));`` + +Also changed is the order in which bootstrapping occurs. In the +past ``app/config/core.php`` was loaded **after** +``app/config/bootstrap.php``. This caused any ``App::import()`` in +an application bootstrap to be un-cached and considerably slower +than a cached include. In 1.3 core.php is loaded and the core cache +configs are created **before** bootstrap.php is loaded. + +**Loading custom inflections** + +``inflections.php`` has been removed, it was an unnecessary file +hit, and the related features have been refactored into a method to +increase their flexibility. You now use ``Inflector::rules()`` to +load custom inflections. + +:: + + Inflector::rules('singular', array( + 'rules' => array('/^(bil)er$/i' => '\1', '/^(inflec|contribu)tors$/i' => '\1ta'), + 'uninflected' => array('singulars'), + 'irregular' => array('spins' => 'spinor') + )); + + +#. ``Inflector::rules('singular', array(`` +#. ``'rules' => array('/^(bil)er$/i' => '\1', '/^(inflec|contribu)tors$/i' => '\1ta'),`` +#. ``'uninflected' => array('singulars'),`` +#. ``'irregular' => array('spins' => 'spinor')`` +#. ``));`` + +Will merge the supplied rules into the infection sets, with the +added rules taking precedence over the core rules. + +File renames and internal changes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +**Library Renames** + +Core libraries of libs/session.php, libs/socket.php, +libs/model/schema.php and libs/model/behavior.php have been renamed +so that there is a better mapping between filenames and main +classes contained within (as well as dealing with some name-spacing +issues): + + +- session.php ⇒ cake\_session.php + + + - App::import('Core', 'Session') ⇒ App::import('Core', + 'CakeSession') + +- socket.php ⇒ cake\_socket.php + + + - App::import('Core', 'Socket') ⇒ App::import('Core', + 'CakeSocket') + +- schema.php ⇒ cake\_schema.php + + + - App::import('Model', 'Schema') ⇒ App::import('Model', + 'CakeSchema') + +- behavior.php ⇒ model\_behavior.php + + + - App::import('Core', 'Behavior') ⇒ App::import('Core', + 'ModelBehavior') + + +In most cases, the above renaming will not affect userland code. + +**Inheritance from Object** + +The following classes no longer extend Object: + + +- Router +- Set +- Inflector +- Cache +- CacheEngine + +If you were using Object methods from these classes, you will need +to not use those methods. + +Controller & Components +~~~~~~~~~~~~~~~~~~~~~~~ + +**Controller** + + +- ``Controller::set()`` no longer changes variables from + ``$var_name`` to ``$varName``. Variables always appear in the view + exactly as you set them. + +- ``Controller::set('title', $var)`` no longer sets + ``$title_for_layout`` when rendering the layout. + ``$title_for_layout`` is still populated by default. But if you + want to customize it, use + ``$this->set('title_for_layout', $var)``. + +- ``Controller::$pageTitle`` has been removed. Use + ``$this->set('title_for_layout', $var);`` instead. + +- Controller has two new methods ``startupProcess`` and + ``shutdownProcess``. These methods are responsible for handling the + controller startup and shutdown processes. + +**Component** + + +- ``Component::triggerCallback`` has been added. It is a generic + hook into the component callback process. It supplants + ``Component::startup()``, ``Component::shutdown()`` and + ``Component::beforeRender()`` as the preferred way to trigger + callbacks. + +**CookieComponent** + + +- ``del`` is deprecated use ``delete`` + +**AclComponent + DbAcl** + +Node reference checks done with paths are now less greedy and will +no longer consume intermediary nodes when doing searches. In the +past given the structure: + +:: + + ROOT/ + Users/ + Users/ + edit + + +#. ``ROOT/`` +#. ``Users/`` +#. ``Users/`` +#. ``edit`` + +The path ``ROOT/Users`` would match the last Users node instead of +the first. In 1.3, if you were expecting to get the last node you +would need to use the path ``ROOT/Users/Users`` + +**RequestHandlerComponent** + + +- ``getReferrer`` is deprecated use ``getReferer`` + +**SessionComponent & SessionHelper** + + +- ``del`` is deprecated use ``delete`` + +``SessionComponent::setFlash()`` second param used to be used for +setting the layout and accordingly rendered a layout file. This has +been modifed to use an element. If you specified custom session +flash layouts in your applications you will need to make the +following changes. + + +#. Move the required layout files into app/views/elements +#. Rename the $content\_for\_layout variable to $message +#. Make sure you have ``echo $session->flash();`` in your layout + +``SessionComponent`` and ``SessionHelper`` are not automatically +loaded. +Both ``SessionComponent`` and ``SessionHelper`` are no longer +automatically included without you asking for them. SessionHelper +and SessionComponent now act like every other component and must be +declared like any other helper/component. You should update +``AppController::$components`` and ``AppController::$helpers`` to +include these classes to retain existing behavior. + +:: + + var $components = array('Session', 'Auth', ...); + var $helpers = array('Session', 'Html', 'Form' ...); + + +#. ``var $components = array('Session', 'Auth', ...);`` +#. ``var $helpers = array('Session', 'Html', 'Form' ...);`` + +These change were done to make CakePHP more explicit and +declarative in what classes you the application developer want to +use. In the past there was no way to avoid loading the Session +classes without modifying core files. Which is something we want +you to be able to avoid. In addition Session classes were the only +magical component and helper. This change helps unify and normalize +behavior amongst all classes. + +Library Classes +~~~~~~~~~~~~~~~ + +**CakeSession** + + +- ``del`` is deprecated use ``delete`` + +**SessionComponent** + + +- ``SessionComponent::setFlash()`` now uses an *element* instead + of a *layout* as its second parameter. Be sure to move any flash + layouts from app/views/layouts to app/views/elements and change + instances of $content\_for\_layout to $message. + +**Folder** + + +- ``mkdir`` is deprecated use ``create`` +- ``mv`` is deprecated use ``move`` +- ``ls`` is deprecated use ``read`` +- ``cp`` is deprecated use ``copy`` +- ``rm`` is deprecated use ``delete`` + +**Set** + + +- ``isEqual`` is deprecated. Use == or ===. + +**String** + + +- ``getInstance`` is deprecated, call String methods statically. + +**Router** + +``Routing.admin`` is deprecated. It provided an inconsistent +behavior with other prefix style routes in that it was treated +differently. Instead you should use ``Routing.prefixes``. Prefix +routes in 1.3 do not require additional routes to be declared +manually. All prefix routes will be generated automatically. To +update simply change your core.php. + +:: + + //from: + Configure::write('Routing.admin', 'admin'); + + //to: + Configure::write('Routing.prefixes', array('admin')); + + +#. ``//from:`` +#. ``Configure::write('Routing.admin', 'admin');`` +#. ``//to:`` +#. ``Configure::write('Routing.prefixes', array('admin'));`` + +See the New features guide for more information on using prefix +routes. A small change has also been done to routing params. Routed +params should now only consist of alphanumeric chars, - and \_ or +``/[A-Z0-9-_+]+/``. + +:: + + Router::connect('/:$%@#param/:action/*', array(...)); // BAD + Router::connect('/:can/:anybody/:see/:m-3/*', array(...)); //Acceptable + + +#. ``Router::connect('/:$%@#param/:action/*', array(...)); // BAD`` +#. ``Router::connect('/:can/:anybody/:see/:m-3/*', array(...)); //Acceptable`` + +For 1.3 the internals of the Router were heavily refactored to +increase performance and reduce code clutter. The side effect of +this is two seldom used features were removed, as they were +problematic and buggy even with the existing code base. First path +segments using full regular expressions was removed. You can no +longer create routes like + +:: + + Router::connect('/([0-9]+)-p-(.*)/', array('controller' => 'products', 'action' => 'show')); + + +#. ``Router::connect('/([0-9]+)-p-(.*)/', array('controller' => 'products', 'action' => 'show'));`` + +These routes complicated route compilation and impossible to +reverse route. If you need routes like this, it is recommended that +you use route parameters with capture patterns. Next mid-route +greedy star support has been removed. It was previously possible to +use a greedy star in the middle of a route. + +:: + + Router::connect( + '/pages/*/:event', + array('controller' => 'pages', 'action' => 'display'), + array('event' => '[a-z0-9_-]+') + ); + + +#. ``Router::connect(`` +#. ``'/pages/*/:event',`` +#. ``array('controller' => 'pages', 'action' => 'display'),`` +#. ``array('event' => '[a-z0-9_-]+')`` +#. ``);`` + +This is no longer supported as mid-route greedy stars behaved +erratically, and complicated route compiling. Outside of these two +edge-case features and the above changes the router behaves exactly +as it did in 1.2 + +Also, people using the 'id' key in array-form URLs will notice that +Router::url() now treats this as a named parameter. If you +previously used this approach for passing the ID parameter to +actions, you will need to rewrite all your $html->link() and +$this->redirect() calls to reflect this change. + +:: + + // old format: + $url = array('controller' => 'posts', 'action' => 'view', 'id' => $id); + // use cases: + Router::url($url); + $html->link($url); + $this->redirect($url); + // 1.2 result: + /posts/view/123 + // 1.3 result: + /posts/view/id:123 + // correct format: + $url = array('controller' => 'posts', 'action' => 'view', $id); + + +#. ``// old format:`` +#. ``$url = array('controller' => 'posts', 'action' => 'view', 'id' => $id);`` +#. ``// use cases:`` +#. ``Router::url($url);`` +#. ``$html->link($url);`` +#. ``$this->redirect($url);`` +#. ``// 1.2 result:`` +#. ``/posts/view/123`` +#. ``// 1.3 result:`` +#. ``/posts/view/id:123`` +#. ``// correct format:`` +#. ``$url = array('controller' => 'posts', 'action' => 'view', $id);`` + +**Dispatcher** + +``Dispatcher`` is no longer capable of setting a controller's +layout/viewPath with request parameters. Control of these +properties should be handled by the Controller, not the Dispatcher. +This feature was also undocumented, and untested. + +**Debugger** + + +- ``Debugger::checkSessionKey()`` has been renamed to + ``Debugger::checkSecurityKeys()`` +- Calling ``Debugger::output("text")`` no longer works. Use + ``Debugger::output("txt")``. + +**Object** + + +- ``Object::$_log`` has been removed. ``CakeLog::write`` is now + called statically. See `New Logging features `_ + for more information on changes made to logging. + +**Sanitize** + + +- ``Sanitize::html()`` now actually always returns escaped + strings. In the past using the ``$remove`` parameter would skip + entity encoding, returning possibly dangerous content. +- ``Sanitize::clean()`` now has a ``remove_html`` option. This + will trigger the ``strip_tags`` feature of ``Sanitize::html()``, + and must be used in conjunction with the ``encode`` parameter. + +**Configure and App** + + +- Configure::listObjects() replaced by App::objects() +- Configure::corePaths() replaced by App::core() +- Configure::buildPaths() replaced by App::build() +- Configure no longer manages paths. +- Configure::write('modelPaths', array...) replaced by + App::build(array('models' => array...)) +- Configure::read('modelPaths') replaced by App::path('models') +- There is no longer a debug = 3. The controller dumps generated + by this setting often caused memory consumption issues making it an + impractical and unusable setting. The ``$cakeDebug`` variable has + also been removed from ``View::renderLayout`` You should remove + this variable reference to avoid errors. +- ``Configure::load()`` can now load configuration files from + plugins. Use ``Configure::load('plugin.file');`` to load + configuration files from plugins. Any configuration files in your + application that use ``.`` in the name should be updated to use + ``_`` + +**Cache** + +In addition to being able to load CacheEngines from app/libs or +plugins, Cache underwent some refactoring for CakePHP1.3. These +refactorings focused around reducing the number and frequency of +method calls. The end result was a significant performance +improvement with only a few minor API changes which are detailed +below. + +The changes in Cache removed the singletons used for each Engine +type, and instead an engine instance is made for each unique key +created with ``Cache::config()``. Since engines are not singletons +anymore, ``Cache::engine()`` was not needed and was removed. In +addition ``Cache::isInitialized()`` now checks cache +*configuration names*, not cache *engine names*. You can still use +``Cache::set()`` or ``Cache::engine()`` to modify cache +configurations. Also checkout the +`New features guide `_ for +more information on the additional methods added to ``Cache``. + +It should be noted that using an app/libs or plugin cache engine +for the default cache config can cause performance issues as the +import that loads these classes will always be uncached. It is +recommended that you either use one of the core cache engines for +your ``default`` configuration, or manually include the cache +engine class before configuring it. Furthermore any non-core cache +engine configurations should be done in +``app/config/bootstrap.php`` for the same reasons detailed above. + +Model Databases and Datasources +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +**Model** + + +- ``Model::del()`` and ``Model::remove()`` have been removed in + favor of ``Model::delete()``, which is now the canonical delete + method. +- ``Model::findAll``, findCount, findNeighbours, removed. +- Dynamic calling of setTablePrefix() has been removed. + tableprefix should be with the ``$tablePrefix`` property, and any + other custom construction behavior should be done in an overridden + ``Model::__construct()``. +- ``DboSource::query()`` now throws warnings for un-handled model + methods, instead of trying to run them as queries. This means, + people starting transactions improperly via the + ``$this->Model->begin()`` syntax will need to update their code so + that it accesses the model's DataSource object directly. +- Missing validation methods will now trigger errors in + development mode. +- Missing behaviors will now trigger a cakeError. +- ``Model::find(first)`` will no longer use the id property for + default conditions if no conditions are supplied and id is not + empty. Instead no conditions will be used +- For Model::saveAll() the default value for option 'validate' is + now 'first' instead of true + +**Datasources** + + +- DataSource::exists() has been refactored to be more consistent + with non-database backed datasources. Previously, if you set + ``var $useTable = false; var $useDbConfig = 'custom';``, it was + impossible for ``Model::exists()`` to return anything but false. + This prevented custom datasources from using ``create()`` or + ``update()`` correctly without some ugly hacks. If you have custom + datasources that implement ``create()``, ``update()``, and + ``read()`` (since ``Model::exists()`` will make a call to + ``Model::find('count')``, which is passed to + ``DataSource::read()``), make sure to re-run your unit tests on + 1.3. + +**Databases** + +Most database configurations no longer support the 'connect' key +(which has been deprecated since pre-1.2). Instead, set +``'persistent' => true`` or false to determine whether or not a +persistent database connection should be used + +**SQL log dumping** + +A commonly asked question is how can one disable or remove the SQL +log dump at the bottom of the page?. In previous versions the HTML +SQL log generation was buried inside DboSource. For 1.3 there is a +new core element called ``sql_dump``. ``DboSource`` no longer +automatically outputs SQL logs. If you want to output SQL logs in +1.3, do the following: + +:: + + element('sql_dump'); ?> + + +#. ``element('sql_dump'); ?>`` + +You can place this element anywhere in your layout or view. The +``sql_dump`` element will only generate output when +``Configure::read('debug')`` is equal to 2. You can of course +customize or override this element in your app by creating +``app/views/elements/sql_dump.ctp``. + +View and Helpers +~~~~~~~~~~~~~~~~ + +**View** + + +- ``View::renderElement`` removed. Use ``View::element()`` + instead. +- Automagic support for ``.thtml`` view file extension has been + removed either declare ``$this->ext = 'thtml';`` in your + controllers, or rename your views to use ``.ctp`` +- ``View::set('title', $var)`` no longer sets + ``$title_for_layout`` when rendering the layout. + ``$title_for_layout`` is still populated by default. But if you + want to customize it, use ``$this->set('title_for_layout', $var)``. +- ``View::$pageTitle`` has been removed. Use + ``$this->set('title_for_layout', $var);`` instead. +- The ``$cakeDebug`` layout variable associated with debug = 3 has + been removed. Remove it from your layouts as it will cause errors. + Also see the notes related to SQL log dumping and Configure for + more information. + +All core helpers no longer use ``Helper::output()``. The method was +inconsistently used and caused output issues with many of +FormHelper's methods. If you previously overrode +``AppHelper::output()`` to force helpers to auto-echo you will need +to update your view files to manually echo helper output. + +**TextHelper** + + +- ``TextHelper::trim()`` is deprecated, used ``truncate()`` + instead. +- ``TextHelper::highlight()`` no longer has: +- an ``$highlighter`` parameter. Use ``$options['format']`` + instead. +- an ``$considerHtml``parameter. Use ``$options['html']`` instead. +- ``TextHelper::truncate()`` no longer has: +- an ``$ending`` parameter. Use ``$options['ending']`` instead. +- an ``$exact`` parameter. Use ``$options['exact']`` instead. +- an ``$considerHtml``parameter. Use ``$options['html']`` + instead. + +**PaginatorHelper** + +PaginatorHelper has had a number of enhancements applied to make +styling easier. +``prev()``, ``next()``, ``first()`` and ``last()`` + +The disabled state of these methods now defaults to ```` tags +instead of ``
`` tags. + +passedArgs are now auto merged with url options in paginator. + +``sort()``, ``prev()``, ``next()`` now add additional class names +to the generated html. ``prev()`` adds a class of prev. ``next()`` +adds a class of next. ``sort()`` will add the direction currently +being sorted, either asc or desc. + +**FormHelper** + + +- ``FormHelper::dateTime()`` no longer has a ``$showEmpty`` + parameter. Use ``$attributes['empty']`` instead. +- ``FormHelper::year()`` no longer has a ``$showEmpty`` parameter. + Use ``$attributes['empty']`` instead. +- ``FormHelper::month()`` no longer has a ``$showEmpty`` + parameter. Use ``$attributes['empty']`` instead. +- ``FormHelper::day()`` no longer has a ``$showEmpty`` parameter. + Use ``$attributes['empty']`` instead. +- ``FormHelper::minute()`` no longer has a ``$showEmpty`` + parameter. Use ``$attributes['empty']`` instead. +- ``FormHelper::meridian()`` no longer has a ``$showEmpty`` + parameter. Use ``$attributes['empty']`` instead. +- ``FormHelper::select()`` no longer has a ``$showEmpty`` + parameter. Use ``$attributes['empty']`` instead. +- Default urls generated by form helper no longer contain 'id' + parameter. This makes default urls more consistent with documented + userland routes. Also enables reverse routing to work in a more + intuitive fashion with default FormHelper urls. +- ``FormHelper::submit()`` Can now create other types of inputs + other than type=submit. Use the type option to control the type of + input generated. +- ``FormHelper::button()`` Now creates `` + + + + +The ``button`` input type allows for a special ``$option`` +attribute called ``'escape'`` which accepts a bool and determines +whether to HTML entity encode the $title of the button. Defaults to +false. + +:: + + Form->button('Submit Form', array('type'=>'submit','escape'=>true)); + ?> + + +#. ``Form->button('Submit Form', array('type'=>'submit','escape'=>true));`` +#. ``?>`` + +year +~~~~ + +``year(string $fieldName, int $minYear, int $maxYear, mixed $selected, array $attributes)`` + +Creates a select element populated with the years from ``$minYear`` +to ``$maxYear``, with the $selected year selected by default. HTML +attributes may be supplied in $attributes. If +``$attributes['empty']`` is false, the select will not include an +empty option. + +:: + + Form->year('purchased',2000,date('Y')); + ?> + + +#. ``Form->year('purchased',2000,date('Y'));`` +#. ``?>`` + +Will output: + +:: + + + +month +~~~~~ + +``month(string $fieldName, mixed $selected, array $attributes)`` + +Creates a select element populated with month names. + +:: + + Form->month('mob'); + ?> + + +#. ``Form->month('mob');`` +#. ``?>`` + +Will output: + +:: + + + +You can pass in your own array of months to be used by setting the +'monthNames' attribute, or have months displayed as numbers by +passing false. (Note: the default months are internationalized and +can be translated using localization.) + +:: + + Form->month('mob', null, array('monthNames' => false)); + ?> + + +#. ``Form->month('mob', null, array('monthNames' => false));`` +#. ``?>`` + +dateTime +~~~~~~~~ + +``dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $selected = null, $attributes = array())`` + +Creates a set of select inputs for date and time. Valid values for +$dateformat are ‘DMY’, ‘MDY’, ‘YMD’ or ‘NONE’. Valid values for +$timeFormat are ‘12’, ‘24’, and null. + +You can specify not to display empty values by setting +"array('empty' => false)" in the attributes parameter. You also can +pre-select the current datetime by setting $selected = null and +$attributes = array("empty" => false). + +day +~~~ + +``day(string $fieldName, mixed $selected, array $attributes, boolean $showEmpty)`` + +Creates a select element populated with the (numerical) days of the +month. + +To create an empty option with prompt text of your choosing (e.g. +the first option is 'Day'), you can supply the text as the final +parameter as follows: + +:: + + Form->day('created'); + ?> + + +#. ``Form->day('created');`` +#. ``?>`` + +Will output: + +:: + + + +hour +~~~~ + +``hour(string $fieldName, boolean $format24Hours, mixed $selected, array $attributes, boolean $showEmpty)`` + +Creates a select element populated with the hours of the day. + +minute +~~~~~~ + +``minute(string $fieldName, mixed $selected, array $attributes, boolean $showEmpty)`` + +Creates a select element populated with the minutes of the hour. + +meridian +~~~~~~~~ + +``meridian(string $fieldName, mixed $selected, array $attributes, boolean $showEmpty)`` + +Creates a select element populated with ‘am’ and ‘pm’. + +error +~~~~~ + +``error(string $fieldName, mixed $text, array $options)`` + +Shows a validation error message, specified by $text, for the given +field, in the event that a validation error has occurred. + +Options: + + +- 'escape' bool Whether or not to html escape the contents of the + error. +- 'wrap' mixed Whether or not the error message should be wrapped + in a div. If a string, will be used as the HTML tag to use. +- 'class' string The classname for the error message + +file +~~~~ + +``file(string $fieldName, array $options)`` + +Creates a file input. + +:: + + Form->create('User',array('type'=>'file')); + echo $this->Form->file('avatar'); + ?> + + +#. ``Form->create('User',array('type'=>'file'));`` +#. ``echo $this->Form->file('avatar');`` +#. ``?>`` + +Will output: + +:: + + + + +When using ``$this->Form->file()``, remember to set the form +encoding-type, by setting the type option to 'file' in +``$this->Form->create()`` +hidden +~~~~~~ + +``hidden(string $fieldName, array $options)`` + +Creates a hidden form input. Example: + +:: + + Form->hidden('id'); + ?> + + +#. ``Form->hidden('id');`` +#. ``?>`` + +Will output: + +:: + + + +isFieldError +~~~~~~~~~~~~ + +``isFieldError(string $fieldName)`` + +Returns true if the supplied $fieldName has an active validation +error. + +:: + + Form->isFieldError('gender')){ + echo $this->Form->error('gender'); + } + ?> + + +#. ``Form->isFieldError('gender')){`` +#. ``echo $this->Form->error('gender');`` +#. ``}`` +#. ``?>`` + +When using ``$this->Form->input()``, errors are rendered by +default. +label +~~~~~ + +``label(string $fieldName, string $text, array $attributes)`` + +Creates a label tag, populated with $text. + +:: + + Form->label('status'); + ?> + + +#. ``Form->label('status');`` +#. ``?>`` + +Will output: + +:: + + + +password +~~~~~~~~ + +``password(string $fieldName, array $options)`` + +Creates a password field. + +:: + + Form->password('password'); + ?> + + +#. ``Form->password('password');`` +#. ``?>`` + +Will output: + +:: + + + +radio +~~~~~ + +``radio(string $fieldName, array $options, array $attributes)`` + +Creates a radio button input. Use ``$attributes['value']`` to set +which value should be selected default. + +Use ``$attributes['separator']`` to specify HTML in between radio +buttons (e.g.
). + +Radio elements are wrapped with a label and fieldset by default. +Set ``$attributes['legend']`` to false to remove them. + +:: + + 'Male','F'=>'Female'); + $attributes=array('legend'=>false); + echo $this->Form->radio('gender',$options,$attributes); + ?> + + +#. ``'Male','F'=>'Female');`` +#. ``$attributes=array('legend'=>false);`` +#. ``echo $this->Form->radio('gender',$options,$attributes);`` +#. ``?>`` + +Will output: + +:: + + + + + + + +If for some reason you don't want the hidden input, setting +``$attributes['value']`` to a selected value or boolean false will +do just that. + +select +~~~~~~ + +``select(string $fieldName, array $options, mixed $selected, array $attributes)`` + +Creates a select element, populated with the items in ``$options``, +with the option specified by ``$selected`` shown as selected by +default. If you wish to display your own default option, add your +string value to the 'empty' key in the ``$attributes`` variable, or +set it to false to turn off the default empty option + +:: + + 'Male', 'F' => 'Female'); + echo $this->Form->select('gender', $options) + ?> + + +#. `` 'Male', 'F' => 'Female');`` +#. ``echo $this->Form->select('gender', $options)`` +#. ``?>`` + +Will output: + +:: + + + +The ``select`` input type allows for a special ``$option`` +attribute called ``'escape'`` which accepts a bool and determines +whether to HTML entity encode the contents of the select options. +Defaults to true. + +:: + + 'Male', 'F' => 'Female'); + echo $this->Form->select('gender', $options, null, array('escape' => false)); + ?> + + +#. `` 'Male', 'F' => 'Female');`` +#. ``echo $this->Form->select('gender', $options, null, array('escape' => false));`` +#. ``?>`` + +submit +~~~~~~ + +``submit(string $caption, array $options)`` + +Creates a submit button with caption ``$caption``. If the supplied +``$caption`` is a URL to an image (it contains a ‘.’ character), +the submit button will be rendered as an image. + +It is enclosed between ``div`` tags by default; you can avoid this +by declaring ``$options['div'] = false``. + +:: + + Form->submit(); + ?> + + +#. ``Form->submit();`` +#. ``?>`` + +Will output: + +:: + +
+ +You can also pass a relative or absolute url to an image for the +caption parameter instead of caption text. + +:: + + Form->submit('ok.png'); + ?> + + +#. ``Form->submit('ok.png');`` +#. ``?>`` + +Will output: + +:: + +
+ +text +~~~~ + +``text(string $fieldName, array $options)`` + +Creates a text input field. + +:: + + Form->text('first_name'); + ?> + + +#. ``Form->text('first_name');`` +#. ``?>`` + +Will output: + +:: + + + +textarea +~~~~~~~~ + +``textarea(string $fieldName, array $options)`` + +Creates a textarea input field. + +:: + + Form->textarea('notes'); + ?> + + +#. ``Form->textarea('notes');`` +#. ``?>`` + +Will output: + +:: + + + +The ``textarea`` input type allows for the ``$options`` attribute +of ``'escape'`` which determines whether or not the contents of the +textarea should be escaped. Defaults to ``true``. +:: + + Form->textarea('notes', array('escape' => false); + // OR.... + echo $this->Form->input('notes', array('type' => 'textarea', 'escape' => false); + ?> + + +#. ``Form->textarea('notes', array('escape' => false);`` +#. ``// OR....`` +#. ``echo $this->Form->input('notes', array('type' => 'textarea', 'escape' => false);`` +#. ``?>`` + +7.3.5 Form Element-Specific Methods +----------------------------------- + +The rest of the methods available in the FormHelper are for +creating specific form elements. Many of these methods also make +use of a special $options parameter. In this case, however, +$options is used primarily to specify HTML tag attributes (such as +the value or DOM id of an element in the form). + +:: + + Form->text('username', array('class' => 'users')); ?> + + +#. ``Form->text('username', array('class' => 'users')); ?>`` + +Will output: + +:: + + + + +checkbox +~~~~~~~~ + +``checkbox(string $fieldName, array $options)`` + +Creates a checkbox form element. This method also generates an +associated hidden form input to force the submission of data for +the specified field. + +:: + + Form->checkbox('done'); ?> + + +#. ``Form->checkbox('done'); ?>`` + +Will output: + +:: + + + + +It is possible to specify the value of the checkbox by using the +$options array: + +:: + + Form->checkbox('done', array('value' => 555)); ?> + + +#. ``Form->checkbox('done', array('value' => 555)); ?>`` + +Will output: + +:: + + + + +If you don't want the Form helper to create a hidden input: + +:: + + Form->checkbox('done', array('hiddenField' => false)); ?> + + +#. ``Form->checkbox('done', array('hiddenField' => false)); ?>`` + +Will output: + +:: + + + +button +~~~~~~ + +``button(string $title, array $options = array())`` + +Creates an HTML button with the specified title and a default type +of "button". Setting ``$options['type']`` will output one of the +three possible button types: + + +#. submit: Same as the ``$this->Form->submit`` method - (the + default). +#. reset: Creates a form reset button. +#. button: Creates a standard push button. + +:: + + Form->button('A Button'); + echo $this->Form->button('Another Button', array('type'=>'button')); + echo $this->Form->button('Reset the Form', array('type'=>'reset')); + echo $this->Form->button('Submit Form', array('type'=>'submit')); + ?> + + +#. ``Form->button('A Button');`` +#. ``echo $this->Form->button('Another Button', array('type'=>'button'));`` +#. ``echo $this->Form->button('Reset the Form', array('type'=>'reset'));`` +#. ``echo $this->Form->button('Submit Form', array('type'=>'submit'));`` +#. ``?>`` + +Will output: + +:: + + + + + + +The ``button`` input type allows for a special ``$option`` +attribute called ``'escape'`` which accepts a bool and determines +whether to HTML entity encode the $title of the button. Defaults to +false. + +:: + + Form->button('Submit Form', array('type'=>'submit','escape'=>true)); + ?> + + +#. ``Form->button('Submit Form', array('type'=>'submit','escape'=>true));`` +#. ``?>`` + +year +~~~~ + +``year(string $fieldName, int $minYear, int $maxYear, mixed $selected, array $attributes)`` + +Creates a select element populated with the years from ``$minYear`` +to ``$maxYear``, with the $selected year selected by default. HTML +attributes may be supplied in $attributes. If +``$attributes['empty']`` is false, the select will not include an +empty option. + +:: + + Form->year('purchased',2000,date('Y')); + ?> + + +#. ``Form->year('purchased',2000,date('Y'));`` +#. ``?>`` + +Will output: + +:: + + + +month +~~~~~ + +``month(string $fieldName, mixed $selected, array $attributes)`` + +Creates a select element populated with month names. + +:: + + Form->month('mob'); + ?> + + +#. ``Form->month('mob');`` +#. ``?>`` + +Will output: + +:: + + + +You can pass in your own array of months to be used by setting the +'monthNames' attribute, or have months displayed as numbers by +passing false. (Note: the default months are internationalized and +can be translated using localization.) + +:: + + Form->month('mob', null, array('monthNames' => false)); + ?> + + +#. ``Form->month('mob', null, array('monthNames' => false));`` +#. ``?>`` + +dateTime +~~~~~~~~ + +``dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $selected = null, $attributes = array())`` + +Creates a set of select inputs for date and time. Valid values for +$dateformat are ‘DMY’, ‘MDY’, ‘YMD’ or ‘NONE’. Valid values for +$timeFormat are ‘12’, ‘24’, and null. + +You can specify not to display empty values by setting +"array('empty' => false)" in the attributes parameter. You also can +pre-select the current datetime by setting $selected = null and +$attributes = array("empty" => false). + +day +~~~ + +``day(string $fieldName, mixed $selected, array $attributes, boolean $showEmpty)`` + +Creates a select element populated with the (numerical) days of the +month. + +To create an empty option with prompt text of your choosing (e.g. +the first option is 'Day'), you can supply the text as the final +parameter as follows: + +:: + + Form->day('created'); + ?> + + +#. ``Form->day('created');`` +#. ``?>`` + +Will output: + +:: + + + +hour +~~~~ + +``hour(string $fieldName, boolean $format24Hours, mixed $selected, array $attributes, boolean $showEmpty)`` + +Creates a select element populated with the hours of the day. + +minute +~~~~~~ + +``minute(string $fieldName, mixed $selected, array $attributes, boolean $showEmpty)`` + +Creates a select element populated with the minutes of the hour. + +meridian +~~~~~~~~ + +``meridian(string $fieldName, mixed $selected, array $attributes, boolean $showEmpty)`` + +Creates a select element populated with ‘am’ and ‘pm’. + +error +~~~~~ + +``error(string $fieldName, mixed $text, array $options)`` + +Shows a validation error message, specified by $text, for the given +field, in the event that a validation error has occurred. + +Options: + + +- 'escape' bool Whether or not to html escape the contents of the + error. +- 'wrap' mixed Whether or not the error message should be wrapped + in a div. If a string, will be used as the HTML tag to use. +- 'class' string The classname for the error message + +file +~~~~ + +``file(string $fieldName, array $options)`` + +Creates a file input. + +:: + + Form->create('User',array('type'=>'file')); + echo $this->Form->file('avatar'); + ?> + + +#. ``Form->create('User',array('type'=>'file'));`` +#. ``echo $this->Form->file('avatar');`` +#. ``?>`` + +Will output: + +:: + + + + +When using ``$this->Form->file()``, remember to set the form +encoding-type, by setting the type option to 'file' in +``$this->Form->create()`` +hidden +~~~~~~ + +``hidden(string $fieldName, array $options)`` + +Creates a hidden form input. Example: + +:: + + Form->hidden('id'); + ?> + + +#. ``Form->hidden('id');`` +#. ``?>`` + +Will output: + +:: + + + +isFieldError +~~~~~~~~~~~~ + +``isFieldError(string $fieldName)`` + +Returns true if the supplied $fieldName has an active validation +error. + +:: + + Form->isFieldError('gender')){ + echo $this->Form->error('gender'); + } + ?> + + +#. ``Form->isFieldError('gender')){`` +#. ``echo $this->Form->error('gender');`` +#. ``}`` +#. ``?>`` + +When using ``$this->Form->input()``, errors are rendered by +default. +label +~~~~~ + +``label(string $fieldName, string $text, array $attributes)`` + +Creates a label tag, populated with $text. + +:: + + Form->label('status'); + ?> + + +#. ``Form->label('status');`` +#. ``?>`` + +Will output: + +:: + + + +password +~~~~~~~~ + +``password(string $fieldName, array $options)`` + +Creates a password field. + +:: + + Form->password('password'); + ?> + + +#. ``Form->password('password');`` +#. ``?>`` + +Will output: + +:: + + + +radio +~~~~~ + +``radio(string $fieldName, array $options, array $attributes)`` + +Creates a radio button input. Use ``$attributes['value']`` to set +which value should be selected default. + +Use ``$attributes['separator']`` to specify HTML in between radio +buttons (e.g.
). + +Radio elements are wrapped with a label and fieldset by default. +Set ``$attributes['legend']`` to false to remove them. + +:: + + 'Male','F'=>'Female'); + $attributes=array('legend'=>false); + echo $this->Form->radio('gender',$options,$attributes); + ?> + + +#. ``'Male','F'=>'Female');`` +#. ``$attributes=array('legend'=>false);`` +#. ``echo $this->Form->radio('gender',$options,$attributes);`` +#. ``?>`` + +Will output: + +:: + + + + + + + +If for some reason you don't want the hidden input, setting +``$attributes['value']`` to a selected value or boolean false will +do just that. + +select +~~~~~~ + +``select(string $fieldName, array $options, mixed $selected, array $attributes)`` + +Creates a select element, populated with the items in ``$options``, +with the option specified by ``$selected`` shown as selected by +default. If you wish to display your own default option, add your +string value to the 'empty' key in the ``$attributes`` variable, or +set it to false to turn off the default empty option + +:: + + 'Male', 'F' => 'Female'); + echo $this->Form->select('gender', $options) + ?> + + +#. `` 'Male', 'F' => 'Female');`` +#. ``echo $this->Form->select('gender', $options)`` +#. ``?>`` + +Will output: + +:: + + + +The ``select`` input type allows for a special ``$option`` +attribute called ``'escape'`` which accepts a bool and determines +whether to HTML entity encode the contents of the select options. +Defaults to true. + +:: + + 'Male', 'F' => 'Female'); + echo $this->Form->select('gender', $options, null, array('escape' => false)); + ?> + + +#. `` 'Male', 'F' => 'Female');`` +#. ``echo $this->Form->select('gender', $options, null, array('escape' => false));`` +#. ``?>`` + +submit +~~~~~~ + +``submit(string $caption, array $options)`` + +Creates a submit button with caption ``$caption``. If the supplied +``$caption`` is a URL to an image (it contains a ‘.’ character), +the submit button will be rendered as an image. + +It is enclosed between ``div`` tags by default; you can avoid this +by declaring ``$options['div'] = false``. + +:: + + Form->submit(); + ?> + + +#. ``Form->submit();`` +#. ``?>`` + +Will output: + +:: + +
+ +You can also pass a relative or absolute url to an image for the +caption parameter instead of caption text. + +:: + + Form->submit('ok.png'); + ?> + + +#. ``Form->submit('ok.png');`` +#. ``?>`` + +Will output: + +:: + +
+ +text +~~~~ + +``text(string $fieldName, array $options)`` + +Creates a text input field. + +:: + + Form->text('first_name'); + ?> + + +#. ``Form->text('first_name');`` +#. ``?>`` + +Will output: + +:: + + + +textarea +~~~~~~~~ + +``textarea(string $fieldName, array $options)`` + +Creates a textarea input field. + +:: + + Form->textarea('notes'); + ?> + + +#. ``Form->textarea('notes');`` +#. ``?>`` + +Will output: + +:: + + + +The ``textarea`` input type allows for the ``$options`` attribute +of ``'escape'`` which determines whether or not the contents of the +textarea should be escaped. Defaults to ``true``. +:: + + Form->textarea('notes', array('escape' => false); + // OR.... + echo $this->Form->input('notes', array('type' => 'textarea', 'escape' => false); + ?> + + +#. ``Form->textarea('notes', array('escape' => false);`` +#. ``// OR....`` +#. ``echo $this->Form->input('notes', array('type' => 'textarea', 'escape' => false);`` +#. ``?>`` diff --git a/source/core-helpers/html.rst b/source/core-helpers/html.rst new file mode 100644 index 000000000..18491a8f1 --- /dev/null +++ b/source/core-helpers/html.rst @@ -0,0 +1,109 @@ +7.4 HTML +-------- + +The role of the HtmlHelper in CakePHP is to make HTML-related +options easier, faster, and more resilient to change. Using this +helper will enable your application to be more light on its feet, +and more flexible on where it is placed in relation to the root of +a domain. + +Before we look at HtmlHelper's methods, you'll need to know about a +few configuration and usage situations that will help you use this +class. First in an effort to assuage those who dislike short tags +() or many echo() calls in their view code all methods of +HtmlHelper are passed to the output() method. If you wish to enable +automatic output of the generated helper HTML you can simply +implement output() in your AppHelper. + +:: + + function output($str) { + echo $str; + } + + +#. ``function output($str) {`` +#. ``echo $str;`` +#. ``}`` + +Doing this will remove the need to add echo statements to your view +code. + +Many HtmlHelper methods also include a $htmlAttributes parameter, +that allow you to tack on any extra attributes on your tags. Here +are a few examples of how to use the $htmlAttributes parameter: + +:: + + Desired attributes: + Array parameter: array('class'=>'someClass') + + Desired attributes: + Array parameter: array('name' => 'foo', 'value' => 'bar') + + +#. ``Desired attributes: `` +#. ``Array parameter: array('class'=>'someClass')`` +#. ```` +#. ``Desired attributes: `` +#. ``Array parameter: array('name' => 'foo', 'value' => 'bar')`` + +The HtmlHelper is available in all views by default. If you're +getting an error informing you that it isn't there, it's usually +due to its name being missing from a manually configured $helpers +controller variable. + +7.4 HTML +-------- + +The role of the HtmlHelper in CakePHP is to make HTML-related +options easier, faster, and more resilient to change. Using this +helper will enable your application to be more light on its feet, +and more flexible on where it is placed in relation to the root of +a domain. + +Before we look at HtmlHelper's methods, you'll need to know about a +few configuration and usage situations that will help you use this +class. First in an effort to assuage those who dislike short tags +() or many echo() calls in their view code all methods of +HtmlHelper are passed to the output() method. If you wish to enable +automatic output of the generated helper HTML you can simply +implement output() in your AppHelper. + +:: + + function output($str) { + echo $str; + } + + +#. ``function output($str) {`` +#. ``echo $str;`` +#. ``}`` + +Doing this will remove the need to add echo statements to your view +code. + +Many HtmlHelper methods also include a $htmlAttributes parameter, +that allow you to tack on any extra attributes on your tags. Here +are a few examples of how to use the $htmlAttributes parameter: + +:: + + Desired attributes: + Array parameter: array('class'=>'someClass') + + Desired attributes: + Array parameter: array('name' => 'foo', 'value' => 'bar') + + +#. ``Desired attributes: `` +#. ``Array parameter: array('class'=>'someClass')`` +#. ```` +#. ``Desired attributes: `` +#. ``Array parameter: array('name' => 'foo', 'value' => 'bar')`` + +The HtmlHelper is available in all views by default. If you're +getting an error informing you that it isn't there, it's usually +due to its name being missing from a manually configured $helpers +controller variable. diff --git a/source/core-helpers/html/changing-the-tags-output-by-htmlhelper.rst b/source/core-helpers/html/changing-the-tags-output-by-htmlhelper.rst new file mode 100644 index 000000000..ddd2ed970 --- /dev/null +++ b/source/core-helpers/html/changing-the-tags-output-by-htmlhelper.rst @@ -0,0 +1,53 @@ +7.4.2 Changing the tags output by HtmlHelper +-------------------------------------------- + +The built in tag sets for ``HtmlHelper`` are XHTML compliant, +however if you need to generate HTML for HTML4 you will need to +create and load a new tags config file containing the tags you'd +like to use. To change the tags used create ``app/config/tags.php`` +containing: + +:: + + $tags = array( + 'metalink' => '', + 'input' => '', + //... + ); + + +#. ``$tags = array(`` +#. ``'metalink' => '',`` +#. ``'input' => '',`` +#. ``//...`` +#. ``);`` + +You can then load this tag set by calling +``$html->loadConfig('tags');`` + +7.4.2 Changing the tags output by HtmlHelper +-------------------------------------------- + +The built in tag sets for ``HtmlHelper`` are XHTML compliant, +however if you need to generate HTML for HTML4 you will need to +create and load a new tags config file containing the tags you'd +like to use. To change the tags used create ``app/config/tags.php`` +containing: + +:: + + $tags = array( + 'metalink' => '', + 'input' => '', + //... + ); + + +#. ``$tags = array(`` +#. ``'metalink' => '',`` +#. ``'input' => '',`` +#. ``//...`` +#. ``);`` + +You can then load this tag set by calling +``$html->loadConfig('tags');`` diff --git a/source/core-helpers/html/creating-breadcrumb-trails-with-htmlhelper.rst b/source/core-helpers/html/creating-breadcrumb-trails-with-htmlhelper.rst new file mode 100644 index 000000000..e4ce121c7 --- /dev/null +++ b/source/core-helpers/html/creating-breadcrumb-trails-with-htmlhelper.rst @@ -0,0 +1,57 @@ +7.4.3 Creating breadcrumb trails with HtmlHelper +------------------------------------------------ + +CakePHP has the built in ability to automatically create a +breadcrumb trail in your app. To set this up, first add something +similar to the following in your layout template. + +:: + + echo $this->Html->getCrumbs(' > ','Home'); + + +#. ``echo $this->Html->getCrumbs(' > ','Home');`` + +Now, in your view you'll want to add the following to start the +breadcrumb trails on each of the pages. + +:: + + echo $this->Html->addCrumb('Users', '/users'); + echo $this->Html->addCrumb('Add User', '/users/add'); + + +#. ``echo $this->Html->addCrumb('Users', '/users');`` +#. ``echo $this->Html->addCrumb('Add User', '/users/add');`` + +This will add the output of "**Home > Users > Add User**" in your +layout where getCrumbs was added. + +7.4.3 Creating breadcrumb trails with HtmlHelper +------------------------------------------------ + +CakePHP has the built in ability to automatically create a +breadcrumb trail in your app. To set this up, first add something +similar to the following in your layout template. + +:: + + echo $this->Html->getCrumbs(' > ','Home'); + + +#. ``echo $this->Html->getCrumbs(' > ','Home');`` + +Now, in your view you'll want to add the following to start the +breadcrumb trails on each of the pages. + +:: + + echo $this->Html->addCrumb('Users', '/users'); + echo $this->Html->addCrumb('Add User', '/users/add'); + + +#. ``echo $this->Html->addCrumb('Users', '/users');`` +#. ``echo $this->Html->addCrumb('Add User', '/users/add');`` + +This will add the output of "**Home > Users > Add User**" in your +layout where getCrumbs was added. diff --git a/source/core-helpers/html/inserting-well-formatted-elements.rst b/source/core-helpers/html/inserting-well-formatted-elements.rst new file mode 100644 index 000000000..85facba5a --- /dev/null +++ b/source/core-helpers/html/inserting-well-formatted-elements.rst @@ -0,0 +1,1787 @@ +7.4.1 Inserting Well-Formatted elements +--------------------------------------- + +The most important task the HtmlHelper accomplishes is creating +well formed markup. Don't be afraid to use it often - you can cache +views in CakePHP in order to save some CPU cycles when views are +being rendered and delivered. This section will cover some of the +methods of the HtmlHelper and how to use them. + +charset +~~~~~~~ + +``charset(string $charset=null)`` + +Used to create a meta tag specifying the document's character. +Defaults to UTF-8. + +:: + + + Html->charset(); ?> + + +#. ``Html->charset(); ?>`` + +Will output: + +:: + + + +Alternatively, + +:: + + Html->charset('ISO-8859-1'); ?> + + +#. ``Html->charset('ISO-8859-1'); ?>`` + +Will output: + +:: + + + +css +~~~ + +``css(mixed $path, string $rel = null, array $options = array())`` + +Creates a link(s) to a CSS style-sheet. If key 'inline' is set to +false in $options parameter, the link tags are added to the +$scripts\_for\_layout variable which you can print inside the head +tag of the document. + +This method of CSS inclusion assumes that the CSS file specified +resides inside the /app/webroot/css directory. + +:: + + Html->css('forms'); ?> + + +#. ``Html->css('forms'); ?>`` + +Will output: + +:: + + + +The first parameter can be an array to include multiple files. + +:: + + Html->css(array('forms','tables','menu')); ?> + + +#. ``Html->css(array('forms','tables','menu')); ?>`` + +Will output: + +:: + + + + + +meta +~~~~ + +``meta(string $type, string $url = null, array $attributes = array())`` + +This method is handy for linking to external resources like +RSS/Atom feeds and favicons. Like css(), you can specify whether or +not you'd like this tag to appear inline or in the head tag by +setting the 'inline' key in the $attributes parameter to false, ie +- ``array('inline' => false)``. + +If you set the "type" attribute using the $attributes parameter, +CakePHP contains a few shortcuts: + +type +translated value +html +text/html +rss +application/rss+xml +atom +application/atom+xml +icon +image/x-icon +:: + + Html->meta( + 'favicon.ico', + '/favicon.ico', + array('type' => 'icon') + );?> //Output (line breaks added)

+ + + Html->meta( + 'Comments', + '/comments/index.rss', + array('type' => 'rss')); + ?> + + //Output (line breaks added) + + + +#. ``Html->meta(`` +#. ``'favicon.ico',`` +#. ``'/favicon.ico',`` +#. ``array('type' => 'icon')`` +#. ``);?> //Output (line breaks added)

`` +#. ```` +#. ```` +#. ``Html->meta(`` +#. ``'Comments',`` +#. ``'/comments/index.rss',`` +#. ``array('type' => 'rss'));`` +#. ``?>`` +#. ```` +#. ``//Output (line breaks added)`` +#. ```` + +This method can also be used to add the meta keywords and +descriptions. Example: + +:: + + Html->meta( + 'keywords', + 'enter any meta keyword here' + );?> + //Output + // + + Html->meta( + 'description', + 'enter any meta description here' + );?> + + //Output + + +#. ``Html->meta(`` +#. ``'keywords',`` +#. ``'enter any meta keyword here'`` +#. ``);?>`` +#. ``//Output `` +#. ``//`` +#. ``Html->meta(`` +#. ``'description',`` +#. ``'enter any meta description here'`` +#. ``);?>`` +#. ``//Output `` + +If you want to add a custom meta tag then the first parameter +should be set to an array. To output a robots noindex tag use the +following code: + +:: + + echo $this->Html->meta(array('name' => 'robots', 'content' => 'noindex')); + + +#. ``echo $this->Html->meta(array('name' => 'robots', 'content' => 'noindex'));`` + +docType +~~~~~~~ + +``docType(string $type = 'xhtml-strict')`` + +Returns a (X)HTML doctype tag. Supply the doctype according to the +following table: + +type +translated value +html +text/html +html4-strict +HTML4 Strict +html4-trans +HTML4 Transitional +html4-frame +HTML4 Frameset +xhtml-strict +XHTML1 Strict +xhtml-trans +XHTML1 Transitional +xhtml-frame +XHTML1 Frameset +xhtml11 +XHTML 1.1 +:: + + Html->docType(); ?> + + + Html->docType('html4-trans'); ?> + + + +#. ``Html->docType(); ?>`` +#. ```` +#. ``Html->docType('html4-trans'); ?>`` +#. ```` + +style +~~~~~ + +``style(array $data, boolean $oneline = true)`` + +Builds CSS style definitions based on the keys and values of the +array passed to the method. Especially handy if your CSS file is +dynamic. + +:: + + Html->style(array( + 'background' => '#633', + 'border-bottom' => '1px solid #000', + 'padding' => '10px' + )); ?> + + +#. ``Html->style(array(`` +#. ``'background' => '#633',`` +#. ``'border-bottom' => '1px solid #000',`` +#. ``'padding' => '10px'`` +#. ``)); ?>`` + +Will output: + +:: + + background:#633; border-bottom:1px solid #000; padding:10px; + +image +~~~~~ + +``image(string $path, array $htmlAttributes = array())`` + +Creates a formatted image tag. The path supplied should be relative +to /app/webroot/img/. + +:: + + Html->image('cake_logo.png', array('alt' => 'CakePHP'))?> + + +#. ``Html->image('cake_logo.png', array('alt' => 'CakePHP'))?>`` + +Will output: + +:: + + CakePHP + +To create an image link specify the link destination using the +``url`` option in ``$htmlAttributes``. + +:: + + Html->image("recipes/6.jpg", array( + "alt" => "Brownies", + 'url' => array('controller' => 'recipes', 'action' => 'view', 6) + )); ?> + + +#. ``Html->image("recipes/6.jpg", array(`` +#. ``"alt" => "Brownies",`` +#. ``'url' => array('controller' => 'recipes', 'action' => 'view', 6)`` +#. ``)); ?>`` + +Will output: + +:: + + + Brownies + + +link +~~~~ + +``link(string $title, mixed $url = null, array $options = array(), string $confirmMessage = false)`` + +General purpose method for creating HTML links. Use ``$options`` to +specify attributes for the element and whether or not the +``$title`` should be escaped. + +:: + + Html->link('Enter', '/pages/home', array('class' => 'button', 'target' => '_blank')); ?> + + +#. ``Html->link('Enter', '/pages/home', array('class' => 'button', 'target' => '_blank')); ?>`` + +Will output: + +:: + + + Enter + +Specify ``$confirmMessage`` to display a javascript ``confirm()`` +dialog. + +:: + + Html->link( + 'Delete', + array('controller' => 'recipes', 'action' => 'delete', 6), + array(), + "Are you sure you wish to delete this recipe?" + );?> + + +#. ``Html->link(`` +#. ``'Delete',`` +#. ``array('controller' => 'recipes', 'action' => 'delete', 6),`` +#. ``array(),`` +#. ``"Are you sure you wish to delete this recipe?"`` +#. ``);?>`` + +Will output: + +:: + + + Delete + +Query strings can also be created with ``link()``. + +:: + + Html->link('View image', array( + 'controller' => 'images', + 'action' => 'view', + 1, + '?' => array('height' => 400, 'width' => 500)) + ); + + +#. ``Html->link('View image', array(`` +#. ``'controller' => 'images',`` +#. ``'action' => 'view',`` +#. ``1,`` +#. ``'?' => array('height' => 400, 'width' => 500))`` +#. ``);`` + +Will output: + +:: + + + View image + +HTML special characters in ``$title`` will be converted to HTML +entities. To disable this conversion, set the escape option to +false in the ``$options`` array. + +:: + + Html->link( + $this->Html->image("recipes/6.jpg", array("alt" => "Brownies")), + "recipes/view/6", + array('escape' => false) + ); + + ?> + + +#. ``Html->link(`` +#. ``$this->Html->image("recipes/6.jpg", array("alt" => "Brownies")),`` +#. ``"recipes/view/6",`` +#. ``array('escape' => false)`` +#. ``);`` +#. ``?>`` + +Will output: + +:: + + + Brownies + + +Also check +`HtmlHelper::url `_ method +for more examples of different types of urls. + +tag +~~~ + +``tag(string $tag, string $text, array $htmlAttributes)`` + +Returns text wrapped in a specified tag. If no text is specified +then only the opening is returned. + +:: + + Html->tag('span', 'Hello World.', array('class' => 'welcome'));?> + + //Output + Hello World + + //No text specified. + Html->tag('span', null, array('class' => 'welcome'));?> + + //Output + + + +#. ``Html->tag('span', 'Hello World.', array('class' => 'welcome'));?>`` +#. ```` +#. ``//Output`` +#. ``Hello World`` +#. ```` +#. ``//No text specified.`` +#. ``Html->tag('span', null, array('class' => 'welcome'));?>`` +#. ```` +#. ``//Output`` +#. ```` + +Text is not escaped by default but you may use +``$htmlOptions['escape'] = true`` to escape your text. This +replaces a fourth parameter ``boolean $escape = false`` that was +available in previous versions. + +div +~~~ + +``div(string $class, string $text, array $options)`` + +Used for creating div-wrapped sections of markup. The first +parameter specifies a CSS class, and the second is used to supply +the text to be wrapped by div tags. If the last parameter has been +set to true, $text will be printed HTML-escaped. + +If no text is specified, only an opening div tag is returned. + +:: + + + Html->div('error', 'Please enter your credit card number.');?> + + //Output +
Please enter your credit card number.
+ + +#. ``Html->div('error', 'Please enter your credit card number.');?>`` +#. `` `` +#. ``//Output`` +#. ``
Please enter your credit card number.
`` + +para +~~~~ + +``para(string $class, string $text, array $htmlAttributes, boolean $escape = false)`` + +Returns a text wrapped in a CSS-classed

tag. If no text is +supplied, only a starting

tag is returned. +:: + + Html->para(null, 'Hello World.');?> + + //Output +

Hello World.

+ + +#. ``Html->para(null, 'Hello World.');?>`` +#. ```` +#. ``//Output`` +#. ``

Hello World.

`` + +script +~~~~~~ + +script(mixed $url, mixed $options) + +Creates link(s) to a javascript file. If key ``inline`` is set to +false in $options, the link tags are added to the +$scripts\_for\_layout variable which you can print inside the head +tag of the document. + +Include a script file into the page. ``$options['inline']`` +controls whether or not a script should be returned inline or added +to $scripts\_for\_layout. ``$options['once']`` controls, whether or +not you want to include this script once per request or more than +once. + +You can also use $options to set additional properties to the +generated script tag. If an array of script tags is used, the +attributes will be applied to all of the generated script tags. + +This method of javascript file inclusion assumes that the +javascript file specified resides inside the /app/webroot/js +directory. + +:: + + Html->script('scripts'); ?> + + +#. ``Html->script('scripts'); ?>`` + +Will output: + +:: + + + +You can link to files with absolute paths as well to link files +that are not in ``app/webroot/js`` + +:: + + Html->script('/otherdir/script_file'); ?> + + +#. ``Html->script('/otherdir/script_file'); ?>`` + +The first parameter can be an array to include multiple files. + +:: + + Html->script(array('jquery','wysiwyg','scripts')); ?> + + +#. ``Html->script(array('jquery','wysiwyg','scripts')); ?>`` + +Will output: + +:: + + + + + +scriptBlock +~~~~~~~~~~~ + +scriptBlock($code, $options = array()) + +Generate a code block containing ``$code`` set +``$options['inline']`` to false to have the script block appear in +``$scripts_for_layout``. Also new is the ability to add attributes +to script tags. +``$this->html->scriptBlock('stuff', array('defer' => true));`` will +create a script tag with ``defer="defer"`` attribute. + +scriptStart +~~~~~~~~~~~ + +scriptStart($options = array()) + +Begin a buffering code block. This code block will capture all +output between ``scriptStart()`` and ``scriptEnd()`` and create an +script tag. Options are the same as ``scriptBlock()`` + +scriptEnd +~~~~~~~~~ + +scriptEnd() + +End a buffering script block, returns the generated script element +or null if the script block was opened with inline = false. + +An example of using ``scriptStart()`` and ``scriptEnd()`` would +be: + +:: + + $this->Html->scriptStart(array('inline' => false)); + + echo $this->Js->alert('I am in the javascript'); + + $this->Html->scriptEnd(); + + +#. ``$this->Html->scriptStart(array('inline' => false));`` +#. ``echo $this->Js->alert('I am in the javascript');`` +#. ``$this->Html->scriptEnd();`` + +tableHeaders +~~~~~~~~~~~~ + +``tableHeaders(array $names, array $trOptions = null, array $thOptions = null)`` + +Creates a row of table header cells to be placed inside of +tags. +:: + + Html->tableHeaders(array('Date','Title','Active'));?> + + //Output + + + + + + + Html->tableHeaders( + array('Date','Title','Active'), + array('class' => 'status'), + array('class' => 'product_table') + );?> + + //Output + + + + + + + +#. ``Html->tableHeaders(array('Date','Title','Active'));?>`` +#. `` `` +#. ``//Output`` +#. ```` +#. ```` +#. ```` +#. ```` +#. ```` +#. ```` +#. ``Html->tableHeaders(`` +#. ``array('Date','Title','Active'),`` +#. ``array('class' => 'status'),`` +#. ``array('class' => 'product_table')`` +#. ``);?>`` +#. ```` +#. ``//Output`` +#. ```` +#. ```` +#. ```` +#. ```` +#. ```` + +tableCells +~~~~~~~~~~ + +``tableCells(array $data, array $oddTrOptions = null, array $evenTrOptions = null, $useCount = false, $continueOddEven = true)`` + +Creates table cells, in rows, assigning attributes differently +for odd- and even-numbered rows. Wrap a single table cell within an +array() for specific + + + + Html->tableCells(array( + array('Jul 7th, 2007', array('Best Brownies', array('class'=>'highlight')) , 'Yes'), + array('Jun 21st, 2007', 'Smart Cookies', 'Yes'), + array('Aug 1st, 2006', 'Anti-Java Cake', array('No', array('id'=>'special'))), + )); + ?> + + //Output + + + + + Html->tableCells( + array( + array('Red', 'Apple'), + array('Orange', 'Orange'), + array('Yellow', 'Banana'), + ), + array('class' => 'darker') + ); + ?> + + //Output + + + + + +#. ``Html->tableCells(array(`` +#. ``array('Jul 7th, 2007', 'Best Brownies', 'Yes'),`` +#. ``array('Jun 21st, 2007', 'Smart Cookies', 'Yes'),`` +#. ``array('Aug 1st, 2006', 'Anti-Java Cake', 'No'),`` +#. ``));`` +#. ``?>`` +#. ```` +#. ``//Output`` +#. ```` +#. ```` +#. ```` +#. ```` +#. ``Html->tableCells(array(`` +#. ``array('Jul 7th, 2007', array('Best Brownies', array('class'=>'highlight')) , 'Yes'),`` +#. ``array('Jun 21st, 2007', 'Smart Cookies', 'Yes'),`` +#. ``array('Aug 1st, 2006', 'Anti-Java Cake', array('No', array('id'=>'special'))),`` +#. ``));`` +#. ``?>`` +#. ```` +#. ``//Output`` +#. ```` +#. ```` +#. ```` +#. ```` +#. ``Html->tableCells(`` +#. ``array(`` +#. ``array('Red', 'Apple'),`` +#. ``array('Orange', 'Orange'),`` +#. ``array('Yellow', 'Banana'),`` +#. ``),`` +#. ``array('class' => 'darker')`` +#. ``);`` +#. ``?>`` +#. ```` +#. ``//Output`` +#. ```` +#. ```` +#. ```` + +url +~~~ + +``url(mixed $url = NULL, boolean $full = false)`` + +Returns an URL pointing to a combination of controller and action. +If $url is empty, it returns the REQUEST\_URI, otherwise it +generates the url for the controller and action combo. If full is +true, the full base URL will be prepended to the result. + +:: + + Html->url(array( + "controller" => "posts", + "action" => "view", + "bar"));?> + + // Output + /posts/view/bar + + +#. ``Html->url(array(`` +#. ``"controller" => "posts",`` +#. ``"action" => "view",`` +#. ``"bar"));?>`` +#. ```` +#. ``// Output`` +#. ``/posts/view/bar`` + +Here are a few more usage examples: + +URL with named parameters + +:: + + Html->url(array( + "controller" => "posts", + "action" => "view", + "foo" => "bar")); + ?> + + // Output + /posts/view/foo:bar + + +#. ``Html->url(array(`` +#. ``"controller" => "posts",`` +#. ``"action" => "view",`` +#. ``"foo" => "bar"));`` +#. ``?>`` +#. ```` +#. ``// Output`` +#. ``/posts/view/foo:bar`` + +URL with extension + +:: + + Html->url(array( + "controller" => "posts", + "action" => "list", + "ext" => "rss")); + ?> + + // Output + /posts/list.rss + + +#. ``Html->url(array(`` +#. ``"controller" => "posts",`` +#. ``"action" => "list",`` +#. ``"ext" => "rss"));`` +#. ``?>`` +#. ```` +#. ``// Output`` +#. ``/posts/list.rss`` + +URL (starting with '/') with the full base URL prepended. + +:: + + Html->url('/posts', true); ?> + + //Output + http://somedomain.com/posts + + +#. ``Html->url('/posts', true); ?>`` +#. `` `` +#. ``//Output`` +#. ``http://somedomain.com/posts`` + +URL with GET params and named anchor + +:: + + Html->url(array( + "controller" => "posts", + "action" => "search", + "?" => array("foo" => "bar"), + "#" => "first")); + ?> + + //Output + /posts/search?foo=bar#first + + +#. ``Html->url(array(`` +#. ``"controller" => "posts",`` +#. ``"action" => "search",`` +#. ``"?" => array("foo" => "bar"),`` +#. ``"#" => "first"));`` +#. ``?>`` +#. `` `` +#. ``//Output`` +#. ``/posts/search?foo=bar#first`` + +For further information check +`Router::url `_ +in the API. + +7.4.1 Inserting Well-Formatted elements +--------------------------------------- + +The most important task the HtmlHelper accomplishes is creating +well formed markup. Don't be afraid to use it often - you can cache +views in CakePHP in order to save some CPU cycles when views are +being rendered and delivered. This section will cover some of the +methods of the HtmlHelper and how to use them. + +charset +~~~~~~~ + +``charset(string $charset=null)`` + +Used to create a meta tag specifying the document's character. +Defaults to UTF-8. + +:: + + + Html->charset(); ?> + + +#. ``Html->charset(); ?>`` + +Will output: + +:: + + + +Alternatively, + +:: + + Html->charset('ISO-8859-1'); ?> + + +#. ``Html->charset('ISO-8859-1'); ?>`` + +Will output: + +:: + + + +css +~~~ + +``css(mixed $path, string $rel = null, array $options = array())`` + +Creates a link(s) to a CSS style-sheet. If key 'inline' is set to +false in $options parameter, the link tags are added to the +$scripts\_for\_layout variable which you can print inside the head +tag of the document. + +This method of CSS inclusion assumes that the CSS file specified +resides inside the /app/webroot/css directory. + +:: + + Html->css('forms'); ?> + + +#. ``Html->css('forms'); ?>`` + +Will output: + +:: + + + +The first parameter can be an array to include multiple files. + +:: + + Html->css(array('forms','tables','menu')); ?> + + +#. ``Html->css(array('forms','tables','menu')); ?>`` + +Will output: + +:: + + + + + +meta +~~~~ + +``meta(string $type, string $url = null, array $attributes = array())`` + +This method is handy for linking to external resources like +RSS/Atom feeds and favicons. Like css(), you can specify whether or +not you'd like this tag to appear inline or in the head tag by +setting the 'inline' key in the $attributes parameter to false, ie +- ``array('inline' => false)``. + +If you set the "type" attribute using the $attributes parameter, +CakePHP contains a few shortcuts: + +type +translated value +html +text/html +rss +application/rss+xml +atom +application/atom+xml +icon +image/x-icon +:: + + Html->meta( + 'favicon.ico', + '/favicon.ico', + array('type' => 'icon') + );?> //Output (line breaks added)

+ + + Html->meta( + 'Comments', + '/comments/index.rss', + array('type' => 'rss')); + ?> + + //Output (line breaks added) + + + +#. ``Html->meta(`` +#. ``'favicon.ico',`` +#. ``'/favicon.ico',`` +#. ``array('type' => 'icon')`` +#. ``);?> //Output (line breaks added)

`` +#. ```` +#. ```` +#. ``Html->meta(`` +#. ``'Comments',`` +#. ``'/comments/index.rss',`` +#. ``array('type' => 'rss'));`` +#. ``?>`` +#. ```` +#. ``//Output (line breaks added)`` +#. ```` + +This method can also be used to add the meta keywords and +descriptions. Example: + +:: + + Html->meta( + 'keywords', + 'enter any meta keyword here' + );?> + //Output + // + + Html->meta( + 'description', + 'enter any meta description here' + );?> + + //Output + + +#. ``Html->meta(`` +#. ``'keywords',`` +#. ``'enter any meta keyword here'`` +#. ``);?>`` +#. ``//Output `` +#. ``//`` +#. ``Html->meta(`` +#. ``'description',`` +#. ``'enter any meta description here'`` +#. ``);?>`` +#. ``//Output `` + +If you want to add a custom meta tag then the first parameter +should be set to an array. To output a robots noindex tag use the +following code: + +:: + + echo $this->Html->meta(array('name' => 'robots', 'content' => 'noindex')); + + +#. ``echo $this->Html->meta(array('name' => 'robots', 'content' => 'noindex'));`` + +docType +~~~~~~~ + +``docType(string $type = 'xhtml-strict')`` + +Returns a (X)HTML doctype tag. Supply the doctype according to the +following table: + +type +translated value +html +text/html +html4-strict +HTML4 Strict +html4-trans +HTML4 Transitional +html4-frame +HTML4 Frameset +xhtml-strict +XHTML1 Strict +xhtml-trans +XHTML1 Transitional +xhtml-frame +XHTML1 Frameset +xhtml11 +XHTML 1.1 +:: + + Html->docType(); ?> + + + Html->docType('html4-trans'); ?> + + + +#. ``Html->docType(); ?>`` +#. ```` +#. ``Html->docType('html4-trans'); ?>`` +#. ```` + +style +~~~~~ + +``style(array $data, boolean $oneline = true)`` + +Builds CSS style definitions based on the keys and values of the +array passed to the method. Especially handy if your CSS file is +dynamic. + +:: + + Html->style(array( + 'background' => '#633', + 'border-bottom' => '1px solid #000', + 'padding' => '10px' + )); ?> + + +#. ``Html->style(array(`` +#. ``'background' => '#633',`` +#. ``'border-bottom' => '1px solid #000',`` +#. ``'padding' => '10px'`` +#. ``)); ?>`` + +Will output: + +:: + + background:#633; border-bottom:1px solid #000; padding:10px; + +image +~~~~~ + +``image(string $path, array $htmlAttributes = array())`` + +Creates a formatted image tag. The path supplied should be relative +to /app/webroot/img/. + +:: + + Html->image('cake_logo.png', array('alt' => 'CakePHP'))?> + + +#. ``Html->image('cake_logo.png', array('alt' => 'CakePHP'))?>`` + +Will output: + +:: + + CakePHP + +To create an image link specify the link destination using the +``url`` option in ``$htmlAttributes``. + +:: + + Html->image("recipes/6.jpg", array( + "alt" => "Brownies", + 'url' => array('controller' => 'recipes', 'action' => 'view', 6) + )); ?> + + +#. ``Html->image("recipes/6.jpg", array(`` +#. ``"alt" => "Brownies",`` +#. ``'url' => array('controller' => 'recipes', 'action' => 'view', 6)`` +#. ``)); ?>`` + +Will output: + +:: + + + Brownies + + +link +~~~~ + +``link(string $title, mixed $url = null, array $options = array(), string $confirmMessage = false)`` + +General purpose method for creating HTML links. Use ``$options`` to +specify attributes for the element and whether or not the +``$title`` should be escaped. + +:: + + Html->link('Enter', '/pages/home', array('class' => 'button', 'target' => '_blank')); ?> + + +#. ``Html->link('Enter', '/pages/home', array('class' => 'button', 'target' => '_blank')); ?>`` + +Will output: + +:: + + + Enter + +Specify ``$confirmMessage`` to display a javascript ``confirm()`` +dialog. + +:: + + Html->link( + 'Delete', + array('controller' => 'recipes', 'action' => 'delete', 6), + array(), + "Are you sure you wish to delete this recipe?" + );?> + + +#. ``Html->link(`` +#. ``'Delete',`` +#. ``array('controller' => 'recipes', 'action' => 'delete', 6),`` +#. ``array(),`` +#. ``"Are you sure you wish to delete this recipe?"`` +#. ``);?>`` + +Will output: + +:: + + + Delete + +Query strings can also be created with ``link()``. + +:: + + Html->link('View image', array( + 'controller' => 'images', + 'action' => 'view', + 1, + '?' => array('height' => 400, 'width' => 500)) + ); + + +#. ``Html->link('View image', array(`` +#. ``'controller' => 'images',`` +#. ``'action' => 'view',`` +#. ``1,`` +#. ``'?' => array('height' => 400, 'width' => 500))`` +#. ``);`` + +Will output: + +:: + + + View image + +HTML special characters in ``$title`` will be converted to HTML +entities. To disable this conversion, set the escape option to +false in the ``$options`` array. + +:: + + Html->link( + $this->Html->image("recipes/6.jpg", array("alt" => "Brownies")), + "recipes/view/6", + array('escape' => false) + ); + + ?> + + +#. ``Html->link(`` +#. ``$this->Html->image("recipes/6.jpg", array("alt" => "Brownies")),`` +#. ``"recipes/view/6",`` +#. ``array('escape' => false)`` +#. ``);`` +#. ``?>`` + +Will output: + +:: + + + Brownies + + +Also check +`HtmlHelper::url `_ method +for more examples of different types of urls. + +tag +~~~ + +``tag(string $tag, string $text, array $htmlAttributes)`` + +Returns text wrapped in a specified tag. If no text is specified +then only the opening is returned. + +:: + + Html->tag('span', 'Hello World.', array('class' => 'welcome'));?> + + //Output + Hello World + + //No text specified. + Html->tag('span', null, array('class' => 'welcome'));?> + + //Output + + + +#. ``Html->tag('span', 'Hello World.', array('class' => 'welcome'));?>`` +#. ```` +#. ``//Output`` +#. ``Hello World`` +#. ```` +#. ``//No text specified.`` +#. ``Html->tag('span', null, array('class' => 'welcome'));?>`` +#. ```` +#. ``//Output`` +#. ```` + +Text is not escaped by default but you may use +``$htmlOptions['escape'] = true`` to escape your text. This +replaces a fourth parameter ``boolean $escape = false`` that was +available in previous versions. + +div +~~~ + +``div(string $class, string $text, array $options)`` + +Used for creating div-wrapped sections of markup. The first +parameter specifies a CSS class, and the second is used to supply +the text to be wrapped by div tags. If the last parameter has been +set to true, $text will be printed HTML-escaped. + +If no text is specified, only an opening div tag is returned. + +:: + + + Html->div('error', 'Please enter your credit card number.');?> + + //Output +
Please enter your credit card number.
+ + +#. ``Html->div('error', 'Please enter your credit card number.');?>`` +#. `` `` +#. ``//Output`` +#. ``
Please enter your credit card number.
`` + +para +~~~~ + +``para(string $class, string $text, array $htmlAttributes, boolean $escape = false)`` + +Returns a text wrapped in a CSS-classed

tag. If no text is +supplied, only a starting

tag is returned. +:: + + Html->para(null, 'Hello World.');?> + + //Output +

Hello World.

+ + +#. ``Html->para(null, 'Hello World.');?>`` +#. ```` +#. ``//Output`` +#. ``

Hello World.

`` + +script +~~~~~~ + +script(mixed $url, mixed $options) + +Creates link(s) to a javascript file. If key ``inline`` is set to +false in $options, the link tags are added to the +$scripts\_for\_layout variable which you can print inside the head +tag of the document. + +Include a script file into the page. ``$options['inline']`` +controls whether or not a script should be returned inline or added +to $scripts\_for\_layout. ``$options['once']`` controls, whether or +not you want to include this script once per request or more than +once. + +You can also use $options to set additional properties to the +generated script tag. If an array of script tags is used, the +attributes will be applied to all of the generated script tags. + +This method of javascript file inclusion assumes that the +javascript file specified resides inside the /app/webroot/js +directory. + +:: + + Html->script('scripts'); ?> + + +#. ``Html->script('scripts'); ?>`` + +Will output: + +:: + + + +You can link to files with absolute paths as well to link files +that are not in ``app/webroot/js`` + +:: + + Html->script('/otherdir/script_file'); ?> + + +#. ``Html->script('/otherdir/script_file'); ?>`` + +The first parameter can be an array to include multiple files. + +:: + + Html->script(array('jquery','wysiwyg','scripts')); ?> + + +#. ``Html->script(array('jquery','wysiwyg','scripts')); ?>`` + +Will output: + +:: + + + + + +scriptBlock +~~~~~~~~~~~ + +scriptBlock($code, $options = array()) + +Generate a code block containing ``$code`` set +``$options['inline']`` to false to have the script block appear in +``$scripts_for_layout``. Also new is the ability to add attributes +to script tags. +``$this->html->scriptBlock('stuff', array('defer' => true));`` will +create a script tag with ``defer="defer"`` attribute. + +scriptStart +~~~~~~~~~~~ + +scriptStart($options = array()) + +Begin a buffering code block. This code block will capture all +output between ``scriptStart()`` and ``scriptEnd()`` and create an +script tag. Options are the same as ``scriptBlock()`` + +scriptEnd +~~~~~~~~~ + +scriptEnd() + +End a buffering script block, returns the generated script element +or null if the script block was opened with inline = false. + +An example of using ``scriptStart()`` and ``scriptEnd()`` would +be: + +:: + + $this->Html->scriptStart(array('inline' => false)); + + echo $this->Js->alert('I am in the javascript'); + + $this->Html->scriptEnd(); + + +#. ``$this->Html->scriptStart(array('inline' => false));`` +#. ``echo $this->Js->alert('I am in the javascript');`` +#. ``$this->Html->scriptEnd();`` + +tableHeaders +~~~~~~~~~~~~ + +``tableHeaders(array $names, array $trOptions = null, array $thOptions = null)`` + +Creates a row of table header cells to be placed inside of
DateTitleActive
DateTitleActive
DateTitleActive
DateTitleActive
-attributes. + +:: + + Html->tableCells(array( + array('Jul 7th, 2007', 'Best Brownies', 'Yes'), + array('Jun 21st, 2007', 'Smart Cookies', 'Yes'), + array('Aug 1st, 2006', 'Anti-Java Cake', 'No'), + )); + ?> + + //Output +
Jul 7th, 2007Best BrowniesYes
Jun 21st, 2007Smart CookiesYes
Aug 1st, 2006Anti-Java CakeNo
Jul 7th, 2007Best BrowniesYes
Jun 21st, 2007Smart CookiesYes
Aug 1st, 2006Anti-Java CakeNo
RedApple
OrangeOrange
YellowBanana
Jul 7th, 2007Best BrowniesYes
Jun 21st, 2007Smart CookiesYes
Aug 1st, 2006Anti-Java CakeNo
Jul 7th, 2007Best BrowniesYes
Jun 21st, 2007Smart CookiesYes
Aug 1st, 2006Anti-Java CakeNo
RedApple
OrangeOrange
YellowBanana
+tags. +:: + + Html->tableHeaders(array('Date','Title','Active'));?> + + //Output + + + + + + + Html->tableHeaders( + array('Date','Title','Active'), + array('class' => 'status'), + array('class' => 'product_table') + );?> + + //Output + + + + + + + +#. ``Html->tableHeaders(array('Date','Title','Active'));?>`` +#. `` `` +#. ``//Output`` +#. ```` +#. ```` +#. ```` +#. ```` +#. ```` +#. ```` +#. ``Html->tableHeaders(`` +#. ``array('Date','Title','Active'),`` +#. ``array('class' => 'status'),`` +#. ``array('class' => 'product_table')`` +#. ``);?>`` +#. ```` +#. ``//Output`` +#. ```` +#. ```` +#. ```` +#. ```` +#. ```` + +tableCells +~~~~~~~~~~ + +``tableCells(array $data, array $oddTrOptions = null, array $evenTrOptions = null, $useCount = false, $continueOddEven = true)`` + +Creates table cells, in rows, assigning attributes differently +for odd- and even-numbered rows. Wrap a single table cell within an +array() for specific + + + + Html->tableCells(array( + array('Jul 7th, 2007', array('Best Brownies', array('class'=>'highlight')) , 'Yes'), + array('Jun 21st, 2007', 'Smart Cookies', 'Yes'), + array('Aug 1st, 2006', 'Anti-Java Cake', array('No', array('id'=>'special'))), + )); + ?> + + //Output + + + + + Html->tableCells( + array( + array('Red', 'Apple'), + array('Orange', 'Orange'), + array('Yellow', 'Banana'), + ), + array('class' => 'darker') + ); + ?> + + //Output + + + + + +#. ``Html->tableCells(array(`` +#. ``array('Jul 7th, 2007', 'Best Brownies', 'Yes'),`` +#. ``array('Jun 21st, 2007', 'Smart Cookies', 'Yes'),`` +#. ``array('Aug 1st, 2006', 'Anti-Java Cake', 'No'),`` +#. ``));`` +#. ``?>`` +#. ```` +#. ``//Output`` +#. ```` +#. ```` +#. ```` +#. ```` +#. ``Html->tableCells(array(`` +#. ``array('Jul 7th, 2007', array('Best Brownies', array('class'=>'highlight')) , 'Yes'),`` +#. ``array('Jun 21st, 2007', 'Smart Cookies', 'Yes'),`` +#. ``array('Aug 1st, 2006', 'Anti-Java Cake', array('No', array('id'=>'special'))),`` +#. ``));`` +#. ``?>`` +#. ```` +#. ``//Output`` +#. ```` +#. ```` +#. ```` +#. ```` +#. ``Html->tableCells(`` +#. ``array(`` +#. ``array('Red', 'Apple'),`` +#. ``array('Orange', 'Orange'),`` +#. ``array('Yellow', 'Banana'),`` +#. ``),`` +#. ``array('class' => 'darker')`` +#. ``);`` +#. ``?>`` +#. ```` +#. ``//Output`` +#. ```` +#. ```` +#. ```` + +url +~~~ + +``url(mixed $url = NULL, boolean $full = false)`` + +Returns an URL pointing to a combination of controller and action. +If $url is empty, it returns the REQUEST\_URI, otherwise it +generates the url for the controller and action combo. If full is +true, the full base URL will be prepended to the result. + +:: + + Html->url(array( + "controller" => "posts", + "action" => "view", + "bar"));?> + + // Output + /posts/view/bar + + +#. ``Html->url(array(`` +#. ``"controller" => "posts",`` +#. ``"action" => "view",`` +#. ``"bar"));?>`` +#. ```` +#. ``// Output`` +#. ``/posts/view/bar`` + +Here are a few more usage examples: + +URL with named parameters + +:: + + Html->url(array( + "controller" => "posts", + "action" => "view", + "foo" => "bar")); + ?> + + // Output + /posts/view/foo:bar + + +#. ``Html->url(array(`` +#. ``"controller" => "posts",`` +#. ``"action" => "view",`` +#. ``"foo" => "bar"));`` +#. ``?>`` +#. ```` +#. ``// Output`` +#. ``/posts/view/foo:bar`` + +URL with extension + +:: + + Html->url(array( + "controller" => "posts", + "action" => "list", + "ext" => "rss")); + ?> + + // Output + /posts/list.rss + + +#. ``Html->url(array(`` +#. ``"controller" => "posts",`` +#. ``"action" => "list",`` +#. ``"ext" => "rss"));`` +#. ``?>`` +#. ```` +#. ``// Output`` +#. ``/posts/list.rss`` + +URL (starting with '/') with the full base URL prepended. + +:: + + Html->url('/posts', true); ?> + + //Output + http://somedomain.com/posts + + +#. ``Html->url('/posts', true); ?>`` +#. `` `` +#. ``//Output`` +#. ``http://somedomain.com/posts`` + +URL with GET params and named anchor + +:: + + Html->url(array( + "controller" => "posts", + "action" => "search", + "?" => array("foo" => "bar"), + "#" => "first")); + ?> + + //Output + /posts/search?foo=bar#first + + +#. ``Html->url(array(`` +#. ``"controller" => "posts",`` +#. ``"action" => "search",`` +#. ``"?" => array("foo" => "bar"),`` +#. ``"#" => "first"));`` +#. ``?>`` +#. `` `` +#. ``//Output`` +#. ``/posts/search?foo=bar#first`` + +For further information check +`Router::url `_ +in the API. diff --git a/source/core-helpers/javascript.rst b/source/core-helpers/javascript.rst new file mode 100644 index 000000000..5374dafd5 --- /dev/null +++ b/source/core-helpers/javascript.rst @@ -0,0 +1,25 @@ +7.6 Javascript +-------------- + +The Javascript helper is used to aid in creating well formatted +related javascript tags and codeblocks. There are several methods +some of which are designed to work with the +`Prototype `_ Javascript library. + +The Javascript Helper is deprecated in 1.3 and will be removed in +future versions of CakePHP. See the new JsHelper and HtmlHelper, as +well as the migration guide for where JavascriptHelper's methods +have moved to. + +7.6 Javascript +-------------- + +The Javascript helper is used to aid in creating well formatted +related javascript tags and codeblocks. There are several methods +some of which are designed to work with the +`Prototype `_ Javascript library. + +The Javascript Helper is deprecated in 1.3 and will be removed in +future versions of CakePHP. See the new JsHelper and HtmlHelper, as +well as the migration guide for where JavascriptHelper's methods +have moved to. diff --git a/source/core-helpers/javascript/methods.rst b/source/core-helpers/javascript/methods.rst new file mode 100644 index 000000000..4c58f8d25 --- /dev/null +++ b/source/core-helpers/javascript/methods.rst @@ -0,0 +1,301 @@ +7.6.1 Methods +------------- + +``codeBlock($script, $options = array('allowCache'=>true,'safe'=>true,'inline'=>true), $safe)`` + + +- string $script - The JavaScript to be wrapped in SCRIPT tags +- array $options - Set of options: + + - allowCache: boolean, designates whether this block is cacheable + using the current cache settings. + - safe: boolean, whether this block should be wrapped in CDATA + tags. Defaults to helper's object configuration. + - inline: whether the block should be printed inline, or written + to cached for later output (i.e. $scripts\_for\_layout). + +- boolean $safe - DEPRECATED. Use $options['safe'] instead + +codeBlock returns a formatted script element containing $script. +But can also return null if Javascript helper is set to cache +events. See JavascriptHelper::cacheEvents(). And can write in +``$scripts_for_layout`` if you set $options['inline'] to false. + +``blockEnd()`` + +Ends a block of cached Javascript. Can return either a end script +tag, or empties the buffer, adding the contents to the cachedEvents +array. Its return value depends on the cache settings. See +JavascriptHelper::cacheEvents() + +``link($url, $inline = true)`` + + +- mixed $url - String URL to JavaScript file, or an array of URLs. +- boolean $inline If true, the
DateTitleActive
DateTitleActive
DateTitleActive
DateTitleActive
-attributes. + +:: + + Html->tableCells(array( + array('Jul 7th, 2007', 'Best Brownies', 'Yes'), + array('Jun 21st, 2007', 'Smart Cookies', 'Yes'), + array('Aug 1st, 2006', 'Anti-Java Cake', 'No'), + )); + ?> + + //Output +
Jul 7th, 2007Best BrowniesYes
Jun 21st, 2007Smart CookiesYes
Aug 1st, 2006Anti-Java CakeNo
Jul 7th, 2007Best BrowniesYes
Jun 21st, 2007Smart CookiesYes
Aug 1st, 2006Anti-Java CakeNo
RedApple
OrangeOrange
YellowBanana
Jul 7th, 2007Best BrowniesYes
Jun 21st, 2007Smart CookiesYes
Aug 1st, 2006Anti-Java CakeNo
Jul 7th, 2007Best BrowniesYes
Jun 21st, 2007Smart CookiesYes
Aug 1st, 2006Anti-Java CakeNo
RedApple
OrangeOrange
YellowBanana