cakephp2-php8/cake/libs/view/helpers/ajax.php
Mark Story 4f67f84ff8 Merge branch '1.2' into 1.3-merger
Conflicts:
	app/config/acl.ini.php
	app/config/bootstrap.php
	app/config/core.php
	app/config/database.php.default
	app/config/inflections.php
	app/config/routes.php
	app/config/schema/db_acl.php
	app/config/schema/i18n.php
	app/config/schema/sessions.php
	app/config/sql/db_acl.sql
	app/config/sql/i18n.sql
	app/index.php
	app/webroot/css.php
	app/webroot/css/cake.generic.css
	app/webroot/index.php
	app/webroot/js/vendors.php
	app/webroot/test.php
	cake/LICENSE.txt
	cake/basics.php
	cake/bootstrap.php
	cake/config/config.php
	cake/config/paths.php
	cake/config/unicode/casefolding/0080_00ff.php
	cake/config/unicode/casefolding/0100_017f.php
	cake/config/unicode/casefolding/0180_024F.php
	cake/config/unicode/casefolding/0250_02af.php
	cake/config/unicode/casefolding/0370_03ff.php
	cake/config/unicode/casefolding/0400_04ff.php
	cake/config/unicode/casefolding/0500_052f.php
	cake/config/unicode/casefolding/0530_058f.php
	cake/config/unicode/casefolding/1e00_1eff.php
	cake/config/unicode/casefolding/1f00_1fff.php
	cake/config/unicode/casefolding/2100_214f.php
	cake/config/unicode/casefolding/2150_218f.php
	cake/config/unicode/casefolding/2460_24ff.php
	cake/config/unicode/casefolding/2c00_2c5f.php
	cake/config/unicode/casefolding/2c60_2c7f.php
	cake/config/unicode/casefolding/2c80_2cff.php
	cake/config/unicode/casefolding/ff00_ffef.php
	cake/console/cake
	cake/console/cake.bat
	cake/console/cake.php
	cake/console/error.php
	cake/console/libs/acl.php
	cake/console/libs/api.php
	cake/console/libs/bake.php
	cake/console/libs/console.php
	cake/console/libs/i18n.php
	cake/console/libs/schema.php
	cake/console/libs/shell.php
	cake/console/libs/tasks/controller.php
	cake/console/libs/tasks/db_config.php
	cake/console/libs/tasks/extract.php
	cake/console/libs/tasks/model.php
	cake/console/libs/tasks/plugin.php
	cake/console/libs/tasks/project.php
	cake/console/libs/tasks/test.php
	cake/console/libs/tasks/view.php
	cake/console/libs/templates/skel/config/bootstrap.php
	cake/console/libs/templates/skel/config/inflections.php
	cake/console/libs/templates/skel/config/sql/sessions.sql
	cake/console/libs/templates/skel/index.php
	cake/console/libs/templates/skel/views/elements/email/html/default.ctp
	cake/console/libs/templates/skel/views/elements/email/text/default.ctp
	cake/console/libs/templates/skel/views/layouts/ajax.ctp
	cake/console/libs/templates/skel/views/layouts/default.ctp
	cake/console/libs/templates/skel/views/layouts/email/html/default.ctp
	cake/console/libs/templates/skel/views/layouts/email/text/default.ctp
	cake/console/libs/templates/skel/webroot/js/vendors.php
	cake/console/libs/templates/skel/webroot/test.php
	cake/console/libs/templates/views/form.ctp
	cake/console/libs/templates/views/index.ctp
	cake/console/libs/testsuite.php
	cake/console/templates/default/views/view.ctp
	cake/console/templates/skel/app_controller.php
	cake/console/templates/skel/app_helper.php
	cake/console/templates/skel/app_model.php
	cake/console/templates/skel/config/acl.ini.php
	cake/console/templates/skel/config/core.php
	cake/console/templates/skel/config/database.php.default
	cake/console/templates/skel/config/routes.php
	cake/console/templates/skel/config/schema/db_acl.php
	cake/console/templates/skel/config/schema/db_acl.sql
	cake/console/templates/skel/config/schema/i18n.php
	cake/console/templates/skel/config/schema/i18n.sql
	cake/console/templates/skel/config/schema/sessions.php
	cake/console/templates/skel/config/schema/sessions.sql
	cake/console/templates/skel/controllers/pages_controller.php
	cake/console/templates/skel/views/layouts/flash.ctp
	cake/console/templates/skel/webroot/css.php
	cake/console/templates/skel/webroot/css/cake.generic.css
	cake/console/templates/skel/webroot/index.php
	cake/dispatcher.php
	cake/libs/cache.php
	cake/libs/cache/apc.php
	cake/libs/cache/file.php
	cake/libs/cache/memcache.php
	cake/libs/cache/xcache.php
	cake/libs/cake_log.php
	cake/libs/cake_session.php
	cake/libs/cake_socket.php
	cake/libs/class_registry.php
	cake/libs/configure.php
	cake/libs/controller/app_controller.php
	cake/libs/controller/component.php
	cake/libs/controller/components/acl.php
	cake/libs/controller/components/auth.php
	cake/libs/controller/components/cookie.php
	cake/libs/controller/components/email.php
	cake/libs/controller/components/request_handler.php
	cake/libs/controller/components/security.php
	cake/libs/controller/components/session.php
	cake/libs/controller/controller.php
	cake/libs/controller/pages_controller.php
	cake/libs/controller/scaffold.php
	cake/libs/debugger.php
	cake/libs/error.php
	cake/libs/file.php
	cake/libs/flay.php
	cake/libs/folder.php
	cake/libs/http_socket.php
	cake/libs/i18n.php
	cake/libs/inflector.php
	cake/libs/l10n.php
	cake/libs/magic_db.php
	cake/libs/model/app_model.php
	cake/libs/model/behaviors/acl.php
	cake/libs/model/behaviors/containable.php
	cake/libs/model/behaviors/translate.php
	cake/libs/model/behaviors/tree.php
	cake/libs/model/cake_schema.php
	cake/libs/model/connection_manager.php
	cake/libs/model/datasources/datasource.php
	cake/libs/model/datasources/dbo/dbo_adodb.php
	cake/libs/model/datasources/dbo/dbo_db2.php
	cake/libs/model/datasources/dbo/dbo_firebird.php
	cake/libs/model/datasources/dbo/dbo_mssql.php
	cake/libs/model/datasources/dbo/dbo_mysql.php
	cake/libs/model/datasources/dbo/dbo_mysqli.php
	cake/libs/model/datasources/dbo/dbo_odbc.php
	cake/libs/model/datasources/dbo/dbo_oracle.php
	cake/libs/model/datasources/dbo/dbo_postgres.php
	cake/libs/model/datasources/dbo/dbo_sqlite.php
	cake/libs/model/datasources/dbo/dbo_sybase.php
	cake/libs/model/datasources/dbo_source.php
	cake/libs/model/db_acl.php
	cake/libs/model/model.php
	cake/libs/model/model_behavior.php
	cake/libs/multibyte.php
	cake/libs/object.php
	cake/libs/overloadable.php
	cake/libs/overloadable_php4.php
	cake/libs/overloadable_php5.php
	cake/libs/router.php
	cake/libs/sanitize.php
	cake/libs/security.php
	cake/libs/set.php
	cake/libs/string.php
	cake/libs/validation.php
	cake/libs/view/elements/dump.ctp
	cake/libs/view/elements/email/html/default.ctp
	cake/libs/view/elements/email/text/default.ctp
	cake/libs/view/errors/error404.ctp
	cake/libs/view/errors/missing_action.ctp
	cake/libs/view/errors/missing_component_class.ctp
	cake/libs/view/errors/missing_component_file.ctp
	cake/libs/view/errors/missing_connection.ctp
	cake/libs/view/errors/missing_controller.ctp
	cake/libs/view/errors/missing_helper_class.ctp
	cake/libs/view/errors/missing_helper_file.ctp
	cake/libs/view/errors/missing_layout.ctp
	cake/libs/view/errors/missing_model.ctp
	cake/libs/view/errors/missing_scaffolddb.ctp
	cake/libs/view/errors/missing_table.ctp
	cake/libs/view/errors/missing_view.ctp
	cake/libs/view/errors/private_action.ctp
	cake/libs/view/errors/scaffold_error.ctp
	cake/libs/view/helper.php
	cake/libs/view/helpers/ajax.php
	cake/libs/view/helpers/app_helper.php
	cake/libs/view/helpers/cache.php
	cake/libs/view/helpers/form.php
	cake/libs/view/helpers/html.php
	cake/libs/view/helpers/javascript.php
	cake/libs/view/helpers/js.php
	cake/libs/view/helpers/number.php
	cake/libs/view/helpers/paginator.php
	cake/libs/view/helpers/rss.php
	cake/libs/view/helpers/session.php
	cake/libs/view/helpers/text.php
	cake/libs/view/helpers/time.php
	cake/libs/view/helpers/xml.php
	cake/libs/view/layouts/ajax.ctp
	cake/libs/view/layouts/default.ctp
	cake/libs/view/layouts/email/html/default.ctp
	cake/libs/view/layouts/email/text/default.ctp
	cake/libs/view/layouts/flash.ctp
	cake/libs/view/media.php
	cake/libs/view/pages/home.ctp
	cake/libs/view/scaffolds/edit.ctp
	cake/libs/view/scaffolds/index.ctp
	cake/libs/view/scaffolds/view.ctp
	cake/libs/view/theme.php
	cake/libs/view/view.php
	cake/libs/xml.php
	cake/tests/cases/basics.test.php
	cake/tests/cases/console/cake.test.php
	cake/tests/cases/console/libs/acl.test.php
	cake/tests/cases/console/libs/api.test.php
	cake/tests/cases/console/libs/schema.test.php
	cake/tests/cases/console/libs/shell.test.php
	cake/tests/cases/console/libs/tasks/extract.test.php
	cake/tests/cases/console/libs/tasks/model.test.php
	cake/tests/cases/console/libs/tasks/test.test.php
	cake/tests/cases/dispatcher.test.php
	cake/tests/cases/libs/cache.test.php
	cake/tests/cases/libs/cache/apc.test.php
	cake/tests/cases/libs/cache/file.test.php
	cake/tests/cases/libs/cache/memcache.test.php
	cake/tests/cases/libs/cache/xcache.test.php
	cake/tests/cases/libs/cake_log.test.php
	cake/tests/cases/libs/cake_session.test.php
	cake/tests/cases/libs/cake_socket.test.php
	cake/tests/cases/libs/cake_test_case.test.php
	cake/tests/cases/libs/cake_test_fixture.test.php
	cake/tests/cases/libs/class_registry.test.php
	cake/tests/cases/libs/code_coverage_manager.test.php
	cake/tests/cases/libs/configure.test.php
	cake/tests/cases/libs/controller/component.test.php
	cake/tests/cases/libs/controller/components/acl.test.php
	cake/tests/cases/libs/controller/components/auth.test.php
	cake/tests/cases/libs/controller/components/cookie.test.php
	cake/tests/cases/libs/controller/components/email.test.php
	cake/tests/cases/libs/controller/components/request_handler.test.php
	cake/tests/cases/libs/controller/components/security.test.php
	cake/tests/cases/libs/controller/components/session.test.php
	cake/tests/cases/libs/controller/controller.test.php
	cake/tests/cases/libs/controller/controller_merge_vars.test.php
	cake/tests/cases/libs/controller/pages_controller.test.php
	cake/tests/cases/libs/controller/scaffold.test.php
	cake/tests/cases/libs/debugger.test.php
	cake/tests/cases/libs/error.test.php
	cake/tests/cases/libs/file.test.php
	cake/tests/cases/libs/flay.test.php
	cake/tests/cases/libs/folder.test.php
	cake/tests/cases/libs/http_socket.test.php
	cake/tests/cases/libs/i18n.test.php
	cake/tests/cases/libs/inflector.test.php
	cake/tests/cases/libs/l10n.test.php
	cake/tests/cases/libs/magic_db.test.php
	cake/tests/cases/libs/model/behaviors/acl.test.php
	cake/tests/cases/libs/model/behaviors/containable.test.php
	cake/tests/cases/libs/model/behaviors/translate.test.php
	cake/tests/cases/libs/model/behaviors/tree.test.php
	cake/tests/cases/libs/model/cake_schema.test.php
	cake/tests/cases/libs/model/connection_manager.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_adodb.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
	cake/tests/cases/libs/model/datasources/dbo_source.test.php
	cake/tests/cases/libs/model/db_acl.test.php
	cake/tests/cases/libs/model/model.test.php
	cake/tests/cases/libs/model/model_behavior.test.php
	cake/tests/cases/libs/model/model_delete.test.php
	cake/tests/cases/libs/model/model_integration.test.php
	cake/tests/cases/libs/model/model_read.test.php
	cake/tests/cases/libs/model/model_validation.test.php
	cake/tests/cases/libs/model/model_write.test.php
	cake/tests/cases/libs/model/models.php
	cake/tests/cases/libs/multibyte.test.php
	cake/tests/cases/libs/object.test.php
	cake/tests/cases/libs/overloadable.test.php
	cake/tests/cases/libs/router.test.php
	cake/tests/cases/libs/sanitize.test.php
	cake/tests/cases/libs/security.test.php
	cake/tests/cases/libs/set.test.php
	cake/tests/cases/libs/string.test.php
	cake/tests/cases/libs/test_manager.test.php
	cake/tests/cases/libs/validation.test.php
	cake/tests/cases/libs/view/helper.test.php
	cake/tests/cases/libs/view/helpers/ajax.test.php
	cake/tests/cases/libs/view/helpers/cache.test.php
	cake/tests/cases/libs/view/helpers/form.test.php
	cake/tests/cases/libs/view/helpers/html.test.php
	cake/tests/cases/libs/view/helpers/javascript.test.php
	cake/tests/cases/libs/view/helpers/js.test.php
	cake/tests/cases/libs/view/helpers/number.test.php
	cake/tests/cases/libs/view/helpers/paginator.test.php
	cake/tests/cases/libs/view/helpers/rss.test.php
	cake/tests/cases/libs/view/helpers/session.test.php
	cake/tests/cases/libs/view/helpers/text.test.php
	cake/tests/cases/libs/view/helpers/time.test.php
	cake/tests/cases/libs/view/helpers/xml.test.php
	cake/tests/cases/libs/view/theme.test.php
	cake/tests/cases/libs/view/view.test.php
	cake/tests/cases/libs/xml.test.php
	cake/tests/fixtures/account_fixture.php
	cake/tests/fixtures/aco_action_fixture.php
	cake/tests/fixtures/aco_fixture.php
	cake/tests/fixtures/aco_two_fixture.php
	cake/tests/fixtures/advertisement_fixture.php
	cake/tests/fixtures/another_article_fixture.php
	cake/tests/fixtures/apple_fixture.php
	cake/tests/fixtures/aro_fixture.php
	cake/tests/fixtures/aro_two_fixture.php
	cake/tests/fixtures/aros_aco_fixture.php
	cake/tests/fixtures/aros_aco_two_fixture.php
	cake/tests/fixtures/article_featured_fixture.php
	cake/tests/fixtures/article_featureds_tags_fixture.php
	cake/tests/fixtures/article_fixture.php
	cake/tests/fixtures/articles_tag_fixture.php
	cake/tests/fixtures/attachment_fixture.php
	cake/tests/fixtures/auth_user_custom_field_fixture.php
	cake/tests/fixtures/auth_user_fixture.php
	cake/tests/fixtures/author_fixture.php
	cake/tests/fixtures/basket_fixture.php
	cake/tests/fixtures/bid_fixture.php
	cake/tests/fixtures/binary_test_fixture.php
	cake/tests/fixtures/book_fixture.php
	cake/tests/fixtures/cache_test_model_fixture.php
	cake/tests/fixtures/callback_fixture.php
	cake/tests/fixtures/category_fixture.php
	cake/tests/fixtures/category_thread_fixture.php
	cake/tests/fixtures/cd_fixture.php
	cake/tests/fixtures/comment_fixture.php
	cake/tests/fixtures/content_account_fixture.php
	cake/tests/fixtures/content_fixture.php
	cake/tests/fixtures/counter_cache_post_fixture.php
	cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php
	cake/tests/fixtures/counter_cache_user_fixture.php
	cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php
	cake/tests/fixtures/data_test_fixture.php
	cake/tests/fixtures/datatype_fixture.php
	cake/tests/fixtures/dependency_fixture.php
	cake/tests/fixtures/device_fixture.php
	cake/tests/fixtures/device_type_category_fixture.php
	cake/tests/fixtures/device_type_fixture.php
	cake/tests/fixtures/document_directory_fixture.php
	cake/tests/fixtures/document_fixture.php
	cake/tests/fixtures/exterior_type_category_fixture.php
	cake/tests/fixtures/feature_set_fixture.php
	cake/tests/fixtures/featured_fixture.php
	cake/tests/fixtures/film_file_fixture.php
	cake/tests/fixtures/flag_tree_fixture.php
	cake/tests/fixtures/fruit_fixture.php
	cake/tests/fixtures/fruits_uuid_tag_fixture.php
	cake/tests/fixtures/home_fixture.php
	cake/tests/fixtures/image_fixture.php
	cake/tests/fixtures/item_fixture.php
	cake/tests/fixtures/items_portfolio_fixture.php
	cake/tests/fixtures/join_a_b_fixture.php
	cake/tests/fixtures/join_a_c_fixture.php
	cake/tests/fixtures/join_a_fixture.php
	cake/tests/fixtures/join_b_fixture.php
	cake/tests/fixtures/join_c_fixture.php
	cake/tests/fixtures/join_thing_fixture.php
	cake/tests/fixtures/message_fixture.php
	cake/tests/fixtures/my_categories_my_products_fixture.php
	cake/tests/fixtures/my_categories_my_users_fixture.php
	cake/tests/fixtures/my_category_fixture.php
	cake/tests/fixtures/my_product_fixture.php
	cake/tests/fixtures/my_user_fixture.php
	cake/tests/fixtures/node_fixture.php
	cake/tests/fixtures/number_tree_fixture.php
	cake/tests/fixtures/number_tree_two_fixture.php
	cake/tests/fixtures/numeric_article_fixture.php
	cake/tests/fixtures/overall_favorite_fixture.php
	cake/tests/fixtures/person_fixture.php
	cake/tests/fixtures/portfolio_fixture.php
	cake/tests/fixtures/post_fixture.php
	cake/tests/fixtures/posts_tag_fixture.php
	cake/tests/fixtures/primary_model_fixture.php
	cake/tests/fixtures/product_fixture.php
	cake/tests/fixtures/project_fixture.php
	cake/tests/fixtures/sample_fixture.php
	cake/tests/fixtures/secondary_model_fixture.php
	cake/tests/fixtures/session_fixture.php
	cake/tests/fixtures/something_else_fixture.php
	cake/tests/fixtures/something_fixture.php
	cake/tests/fixtures/stories_tag_fixture.php
	cake/tests/fixtures/story_fixture.php
	cake/tests/fixtures/syfile_fixture.php
	cake/tests/fixtures/tag_fixture.php
	cake/tests/fixtures/test_plugin_article_fixture.php
	cake/tests/fixtures/test_plugin_comment_fixture.php
	cake/tests/fixtures/the_paper_monkies_fixture.php
	cake/tests/fixtures/thread_fixture.php
	cake/tests/fixtures/translate_article_fixture.php
	cake/tests/fixtures/translate_fixture.php
	cake/tests/fixtures/translate_table_fixture.php
	cake/tests/fixtures/translated_article_fixture.php
	cake/tests/fixtures/translated_item_fixture.php
	cake/tests/fixtures/unconventional_tree_fixture.php
	cake/tests/fixtures/underscore_field_fixture.php
	cake/tests/fixtures/user_fixture.php
	cake/tests/fixtures/uuid_fixture.php
	cake/tests/fixtures/uuid_tag_fixture.php
	cake/tests/fixtures/uuid_tree_fixture.php
	cake/tests/fixtures/uuiditem_fixture.php
	cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php
	cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php
	cake/tests/fixtures/uuidportfolio_fixture.php
	cake/tests/groups/acl.group.php
	cake/tests/groups/cache.group.php
	cake/tests/groups/components.group.php
	cake/tests/groups/configure.group.php
	cake/tests/groups/console.group.php
	cake/tests/groups/controller.group.php
	cake/tests/groups/database.group.php
	cake/tests/groups/helpers.group.php
	cake/tests/groups/lib.group.php
	cake/tests/groups/model.group.php
	cake/tests/groups/no_cross_contamination.group.php
	cake/tests/groups/routing_system.group.php
	cake/tests/groups/socket.group.php
	cake/tests/groups/test_suite.group.php
	cake/tests/groups/view.group.php
	cake/tests/groups/xml.group.php
	cake/tests/lib/cake_reporter.php
	cake/tests/lib/cake_test_case.php
	cake/tests/lib/cake_test_fixture.php
	cake/tests/lib/cake_test_model.php
	cake/tests/lib/cake_web_test_case.php
	cake/tests/lib/cli_reporter.php
	cake/tests/lib/code_coverage_manager.php
	cake/tests/lib/templates/footer.php
	cake/tests/lib/templates/header.php
	cake/tests/lib/templates/menu.php
	cake/tests/lib/templates/simpletest.php
	cake/tests/lib/test_manager.php
	cake/tests/lib/xdebug.php
	cake/tests/test_app/config/acl.ini.php
	cake/tests/test_app/controllers/tests_apps_controller.php
	cake/tests/test_app/controllers/tests_apps_posts_controller.php
	cake/tests/test_app/models/behaviors/persister_one_behavior.php
	cake/tests/test_app/models/behaviors/persister_two_behavior.php
	cake/tests/test_app/models/comment.php
	cake/tests/test_app/models/persister_one.php
	cake/tests/test_app/models/persister_two.php
	cake/tests/test_app/models/post.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php
	cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php
	cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php
	cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php
	cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php
	cake/tests/test_app/plugins/test_plugin/vendors/shells/example.php
	cake/tests/test_app/plugins/test_plugin/vendors/welcome.php
	cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php
	cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php
	cake/tests/test_app/plugins/test_plugin_two/vendors/shells/example.php
	cake/tests/test_app/plugins/test_plugin_two/vendors/shells/welcome.php
	cake/tests/test_app/vendors/Test/MyTest.php
	cake/tests/test_app/vendors/Test/hello.php
	cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php
	cake/tests/test_app/vendors/shells/sample.php
	cake/tests/test_app/vendors/somename/some.name.php
	cake/tests/test_app/vendors/welcome.php
	cake/tests/test_app/views/elements/email/html/default.ctp
	cake/tests/test_app/views/elements/email/text/default.ctp
	cake/tests/test_app/views/elements/email/text/wide.ctp
	cake/tests/test_app/views/layouts/ajax.ctp
	cake/tests/test_app/views/layouts/ajax2.ctp
	cake/tests/test_app/views/layouts/cache_layout.ctp
	cake/tests/test_app/views/layouts/default.ctp
	cake/tests/test_app/views/layouts/email/html/default.ctp
	cake/tests/test_app/views/layouts/email/html/thin.ctp
	cake/tests/test_app/views/layouts/email/text/default.ctp
	cake/tests/test_app/views/layouts/flash.ctp
	cake/tests/test_app/views/layouts/multi_cache.ctp
	cake/tests/test_app/views/posts/sequencial_nocache.ctp
	cake/tests/test_app/views/posts/test_nocache_tags.ctp
	index.php
2010-01-26 17:54:34 -05:00

1014 lines
No EOL
31 KiB
PHP

<?php
/**
* Helper for AJAX operations.
*
* Helps doing AJAX using the Prototype library.
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs.view.helpers
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* AjaxHelper helper library.
*
* Helps doing AJAX using the Prototype library.
*
* @package cake
* @subpackage cake.cake.libs.view.helpers
*/
class AjaxHelper extends AppHelper {
/**
* Included helpers.
*
* @var array
*/
var $helpers = array('Html', 'Javascript', 'Form');
/**
* HtmlHelper instance
*
* @var HtmlHelper
* @access public
*/
var $Html = null;
/**
* JavaScriptHelper instance
*
* @var JavaScriptHelper
* @access public
*/
var $Javascript = null;
/**
* Names of Javascript callback functions.
*
* @var array
*/
var $callbacks = array(
'complete', 'create', 'exception', 'failure', 'interactive', 'loading',
'loaded', 'success', 'uninitialized'
);
/**
* Names of AJAX options.
*
* @var array
*/
var $ajaxOptions = array(
'after', 'asynchronous', 'before', 'confirm', 'condition', 'contentType', 'encoding',
'evalScripts', 'failure', 'fallback', 'form', 'indicator', 'insertion', 'interactive',
'loaded', 'loading', 'method', 'onCreate', 'onComplete', 'onException', 'onFailure',
'onInteractive', 'onLoaded', 'onLoading', 'onSuccess', 'onUninitialized', 'parameters',
'position', 'postBody', 'requestHeaders', 'success', 'type', 'update', 'with'
);
/**
* Options for draggable.
*
* @var array
*/
var $dragOptions = array(
'handle', 'revert', 'snap', 'zindex', 'constraint', 'change', 'ghosting',
'starteffect', 'reverteffect', 'endeffect', 'scroll', 'scrollSensitivity',
'onStart', 'onDrag', 'onEnd'
);
/**
* Options for droppable.
*
* @var array
*/
var $dropOptions = array(
'accept', 'containment', 'greedy', 'hoverclass', 'onHover', 'onDrop', 'overlap'
);
/**
* Options for sortable.
*
* @var array
*/
var $sortOptions = array(
'constraint', 'containment', 'dropOnEmpty', 'ghosting', 'handle', 'hoverclass', 'onUpdate',
'onChange', 'only', 'overlap', 'scroll', 'scrollSensitivity', 'scrollSpeed', 'tag', 'tree',
'treeTag', 'update'
);
/**
* Options for slider.
*
* @var array
*/
var $sliderOptions = array(
'alignX', 'alignY', 'axis', 'disabled', 'handleDisabled', 'handleImage', 'increment',
'maximum', 'minimum', 'onChange', 'onSlide', 'range', 'sliderValue', 'values'
);
/**
* Options for in-place editor.
*
* @var array
*/
var $editorOptions = array(
'okText', 'cancelText', 'savingText', 'formId', 'externalControl', 'rows', 'cols', 'size',
'highlightcolor', 'highlightendcolor', 'savingClassName', 'formClassName', 'loadTextURL',
'loadingText', 'callback', 'ajaxOptions', 'clickToEditText', 'collection', 'okControl',
'cancelControl', 'submitOnBlur'
);
/**
* Options for auto-complete editor.
*
* @var array
*/
var $autoCompleteOptions = array(
'afterUpdateElement', 'callback', 'frequency', 'indicator', 'minChars', 'onShow', 'onHide',
'parameters', 'paramName', 'tokens', 'updateElement'
);
/**
* Output buffer for Ajax update content
*
* @var array
*/
var $__ajaxBuffer = array();
/**
* Returns link to remote action
*
* Returns a link to a remote action defined by <i>options[url]</i>
* (using the url() format) that's called in the background using
* XMLHttpRequest. The result of that request can then be inserted into a
* DOM object whose id can be specified with <i>options[update]</i>.
*
* Examples:
* <code>
* link("Delete this post",
* array("update" => "posts", "url" => "delete/{$postid->id}"));
* link(imageTag("refresh"),
* array("update" => "emails", "url" => "list_emails" ));
* </code>
*
* By default, these remote requests are processed asynchronous during
* which various callbacks can be triggered (for progress indicators and
* the likes).
*
* Example:
* <code>
* link (word,
* array("url" => "undo", "n" => word_counter),
* array("complete" => "undoRequestCompleted(request)"));
* </code>
*
* The callbacks that may be specified are:
*
* - <i>loading</i>:: Called when the remote document is being
* loaded with data by the browser.
* - <i>loaded</i>:: Called when the browser has finished loading
* the remote document.
* - <i>interactive</i>:: Called when the user can interact with the
* remote document, even though it has not
* finished loading.
* - <i>complete</i>:: Called when the XMLHttpRequest is complete.
*
* If you for some reason or another need synchronous processing (that'll
* block the browser while the request is happening), you can specify
* <i>options[type] = synchronous</i>.
*
* You can customize further browser side call logic by passing
* in Javascript code snippets via some optional parameters. In
* their order of use these are:
*
* - <i>confirm</i>:: Adds confirmation dialog.
* -<i>condition</i>:: Perform remote request conditionally
* by this expression. Use this to
* describe browser-side conditions when
* request should not be initiated.
* - <i>before</i>:: Called before request is initiated.
* - <i>after</i>:: Called immediately after request was
* initiated and before <i>loading</i>.
*
* @param string $title Title of link
* @param mixed $url Cake-relative URL or array of URL parameters, or external URL (starts with http://)
* @param array $options Options for JavaScript function
* @param string $confirm Confirmation message. Calls up a JavaScript confirm() message.
*
* @return string HTML code for link to remote action
*/
function link($title, $url = null, $options = array(), $confirm = null) {
if (!isset($url)) {
$url = $title;
}
if (!isset($options['url'])) {
$options['url'] = $url;
}
if (isset($confirm)) {
$options['confirm'] = $confirm;
unset($confirm);
}
$htmlOptions = $this->__getHtmlOptions($options, array('url'));
unset($options['escape']);
if (empty($options['fallback']) || !isset($options['fallback'])) {
$options['fallback'] = $url;
}
$htmlDefaults = array('id' => 'link' . intval(mt_rand()), 'onclick' => '');
$htmlOptions = array_merge($htmlDefaults, $htmlOptions);
$htmlOptions['onclick'] .= ' event.returnValue = false; return false;';
$return = $this->Html->link($title, $url, $htmlOptions);
$callback = $this->remoteFunction($options);
$script = $this->Javascript->event("'{$htmlOptions['id']}'", "click", $callback);
if (is_string($script)) {
$return .= $script;
}
return $return;
}
/**
* Creates JavaScript function for remote AJAX call
*
* This function creates the javascript needed to make a remote call
* it is primarily used as a helper for AjaxHelper::link.
*
* @param array $options options for javascript
* @return string html code for link to remote action
* @see AjaxHelper::link() for docs on options parameter.
*/
function remoteFunction($options) {
if (isset($options['update'])) {
if (!is_array($options['update'])) {
$func = "new Ajax.Updater('{$options['update']}',";
} else {
$func = "new Ajax.Updater(document.createElement('div'),";
}
if (!isset($options['requestHeaders'])) {
$options['requestHeaders'] = array();
}
if (is_array($options['update'])) {
$options['update'] = implode(' ', $options['update']);
}
$options['requestHeaders']['X-Update'] = $options['update'];
} else {
$func = "new Ajax.Request(";
}
$func .= "'" . $this->url(isset($options['url']) ? $options['url'] : "") . "'";
$func .= ", " . $this->__optionsForAjax($options) . ")";
if (isset($options['before'])) {
$func = "{$options['before']}; $func";
}
if (isset($options['after'])) {
$func = "$func; {$options['after']};";
}
if (isset($options['condition'])) {
$func = "if ({$options['condition']}) { $func; }";
}
if (isset($options['confirm'])) {
$func = "if (confirm('" . $this->Javascript->escapeString($options['confirm'])
. "')) { $func; } else { event.returnValue = false; return false; }";
}
return $func;
}
/**
* Periodically call remote url via AJAX.
*
* Periodically calls the specified url (<i>options[url]</i>) every <i>options[frequency]</i>
* seconds (default is 10). Usually used to update a specified div (<i>options[update]</i>) with
* the results of the remote call. The options for specifying the target with url and defining
* callbacks is the same as AjaxHelper::link().
*
* @param array $options Callback options
* @return string Javascript code
* @see AjaxHelper::link()
*/
function remoteTimer($options = null) {
$frequency = (isset($options['frequency'])) ? $options['frequency'] : 10;
$callback = $this->remoteFunction($options);
$code = "new PeriodicalExecuter(function() {{$callback}}, $frequency)";
return $this->Javascript->codeBlock($code);
}
/**
* Returns form tag that will submit using Ajax.
*
* Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular
* reloading POST arrangement. Even though it's using Javascript to serialize the form elements,
* the form submission will work just like a regular submission as viewed by the receiving side
* (all elements available in params). The options for defining callbacks is the same
* as AjaxHelper::link().
*
* @param mixed $params Either a string identifying the form target, or an array of method parameters, including:
* - 'params' => Acts as the form target
* - 'type' => 'post' or 'get'
* - 'options' => An array containing all HTML and script options used to
* generate the form tag and Ajax request.
* @param array $type How form data is posted: 'get' or 'post'
* @param array $options Callback/HTML options
* @return string JavaScript/HTML code
* @see AjaxHelper::link()
*/
function form($params = null, $type = 'post', $options = array()) {
$model = false;
if (is_array($params)) {
extract($params, EXTR_OVERWRITE);
}
if (empty($options['url'])) {
$options['url'] = array('action' => $params);
}
$htmlDefaults = array(
'id' => 'form' . intval(mt_rand()),
'onsubmit' => "event.returnValue = false; return false;",
'type' => $type
);
$htmlOptions = $this->__getHtmlOptions($options, array('model', 'with'));
$htmlOptions = array_merge($htmlDefaults, $htmlOptions);
$defaults = array('model' => $model, 'with' => "Form.serialize('{$htmlOptions['id']}')");
$options = array_merge($defaults, $options);
$callback = $this->remoteFunction($options);
$form = $this->Form->create($options['model'], $htmlOptions);
$script = $this->Javascript->event("'" . $htmlOptions['id']. "'", 'submit', $callback);
return $form . $script;
}
/**
* Returns a button input tag that will submit using Ajax
*
* Returns a button input tag that will submit form using XMLHttpRequest in the background instead
* of regular reloading POST arrangement. <i>options</i> argument is the same as
* in AjaxHelper::form().
*
* @param string $title Input button title
* @param array $options Callback options
* @return string Ajaxed input button
* @see AjaxHelper::form()
*/
function submit($title = 'Submit', $options = array()) {
$htmlOptions = $this->__getHtmlOptions($options);
$htmlOptions['value'] = $title;
if (!isset($options['with'])) {
$options['with'] = 'Form.serialize(Event.element(event).form)';
}
if (!isset($htmlOptions['id'])) {
$htmlOptions['id'] = 'submit' . intval(mt_rand());
}
$htmlOptions['onclick'] = "event.returnValue = false; return false;";
$callback = $this->remoteFunction($options);
$form = $this->Form->submit($title, $htmlOptions);
$script = $this->Javascript->event('"' . $htmlOptions['id'] . '"', 'click', $callback);
return $form . $script;
}
/**
* Observe field and call ajax on change.
*
* Observes the field with the DOM ID specified by <i>field</i> and makes
* an Ajax when its contents have changed.
*
* Required +options+ are:
* - <i>frequency</i>:: The frequency (in seconds) at which changes to
* this field will be detected.
* - <i>url</i>:: @see url() -style options for the action to call
* when the field has changed.
*
* Additional options are:
* - <i>update</i>:: Specifies the DOM ID of the element whose
* innerHTML should be updated with the
* XMLHttpRequest response text.
* - <i>with</i>:: A Javascript expression specifying the
* parameters for the XMLHttpRequest. This defaults
* to Form.Element.serialize('$field'), which can be
* accessed from params['form']['field_id'].
*
* Additionally, you may specify any of the options documented in
* @see linkToRemote().
*
* @param string $field DOM ID of field to observe
* @param array $options ajax options
* @return string ajax script
*/
function observeField($field, $options = array()) {
if (!isset($options['with'])) {
$options['with'] = 'Form.Element.serialize(\'' . $field . '\')';
}
$observer = 'Observer';
if (!isset($options['frequency']) || intval($options['frequency']) == 0) {
$observer = 'EventObserver';
}
return $this->Javascript->codeBlock(
$this->_buildObserver('Form.Element.' . $observer, $field, $options)
);
}
/**
* Observe entire form and call ajax on change.
*
* Like @see observeField(), but operates on an entire form identified by the
* DOM ID <b>form</b>. <b>options</b> are the same as <b>observeField</b>, except
* the default value of the <i>with</i> option evaluates to the
* serialized (request string) value of the form.
*
* @param string $form DOM ID of form to observe
* @param array $options ajax options
* @return string ajax script
*/
function observeForm($form, $options = array()) {
if (!isset($options['with'])) {
$options['with'] = 'Form.serialize(\'' . $form . '\')';
}
$observer = 'Observer';
if (!isset($options['frequency']) || intval($options['frequency']) == 0) {
$observer = 'EventObserver';
}
return $this->Javascript->codeBlock(
$this->_buildObserver('Form.' . $observer, $form, $options)
);
}
/**
* Create a text field with Autocomplete.
*
* Creates an autocomplete field with the given ID and options.
*
* options['with'] defaults to "Form.Element.serialize('$field')",
* but can be any valid javascript expression defining the additional fields.
*
* @param string $field DOM ID of field to observe
* @param string $url URL for the autocomplete action
* @param array $options Ajax options
* @return string Ajax script
*/
function autoComplete($field, $url = "", $options = array()) {
$var = '';
if (isset($options['var'])) {
$var = 'var ' . $options['var'] . ' = ';
unset($options['var']);
}
if (!isset($options['id'])) {
$options['id'] = Inflector::camelize(str_replace(".", "_", $field));
}
$divOptions = array(
'id' => $options['id'] . "_autoComplete",
'class' => isset($options['class']) ? $options['class'] : 'auto_complete'
);
if (isset($options['div_id'])) {
$divOptions['id'] = $options['div_id'];
unset($options['div_id']);
}
$htmlOptions = $this->__getHtmlOptions($options);
$htmlOptions['autocomplete'] = "off";
foreach ($this->autoCompleteOptions as $opt) {
unset($htmlOptions[$opt]);
}
if (isset($options['tokens'])) {
if (is_array($options['tokens'])) {
$options['tokens'] = $this->Javascript->object($options['tokens']);
} else {
$options['tokens'] = '"' . $options['tokens'] . '"';
}
}
$options = $this->_optionsToString($options, array('paramName', 'indicator'));
$options = $this->_buildOptions($options, $this->autoCompleteOptions);
$text = $this->Form->text($field, $htmlOptions);
$div = $this->Html->div(null, '', $divOptions);
$script = "{$var}new Ajax.Autocompleter('{$htmlOptions['id']}', '{$divOptions['id']}', '";
$script .= $this->Html->url($url) . "', {$options});";
return "{$text}\n{$div}\n" . $this->Javascript->codeBlock($script);
}
/**
* Creates an Ajax-updateable DIV element
*
* @param string $id options for javascript
* @return string HTML code
*/
function div($id, $options = array()) {
if (env('HTTP_X_UPDATE') != null) {
$this->Javascript->enabled = false;
$divs = explode(' ', env('HTTP_X_UPDATE'));
if (in_array($id, $divs)) {
@ob_end_clean();
ob_start();
return '';
}
}
$attr = $this->_parseAttributes(array_merge($options, array('id' => $id)));
return sprintf($this->Html->tags['blockstart'], $attr);
}
/**
* Closes an Ajax-updateable DIV element
*
* @param string $id The DOM ID of the element
* @return string HTML code
*/
function divEnd($id) {
if (env('HTTP_X_UPDATE') != null) {
$divs = explode(' ', env('HTTP_X_UPDATE'));
if (in_array($id, $divs)) {
$this->__ajaxBuffer[$id] = ob_get_contents();
ob_end_clean();
ob_start();
return '';
}
}
return $this->Html->tags['blockend'];
}
/**
* Detects Ajax requests
*
* @return boolean True if the current request is a Prototype Ajax update call
*/
function isAjax() {
return (isset($this->params['isAjax']) && $this->params['isAjax'] === true);
}
/**
* Creates a draggable element. For a reference on the options for this function,
* check out http://github.com/madrobby/scriptaculous/wikis/draggable
*
* @param unknown_type $id
* @param array $options
* @return unknown
*/
function drag($id, $options = array()) {
$var = '';
if (isset($options['var'])) {
$var = 'var ' . $options['var'] . ' = ';
unset($options['var']);
}
$options = $this->_buildOptions(
$this->_optionsToString($options, array('handle', 'constraint')), $this->dragOptions
);
return $this->Javascript->codeBlock("{$var}new Draggable('$id', " .$options . ");");
}
/**
* For a reference on the options for this function, check out
* http://github.com/madrobby/scriptaculous/wikis/droppables
*
* @param unknown_type $id
* @param array $options
* @return string
*/
function drop($id, $options = array()) {
$optionsString = array('overlap', 'hoverclass');
if (!isset($options['accept']) || !is_array($options['accept'])) {
$optionsString[] = 'accept';
} else if (isset($options['accept'])) {
$options['accept'] = $this->Javascript->object($options['accept']);
}
$options = $this->_buildOptions(
$this->_optionsToString($options, $optionsString), $this->dropOptions
);
return $this->Javascript->codeBlock("Droppables.add('{$id}', {$options});");
}
/**
* Make an element with the given $id droppable, and trigger an Ajax call when a draggable is
* dropped on it.
*
* For a reference on the options for this function, check out
* http://wiki.script.aculo.us/scriptaculous/show/Droppables.add
*
* @param string $id
* @param array $options
* @param array $ajaxOptions
* @return string JavaScript block to create a droppable element
*/
function dropRemote($id, $options = array(), $ajaxOptions = array()) {
$callback = $this->remoteFunction($ajaxOptions);
$options['onDrop'] = "function(element, droppable, event) {{$callback}}";
$optionsString = array('overlap', 'hoverclass');
if (!isset($options['accept']) || !is_array($options['accept'])) {
$optionsString[] = 'accept';
} else if (isset($options['accept'])) {
$options['accept'] = $this->Javascript->object($options['accept']);
}
$options = $this->_buildOptions(
$this->_optionsToString($options, $optionsString),
$this->dropOptions
);
return $this->Javascript->codeBlock("Droppables.add('{$id}', {$options});");
}
/**
* Makes a slider control.
*
* @param string $id DOM ID of slider handle
* @param string $trackId DOM ID of slider track
* @param array $options Array of options to control the slider
* @link http://github.com/madrobby/scriptaculous/wikis/slider
*/
function slider($id, $trackId, $options = array()) {
if (isset($options['var'])) {
$var = 'var ' . $options['var'] . ' = ';
unset($options['var']);
} else {
$var = 'var ' . $id . ' = ';
}
$options = $this->_optionsToString($options, array(
'axis', 'handleImage', 'handleDisabled'
));
$callbacks = array('change', 'slide');
foreach ($callbacks as $callback) {
if (isset($options[$callback])) {
$call = $options[$callback];
$options['on' . ucfirst($callback)] = "function(value) {{$call}}";
unset($options[$callback]);
}
}
if (isset($options['values']) && is_array($options['values'])) {
$options['values'] = $this->Javascript->object($options['values']);
}
$options = $this->_buildOptions($options, $this->sliderOptions);
$script = "{$var}new Control.Slider('$id', '$trackId', $options);";
return $this->Javascript->codeBlock($script);
}
/**
* Makes an Ajax In Place editor control.
*
* @param string $id DOM ID of input element
* @param string $url Postback URL of saved data
* @param array $options Array of options to control the editor, including ajaxOptions (see link).
* @link http://github.com/madrobby/scriptaculous/wikis/ajax-inplaceeditor
*/
function editor($id, $url, $options = array()) {
$url = $this->url($url);
$options['ajaxOptions'] = $this->__optionsForAjax($options);
foreach ($this->ajaxOptions as $opt) {
if (isset($options[$opt])) {
unset($options[$opt]);
}
}
if (isset($options['callback'])) {
$options['callback'] = 'function(form, value) {' . $options['callback'] . '}';
}
$type = 'InPlaceEditor';
if (isset($options['collection']) && is_array($options['collection'])) {
$options['collection'] = $this->Javascript->object($options['collection']);
$type = 'InPlaceCollectionEditor';
}
$var = '';
if (isset($options['var'])) {
$var = 'var ' . $options['var'] . ' = ';
unset($options['var']);
}
$options = $this->_optionsToString($options, array(
'okText', 'cancelText', 'savingText', 'formId', 'externalControl', 'highlightcolor',
'highlightendcolor', 'savingClassName', 'formClassName', 'loadTextURL', 'loadingText',
'clickToEditText', 'okControl', 'cancelControl'
));
$options = $this->_buildOptions($options, $this->editorOptions);
$script = "{$var}new Ajax.{$type}('{$id}', '{$url}', {$options});";
return $this->Javascript->codeBlock($script);
}
/**
* Makes a list or group of floated objects sortable.
*
* @param string $id DOM ID of parent
* @param array $options Array of options to control sort.
* @link http://github.com/madrobby/scriptaculous/wikis/sortable
*/
function sortable($id, $options = array()) {
if (!empty($options['url'])) {
if (empty($options['with'])) {
$options['with'] = "Sortable.serialize('$id')";
}
$options['onUpdate'] = 'function(sortable) {' . $this->remoteFunction($options) . '}';
}
$block = true;
if (isset($options['block'])) {
$block = $options['block'];
unset($options['block']);
}
$strings = array(
'tag', 'constraint', 'only', 'handle', 'hoverclass', 'tree',
'treeTag', 'update', 'overlap'
);
$scrollIsObject = (
isset($options['scroll']) &&
$options['scroll'] != 'window' &&
strpos($options['scroll'], '$(') !== 0
);
if ($scrollIsObject) {
$strings[] = 'scroll';
}
$options = $this->_optionsToString($options, $strings);
$options = array_merge($options, $this->_buildCallbacks($options));
$options = $this->_buildOptions($options, $this->sortOptions);
$result = "Sortable.create('$id', $options);";
if (!$block) {
return $result;
}
return $this->Javascript->codeBlock($result);
}
/**
* Private helper function for Javascript.
*
* @param array $options Set of options
* @access private
*/
function __optionsForAjax($options) {
if (isset($options['indicator'])) {
if (isset($options['loading'])) {
$loading = $options['loading'];
if (!empty($loading) && substr(trim($loading), -1, 1) != ';') {
$options['loading'] .= '; ';
}
$options['loading'] .= "Element.show('{$options['indicator']}');";
} else {
$options['loading'] = "Element.show('{$options['indicator']}');";
}
if (isset($options['complete'])) {
$complete = $options['complete'];
if (!empty($complete) && substr(trim($complete), -1, 1) != ';') {
$options['complete'] .= '; ';
}
$options['complete'] .= "Element.hide('{$options['indicator']}');";
} else {
$options['complete'] = "Element.hide('{$options['indicator']}');";
}
unset($options['indicator']);
}
$jsOptions = array_merge(
array('asynchronous' => 'true', 'evalScripts' => 'true'),
$this->_buildCallbacks($options)
);
$options = $this->_optionsToString($options, array(
'contentType', 'encoding', 'fallback', 'method', 'postBody', 'update', 'url'
));
$jsOptions = array_merge($jsOptions, array_intersect_key($options, array_flip(array(
'contentType', 'encoding', 'method', 'postBody'
))));
foreach ($options as $key => $value) {
switch ($key) {
case 'type':
$jsOptions['asynchronous'] = ($value == 'synchronous') ? 'false' : 'true';
break;
case 'evalScripts':
$jsOptions['evalScripts'] = ($value) ? 'true' : 'false';
break;
case 'position':
$pos = Inflector::camelize($options['position']);
$jsOptions['insertion'] = "Insertion.{$pos}";
break;
case 'with':
$jsOptions['parameters'] = $options['with'];
break;
case 'form':
$jsOptions['parameters'] = 'Form.serialize(this)';
break;
case 'requestHeaders':
$keys = array();
foreach ($value as $key => $val) {
$keys[] = "'" . $key . "'";
$keys[] = "'" . $val . "'";
}
$jsOptions['requestHeaders'] = '[' . implode(', ', $keys) . ']';
break;
}
}
return $this->_buildOptions($jsOptions, $this->ajaxOptions);
}
/**
* Private Method to return a string of html options
* option data as a JavaScript options hash.
*
* @param array $options Options in the shape of keys and values
* @param array $extra Array of legal keys in this options context
* @return array Array of html options
* @access private
*/
function __getHtmlOptions($options, $extra = array()) {
foreach (array_merge($this->ajaxOptions, $this->callbacks, $extra) as $key) {
if (isset($options[$key])) {
unset($options[$key]);
}
}
return $options;
}
/**
* Returns a string of JavaScript with the given option data as a JavaScript options hash.
*
* @param array $options Options in the shape of keys and values
* @param array $acceptable Array of legal keys in this options context
* @return string String of Javascript array definition
*/
function _buildOptions($options, $acceptable) {
if (is_array($options)) {
$out = array();
foreach ($options as $k => $v) {
if (in_array($k, $acceptable)) {
if ($v === true) {
$v = 'true';
} elseif ($v === false) {
$v = 'false';
}
$out[] = "$k:$v";
} elseif ($k === 'with' && in_array('parameters', $acceptable)) {
$out[] = "parameters:${v}";
}
}
$out = implode(', ', $out);
$out = '{' . $out . '}';
return $out;
} else {
return false;
}
}
/**
* Return JavaScript text for an observer...
*
* @param string $klass Name of JavaScript class
* @param string $name
* @param array $options Ajax options
* @return string Formatted JavaScript
*/
function _buildObserver($klass, $name, $options = null) {
if (!isset($options['with']) && isset($options['update'])) {
$options['with'] = 'value';
}
$callback = $this->remoteFunction($options);
$hasFrequency = !(!isset($options['frequency']) || intval($options['frequency']) == 0);
$frequency = $hasFrequency ? $options['frequency'] . ', ' : '';
return "new $klass('$name', {$frequency}function(element, value) {{$callback}})";
}
/**
* Return Javascript text for callbacks.
*
* @param array $options Option array where a callback is specified
* @return array Options with their callbacks properly set
* @access protected
*/
function _buildCallbacks($options) {
$callbacks = array();
foreach ($this->callbacks as $callback) {
if (isset($options[$callback])) {
$name = 'on' . ucfirst($callback);
$code = $options[$callback];
switch ($name) {
case 'onComplete':
$callbacks[$name] = "function(request, json) {" . $code . "}";
break;
case 'onCreate':
$callbacks[$name] = "function(request, xhr) {" . $code . "}";
break;
case 'onException':
$callbacks[$name] = "function(request, exception) {" . $code . "}";
break;
default:
$callbacks[$name] = "function(request) {" . $code . "}";
break;
}
if (isset($options['bind'])) {
$bind = $options['bind'];
$hasBinding = (
(is_array($bind) && in_array($callback, $bind)) ||
(is_string($bind) && strpos($bind, $callback) !== false)
);
if ($hasBinding) {
$callbacks[$name] .= ".bind(this)";
}
}
}
}
return $callbacks;
}
/**
* Returns a string of JavaScript with a string representation of given options array.
*
* @param array $options Ajax options array
* @param array $stringOpts Options as strings in an array
* @access private
* @return array
*/
function _optionsToString($options, $stringOpts = array()) {
foreach ($stringOpts as $option) {
$hasOption = (
isset($options[$option]) && !empty($options[$option]) &&
is_string($options[$option]) && $options[$option][0] != "'"
);
if ($hasOption) {
if ($options[$option] === true || $options[$option] === 'true') {
$options[$option] = 'true';
} elseif ($options[$option] === false || $options[$option] === 'false') {
$options[$option] = 'false';
} else {
$options[$option] = "'{$options[$option]}'";
}
}
}
return $options;
}
/**
* Executed after a view has rendered, used to include bufferred code
* blocks.
*
* @access public
*/
function afterRender() {
if (env('HTTP_X_UPDATE') != null && !empty($this->__ajaxBuffer)) {
@ob_end_clean();
$data = array();
$divs = explode(' ', env('HTTP_X_UPDATE'));
$keys = array_keys($this->__ajaxBuffer);
if (count($divs) == 1 && in_array($divs[0], $keys)) {
echo $this->__ajaxBuffer[$divs[0]];
} else {
foreach ($this->__ajaxBuffer as $key => $val) {
if (in_array($key, $divs)) {
$data[] = $key . ':"' . rawurlencode($val) . '"';
}
}
$out = 'var __ajaxUpdater__ = {' . implode(", \n", $data) . '};' . "\n";
$out .= 'for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string"';
$out .= ' && $(n)) Element.update($(n), unescape(decodeURIComponent(';
$out .= '__ajaxUpdater__[n]))); }';
echo $this->Javascript->codeBlock($out, false);
}
$scripts = $this->Javascript->getCache();
if (!empty($scripts)) {
echo $this->Javascript->codeBlock($scripts, false);
}
$this->_stop();
}
}
}
?>