From 85451dc5fe2c2adbdb470692009732a3fe390724 Mon Sep 17 00:00:00 2001 From: Earl Miles Date: Wed, 4 May 2011 11:02:01 -0700 Subject: [PATCH] Emptying master branch. --- API.txt | 12 - CHANGELOG.txt | 81 - README.txt | 1 + UPGRADE.txt | 63 - bulk_export/bulk_export.css | 17 - bulk_export/bulk_export.info | 5 - bulk_export/bulk_export.module | 204 --- css/collapsible-div.css | 18 - css/context.css | 10 - css/ctools.css | 25 - css/dropdown.css | 73 - css/export-ui-list.css | 32 - css/modal.css | 127 -- css/ruleset.css | 11 - css/stylizer.css | 129 -- css/wizard.css | 8 - ctools.api.php | 86 - ctools.info | 7 - ctools.install | 197 --- ctools.module | 782 --------- ctools_access_ruleset/ctools_access_ruleset.info | 5 - .../ctools_access_ruleset.install | 82 - ctools_access_ruleset/ctools_access_ruleset.module | 85 - ctools_access_ruleset/plugins/access/ruleset.inc | 100 -- .../plugins/export_ui/ctools_access_ruleset.inc | 29 - .../export_ui/ctools_access_ruleset_ui.class.php | 53 - ctools_ajax_sample/css/ctools-ajax-sample.css | 134 -- ctools_ajax_sample/ctools_ajax_sample.info | 5 - ctools_ajax_sample/ctools_ajax_sample.install | 19 - ctools_ajax_sample/ctools_ajax_sample.module | 744 -------- ctools_ajax_sample/images/ajax-loader.gif | Bin 10819 -> 0 bytes ctools_ajax_sample/images/loading-large.gif | Bin 2545 -> 0 bytes ctools_ajax_sample/images/loading.gif | Bin 1849 -> 0 bytes ctools_ajax_sample/images/popups-border.png | Bin 380 -> 0 bytes ctools_ajax_sample/js/ctools-ajax-sample.js | 42 - ctools_custom_content/ctools_custom_content.info | 5 - .../ctools_custom_content.install | 67 - ctools_custom_content/ctools_custom_content.module | 98 - .../plugins/export_ui/ctools_custom_content.inc | 20 - .../export_ui/ctools_custom_content_ui.class.php | 122 -- ctools_plugin_example/README.txt | 14 - ctools_plugin_example/ctools_plugin_example.info | 8 - ctools_plugin_example/ctools_plugin_example.module | 94 - .../ctools_plugin_example.pages_default.inc | 451 ----- ...Plugins--Determining-access-and-visibility.html | 17 - ...rgument-Plugins--Starting-at-the-beginning.html | 20 - .../help/Chaos-Tools--CTools--Plugin-Examples.html | 19 - ...lugins--Displaying-content-using-a-context.html | 17 - ...ins--Creating-a--context--from-an-argument.html | 21 - .../help/Module-setup-and-hooks.html | 20 - ...ps--Letting-one-context-take-us-to-another.html | 18 - .../help/ctools_plugin_example.help.ini | 42 - .../plugins/access/arg_length.inc | 65 - .../plugins/access/example_role.inc | 76 - .../plugins/arguments/simplecontext_arg.inc | 52 - .../plugins/content_types/icon_example.png | Bin 566 -> 0 bytes .../content_types/no_context_content_type.inc | 116 -- .../content_types/relcontext_content_type.inc | 103 -- .../content_types/simplecontext_content_type.inc | 129 -- .../plugins/contexts/relcontext.inc | 83 - .../plugins/contexts/simplecontext.inc | 134 -- ctools_plugin_example/plugins/panels.pages.inc | 214 --- .../relcontext_from_simplecontext.inc | 50 - help/about.html | 30 - help/context-access.html | 14 - help/context-arguments.html | 19 - help/context-content.html | 246 --- help/context-context.html | 12 - help/context-relationships.html | 10 - help/ctools.help.ini | 93 - help/export-ui.html | 84 - help/export.html | 234 --- help/modal.html | 220 --- help/object-cache.html | 132 -- help/plugins-api.html | 54 - help/plugins-creating.html | 189 -- help/plugins-implementing.html | 58 - help/plugins.html | 5 - help/wizard.html | 287 --- images/arrow-active.png | Bin 313 -> 0 bytes images/collapsible-collapsed.png | Bin 108 -> 0 bytes images/collapsible-expanded.png | Bin 106 -> 0 bytes images/expanded-options.png | Bin 228 -> 0 bytes images/icon-close-window.png | Bin 877 -> 0 bytes images/icon-configure.png | Bin 765 -> 0 bytes images/icon-delete.png | Bin 877 -> 0 bytes images/no-icon.png | Bin 574 -> 0 bytes images/status-active.gif | Bin 2196 -> 0 bytes images/throbber.gif | Bin 3208 -> 0 bytes includes/ajax.inc | 125 -- includes/cache.inc | 169 -- includes/cache.plugin-type.inc | 11 - includes/cleanstring.inc | 205 --- includes/collapsible.theme.inc | 79 - includes/content.inc | 773 -------- includes/content.menu.inc | 72 - includes/content.plugin-type.inc | 17 - includes/content.theme.inc | 21 - includes/context-access-admin.inc | 486 ----- includes/context-admin.inc | 782 --------- includes/context-task-handler.inc | 486 ----- includes/context.inc | 1542 ---------------- includes/context.menu.inc | 39 - includes/context.plugin-type.inc | 24 - includes/context.theme.inc | 344 ---- includes/css.inc | 562 ------ includes/dependent.inc | 154 -- includes/dropdown.theme.inc | 87 - includes/export-ui.inc | 466 ----- includes/export-ui.menu.inc | 24 - includes/export-ui.plugin-type.inc | 20 - includes/export.inc | 1015 ----------- includes/fields.inc | 102 -- includes/jump-menu.inc | 120 -- includes/math-expr.inc | 385 ---- includes/menu.inc | 98 - includes/modal.inc | 249 --- includes/object-cache.cron.inc | 16 - includes/object-cache.inc | 174 -- includes/page-wizard.inc | 194 -- includes/page-wizard.menu.inc | 32 - includes/plugins-admin.inc | 196 --- includes/plugins.inc | 880 ---------- includes/registry.inc | 77 - includes/stylizer.inc | 1655 ------------------ includes/stylizer.theme.inc | 28 - includes/utility.inc | 44 - includes/wizard.inc | 515 ------ includes/wizard.theme.inc | 25 - js/ajax-responder.js | 122 -- js/auto-submit.js | 74 - js/collapsible-div.js | 240 --- js/dependent.js | 215 --- js/dropdown.js | 87 - js/jump-menu.js | 34 - js/modal.js | 494 ------ js/stylizer.js | 219 --- page_manager/css/page-manager.css | 341 ---- page_manager/help/about.html | 11 - page_manager/help/api-task-handler.html | 43 - page_manager/help/api-task-type.html | 2 - page_manager/help/api-task.html | 38 - page_manager/help/custom-pages-access.html | 2 - page_manager/help/custom-pages-arguments.html | 2 - page_manager/help/custom-pages-menu.html | 2 - page_manager/help/custom-pages.html | 2 - page_manager/help/getting-started-create.html | 2 - .../help/getting-started-custom-nodes.html | 2 - .../help/getting-started-custom-vocabulary.html | 2 - page_manager/help/getting-started-members.html | 2 - page_manager/help/getting-started-page-list.html | 2 - page_manager/help/getting-started.html | 15 - page_manager/help/page-task-type.html | 4 - page_manager/help/page_manager.help.ini | 59 - page_manager/help/variants.html | 2 - page_manager/images/arrow-active.png | Bin 313 -> 0 bytes page_manager/images/locked-other.png | Bin 262 -> 0 bytes page_manager/images/locked.png | Bin 273 -> 0 bytes page_manager/js/page-list.js | 44 - page_manager/page_manager.admin.inc | 1849 -------------------- page_manager/page_manager.info | 5 - page_manager/page_manager.install | 202 --- page_manager/page_manager.module | 1177 ------------- .../plugins/cache/page_manager_context.inc | 70 - .../plugins/task_handlers/http_response.inc | 286 --- page_manager/plugins/tasks/blog.inc | 104 -- page_manager/plugins/tasks/blog_user.inc | 134 -- page_manager/plugins/tasks/contact_site.inc | 104 -- page_manager/plugins/tasks/contact_user.inc | 133 -- page_manager/plugins/tasks/node_edit.inc | 167 -- page_manager/plugins/tasks/node_view.inc | 143 -- page_manager/plugins/tasks/page.admin.inc | 1517 ---------------- page_manager/plugins/tasks/page.inc | 770 -------- page_manager/plugins/tasks/poll.inc | 104 -- page_manager/plugins/tasks/search.inc | 292 --- page_manager/plugins/tasks/term_view.inc | 293 ---- page_manager/plugins/tasks/user_view.inc | 131 -- page_manager/theme/page-manager-edit-page.tpl.php | 53 - page_manager/theme/page_manager.theme.inc | 118 -- plugins/access/compare_users.inc | 70 - plugins/access/context_exists.inc | 51 - plugins/access/node_access.inc | 89 - plugins/access/node_language.inc | 114 -- plugins/access/node_type.inc | 100 -- plugins/access/path_visibility.inc | 88 - plugins/access/perm.inc | 73 - plugins/access/php.inc | 64 - plugins/access/role.inc | 79 - plugins/access/site_language.inc | 87 - plugins/access/string_equal.inc | 94 - plugins/access/string_length.inc | 78 - plugins/access/term.inc | 152 -- plugins/access/term_parent.inc | 86 - plugins/access/term_vocabulary.inc | 87 - plugins/access/theme.inc | 70 - plugins/arguments/entity_id.inc | 66 - plugins/arguments/nid.inc | 49 - plugins/arguments/node_add.inc | 32 - plugins/arguments/node_edit.inc | 51 - plugins/arguments/rid.inc | 50 - plugins/arguments/string.inc | 64 - plugins/arguments/term.inc | 147 -- plugins/arguments/terms.inc | 77 - plugins/arguments/uid.inc | 52 - plugins/arguments/user_name.inc | 47 - plugins/arguments/vid.inc | 45 - plugins/cache/export_ui.inc | 39 - plugins/cache/simple.inc | 45 - plugins/content_types/block/block.inc | 415 ----- plugins/content_types/block/icon_contrib_block.png | Bin 574 -> 0 bytes .../block/icon_contrib_block_empty.png | Bin 450 -> 0 bytes plugins/content_types/block/icon_contrib_menu.png | Bin 552 -> 0 bytes plugins/content_types/block/icon_contrib_page.png | Bin 460 -> 0 bytes .../block/icon_core_activeforumtopics.png | Bin 603 -> 0 bytes .../block/icon_core_authorinformation.png | Bin 606 -> 0 bytes plugins/content_types/block/icon_core_block.png | Bin 568 -> 0 bytes .../content_types/block/icon_core_block_empty.png | Bin 450 -> 0 bytes .../content_types/block/icon_core_block_menu.png | Bin 552 -> 0 bytes .../block/icon_core_booknavigation.png | Bin 626 -> 0 bytes .../block/icon_core_languageswitcher.png | Bin 601 -> 0 bytes .../content_types/block/icon_core_navigation.png | Bin 818 -> 0 bytes .../block/icon_core_newforumtopics.png | Bin 604 -> 0 bytes plugins/content_types/block/icon_core_page.png | Bin 460 -> 0 bytes .../block/icon_core_popularcontent.png | Bin 604 -> 0 bytes .../content_types/block/icon_core_primarylinks.png | Bin 892 -> 0 bytes .../block/icon_core_recentblogposts.png | Bin 681 -> 0 bytes .../block/icon_core_recentcomments.png | Bin 662 -> 0 bytes .../content_types/block/icon_core_recentpoll.png | Bin 608 -> 0 bytes .../content_types/block/icon_core_searchform.png | Bin 717 -> 0 bytes .../content_types/block/icon_core_syndicate.png | Bin 803 -> 0 bytes .../content_types/block/icon_core_userlogin.png | Bin 601 -> 0 bytes plugins/content_types/block/icon_core_whosnew.png | Bin 732 -> 0 bytes .../content_types/block/icon_core_whosonline.png | Bin 744 -> 0 bytes plugins/content_types/contact/contact.inc | 60 - plugins/content_types/contact/icon_contact.png | Bin 606 -> 0 bytes plugins/content_types/contact/user_contact.inc | 65 - plugins/content_types/custom/custom.inc | 407 ----- plugins/content_types/custom/icon_block_custom.png | Bin 522 -> 0 bytes .../content_types/entity_context/entity_field.inc | 170 -- plugins/content_types/form/form.inc | 56 - plugins/content_types/form/icon_form.png | Bin 460 -> 0 bytes plugins/content_types/node/icon_node.png | Bin 460 -> 0 bytes plugins/content_types/node/node.inc | 242 --- plugins/content_types/node_context/icon_node.png | Bin 460 -> 0 bytes .../node_context/node_attachments.inc | 44 - plugins/content_types/node_context/node_author.inc | 71 - plugins/content_types/node_context/node_body.inc | 60 - .../node_context/node_book_children.inc | 43 - .../content_types/node_context/node_book_nav.inc | 43 - .../node_context/node_comment_form.inc | 96 - .../content_types/node_context/node_comments.inc | 129 -- .../content_types/node_context/node_content.inc | 203 --- .../content_types/node_context/node_created.inc | 74 - plugins/content_types/node_context/node_links.inc | 105 -- plugins/content_types/node_context/node_terms.inc | 187 -- plugins/content_types/node_context/node_title.inc | 73 - .../content_types/node_context/node_type_desc.inc | 47 - .../content_types/node_context/node_updated.inc | 74 - plugins/content_types/node_form/icon_node_form.png | Bin 460 -> 0 bytes .../node_form/node_form_attachments.inc | 45 - .../content_types/node_form/node_form_author.inc | 45 - plugins/content_types/node_form/node_form_book.inc | 49 - .../content_types/node_form/node_form_buttons.inc | 42 - .../content_types/node_form/node_form_comment.inc | 45 - .../node_form/node_form_input_format.inc | 43 - plugins/content_types/node_form/node_form_log.inc | 32 - plugins/content_types/node_form/node_form_menu.inc | 46 - plugins/content_types/node_form/node_form_path.inc | 46 - .../node_form/node_form_publishing.inc | 49 - .../content_types/node_form/node_form_taxonomy.inc | 45 - plugins/content_types/page/page_breadcrumb.inc | 32 - plugins/content_types/page/page_feed_icons.inc | 32 - plugins/content_types/page/page_help.inc | 33 - plugins/content_types/page/page_logo.inc | 36 - plugins/content_types/page/page_messages.inc | 33 - plugins/content_types/page/page_primary_links.inc | 32 - .../content_types/page/page_secondary_links.inc | 32 - plugins/content_types/page/page_site_name.inc | 32 - plugins/content_types/page/page_slogan.inc | 32 - plugins/content_types/page/page_tabs.inc | 70 - plugins/content_types/page/page_title.inc | 118 -- plugins/content_types/search/icon_search.png | Bin 717 -> 0 bytes plugins/content_types/search/search_form.inc | 170 -- plugins/content_types/search/search_result.inc | 202 --- plugins/content_types/term_context/icon_term.png | Bin 460 -> 0 bytes .../term_context/term_description.inc | 50 - plugins/content_types/term_context/term_list.inc | 118 -- plugins/content_types/user_context/icon_user.png | Bin 606 -> 0 bytes .../content_types/user_context/profile_fields.inc | 129 -- .../user_context/profile_fields_pane.tpl.php | 16 - .../content_types/user_context/user_picture.inc | 41 - .../content_types/user_context/user_profile.inc | 65 - .../content_types/user_context/user_signature.inc | 39 - .../vocabulary_context/icon_vocabulary.png | Bin 460 -> 0 bytes .../vocabulary_context/vocabulary_terms.inc | 93 - plugins/contexts/entity.inc | 252 --- plugins/contexts/node.inc | 178 -- plugins/contexts/node_add_form.inc | 117 -- plugins/contexts/node_edit_form.inc | 183 -- plugins/contexts/string.inc | 64 - plugins/contexts/term.inc | 164 -- plugins/contexts/terms.inc | 97 - plugins/contexts/token.inc | 61 - plugins/contexts/user.inc | 168 -- plugins/contexts/vocabulary.inc | 68 - plugins/export_ui/ctools_export_ui.class.php | 1448 --------------- plugins/export_ui/ctools_export_ui.inc | 24 - plugins/relationships/book_parent.inc | 66 - plugins/relationships/entity_from_field.inc | 94 - plugins/relationships/entity_from_schema.inc | 89 - plugins/relationships/node_edit_form_from_node.inc | 31 - plugins/relationships/term_from_node.inc | 60 - plugins/relationships/term_parent.inc | 68 - plugins/relationships/terms_from_node.inc | 76 - plugins/relationships/user_from_node.inc | 37 - stylizer/plugins/export_ui/stylizer.inc | 45 - stylizer/plugins/export_ui/stylizer_ui.class.php | 270 --- stylizer/stylizer.info | 6 - stylizer/stylizer.install | 64 - stylizer/stylizer.module | 135 -- tests/css.test | 69 - tests/ctools.plugins.test | 100 -- tests/ctools_plugin_test.info | 8 - tests/ctools_plugin_test.module | 72 - tests/object_cache.test | 46 - .../cached/ctoolsCachedPluginArray.class.php | 7 - .../cached/ctoolsCachedPluginArray2.class.php | 7 - tests/plugins/cached/plugin_array.inc | 20 - tests/plugins/cached/plugin_array2.inc | 20 - tests/plugins/cached/plugin_array_dne.inc | 15 - .../ctoolsNotCachedPluginArray.class.php | 7 - .../ctoolsNotCachedPluginArray2.class.php | 7 - tests/plugins/not_cached/plugin_array.inc | 20 - tests/plugins/not_cached/plugin_array2.inc | 20 - tests/plugins/not_cached/plugin_array_dne.inc | 15 - .../content_types/icon_views_block_legacy.png | Bin 599 -> 0 bytes .../plugins/content_types/icon_views_page.png | Bin 716 -> 0 bytes .../content_types/icon_views_page_legacy.png | Bin 587 -> 0 bytes views_content/plugins/content_types/views.inc | 566 ------ .../plugins/content_types/views_attachments.inc | 75 - .../plugins/content_types/views_empty.inc | 52 - .../plugins/content_types/views_exposed.inc | 52 - views_content/plugins/content_types/views_feed.inc | 52 - .../plugins/content_types/views_footer.inc | 52 - .../plugins/content_types/views_header.inc | 52 - .../plugins/content_types/views_pager.inc | 52 - .../plugins/content_types/views_panes.inc | 614 ------- views_content/plugins/content_types/views_row.inc | 189 -- views_content/plugins/contexts/view.inc | 134 -- .../plugins/relationships/node_from_view.inc | 64 - .../plugins/relationships/term_from_view.inc | 64 - .../plugins/relationships/user_from_view.inc | 64 - .../plugins/views/views_content.views.inc | 58 - ...views_content_plugin_display_ctools_context.inc | 155 -- .../views_content_plugin_display_panel_pane.inc | 403 ----- .../views_content_plugin_style_ctools_context.inc | 57 - views_content/views_content.info | 10 - views_content/views_content.module | 184 -- 358 files changed, 1 insertions(+), 42903 deletions(-) delete mode 100644 API.txt delete mode 100644 CHANGELOG.txt create mode 100644 README.txt delete mode 100644 UPGRADE.txt delete mode 100644 bulk_export/bulk_export.css delete mode 100644 bulk_export/bulk_export.info delete mode 100644 bulk_export/bulk_export.module delete mode 100644 css/collapsible-div.css delete mode 100644 css/context.css delete mode 100644 css/ctools.css delete mode 100644 css/dropdown.css delete mode 100644 css/export-ui-list.css delete mode 100644 css/modal.css delete mode 100644 css/ruleset.css delete mode 100644 css/stylizer.css delete mode 100644 css/wizard.css delete mode 100644 ctools.api.php delete mode 100644 ctools.info delete mode 100644 ctools.install delete mode 100644 ctools.module delete mode 100644 ctools_access_ruleset/ctools_access_ruleset.info delete mode 100644 ctools_access_ruleset/ctools_access_ruleset.install delete mode 100644 ctools_access_ruleset/ctools_access_ruleset.module delete mode 100644 ctools_access_ruleset/plugins/access/ruleset.inc delete mode 100644 ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc delete mode 100644 ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php delete mode 100644 ctools_ajax_sample/css/ctools-ajax-sample.css delete mode 100644 ctools_ajax_sample/ctools_ajax_sample.info delete mode 100644 ctools_ajax_sample/ctools_ajax_sample.install delete mode 100644 ctools_ajax_sample/ctools_ajax_sample.module delete mode 100644 ctools_ajax_sample/images/ajax-loader.gif delete mode 100644 ctools_ajax_sample/images/loading-large.gif delete mode 100644 ctools_ajax_sample/images/loading.gif delete mode 100644 ctools_ajax_sample/images/popups-border.png delete mode 100644 ctools_ajax_sample/js/ctools-ajax-sample.js delete mode 100644 ctools_custom_content/ctools_custom_content.info delete mode 100644 ctools_custom_content/ctools_custom_content.install delete mode 100644 ctools_custom_content/ctools_custom_content.module delete mode 100644 ctools_custom_content/plugins/export_ui/ctools_custom_content.inc delete mode 100644 ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php delete mode 100644 ctools_plugin_example/README.txt delete mode 100644 ctools_plugin_example/ctools_plugin_example.info delete mode 100644 ctools_plugin_example/ctools_plugin_example.module delete mode 100644 ctools_plugin_example/ctools_plugin_example.pages_default.inc delete mode 100644 ctools_plugin_example/help/Access-Plugins--Determining-access-and-visibility.html delete mode 100644 ctools_plugin_example/help/Argument-Plugins--Starting-at-the-beginning.html delete mode 100644 ctools_plugin_example/help/Chaos-Tools--CTools--Plugin-Examples.html delete mode 100644 ctools_plugin_example/help/Content-Type-Plugins--Displaying-content-using-a-context.html delete mode 100644 ctools_plugin_example/help/Context-plugins--Creating-a--context--from-an-argument.html delete mode 100644 ctools_plugin_example/help/Module-setup-and-hooks.html delete mode 100644 ctools_plugin_example/help/Relationships--Letting-one-context-take-us-to-another.html delete mode 100644 ctools_plugin_example/help/ctools_plugin_example.help.ini delete mode 100644 ctools_plugin_example/plugins/access/arg_length.inc delete mode 100644 ctools_plugin_example/plugins/access/example_role.inc delete mode 100644 ctools_plugin_example/plugins/arguments/simplecontext_arg.inc delete mode 100644 ctools_plugin_example/plugins/content_types/icon_example.png delete mode 100644 ctools_plugin_example/plugins/content_types/no_context_content_type.inc delete mode 100644 ctools_plugin_example/plugins/content_types/relcontext_content_type.inc delete mode 100644 ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc delete mode 100644 ctools_plugin_example/plugins/contexts/relcontext.inc delete mode 100644 ctools_plugin_example/plugins/contexts/simplecontext.inc delete mode 100644 ctools_plugin_example/plugins/panels.pages.inc delete mode 100644 ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc delete mode 100644 help/about.html delete mode 100644 help/ajax.html delete mode 100644 help/context-access.html delete mode 100644 help/context-arguments.html delete mode 100644 help/context-content.html delete mode 100644 help/context-context.html delete mode 100644 help/context-relationships.html delete mode 100644 help/context.html delete mode 100644 help/ctools.help.ini delete mode 100644 help/export-ui.html delete mode 100644 help/export.html delete mode 100644 help/modal.html delete mode 100644 help/object-cache.html delete mode 100644 help/plugins-api.html delete mode 100644 help/plugins-creating.html delete mode 100644 help/plugins-implementing.html delete mode 100644 help/plugins.html delete mode 100644 help/wizard.html delete mode 100644 images/arrow-active.png delete mode 100644 images/collapsible-collapsed.png delete mode 100644 images/collapsible-expanded.png delete mode 100644 images/expanded-options.png delete mode 100644 images/icon-close-window.png delete mode 100644 images/icon-configure.png delete mode 100644 images/icon-delete.png delete mode 100644 images/no-icon.png delete mode 100644 images/status-active.gif delete mode 100644 images/throbber.gif delete mode 100644 includes/ajax.inc delete mode 100644 includes/cache.inc delete mode 100644 includes/cache.plugin-type.inc delete mode 100644 includes/cleanstring.inc delete mode 100644 includes/collapsible.theme.inc delete mode 100644 includes/content.inc delete mode 100644 includes/content.menu.inc delete mode 100644 includes/content.plugin-type.inc delete mode 100644 includes/content.theme.inc delete mode 100644 includes/context-access-admin.inc delete mode 100644 includes/context-admin.inc delete mode 100644 includes/context-task-handler.inc delete mode 100644 includes/context.inc delete mode 100644 includes/context.menu.inc delete mode 100644 includes/context.plugin-type.inc delete mode 100644 includes/context.theme.inc delete mode 100644 includes/css.inc delete mode 100644 includes/dependent.inc delete mode 100644 includes/dropdown.theme.inc delete mode 100644 includes/export-ui.inc delete mode 100644 includes/export-ui.menu.inc delete mode 100644 includes/export-ui.plugin-type.inc delete mode 100644 includes/export.inc delete mode 100644 includes/fields.inc delete mode 100644 includes/jump-menu.inc delete mode 100644 includes/math-expr.inc delete mode 100644 includes/menu.inc delete mode 100644 includes/modal.inc delete mode 100644 includes/object-cache.cron.inc delete mode 100644 includes/object-cache.inc delete mode 100644 includes/page-wizard.inc delete mode 100644 includes/page-wizard.menu.inc delete mode 100644 includes/plugins-admin.inc delete mode 100644 includes/plugins.inc delete mode 100644 includes/registry.inc delete mode 100644 includes/stylizer.inc delete mode 100644 includes/stylizer.theme.inc delete mode 100644 includes/utility.inc delete mode 100644 includes/wizard.inc delete mode 100644 includes/wizard.theme.inc delete mode 100644 js/ajax-responder.js delete mode 100644 js/auto-submit.js delete mode 100644 js/collapsible-div.js delete mode 100644 js/dependent.js delete mode 100644 js/dropdown.js delete mode 100644 js/jump-menu.js delete mode 100644 js/modal.js delete mode 100644 js/stylizer.js delete mode 100644 page_manager/css/page-manager.css delete mode 100644 page_manager/help/about.html delete mode 100644 page_manager/help/api-task-handler.html delete mode 100644 page_manager/help/api-task-type.html delete mode 100644 page_manager/help/api-task.html delete mode 100644 page_manager/help/custom-pages-access.html delete mode 100644 page_manager/help/custom-pages-arguments.html delete mode 100644 page_manager/help/custom-pages-menu.html delete mode 100644 page_manager/help/custom-pages.html delete mode 100644 page_manager/help/getting-started-create.html delete mode 100644 page_manager/help/getting-started-custom-nodes.html delete mode 100644 page_manager/help/getting-started-custom-vocabulary.html delete mode 100644 page_manager/help/getting-started-members.html delete mode 100644 page_manager/help/getting-started-page-list.html delete mode 100644 page_manager/help/getting-started.html delete mode 100644 page_manager/help/page-task-type.html delete mode 100644 page_manager/help/page_manager.help.ini delete mode 100644 page_manager/help/variants.html delete mode 100644 page_manager/images/arrow-active.png delete mode 100644 page_manager/images/locked-other.png delete mode 100644 page_manager/images/locked.png delete mode 100644 page_manager/js/page-list.js delete mode 100644 page_manager/page_manager.admin.inc delete mode 100644 page_manager/page_manager.info delete mode 100644 page_manager/page_manager.install delete mode 100644 page_manager/page_manager.module delete mode 100644 page_manager/plugins/cache/page_manager_context.inc delete mode 100644 page_manager/plugins/task_handlers/http_response.inc delete mode 100644 page_manager/plugins/tasks/blog.inc delete mode 100644 page_manager/plugins/tasks/blog_user.inc delete mode 100644 page_manager/plugins/tasks/contact_site.inc delete mode 100644 page_manager/plugins/tasks/contact_user.inc delete mode 100644 page_manager/plugins/tasks/node_edit.inc delete mode 100644 page_manager/plugins/tasks/node_view.inc delete mode 100644 page_manager/plugins/tasks/page.admin.inc delete mode 100644 page_manager/plugins/tasks/page.inc delete mode 100644 page_manager/plugins/tasks/poll.inc delete mode 100644 page_manager/plugins/tasks/search.inc delete mode 100644 page_manager/plugins/tasks/term_view.inc delete mode 100644 page_manager/plugins/tasks/user_view.inc delete mode 100644 page_manager/theme/page-manager-edit-page.tpl.php delete mode 100644 page_manager/theme/page_manager.theme.inc delete mode 100644 plugins/access/compare_users.inc delete mode 100644 plugins/access/context_exists.inc delete mode 100644 plugins/access/node.inc delete mode 100644 plugins/access/node_access.inc delete mode 100644 plugins/access/node_language.inc delete mode 100644 plugins/access/node_type.inc delete mode 100644 plugins/access/path_visibility.inc delete mode 100644 plugins/access/perm.inc delete mode 100644 plugins/access/php.inc delete mode 100644 plugins/access/role.inc delete mode 100644 plugins/access/site_language.inc delete mode 100644 plugins/access/string_equal.inc delete mode 100644 plugins/access/string_length.inc delete mode 100644 plugins/access/term.inc delete mode 100644 plugins/access/term_parent.inc delete mode 100644 plugins/access/term_vocabulary.inc delete mode 100644 plugins/access/theme.inc delete mode 100644 plugins/arguments/entity_id.inc delete mode 100644 plugins/arguments/nid.inc delete mode 100644 plugins/arguments/node_add.inc delete mode 100644 plugins/arguments/node_edit.inc delete mode 100644 plugins/arguments/rid.inc delete mode 100644 plugins/arguments/string.inc delete mode 100644 plugins/arguments/term.inc delete mode 100644 plugins/arguments/terms.inc delete mode 100644 plugins/arguments/uid.inc delete mode 100644 plugins/arguments/user_name.inc delete mode 100644 plugins/arguments/vid.inc delete mode 100644 plugins/cache/export_ui.inc delete mode 100644 plugins/cache/simple.inc delete mode 100644 plugins/content_types/block/block.inc delete mode 100644 plugins/content_types/block/icon_contrib_block.png delete mode 100644 plugins/content_types/block/icon_contrib_block_empty.png delete mode 100644 plugins/content_types/block/icon_contrib_menu.png delete mode 100644 plugins/content_types/block/icon_contrib_page.png delete mode 100644 plugins/content_types/block/icon_core_activeforumtopics.png delete mode 100644 plugins/content_types/block/icon_core_authorinformation.png delete mode 100644 plugins/content_types/block/icon_core_block.png delete mode 100644 plugins/content_types/block/icon_core_block_empty.png delete mode 100644 plugins/content_types/block/icon_core_block_menu.png delete mode 100644 plugins/content_types/block/icon_core_booknavigation.png delete mode 100644 plugins/content_types/block/icon_core_languageswitcher.png delete mode 100644 plugins/content_types/block/icon_core_navigation.png delete mode 100644 plugins/content_types/block/icon_core_newforumtopics.png delete mode 100644 plugins/content_types/block/icon_core_page.png delete mode 100644 plugins/content_types/block/icon_core_popularcontent.png delete mode 100644 plugins/content_types/block/icon_core_primarylinks.png delete mode 100644 plugins/content_types/block/icon_core_recentblogposts.png delete mode 100644 plugins/content_types/block/icon_core_recentcomments.png delete mode 100644 plugins/content_types/block/icon_core_recentpoll.png delete mode 100644 plugins/content_types/block/icon_core_searchform.png delete mode 100644 plugins/content_types/block/icon_core_syndicate.png delete mode 100644 plugins/content_types/block/icon_core_userlogin.png delete mode 100644 plugins/content_types/block/icon_core_whosnew.png delete mode 100644 plugins/content_types/block/icon_core_whosonline.png delete mode 100644 plugins/content_types/contact/contact.inc delete mode 100644 plugins/content_types/contact/icon_contact.png delete mode 100644 plugins/content_types/contact/user_contact.inc delete mode 100644 plugins/content_types/custom/custom.inc delete mode 100644 plugins/content_types/custom/icon_block_custom.png delete mode 100644 plugins/content_types/entity_context/entity_field.inc delete mode 100644 plugins/content_types/form/form.inc delete mode 100644 plugins/content_types/form/icon_form.png delete mode 100644 plugins/content_types/node/icon_node.png delete mode 100644 plugins/content_types/node/node.inc delete mode 100644 plugins/content_types/node_context/icon_node.png delete mode 100644 plugins/content_types/node_context/node_attachments.inc delete mode 100644 plugins/content_types/node_context/node_author.inc delete mode 100644 plugins/content_types/node_context/node_body.inc delete mode 100644 plugins/content_types/node_context/node_book_children.inc delete mode 100644 plugins/content_types/node_context/node_book_nav.inc delete mode 100644 plugins/content_types/node_context/node_comment_form.inc delete mode 100644 plugins/content_types/node_context/node_comments.inc delete mode 100644 plugins/content_types/node_context/node_content.inc delete mode 100644 plugins/content_types/node_context/node_created.inc delete mode 100644 plugins/content_types/node_context/node_links.inc delete mode 100644 plugins/content_types/node_context/node_terms.inc delete mode 100644 plugins/content_types/node_context/node_title.inc delete mode 100644 plugins/content_types/node_context/node_type_desc.inc delete mode 100644 plugins/content_types/node_context/node_updated.inc delete mode 100644 plugins/content_types/node_form/icon_node_form.png delete mode 100644 plugins/content_types/node_form/node_form_attachments.inc delete mode 100644 plugins/content_types/node_form/node_form_author.inc delete mode 100644 plugins/content_types/node_form/node_form_book.inc delete mode 100644 plugins/content_types/node_form/node_form_buttons.inc delete mode 100644 plugins/content_types/node_form/node_form_comment.inc delete mode 100644 plugins/content_types/node_form/node_form_input_format.inc delete mode 100644 plugins/content_types/node_form/node_form_log.inc delete mode 100644 plugins/content_types/node_form/node_form_menu.inc delete mode 100644 plugins/content_types/node_form/node_form_path.inc delete mode 100644 plugins/content_types/node_form/node_form_publishing.inc delete mode 100644 plugins/content_types/node_form/node_form_taxonomy.inc delete mode 100644 plugins/content_types/page/page_breadcrumb.inc delete mode 100644 plugins/content_types/page/page_feed_icons.inc delete mode 100644 plugins/content_types/page/page_help.inc delete mode 100644 plugins/content_types/page/page_logo.inc delete mode 100644 plugins/content_types/page/page_messages.inc delete mode 100644 plugins/content_types/page/page_primary_links.inc delete mode 100644 plugins/content_types/page/page_secondary_links.inc delete mode 100644 plugins/content_types/page/page_site_name.inc delete mode 100644 plugins/content_types/page/page_slogan.inc delete mode 100644 plugins/content_types/page/page_tabs.inc delete mode 100644 plugins/content_types/page/page_title.inc delete mode 100644 plugins/content_types/search/icon_search.png delete mode 100644 plugins/content_types/search/search_form.inc delete mode 100644 plugins/content_types/search/search_result.inc delete mode 100644 plugins/content_types/term_context/icon_term.png delete mode 100644 plugins/content_types/term_context/term_description.inc delete mode 100644 plugins/content_types/term_context/term_list.inc delete mode 100644 plugins/content_types/user_context/icon_user.png delete mode 100644 plugins/content_types/user_context/profile_fields.inc delete mode 100644 plugins/content_types/user_context/profile_fields_pane.tpl.php delete mode 100644 plugins/content_types/user_context/user_picture.inc delete mode 100644 plugins/content_types/user_context/user_profile.inc delete mode 100644 plugins/content_types/user_context/user_signature.inc delete mode 100644 plugins/content_types/vocabulary_context/icon_vocabulary.png delete mode 100644 plugins/content_types/vocabulary_context/vocabulary_terms.inc delete mode 100644 plugins/contexts/entity.inc delete mode 100644 plugins/contexts/node.inc delete mode 100644 plugins/contexts/node_add_form.inc delete mode 100644 plugins/contexts/node_edit_form.inc delete mode 100644 plugins/contexts/string.inc delete mode 100644 plugins/contexts/term.inc delete mode 100644 plugins/contexts/terms.inc delete mode 100644 plugins/contexts/token.inc delete mode 100644 plugins/contexts/user.inc delete mode 100644 plugins/contexts/vocabulary.inc delete mode 100644 plugins/export_ui/ctools_export_ui.class.php delete mode 100644 plugins/export_ui/ctools_export_ui.inc delete mode 100644 plugins/relationships/book_parent.inc delete mode 100644 plugins/relationships/entity_from_field.inc delete mode 100644 plugins/relationships/entity_from_schema.inc delete mode 100644 plugins/relationships/node_edit_form_from_node.inc delete mode 100644 plugins/relationships/term_from_node.inc delete mode 100644 plugins/relationships/term_parent.inc delete mode 100644 plugins/relationships/terms_from_node.inc delete mode 100644 plugins/relationships/user_from_node.inc delete mode 100644 stylizer/plugins/export_ui/stylizer.inc delete mode 100644 stylizer/plugins/export_ui/stylizer_ui.class.php delete mode 100644 stylizer/stylizer.info delete mode 100644 stylizer/stylizer.install delete mode 100644 stylizer/stylizer.module delete mode 100644 tests/css.test delete mode 100644 tests/ctools.plugins.test delete mode 100644 tests/ctools_plugin_test.info delete mode 100644 tests/ctools_plugin_test.module delete mode 100644 tests/object_cache.test delete mode 100644 tests/plugins/cached/ctoolsCachedPluginArray.class.php delete mode 100644 tests/plugins/cached/ctoolsCachedPluginArray2.class.php delete mode 100644 tests/plugins/cached/plugin_array.inc delete mode 100644 tests/plugins/cached/plugin_array2.inc delete mode 100644 tests/plugins/cached/plugin_array_dne.inc delete mode 100644 tests/plugins/not_cached/ctoolsNotCachedPluginArray.class.php delete mode 100644 tests/plugins/not_cached/ctoolsNotCachedPluginArray2.class.php delete mode 100644 tests/plugins/not_cached/plugin_array.inc delete mode 100644 tests/plugins/not_cached/plugin_array2.inc delete mode 100644 tests/plugins/not_cached/plugin_array_dne.inc delete mode 100644 views_content/plugins/content_types/icon_views_block_legacy.png delete mode 100644 views_content/plugins/content_types/icon_views_page.png delete mode 100644 views_content/plugins/content_types/icon_views_page_legacy.png delete mode 100644 views_content/plugins/content_types/views.inc delete mode 100644 views_content/plugins/content_types/views_attachments.inc delete mode 100644 views_content/plugins/content_types/views_empty.inc delete mode 100644 views_content/plugins/content_types/views_exposed.inc delete mode 100644 views_content/plugins/content_types/views_feed.inc delete mode 100644 views_content/plugins/content_types/views_footer.inc delete mode 100644 views_content/plugins/content_types/views_header.inc delete mode 100644 views_content/plugins/content_types/views_pager.inc delete mode 100644 views_content/plugins/content_types/views_panes.inc delete mode 100644 views_content/plugins/content_types/views_row.inc delete mode 100644 views_content/plugins/contexts/view.inc delete mode 100644 views_content/plugins/relationships/node_from_view.inc delete mode 100644 views_content/plugins/relationships/term_from_view.inc delete mode 100644 views_content/plugins/relationships/user_from_view.inc delete mode 100644 views_content/plugins/views/views_content.views.inc delete mode 100644 views_content/plugins/views/views_content_plugin_display_ctools_context.inc delete mode 100644 views_content/plugins/views/views_content_plugin_display_panel_pane.inc delete mode 100644 views_content/plugins/views/views_content_plugin_style_ctools_context.inc delete mode 100644 views_content/views_content.admin.inc delete mode 100644 views_content/views_content.info delete mode 100644 views_content/views_content.module diff --git a/API.txt b/API.txt deleted file mode 100644 index f443e0d..0000000 --- a/API.txt +++ /dev/null @@ -1,12 +0,0 @@ -API.txt: $Id$ - -This file contains a log of changes to the API. -API Version 2.0 - Remove the deprecated callback-based behavior of the 'defaults' property on - plugin types; array addition is now the only option. If you need more - complex logic, do it with the 'process' callback. - Introduce a global plugin type registration hook and remove the per-plugin - type magic callbacks. - -Versions prior to 2.0 have been removed from this document. See the D6 version -for that information. diff --git a/CHANGELOG.txt b/CHANGELOG.txt deleted file mode 100644 index d14e621..0000000 --- a/CHANGELOG.txt +++ /dev/null @@ -1,81 +0,0 @@ -Current API VERSION: 2.0. See API.txt for more information. - -ctools 7.x-1.x-dev -================== -#1008120: "New custom content" shows empty form if custom content panes module is not enabled. -#999302 by troky: Fix jump menu. Apparently this wasn't actually committed the last time it was committed. -#1065976 by tekante and David_Rothstein: Reset plugin static cache during module enable to prevent stale data from harming export ui. - -ctools 7.x-1.x-alpha2 (05-Jan-2011) -=================================== - -#911396 by alex_b: Prevent notices in export UI. -#919768 by mikey_p: Allow url options to be sent to ctools_ajax_command_url(). -#358953 by cedarm: Allow term context to return lowercase, spaces to dashes versions of terms. -#931434 by EclipseGc: Argument plugin for node revision ID. -#910656: CTools AJAX sample wizard demo "domesticated" checkbox value not stored. -#922442 by EugenMayer, neclimdul and voxpelli: Make sure ctools_include can handle '' or NULL directory. -#919956 by traviss359: Correct example in wizard advanced help. -#942968: Fix taxonomy term access rule with tag term vocabs. -#840344: node add argument had crufty code causing notices. -#944462 by longhairedgit: Invalid character in regex causes rare notice. -#938778 by dereine: Fix profile content type for D7 updates. -Add detach event to modal close so that wysiwyg can detach the editor. -Variant titles showing up as blank if more than one variant on a page. -#940016: token support was not yet updated for D7. -#940446: Skip validation on back and cancel buttons in all wizards. -#954492: Redirect not always working in wizard.inc -#955348: Lack of redirect on "Update" button in Page Manager causing data loss sometimes. -#941778: Update and save button should not appear in the "Add variant" path. -#955070 by EclipseGc: Update ctools internal page tokens to work properly on content all content. -#956890 by EclipseGc: Update views_content to not use views dependency since that is gone. -#954728 by EclipseGc: Update node template page function name to not collide with new hook_node_view(). -#946534 by EclipseGc: Add support for field content on all entitities. -#952586 by EclipseGc: Fix node_author content type. -#959206: If a context is not set when rendering content, attempt to guess the context (fixes Views panes where "From context" was added but pane was never edited.) -#961654 by benshell: drupal_alter() only supports 4 arguments. -#911362 by alex_b: Facilitate plugin cache resets for tests. -#945360 by naxoc: node_tag_new() not updated to D7. -#953804 by EclipseGc: Fix node comment rendering. -#953542 by EclipseGc: Fix node rendering. -#953776 by EclipseGc: Fix node link rendering. -#954772 by EclipseGc: Fix node build mode selection in node content type. -#954762 by EclipseGc: Fix comment forbidden theme call. -#954894 by EclipseGc: Fix breadcrumb content type. -#955180 by EclipseGc: Fix page primary navigation type. -#957190 by EclipseGc: Fix page secondary navigation type. -#957194 by EclipseGc: Remove mission content type, since D7 no longer has a site mission. -#957348 by EclipseGc: Fix search form URL path. -#952586 by andypost: Use format_username for displaying unlinked usernames. -#963800 by benshell: Fix query to fetch custom block title. -#983496 by Amitaibu: Fix term argument to use proper load function. -#989484 by Amitaibu: Fix notice in views plugin. -#982496: Fix token context. -#995026: Fix export UI during enable/disable which would throw notices and not properly set/unset menu items. -#998870 by Amitaibu: Fix notice when content has no icon by using function already designed for that. -#983576 by Amitaibu: Node view fallback task showed white screen. -#1004644 by pillarsdotnet: Update a missed theme() call to D7. -#1006162 by aspilicious: .info file cleanup. -#998312 by dereine: Support the expanded/hidden options that Views did for dependent.js -#955030: Remove no longer supported footer message content type. -Fix broken query in term context config. -#992022 by pcambra: Fix node autocomplete. -#946302 by BerdArt and arywyr: Fix PHP 5.3 reference error. -#980528 by das-peter: Notice fix with entity settings. -#999302 by troky: ctools_jump_menu() needed updating to new form parameters. -#964174: stylizer plugin theme delegation was in the wrong place, causing errors. -#991658 by burlap: Fully load the "user" context for the logged in user because not all fields are in $user. -#1014866 by das-peter: Smarter title panes, notice fix on access plugin descriptions. -#1015662 by troky: plugin .info files were not using correct filepaths. -#941780 by EclipseGc: Restore the "No blocks" functionality. -#951048 by EclipseGc: Tighter entity integration so that new entities are automatic contexts and relationships. -#941800 by me and aspilicious: Use Drupal 7 #machine_name automation on page manager pages and all export_ui defaults. -Disabled exportables and pages not properly greyed out. -#969208 by me and benshell: Get user_view and user profile working. -#941796: Recategorize blocks - -ctools 7.x-1.x-alpha1 -===================== - -Changelog reset for 7.x -Basic conversion done during sprint. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..494c729 --- /dev/null +++ b/README.txt @@ -0,0 +1 @@ +The master branch is not used. See version branches. diff --git a/UPGRADE.txt b/UPGRADE.txt deleted file mode 100644 index 844ecce..0000000 --- a/UPGRADE.txt +++ /dev/null @@ -1,63 +0,0 @@ -Upgrading from ctools-6.x-1.x to ctools-7.x-2.x: - - - Remove ctools_ajax_associate_url_to_element as it shouldn't be necessary - with the new AJAX api's in Drupal core. - - - All calls to the ctools_ajax_command_prepend() should be replace with - the core function ajax_command_prepend(); - This is also the case for append, insert, after, before, replace, html, - and remove commands. - Each of these commands have been incorporated into the - Drupal.ajax.prototype.commands.insert - function with a corresponding parameter specifying which method to use. - - - All calls to ctools_ajax_render() should be replaced with calls to core - ajax_render(). Note that ctools_ajax_render() printed the json object and - exited, ajax_render() gives you this responsibility. - - ctools_ajax_render() - - becomes - - print ajax_render(); - exit; - - - All calls to ctools_static*() should be replaced with corresponding calls - to drupal_static*(). - - - All calls to ctools_css_add_css should be replaced with calls to - drupal_add_css(). Note that the arguments to drupal_add_css() have changed. - - - All wizard form builder functions must now return a form array(). - - - ctools_build_form is very close to being removed. In anticipation of this, - all $form_state['wrapper callback']s must now be - $form_state['wrapper_callback']. In addition to this $form_state['args'] - must now be $form_state['build_info']['args']. - - NOTE: Previously checking to see if the return from ctools_build_form() - is empty would be enough to see if the form was submitted. This is no - longer true. Please check for $form_state['executed']. If using a wizard - check for $form_state['complete']. - - - Plugin types now must be explicitly registered via a registration hook, - hook_ctools_plugin_type(); info once provided in magically-named functions - (e.g., ctools_ctools_plugin_content_types() was the old function to - provide plugin type info for ctools' content_type plugins) now must be - provided in that global hook. See http://drupal.org/node/910538 for more - details. - - - Plugins that use 'theme arguments' now use 'theme variables' instead. - - - Context, argument and relationship plugins now use 'add form' and/or - 'edit form' rather than 'settings form'. These plugins now support - form wizards just like content plugins. These forms now all take - $form, &$form_state as arguments, and the configuration for the plugin - can be found in $form_state['conf']. - - For all these forms, the submit handler MUST put appropriate data in - $form_state['conf']. Data will no longer be stored automatically. - - For all of these forms, the separate settings #trees in the form are now - gone, so form ids may be adjusted. Also, these are now all real forms - using CTools form wizard instead of fake subforms as previously. \ No newline at end of file diff --git a/bulk_export/bulk_export.css b/bulk_export/bulk_export.css deleted file mode 100644 index 41b0592..0000000 --- a/bulk_export/bulk_export.css +++ /dev/null @@ -1,17 +0,0 @@ - -div.export-container { - width: 48%; - float: left; - padding: .5em; -} - -div.export-container table { - width: 100%; -} - -div.export-container table input, -div.export-container table th, -div.export-container table td { - padding: 0 0 0 .5em; - margin: 0; -} \ No newline at end of file diff --git a/bulk_export/bulk_export.info b/bulk_export/bulk_export.info deleted file mode 100644 index 62077dc..0000000 --- a/bulk_export/bulk_export.info +++ /dev/null @@ -1,5 +0,0 @@ -name = Bulk Export -description = Performs bulk exporting of data objects known about by Chaos tools. -core = 7.x -dependencies[] = ctools -package = Chaos tool suite diff --git a/bulk_export/bulk_export.module b/bulk_export/bulk_export.module deleted file mode 100644 index 4804d91..0000000 --- a/bulk_export/bulk_export.module +++ /dev/null @@ -1,204 +0,0 @@ - array( - 'title' => t('Access Bulk Exporter'), - 'description' => t('Export various system objects into code.'), - ), - ); -} - -/** - * Implements hook_menu(). - */ -function bulk_export_menu() { - $items['admin/structure/bulk-export'] = array( - 'title' => 'Bulk Exporter', - 'description' => 'Bulk-export multiple CTools-handled data objects to code.', - 'access arguments' => array('use bulk exporter'), - 'page callback' => 'bulk_export_export', - ); - $items['admin/structure/bulk-export/results'] = array( - 'access arguments' => array('use bulk exporter'), - 'page callback' => 'bulk_export_export', - 'type' => MENU_CALLBACK, - ); - return $items; -} - -/** - * FAPI gateway to the bulk exporter. - */ -function bulk_export_export() { - ctools_include('export'); - $schemas = ctools_export_get_schemas(TRUE); - $exportables = $export_tables = array(); - - foreach ($schemas as $table => $schema) { - if (!empty($schema['export']['list callback']) && function_exists($schema['export']['list callback'])) { - $exportables[$table] = $schema['export']['list callback'](); - } - else { - $exportables[$table] = ctools_export_default_list($table, $schema); - } - natcasesort($exportables[$table]); - $export_tables[$table] = $schema['module']; - } - if ($exportables) { - $form_state = array( - 're_render' => FALSE, - 'no_redirect' => TRUE, - 'exportables' => $exportables, - 'export_tables' => $export_tables, - ); - $output = drupal_build_form('bulk_export_export_form', $form_state); - if (!empty($form_state['submitted'])) { - drupal_set_title(t('Bulk export results')); - $output = ''; - $module_code = ''; - $api_code = ''; - $dependencies = array(); - foreach ($form_state['code'] as $module => $api_info) { - if ($module == 'general') { - $module_code .= $api_info; - } - else { - foreach ($api_info as $api => $info) { - $api_code .= " if (\$module == '$module' && \$api == '$api') {\n"; - $api_code .= " return array('version' => $info[version]);\n"; - $api_code .= " }\n"; - $dependencies[$module] = TRUE; - - $file = $form_state['module'] . '.' . $api . '.inc'; - $code = " $file)))); - } - } - } - - // Add hook_ctools_plugin_api at the top of the module code, if there is any. - if ($api_code) { - $api = "/**\n"; - $api .= " * Implements hook_ctools_plugin_api().\n"; - $api .= " */\n"; - $api .= "function $form_state[module]_ctools_plugin_api(\$module, \$api) {\n"; - $api .= $api_code; - $api .= "}\n"; - $module_code = $api . $module_code; - } - - if ($module_code) { - $module = " $form_state['module'] . '.module')))) . $output; - } - - $info = "; \$Id" . ": $\n"; // The break in the string prevents CVS from subbing the ID. - $info .= strtr("name = @module export module\n", array('@module' => $form_state['module'])); - $info .= strtr("description = Export objects from CTools\n", array('@module' => $form_state['values']['name'])); - foreach ($dependencies as $module => $junk) { - $info .= "dependencies[] = $module\n"; - } - $info .= "package = Chaos tool suite\n"; - $info .= "core = 7.x\n"; - $info .= "files[] = " . check_plain($form_state['module'] . '.info') . "\n"; - $output = drupal_render(drupal_get_form('ctools_export_form', $info, t('Place this in @file', array('@file' => $form_state['module'] . '.info')))) . $output; - - } - - return $output; - } - else { - return t('There are no objects to be exported at this time.'); - } -} - -/** - * FAPI definition for the bulk exporter form. - * - */ -function bulk_export_export_form($form, &$form_state) { - $form['tables'] = array( - '#prefix' => '
', - '#suffix' => '
', - '#tree' => TRUE, - ); - - $files = system_rebuild_module_data(); - - $options = array(); - foreach ($form_state['exportables'] as $table => $list) { - if (empty($list)) { - continue; - } - - foreach ($list as $id => $title) { - $options[$table][$id] = array($title); - } - - $module = $form_state['export_tables'][$table]; - $header = array("{$files[$module]->info['name']}: $table"); - - $form['tables'][$table] = array( - '#prefix' => '
', - '#suffix' => '
', - '#type' => 'tableselect', - '#header' => $header, - '#options' => $options[$table], - ); - } - - $form['name'] = array( - '#type' => 'textfield', - '#title' => t('Module name'), - '#description' => t('Enter the module name to export code to.'), - ); - - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Export'), - ); - - $form['#action'] = url('admin/structure/bulk-export/results'); - $form['#attached']['css'][] = drupal_get_path('module', 'bulk_export') . '/bulk_export.css'; - return $form; -} - -/** - * Process the bulk export submit form and make the results available. - */ -function bulk_export_export_form_submit($form, &$form_state) { - $code = array(); - $name = empty($form_state['values']['name']) ? 'foo' : $form_state['values']['name']; - - foreach ($form_state['values']['tables'] as $table => $names) { - $names = array_keys(array_filter($names)); - if ($names) { - natcasesort($names); - ctools_export_to_hook_code($code, $table, $names, $name); - } - } - - $form_state['code'] = $code; - $form_state['module'] = $name; -} diff --git a/css/collapsible-div.css b/css/collapsible-div.css deleted file mode 100644 index 91e7876..0000000 --- a/css/collapsible-div.css +++ /dev/null @@ -1,18 +0,0 @@ - -.ctools-collapsible-container .ctools-toggle { - float: left; - width: 21px; - height: 21px; - cursor: pointer; - background-position: 7px 7px; - background-repeat: no-repeat; - background-image: url(../images/collapsible-expanded.png); -} - -.ctools-collapsible-container .ctools-collapsible-handle { - cursor: pointer; -} - -.ctools-collapsible-container .ctools-toggle-collapsed { - background-image: url(../images/collapsible-collapsed.png); -} diff --git a/css/context.css b/css/context.css deleted file mode 100644 index 5093104..0000000 --- a/css/context.css +++ /dev/null @@ -1,10 +0,0 @@ -.ctools-context-holder .ctools-context-title { - float: left; - width: 49%; - font-style: italic; -} - -.ctools-context-holder .ctools-context-content { - float: right; - width: 49%; -} diff --git a/css/ctools.css b/css/ctools.css deleted file mode 100644 index 7372988..0000000 --- a/css/ctools.css +++ /dev/null @@ -1,25 +0,0 @@ -.ctools-locked { - color: red; - border: 1px solid red; - padding: 1em; -} - -.ctools-owns-lock { - background: #FFFFDD none repeat scroll 0 0; - border: 1px solid #F0C020; - padding: 1em; -} - -a.ctools-ajaxing, -input.ctools-ajaxing, -button.ctools-ajaxing, -select.ctools-ajaxing { - padding-right: 18px !important; - background: url(../images/status-active.gif) right center no-repeat; -} - -div.ctools-ajaxing { - float: left; - width: 18px; - background: url(../images/status-active.gif) center center no-repeat; -} diff --git a/css/dropdown.css b/css/dropdown.css deleted file mode 100644 index bb50f3f..0000000 --- a/css/dropdown.css +++ /dev/null @@ -1,73 +0,0 @@ -html.js div.ctools-dropdown div.ctools-dropdown-container { - z-index: 1001; - display: none; - text-align: left; - position: absolute; -} - -html.js div.ctools-dropdown div.ctools-dropdown-container ul li a { - display: block; -} - -html.js div.ctools-dropdown div.ctools-dropdown-container ul { - list-style-type: none; - margin: 0; - padding: 0; -} - -html.js div.ctools-dropdown div.ctools-dropdown-container ul li { - display: block; - /* prevent excess right margin in IE */ - margin-right: 0; - margin-left: 0; - padding-right: 0; - padding-left: 0; - background-image: none; /* prevent list backgrounds from mucking things up */ -} - -.ctools-dropdown-no-js .ctools-dropdown-link, -.ctools-dropdown-no-js span.text { - display: none; -} - -/* Everything from here down is purely visual style and can be overridden. */ - -html.js div.ctools-dropdown a.ctools-dropdown-text-link { - background: url(../images/collapsible-expanded.png) 3px 5px no-repeat; - padding-left: 12px; -} - -html.js div.ctools-dropdown div.ctools-dropdown-container { - width: 175px; - background: #fff; - border: 1px solid black; - margin: 4px 1px 0 0; - padding: 0; - color: #494949; -} - -html.js div.ctools-dropdown div.ctools-dropdown-container ul li li a { - padding-left: 25px; - width: 150px; - color: #027AC6; -} - -html.js div.ctools-dropdown div.ctools-dropdown-container ul li a { - text-decoration: none; - padding-left: 5px; - width: 170px; - color: #027AC6; -} - -html.js div.ctools-dropdown div.ctools-dropdown-container ul li span { - display: block; -} - -html.js div.ctools-dropdown div.ctools-dropdown-container ul li span.text { - font-style: italic; - padding-left: 5px; -} - -html.js .ctools-dropdown-hover { - background-color: #ECECEC; -} diff --git a/css/export-ui-list.css b/css/export-ui-list.css deleted file mode 100644 index 8f7ef5e..0000000 --- a/css/export-ui-list.css +++ /dev/null @@ -1,32 +0,0 @@ -body form#ctools-export-ui-list-form { - margin: 0 0 20px 0; -} - -#ctools-export-ui-list-form .form-item { - padding-right: 1em; /* LTR */ - float: left; /* LTR */ - margin-top: 0; - margin-bottom: 0; -} - -#ctools-export-ui-list-items { - width: 100%; -} - -#edit-order-wrapper { - clear: left; /* LTR */ -} - -#ctools-export-ui-list-form .form-submit { - margin-top: 1.65em; - float: left; /* LTR */ -} - -tr.ctools-export-ui-disabled td { - color: #999; -} - -th.ctools-export-ui-operations, -td.ctools-export-ui-operations { - text-align: right; /* LTR */ -} diff --git a/css/modal.css b/css/modal.css deleted file mode 100644 index c81a0f2..0000000 --- a/css/modal.css +++ /dev/null @@ -1,127 +0,0 @@ -div.ctools-modal-content { - background: #fff; - color: #000; - padding: 0; - margin: 2px; - border: 1px solid #000; - width: 600px; - text-align: left; -} - -div.ctools-modal-content .modal-title { - font-size: 120%; - font-weight: bold; - color: white; - overflow: hidden; - white-space: nowrap; -} - -div.ctools-modal-content .modal-header { - background-color: #2385c2; - padding: 0 .25em 0 1em; -} - -div.ctools-modal-content .modal-header a { - color: white; - float: right; -} - -div.ctools-modal-content .modal-content { - padding: 1em 1em 0 1em; - overflow: auto; - position: relative; /* Keeps IE7 from flowing outside the modal. */ -} - -div.ctools-modal-content .modal-form { -} - -div.ctools-modal-content a.close { - color: white; -} - -div.ctools-modal-content a.close:hover { - text-decoration: none; -} - -div.ctools-modal-content a.close img { - position: relative; - top: 1px; -} - -div.ctools-modal-content .modal-content .modal-throbber-wrapper { - text-align: center; -} - -div.ctools-modal-content .modal-content .modal-throbber-wrapper img { - margin-top: 160px; -} - -/** modal forms CSS **/ -div.ctools-modal-content .form-item label { - width: 15em; - float: left; -} - -div.ctools-modal-content .form-item label.option { - width: auto; - float: none; -} - -div.ctools-modal-content .form-item .description { - clear: left; -} - -div.ctools-modal-content .form-item .description .tips { - margin-left: 2em; -} - -div.ctools-modal-content .no-float .form-item * { - float: none; -} - -div.ctools-modal-content .modal-form .no-float label { - width: auto; -} - -div.ctools-modal-content fieldset, -div.ctools-modal-content .form-radios, -div.ctools-modal-content .form-checkboxes { - clear: left; -} - -div.ctools-modal-content .resizable-textarea { - width: auto; - margin-left: 15em; - margin-right: 5em; -} - -div.ctools-modal-content .container-inline .form-item { - margin-right: 2em; -} - -#views-exposed-pane-wrapper .form-item { - margin-top: 0; - margin-bottom: 0; -} - -div.ctools-modal-content label.hidden-options { - background: transparent url(../images/arrow-active.png) no-repeat right; - height: 12px; - padding-right: 12px; -} - -div.ctools-modal-content label.expanded-options { - background: transparent url(../images/expanded-options.png) no-repeat right; - height: 12px; - padding-right: 16px; -} - -div.ctools-modal-content .option-text-aligner label.expanded-options, -div.ctools-modal-content .option-text-aligner label.hidden-options { - background: none; -} - - -div.ctools-modal-content .dependent-options { - padding-left: 30px; -} diff --git a/css/ruleset.css b/css/ruleset.css deleted file mode 100644 index 891455f..0000000 --- a/css/ruleset.css +++ /dev/null @@ -1,11 +0,0 @@ -.ctools-right-container { - float: right; - padding: 0 0 0 .5em; - margin: 0; - width: 48.5%; -} - -.ctools-left-container { - padding-right: .5em; - width: 48.5%; -} diff --git a/css/stylizer.css b/css/stylizer.css deleted file mode 100644 index a16ec78..0000000 --- a/css/stylizer.css +++ /dev/null @@ -1,129 +0,0 @@ - -/* Farbtastic placement */ -.color-form { - max-width: 50em; - position: relative; - min-height: 195px; -} -#placeholder { -/* - position: absolute; - top: 0; - right: 0; -*/ - margin: 0 auto; - width: 195px; -} - -/* Palette */ -.color-form .form-item { - height: 2em; - line-height: 2em; - padding-left: 1em; /* LTR */ - margin: 0.5em 0; -} - -.color-form .form-item input { - margin-top: .2em; -} - -.color-form label { - float: left; /* LTR */ - clear: left; /* LTR */ - width: 14em; -} -.color-form .form-text, .color-form .form-select { - float: left; /* LTR */ -} -.color-form .form-text { - text-align: center; - margin-right: 5px; /* LTR */ - cursor: pointer; -} - -#palette .hook { - float: left; /* LTR */ - margin-top: 3px; - width: 16px; - height: 16px; -} -#palette .up { - background-position: 100% -27px; /* LTR */ -} -#palette .both { - background-position: 100% -54px; /* LTR */ -} - - -#palette .form-item { - width: 24em; -} -#palette .item-selected { - background: #eee; -} - -/* Preview */ -#preview { - width: 45%; - float: right; - margin: 0; -} - -#ctools_stylizer_color_scheme_form { - float: left; - width: 45%; - margin: 0; -} - -/* general style for the layout-icon */ -.ctools-style-icon .caption { - width: 100px; - margin-bottom: 1em; - line-height: 1em; - text-align: center; - cursor: default; -} - -.ctools-style-icons .form-item { - width: 100px; - float: left; - margin: 0 3px !important; -} - -.ctools-style-icons .form-item .ctools-style-icon { - float: none; - height: 150px; - width: 100px; -} - -.ctools-style-icons .form-item label.option { - width: 100px; - display: block; - text-align: center; -} - -.ctools-style-icons .form-item label.option input { - margin: 0 auto; -} - -.ctools-style-icons .ctools-style-category { - height: 190px; -} - -.ctools-style-icons .ctools-style-category label { - font-weight: bold; - width: 100%; - float: left; -} - -/** - * Stylizer font editor widget - */ -.ctools-stylizer-spacing-form .form-item { - float: left; - margin: .25em; -} - -#edit-font-font { - width: 9em; -} diff --git a/css/wizard.css b/css/wizard.css deleted file mode 100644 index d42a2db..0000000 --- a/css/wizard.css +++ /dev/null @@ -1,8 +0,0 @@ - -.wizard-trail { - font-size: 120%; -} - -.wizard-trail-current { - font-weight: bold; -} diff --git a/ctools.api.php b/ctools.api.php deleted file mode 100644 index 93efd6f..0000000 --- a/ctools.api.php +++ /dev/null @@ -1,86 +0,0 @@ -/plugins/content_types directory for .inc plugin files. - if ($owner == 'ctools' && $plugin_type == 'content_types') { - return 'plugins/content_types'; - } - - // Form 2 - if your module implements only Panels plugins, and has 'layouts' - // and 'styles' plugins but no 'cache' or 'display_renderers', it is OK to be - // lazy and return a directory for a plugin you don't actually implement (so - // long as that directory doesn't exist). This lets you avoid ugly in_array() - // logic in your conditional, and also makes it easy to add plugins of those - // types later without having to change this hook implementation. - if ($owner == 'panels') { - return "plugins/$plugin_type"; - } - - // Form 3 - CTools makes no assumptions about where your plugins are located, - // so you still have to implement this hook even for plugins created by your - // own module. - if ($owner == 'mymodule') { - // Yes, this is exactly like Form 2 - just a different reasoning for it. - return "plugins/$plugin_type"; - } - // Finally, if nothing matches, it's safe to return nothing at all (or NULL). -} - -/** - * @} End of "addtogroup hooks". - */ \ No newline at end of file diff --git a/ctools.info b/ctools.info deleted file mode 100644 index b2c54ad..0000000 --- a/ctools.info +++ /dev/null @@ -1,7 +0,0 @@ -name = Chaos tools -description = A library of helpful tools by Merlin of Chaos. -core = 7.x -package = Chaos tool suite -files[] = includes/context.inc -files[] = includes/math-expr.inc -files[] = includes/stylizer.inc diff --git a/ctools.install b/ctools.install deleted file mode 100644 index e4447db..0000000 --- a/ctools.install +++ /dev/null @@ -1,197 +0,0 @@ - t('CTools CSS Cache'), - 'severity' => REQUIREMENT_OK, - 'value' => t('Exists'), - ); - - $path = 'public://ctools/css'; - if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) { - $requirements['ctools_css_cache']['description'] = t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array('%path' => file_uri_target($path))); - $requirements['ctools_css_cache']['severity'] = REQUIREMENT_ERROR; - $requirements['ctools_css_cache']['value'] = t('Unable to create'); - } - - if (!function_exists('error_get_last')) { - $requirements['ctools_php_52']['title'] = t('CTools PHP requirements'); - $requirements['ctools_php_52']['description'] = t('CTools requires certain features only available in PHP 5.2.0 or higher.'); - $requirements['ctools_php_52']['severity'] = REQUIREMENT_WARNING; - $requirements['ctools_php_52']['value'] = t('PHP !version', array('!version' => phpversion())); - } - } - - return $requirements; -} - -/** - * Implements hook_schemea - */ -function ctools_schema() { - return ctools_schema_2(); -} - -/** - * Version 2 of the CTools schema. - */ -function ctools_schema_2() { - $schema = ctools_schema_1(); - - // update the 'name' field to be 128 bytes long: - $schema['ctools_object_cache']['fields']['name']['length'] = 128; - - // DO NOT MODIFY THIS TABLE -- this definition is used to create the table. - // Changes to this table must be made in schema_3 or higher. - $schema['ctools_css_cache'] = array( - 'description' => 'A special cache used to store CSS that must be non-volatile.', - 'fields' => array( - 'cid' => array( - 'type' => 'varchar', - 'length' => '128', - 'description' => 'The CSS ID this cache object belongs to.', - 'not null' => TRUE, - ), - 'filename' => array( - 'type' => 'varchar', - 'length' => '255', - 'description' => 'The filename this CSS is stored in.', - ), - 'css' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'CSS being stored.', - 'serialize' => TRUE, - ), - 'filter' => array( - 'type' => 'int', - 'size' => 'tiny', - 'description' => 'Whether or not this CSS needs to be filtered.', - ), - ), - 'primary key' => array('cid'), - ); - - return $schema; -} - -/** - * CTools' initial schema; separated for the purposes of updates. - * - * DO NOT MAKE CHANGES HERE. This schema version is locked. - */ -function ctools_schema_1() { - $schema['ctools_object_cache'] = array( - 'description' => t('A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.'), - 'fields' => array( - 'sid' => array( - 'type' => 'varchar', - 'length' => '64', - 'not null' => TRUE, - 'description' => 'The session ID this cache object belongs to.', - ), - 'name' => array( - 'type' => 'varchar', - 'length' => '32', - 'not null' => TRUE, - 'description' => 'The name of the object this cache is attached to.', - ), - 'obj' => array( - 'type' => 'varchar', - 'length' => '32', - 'not null' => TRUE, - 'description' => 'The type of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.', - ), - 'updated' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The time this cache was created or updated.', - ), - 'data' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Serialized data being stored.', - 'serialize' => TRUE, - ), - ), - 'primary key' => array('sid', 'obj', 'name'), - 'indexes' => array('updated' => array('updated')), - ); - return $schema; -} - -/** - * Enlarge the ctools_object_cache.name column to prevent truncation and weird - * errors. - */ -function ctools_update_6001() { - // Perform updates like this to reduce code duplication. - $schema = ctools_schema_2(); - - db_change_field('ctools_object_cache', 'name', 'name', $schema['ctools_object_cache']['fields']['name']); -} - -/** - * Add the new css cache table. - */ -function ctools_update_6002() { - // Schema 2 is locked and should not be changed. - $schema = ctools_schema_2(); - - db_create_table('ctools_css_cache', $schema['ctools_css_cache']); -} - -/** - * Take over for the panels_views module if it was on. - */ -function ctools_update_6003() { - $result = db_query('SELECT status FROM {system} WHERE name = :name', array(':name' => 'panels_views'))->fetchField(); - if ($result) { - db_delete('system')->condition('name', 'panels_views')->execute(); - drupal_install_modules(array('views_content')); - } -} - -/** - * Add primary key to the ctools_object_cache table. - */ -function ctools_update_6004() { - db_add_primary_key('ctools_object_cache', array('sid', 'obj', 'name')); - db_drop_index('ctools_object_cache', 'sid_obj_name'); -} - -/** - * Removed update. - */ -function ctools_update_6005() { - return array(); -} - -/** - * ctools_custom_content table was originally here, but is now moved to - * its own module. - */ -function ctools_update_6007() { - $ret = array(); - if (db_table_exists('ctools_custom_content')) { - // Enable the module to make everything as seamless as possible. - drupal_install_modules(array('ctools_custom_content')); - } - - return $ret; -} - - diff --git a/ctools.module b/ctools.module deleted file mode 100644 index b6e6e2c..0000000 --- a/ctools.module +++ /dev/null @@ -1,782 +0,0 @@ - $t('MODULENAME required Chaos Tool Suite (CTools) API Version'), - * 'value' => t('Between @a and @b', array('@a' => MODULENAME_MINIMUM_CTOOLS_API_VERSION, '@b' => MODULENAME_MAXIMUM_CTOOLS_API_VERSION)), - * 'severity' => REQUIREMENT_ERROR, - * ); - * } - * return $requirements; - * } - * @endcode - * - * Please note that the version is a string, not an floating point number. - * This will matter once CTools reaches version 1.10. - * - * A CTools API changes history will be kept in API.txt. Not every new - * version of CTools will necessarily update the API version. - * @param $minimum - * The minimum version of CTools necessary for your software to run with it. - * @param $maximum - * The maximum version of CTools allowed for your software to run with it. - */ -function ctools_api_version($minimum, $maximum = NULL) { - if (version_compare(CTOOLS_API_VERSION, $minimum, '<')) { - return FALSE; - } - - if (isset($maximum) && version_compare(CTOOLS_API_VERSION, $maximum, '>')) { - return FALSE; - } - - return TRUE; -} - -// ----------------------------------------------------------------------- -// General utility functions - -/** - * Include .inc files as necessary. - * - * This fuction is helpful for including .inc files for your module. The - * general case is including ctools funcitonality like this: - * - * @code - * ctools_include('plugins'); - * @endcode - * - * Similar funcitonality can be used for other modules by providing the $module - * and $dir arguments like this: - * - * @code - * // include mymodule/includes/import.inc - * ctools_include('import', 'mymodule'); - * // include mymodule/plugins/foobar.inc - * ctools_include('foobar', 'mymodule', 'plugins'); - * @endcode - * - * @param $file - * The base file name to be included. - * @param $module - * Optional module containing the include. - * @param $dir - * Optional subdirectory containing the include file. - */ -function ctools_include($file, $module = 'ctools', $dir = 'includes') { - static $used = array(); - - $dir = '/' . ($dir ? $dir . '/' : ''); - - if (!isset($used[$module][$dir][$file])) { - require_once DRUPAL_ROOT . '/' . drupal_get_path('module', $module) . "$dir$file.inc"; - $used[$module][$dir][$file] = true; - } -} - -/** - * Include .inc files in a form context. - * - * This is a variant of ctools_include that will save information in the - * the form_state so that cached forms will properly include things. - */ -function ctools_form_include(&$form_state, $file, $module = 'ctools', $dir = 'includes') { - $dir = '/' . ($dir ? $dir . '/' : ''); - form_load_include($form_state, 'inc', $module, $dir . $file); -} - -/** - * Provide the proper path to an image as necessary. - * - * This helper function is used by ctools but can also be used in other - * modules in the same way as explained in the comments of ctools_include. - * - * @param $image - * The base file name (with extension) of the image to be included. - * @param $module - * Optional module containing the include. - * @param $dir - * Optional subdirectory containing the include file. - */ -function ctools_image_path($image, $module = 'ctools', $dir = 'images') { - return drupal_get_path('module', $module) . "/$dir/" . $image; -} - -/** - * Include css files as necessary. - * - * This helper function is used by ctools but can also be used in other - * modules in the same way as explained in the comments of ctools_include. - * - * @param $file - * The base file name to be included. - * @param $module - * Optional module containing the include. - * @param $dir - * Optional subdirectory containing the include file. - */ -function ctools_add_css($file, $module = 'ctools', $dir = 'css') { - drupal_add_css(drupal_get_path('module', $module) . "/$dir/$file.css"); -} - -/** - * Format a css file name for use with $form['#attached']['css']. - * - * This helper function is used by ctools but can also be used in other - * modules in the same way as explained in the comments of ctools_include. - * - * @code - * $form['#attached']['css'] = array(ctools_attach_css('collapsible-div')); - * $form['#attached']['css'][ctools_attach_css('collapsible-div')] = array('preprocess' => FALSE); - * @endcode - * - * @param $file - * The base file name to be included. - * @param $module - * Optional module containing the include. - * @param $dir - * Optional subdirectory containing the include file. - */ -function ctools_attach_css($file, $module = 'ctools', $dir = 'css') { - return drupal_get_path('module', $module) . "/$dir/$file.css"; -} - -/** - * Include js files as necessary. - * - * This helper function is used by ctools but can also be used in other - * modules in the same way as explained in the comments of ctools_include. - * - * @param $file - * The base file name to be included. - * @param $module - * Optional module containing the include. - * @param $dir - * Optional subdirectory containing the include file. - */ -function ctools_add_js($file, $module = 'ctools', $dir = 'js') { - drupal_add_js(drupal_get_path('module', $module) . "/$dir/$file.js"); -} - -/** - * Format a javascript file name for use with $form['#attached']['js']. - * - * This helper function is used by ctools but can also be used in other - * modules in the same way as explained in the comments of ctools_include. - * - * @code - * $form['#attached']['js'] = array(ctools_attach_js('auto-submit')); - * @endcode - * - * @param $file - * The base file name to be included. - * @param $module - * Optional module containing the include. - * @param $dir - * Optional subdirectory containing the include file. - */ -function ctools_attach_js($file, $module = 'ctools', $dir = 'js') { - return drupal_get_path('module', $module) . "/$dir/$file.js"; -} - -/** - * Get a list of roles in the system. - * - * @return - * An array of role names keyed by role ID. - */ -function ctools_get_roles() { - static $roles = NULL; - if (!isset($roles)) { - $roles = user_roles(TRUE); - unset($roles[DRUPAL_AUTHENTICATED_RID]); - } - - return $roles; -} - -/* - * Break x,y,z and x+y+z into an array. Numeric only. - * - * @param $str - * The string to parse. - * - * @return $object - * An object containing - * - operator: Either 'and' or 'or' - * - value: An array of numeric values. - */ -function ctools_break_phrase($str) { - $object = new stdClass(); - - if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str)) { - // The '+' character in a query string may be parsed as ' '. - $object->operator = 'or'; - $object->value = preg_split('/[+ ]/', $str); - } - else if (preg_match('/^([0-9]+,)*[0-9]+$/', $str)) { - $object->operator = 'and'; - $object->value = explode(',', $str); - } - - // Keep an 'error' value if invalid strings were given. - if (!empty($str) && (empty($object->value) || !is_array($object->value))) { - $object->value = array(-1); - $object->invalid_input = TRUE; - return $object; - } - - if (empty($object->value)) { - $object->value = array(); - } - - // Doubly ensure that all values are numeric only. - foreach ($object->value as $id => $value) { - $object->value[$id] = intval($value); - } - - return $object; -} - -/** - * Set a token/value pair to be replaced later in the request, specifically in - * ctools_preprocess_page(). - * - * @param $token - * The token to be replaced later, during page rendering. This should - * ideally be a string inside of an HTML comment, so that if there is - * no replacement, the token will not render on the page. - * @param $type - * The type of the token. Can be either 'variable', which will pull data - * directly from the page variables - * @param $argument - * If $type == 'variable' then argument should be the key to fetch from - * the $variables. If $type == 'callback' then it should either be the - * callback, or an array that will be sent to call_user_func_array(). - * - * @return - * A array of token/variable names to be replaced. - */ -function ctools_set_page_token($token = NULL, $type = NULL, $argument = NULL) { - static $tokens = array(); - - if (isset($token)) { - $tokens[$token] = array($type, $argument); - } - return $tokens; -} - -/** - * Easily set a token from the page variables. - * - * This function can be used like this: - * $token = ctools_set_variable_token('tabs'); - * - * $token will then be a simple replacement for the 'tabs' about of the - * variables available in the page template. - */ -function ctools_set_variable_token($token) { - $string = ''; - ctools_set_page_token($string, 'variable', $token); - return $string; -} - -/** - * Easily set a token from the page variables. - * - * This function can be used like this: - * $token = ctools_set_variable_token('id', 'mymodule_myfunction'); - */ -function ctools_set_callback_token($token, $callback) { - $string = ''; - ctools_set_page_token($string, 'callback', $callback); - return $string; -} - -/** - * Tell CTools that sidebar blocks should not be rendered. - * - * It is often desirable to not display sidebars when rendering a page, - * particularly when using Panels. This informs CTools to alter out any - * sidebar regions during block render. - */ -function ctools_set_no_blocks($blocks = FALSE) { - $status = &drupal_static(__FUNCTION__, TRUE); - $status = $blocks; -} - -// ----------------------------------------------------------------------- -// Drupal core hooks - -/** - * Implement hook_init to keep our global CSS at the ready. - */ -function ctools_init() { - ctools_add_css('ctools'); - // If we are sure that CTools' AJAX is in use, change the error handling. - if (!empty($_REQUEST['ctools_ajax'])) { - ini_set('display_errors', 0); - register_shutdown_function('ctools_shutdown_handler'); - } - - // Clear plugin cache on the module page submit. - if ($_GET['q'] == 'admin/modules/list/confirm' && !empty($_POST)) { - cache_clear_all('ctools_plugin_files:', 'cache', TRUE); - } -} - -/** - * Shutdown handler used during ajax operations to help catch fatal errors. - */ -function ctools_shutdown_handler() { - if (function_exists('error_get_last') AND ($error = error_get_last())){ - switch($error['type']){ - case E_ERROR: - case E_CORE_ERROR: - case E_COMPILE_ERROR: - case E_USER_ERROR: - // Do this manually because including files here is dangerous. - $commands = array( - array( - 'command' => 'alert', - 'title' => t('Error'), - 'text' => t('Unable to complete operation. Fatal error in @file on line @line: @message', array( - '@file' => $error['file'], - '@line' => $error['line'], - '@message' => $error['message'], - )), - ), - ); - - // Change the status code so that the client will read the AJAX returned. - header('HTTP/1.1 200 OK'); - drupal_json($commands); - } - } -} - -/** - * Implements hook_theme(). - */ -function ctools_theme() { - ctools_include('utility'); - $items = array(); - _ctools_passthrough($items, 'theme'); - return $items; -} - -/** - * Implements hook_menu(). - */ -function ctools_menu() { - ctools_include('utility'); - $items = array(); - _ctools_passthrough($items, 'menu'); - return $items; -} - -/** - * Implementation of hook_cron. Clean up old caches. - */ -function ctools_cron() { - ctools_include('utility'); - _ctools_passthrough($items, 'cron'); -} - -/** - * Ensure the CTools CSS cache is flushed whenever hook_flush_caches is invoked. - */ -function ctools_flush_caches() { - // Do not actually flush caches if running on cron. Drupal uses this hook - // in an inconsistent fashion and it does not necessarily mean to *flush* - // caches when running from cron. Instead it's just getting a list of cache - // tables and may not do any flushing. - if (variable_get('cron_semaphore', FALSE)) { - return; - } - - ctools_include('css'); - ctools_css_flush_caches(); -} - -/** - * Provide a search form with a different id so that form_alters will miss it - * and thus not get advanced search settings. - */ -function ctools_forms() { - $forms['ctools_search_form']= array( - 'callback' => 'search_form', - ); - - return $forms; -} - -/** - * Implementation of hook_file_download() - * - * When using the private file system, we have to let Drupal know it's ok to - * download CSS and image files from our temporary directory. - */ -function ctools_file_download($filepath) { - if (strpos($filepath, 'ctools') === 0) { - $mime = file_get_mimetype($filepath); - // For safety's sake, we allow only text and images. - if (strpos($mime, 'text') === 0 || strpos($mime, 'image') === 0) { - return array('Content-type:' . $mime); - } - } -} - -/** - * Implements hook_registry_files_alter(). - * - * Alter the registry of files to automagically include all classes in - * class-based plugins. - */ -function ctools_registry_files_alter(&$files, $indexed_modules) { - ctools_include('registry'); - return _ctools_registry_files_alter($files, $indexed_modules); -} - -// ----------------------------------------------------------------------- -// CTools hook implementations. - -/** - * Implementation of hook_ctools_plugin_directory() to let the system know - * where all our own plugins are. - */ -function ctools_ctools_plugin_directory($owner, $plugin_type) { - if ($owner == 'ctools') { - return 'plugins/' . $plugin_type; - } -} - -/** - * Implements hook_ctools_plugin_type(). - */ -function ctools_ctools_plugin_type() { - ctools_include('utility'); - $items = array(); - // Add all the plugins that have their own declaration space elsewhere. - _ctools_passthrough($items, 'plugin-type'); - - return $items; -} - -// ----------------------------------------------------------------------- -// Drupal theme preprocess hooks that must be in the .module file. - -/** - * A theme preprocess function to automatically allow panels-based node - * templates based upon input when the panel was configured. - */ -function ctools_preprocess_node(&$vars) { - // The 'panel_identifier' attribute of the node is added when the pane is - // rendered. - if (!empty($vars['node']->panel_identifier)) { - $vars['panel_identifier'] = check_plain($vars['node']->panel_identifier); - $vars['template_files'][] = 'node-panel-' . check_plain($vars['node']->panel_identifier); - } -} - -function ctools_page_alter(&$page) { - $page['#post_render'][] = 'ctools_page_token_processing'; -} - -/** - * A theme post_render callback to allow content type plugins to use page - * template variables which are not yet available when the content type is - * rendered. - */ -function ctools_page_token_processing($children, $elements) { - $tokens = ctools_set_page_token(); - if (!empty($tokens)) { - foreach ($tokens as $token => $key) { - list($type, $argument) = $key; - switch ($type) { - case 'variable': - $tokens[$token] = isset($variables[$argument]) ? $variables[$argument] : ''; - break; - case 'callback': - if (is_string($argument) && function_exists($argument)) { - $tokens[$token] = $argument($variables); - } - if (is_array($argument) && function_exists($argument[0])) { - $function = array_shift($argument); - $argument = array_merge(array(&$variables), $argument); - $tokens[$token] = call_user_func_array($function, $argument); - } - break; - } - } - $children = strtr($children, $tokens); - } - return $children; -} - -// ----------------------------------------------------------------------- -// Menu callbacks that must be in the .module file. - -/** - * Determine if the current user has access via a plugin. - * - * This function is meant to be embedded in the Drupal menu system, and - * therefore is in the .module file since sub files can't be loaded, and - * takes arguments a little bit more haphazardly than ctools_access(). - * - * @param $access - * An access control array which contains the following information: - * - 'logic': and or or. Whether all tests must pass or one must pass. - * - 'plugins': An array of access plugins. Each contains: - * - - 'name': The name of the plugin - * - - 'settings': The settings from the plugin UI. - * - - 'context': Which context to use. - * @param ... - * zero or more context arguments generated from argument plugins. These - * contexts must have an 'id' attached to them so that they can be - * properly associated. The argument plugin system should set this, but - * if the context is coming from elsewhere it will need to be set manually. - * - * @return - * TRUE if access is granted, false if otherwise. - */ -function ctools_access_menu($access) { - // Short circuit everything if there are no access tests. - if (empty($access['plugins'])) { - return TRUE; - } - - $contexts = array(); - foreach (func_get_args() as $arg) { - if (is_object($arg) && get_class($arg) == 'ctools_context') { - $contexts[$arg->id] = $arg; - } - } - - ctools_include('context'); - return ctools_access($access, $contexts); -} - -/** - * Determine if the current user has access via checks to multiple different - * permissions. - * - * This function is a thin wrapper around user_access that allows multiple - * permissions to be easily designated for use on, for example, a menu callback. - * - * @param ... - * An indexed array of zero or more permission strings to be checked by - * user_access(). - * - * @return - * Iff all checks pass will this function return TRUE. If an invalid argument - * is passed (e.g., not a string), this function errs on the safe said and - * returns FALSE. - */ -function ctools_access_multiperm() { - foreach (func_get_args() as $arg) { - if (!is_string($arg) || !user_access($arg)) { - return FALSE; - } - } - return TRUE; -} - -/** - * Check to see if the incoming menu item is js capable or not. - * - * This can be used as %ctools_js as part of a path in hook menu. CTools - * ajax functions will automatically change the phrase 'nojs' to 'ajax' - * when it attaches ajax to a link. This can be used to autodetect if - * that happened. - */ -function ctools_js_load($js) { - if ($js == 'ajax') { - return TRUE; - } - return 0; -} - -/** - * Menu _load hook. - * - * This function will be called to load an object as a replacement for - * %ctools_export_ui in menu paths. - */ -function ctools_export_ui_load($item_name, $plugin_name) { - $return = &drupal_static(__FUNCTION__, FALSE); - - if (!$return) { - ctools_include('export-ui'); - $plugin = ctools_get_export_ui($plugin_name); - - if ($plugin) { - // Get the load callback. - $item = ctools_export_crud_load($plugin['schema'], $item_name); - return empty($item) ? FALSE : $item; - } - } - - return $return; -} - -// ----------------------------------------------------------------------- -// Caching callbacks on behalf of export-ui. - -/** - * Menu access callback for various tasks of export-ui. - */ -function ctools_export_ui_task_access($plugin_name, $op, $item = NULL) { - ctools_include('export-ui'); - $plugin = ctools_get_export_ui($plugin_name); - $handler = ctools_export_ui_get_handler($plugin); - - if ($handler) { - return $handler->access($op, $item); - } - - // Deny access if the handler cannot be found. - return FALSE; -} - -/** - * Cache callback on behalf of ctools_export_ui. - */ -function ctools_export_ui_context_cache_get($plugin_name, $key) { - dsm('should not be called!'); - return; -} - -/** - * Cache callback on behalf of ctools_export_ui. - */ -function ctools_export_ui_context_cache_set($plugin_name, $key, $item) { - dsm('should not be called!'); - return; -} - -/** - * Callback for access control ajax form on behalf of export ui. - * - * Returns the cached access config and contexts used. - * Note that this is assuming that access will be in $item->access -- if it - * is not, an export UI plugin will have to make its own callbacks. - */ -function ctools_export_ui_ctools_access_get($argument) { - ctools_include('export-ui'); - list($plugin_name, $key) = explode(':', $argument, 2); - - $plugin = ctools_get_export_ui($plugin_name); - $handler = ctools_export_ui_get_handler($plugin); - - if ($handler) { - ctools_include('context'); - $item = $handler->edit_cache_get($key); - if (!$item) { - $item = ctools_export_crud_load($handler->plugin['schema'], $key); - } - - $contexts = ctools_context_load_contexts($item); - return array($item->access, $contexts); - } -} - -/** - * Callback for access control ajax form on behalf of export ui - * - * Returns the cached access config and contexts used. - * Note that this is assuming that access will be in $item->access -- if it - * is not, an export UI plugin will have to make its own callbacks. - */ -function ctools_export_ui_ctools_access_set($argument, $access) { - ctools_include('export-ui'); - list($plugin_name, $key) = explode(':', $argument, 2); - - $plugin = ctools_get_export_ui($plugin_name); - $handler = ctools_export_ui_get_handler($plugin); - - if ($handler) { - ctools_include('context'); - $item = $handler->edit_cache_get($key); - if (!$item) { - $item = ctools_export_crud_load($handler->plugin['schema'], $key); - } - $item->access = $access; - return $handler->edit_cache_set_key($item, $key); - } -} - -/** - * Implements hook_menu_local_tasks_alter(). - */ -function ctools_menu_local_tasks_alter(&$data, $router_item, $root_path) { - ctools_include('menu'); - _ctools_menu_add_dynamic_items($data, $router_item, $root_path); -} - -/** - * Implement hook_block_list_alter() to potentially remove blocks. - * - * This exists in order to replicate Drupal 6's "no blocks" functionality. - */ -function ctools_block_list_alter(&$blocks) { - $check = drupal_static('ctools_set_no_blocks', TRUE); - if (!$check) { - foreach ($blocks as $block_id => $block) { - // @todo -- possibly we can set configuration for this so that users can - // specify which blocks will not get rendered. - if (substr_compare($block->region, 'sidebar', 0)) { - unset($blocks[$block_id]); - } - } - } -} - -/** - * Implement hook_modules_enabled to clear static caches for detecting new plugins - */ -function ctools_modules_enabled($modules) { - ctools_include('plugins'); - ctools_get_plugins_reset(); -} diff --git a/ctools_access_ruleset/ctools_access_ruleset.info b/ctools_access_ruleset/ctools_access_ruleset.info deleted file mode 100644 index 4d1d994..0000000 --- a/ctools_access_ruleset/ctools_access_ruleset.info +++ /dev/null @@ -1,5 +0,0 @@ -name = Custom rulesets -description = Create custom, exportable, reusable access rulesets for applications like Panels. -core = 7.x -package = Chaos tool suite -dependencies[] = ctools diff --git a/ctools_access_ruleset/ctools_access_ruleset.install b/ctools_access_ruleset/ctools_access_ruleset.install deleted file mode 100644 index b1613d8..0000000 --- a/ctools_access_ruleset/ctools_access_ruleset.install +++ /dev/null @@ -1,82 +0,0 @@ - 'Contains exportable customized access rulesets.', - 'export' => array( - 'identifier' => 'ruleset', - 'bulk export' => TRUE, - 'primary key' => 'rsid', - 'api' => array( - 'owner' => 'ctools', - 'api' => 'ctools_rulesets', - 'minimum_version' => 1, - 'current_version' => 1, - ), - ), - 'fields' => array( - 'rsid' => array( - 'type' => 'serial', - 'description' => 'A database primary key to ensure uniqueness', - 'not null' => TRUE, - 'no export' => TRUE, - ), - 'name' => array( - 'type' => 'varchar', - 'length' => '255', - 'description' => 'Unique ID for this ruleset. Used to identify it programmatically.', - ), - 'admin_title' => array( - 'type' => 'varchar', - 'length' => '255', - 'description' => 'Administrative title for this ruleset.', - ), - 'admin_description' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Administrative description for this ruleset.', - 'object default' => '', - ), - 'requiredcontexts' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Any required contexts for this ruleset.', - 'serialize' => TRUE, - 'object default' => array(), - ), - 'contexts' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Any embedded contexts for this ruleset.', - 'serialize' => TRUE, - 'object default' => array(), - ), - 'relationships' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Any relationships for this ruleset.', - 'serialize' => TRUE, - 'object default' => array(), - ), - 'access' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'The actual group of access plugins for this ruleset.', - 'serialize' => TRUE, - 'object default' => array(), - ), - ), - 'primary key' => array('rsid'), - ); - - return $schema; -} diff --git a/ctools_access_ruleset/ctools_access_ruleset.module b/ctools_access_ruleset/ctools_access_ruleset.module deleted file mode 100644 index fb39f37..0000000 --- a/ctools_access_ruleset/ctools_access_ruleset.module +++ /dev/null @@ -1,85 +0,0 @@ - array( - 'title' => t('Administer access rulesets'), - 'description' => t('Add, delete and edit custom access rulesets.'), - ), - ); -} - -/** - * Implementation of hook_ctools_plugin_directory() to let the system know - * we implement task and task_handler plugins. - */ -function ctools_access_ruleset_ctools_plugin_directory($module, $plugin) { - // Most of this module is implemented as an export ui plugin, and the - // rest is in ctools/includes/ctools_access_ruleset.inc - if ($module == 'ctools' && ($plugin == 'export_ui' || $plugin == 'access')) { - return 'plugins/' . $plugin; - } -} - -/** - * Implementation of hook_panels_dashboard_blocks(). - * - * Adds page information to the Panels dashboard. - */ -function ctools_access_ruleset_panels_dashboard_blocks(&$vars) { - $vars['links']['ctools_access_ruleset'] = array( - 'title' => l(t('Custom ruleset'), 'admin/structure/ctools-rulesets/add'), - 'description' => t('Custom rulesets are combinations of access plugins you can use for access control, selection criteria and pane visibility.'), - ); - - // Load all mini panels and their displays. - ctools_include('export'); - $items = ctools_export_crud_load_all('ctools_access_ruleset'); - $count = 0; - $rows = array(); - - foreach ($items as $item) { - $rows[] = array( - check_plain($item->admin_title), - array( - 'data' => l(t('Edit'), "admin/structure/ctools-rulesets/list/$item->name/edit"), - 'class' => 'links', - ), - ); - - // Only show 10. - if (++$count >= 10) { - break; - } - } - - if ($rows) { - $content = theme('table', array('rows' => $rows, 'attributes' => array('class' => 'panels-manage'))); - } - else { - $content = '

' . t('There are no custom rulesets.') . '

'; - } - - $vars['blocks']['ctools_access_ruleset'] = array( - 'title' => t('Manage custom rulesets'), - 'link' => l(t('Go to list'), 'admin/structure/ctools-rulesets'), - 'content' => $content, - 'class' => 'dashboard-ruleset', - 'section' => 'right', - ); -} diff --git a/ctools_access_ruleset/plugins/access/ruleset.inc b/ctools_access_ruleset/plugins/access/ruleset.inc deleted file mode 100644 index fc8615e..0000000 --- a/ctools_access_ruleset/plugins/access/ruleset.inc +++ /dev/null @@ -1,100 +0,0 @@ - '', - 'description' => '', - 'callback' => 'ctools_ruleset_ctools_access_check', - 'settings form' => 'ctools_ruleset_ctools_access_settings', - 'summary' => 'ctools_ruleset_ctools_access_summary', - - // This access plugin actually just contains child plugins that are - // exportable, UI configured rulesets. - 'get child' => 'ctools_ruleset_ctools_access_get_child', - 'get children' => 'ctools_ruleset_ctools_access_get_children', -); - -/** - * Merge the main access plugin with a loaded ruleset to form a child plugin. - */ -function ctools_ruleset_ctools_access_merge_plugin($plugin, $parent, $item) { - $plugin['name'] = $parent . ':' . $item->name; - $plugin['title'] = check_plain($item->admin_title); - $plugin['description'] = check_plain($item->admin_description); - - // TODO: Generalize this in CTools. - if (!empty($item->requiredcontexts)) { - $plugin['required context'] = array(); - foreach ($item->requiredcontexts as $context) { - $info = ctools_get_context($context['name']); - // TODO: allow an optional setting - $plugin['required context'][] = new ctools_context_required($context['identifier'], $info['context name']); - } - } - - // Store the loaded ruleset in the plugin. - $plugin['ruleset'] = $item; - return $plugin; -} - -/** - * Get a single child access plugin. - */ -function ctools_ruleset_ctools_access_get_child($plugin, $parent, $child) { - ctools_include('export'); - $item = ctools_export_crud_load('ctools_access_ruleset', $child); - if ($item) { - return ctools_ruleset_ctools_access_merge_plugin($plugin, $parent, $item); - } -} - -/** - * Get all child access plugins. - */ -function ctools_ruleset_ctools_access_get_children($plugin, $parent) { - $plugins = array(); - ctools_include('export'); - $items = ctools_export_crud_load_all('ctools_access_ruleset'); - foreach ($items as $name => $item) { - $child = ctools_ruleset_ctools_access_merge_plugin($plugin, $parent, $item); - $plugins[$child['name']] = $child; - } - - return $plugins; -} - -/** - * Settings form for the 'by ruleset' access plugin - */ -function ctools_ruleset_ctools_access_settings(&$form, &$form_state, $conf) { - $form['markup'] = array( - '#value' => '
' . check_plain($form_state['plugin']['ruleset']->admin_description) . '
', - ); -} - -/** - * Check for access. - */ -function ctools_ruleset_ctools_access_check($conf, $context, $plugin) { - // Load up any contexts we might be using. - $contexts = ctools_context_match_required_contexts($plugin['ruleset']->requiredcontexts, $context); - $contexts = ctools_context_load_contexts($plugin['ruleset'], FALSE, $contexts); - - return ctools_access($plugin['ruleset']->access, $contexts); -} - -/** - * Provide a summary description based upon the checked roles. - */ -function ctools_ruleset_ctools_access_summary($conf, $context, $plugin) { - return check_plain($plugin['ruleset']->admin_description); -} - diff --git a/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc b/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc deleted file mode 100644 index d2a1c60..0000000 --- a/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc +++ /dev/null @@ -1,29 +0,0 @@ - 'ctools_access_ruleset', - 'access' => 'administer ctools access ruleset', - - 'menu' => array( - 'menu item' => 'ctools-rulesets', - 'menu title' => 'Custom access rulesets', - 'menu description' => 'Add, edit or delete custom access rulesets for use with Panels and other systems that utilize CTools content plugins.', - ), - - 'title singular' => t('ruleset'), - 'title singular proper' => t('Ruleset'), - 'title plural' => t('rulesets'), - 'title plural proper' => t('Rulesets'), - - 'handler' => 'ctools_access_ruleset_ui', - - 'use wizard' => TRUE, - 'form info' => array( - 'order' => array( - 'basic' => t('Basic information'), - 'context' => t('Contexts'), - 'rules' => t('Rules'), - ), - ), -); - diff --git a/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php b/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php deleted file mode 100644 index b181464..0000000 --- a/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php +++ /dev/null @@ -1,53 +0,0 @@ - '
', - '#suffix' => '
', - ); - - $form['left'] = array( - '#prefix' => '
', - '#suffix' => '
', - ); - - // Set this up and we can use CTools' Export UI's built in wizard caching, - // which already has callbacks for the context cache under this name. - $module = 'export_ui::' . $this->plugin['name']; - $name = $this->edit_cache_get_key($form_state['item'], $form_state['form type']); - - ctools_context_add_context_form($module, $form, $form_state, $form['right']['contexts_table'], $form_state['item'], $name); - ctools_context_add_required_context_form($module, $form, $form_state, $form['left']['required_contexts_table'], $form_state['item'], $name); - ctools_context_add_relationship_form($module, $form, $form_state, $form['right']['relationships_table'], $form_state['item'], $name); - } - - function edit_form_rules(&$form, &$form_state) { - // The 'access' UI passes everything via $form_state, unlike the 'context' UI. - // The main difference is that one is about 3 years newer than the other. - ctools_include('context'); - ctools_include('context-access-admin'); - - $form_state['access'] = $form_state['item']->access; - $form_state['contexts'] = ctools_context_load_contexts($form_state['item']); - - $form_state['module'] = 'ctools_export_ui'; - $form_state['callback argument'] = $form_state['object']->plugin['name'] . ':' . $form_state['object']->edit_cache_get_key($form_state['item'], $form_state['form type']); - $form_state['no buttons'] = TRUE; - - $form = ctools_access_admin_form($form, $form_state); - } - - function edit_form_rules_submit(&$form, &$form_state) { - $form_state['item']->access['logic'] = $form_state['values']['logic']; - } - - function edit_form_submit(&$form, &$form_state) { - parent::edit_form_submit($form, $form_state); - } -} diff --git a/ctools_ajax_sample/css/ctools-ajax-sample.css b/ctools_ajax_sample/css/ctools-ajax-sample.css deleted file mode 100644 index dc83b0b..0000000 --- a/ctools_ajax_sample/css/ctools-ajax-sample.css +++ /dev/null @@ -1,134 +0,0 @@ -div.ctools-sample-modal-content { - background:none; - border:0; - color:#000000; - margin:0; - padding:0; - text-align:left; -} -div.ctools-sample-modal-content .modal-scroll{ - overflow:hidden; - overflow-y:auto; -} -div.ctools-sample-modal-content #popups-overlay { - background-color:transparent; -} -div.ctools-sample-modal-content #popups-loading { - width:248px; - position:absolute; - display:none; - opacity:1; - -moz-border-radius: 8px; - -webkit-border-radius: 8px; - z-index:99; -} -div.ctools-sample-modal-content #popups-loading span.popups-loading-message { - background:#FFF url(../images/loading-large.gif) no-repeat 8px center; - display:block; - color:#444444; - font-family:Arial; - font-size:22px; - font-weight:bold; - height:36px; - line-height:36px; - padding:0 40px; -} -div.ctools-sample-modal-content #popups-loading table, -div.ctools-sample-modal-content .popups-box table { - margin:0px; -} -div.ctools-sample-modal-content #popups-loading tbody, -div.ctools-sample-modal-content .popups-box tbody { - border:none; -} -div.ctools-sample-modal-content .popups-box tr { - background-color:transparent; -} -div.ctools-sample-modal-content td.popups-border { - background: url(../images/popups-border.png); - background-color:transparent; -} -div.ctools-sample-modal-content td.popups-tl, -div.ctools-sample-modal-content td.popups-tr, -div.ctools-sample-modal-content td.popups-bl, -div.ctools-sample-modal-content td.popups-br { - background-repeat: no-repeat; - height:10px; - padding:0px; -} -div.ctools-sample-modal-content td.popups-tl { background-position: 0px 0px; } -div.ctools-sample-modal-content td.popups-t, -div.ctools-sample-modal-content td.popups-b { - background-position: 0px -40px; - background-repeat: repeat-x; - height:10px; -} -div.ctools-sample-modal-content td.popups-tr { background-position: 0px -10px; } -div.ctools-sample-modal-content td.popups-cl, -div.ctools-sample-modal-content td.popups-cr { - background-position: -10px 0; - background-repeat: repeat-y; - width:10px; -} -div.ctools-sample-modal-content td.popups-cl, -div.ctools-sample-modal-content td.popups-cr, -div.ctools-sample-modal-content td.popups-c { padding:0; } -div.ctools-sample-modal-content td.popups-c { background:#fff; } -div.ctools-sample-modal-content td.popups-bl { background-position: 0px -20px; } -div.ctools-sample-modal-content td.popups-br { background-position: 0px -30px; } - -div.ctools-sample-modal-content .popups-box, -div.ctools-sample-modal-content #popups-loading { - border: 0px solid #454545; - opacity:1; - overflow:hidden; - padding:0; - background-color:transparent; -} -div.ctools-sample-modal-content .popups-container { - overflow:hidden; - height:100%; - background-color:#fff; -} -div.ctools-sample-modal-content div.popups-title { - -moz-border-radius-topleft: 0px; - -webkit-border-radius-topleft: 0px; - margin-bottom:0px; - background-color:#ff7200; - border:1px solid #ce5c00; - padding:4px 10px 5px; - color:white; - font-size:1em; - font-weight:bold; -} -div.ctools-sample-modal-content .popups-body { - background-color:#fff; - padding:8px; -} -div.ctools-sample-modal-content .popups-box .popups-buttons, -div.ctools-sample-modal-content .popups-box .popups-footer { - background-color:#fff; -} -div.ctools-sample-modal-content .popups-title a.close { - color: #fff; - text-decoration:none; -} -div.ctools-sample-modal-content .popups-close { - font-size:120%; - float:right; - text-align:right; -} -div.ctools-sample-modal-content .modal-loading-wrapper { - width:220px; - height:19px; - margin:0 auto; - margin-top:2%; -} - -div.ctools-sample-modal-content tbody{ - border:none; -} - -div.ctools-sample-modal-content .modal-content .modal-throbber-wrapper img { - margin-top: 100px; -} diff --git a/ctools_ajax_sample/ctools_ajax_sample.info b/ctools_ajax_sample/ctools_ajax_sample.info deleted file mode 100644 index 1361f4f..0000000 --- a/ctools_ajax_sample/ctools_ajax_sample.info +++ /dev/null @@ -1,5 +0,0 @@ -name = Chaos Tools (CTools) AJAX Example -description = Shows how to use the power of Chaos AJAX. -package = Chaos tool suite -dependencies[] = ctools -core = 7.x diff --git a/ctools_ajax_sample/ctools_ajax_sample.install b/ctools_ajax_sample/ctools_ajax_sample.install deleted file mode 100644 index 04325db..0000000 --- a/ctools_ajax_sample/ctools_ajax_sample.install +++ /dev/null @@ -1,19 +0,0 @@ - 'Chaos Tools AJAX Demo', - 'page callback' => 'ctools_ajax_sample_page', - 'access callback' => TRUE, - 'type' => MENU_NORMAL_ITEM, - ); - $items['ctools_ajax_sample/simple_form'] = array( - 'title' => 'Simple Form', - 'page callback' => 'ctools_ajax_simple_form', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['ctools_ajax_sample/%ctools_js/tablenix/%'] = array( - 'title' => 'Hello World', - 'page callback' => 'ctools_ajax_sample_tablenix', - 'page arguments' => array(1, 3), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['ctools_ajax_sample/%ctools_js/login'] = array( - 'title' => 'Login', - 'page callback' => 'ctools_ajax_sample_login', - 'page arguments' => array(1), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['ctools_ajax_sample/%ctools_js/animal'] = array( - 'title' => 'Animal', - 'page callback' => 'ctools_ajax_sample_animal', - 'page arguments' => array(1), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['ctools_ajax_sample/%ctools_js/login/%'] = array( - 'title' => 'Post-Login Action', - 'page callback' => 'ctools_ajax_sample_login_success', - 'page arguments' => array(1, 3), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['ctools_ajax_sample/jumped'] = array( - 'title' => 'Successful Jumping', - 'page callback' => 'ctools_ajax_sample_jump_menu_page', - 'access callback' => TRUE, - 'type' => MENU_NORMAL_ITEM, - ); - - return $items; -} - -function ctools_ajax_simple_form() { - ctools_include('content'); - ctools_include('context'); - $node = node_load(1); - $context = ctools_context_create('node', $node); - $context = array('context_node_1' => $context); - return ctools_content_render('node_comment_form', 'node_comment_form', ctools_ajax_simple_form_pane(), array(), array(), $context); -} - -function ctools_ajax_simple_form_pane() { - $configuration = array( - 'anon_links' => 0, - 'context' => 'context_node_1', - 'override_title' => 0, - 'override_title_text' => '', - ); - return $configuration; -} - -/** - * Implementation of hook_theme() - * - * Render some basic output for this module. - */ -function ctools_ajax_sample_theme() { - return array( - // Sample theme functions. - 'ctools_ajax_sample_container' => array( - 'arguments' => array('content' => NULL), - ), - ); -} - -// --------------------------------------------------------------------------- -// Page callbacks - -/** - * Page callback to display links and render a container for AJAX stuff. - */ -function ctools_ajax_sample_page() { - global $user; - - // Include the CTools tools that we need. - ctools_include('ajax'); - ctools_include('modal'); - - // Add CTools' javascript to the page. - ctools_modal_add_js(); - - // Create our own javascript that will be used to theme a modal. - $sample_style = array( - 'ctools-sample-style' => array( - 'modalSize' => array( - 'type' => 'fixed', - 'width' => 500, - 'height' => 300, - 'addWidth' => 20, - 'addHeight' => 15, - ), - 'modalOptions' => array( - 'opacity' => .5, - 'background-color' => '#000', - ), - 'animation' => 'fadeIn', - 'modalTheme' => 'CToolsSampleModal', - 'throbber' => theme('image', array('path' => ctools_image_path('ajax-loader.gif', 'ctools_ajax_sample'), 'alt' => t('Loading...'), 'title' => t('Loading'))), - ), - ); - - drupal_add_js($sample_style, 'setting'); - - // Since we have our js, css and images in well-known named directories, - // CTools makes it easy for us to just use them without worrying about - // using drupal_get_path() and all that ugliness. - ctools_add_js('ctools-ajax-sample', 'ctools_ajax_sample'); - ctools_add_css('ctools-ajax-sample', 'ctools_ajax_sample'); - - // Create a list of clickable links. - $links = array(); - - // Only show login links to the anonymous user. - if ($user->uid == 0) { - $links[] = ctools_modal_text_button(t('Modal Login (default style)'), 'ctools_ajax_sample/nojs/login', t('Login via modal')); - - // The extra class points to the info in ctools-sample-style which we added to the settings. - $links[] = ctools_modal_text_button(t('Modal Login (custom style)'), 'ctools_ajax_sample/nojs/login', t('Login via modal'), 'ctools-modal-ctools-sample-style'); - } - - // Four ways to do our animal picking wizard. - $button_form = ctools_ajax_sample_ajax_button_form(); - $links[] = l(t('Wizard (no modal)'), 'ctools_ajax_sample/nojs/animal'); - $links[] = ctools_modal_text_button(t('Wizard (default modal)'), 'ctools_ajax_sample/nojs/animal', t('Pick an animal')); - $links[] = ctools_modal_text_button(t('Wizard (custom modal)'), 'ctools_ajax_sample/nojs/animal', t('Pick an animal'), 'ctools-modal-ctools-sample-style'); - $links[] = drupal_render($button_form); - - $links[] = ctools_ajax_text_button(t('Hello world!'), "ctools_ajax_sample/nojs/hello", t('Replace text with "hello world"')); - - $output = theme('item_list', array('items' => $links, 'title' => t('Actions'))); - - // This container will have data AJAXed into it. - $output .= theme('ctools_ajax_sample_container', array('content' => '

' . t('Sample Content') . '

')); - - // Create a table that we can have data removed from via AJAX. - $header = array(t('Row'), t('Content'), t('Actions')); - $rows = array(); - for($i = 1; $i < 11; $i++) { - $rows[] = array( - 'class' => array('ajax-sample-row-'. $i), - 'data' => array( - $i, - md5($i), - ctools_ajax_text_button("remove", "ctools_ajax_sample/nojs/tablenix/$i", t('Delete this row')), - ), - ); - } - - $output .= theme('table', array('header' => $header, 'rows' => $rows, array('class' => array('ajax-sample-table')))); - - // Show examples of ctools javascript widgets - $output .= '

'. t('CTools Javascript Widgets') .'

'; - - // Create a drop down menu - $links = array(); - $links[] = array('title' => t('Link 1'), 'href' => $_GET['q']); - $links[] = array('title' => t('Link 2'), 'href' => $_GET['q']); - $links[] = array('title' => t('Link 3'), 'href' => $_GET['q']); - - $output .= '

' . t('Drop Down Menu') . '

'; - $output .= theme('ctools_dropdown', array('title' => t('Click to Drop Down'), 'links' => $links)); - - // Create a collapsible div - $handle = t('Click to Collapse'); - $content = 'Nulla ligula ante, aliquam at adipiscing egestas, varius vel arcu. Etiam laoreet elementum mi vel consequat. Etiam scelerisque lorem vel neque consequat quis bibendum libero congue. Nulla facilisi. Mauris a elit a leo feugiat porta. Phasellus placerat cursus est vitae elementum.'; - $output .= '

'. t('Collapsible Div') .'

'; - $output .= theme('ctools_collapsible', array('handle' => $handle, 'content' => $content, 'collapsed' => FALSE)); - - // Create a jump menu - ctools_include('jump-menu'); - $form = drupal_get_form('ctools_ajax_sample_jump_menu_form'); - $output .= '

'. t('Jump Menu') .'

'; - $output .= drupal_render($form); - - return array('markup' => array('#markup' => $output)); -} - -/** - * Returns a "take it all over" hello world style request. - */ -function ctools_ajax_sample_hello($js = NULL) { - $output = '

' . t('Hello World') . '

'; - if ($js) { - ctools_include('ajax'); - $commands = array(); - $commands[] = ajax_command_html('#ctools-sample', $output); - print ajax_render($commands); // this function exits. - exit; - } - else { - return $output; - } -} - -/** - * Nix a row from a table and restripe. - */ -function ctools_ajax_sample_tablenix($js, $row) { - if (!$js) { - // We don't support degrading this from js because we're not - // using the server to remember the state of the table. - return MENU_ACCESS_DENIED; - } - ctools_include('ajax'); - - $commands = array(); - $commands[] = ajax_command_remove("tr.ajax-sample-row-$row"); - $commands[] = ajax_command_restripe("table.ajax-sample-table"); - print ajax_render($commands); - exit; -} - -/** - * A modal login callback. - */ -function ctools_ajax_sample_login($js = NULL) { - // Fall back if $js is not set. - if (!$js) { - return drupal_get_form('user_login'); - } - - ctools_include('modal'); - ctools_include('ajax'); - $form_state = array( - 'title' => t('Login'), - 'ajax' => TRUE, - ); - $output = ctools_modal_form_wrapper('user_login', $form_state); - if (empty($output)) { - // empty $output signifies success, so we'll use it as our $commands - // array. - $output = array(); - $inplace = ctools_ajax_text_button(t('remain here'), 'ctools_ajax_sample/nojs/login/inplace', t('Go to your account')); - $account = ctools_ajax_text_button(t('your account'), 'ctools_ajax_sample/nojs/login/user', t('Go to your account')); - $output[] = ctools_modal_command_display(t('Login Success'), ''); - } - print ajax_render($output); - exit; -} - -/** - * Post-login processor: should we go to the user account or stay in place? - */ -function ctools_ajax_sample_login_success($js, $action) { - if (!$js) { - // we should never be here out of ajax context - return MENU_NOT_FOUND; - } - - ctools_include('ajax'); - $commands = array(); - if ($action == 'inplace') { - // stay here - $commands[] = ctools_ajax_command_reload(); - } - else { - // bounce bounce - $commands[] = ctools_ajax_command_redirect('user'); - } - print ajax_render($commands); - exit; -} - -/** - * A modal login callback. - */ -function ctools_ajax_sample_animal($js = NULL, $step = NULL) { - if ($js) { - ctools_include('modal'); - ctools_include('ajax'); - } - - $form_info = array( - 'id' => 'animals', - 'path' => "ctools_ajax_sample/" . ($js ? 'ajax' : 'nojs') . "/animal/%step", - 'show trail' => TRUE, - 'show back' => TRUE, - 'show cancel' => TRUE, - 'show return' => FALSE, - 'next callback' => 'ctools_ajax_sample_wizard_next', - 'finish callback' => 'ctools_ajax_sample_wizard_finish', - 'cancel callback' => 'ctools_ajax_sample_wizard_cancel', - // this controls order, as well as form labels - 'order' => array( - 'start' => t('Choose animal'), - ), - // here we map a step to a form id. - 'forms' => array( - // e.g. this for the step at wombat/create - 'start' => array( - 'form id' => 'ctools_ajax_sample_start' - ), - ), - ); - - // We're not using any real storage here, so we're going to set our - // object_id to 1. When using wizard forms, id management turns - // out to be one of the hardest parts. Editing an object with an id - // is easy, but new objects don't usually have ids until somewhere - // in creation. - // - // We skip all this here by just using an id of 1. - - $object_id = 1; - - if (empty($step)) { - // We reset the form when $step is NULL because that means they have - // for whatever reason started over. - ctools_ajax_sample_cache_clear($object_id); - $step = 'start'; - } - - // This automatically gets defaults if there wasn't anything saved. - $object = ctools_ajax_sample_cache_get($object_id); - - $animals = ctools_ajax_sample_animals(); - - // Make sure we can't somehow accidentally go to an invalid animal. - if (empty($animals[$object->type])) { - $object->type = 'unknown'; - } - - // Now that we have our object, dynamically add the animal's form. - if ($object->type == 'unknown') { - // If they haven't selected a type, add a form that doesn't exist yet. - $form_info['order']['unknown'] = t('Configure animal'); - $form_info['forms']['unknown'] = array('form id' => 'nothing'); - } - else { - // Add the selected animal to the order so that it shows up properly in the trail. - $form_info['order'][$object->type] = $animals[$object->type]['config title']; - } - - // Make sure all animals forms are represented so that the next stuff can - // work correctly: - foreach ($animals as $id => $animal) { - $form_info['forms'][$id] = array('form id' => $animals[$id]['form']); - } - - $form_state = array( - 'ajax' => $js, - // Put our object and ID into the form state cache so we can easily find - // it. - 'object_id' => $object_id, - 'object' => &$object, - ); - - // Send this all off to our form. This is like drupal_get_form only wizardy. - ctools_include('wizard'); - $form = ctools_wizard_multistep_form($form_info, $step, $form_state); - $output = drupal_render($form); - - if ($output === FALSE || !empty($form_state['complete'])) { - // This creates a string based upon the animal and its setting using - // function indirection. - $animal = $animals[$object->type]['output']($object); - } - - // If $output is FALSE, there was no actual form. - if ($js) { - // If javascript is active, we have to use a render array. - $commands = array(); - if ($output === FALSE || !empty($form_state['complete'])) { - // Dismiss the modal. - $commands[] = ajax_command_html('#ctools-sample', $animal); - $commands[] = ctools_modal_command_dismiss(); - } - else if (!empty($form_state['cancel'])) { - // If cancelling, return to the activity. - $commands[] = ctools_modal_command_dismiss(); - } - else { - $commands = ctools_modal_form_render($form_state, $output); - } - print ajax_render($commands); - exit; - } - else { - if ($output === FALSE || !empty($form_state['complete'])) { - return $animal; - } - else if (!empty($form_state['cancel'])) { - drupal_goto('ctools_ajax_sample'); - } - else { - return $output; - } - } -} - -// --------------------------------------------------------------------------- -// Themes - -/** - * Theme function for main rendered output. - */ -function theme_ctools_ajax_sample_container($vars) { - $output = '
'; - $output .= $vars['content']; - $output .= '
'; - - return $output; -} - -// --------------------------------------------------------------------------- -// Stuff needed for our little wizard. - -/** - * Get a list of our animals and associated forms. - * - * What we're doing is making it easy to add more animals in just one place, - * which is often how it will work in the real world. If using CTools, what - * you would probably really have, here, is a set of plugins for each animal. - */ -function ctools_ajax_sample_animals() { - return array( - 'sheep' => array( - 'title' => t('Sheep'), - 'config title' => t('Configure sheep'), - 'form' => 'ctools_ajax_sample_configure_sheep', - 'output' => 'ctools_ajax_sample_show_sheep', - ), - 'lizard' => array( - 'title' => t('Lizard'), - 'config title' => t('Configure lizard'), - 'form' => 'ctools_ajax_sample_configure_lizard', - 'output' => 'ctools_ajax_sample_show_lizard', - ), - 'raptor' => array( - 'title' => t('Raptor'), - 'config title' => t('Configure raptor'), - 'form' => 'ctools_ajax_sample_configure_raptor', - 'output' => 'ctools_ajax_sample_show_raptor', - ), - ); -} - -// --------------------------------------------------------------------------- -// Wizard caching helpers. - -/** - * Store our little cache so that we can retain data from form to form. - */ -function ctools_ajax_sample_cache_set($id, $object) { - ctools_include('object-cache'); - ctools_object_cache_set('ctools_ajax_sample', $id, $object); -} - -/** - * Get the current object from the cache, or default. - */ -function ctools_ajax_sample_cache_get($id) { - ctools_include('object-cache'); - $object = ctools_object_cache_get('ctools_ajax_sample', $id); - if (!$object) { - // Create a default object. - $object = new stdClass; - $object->type = 'unknown'; - $object->name = ''; - } - - return $object; -} - -/** - * Clear the wizard cache. - */ -function ctools_ajax_sample_cache_clear($id) { - ctools_include('object-cache'); - ctools_object_cache_clear('ctools_ajax_sample', $id); -} - -// --------------------------------------------------------------------------- -// Wizard in-between helpers; what to do between or after forms. - -/** - * Handle the 'next' click on the add/edit pane form wizard. - * - * All we need to do is store the updated pane in the cache. - */ -function ctools_ajax_sample_wizard_next(&$form_state) { - ctools_ajax_sample_cache_set($form_state['object_id'], $form_state['object']); -} - -/** - * Handle the 'finish' click on teh add/edit pane form wizard. - * - * All we need to do is set a flag so the return can handle adding - * the pane. - */ -function ctools_ajax_sample_wizard_finish(&$form_state) { - $form_state['complete'] = TRUE; -} - -/** - * Handle the 'cancel' click on the add/edit pane form wizard. - */ -function ctools_ajax_sample_wizard_cancel(&$form_state) { - $form_state['cancel'] = TRUE; -} - -// --------------------------------------------------------------------------- -// Wizard forms for our simple info collection wizard. - -/** - * Wizard start form. Choose an animal. - */ -function ctools_ajax_sample_start($form, &$form_state) { - $form_state['title'] = t('Choose animal'); - - $animals = ctools_ajax_sample_animals(); - foreach ($animals as $id => $animal) { - $options[$id] = $animal['title']; - } - - $form['type'] = array( - '#title' => t('Choose your animal'), - '#type' => 'radios', - '#options' => $options, - '#default_value' => $form_state['object']->type, - '#required' => TRUE, - ); - return $form; -} - -/** - * They have selected a sheep. Set it. - */ -function ctools_ajax_sample_start_submit(&$form, &$form_state) { - $form_state['object']->type = $form_state['values']['type']; - // Override where to go next based on the animal selected. - $form_state['clicked_button']['#next'] = $form_state['values']['type']; -} - -/** - * Wizard form to configure your sheep. - */ -function ctools_ajax_sample_configure_sheep($form, &$form_state) { - $form_state['title'] = t('Configure sheep'); - - $form['name'] = array( - '#type' => 'textfield', - '#title' => t('Name your sheep'), - '#default_value' => $form_state['object']->name, - '#required' => TRUE, - ); - - $form['sheep'] = array( - '#title' => t('What kind of sheep'), - '#type' => 'radios', - '#options' => array( - t('Wensleydale') => t('Wensleydale'), - t('Merino') => t('Merino'), - t('Corriedale') => t('Coriedale'), - ), - '#default_value' => !empty($form_state['object']->sheep) ? $form_state['object']->sheep : '', - '#required' => TRUE, - ); - return $form; -} - -/** - * Submit the sheep and store the values from the form. - */ -function ctools_ajax_sample_configure_sheep_submit(&$form, &$form_state) { - $form_state['object']->name = $form_state['values']['name']; - $form_state['object']->sheep = $form_state['values']['sheep']; -} - -/** - * Provide some output for our sheep. - */ -function ctools_ajax_sample_show_sheep($object) { - return t('You have a @type sheep named "@name".', array( - '@type' => $object->sheep, - '@name' => $object->name, - )); -} - -/** - * Wizard form to configure your lizard. - */ -function ctools_ajax_sample_configure_lizard($form, &$form_state) { - $form_state['title'] = t('Configure lizard'); - - $form['name'] = array( - '#type' => 'textfield', - '#title' => t('Name your lizard'), - '#default_value' => $form_state['object']->name, - '#required' => TRUE, - ); - - $form['lizard'] = array( - '#title' => t('Venomous'), - '#type' => 'checkbox', - '#default_value' => !empty($form_state['object']->lizard), - ); - return $form; -} - -/** - * Submit the lizard and store the values from the form. - */ -function ctools_ajax_sample_configure_lizard_submit(&$form, &$form_state) { - $form_state['object']->name = $form_state['values']['name']; - $form_state['object']->lizard = $form_state['values']['lizard']; -} - -/** - * Provide some output for our raptor. - */ -function ctools_ajax_sample_show_lizard($object) { - return t('You have a @type lizard named "@name".', array( - '@type' => empty($object->lizard) ? t('non-venomous') : t('venomous'), - '@name' => $object->name, - )); -} - -/** - * Wizard form to configure your raptor. - */ -function ctools_ajax_sample_configure_raptor($form, &$form_state) { - $form_state['title'] = t('Configure raptor'); - - $form['name'] = array( - '#type' => 'textfield', - '#title' => t('Name your raptor'), - '#default_value' => $form_state['object']->name, - '#required' => TRUE, - ); - - $form['raptor'] = array( - '#title' => t('What kind of raptor'), - '#type' => 'radios', - '#options' => array( - t('Eagle') => t('Eagle'), - t('Hawk') => t('Hawk'), - t('Owl') => t('Owl'), - t('Buzzard') => t('Buzzard'), - ), - '#default_value' => !empty($form_state['object']->raptor) ? $form_state['object']->raptor : '', - '#required' => TRUE, - ); - - $form['domesticated'] = array( - '#title' => t('Domesticated'), - '#type' => 'checkbox', - '#default_value' => !empty($form_state['object']->domesticated), - ); - return $form; -} - -/** - * Submit the raptor and store the values from the form. - */ -function ctools_ajax_sample_configure_raptor_submit(&$form, &$form_state) { - $form_state['object']->name = $form_state['values']['name']; - $form_state['object']->raptor = $form_state['values']['raptor']; - $form_state['object']->domesticated = $form_state['values']['domesticated']; -} - -/** - * Provide some output for our raptor. - */ -function ctools_ajax_sample_show_raptor($object) { - return t('You have a @type @raptor named "@name".', array( - '@type' => empty($object->domesticated) ? t('wild') : t('domesticated'), - '@raptor' => $object->raptor, - '@name' => $object->name, - )); -} - -/** - * Helper function to provide a sample jump menu form - */ -function ctools_ajax_sample_jump_menu_form() { - $url = url('ctools_ajax_sample/jumped'); - $form = ctools_jump_menu(array(), array($url => t('Jump!')), array()); - return $form; -} - -/** - * Provide a message to the user that the jump menu worked - */ -function ctools_ajax_sample_jump_menu_page() { - $return_link = l(t('Return to the examples page.'), 'ctools_ajax_sample'); - $output = t('You successfully jumped! !return_link', array('!return_link' => $return_link)); - return $output; -} - -/** - * Provide a form for an example ajax modal button - */ -function ctools_ajax_sample_ajax_button_form() { - $form = array(); - - $form['url'] = array( - '#type' => 'hidden', - '#attributes' => array('class' => array('ctools-ajax-sample-button-url')), - '#value' => 'ctools_ajax_sample/nojs/animal', - ); - - $form['ajax_button'] = array( - '#type' => 'button', - '#value' => 'Wizard (button modal)', - '#attributes' => array('class' => array('ctools-use-modal')), - '#id' => 'ctools-ajax-sample-button', - ); - - return $form; -} diff --git a/ctools_ajax_sample/images/ajax-loader.gif b/ctools_ajax_sample/images/ajax-loader.gif deleted file mode 100644 index d84f653789e5008da64ff04ee109471284a9e284..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 10819 zcwViVXHZjX!>*H%1QJksO+b()O%YU3Q9(BX7GztHZs?ta9(o#~_ui}YE>aZ(NQ;0- z4L$TKAR+=54(|8;zH{dM-kHfveq?54GV8hKy6<~wXx&x5YB~kr1ndC-$H&J20HCF% zrJ$f7Jw3glp`oUxrn|eFMx(ud|9*IQcxq~jPNy#}E>=}ly?OIyb#--fbCXJ??(XjH z?d|pV_wVoTcXoCT3=C{-ZHjZJUf)>ANTZ{IaFv$ntPp?0-& zH1)lwR`>ROY#nc(?40f%s%qmaW@3;9Lt$`cmQ!rZ5XRzt4qnzTY(IZ~{q}ulZDTA7 zUx;IXQLke!h^P?(>{~wF1DWjvZix1KzJd9>0sLS6jQFbOG=l{>kBvw{c-%GM7Sn{j zdRzhy!s)W!D<7BeQCHb>dGnC7Xdq`LbVlVGe)Z!^jf^9b^wW~Q>}PQ|JDP?{J{1`h zx{RzP*ga2@VM6Kw)K=sSFi-T8?~k<+JTTTh<=4MEnY`sb*zZX5yzt^(z^O5HBjqYo zr?cQ038a3NF}0R!C@@`r*Q^&OH>+NHTaL)YCA%Yg&z{(Sy6Sq_@5y!d&G7)^u9mm> zZ?eG1kdA!u~4yI2*~9=Mg>@Oib}^~Lk)G&lHAksQgfkFt9(y9CJ^ zi$-luef!*(6;LMT&#Nt8EMzd>o z8w9eNY36|Yw30=F`t8O}X`dm>(SJcU@UsM2z*!t&X_)f1Y35`1tj3dbDWAwv-V= zq&OebA+k6?yF8ddkBv#!6i9@!DV#rtK_!!-&YVH@YPz%%8MsxCC77i&9fZESUrxAR0DAz?O8rZ;7FgSm44QCulz=y z0>p66&95<$C zC}`1bY{qRO*%!!fw`veL+VffsD&iq5;_!*j)htxT;CVXe0=Z!hDhTi53%+6y4UFV6 zQ8J1+>w;zRK%n%*qJLbD7Yi4qHi*VZdr(At&P(%~GP0jb1_2qBnM_^I2p;ADSi&`| zEQGY{aH%};dqKr<{MvRILh%BX1i@QPUk9k6eVU* z`Msy1kuy?wufoG5T+%t5l$8q$MI#v`Bb8)Ue4AjE?jhizBOUg=xMbdk2)UXKDHUKc zz*c!gBi&^MzWyC5QsbRr(sfqG-Zu90gnh-p)gPP3)}8lI_T*RR$tB?K(?5#;GQGJf zTHEETxfD@w^(rv@rh?X7{Pu+MytRO)>Ps>VRaF-9?Y#a2t4mPdji}Fq!MShm3b}>@ zn3-kyp^qlI#Up2USeBv~vP!Bu*d1`dB1snEQ(#9^44}M7L3J%vHc$VY6{%6nmMW8W zSQsEZv|ixjQt)G?PjHU~VXnYw<5oc`X>{v*cuU~YFwRM-b;w)2ycon@4uIa}jGy>& z@u*E}nigJusUX*Sp>%tK{rA{~Iu0b@dov44c25HnSMt5sj?-p}HopH$Xl`y??qJI2 z@>Ber*--fb)@#LJZZhoSQrMWL!`$IYcF_4Ffz|vcpVZll3M-D*%j&m|HmbVL|JbY@ z^S{mX@8Ked(H6^e#byt;fZ?0?tS0jCMg1vky-JMgS5Bk@mI!5FMflm`FlZv#FC-Wr z5$+RXheSI?vIh7jN07+DnYa`u&p=2>rbAk8MwTtUGR-GH%Rb%_DRdfjLJWH(gb&^= z06#$n$l49U$}~I-XX+b>?i(5z=|fmg4$h3gpf&?GmP^BQH^0r9v6YEn#Nt<`l~CKm zrR`PvhHhk5!=+t#E;DaLwi5CCJb$zfuob`qhAN*!q0|_dgw;;Cp-Sk9;}AObWs%xd z(}KZJsZV=2#E6XCI;n3|UoAfjRWL6w>e;o@&QJ*<8|_dm0+TPsjgl~5U-oCJr-5!r zjTDY%b2Qahz@OUam5G$*a+SoYF@VAHJTlq9MN+fpA@UU&K*T|?U##fFO#zTMvjVt3 zEqmt+VW0lMT zrPwHVFuRR%21Md*u%6Fyhg6P@+l*zQH}y^8nRE`E-SluO>S zowc0OvVI)3As79^%OkTPJSzq&ZG-Uw!84=aVmhltn_N{K150hsG@!PPE{1Kqx@9JVuj_J>$gFI* z9lUvm+s59>v{25l;#Hiw51)F2%h);$%qA@p-=v?XnkeQZbzT9$EF}S@x_OBuVCB3X zD40Cvx5$ItKNJtUl&U*!3i;Yx`a)4xD>Fp-?hkbLWv99a;pdcmfoX4K%pO8@8x}stCD#f;9t4W0DkF=PrnKdYP}2< z%Y}+{UKr@LMYrg`rWQ-cJhE{wt(H)F+-X*_7+>^t|boq37$ommR8TwgI< zxtiWFa->U^9Zw~<@Jq|oF$!F?4)DKoEEvIpw;Bpfc=ltHZ^s5*EYe`CCY(c}axRJt z&?^ZL=3rhiy}MWe=t5V_*t33L;XT-(q>f}olAYTcPhFgkzsjM@d>^OL#|mGp>#3Pn zj~>xm5QnQC#Y*)BExywWN1u7Kyha`}%(`=K7Ti8YulyxE3&!@;@j(#}27n%QJ)_7# zp5K;gq*ZqbRVeSxL>!5Vd}12HpPTeRLDVD|=_0I~_dJ|WD5(`neVWu8DzsIUW1@Pq z)BFyy20IoqHLYnD&n0})yyLl@M?vCn zFeY2IC~veuB$^IuOunqO%p?+3cs6=F;D>ZtcmyIkc_ZlOR-tOEI8`9Wg7oE^g~vVz zRIc4)?VP2>t(&%D(8?p`{BXgi$VXkWgEo%V951@(n4?L~b`_8iR%nr~yLju8aTE%~d zCiWZW;pyq+Vh8hwF`$XzOMJ&goHFG;MJV zT3tObI6OnQpV}Fnoe0@moK4zVWBQ)C7B&{t-{98ACbIqn*Nz9uGRdCx5NTyN2|0E~ zI&>TOR0Pr&$wDDB;z#iC24uE+a8?z;!r@(n+-@jHx9yl#Ir-@dC zA+PN%*92bZGI`Y61sj-ExM0$^_vIaD!}hoHB3Dh;+=%V&S(z#-+Y@=bSyqQXz?0H+ zo^<0?%POE{gt#v17!)tKPjf-@uhL8_U^;aCOQ}3z2S(ja0nmw|;9cglg6RqZ!J22? zI8v=mg86%SO@n+##Los@uJ9B!jXbH{SZy#C6| zbg3rwT&#tJxsd8Z7pWxhhaIJd*4k~atrQ#vVZ1mg`lyD_BaZq^v-Jugtu?!eG;CSQE1m^R>8( z7y7Zqy6iZwYwl>HxOw;9nSygR1_1D*e&uPB^hC-8lyB8`A-JVK7#JhGrFZ^bytd4I zOixV7SjDXt^^(Tm#>DeR8ql%SmWwTG#UbTdFtJGXyfomu0RiR8JYZ?_R%h3ij}$Y5 zCJG1g+x;O)aMXv*WJSDApX$X3;Y#8S_O)y>QIA7}pjR%Wi>IR7AbZ}*KSt0l8Y{v0 zm+0G!dr3Pg88*W_NIA^{7+IF(a`So;D^8)6+6p-9T5sk%CBhKn+4 zKLIjuK&yo5_z5C2PUt_5!uZEgq}0qcq5{N@#e}_D7qysJgu;!k?y3=!(CipXUbbsrdb*2bNp;DHMtRJS}yDUsCQX1Lc3;k(fBdQT{^lT`c0R zLJ=nGIX8>iDLh+~3HxtGUL%z7l(!hg?$?Fc@~8$Eb}o|wdX-@-jDC?g)*v^VFuHs5 z6_W3jQhPf4eZ55eJC-fZ;^(e7e*6M%EvYmu(#hHUE8r}17|Gt05NHkZ{A$dmpFx7Z z@#AEToT><13Vqw>G5JGo&%Q}qEUPNL>h&7h=hlUa)=B5#F=oT-x2Di0L(Otezu$;< zaf7sdzMYjmy$J_F#dLtSuxyEB?@&1j!0`(nq-M$uJ_l7}>-cKjWRkCCRjXMapB0^) zZ#kNb_OP{yQe^r|c@8Y-h7krWwPNQ&qwv^=UZU5m&w7M8Myrt#X5R(LPVPE+RyVBZ zS#W@fys$q@ba$>HHbhU`W;n!66#w_Gc&x30LL3FO8?rK*)OSfyB7!G7Wm(nuNFpE5;1X|DtuyqlTNOAMk#Uk?+Z-NpW-eY_wriTO7{+%lT-`KBnaqN zji(&h7Nta_W}!Q;q|sjuf0mp+F3&vbbTG-+#!0~eJlP{r-a?1;=u0hDdBO05;EhPb zx->QSyH^_U1|(zUO33?(uvWj-#Emrau|ndap*Nh2&N!lKlr;s;b*DzD#zGyM2gn-o z;iZ>*5v{Efn$`8PEW&sI<3UelJO?s5JD4OfwrbsUQD-@e6NSNbgcm=^@Rhr-OT$$> zWUIC1;Rtn2%)4QeN)`Nh)wK*Bt}kJ9Z88XG<8n{1wlz@B?)is7;}BPO3q^-M6CTZ4 z5Fba88h)4>vR>xVz)@cXVvxW9AfJDw*@SZU$`#K*E=UYcy$LKy3~%}+sGJ;npQ3CO z93?GF_oA*~=VLy~RjJId-_bkhb6UG0?Hj9;0!6nYKHjp~za%O#doQtje^o5{r-*!pqXv*V^9$ zOMsz$PLl(|V+mH!#ORP%Z)BiNu%{QyInm{GfM-~4R8ml3Xeg#MKR740nw(VVgwU`= znwrQk)|m^Di?CIh5biw?Dr=?}_NP4IoTp~sR?sf~BSC<{&v8;vXGu)OJ+g3c@W%8+f z`O2BB)UIpNXtMTBBrRa}=Y-v`oIq0a6DYJo^IdM^P^(bSLV zSN_@?I`_Flgv`FKJVt&g!ZQxNDAbb|B!JRE!5K}m=>&xQK)z9rsZADC|FI1%qOZG9 z9A$jBlO>r&Rno}CULj63?WhAHsd!TYkOb-YlCtdmVfE@%I9h0VK7wQMbw(C>rppT3 z5kl(AK`g2xvv??nmf4B9l5061AB42wb*B^3!;7fhs;=z!B=C@8jK#Nm_I+P$mtx$NY28{D`b%;h z#^@2)Y77FbEt+2_K}tXz3v;M z@zs5B_4A%KQ`9(N3Ewje1$aT@`HK!3wZn*V>;4H#-i5xcn(-a-bZ_W^M9xez_&>+b zc}TKhNP*v{rJ=aV2{-S^Gss5zehKto$>qfj;fqUT^QMwnKC{2@fY!2z_dNe?U!AW1 zsZRb2l>aLx|7LX(NNA_?V~{qN8mnxZm8|xz-oT1&9lRfpzH)HG1A!$Vk-l~Tcu#^i z+1&QDJB$#HA^S(ihGVUQ%>84%NYN>wM4upkXsTC4Nmi*xSeQ>$HY*wgW3~Ll5EvA7 zx`qg06%b&eQW5R(aj;podI==YtS2a{=dZ#ZA{pT@+LgFF|b`ghx(4ad%ChpyTI=DKhaZ@#Fh!-U0; zgWqd%fEeN=Wg;DVE{b==D{8eofYn%QN3g(sRSp#wKIDjm-7eyP@^Ucy%yzb~0mZ5# zK`u$)zAEKpix9jRtd7f>AVW9@OENHBsRTRJr;3c|obpLK&|?2XruQJ&|gk>lHo?f7vCovLJcQ;O?GWF6V`;`-~7i%*M$ zb2i{0Mh`82d&fHvW=RD0GjAjh&w z4fi4auAoC+Lf0&`d&F|WkHckOm{ehTAY$5QgA=hXt!CsU3%UU&iQjvITA}>engWXK z(wJNXKu$0(n7((Tu*=@yW$jFn7zI#I~r~$yhO4y=FcG*_FKNR z5RXlyfY$WotwQ=7D1f9SDdK{eHQZWKeK%oMBH?4XeuPz|bD@QDyjtj6^fJggPe3*V1avnVPj-+ar}B6K+n(Wzri@ok6@C1>i{kAhMb9*lYmv@~ z7No&hOKX=?^9{KIr8i3pswGRoZRC5KQC$YnWtEv7j2!OmZR^jEFZVT`Gb;b!_dKFN z@{$x6l>TW|1U<%Kui zs^1#j%4FGMFKEOQz&pw;Z=Bb6KNIy*w$y~&-`v#wH- zm~M`}X*&#y1Ezt_!S)+nAzH`l^&x^$vm!BuRUjQgV?v^?&&QTpVq?Y=Dy(L1q^&FE z=YeK20q<&0c+#-)A1(RAlmD$w{#Q%>WuEBlupn(}Tj!)4W_CooE2_c)W7O5Zd{9$B7a-SR7DC_Xeovcx zgI+N(Oxr=5G$PKHybR;r0mlfOEqJ|8shT;(BxX1?z*j}@9=o=Yklj!T`h<~Gk1XQ* z25#ioBxs`!%cq#Rr8U`_2^2iUle@H3zV-H(d7hfLAMUDDLYSF3WFM(cVP{r{O3x@o zW;nfF?wY-O;g{gf*R3{g%>jR7@8u@=r7};JX}_Plk$IJoNUs+623p4$FX-!4rB-b0 zmp_{@hfNg_+CLSf28w)}2(bT9Ri}paPT+ZAfe<+N{I8!QmrbFO5y5i`lA&0UkiNgT z&Z0!UyTU;T4^?xsGrN};OnDXJOsx>Vt&N~6ZAH4Eb1ftINKLa<^T5CTi*N)f`Q)J3 zQ6>t`iw9N9A28nV?FH(T6_0t!@cXUBC|j0gRO5^dGn-23!qNO(xaD8u~>h$vlxdS=@Q5- zSwDE;xme|iEZ@GE#9PYJ5EKF8)?wnUY}w`Bthlx>ZDiG3-n0&;rt-w7_jCLxIW`-9 z_QRsqP414dbHC84Oxa{P)$v7crYb;)12w=K{7@({*;AksF-F{h1?RohXz7+UR&TR3 z25lumw^MkQnBp0u*sGV`lha@65~^5w?Lx0qLD!lQFeIGcV-2jz+%20wYHUzz z_2uxVjd1r5pLea5OY>0DHq(j!0M)SE+PXOfZ>CEk!h)0z51(Qb~8YrFL3^2F5W1pN?Ua6!i zU7ff8n`*R-%e|Qmj=LpiGQW6({$cuLJpP}$|%8|7q zpLe*f>>MojR`>{oyz!5`a&XLmg(191NWTDoJTZ_M_1T9=6mNuLV*ORR3;__l=O+z+&9wq(K}^$ zwC`O`ToY(&8cLjvg!WzxmVIkQaXDhCQFyrT~Qi zkcTky3IAD&JHj}GF8#CcFfwu&_10C3c13agbzD%3Rm;^A3AfeevEHk4|% zs@lLmVMq8e{&GEt-k%YzCN^ou$F(?(7~3{zc3|YZGSyp-dh4@MQNEvyc>!}uv(;qr zs?az5BJ`(e4VZC8R?_nM&kybmc_}pjyJ2NKJCg7o+Sg} ziY=wN8CW{AUup>=d460^-Mmi(ic41S>UXCSDI0EZU5la zyDa+~SC)<@J61;jXbO;lU9}2-Z2tMRIK|b^Qa6*xMjhi({$)0a;(H}H=ukX{P^Zg`123O6eOU*xrV(vd}fS--3bf6@qU_mjO>KF zC^+=24SPuL#cZVW6T)aVK$pXc-RF1l(95VSTm6S1?+_(5M*WJSUZ^>gCXp;4MxnS3 zziteNVw?(><7vgOa9Hem2u{J{NGeG^)seiKjXj@ac{#XK>UoNQN(ceZ%#@g73wx?6 z<|`<_lY9B>p=N$@e~f{hn~;CdOwpI=B_3>E1>8QOzEfSsE#6NO7}MB7wKwEpH_Wdn z4df}Qd0#`-CAOX0kU1{R5s^{D446%Z7f3Ej=s|)VM|GnrocT5y6)JcT&5}YPf^Tk8 zuRDgHHBruqu;*zs^(y@GVUqFmBtCqlG|*y@+7s9c)J1m=z)>V{jXC{Pq0Hd8<8`BVEWLaMnq2uw zLw0SQebZBJqMo?vVSQe{>2*!E@0I?Q^_lX{rH9f`JlG;e;zf_R_9e8{?o$#S5y9j6_^MBaQ)9Cng6{0595G2 Aod5s; diff --git a/ctools_ajax_sample/images/loading-large.gif b/ctools_ajax_sample/images/loading-large.gif deleted file mode 100644 index 1c72ebb554be018511ae972c3f2361dff02dce02..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 2545 zcwUXxSyU5Q8VB%8?NzBNDx$VB&P=EjO~^oZAmAV>L?MBQwjegNJ1EGavM90$(*_bk zAPb8uf}mkhg9k-Gg>emnHny$Oc01}hGpDunLG4+NPCvAsGvicrW}bMkp6i}_e|5j_ ztACtc7qKXP9+(Gy2H@@6w*Y|Kw{O3B^XAc`N2gDpe)jB{!{L~kn(FNAeDL6b%jI&r z-LGD~DlRTIo6TcmW7*l+;*t-1{N74F)2>a9S(c~`{X_+OiOc-{?HjW@GrcG?LspVg zlr2loO)uS;P)CKaq+Dn&jy}D0`!zj<`BTL%=IkwddX8~lWD@16t>W` z#OjSNYxZG?i6fTB@gN<*-QAH*Ec-$qtD4lACcM%&mc|*?hWo$rnN+cj<3;I;9 z-a=XL6I){6bZ@G}=@ZB=b`phOST^4wV#8Gpvue!bJJC26J=H5NHVi${&FVagDUvD)h`P5CXghqKIw8HnCq*=#}rB5Dql z11um06r|;XytDiuphCyWo6}061}wMiVi*LC#{`Xp^^WGt^SXtLUriiw*UX3*^B@c| z529V@3w8B25>E@WJzd8?9ACzFns)S7gB1!5^amS4Ep6=so3=S`i{Jg?E48p_J^SB z*6;S;eAISbIU{DkgOL#;23t2<2yyi$DYiA)roO$~bANRJzkqc&_PB|wzzSFWNfttl z_&5t6*fV(8xQt`Cd%h`?r4a?!UWP4-h*+>{O^jRP^$|;EDq*#T$?U@ zQg6;)->5mz(q?sbTZ528wxeb_gB-PD1GVt!@O}_hFeWa(>4JfGjJ zrg4_VX-4b}WkXZ5oUaT$QW2fU`zaV28LMkFJZlMr zGYzJ&(z0#Q1c~D$!PH>2YOyz}+uNCDc}dv{3A@vu$v40var1_)TU2BU?ai*;pxV_5 z7^$~_7{i)Rn(owbXy6{EE#V-FDYwDy2k~S~1gYD~Sa7D7Q zYU*md>Riw)WG)EERn5DcWaReLB6QVCMQHpgmly2ib2nEG&zYX8on5`$MsHj_|M^Eb zX?u@zsCnr+U)yVgHf7~f{rgG97_sW8np$gROAFJmXRjW`C8;ZRRluTfBfq73t4gw* zIOg1z!gE{(i*HgUgm`=NBpY9$SuT}Evu=G@^^}}uoyo$L;QbZnDrOW6dIZy99zps$ z0nJTj6X$Frqn&zL!#MG&A)${GQiC6pDo&B6?z{zNf2%{VClB3A?Zi;Qc8#wWg#F`R zzbShDOH!}>uQz6Uh7(o3{Y#~x%2Z~zCoADyS%EakHD~7S6$h|(^ZLzX7KUmd3Av-h zTdLUlF-``T$T=y_(?y5-JKC1vH=`MTsNc!wMzS&0s! zp>;ehwt1buIC-^zV!i1YbSpzF>(Yk_B(B&8V6-nXl)&o&ingHCE*#gBbZbrfIhY0$yx|Eki32a=I1r81U8Nfd|eqR;K*AJd}E(EfTrlIF8 zN%mhZ))f{+uyh%-6Jx}?s4^|wXDMwpL=4@@K%0&( zOc&5@KqbNSiO5ih+z9AO0MS~Vgw&&LA5WBGg`OQh&xWTx_3K59>4?&(hd7{_rA3l88-`{`t?%j%t3ZKsx*x9pZ&!$bA#>dC6 zU%zfPn}>&o4F<#3ty^1KT9Ci9BA?LNsheL+Hsz$ot=3^n0(T?-kR;dGth;R6rFHgQ zJEYbMYklQT>-N?5SIc)Ik&gkN3Y=0eyt05q@H(j!Mfs6G45BG!@~Ww4C_Tb^`h#yX=naMLCG}CwI17M( z^`-ATEiZ?bcZGl~v{Z)Sl!MZn-33kn0o_*8ki}z*4F}$6c>Rd+SYlCPP)hv*GLky@&n`Ccd1 zywA>6Z72}`GP`CXD`y~8AA?d*;X=(amPeO&zR{*K7nEwf`%soEm3v){nKjNtQ%!Kp zVlH3B2QZ#UGJRh5xk}W%oW7act>xUKZ5ja-Ipdokz^|Ngz<5DNUd;c;H6r4~y$g=B zD_m*ozC=iw3nC~ z4Th73pt)2oRwQ1?MMhqoUlE|RE~lA^Nd(jU+o($iBG+isbJh3m=VL4WQ2=b*uG)01w$Ac=v$wo4>VWr< z!FMn!D4=lx@Uc1oaLGvbykuHMwInf)ymQg0XCz9;8#rR=mrhAmT`B8R41{66433Lf zap{@M7et{FZR}+`77yF}mWlkc5--5a-%sWPAzQoGBP$~a+?s9IGDHc%D3zTWf<&@x zmHYSvU1i^k0D`Tu6~zQ4?O7mggaMLYM!xW0!?emjC`(MeameH3(iDoUmA4$#6ueWER{vV7S{gDLF_4qy%p#5F6$YcMznuf&jn3{VCLEWDX|Z9U2!|o z<3k~y&xg^h9V0NIka85|$r|`*2TBThqo_WVFErrx!n(3L)nE6ts8MJ7RF5xCqx%PS zCur-Dq%Zg199ik zd=YVNV&qvVph;ddwH_l_5~mp|P6Y@d+K%#sb`{On;`mzF7bC~8-N7}rPqV2kIxW9L zjb*^sFt7ARN;3M_4rPWOJzaSGGuG=+^j03y|u-BUfn0@YW{JhcpcU3>^T2TxM;^HQ_!e^Y|ny#2GM5dtvSf-(z);^nG*ISD zlPMUmL5~gkY|xzpDud5ibHJW`IkarBV}lJFEUBQr_iE-2hh$VxU!qsWPA&Rl$?(5I zv1hqwgDo5E*kHp3OD0%PUlD7;SySYE+S!t)h@%f}|Lw74JbF'; - html += '
'; - html += ' '; - html += ' '; - html += '
'; //Maybe someday add the option for some specific buttons. - html += ' '; //Maybe someday add some footer. - html += ' '; - html += ' '; - html += ' '; - html += ' '; - html += ' '; - html += ' '; - html += ' '; - html += ' '; - html += ' '; - html += ' '; - html += ' '; - html += ''; - - return html; - -} diff --git a/ctools_custom_content/ctools_custom_content.info b/ctools_custom_content/ctools_custom_content.info deleted file mode 100644 index a3f6665..0000000 --- a/ctools_custom_content/ctools_custom_content.info +++ /dev/null @@ -1,5 +0,0 @@ -name = Custom content panes -description = Create custom, exportable, reusable content panes for applications like Panels. -core = 7.x -package = Chaos tool suite -dependencies[] = ctools diff --git a/ctools_custom_content/ctools_custom_content.install b/ctools_custom_content/ctools_custom_content.install deleted file mode 100644 index 8348434..0000000 --- a/ctools_custom_content/ctools_custom_content.install +++ /dev/null @@ -1,67 +0,0 @@ - 'Contains exportable customized content for this site.', - 'export' => array( - 'identifier' => 'content', - 'bulk export' => TRUE, - 'primary key' => 'cid', - 'api' => array( - 'owner' => 'ctools', - 'api' => 'ctools_content', - 'minimum_version' => 1, - 'current_version' => 1, - ), - 'create callback' => 'ctools_content_type_new', - ), - 'fields' => array( - 'cid' => array( - 'type' => 'serial', - 'description' => 'A database primary key to ensure uniqueness', - 'not null' => TRUE, - 'no export' => TRUE, - ), - 'name' => array( - 'type' => 'varchar', - 'length' => '255', - 'description' => 'Unique ID for this content. Used to identify it programmatically.', - ), - 'admin_title' => array( - 'type' => 'varchar', - 'length' => '255', - 'description' => 'Administrative title for this content.', - ), - 'admin_description' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Administrative description for this content.', - 'object default' => '', - ), - 'category' => array( - 'type' => 'varchar', - 'length' => '255', - 'description' => 'Administrative category for this content.', - ), - 'settings' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Serialized settings for the actual content to be used', - 'serialize' => TRUE, - 'object default' => array(), - ), - ), - 'primary key' => array('cid'), - ); - - return $schema; -} diff --git a/ctools_custom_content/ctools_custom_content.module b/ctools_custom_content/ctools_custom_content.module deleted file mode 100644 index a2e8ee2..0000000 --- a/ctools_custom_content/ctools_custom_content.module +++ /dev/null @@ -1,98 +0,0 @@ - array( - 'title' => t('Administer custom content'), - 'description' => t('Add, edit and delete CTools custom stored custom content'), - ), - ); -} - -/** - * Implementation of hook_ctools_plugin_directory() to let the system know - * we implement task and task_handler plugins. - */ -function ctools_custom_content_ctools_plugin_directory($module, $plugin) { - // Most of this module is implemented as an export ui plugin, and the - // rest is in ctools/includes/ctools_custom_content.inc - if ($module == 'ctools' && $plugin == 'export_ui') { - return 'plugins/' . $plugin; - } -} - -/** - * Create callback for creating a new CTools custom content type. - * - * This ensures we get proper defaults from the plugin for its settings. - */ -function ctools_content_type_new($set_defaults) { - $item = ctools_export_new_object('ctools_custom_content', $set_defaults); - ctools_include('content'); - $plugin = ctools_get_content_type('custom'); - $item->settings = ctools_content_get_defaults($plugin, array()); - return $item; -} - -/** - * Implementation of hook_panels_dashboard_blocks(). - * - * Adds page information to the Panels dashboard. - */ -function ctools_custom_content_panels_dashboard_blocks(&$vars) { - $vars['links']['ctools_custom_content'] = array( - 'title' => l(t('Custom content'), 'admin/structure/ctools-content/add'), - 'description' => t('Custom content panes are basic HTML you enter that can be reused in all of your panels.'), - ); - - // Load all mini panels and their displays. - ctools_include('export'); - $items = ctools_export_crud_load_all('ctools_custom_content'); - $count = 0; - $rows = array(); - - foreach ($items as $item) { - $rows[] = array( - check_plain($item->admin_title), - array( - 'data' => l(t('Edit'), "admin/structure/ctools-content/list/$item->name/edit"), - 'class' => 'links', - ), - ); - - // Only show 10. - if (++$count >= 10) { - break; - } - } - - if ($rows) { - $content = theme('table', array('rows' => $rows, 'attributes' => array('class' => 'panels-manage'))); - } - else { - $content = '

' . t('There are no custom content panes.') . '

'; - } - - $vars['blocks']['ctools_custom_content'] = array( - 'title' => t('Manage custom content'), - 'link' => l(t('Go to list'), 'admin/structure/ctools-content'), - 'content' => $content, - 'class' => 'dashboard-content', - 'section' => 'right', - ); -} diff --git a/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc b/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc deleted file mode 100644 index 467dc58..0000000 --- a/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc +++ /dev/null @@ -1,20 +0,0 @@ - 'ctools_custom_content', - 'access' => 'administer custom content', - - 'menu' => array( - 'menu item' => 'ctools-content', - 'menu title' => 'Custom content panes', - 'menu description' => 'Add, edit or delete custom content panes.', - ), - - 'title singular' => t('content pane'), - 'title singular proper' => t('Content pane'), - 'title plural' => t('content panes'), - 'title plural proper' => t('Content panes'), - - 'handler' => 'ctools_custom_content_ui', -); - diff --git a/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php b/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php deleted file mode 100644 index ea522d3..0000000 --- a/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php +++ /dev/null @@ -1,122 +0,0 @@ - 'textfield', - '#title' => t('Category'), - '#description' => t('What category this content should appear in. If left blank the category will be "Miscellaneous".'), - '#default_value' => $form_state['item']->category, - ); - - $form['title'] = array( - '#type' => 'textfield', - '#default_value' => $form_state['item']->settings['title'], - '#title' => t('Title'), - ); - - $form['body'] = array( - '#type' => 'text_format', - '#title' => t('Body'), - '#default_value' => $form_state['item']->settings['body'], - '#format' => $form_state['item']->settings['format'], - ); - - $form['substitute'] = array( - '#type' => 'checkbox', - '#title' => t('Use context keywords'), - '#description' => t('If checked, context keywords will be substituted in this content.'), - '#default_value' => !empty($form_state['item']->settings['substitute']), - ); - } - - function edit_form_submit(&$form, &$form_state) { - parent::edit_form_submit($form, $form_state); - - // Since items in our settings are not in the schema, we have to do these manually: - $form_state['item']->settings['title'] = $form_state['values']['title']; - $form_state['item']->settings['body'] = $form_state['values']['body']['value']; - $form_state['item']->settings['format'] = $form_state['values']['body']['format']; - $form_state['item']->settings['substitute'] = $form_state['values']['substitute']; - } - - function list_form(&$form, &$form_state) { - parent::list_form($form, $form_state); - - $options = array('all' => t('- All -')); - foreach ($this->items as $item) { - $options[$item->category] = $item->category; - } - - $form['top row']['category'] = array( - '#type' => 'select', - '#title' => t('Category'), - '#options' => $options, - '#default_value' => 'all', - '#weight' => -10, - ); - } - - function list_filter($form_state, $item) { - if ($form_state['values']['category'] != 'all' && $form_state['values']['category'] != $item->category) { - return TRUE; - } - - return parent::list_filter($form_state, $item); - } - - function list_sort_options() { - return array( - 'disabled' => t('Enabled, title'), - 'title' => t('Title'), - 'name' => t('Name'), - 'category' => t('Category'), - 'storage' => t('Storage'), - ); - } - - function list_build_row($item, &$form_state, $operations) { - // Set up sorting - switch ($form_state['values']['order']) { - case 'disabled': - $this->sorts[$item->name] = empty($item->disabled) . $item->admin_title; - break; - case 'title': - $this->sorts[$item->name] = $item->admin_title; - break; - case 'name': - $this->sorts[$item->name] = $item->name; - break; - case 'category': - $this->sorts[$item->name] = $item->category; - break; - case 'storage': - $this->sorts[$item->name] = $item->type . $item->admin_title; - break; - } - - $this->rows[$item->name] = array( - 'data' => array( - array('data' => check_plain($item->name), 'class' => array('ctools-export-ui-name')), - array('data' => check_plain($item->admin_title), 'class' => array('ctools-export-ui-title')), - array('data' => check_plain($item->category), 'class' => array('ctools-export-ui-category')), - array('data' => theme('links', array('links' => $operations)), 'class' => array('ctools-export-ui-operations')), - ), - 'title' => check_plain($item->admin_description), - 'class' => array(!empty($item->disabled) ? 'ctools-export-ui-disabled' : 'ctools-export-ui-enabled'), - ); - } - - function list_table_header() { - return array( - array('data' => t('Name'), 'class' => array('ctools-export-ui-name')), - array('data' => t('Title'), 'class' => array('ctools-export-ui-title')), - array('data' => t('Category'), 'class' => array('ctools-export-ui-category')), - array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')), - ); - } - -} diff --git a/ctools_plugin_example/README.txt b/ctools_plugin_example/README.txt deleted file mode 100644 index 42edcdc..0000000 --- a/ctools_plugin_example/README.txt +++ /dev/null @@ -1,14 +0,0 @@ - -The CTools Plugin Example is an example for developers of how to CTools -access, argument, content type, context, and relationship plugins. - -There are a number of ways to profit from this: - -1. The code itself intends to be as simple and self-explanatory as possible. - Nothing fancy is attempted: It's just trying to use the plugin API to show - how it can be used. - -2. There is a sample panel. You can access it at /ctools_plugin_example/xxxx - to see how it works. - -3. There is Advanced Help at admin/advanced_help/ctools_plugin_example. \ No newline at end of file diff --git a/ctools_plugin_example/ctools_plugin_example.info b/ctools_plugin_example/ctools_plugin_example.info deleted file mode 100644 index d710125..0000000 --- a/ctools_plugin_example/ctools_plugin_example.info +++ /dev/null @@ -1,8 +0,0 @@ -name = Chaos Tools (CTools) Plugin Example -description = Shows how an external module can provide ctools plugins (for Panels, etc.). -package = Chaos tool suite -dependencies[] = ctools -dependencies[] = panels -dependencies[] = page_manager -dependencies[] = advanced_help -core = 7.x diff --git a/ctools_plugin_example/ctools_plugin_example.module b/ctools_plugin_example/ctools_plugin_example.module deleted file mode 100644 index 442969d..0000000 --- a/ctools_plugin_example/ctools_plugin_example.module +++ /dev/null @@ -1,94 +0,0 @@ - 'CTools plugin example', - 'description' => t("Demonstration code, advanced help, and a demo panel to show how to build ctools plugins."), - 'page callback' => 'ctools_plugin_example_explanation_page', - 'access arguments' => array('administer site configuration'), - 'type' => MENU_NORMAL_ITEM, - ); - - return $items; -} - -/** - * Implements hook_ctools_plugin_directory(). - * - * It simply tells panels where to find the .inc files that define various - * args, contexts, content_types. In this case the subdirectories of - * ctools_plugin_example/panels are used. - */ -function ctools_plugin_example_ctools_plugin_directory($module, $plugin) { - if ($module == 'ctools' && !empty($plugin)) { - return "plugins/$plugin"; - } -} - -/** - * Implement hook_ctools_plugin_api(). - * - * If you do this, CTools will pick up default panels pages in - * .pages_default.inc - */ -function ctools_plugin_example_ctools_plugin_api($module, $api) { - // @todo -- this example should explain how to put it in a different file. - if ($module == 'panels_mini' && $api == 'panels_default') { - return array('version' => 1); - } - if ($module == 'page_manager' && $api == 'pages_default') { - return array('version' => 1); - } -} - -/** - * Just provide an explanation page for the admin section - * @return unknown_type - */ -function ctools_plugin_example_explanation_page() { - $content = '

' . t("The CTools Plugin Example is simply a developer's demo of how to create plugins for CTools. It provides no useful functionality for an ordinary user.") . '

'; - - $content .= '

' . t( - 'There is a demo panel demonstrating much of the functionality provided at - CTools demo panel, and you can find documentation on the examples at - !ctools_plugin_example_help. - CTools itself provides documentation at !ctools_help. Mostly, though, the code itself is intended to be the teacher. - You can find it in %path.', - array( - '@demo_url' => url('ctools_plugin_example/xxxxx'), - '!ctools_plugin_example_help' => theme('advanced_help_topic', 'ctools_plugin_example', 'Chaos-Tools--CTools--Plugin-Examples', 'title'), - '!ctools_help' => theme('advanced_help_topic', 'ctools', 'plugins', 'title'), - '%path' => drupal_get_path('module', 'ctools_plugin_example'), - )) . '

'; - - return $content; -} diff --git a/ctools_plugin_example/ctools_plugin_example.pages_default.inc b/ctools_plugin_example/ctools_plugin_example.pages_default.inc deleted file mode 100644 index 10a7619..0000000 --- a/ctools_plugin_example/ctools_plugin_example.pages_default.inc +++ /dev/null @@ -1,451 +0,0 @@ -.pages_default.inc - * With this naming, no additional code needs to be provided. CTools will just find the file. - * The name of the hook is _default_page_manager_pages() - * - * This example provides two pages, but the returned array could - * have several pages. - * - * @return - * Array of pages, normally exported from Panels. - */ - -function ctools_plugin_example_default_page_manager_pages() { - - // begin exported panel. - - $page = new stdClass; - $page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */ - $page->api_version = 1; - $page->name = 'ctools_plugin_example'; - $page->task = 'page'; - $page->admin_title = 'CTools plugin example'; - $page->admin_description = 'This panel provides no functionality to a working Drupal system. It\'s intended to display the various sample plugins provided by the CTools Plugin Example module. '; - $page->path = 'ctools_plugin_example/%sc'; - $page->access = array( - 'logic' => 'and', - ); - $page->menu = array( - 'type' => 'normal', - 'title' => 'CTools plugin example', - 'name' => 'navigation', - 'weight' => '0', - 'parent' => array( - 'type' => 'none', - 'title' => '', - 'name' => 'navigation', - 'weight' => '0', - ), - ); - $page->arguments = array( - 'sc' => array( - 'id' => 2, - 'identifier' => 'simplecontext-arg', - 'name' => 'simplecontext_arg', - 'settings' => array(), - ), - ); - $page->conf = array(); - $page->default_handlers = array(); - $handler = new stdClass; - $handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ - $handler->api_version = 1; - $handler->name = 'page_ctools_panel_context'; - $handler->task = 'page'; - $handler->subtask = 'ctools_plugin_example'; - $handler->handler = 'panel_context'; - $handler->weight = 0; - $handler->conf = array( - 'title' => 'Panel', - 'no_blocks' => FALSE, - 'css_id' => '', - 'css' => '', - 'contexts' => array( - '0' => array( - 'name' => 'simplecontext', - 'id' => 1, - 'identifier' => 'Configured simplecontext (not from argument)', - 'keyword' => 'configured_simplecontext', - 'context_settings' => array( - 'sample_simplecontext_setting' => 'default simplecontext setting', - ), - ), - ), - 'relationships' => array( - '0' => array( - 'context' => 'argument_simplecontext_arg_2', - 'name' => 'relcontext_from_simplecontext', - 'id' => 1, - 'identifier' => 'Relcontext from simplecontext (from relationship)', - 'keyword' => 'relcontext', - ), - ), - 'access' => array( - 'logic' => 'and', - ), - ); - $display = new panels_display; - $display->layout = 'threecol_33_34_33_stacked'; - $display->layout_settings = array(); - $display->panel_settings = array( - 'style' => 'rounded_corners', - 'style_settings' => array( - 'default' => array( - 'corner_location' => 'pane', - ), - ), - ); - $display->cache = array(); - $display->title = 'CTools plugin example panel'; - $display->hide_title = FALSE; - $display->title_pane = 1; - $display->content = array(); - $display->panels = array(); - $pane = new stdClass; - $pane->pid = 'new-1'; - $pane->panel = 'left'; - $pane->type = 'no_context_content_type'; - $pane->subtype = 'no_context_content_type'; - $pane->shown = TRUE; - $pane->access = array(); - $pane->configuration = array( - 'item1' => 'contents of config item 1', - 'item2' => 'contents of config item 2', - 'override_title' => 0, - 'override_title_text' => '', - ); - $pane->cache = array(); - $pane->style = array(); - $pane->css = array(); - $pane->extras = array(); - $pane->position = 0; - $display->content['new-1'] = $pane; - $display->panels['left'][0] = 'new-1'; - $pane = new stdClass; - $pane->pid = 'new-2'; - $pane->panel = 'left'; - $pane->type = 'custom'; - $pane->subtype = 'custom'; - $pane->shown = TRUE; - $pane->access = array( - 'plugins' => array( - '0' => array( - 'name' => 'arg_length', - 'settings' => array( - 'greater_than' => '1', - 'arg_length' => '4', - ), - 'context' => 'argument_simplecontext_arg_2', - ), - ), - ); - $pane->configuration = array( - 'title' => 'Long Arg Visibility Block', - 'body' => 'This block will be here when the argument is longer than configured arg length. It uses the \'arg_length\' access plugin to test against the length of the argument used for Simplecontext.', - 'format' => '1', - 'substitute' => 1, - ); - $pane->cache = array(); - $pane->style = array(); - $pane->css = array(); - $pane->extras = array(); - $pane->position = 1; - $display->content['new-2'] = $pane; - $display->panels['left'][1] = 'new-2'; - $pane = new stdClass; - $pane->pid = 'new-3'; - $pane->panel = 'left'; - $pane->type = 'custom'; - $pane->subtype = 'custom'; - $pane->shown = TRUE; - $pane->access = array( - 'plugins' => array( - '0' => array( - 'name' => 'arg_length', - 'settings' => array( - 'greater_than' => '0', - 'arg_length' => '4', - ), - 'context' => 'argument_simplecontext_arg_2', - ), - ), - ); - $pane->configuration = array( - 'title' => 'Short Arg Visibility', - 'body' => 'This block appears when the simplecontext argument is less than the configured length.', - 'format' => '1', - 'substitute' => 1, - ); - $pane->cache = array(); - $pane->style = array(); - $pane->css = array(); - $pane->extras = array(); - $pane->position = 2; - $display->content['new-3'] = $pane; - $display->panels['left'][2] = 'new-3'; - $pane = new stdClass; - $pane->pid = 'new-4'; - $pane->panel = 'middle'; - $pane->type = 'simplecontext_content_type'; - $pane->subtype = 'simplecontext_content_type'; - $pane->shown = TRUE; - $pane->access = array(); - $pane->configuration = array( - 'buttons' => NULL, - '#validate' => NULL, - '#submit' => NULL, - '#action' => NULL, - 'context' => 'argument_simplecontext_arg_2', - 'aligner_start' => NULL, - 'override_title' => 1, - 'override_title_text' => 'Simplecontext (with an arg)', - 'aligner_stop' => NULL, - 'override_title_markup' => NULL, - 'config_item_1' => 'Config item 1 contents', - '#build_id' => NULL, - '#type' => NULL, - '#programmed' => NULL, - 'form_build_id' => 'form-19c4ae6cb54fad8f096da46e95694e5a', - '#token' => NULL, - 'form_token' => '17141d3531eaa7b609da78afa6f3b560', - 'form_id' => 'simplecontext_content_type_edit_form', - '#id' => NULL, - '#description' => NULL, - '#attributes' => NULL, - '#required' => NULL, - '#tree' => NULL, - '#parents' => NULL, - '#method' => NULL, - '#post' => NULL, - '#processed' => NULL, - '#defaults_loaded' => NULL, - ); - $pane->cache = array(); - $pane->style = array(); - $pane->css = array(); - $pane->extras = array(); - $pane->position = 0; - $display->content['new-4'] = $pane; - $display->panels['middle'][0] = 'new-4'; - $pane = new stdClass; - $pane->pid = 'new-5'; - $pane->panel = 'middle'; - $pane->type = 'simplecontext_content_type'; - $pane->subtype = 'simplecontext_content_type'; - $pane->shown = TRUE; - $pane->access = array(); - $pane->configuration = array( - 'buttons' => NULL, - '#validate' => NULL, - '#submit' => NULL, - '#action' => NULL, - 'context' => 'context_simplecontext_1', - 'aligner_start' => NULL, - 'override_title' => 1, - 'override_title_text' => 'Configured simplecontext content type (not from arg)', - 'aligner_stop' => NULL, - 'override_title_markup' => NULL, - 'config_item_1' => '(configuration for simplecontext)', - '#build_id' => NULL, - '#type' => NULL, - '#programmed' => NULL, - 'form_build_id' => 'form-d016200490abd015dc5b8a7e366d76ea', - '#token' => NULL, - 'form_token' => '17141d3531eaa7b609da78afa6f3b560', - 'form_id' => 'simplecontext_content_type_edit_form', - '#id' => NULL, - '#description' => NULL, - '#attributes' => NULL, - '#required' => NULL, - '#tree' => NULL, - '#parents' => NULL, - '#method' => NULL, - '#post' => NULL, - '#processed' => NULL, - '#defaults_loaded' => NULL, - ); - $pane->cache = array(); - $pane->style = array(); - $pane->css = array(); - $pane->extras = array(); - $pane->position = 1; - $display->content['new-5'] = $pane; - $display->panels['middle'][1] = 'new-5'; - $pane = new stdClass; - $pane->pid = 'new-6'; - $pane->panel = 'middle'; - $pane->type = 'custom'; - $pane->subtype = 'custom'; - $pane->shown = TRUE; - $pane->access = array(); - $pane->configuration = array( - 'admin_title' => 'Simplecontext keyword usage', - 'title' => 'Simplecontext keyword usage', - 'body' => 'Demonstrating context keyword usage: - item1 is %sc:item1 - item2 is %sc:item2 - description is %sc:description', - 'format' => '1', - 'substitute' => 1, - ); - $pane->cache = array(); - $pane->style = array(); - $pane->css = array(); - $pane->extras = array(); - $pane->position = 2; - $display->content['new-6'] = $pane; - $display->panels['middle'][2] = 'new-6'; - $pane = new stdClass; - $pane->pid = 'new-7'; - $pane->panel = 'right'; - $pane->type = 'relcontext_content_type'; - $pane->subtype = 'relcontext_content_type'; - $pane->shown = TRUE; - $pane->access = array(); - $pane->configuration = array( - 'buttons' => NULL, - '#validate' => NULL, - '#submit' => NULL, - '#action' => NULL, - 'context' => 'relationship_relcontext_from_simplecontext_1', - 'aligner_start' => NULL, - 'override_title' => 0, - 'override_title_text' => '', - 'aligner_stop' => NULL, - 'override_title_markup' => NULL, - 'config_item_1' => 'some stuff in this one', - '#build_id' => NULL, - '#type' => NULL, - '#programmed' => NULL, - 'form_build_id' => 'form-8485f84511bd06e51b4a48e998448054', - '#token' => NULL, - 'form_token' => '1c3356396374d51d7d2531a10fd25310', - 'form_id' => 'relcontext_edit_form', - '#id' => NULL, - '#description' => NULL, - '#attributes' => NULL, - '#required' => NULL, - '#tree' => NULL, - '#parents' => NULL, - '#method' => NULL, - '#post' => NULL, - '#processed' => NULL, - '#defaults_loaded' => NULL, - ); - $pane->cache = array(); - $pane->style = array(); - $pane->css = array(); - $pane->extras = array(); - $pane->position = 0; - $display->content['new-7'] = $pane; - $display->panels['right'][0] = 'new-7'; - $pane = new stdClass; - $pane->pid = 'new-8'; - $pane->panel = 'top'; - $pane->type = 'custom'; - $pane->subtype = 'custom'; - $pane->shown = TRUE; - $pane->access = array(); - $pane->configuration = array( - 'title' => 'Demonstrating ctools plugins', - 'body' => 'The CTools Plugin Example module (and this panel page) are just here to demonstrate how to build CTools plugins. - - ', - 'format' => '2', - 'substitute' => 1, - ); - $pane->cache = array(); - $pane->style = array(); - $pane->css = array(); - $pane->extras = array(); - $pane->position = 0; - $display->content['new-8'] = $pane; - $display->panels['top'][0] = 'new-8'; - $handler->conf['display'] = $display; - $page->default_handlers[$handler->name] = $handler; - - // end of exported panel. - $pages['ctools_plugin_example_demo_page'] = $page; - - // begin exported panel - - $page = new stdClass; - $page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */ - $page->api_version = 1; - $page->name = 'ctools_plugin_example_base'; - $page->task = 'page'; - $page->admin_title = 'CTools Plugin Example base page'; - $page->admin_description = 'This panel is for when people hit /ctools_plugin_example without an argument. We can use it to tell people to move on.'; - $page->path = 'ctools_plugin_example'; - $page->access = array(); - $page->menu = array(); - $page->arguments = array(); - $page->conf = array(); - $page->default_handlers = array(); - $handler = new stdClass; - $handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ - $handler->api_version = 1; - $handler->name = 'page_ctools_plugin_example_base_panel_context'; - $handler->task = 'page'; - $handler->subtask = 'ctools_plugin_example_base'; - $handler->handler = 'panel_context'; - $handler->weight = 0; - $handler->conf = array( - 'title' => 'Panel', - 'no_blocks' => FALSE, - 'css_id' => '', - 'css' => '', - 'contexts' => array(), - 'relationships' => array(), - ); - $display = new panels_display; - $display->layout = 'onecol'; - $display->layout_settings = array(); - $display->panel_settings = array(); - $display->cache = array(); - $display->title = ''; - $display->hide_title = FALSE; - $display->content = array(); - $display->panels = array(); - $pane = new stdClass; - $pane->pid = 'new-1'; - $pane->panel = 'middle'; - $pane->type = 'custom'; - $pane->subtype = 'custom'; - $pane->shown = TRUE; - $pane->access = array(); - $pane->configuration = array( - 'title' => 'Use this page with an argument', - 'body' => 'This demo page works if you use an argument, like ctools_plugin_example/xxxxx.', - 'format' => '1', - 'substitute' => NULL, - ); - $pane->cache = array(); - $pane->style = array(); - $pane->css = array(); - $pane->extras = array(); - $pane->position = 0; - $display->content['new-1'] = $pane; - $display->panels['middle'][0] = 'new-1'; - $handler->conf['display'] = $display; - $page->default_handlers[$handler->name] = $handler; - // end exported panel. - - $pages['base_page'] = $page; - - return $pages; -} \ No newline at end of file diff --git a/ctools_plugin_example/help/Access-Plugins--Determining-access-and-visibility.html b/ctools_plugin_example/help/Access-Plugins--Determining-access-and-visibility.html deleted file mode 100644 index 781260e..0000000 --- a/ctools_plugin_example/help/Access-Plugins--Determining-access-and-visibility.html +++ /dev/null @@ -1,17 +0,0 @@ -
- - - - -
-

We can use access plugins to determine access to a page or visibility of the panes in a page. Basically, we just determine access based on configuration settings and the various contexts that are available to us.

-

The arbitrary example in plugins/access/arg_length.inc determines access based on the length of the simplecontext argument. You can configure whether access should be granted if the simplecontext argument is greater or less than some number.

-
- -
-
-
- -
- -
diff --git a/ctools_plugin_example/help/Argument-Plugins--Starting-at-the-beginning.html b/ctools_plugin_example/help/Argument-Plugins--Starting-at-the-beginning.html deleted file mode 100644 index 4dd569d..0000000 --- a/ctools_plugin_example/help/Argument-Plugins--Starting-at-the-beginning.html +++ /dev/null @@ -1,20 +0,0 @@ -
- - - - -
-

Contexts are fundamental to CTools, and they almost always start with an argument to a panels page, so we'll start there too.

-

We first need to process an argument.

-

We're going to work with a "Simplecontext" context type and argument, and then with a content type that displays it. So we'll start by with the Simplecontext argument plugin in plugins/arguments/simplecontext_arg.inc.

-

Note that the name of the file (simplecontext_arg.inc) is built from the machine name of our plugin (simplecontext_arg). And note also that the primary function that we use to provide our argument (ctools_plugin_example_simplecontext_arg_ctools_arguments()) is also built from the machine name. This magic is most of the naming magic that you have to know.

-

You can browse plugins/arguments/simplecontext_arg.inc and see the little that it does.

-
- -
-
-
- -
- -
diff --git a/ctools_plugin_example/help/Chaos-Tools--CTools--Plugin-Examples.html b/ctools_plugin_example/help/Chaos-Tools--CTools--Plugin-Examples.html deleted file mode 100644 index 7576c80..0000000 --- a/ctools_plugin_example/help/Chaos-Tools--CTools--Plugin-Examples.html +++ /dev/null @@ -1,19 +0,0 @@ -
- - - - -
-

This demonstration module is intended for developers to look at and play with. CTools plugins are not terribly difficult to do, but it can be hard to sort through the various arguments and required functions. The idea here is that you should have a starting point for most anything you want to do. Just work through the example, and then start experimenting with changing it.

-

There are two parts to this demo:

-

First, there is a sample panel provided that uses all the various plugins. It's at ctools_example/12345. You can edit the panel and configure all the panes on it.

-

Second, the code is there for you to experiment with and change as you see fit. Sometimes starting with simple code and working with it can take you places that it's hard to go when you're looking at more complex examples.

-
- -
-
-
- -
- -
diff --git a/ctools_plugin_example/help/Content-Type-Plugins--Displaying-content-using-a-context.html b/ctools_plugin_example/help/Content-Type-Plugins--Displaying-content-using-a-context.html deleted file mode 100644 index 918a13c..0000000 --- a/ctools_plugin_example/help/Content-Type-Plugins--Displaying-content-using-a-context.html +++ /dev/null @@ -1,17 +0,0 @@ -
- - - - -
-

Now we get to the heart of the matter: Building a content type plugin. A content type plugin uses the contexts available to it to display something. plugins/content_types/simplecontext_content_type.inc does this work for us.

-

Note that our content type also has an edit form which can be used to configure its behavior. This settings form is accessed through the panels interface, and it's up to you what the settings mean to the code and the generation of content in the display rendering.

-
- -
-
-
- -
- -
diff --git a/ctools_plugin_example/help/Context-plugins--Creating-a--context--from-an-argument.html b/ctools_plugin_example/help/Context-plugins--Creating-a--context--from-an-argument.html deleted file mode 100644 index e8efbb3..0000000 --- a/ctools_plugin_example/help/Context-plugins--Creating-a--context--from-an-argument.html +++ /dev/null @@ -1,21 +0,0 @@ -
- - - - -
-

Now that we have a plugin for a simplecontext argument, we can create a plugin for a simplecontext context.

-

Normally, a context would take an argument which is a key like a node ID (nid) and retrieve a more complex object from a database or whatever. In our example, we'll artificially transform the argument into an arbitrary "context" data object.

-

plugins/contexts/simplecontext.inc implements our context.

-

Note that there are actually two ways to create a context. The normal one, which we've been referring to, is to create a context from an argument. However, it is also possible to configure a context in a panel using the panels interface. This is quite inflexible, but might be useful for configuring single page. However, it means that we have a settings form for exactly that purpose. Our context would have to know how to create itself from a settings form as well as from an argument. Simplecontext can do that.

-

A context plugin can also provide keywords that expose parts of its context using keywords like masterkeyword:dataitem. The node plugin for ctools has node:nid and node:title, for example. The simplecontext plugin here provides the simplest of keywords.

- -
- -
-
-
- -
- -
diff --git a/ctools_plugin_example/help/Module-setup-and-hooks.html b/ctools_plugin_example/help/Module-setup-and-hooks.html deleted file mode 100644 index f816917..0000000 --- a/ctools_plugin_example/help/Module-setup-and-hooks.html +++ /dev/null @@ -1,20 +0,0 @@ -
- - - - -
-

Your module must provide a few things so that your plugins can be found.

-

First, you need to implement hook_ctools_plugin_directory(). Here we're telling CTools that our plugins will be found in the module's directory in the plugins/<plugintype> directory. Context plugins will be in ctools_plugin_example/plugins/contexts, Content-type plugins will be in ctools_plugin_example/plugins/content_types.

-

<?php
function ctools_plugin_example_ctools_plugin_directory($module, $plugin) {
  if (
$module == 'ctools' && !empty($plugin)) {
    return
"plugins/$plugin";
  }
}
?>

-

Second, if you module wants to provide default panels pages, you can implement hook_ctools_plugin_api(). CTools will then pick up your panels pages in the file named <modulename>.pages_default.inc.

-

<?php
function ctools_plugin_example_ctools_plugin_api($module, $api) {
  if (
$module == 'panels_mini' && $api == 'panels_default') {
    return array(
'version' => 1);
  }
  if (
$module == 'page_manager' && $api == 'pages_default') {
    return array(
'version' => 1);
  }
}
?>

-
- -
-
-
- -
- -
diff --git a/ctools_plugin_example/help/Relationships--Letting-one-context-take-us-to-another.html b/ctools_plugin_example/help/Relationships--Letting-one-context-take-us-to-another.html deleted file mode 100644 index 7691245..0000000 --- a/ctools_plugin_example/help/Relationships--Letting-one-context-take-us-to-another.html +++ /dev/null @@ -1,18 +0,0 @@ -
- - - - -
-

Often a single data type can lead us to other data types. For example, a node has a user (the author) and the user has data associated with it.

-

A relationship plugin allows this kind of data to be accessed.

-

An example relationship plugin is provided in plugins/relationships/relcontext_from_simplecontext.inc. It looks at a simplecontext (which we got from an argument) and builds an (artificial) "relcontext" from that.

-
- -
-
-
- -
- -
diff --git a/ctools_plugin_example/help/ctools_plugin_example.help.ini b/ctools_plugin_example/help/ctools_plugin_example.help.ini deleted file mode 100644 index 6fb3d4c..0000000 --- a/ctools_plugin_example/help/ctools_plugin_example.help.ini +++ /dev/null @@ -1,42 +0,0 @@ -[Chaos-Tools--CTools--Plugin-Examples] -title = CTools Plugin Examples -file = Chaos-Tools--CTools--Plugin-Examples -weight = 0 -parent = - -[Module-setup-and-hooks] -title = Module setup and hooks -file = Module-setup-and-hooks -weight = -15 -parent = Chaos-Tools--CTools--Plugin-Examples - -[Argument-Plugins--Starting-at-the-beginning] -title = Argument Plugins: Starting at the beginning -file = Argument-Plugins--Starting-at-the-beginning -weight = -14 -parent = Chaos-Tools--CTools--Plugin-Examples - -[Context-plugins--Creating-a--context--from-an-argument] -title = Context plugins: Creating a context from an argument -file = Context-plugins--Creating-a--context--from-an-argument -weight = -13 -parent = Chaos-Tools--CTools--Plugin-Examples - -[Content-Type-Plugins--Displaying-content-using-a-context] -title = Content Type Plugins: Displaying content using a context -file = Content-Type-Plugins--Displaying-content-using-a-context -weight = -12 -parent = Chaos-Tools--CTools--Plugin-Examples - -[Access-Plugins--Determining-access-and-visibility] -title = Access Plugins: Determining access and visibility -file = Access-Plugins--Determining-access-and-visibility -weight = -11 -parent = Chaos-Tools--CTools--Plugin-Examples - -[Relationships--Letting-one-context-take-us-to-another] -title = Relationships: Letting one context take us to another -file = Relationships--Letting-one-context-take-us-to-another -weight = -10 -parent = Chaos-Tools--CTools--Plugin-Examples - diff --git a/ctools_plugin_example/plugins/access/arg_length.inc b/ctools_plugin_example/plugins/access/arg_length.inc deleted file mode 100644 index 2a09eea..0000000 --- a/ctools_plugin_example/plugins/access/arg_length.inc +++ /dev/null @@ -1,65 +0,0 @@ - t("Arg length"), - 'description' => t('Control access by length of simplecontext argument.'), - 'callback' => 'ctools_plugin_example_arg_length_ctools_access_check', - 'settings form' => 'ctools_plugin_example_arg_length_ctools_access_settings', - 'summary' => 'ctools_plugin_example_arg_length_ctools_access_summary', - 'required context' => new ctools_context_required(t('Simplecontext'), 'simplecontext'), -); - -/** - * Settings form for the 'by role' access plugin. - */ -function ctools_plugin_example_arg_length_ctools_access_settings(&$form, &$form_state, $conf) { - $form['settings']['greater_than'] = array( - '#type' => 'radios', - '#title' => t('Grant access if simplecontext argument length is'), - '#options' => array(1 => t('Greater than'), 0 => t('Less than or equal to')), - '#default_value' => $conf['greater_than'], - ); - $form['settings']['arg_length'] = array( - '#type' => 'textfield', - '#title' => t('Length of simplecontext argument'), - '#size' => 3, - '#default_value' => $conf['arg_length'], - '#description' => t('Access/visibility will be granted based on arg length.'), - ); -} - -/** - * Check for access. - */ -function ctools_plugin_example_arg_length_ctools_access_check($conf, $context) { - // As far as I know there should always be a context at this point, but this - // is safe. - if (empty($context) || empty($context->data)) { - return FALSE; - } - $compare = ($context->arg_length > $conf['arg_length']); - if (($compare && $conf['greater_than']) || (!$compare && !$conf['greater_than'])) { - return TRUE; - } - return FALSE; -} - -/** - * Provide a summary description based upon the checked roles. - */ -function ctools_plugin_example_arg_length_ctools_access_summary($conf, $context) { - return t('Simpletext argument must be !comp @length characters', - array('!comp' => $conf['greater_than'] ? 'greater than' : 'less than or equal to', - '@length' => $conf['arg_length'])); -} - diff --git a/ctools_plugin_example/plugins/access/example_role.inc b/ctools_plugin_example/plugins/access/example_role.inc deleted file mode 100644 index bbe364c..0000000 --- a/ctools_plugin_example/plugins/access/example_role.inc +++ /dev/null @@ -1,76 +0,0 @@ - t("CTools example: role"), - 'description' => t('Control access by role.'), - 'callback' => 'ctools_plugin_example_example_role_ctools_access_check', - 'default' => array('rids' => array()), - 'settings form' => 'ctools_plugin_example_example_role_ctools_access_settings', - 'summary' => 'ctools_plugin_example_example_role_ctools_access_summary', - 'required context' => new ctools_context_required(t('User'), 'user'), -); - -/** - * Settings form for the 'by role' access plugin. - */ -function ctools_plugin_example_example_role_ctools_access_settings(&$form, &$form_state, $conf) { - $form['settings']['rids'] = array( - '#type' => 'checkboxes', - '#title' => t('Role'), - '#default_value' => $conf['rids'], - '#options' => ctools_get_roles(), - '#description' => t('Only the checked roles will be granted access.'), - ); -} - -/** - * Compress the roles allowed to the minimum. - */ -function ctools_plugin_example_example_role_ctools_access_settings_submit(&$form, &$form_state) { - $form_state['values']['settings']['rids'] = array_keys(array_filter($form_state['values']['settings']['rids'])); -} - -/** - * Check for access. - */ -function ctools_plugin_example_example_role_ctools_access_check($conf, $context) { - // As far as I know there should always be a context at this point, but this - // is safe. - if (empty($context) || empty($context->data) || !isset($context->data->roles)) { - return FALSE; - } - - $roles = array_keys($context->data->roles); - $roles[] = $context->data->uid ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID; - return (bool) array_intersect($conf['rids'], $roles); -} - -/** - * Provide a summary description based upon the checked roles. - */ -function ctools_plugin_example_example_role_ctools_access_summary($conf, $context) { - if (!isset($conf['rids'])) { - $conf['rids'] = array(); - } - $roles = ctools_get_roles(); - $names = array(); - foreach (array_filter($conf['rids']) as $rid) { - $names[] = check_plain($roles[$rid]); - } - if (empty($names)) { - return t('@identifier can have any role', array('@identifier' => $context->identifier)); - } - return format_plural(count($names), '@identifier must have role "@roles"', '@identifier can be one of "@roles"', array('@roles' => implode(', ', $names), '@identifier' => $context->identifier)); -} - diff --git a/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc b/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc deleted file mode 100644 index 51c7c60..0000000 --- a/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc +++ /dev/null @@ -1,52 +0,0 @@ - t("Simplecontext arg"), - // keyword to use for %substitution - 'keyword' => 'simplecontext', - 'description' => t('Creates a "simplecontext" from the arg.'), - 'context' => 'simplecontext_arg_context', - // 'settings form' => 'simplecontext_arg_settings_form', - - // placeholder_form is used in panels preview, for example, so we can - // preview without getting the arg from a URL - 'placeholder form' => array( - '#type' => 'textfield', - '#description' => t('Enter the simplecontext arg'), - ), -); - -/** - * Get the simplecontext context using the arg. In this case we're just going - * to manufacture the context from the data in the arg, but normally it would - * be an API call, db lookup, etc. - */ -function simplecontext_arg_context($arg = NULL, $conf = NULL, $empty = FALSE) { - // If $empty == TRUE it wants a generic, unfilled context. - if ($empty) { - return ctools_context_create_empty('simplecontext'); - } - // Do whatever error checking is required, returning FALSE if it fails the test - // Normally you'd check - // for a missing object, one you couldn't create, etc. - if (empty($arg)) { - return FALSE; - } - return ctools_context_create('simplecontext', $arg); -} diff --git a/ctools_plugin_example/plugins/content_types/icon_example.png b/ctools_plugin_example/plugins/content_types/icon_example.png deleted file mode 100644 index 58c6bee4fde937b4f09ca13cfdf2d90d49cdad64..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 566 zcwPZE0?GY}P){vZ`Tt4V^$2sChDDvSXGLx(hiFm;;i>d7QU z9XOkN?%|$$#M8sXo+;vNf?bN=F2y?doJZzY=KT#csHqB&`$~4XZTiNG`QWO2L8cKS zd1)KrM2hlRP5qt}W4Qe~?i!m;0EvoJjMH5-$&RHoF5~kscm6c@RF%K+)I}Z-R5P3R zlAKyU9iiR)tO?Mjs<<{s{}V>bX^Fegk~j2vEl%7%%CnKfdJRB)9_F@xf+0#YF-3Zm+?YW; zWrd_I%cO1y|I@*Nht$2z=SP)=HCRog?E<5Y_RkI^DqGz)U1R$QJ=ssw-9~!64=6iy zU)ncbSTIR12ufq3aXFRgaIuEG7Tx(FGCR*vr>3q-g!PQ}6}aR2}S07*qoM6N<$ Ef;?gI>i_@% diff --git a/ctools_plugin_example/plugins/content_types/no_context_content_type.inc b/ctools_plugin_example/plugins/content_types/no_context_content_type.inc deleted file mode 100644 index 28d749b..0000000 --- a/ctools_plugin_example/plugins/content_types/no_context_content_type.inc +++ /dev/null @@ -1,116 +0,0 @@ - t('CTools example no context content type'), - 'description' => t('No context content type - requires and uses no context.'), - - // 'single' => TRUE means has no subtypes. - 'single' => TRUE, - // Constructor. - 'content_types' => array('no_context_content_type'), - // Name of a function which will render the block. - 'render callback' => 'no_context_content_type_render', - // The default context. - 'defaults' => array(), - - // This explicitly declares the config form. Without this line, the func would be - // ctools_plugin_example_no_context_content_type_edit_form. - 'edit form' => 'no_context_content_type_edit_form', - - // Icon goes in the directory with the content type. - 'icon' => 'icon_example.png', - 'category' => array(t('CTools Examples'), -9), - - // this example does not provide 'admin info', which would populate the - // panels builder page preview. -); - -/** - * Run-time rendering of the body of the block. - * - * @param $subtype - * @param $conf - * Configuration as done at admin time. - * @param $args - * @param $context - * Context - in this case we don't have any. - * - * @return - * An object with at least title and content members. - */ -function no_context_content_type_render($subtype, $conf, $args, $context) { - $block = new stdClass(); - - $ctools_help = theme('advanced_help_topic', 'ctools', 'plugins', 'title'); - $ctools_plugin_example_help = theme('advanced_help_topic', 'ctools_plugin_example', 'Chaos-Tools--CTools--Plugin-Examples', 'title'); - - // The title actually used in rendering - $block->title = check_plain("No-context content type"); - $block->content = t(" -
Welcome to the CTools Plugin Example demonstration content type. - - This block is a content type which requires no context at all. It's like a custom block, - but not even that sophisticated. - - For more information on the example plugins, please see the advanced help for - - {$ctools_help} and {$ctools_plugin_example_help} -
- "); - if (!empty($conf)) { - $block->content .= '
The only information that can be displayed in this block comes from the code and its settings form:
'; - $block->content .= '
' . var_export($conf, TRUE) . '
'; - } - - return $block; - -} - -/** - * 'Edit form' callback for the content type. - * This example just returns a form; validation and submission are standard drupal - * Note that if we had not provided an entry for this in hook_content_types, - * this could have had the default name - * ctools_plugin_example_no_context_content_type_edit_form. - * - */ -function no_context_content_type_edit_form(&$form, &$form_state) { - $conf = $form_state['conf']; - $form['item1'] = array( - '#type' => 'textfield', - '#title' => t('Item1'), - '#size' => 50, - '#description' => t('The setting for item 1.'), - '#default_value' => !empty($conf['item1']) ? $conf['item1'] : '', - '#prefix' => '
', - '#suffix' => '
', - ); - $form['item2'] = array( - '#type' => 'textfield', - '#title' => t('Item2'), - '#size' => 50, - '#description' => t('The setting for item 2'), - '#default_value' => !empty($conf['item2']) ? $conf['item2'] : '', - '#prefix' => '
', - '#suffix' => '
', - ); - return $form; -} - -function no_context_content_type_edit_form_submit(&$form, &$form_state) { - foreach (array('item1', 'item2') as $key) { - $form_state['conf'][$key] = $form_state['values'][$key]; - } -} \ No newline at end of file diff --git a/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc b/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc deleted file mode 100644 index b0742e0..0000000 --- a/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc +++ /dev/null @@ -1,103 +0,0 @@ - t('CTools example relcontext content type'), - 'admin info' => 'ctools_plugin_example_relcontext_content_type_admin_info', - 'content_types' => 'relcontext_content_type', - 'single' => TRUE, - 'render callback' => 'relcontext_content_type_render', - // Icon goes in the directory with the content type. Here, in plugins/content_types. - 'icon' => 'icon_example.png', - 'description' => t('Relcontext content type - works with relcontext context.'), - 'required context' => new ctools_context_required(t('Relcontext'), 'relcontext'), - 'category' => array(t('CTools Examples'), -9), - 'edit form' => 'relcontext_edit_form', - - // this example does not provide 'admin info', which would populate the - // panels builder page preview. - -); - -/** - * Run-time rendering of the body of the blcok - * - * @param $subtype - * @param $conf - * Configuration as done at admin time - * @param $args - * @param $context - * Context - in this case we don't have any - * - * @return - * An object with at least title and content members - */ -function relcontext_content_type_render($subtype, $conf, $args, $context) { - $data = $context->data; - $block = new stdClass(); - - // Don't forget to check this data if it's untrusted. - // The title actually used in rendering. - $block->title = "Relcontext content type"; - $block->content = t(" - This is a block of data created by the Relcontent content type. - Data in the block may be assembled from static text (like this) or from the - content type settings form (\$conf) for the content type, or from the context - that is passed in.
- In our case, the configuration form (\$conf) has just one field, 'config_item_1; - and it's configured with: - "); - if (!empty($conf)) { - $block->content .= '
' . var_export($conf['config_item_1'], TRUE) . '
'; - } - if (!empty($context)) { - $block->content .= '
The args ($args) were
' . - var_export($args, TRUE) . '
'; - } - $block->content .= '
And the relcontext context ($context->data->description) - (which was created from a - simplecontext context) was
' . - print_r($context->data->description, TRUE) . '
'; - return $block; -} - -/** - * 'Edit' callback for the content type. - * This example just returns a form. - * - */ -function relcontext_edit_form(&$form, &$form_state) { - $conf = $form_state['conf']; - - $form['config_item_1'] = array( - '#type' => 'textfield', - '#title' => t('Config Item 1 (relcontext)'), - '#size' => 50, - '#description' => t('Setting for relcontext.'), - '#default_value' => !empty($conf['config_item_1']) ? $conf['config_item_1'] : '', - '#prefix' => '
', - '#suffix' => '
', - ); - return $form; -} - -function relcontext_edit_form_submit(&$form, &$form_state) { - foreach (element_children($form) as $key) { - if (!empty($form_state['values'][$key])) { - $form_state['conf'][$key] = $form_state['values'][$key]; - } - } -} diff --git a/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc b/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc deleted file mode 100644 index 82291d0..0000000 --- a/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc +++ /dev/null @@ -1,129 +0,0 @@ - t('Simplecontext content type'), - 'content_types' => 'simplecontext_content_type', - // 'single' means not to be subtyped. - 'single' => TRUE, - // Name of a function which will render the block. - 'render callback' => 'simplecontext_content_type_render', - - // Icon goes in the directory with the content type. - 'icon' => 'icon_example.png', - 'description' => t('Simplecontext content type - works with a simplecontext context.'), - 'required context' => new ctools_context_required(t('Simplecontext'), 'simplecontext'), - 'edit form' => 'simplecontext_content_type_edit_form', - 'admin title' => 'ctools_plugin_example_simplecontext_content_type_admin_title', - - // presents a block which is used in the preview of the data. - // Pn Panels this is the preview pane shown on the panels building page. - 'admin info' => 'ctools_plugin_example_simplecontext_content_type_admin_info', - 'category' => array(t('CTools Examples'), -9), -); - -function ctools_plugin_example_simplecontext_content_type_admin_title($subtype, $conf, $context = NULL) { - $output = t('Simplecontext'); - if ($conf['override_title'] && !empty($conf['override_title_text'])) { - $output = filter_xss_admin($conf['override_title_text']); - } - return $output; -} - -/** - * Callback to provide administrative info (the preview in panels when building - * a panel). - * - * In this case we'll render the content with a dummy argument and - * a dummy context. - */ -function ctools_plugin_example_simplecontext_content_type_admin_info($subtype, $conf, $context = NULL) { - $context = new stdClass(); - $context->data = new stdClass(); - $context->data->description = t("no real context"); - $block = simplecontext_content_type_render($subtype, $conf, array("Example"), $context); - return $block; -} - -/** - * Run-time rendering of the body of the block (content type) - * - * @param $subtype - * @param $conf - * Configuration as done at admin time - * @param $args - * @param $context - * Context - in this case we don't have any - * - * @return - * An object with at least title and content members - */ -function simplecontext_content_type_render($subtype, $conf, $args, $context) { - $data = $context->data; - $block = new stdClass(); - - // Don't forget to check this data if it's untrusted. - // The title actually used in rendering. - $block->title = "Simplecontext content type"; - $block->content = t(" - This is a block of data created by the Simplecontext content type. - Data in the block may be assembled from static text (like this) or from the - content type settings form (\$conf) for the content type, or from the context - that is passed in.
- In our case, the configuration form (\$conf) has just one field, 'config_item_1; - and it's configured with: - "); - if (!empty($conf)) { - $block->content .= '
' . print_r(filter_xss_admin($conf['config_item_1']), TRUE) . '
'; - } - if (!empty($context)) { - $block->content .= '
The args ($args) were
' . - var_export($args, TRUE) . '
'; - } - $block->content .= '
And the simplecontext context ($context->data->description) was
' . - print_r($context->data->description, TRUE) . '
'; - return $block; -} - -/** - * 'Edit' callback for the content type. - * This example just returns a form. - * - */ -function simplecontext_content_type_edit_form(&$form, &$form_state) { - $conf = $form_state['conf']; - $form['config_item_1'] = array( - '#type' => 'textfield', - '#title' => t('Config Item 1 for simplecontext content type'), - '#size' => 50, - '#description' => t('The stuff for item 1.'), - '#default_value' => !empty($conf['config_item_1']) ? $conf['config_item_1'] : '', - '#prefix' => '
', - '#suffix' => '
', - ); - - return $form; -} - -function simplecontext_content_type_edit_form_submit(&$form, &$form_state) { - foreach (element_children($form) as $key) { - if (!empty($form_state['values'][$key])) { - $form_state['conf'][$key] = $form_state['values'][$key]; - } - } -} \ No newline at end of file diff --git a/ctools_plugin_example/plugins/contexts/relcontext.inc b/ctools_plugin_example/plugins/contexts/relcontext.inc deleted file mode 100644 index 0c7ef11..0000000 --- a/ctools_plugin_example/plugins/contexts/relcontext.inc +++ /dev/null @@ -1,83 +0,0 @@ - t("Relcontext"), - 'description' => t('A relcontext object.'), - // Function to create the relcontext. - 'context' => 'ctools_plugin_example_context_create_relcontext', - // Function that does the settings. - 'settings form' => 'relcontext_settings_form', - 'keyword' => 'relcontext', - 'context name' => 'relcontext', -); - -/** - * Create a context, either from manual configuration (form) or from an argument on the URL. - * - * @param $empty - * If true, just return an empty context. - * @param $data - * If from settings form, an array as from a form. If from argument, a string. - * @param $conf - * TRUE if the $data is coming from admin configuration, FALSE if it's from a URL arg. - * - * @return - * a Context object. - */ -function ctools_plugin_example_context_create_relcontext($empty, $data = NULL, $conf = FALSE) { - $context = new ctools_context('relcontext'); - $context->plugin = 'relcontext'; - if ($empty) { - return $context; - } - if ($conf) { - if (!empty($data)) { - $context->data = new stdClass(); - // For this simple item we'll just create our data by stripping non-alpha and - // adding 'sample_relcontext_setting' to it. - $context->data->description = 'relcontext_from__' . preg_replace('/[^a-z]/i', '', $data['sample_relcontext_setting']); - $context->data->description .= '_from_configuration_sample_simplecontext_setting'; - $context->title = t("Relcontext context from simplecontext"); - return $context; - } - } - else { - // $data is coming from an arg - it's just a string. - // This is used for keyword. - $context->title = "relcontext_" . $data->data->description; - $context->argument = $data->argument; - // Make up a bogus context. - $context->data = new stdClass(); - // For this simple item we'll just create our data by stripping non-alpha and - // prepend 'relcontext_' and adding '_created_from_from_simplecontext' to it. - $context->data->description = 'relcontext_' . preg_replace('/[^a-z]/i', '', $data->data->description); - $context->data->description .= '_created_from_simplecontext'; - return $context; - } -} - -function relcontext_settings_form($conf, $external = FALSE) { - $form = array(); - - $form['sample_relcontext_setting'] = array( - '#type' => 'textfield', - '#title' => t('Relcontext setting'), - '#size' => 50, - '#description' => t('Just an example setting.'), - '#default_value' => !empty($conf['sample_relcontext_setting']) ? $conf['sample_relcontext_setting'] : '', - '#prefix' => '
', - '#suffix' => '
', - ); - return $form; -} - diff --git a/ctools_plugin_example/plugins/contexts/simplecontext.inc b/ctools_plugin_example/plugins/contexts/simplecontext.inc deleted file mode 100644 index e19a842..0000000 --- a/ctools_plugin_example/plugins/contexts/simplecontext.inc +++ /dev/null @@ -1,134 +0,0 @@ - t("Simplecontext"), - 'description' => t('A single "simplecontext" context, or data element.'), - 'context' => 'ctools_plugin_example_context_create_simplecontext', // func to create context - 'context name' => 'simplecontext', - 'settings form' => 'simplecontext_settings_form', - 'keyword' => 'simplecontext', - - // Provides a list of items which are exposed as keywords. - 'convert list' => 'simplecontext_convert_list', - // Convert keywords into data. - 'convert' => 'simplecontext_convert', - - 'placeholder form' => array( - '#type' => 'textfield', - '#description' => t('Enter some data to represent this "simplecontext".'), - ), -); - -/** - * Create a context, either from manual configuration or from an argument on the URL. - * - * @param $empty - * If true, just return an empty context. - * @param $data - * If from settings form, an array as from a form. If from argument, a string. - * @param $conf - * TRUE if the $data is coming from admin configuration, FALSE if it's from a URL arg. - * - * @return - * a Context object/ - */ -function ctools_plugin_example_context_create_simplecontext($empty, $data = NULL, $conf = FALSE) { - $context = new ctools_context('simplecontext'); - $context->plugin = 'simplecontext'; - - if ($empty) { - return $context; - } - - if ($conf) { - if (!empty($data)) { - $context->data = new stdClass(); - // For this simple item we'll just create our data by stripping non-alpha and - // adding '_from_configuration_item_1' to it. - $context->data->item1 = t("Item1"); - $context->data->item2 = t("Item2"); - $context->data->description = preg_replace('/[^a-z]/i', '', $data['sample_simplecontext_setting']); - $context->data->description .= '_from_configuration_sample_simplecontext_setting'; - $context->title = t("Simplecontext context from config"); - return $context; - } - } - else { - // $data is coming from an arg - it's just a string. - // This is used for keyword. - $context->title = $data; - $context->argument = $data; - // Make up a bogus context - $context->data = new stdClass(); - $context->data->item1 = t("Item1"); - $context->data->item2 = t("Item2"); - - // For this simple item we'll just create our data by stripping non-alpha and - // adding '_from_simplecontext_argument' to it. - $context->data->description = preg_replace('/[^a-z]/i', '', $data); - $context->data->description .= '_from_simplecontext_argument'; - $context->arg_length = strlen($context->argument); - return $context; - } -} - -function simplecontext_settings_form($conf, $external = FALSE) { - if (empty($conf)) { - $conf = array( - 'sample_simplecontext_setting' => 'default simplecontext setting', - ); - } - $form = array(); - $form['sample_simplecontext_setting'] = array( - '#type' => 'textfield', - '#title' => t('Setting for simplecontext'), - '#size' => 50, - '#description' => t('An example setting that could be used to configure a context'), - '#default_value' => $conf['sample_simplecontext_setting'], - '#prefix' => '
', - '#suffix' => '
', - ); - return $form; -} - - - -/** - * Provide a list of sub-keywords. - * - * This is used to provide keywords from the context for use in a content type, - * pane, etc. - */ -function simplecontext_convert_list() { - return array( - 'item1' => t('Item1'), - 'item2' => t('Item2'), - 'description' => t('Description'), - ); -} - -/** - * Convert a context into a string to be used as a keyword by content types, etc. - */ -function simplecontext_convert($context, $type) { - switch ($type) { - case 'item1': - return $context->data->item1; - case 'item2': - return $context->data->item2; - case 'description': - return $context->data->description; - } -} - diff --git a/ctools_plugin_example/plugins/panels.pages.inc b/ctools_plugin_example/plugins/panels.pages.inc deleted file mode 100644 index d3022af..0000000 --- a/ctools_plugin_example/plugins/panels.pages.inc +++ /dev/null @@ -1,214 +0,0 @@ -pid = 'new'; - $page->did = 'new'; - $page->name = 'ctools_plugin_example_demo_panel'; - $page->title = 'Panels Plugin Example Demo Panel'; - $page->access = array(); - $page->path = 'demo_panel'; - $page->load_flags = 1; - $page->css_id = ''; - $page->arguments = array( - 0 => - array( - 'name' => 'simplecontext_arg', - 'id' => 1, - 'default' => '404', - 'title' => '', - 'identifier' => 'Simplecontext arg', - 'keyword' => 'simplecontext', - ), - ); - $page->relationships = array( - 0 => - array( - 'context' => 'argument_simplecontext_arg_1', - 'name' => 'relcontext_from_simplecontext', - 'id' => 1, - 'identifier' => 'Relcontext from Simplecontext', - 'keyword' => 'relcontext', - ), - ); - $page->no_blocks = '0'; - $page->switcher_options = array(); - $page->menu = '0'; - $page->contexts = array(); - $display = new ctools_display(); - $display->did = 'new'; - $display->layout = 'threecol_33_34_33_stacked'; - $display->layout_settings = array(); - $display->panel_settings = array(); - $display->content = array(); - $display->panels = array(); - $pane = new stdClass(); - $pane->pid = 'new-1'; - $pane->panel = 'left'; - $pane->type = 'custom'; - $pane->shown = '1'; - $pane->subtype = 'custom'; - $pane->access = array(); - $pane->configuration = array( - 'style' => 'default', - 'override_title' => 0, - 'override_title_text' => '', - 'css_id' => '', - 'css_class' => '', - 'title' => '"No Context Item"', - 'body' => 'The "no context item" content type is here to demonstrate that you can create a content_type that does not require a context. This is probably the same as just creating a custom php block on the fly, and might serve the same purpose.', - 'format' => '1', - ); - $pane->cache = array(); - $display->content['new-1'] = $pane; - $display->panels['left'][0] = 'new-1'; - $pane = new stdClass(); - $pane->pid = 'new-2'; - $pane->panel = 'left'; - $pane->type = 'no_context_item'; - $pane->shown = '1'; - $pane->subtype = 'description'; - $pane->access = array(); - $pane->configuration = array( - 'style' => 'default', - 'override_title' => 0, - 'override_title_text' => '', - 'css_id' => '', - 'css_class' => '', - 'item1' => 'one', - 'item2' => 'two', - 'item3' => 'three', - ); - $pane->cache = array(); - $display->content['new-2'] = $pane; - $display->panels['left'][1] = 'new-2'; - $pane = new stdClass(); - $pane->pid = 'new-3'; - $pane->panel = 'middle'; - $pane->type = 'custom'; - $pane->shown = '1'; - $pane->subtype = 'custom'; - $pane->access = array(); - $pane->configuration = array( - 'style' => 'default', - 'override_title' => 0, - 'override_title_text' => '', - 'css_id' => '', - 'css_class' => '', - 'title' => 'Simplecontext', - 'body' => 'The "Simplecontext" content and content type demonstrate a very basic context and how to display it. - - Simplecontext includes configuration, so it can get info from the config. It can also get its information to run from a simplecontext context, generated either from an arg to the panels page or via explicitly adding a context to the page.', - 'format' => '1', - ); - $pane->cache = array(); - $display->content['new-3'] = $pane; - $display->panels['middle'][0] = 'new-3'; - $pane = new stdClass(); - $pane->pid = 'new-4'; - $pane->panel = 'middle'; - $pane->type = 'simplecontext_item'; - $pane->shown = '1'; - $pane->subtype = 'description'; - $pane->access = array( - 0 => '2', - 1 => '4', - ); - $pane->configuration = array( - 'context' => 'argument_simplecontext_arg_1', - 'style' => 'default', - 'override_title' => 0, - 'override_title_text' => '', - 'css_id' => '', - 'css_class' => '', - 'config_item_1' => 'simplecontext called from arg', - ); - $pane->cache = array(); - $display->content['new-4'] = $pane; - $display->panels['middle'][1] = 'new-4'; - $pane = new stdClass(); - $pane->pid = 'new-5'; - $pane->panel = 'right'; - $pane->type = 'custom'; - $pane->shown = '1'; - $pane->subtype = 'custom'; - $pane->access = array(); - $pane->configuration = array( - 'style' => 'default', - 'override_title' => 0, - 'override_title_text' => '', - 'css_id' => '', - 'css_class' => '', - 'title' => 'Relcontext', - 'body' => 'The relcontext content_type gets its data from a relcontext, which is an example of a relationship. This panel should be run with an argument like "/xxx", which allows the simplecontext to get its context, and then the relcontext is configured in this panel to get (create) its data from the simplecontext.', - 'format' => '1', - ); - $pane->cache = array(); - $display->content['new-5'] = $pane; - $display->panels['right'][0] = 'new-5'; - $pane = new stdClass(); - $pane->pid = 'new-6'; - $pane->panel = 'right'; - $pane->type = 'relcontext_item'; - $pane->shown = '1'; - $pane->subtype = 'description'; - $pane->access = array(); - $pane->configuration = array( - 'context' => 'relationship_relcontext_from_simplecontext_1', - 'style' => 'default', - 'override_title' => 0, - 'override_title_text' => '', - 'css_id' => '', - 'css_class' => '', - 'config_item_1' => 'default1', - ); - $pane->cache = array(); - $display->content['new-6'] = $pane; - $display->panels['right'][1] = 'new-6'; - $pane = new stdClass(); - $pane->pid = 'new-7'; - $pane->panel = 'top'; - $pane->type = 'custom_php'; - $pane->shown = '1'; - $pane->subtype = 'custom_php'; - $pane->access = array(); - $pane->configuration = array( - 'style' => 'default', - 'override_title' => 0, - 'override_title_text' => '', - 'css_id' => '', - 'css_class' => '', - 'title' => '', - 'body' => '$arg = arg(1); - $arg0 = arg(0); - if (!$arg) { - $block->content = <<This page is intended to run with an arg and you don\'t have one. -
- Without an arg, the page doesn\'t have any context. -
Please try something like "/$arg0/xxx" -END; - - $block->title = "This is intended to run with an argument"; - } else { - $block->content = "The arg for this page is \'$arg\'"; - }', - ); - $pane->cache = array(); - $display->content['new-7'] = $pane; - $display->panels['top'][0] = 'new-7'; - $page->display = $display; - $page->displays = array(); - $pages['ctools_plugin_example'] = $page; - - - return $pages; -} diff --git a/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc b/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc deleted file mode 100644 index 6224621..0000000 --- a/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc +++ /dev/null @@ -1,50 +0,0 @@ - t("Relcontext from simplecontext"), - 'keyword' => 'relcontext', - 'description' => t('Adds a relcontext from existing simplecontext.'), - 'required context' => new ctools_context_required(t('Simplecontext'), 'simplecontext'), - 'context' => 'ctools_relcontext_from_simplecontext_context', - 'settings form' => 'ctools_relcontext_from_simplecontext_settings_form', -); - -/** - * Return a new context based on an existing context. - */ -function ctools_relcontext_from_simplecontext_context($context = NULL, $conf) { - // If unset it wants a generic, unfilled context, which is just NULL. - if (empty($context->data)) { - return ctools_context_create_empty('relcontext', NULL); - } - - // You should do error-checking here. - - // Create the new context from some element of the parent context. - // In this case, we'll pass in the whole context so it can be used to - // create the relcontext. - return ctools_context_create('relcontext', $context); -} - -/** - * Settings form for the relationship. - */ -function ctools_relcontext_from_simplecontext_settings_form($conf) { - // We won't configure it in this case. - return array(); -} - diff --git a/help/about.html b/help/about.html deleted file mode 100644 index 39493ff..0000000 --- a/help/about.html +++ /dev/null @@ -1,30 +0,0 @@ -The Chaos Tool Suite is a series of tools for developers to make code that I've found to be very useful to Views and Panels more readily available. Certain methods of doing things, particularly with AJAX, exportable objects, and a plugin system are proving to be ideas that are useful outside of just Views and Panels. This module does not offer much directly ot the end user, but instead creates a library for other modules to use. If you are an end user and some module asked you to install the CTools suite, then this is far as you really need to go. If you're a developer and are interested in these tools, read on! - -

Tools provided by CTools

-
-
Plugins
-
The plugins tool allows a module to allow other modules (and themes!) to provide plugins which provide some kind of functionality or some kind of task. For example, in Panels there are several types of plugins: Content types (which are like blocks), layouts (which are page layouts) and styles (which can be used to style a panel). Each plugin is represented by a .inc file, and the functionaly they offer can differ wildly. - -
Context
-
Context is the idea that the objects that are used in page generation have more value than simply creating a single piece of output. Instead, contexts can be used to create multiple pieces of content that can all be put onto the page. Additionally, contexts can be used to derive other contexts via relationships, such as determining the node author and displaying data about the new context.
- -
AJAX Tools
-
AJAX (also known as AHAH) is a method of allowing the browser and the server to communicate without requiring a page refresh. It can be used to create complicated interactive forms, but it is somewhat difficult to integrate into Drupal's Form API. These tools make it easier to accomplish this goal. In addition, CTools provides a few other javascript helpers, such as a modal dialog, a collapsible div, a simple dropdown and dependent checkboxes. - -
CSS scrubbing and caching
-
Drupal comes with a fantastic array of tools to ensure HTML is safe to output, but does not contain any similar tools for CSS. CTools provides a small tool to sanitize CSS so that user-input CSS code can still be safely used. It also provides a method for caching CSS for better performance.
- -
Exportable objects
-
Views and Panels both use objects that can either be in code or in the database, and the object can be exported into a piece of PHP code so that it can be moved from site to site or out of the database entirely. This library abstracts that so that other modules can use this same concept for their data.
- -
Form tools
-
Drupal 6's FAPI really improved over Drupal 5, and made a lot of things possible. Still, it missed a few items that were needed to make form wizards and truly dynamic AJAX forms possible. CTools includes a replacement for drupal_get_form() that has a few more options and allows the caller to examine the $form_state once the form has completed.
- -
Form wizards
-
Finally! An easy way to have form wizards, which is any 'form' which is actually a string of forms that build up to a final conclusion. The form wizard supports a single entry point, the ability to choose whether or not the user can go forward/back/up on the form and easy callbacks to handle the difficult job of dealing with data in between forms.
- -
Temporary object cache
-
For normal forms, all of the data needed for an object is stored in the form so that the browser handles a lot of the work. For multi-step and ajax forms, however, this is impractical, and letting the browser store data can be insecure. The object cache provides a non-volatile location to store temporary data while the form is being worked on. This is much safer than the standard Drupal caching mechanism, which is volatile, meaning it can be cleared at any time and any system using it must be capable of recreating the data that was there. This system also allows for object locking, since any object which has an item in the cache from another person can be assumed to be 'locked for editing'.
- - -
\ No newline at end of file diff --git a/help/ajax.html b/help/ajax.html deleted file mode 100644 index e69de29..0000000 diff --git a/help/context-access.html b/help/context-access.html deleted file mode 100644 index ef2ddbf..0000000 --- a/help/context-access.html +++ /dev/null @@ -1,14 +0,0 @@ - -access plugins allow context based access control to pages. - - - 'title' => Title of the plugin - 'description' => Description of the plugin - 'callback' => callback to see if there is access is available. params: $conf, $contexts, $account - 'required context' => zero or more required contexts for this access plugin - 'default' => an array of defaults or a callback giving defaults - 'settings form' => settings form. params: &$form, &$form_state, $conf - settings form validate - settings form submit - -warning: Your settings array will be stored IN THE MENU SYSTEM to reduce loads, so be TRIM. \ No newline at end of file diff --git a/help/context-arguments.html b/help/context-arguments.html deleted file mode 100644 index f19f597..0000000 --- a/help/context-arguments.html +++ /dev/null @@ -1,19 +0,0 @@ - -Arguments create a context from external input, which is assumed to be a -string as though it came from a URL element. - - 'title' => title - 'description' => Description - 'keyword' => Default keyword for the context - 'context' => Callback to create the context. Params: $arg = NULL, $conf = NULL, $empty = FALSE - - 'default' => either an array of default settings or a string which is a callback or null to not use. - - 'settings form' => params: $form, $form_state, $conf -- gets the whole form. Should put anything it wants to keep automatically in $form['settings'] - 'settings form validate' => params: $form, $form_state - 'settings form submit' => params: $form, $form_state - - 'criteria form' => params: $form, &$form_state, $conf, $argument, $id -- gets the whole argument. It should only put form widgets in $form[$id]. $conf may not be properly initialized so always guard against this due to arguments being changed and handlers not being updated to match. - + submit + validate - - 'criteria select' => returns true if the selected criteria matches the context. params: $context, $conf diff --git a/help/context-content.html b/help/context-content.html deleted file mode 100644 index 7c18d51..0000000 --- a/help/context-content.html +++ /dev/null @@ -1,246 +0,0 @@ -

The CTools pluggable content system provides various pieces of -content as discrete bits of data that can be added to other -applications, such as Panels or Dashboard via the UI. Whatever the -content is added to stores the configuration for that individual piece -of content, and provides this to the content.

- -

Each content type plugin will be contained in a .inc file, with -subsidiary files, if necessary, in or near the same directory. Each -content type consists of some information and one or more subtypes, -which all use the same renderer. Subtypes are considered to be -instances of the type. For example, the 'views' content type would have -each view in the system as a subtype. Many content types will have -exactly one subtype.

- -

Because the content and forms can be provided via ajax, the plugin -also provides a list of CSS and JavaScript information that should be available -on whatever page the content or forms may be AJAXed onto.

- -

For the purposes of selecting content from the UI, each content -subtype will have the following information:

- -
    -
  • A title
  • - -
  • A short description
  • - -
  • A category [Do we want to add hierarchy categories? Do we want - category to be more than just a string?]
  • - -
  • An icon [do we want multiple icons? This becomes a hefty - requirement]
  • -
- -

Each piece of content provides one or more configuration forms, if -necessary, and the system that includes the content will handle the -data storage. These forms can be provided in sequence as wizards or as -extra forms that can be accessed through advanced administration.

- -

The plugin for a content type should contain:

- -
-
title
- -
For use on the content permissions screen.
- -
content types
- -
Either an array of content type definitions, or a callback that - will return content type definitions. This callback will get the - plugin definition as an argument.
- -
content type
- -
[Optional] Provide a single content type definition. This is only - necessary if content types might be intensive.
- -
render callback
- -
- The callback to render the content. Parameters: - -
-
$subtype
- -
The name of the subtype being rendered. NOT the loaded - subtype data.
- -
$conf
- -
The stored configuration for the content.
- -
$args
- -
Any arguments passed.
- -
$context
- -
An array of contexts requested by the required contexts and - assigned by the configuration step.
- -
$incoming_content
- -
Any 'incoming content' if this is a wrapper.
-
-
- -
admin title
- -
A callback to provide the administrative title. If it is not a - function, then it will be counted as a string to use as the admin - title.
- -
admin info
- -
A callback to provide administrative information about the - content, to be displayed when manipulating the content. It should - contain a summary of configuration.
- -
edit form
- -
- Either a single form ID or an array of forms *keyed* by form ID - with the value to be used as the title of the form. %title me be - used as a placeholder for the administrative title if necessary. - Example: -
-  array(
-    'ctools_example_content_form_second' => t('Configure first form'),
-    'ctools_example_content_form_first' => t('Configure second form'),
-  ),
-
The first form will always have required configuration added to -it. These forms are normal FAPI forms, but you do not need to provide -buttons, these will be added by the form wizard. -
- -
add form
- -
[Optional] If different from the edit forms, provide them here in - the same manner. Also may be set to FALSE to not have an add - form.
- -
css
- -
A file or array of CSS files that are necessary for the - content.
- -
js
- -
A file or array of javascript files that are necessary for the - content to be displayed.
- -
admin css
- -
A file or array of CSS files that are necessary for the - forms.
- -
admin js
- -
A file or array of JavaScript files that are necessary for the - forms.
- -
extra forms
- -
An array of form information to handle extra administrative - forms.
- -
no title override
- -
Set to TRUE if the title cannot be overridden.
- -
single
- -
Set to TRUE if this content provides exactly one subtype.
- -
render last
- -
Set to true if for some reason this content needs to render after - other content. This is primarily used for forms to ensure that render - order is correct.
-
- -

TODO: many of the above callbacks can be assumed based upon -patterns: modulename + '_' + name + '_' + function. i.e, render, -admin_title, admin_info, etc.

- -

TODO: Some kind of simple access control to easily filter out -content.

- -

The subtype definition should contain:

- -
-
title
- -
The title of the subtype.
- -
icon
- -
The icon to display for the subtype.
- -
path
- -
The path for the icon if it is not in the same directory as the - plugin.
- -
description
- -
The short description of the subtype, to be used when selecting - it in the UI.
- -
category
- -
Either a text string for the category, or an array of the text - string followed by the category weight.
- -
required context [Optional]
- -
Either a ctools_context_required or ctools_context_optional or - array of contexts for this content. If omitted, no contexts are - used.
-
- -

Rendered content

- -

Rendered content is a little more than just HTML.

- -
-
title
- -
The safe to render title of the content.
- -
content
- -
The safe to render HTML content.
- -
links
- -
An array of links associated with the content suitable for - theme('links').
- -
more
- -
An optional 'more' link (destination only)
- -
admin_links
- -
Administrative links associated with the content, suitable for - theme('links').
- -
feeds
- -
An array of feed icons or links associated with the content. Each - member of the array is rendered HTML.
- -
type
- -
The content type.
- -
subtype
- -
The content subtype. These two may be used together as - module-delta for block style rendering.
-
- -

Todo: example

- -

Todo after implementations are updated to new version.

diff --git a/help/context-context.html b/help/context-context.html deleted file mode 100644 index 23a9631..0000000 --- a/help/context-context.html +++ /dev/null @@ -1,12 +0,0 @@ - -Context plugin data: - - 'title' => Visible title - 'description' => Description of context - 'context' => Callback to create a context. Params: $empty, $data = NULL, $conf = FALSE - 'settings form' => Callback to show a context setting form. Params: ($conf, $external = FALSE) - 'settings form validate' => params: ($form, &$form_values, &$form_state) - 'settings form submit' => params: 'ctools_context_node_settings_form_submit', - 'keyword' => The default keyword to use. - 'context name' => The unique identifier for this context for use by required context checks. - 'no ui' => if TRUE this context cannot be selected. diff --git a/help/context-relationships.html b/help/context-relationships.html deleted file mode 100644 index 547f891..0000000 --- a/help/context-relationships.html +++ /dev/null @@ -1,10 +0,0 @@ - - 'title' => The title to display. - 'description' => Description to display. - 'keyword' => Default keyword for the context created by this relationship. - 'required context' => One or more ctools_context_required/optional objects - describing the context input. - new panels_required_context(t('Node'), 'node'), - 'context' => The callback to create the context. Params: ($context = NULL, $conf) - 'settings form' => Settings form. Params: $conf - 'settings form validate' => Validate. diff --git a/help/context.html b/help/context.html deleted file mode 100644 index e69de29..0000000 diff --git a/help/ctools.help.ini b/help/ctools.help.ini deleted file mode 100644 index a3f2075..0000000 --- a/help/ctools.help.ini +++ /dev/null @@ -1,93 +0,0 @@ -[advanced help settings] -line break = TRUE - -[about] -title = About Chaos Tool Suite -weight = -100 - -[context] -title = Context tool -weight = -40 - -[context-access] -title = Context based access control plugins -parent = context - -[context-context] -title = Context plugins -parent = context - -[context-arguments] -title = Argument plugins -parent = context - -[context-relationships] -title = Relationship plugins -parent = context - -[context-content] -title = Content plugins -parent = context - -[css] -title = CSS scrubbing and caching tool - -[menu] -title = Miscellaneous menu helper tool - -[plugins] -title = Plugins and APIs tool -weight = -50 - -[plugins-api] -title = Implementing APIs -parent = plugins - -[plugins-creating] -title = Creating plugins -parent = plugins - -[plugins-implementing] -title = Implementing plugins -parent = plugins - -[export] -title = Exportable objects tool - -[export-ui] -title = Exportable objects UI creator - -[form] -title = Form tools - -[wizard] -title = Form wizard tool - -[ajax] -title = AJAX and Javascript helper tools -weight = -30 - -[modal] -title = Javascript modal tool -parent = ajax - -[collapsible-div] -title = Javascript collapsible DIV -parent = ajax - -[dropdown] -title = Javascript dropdown -parent = ajax - -[dependent] -title = Dependent checkboxes and radio buttons -parent = ajax - -[object-cache] -title = Temporary object caching - -; A bunch of this stuff we'll put in panels. - -[plugins-content] -title = Creating content type plugins -parent = panels%api diff --git a/help/export-ui.html b/help/export-ui.html deleted file mode 100644 index d291ce4..0000000 --- a/help/export-ui.html +++ /dev/null @@ -1,84 +0,0 @@ -Most user interfaces for exportables are very similar, so CTools includes a tool to provide the framework for the most common UI. This tool is a plugin of the 'export_ui' type. In order to create a UI for your exportable object with this tool, you first need to ensure that your module supports the plugin: - -
-function HOOK_ctools_plugin_directory($module, $plugin) {
-  if ($module == 'ctools' && $plugin == 'export_ui') {
-    return 'plugins/' . $plugin;
-  }
-}
-
- -Then, you need to create a plugin .inc file describing your UI. Most of the UI runs with sane but simple defaults, so for the very simplest UI you don't need to do very much. This is a very simple example plugin for the 'example' export type: - -
-$plugin = array(
-  // The name of the table as found in the schema in hook_install. This
-  // must be an exportable type with the 'export' section defined.
-  'schema' => 'example',
-
-  // The access permission to use. If not provided it will default to
-  // 'administer site configuration'
-  'access' => 'administer example',
-
-  // You can actually define large chunks of the menu system here. Nothing
-  // is required here. If you leave out the values, the prefix will default
-  // to admin/structure and the item will default to the plugin name.
-  'menu' => array(
-    'menu prefix' => 'admin/structure',
-    'menu item' => 'example',
-    // Title of the top level menu. Note this should not be translated,
-    // as the menu system will translate it.
-    'menu title' => 'Example', 
-    // Description of the top level menu, which is usually needed for
-    // menu items in an administration list. Will be translated
-    // by the menu system.
-    'menu description' => 'Administer site example objects.',
-  ),
-
-  // These are required to provide proper strings for referring to the
-  // actual type of exportable. "proper" means it will appear at the
-  // beginning of a sentence.
-  'title singular' => t('example'),
-  'title singular proper' => t('Example'),
-  'title plural' => t('examples'),
-  'title plural proper' => t('Examples'),
-
-  // This will provide you with a form for editing the properties on your
-  // exportable, with validate and submit handler.
-  //
-  // The item being edited will be in $form_state['item'].
-  //
-  // The submit handler is only responsible for moving data from
-  // $form_state['values'] to $form_state['item'].
-  //
-  // All callbacks will accept &$form and &$form_state as arguments.
-  'form' => array(
-    'settings' => 'example_ctools_export_ui_form',
-    'validate' => 'example_ctools_export_ui_form_validate',
-    'submit' => 'example_ctools_export_ui_form_submit',
-  ),
-
-);
-
- -For a more complete list of what you can set in your plugin, please see ctools_export_ui_defaults() in includes/export-ui.inc to see what the defaults are. - -

More advanced UIs

-The bulk of this UI is built on an class called ctools_export_ui, which is itself stored in ctools/plugins/export_ui as the default plugin. Many UIs will have more complex needs than the defaults provide. Using OO and overriding methods can allow an implementation to use the basics and still provide more where it is needed. To utilize this, first add a 'handler' directive to your plugin .inc file: - -
-   'handler' => array(
-     'class' => 'ctools_export_ui_example',
-     'parent' => 'ctools_export_ui',
-   ),
-
- -Then create your class in ctools_export_ui_example.class.php in your plugins directory: - -
-class ctools_export_ui_example extends ctools_export_ui {
-
-}
-
- -You can override any method found in the class (see the source file for details). In particular, there are several list methods that are good candidates for overriding if you need to provide richer data for listing, sorting or filtering. If you need multi-step add/edit forms, you can override edit_page(), add_page(), clone_page(), and import_page() to put your wizard in place of the basic editing system. For an example of how to use multi-step wizards, see the import_page() method. diff --git a/help/export.html b/help/export.html deleted file mode 100644 index bd5367d..0000000 --- a/help/export.html +++ /dev/null @@ -1,234 +0,0 @@ -Exportable objects are objects that can live either in the database or in code, or in both. If they live in both, then the object in code is considered to be "overridden", meaning that the version in code is ignored in favor of the version in the database. - -The main benefit to this is that you can move objects that are intended to be structure or feature-related into code, thus removing them entirely from the database. This is a very important part of the deployment path, since in an ideal world, the database is primarily user generated content, whereas site structure and site features should be in code. However, many many features in Drupal rely on objects being in the database and provide UIs to create them. - -Using this system, you can give your objects dual life. They can be created in the UI, exported into code and put in revision control. Views and Panels both use this system heavily. Plus, any object that properly implements this system can be utilized by the Features module to be used as part of a bundle of objects that can be turned into feature modules. - -Typically, exportable objects have two identifiers. One identifier is a simple serial used for database identification. It is a primary key in the database and can be used locally. It also has a name which is an easy way to uniquely identify it. This makes it much less likely that importing and exporting these objects across systems will have collisions. They still can, of course, but with good name selection, these problems can be worked around. - -

Making your objects exportable

-To make your objects exportable, you do have to do a medium amount of work. -
    -
  1. Create a chunk of code in your object's schema definition in the .install file to introduce the object to CTools' export system.
  2. -
  3. Create a load function for your object that utilizes ctools_export_load_object().
  4. -
  5. Create a save function for your object that utilizes drupal_write_record() or any method you desire.
  6. -
  7. Create an import and export mechanism from the UI.
  8. -
-

The export section of the schema file

- -Exportable objects are created by adding definition to the schema in an 'export' section. For example: - -
-function mymodule_schema() {
-  $schema['mymodule_myobj'] = array(
-    'description' => t('Table storing myobj definitions.'),
-    'export' => array(
-      'key' => 'name',
-      'key name' => 'Name',
-      'primary key' => 'oid',
-      'identifier' => 'myobj', // Exports will be as $myobj
-      'default hook' => 'default_mymodule_myobj',  // Function hook name.
-      'api' => array(
-        'owner' => 'mymodule',
-        'api' => 'default_mymodule_myobjs',  // Base name for api include files.
-        'minimum_version' => 1,
-        'current_version' => 1,
-      ),
-      // If the key is stored in a table that is joined in, specify it:
-      'key in table' => 'my_join_table',
-
-    ),
-
-    // If your object's data is split up across multiple tables, you can
-    // specify additional tables to join. This is very useful when working
-    // with modules like exportables.module that has a special table for
-    // translating keys to local database IDs.
-    //
-    // The joined table must have its own schema definition.
-    //
-    // If using joins, you should implement a 'delete callback' (see below)
-    // to ensure that deletes happen properly. export.inc does not do this
-    // automatically!
-    'join' => array(
-      'exportables' => array(
-        // The following parameters will be used in this way:
-        // SELECT ... FROM {mymodule_myobj} t__0 INNER JOIN {my_join_table} t__1 ON t__0.id = t__1.id AND extras
-        'table' => 'my_join_table',
-        'left_key' => 'format',
-        'right_key' => 'id',
-        // Optionally you can define a callback to add custom conditions or
-        // alter the query as necessary. The callback function takes 3 args:
-        //
-        //   myjoincallback(&$query, $schema, $join_schema);
-        //
-        // where $query is the database query object, $schema is the schema for
-        // the export base table and $join_schema is the schema for the current
-        // join table.
-        'callback' => 'myjoincallback',
-
-        // You must specify which fields will be loaded. These fields must
-        // exist in the schema definition of the joined table.
-        'load' => array(
-          'machine',
-        ),
-
-        // And finally you can define other tables to perform INNER JOINS
-        //'other_joins' => array(
-        //   'table' => ...
-        //),
-      ),
-    )
-    'fields' => array(
-      'name' => array(
-        'type' => 'varchar',
-        'length' => '255',
-        'description' => 'Unique ID for this object. Used to identify it programmatically.',
-      ),
-      'oid' => array(
-        'type' => 'serial',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-        'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
-        'no export' => TRUE, // Do not export database-only keys.
-      ),
-    // ......
-    'primary key' => array('oid'),
-    'unique keys' => array(
-      'name' => array('name'),
-    ),
-  );
-  return $schema;
-}
-
- -
-
key
-
This is the primary key of the exportable object and should be a string as names are more portable across systems. It is possible to use numbers here, but be aware that export collisions are very likely. Defaults to 'name'.
- -
key name
-
Human readable title of the export key. Defaults to 'Name'. Because the schema is cached, do not translate this. It must instead be translated when used.
- -
primary key
-
Objects should contain a primary key which is a database identifier primarily used to determine if an object has been written or not. This is required for the default CRUD save callback to work.
- -
object
-
The class the object should be created as. Defaults as stdClass.
- -
can disable
-
Control whether or not the exportable objects can be disabled. All this does is cause the 'disabled' field on the object to always be set appropriately, and a variable is kept to record the state. Changes made to this state must be handled by the owner of the object. Defaults to TRUE.
- -
status
-
Exportable objects can be enabled or disabled, and this status is stored in a variable. This defines what variable that is. Defaults to: 'default_' . $table.
- -
default hook
-
What hook to invoke to find exportable objects that are currently defined. These will all be gathered into a giant array. Defaults to 'default_' . $table.
- -
identifier
-
When exporting the object, the identifier is the variable that the exported object will be placed in. Defaults to $table.
- -
bulk export
-
Declares whether or not the exportable will be available for bulk exporting.
- -
list callback
-
Bulk export callback to provide a list of exportable objects to be chosen for bulk exporting. Defaults to $module . '_' . $table . '_list' if the function exists. If it is not, a default listing function will be provided that will make a best effort to list the titles. See ctools_export_default_list().
- -
to hook code callback
-
Function used to generate an export for the bulk export process. This is only necessary if the export is more complicated than simply listing the fields. Defaults to $module . '_' . $table . '_to_hook_code'. -
- -
create callback
-
CRUD callback to use to create a new exportable item in memory. If not provided, the default function will be used. The single argument is a boolean used to determine if defaults should be set on the object. This object will not be written to the database by this callback.
- -
load callback
-
CRUD callback to use to load a single item. If not provided, the default load function will be used. The callback will accept a single argument which should be an identifier of the export key.
- -
load all callback
-
CRUD callback to use to load all items, usually for administrative purposes. If not provided, the default load function will be used. The callback will accept a single argument to determine if the load cache should be reset or not.
- -
save callback
-
CRUD callback to use to save a single item. If not provided, the default save function will be used. The callback will accept a single argument which should be the complete exportable object to save.
- -
delete callback
-
CRUD callback to use to delete a single item. If not provided, the default delete function will be used. The callback will accept a single argument which can be *either* the object or just the export key to delete. The callback MUST be able to accept either.
- -
export callback
-
CRUD callback to use for exporting. If not provided, the default export function will be used. The callback will accept two arguments, the first is the item to export, the second is the indent to place on the export, if any.
- -
import callback
-
CRUD callback to use for importing. If not provided, the default export function will be used. This function will accept the code as a single argument and, if the code evaluates, return an object represented by that code. In the case of failure, this will return a string with human readable errors.
- -In addition, each field can contain the following: -
-
no export
-
Set to TRUE to prevent that field from being exported.
- -
export callback
-
A function to override the export behavior. It will receive ($myobject, $field, $value, $indent) as arguments. By default, fields are exported through ctools_var_export().
-
- -

Reserved keys on exportable objects

- -Exportable objects have several reserved keys that are used by the CTools export API. Each key can be found at $myobj->{$key} on an object loaded through ctools_export_load_object(). Implementing modules should not use these keys as they will be overwritten by the CTools export API. -
-
api_version
-
The API version that this object implements.
- -
disabled
-
A boolean for whether the object is disabled.
- -
export_module
-
For objects that live in code, the module which provides the default object.
- -
export_type
-
A bitmask representation of an object current storage. You can use this bitmask in combination with the EXPORT_IN_CODE and EXPORT_IN_DATABASE constants to test for an object's storage in your code. -
- -
in_code_only
-
A boolean for whether the object lives only in code.
- -
table
-
The schema API table that this object belongs to.
- -
type
-
A string representing the storage type of this object. Can be one of the following: -
    -
  • Normal is an object that lives only in the database.
  • -
  • Overridden is an object that lives in the database and is overriding the exported configuration of a corresponding object in code.
  • -
  • Default is an object that lives only in code.
  • -
-
-
- -

The load callback

-Calling ctools_export_crud_load($table, $name) will invoke your load callback, and calling ctools_export_crud_load_all($table, $reset) will invoke your load all callback. The default handlers should be sufficient for most uses. - -Typically, there will be two load functions. A 'single' load, to load just one object, and an 'all' load, to load all of the objects for use in administrating the objects or utilizing the objects when you need all of them. Using ctools_export_load_object() you can easily do both, as well as quite a bit in between. This example duplicates the default functionality for loading one myobj. - -
-/**
-* Load a single myobj.
-*/
-function mymodule_myobj_load($name) {
-  ctools_include('export');
-  $result = ctools_export_load_object('mymodule_myobjs', 'names', array($name));
-  if (isset($result[$name])) {
-    return $result[$name];
-  }
-}
-
- -

The save callback

-Calling ctools_export_crud_save($table, $object) will invoke your save callback. The default handlers should be sufficient for most uses. For the default save mechanism to work, you must define a 'primary key' in the 'export' section of your schema. The following example duplicates the default functionality for the myobj. - -
-/**
-* Save a single myobj.
-*/
-function mymodule_myobj_save(&$myobj) {
-  $update = (isset($myobj->oid) && is_numeric($myobj->oid)) ? array('oid') : array();
-  return drupal_write_record('myobj', $myobj, $update);
-}
-
- -

Default hooks for your exports

-All exportables come with a 'default' hook, which can be used to put your exportable into code. The easiest way to actually use this hook is to set up your exportable for bulk exporting, enable the bulk export module and export an object. diff --git a/help/modal.html b/help/modal.html deleted file mode 100644 index 7fc3440..0000000 --- a/help/modal.html +++ /dev/null @@ -1,220 +0,0 @@ -CTools provides a simple modal that can be used as a popup to place forms. It differs from the normal modal frameworks in that it does not do its work via an iframe. This is both an advantage and a disadvantage. The iframe simply renders normal pages in a sub-browser and they can do their thing. That makes it much easier to put arbitrary pages and forms in a modal. However, the iframe is not very good at actually communicating changes to the main page, so you cannot open the modal, have it do some work, and then modify the page. - -

Invoking the modal

- -The basic form of the modal can be set up just by including the javascript and adding the proper class to a link or form that will open the modal. To include the proper javascript, simply include the library and call the add_js function: - -
-ctools_include('modal');
-ctools_modal_add_js();
-
- -You can have links and buttons bound to use the modal by adding the class ctools-use-modal. For convenience, there is a helper function to try and do this, though it's not great at doing all links so using this is optional: - -
-/**
- * Render an image as a button link. This will automatically apply an AJAX class
- * to the link and add the appropriate javascript to make this happen.
- *
- * @param $image
- *   The path to an image to use that will be sent to theme('image') for rendering.
- * @param $dest
- *   The destination of the link.
- * @param $alt
- *   The alt text of the link.
- * @param $class
- *   Any class to apply to the link. @todo this should be a options array.
- */
-function ctools_modal_image_button($image, $dest, $alt, $class = '') {
-  return ctools_ajax_text_button(theme('image', array('path' => $image), $dest, $alt, $class, 'ctools-use-modal');
-}
-
-/**
- * Render text as a link. This will automatically apply an AJAX class
- * to the link and add the appropriate javascript to make this happen.
- *
- * Note: 'html' => true so be sure any text is vetted! Chances are these kinds of buttons will
- * not use user input so this is a very minor concern.
- *
- * @param $text
- *   The text to display as the link.
- * @param $dest
- *   The destination of the link.
- * @param $alt
- *   The alt text of the link.
- * @param $class
- *   Any class to apply to the link. @todo this should be a options array.
- */
-function ctools_modal_text_button($text, $dest, $alt, $class = '') {
-  return ctools_ajax_text_button($text, $dest, $alt, $class, 'ctools-use-modal');
-}
-
- -Like with all CTools' AJAX functionality, the href of the link will be the destination, with any appearance of /nojs/ converted to /ajax/. - - -For submit buttons, however, the URL may be found a different, slightly more complex way. If you do not wish to simply submit the form to the modal, you can create a URL using hidden form fields. The ID of the item is taken and -url is appended to it to derive a class name. Then, all form elements that contain that class name are founded and their values put together to form a URL. - -For example, let's say you have an 'add' button, and it has a select form item that tells your system what widget it is adding. If the id of the add button is edit-add, you would place a hidden input with the base of your URL in the form and give it a class of 'edit-add-url'. You would then add 'edit-add-url' as a class to the select widget allowing you to convert this value to the form without posting. If no URL is found, the action of the form will be used and the entire form posted to it. - -

Customizing the modal

- -If you do not wish to use the default modal, the modal can be customized by creating an array of data to define a customized modal. To do this, you add an array of info to the javascript settings to define the customizations for the modal and add an additional class to your modal link or button to tell it which modal to use. - -First, you need to create a settings array. You can do this most easily with a bit of PHP: - -
-  drupal_add_js(array(
-    'my-modal-style' => array(
-      'modalSize' => array(
-        'type' => 'fixed',
-        'width' => 250,
-        'height' => 250,
-      ),
-    ),
-  ), 'setting');
-
- -The key to the array above (in this case, my-modal-style) is the identifier to your modal theme. You can have multiple modal themes on a page, so be sure to use an ID that will not collide with some other module's use. Using your module or theme as a prefix is a good idea. - -Then, when adding the ctools-use-modal class to your link or button, also add the following class: ctools-modal-ID (in the example case, that would be ctools-modal-my-modal-style). - -modalSize can be 'fixed' or 'scale'. If fixed it will be a raw pixel value; if 'scale' it will be a percentage of the screen. - -You can set: -
    -
  • modalSize: an array of data to control the sizing of the modal. It can contain: -
      -
    • type: Either fixed or scale. If fixed, the modal will always be a fixed size. If scale the modal will scale to a percentage of the browser window. Default: scale. -
    • width: If fixed the width in pixels. If scale the percentage of the screen expressed as a number less than zero. (For 80 percent, use .8, for example). Default: .8
    • -
    • height: If fixed the height in pixels. If scale the percentage of the screen expressed as a number less than zero. (For 80 percent, use .8, for example). Default: .8
    • -
    • addWidth: Any additional width to add to the modal in pixels. Only useful if the type is scale. Default: 0
    • -
    • addHeight: Any additional height to add to the modal in pixels. Only useful if the type is scale. Default: 0
    • -
    • contentRight: The number of pixels to remove from the content inside the modal to make room for scroll bar and decorations. Default: 25
    • -
    • contentBottom: The number of pixels to remove from the content inside the modal to make room for scroll bar and decorations. Default: 45
    • -
    -
  • -
  • modalTheme: The Drupal javascript themable function which controls how the modal will be rendered. This function must be in the Drupal.theme.prototype namespace. If you set this value, you must include a corresponding function in a javascript file and use drupal_add_js() to add that file. Default: CToolsModalDialog -
    -  Drupal.theme.prototype.CToolsModalDialog = function () {
    -    var html = ''
    -    html += '  <div id="ctools-modal">'
    -    html += '    <div class="ctools-modal-content">' // panels-modal-content
    -    html += '      <div class="modal-header">';
    -    html += '        <a class="close" href="#">';
    -    html +=            Drupal.CTools.Modal.currentSettings.closeText + Drupal.CTools.Modal.currentSettings.closeImage;
    -    html += '        </a>';
    -    html += '        <span id="modal-title" class="modal-title"> </span>';
    -    html += '      </div>';
    -    html += '      <div id="modal-content" class="modal-content">';
    -    html += '      </div>';
    -    html += '    </div>';
    -    html += '  </div>';
    -
    -    return html;
    -  }
    -
  • -
  • throbberTheme: The Drupal javascript themable function which controls how the modal throbber will be rendered. This function must be in the Drupal.theme.prototype namespace. If you set this value, you must include a corresponding function in a javascript file and use drupal_add_js() to add that file. Default: CToolsModalThrobber -
    -  Drupal.theme.prototype.CToolsModalThrobber = function () {
    -    var html = '';
    -    html += '  <div id="modal-throbber">';
    -    html += '    <div class="modal-throbber-wrapper">';
    -    html +=        Drupal.CTools.Modal.currentSettings.throbber;
    -    html += '    </div>';
    -    html += '  </div>';
    -
    -    return html;
    -  };
    -
    -
  • -
  • modalOptions: The options object that's sent to Drupal.CTools.Modal.modalContent. Can contain any CSS settings that will be applied to the modal backdrop, in particular settings such as opacity and background. Default: array('opacity' => .55, 'background' => '#fff');
  • -
  • animation: Controls how the modal is animated when it is first drawn. Either show, fadeIn or slideDown. Default: show
  • -
  • animationSpeed: The speed of the animation, expressed either as a word jQuery understands (slow, medium or fast) or a number of milliseconds for the animation to run. Defaults: fast
  • -
  • closeText: The text to display for the close button. Be sure to wrap this in t() for translatability. Default: t('Close window')
  • -
  • closeImage: The image to use for the close button of the modal. Default: theme('image', array('path' => ctools_image_path('icon-close-window.png'), 'alt' => t('Close window'), 'title' => t('Close window')))
  • -
  • loadingText: The text to display for the modal title during loading, along with the throbber. Be sure to wrap this in t() for translatability. Default: t('Close window')
  • -
  • throbber: The HTML to display for the throbber image. You can use this instead of CToolsModalThrobber theme if you just want to change the image but not the throbber HTML. Default: theme('image', array('path' => ctools_image_path('throbber.gif'), 'alt' => t('Loading...'), 'title' => t('Loading')))
  • -
  • -
- -

Rendering within the modal

-To render your data inside the modal, you need to provide a page callback in your module that responds more or less like a normal page. - -In order to handle degradability, it's nice to allow your page to work both inside and outside of the modal so that users whose javascript is turned off can still use your page. There are two ways to accomplish this. First, you can embed 'nojs' as a portion of the URL and then watch to see if that turns into 'ajax' when the link is clicked. Second, if you do not wish to modify the URLs, you can check $_POST['js'] or $_POST['ctools_js'] to see if that flag was set. The URL method is the most flexible because it is easy to send the two links along completely different paths if necessary, and it is also much easier to manually test your module's output by manually visiting the nojs URL. It's actually quite difficult to do this if you have to set $_POST['js'] to test. - -In your hook_menu, you can use the a CTools' AJAX convenience loader to help: - -
-  $items['ctools_ajax_sample/%ctools_js/login'] = array(
-      'title' => 'Login',
-      'page callback' => 'ctools_ajax_sample_login',
-      'page arguments' => array(1),
-      'access callback' => TRUE,
-      'type' => MENU_CALLBACK,
-  );
-
- -The first argument to the page callback will be the result of ctools_js_load() which will return TRUE if 'ajax' was the string, and FALSE if anything else (i.e, nojs) is the string. Which means you can then declare your function like this: - -
-function ctools_ajax_sample_login($js) {
-  if ($js) {
-    // react with the modal
-  }
-  else {
-    // react without the modal
-  }
-}
-
- -If your modal does not include a form, rendering the output you wish to give the user is just a matter of calling the modal renderer with your data: - -
-function ctools_ajax_hello_world($js) {
-  $title = t('Greetings');
-  $output = '<p>' . t('Hello world') . ''</p>';
-  if ($js) {
-    ctools_modal_render($title, $output);
-  }
-  else {
-    drupal_set_title($title);
-    return $output;
-  }
-}
-
- -If you need to do more than just render your modal, you can use a CTools $commands array. See the function ctools_modal_render() for more information on what you need to do here. - -If you are displaying a form -- and the vast majority of modals display forms -- then you need to do just slightly more. Fortunately there is the ctools_modal_form_wrapper() function: - -
-  ctools_include('modal');
-  ctools_include('ajax');
-  $form_state = array(
-    'title' => t('Title of my form'),
-    'ajax' => $js,
-  );
-  $output = ctools_modal_form_wrapper('my_form', $form_state);
-  // There are some possible states after calling the form wrapper:
-  // 1) We are not using $js and there is form output to be rendered.
-  // 2) We are using $js and the form was successfully submitted and
-  //    we need to dismiss the modal.
-  // Most other states are handled automatically unless you set flags in
-  // $form_state to avoid handling them, so we only deal with those two
-  // states.
-  if (empty($output) && $js) {
-    $commands = array();
-    $commands[] = ctools_modal_command_dismiss(t('Login Success');
-    // In typical usage you will do something else here, such as update a
-    // div with HTML or redirect the page based upon the results of the modal
-    // form.
-    print ajax_render($commands);
-    exit;
-  }
-
-  // Otherwise, just return the output.
-  return $output;
-
- -You can also use CTools' form wizard inside the modal. You do not need to do much special beyond setting $form_state['modal'] = TRUE in the wizard form; it already knows how to handle the rest. diff --git a/help/object-cache.html b/help/object-cache.html deleted file mode 100644 index 9648170..0000000 --- a/help/object-cache.html +++ /dev/null @@ -1,132 +0,0 @@ -The CTools Object Cache is a specialized cache for storing data that is non-volatile. This differs from the standard Drupal cache mechanism, which is volatile, meaning that the data can be cleared at any time and it is expected that any cached data can easily be reconstructed. In contrast, data stored in this cache is not expected to be reconstructable. It is primarily used for storing user input which is retrieved in stages, allowing for more complex user interface interactions. - -The object cache consists of 3 normal functions for cache maintenance, and 2 additional functions to facilitate locking. - -To use any of these functions, you must first use ctools_include: - -
-ctools_include('object-cache');
-
- -
-/**
- * Get an object from the non-volatile ctools cache.
- *
- * This function caches in memory as well, so that multiple calls to this
- * will not result in multiple database reads.
- *
- * @param $obj
- *   A 32 character or less string to define what kind of object is being
- *   stored; primarily this is used to prevent collisions.
- * @param $name
- *   The name of the object being stored.
- * @param $skip_cache
- *   Skip the memory cache, meaning this must be read from the db again.
- *
- * @return
- *   The data that was cached.
- */
-function ctools_object_cache_get($obj, $name, $skip_cache = FALSE) {
-
- -
-/**
- * Store an object in the non-volatile ctools cache.
- *
- * @param $obj
- *   A 32 character or less string to define what kind of object is being
- *   stored; primarily this is used to prevent collisions.
- * @param $name
- *   The name of the object being stored.
- * @param $cache
- *   The object to be cached. This will be serialized prior to writing.
- */
-function ctools_object_cache_set($obj, $name, $cache) {
-
- -
-/**
- * Remove an object from the non-volatile ctools cache
- *
- * @param $obj
- *   A 32 character or less string to define what kind of object is being
- *   stored; primarily this is used to prevent collisions.
- * @param $name
- *   The name of the object being removed.
- */
-function ctools_object_cache_clear($obj, $name) {
-
- -To facilitate locking, which is the ability to prohibit updates by other users while one user has an object cached, this system provides two functions: - -
-/**
- * Determine if another user has a given object cached.
- *
- * This is very useful for 'locking' objects so that only one user can
- * modify them.
- *
- * @param $obj
- *   A 32 character or less string to define what kind of object is being
- *   stored; primarily this is used to prevent collisions.
- * @param $name
- *   The name of the object being removed.
- *
- * @return
- *   An object containing the UID and updated date if found; NULL if not.
- */
-function ctools_object_cache_test($obj, $name) {
-
- -The object returned by ctools_object_cache_test can be directly used to determine whether a user should be allowed to cache their own version of an object. - -To allow the concept of breaking a lock, that is, clearing another users changes: - -
-/**
- * Remove an object from the non-volatile ctools cache for all session IDs.
- *
- * This is useful for clearing a lock.
- *
- * @param $obj
- *   A 32 character or less string to define what kind of object is being
- *   stored; primarily this is used to prevent collisions.
- * @param $name
- *   The name of the object being removed.
- */
-function ctools_object_cache_clear_all($obj, $name) {
-
- -Typical best practice is to use wrapper functions such as these: - -
-/**
- * Get the cached changes to a given task handler.
- */
-function delegator_page_get_page_cache($name) {
-  ctools_include('object-cache');
-  $cache = ctools_object_cache_get('delegator_page', $name);
-  if (!$cache) {
-    $cache = delegator_page_load($name);
-    $cache->locked = ctools_object_cache_test('delegator_page', $name);
-  }
-
-  return $cache;
-}
-
-/**
- * Store changes to a task handler in the object cache.
- */
-function delegator_page_set_page_cache($name, $page) {
-  ctools_include('object-cache');
-  $cache = ctools_object_cache_set('delegator_page', $name, $page);
-}
-
-/**
- * Remove an item from the object cache.
- */
-function delegator_page_clear_page_cache($name) {
-  ctools_include('object-cache');
-  ctools_object_cache_clear('delegator_page', $name);
-}
-
diff --git a/help/plugins-api.html b/help/plugins-api.html deleted file mode 100644 index 47e5d6b..0000000 --- a/help/plugins-api.html +++ /dev/null @@ -1,54 +0,0 @@ -APIs are a form of plugins that are tightly associated with a module. Instead of a module providing any number of plugins, each module provides only one file for an API and this file can contain hooks that the module should invoke. - -Modules support this API by implementing hook_ctools_plugin_api($module, $api). If they support the API, they return a packet of data: -
-function mymodule_ctools_plugin_api($module, $api) {
-  if ($module == 'some module' && $api = 'some api') {
-    return array(
-      'version' => The minimum API version this system supports. If this API version is incompatible then the .inc file will not be loaded.
-      'path' => Where to find the file. Optional; if not specified it will be the module's directory.
-      'file' => an alternative version of the filename. If not specified it will be $module.$api.inc
-    );
-  }
-}
-
- -This implementation must be in the .module file. - -Modules utilizing this can invole ctools_plugin_api_include() in order to ensure all modules that support the API will have their files loaded as necessary. It's usually easiest to create a small helper function like this: - -
-define('MYMODULE_MINIMUM_VERSION', 1);
-define('MYMODULE_VERSION', 1);
-
-function mymodule_include_api() {
-  ctools_include('plugins');
-  return ctools_plugin_api_include('mymodule', 'myapi', MYMODULE_MINIMUM_VERSION, MYMODULE_VERSION);
-}
-
- -Using a define will ensure your use of version numbers is consistent and easy to update when you make API changes. You can then use the usual module_invoke type commands: - -
-mymodule_include_api();
-module_invoke('myhook', $data);
-
- -If you need to pass references, this construct is standard: - -
-foreach (mymodule_include_api() as $module => $info) {
-  $function = $module . '_hookname';
-  // Just because they implement the API and include a file does not guarantee they implemented
-  // a hook function!
-  if (!function_exists($function)) {
-    continue;
-  }
-
-  // Typically array_merge() is used below if data is returned.
-  $result = $function($data1, $data2, $data3);
-}
-
- -TODO: There needs to be a way to check API version without including anything, as a module may simply -provide normal plugins and versioning could still matter. diff --git a/help/plugins-creating.html b/help/plugins-creating.html deleted file mode 100644 index 77f0315..0000000 --- a/help/plugins-creating.html +++ /dev/null @@ -1,189 +0,0 @@ -There are two primary pieces to using plugins. The first is getting the data, and the second is using the data. - -

Getting the data

-To create a plugin, a module only has to execute ctools_get_plugins with the right data: - -
-  ctools_include('plugins');
-  ctools_get_plugins($module, $type, [$id])
-
- -In the above example, $module should be your module's name and $type is the type of the plugin. It is typically best practice to provide some kind of wrapper function to make this easier. For example, Panels provides the following functions to implement the 'content_types' plugin: - -
-/**
- * Fetch metadata on a specific content_type plugin.
- *
- * @param $content type
- *   Name of a panel content type.
- *
- * @return
- *   An array with information about the requested panel content type.
- */
-function panels_get_content_type($content_type) {
-  ctools_include('context');
-  ctools_include('plugins');
-  return ctools_get_plugins('panels', 'content_types', $content_type);
-}
-
-/**
- * Fetch metadata for all content_type plugins.
- *
- * @return
- *   An array of arrays with information about all available panel content types.
- */
-function panels_get_content_types() {
-  ctools_include('context');
-  ctools_include('plugins');
-  return ctools_get_plugins('panels', 'content_types');
-}
-
- -As a plugin creator, your module can also implement a hook to give more information about this plugin, and to enable a few features that are not normally enabled. If you need any of these features, simply implement hook_ctools_plugin_TYPE (where TYPE is the same $type sent to ctools_get_plugins). This isn't a true hook, it will only be called for the $module that was given. This hook returns an array: - -
-/**
- * Inform CTools that the layout plugin can be loaded from themes.
- */
-function panels_ctools_plugin_layouts() {
-  return array(
-    'load themes' => TRUE,
-  );
-}
-
- -The following information can be specified: -
-
cache
-
Defaults to: FALSE
-
If set to TRUE, the results of ctools_get_plugins will be cached in the 'cache' table (by default), thus preventing .inc files from being loaded. ctools_get_plugins looking for a specific plugin will always load the appropriate .inc file.
-
cache table
-
Defaults to: 'cache'
-
If 'cache' is TRUE, then this value specifies the cache table where the cached plugin information will be stored.
-
defaults
-
Defaults to: array()
-
An array of defaults that should be added to each plugin; this can be used to ensure that every plugin has the basic data necessary. These defaults will not ovewrite data supplied by the plugin. This could also be a function name, in which case the callback will be used to provide defaults. NOTE, however, that the callback-based approach is deprecated as it is redundant with the 'process' callback, and as such will be removed in later versions. Consequently, you should only use the array form for maximum cross-version compatibility.
-
load themes
-
Defaults to: FALSE
-
If set to TRUE, then plugins of this type can be supplied by themes as well as modules. If this is the case, all themes that are currently enabled will provide a plugin: NOTE: Due to a slight UI bug in Drupal, it is possible for the default theme to be active but not enabled. If this is the case, that theme will NOT provide plugins, so if you are using this feature, be sure to document that issue. Also, themes set via $custom_theme do not necessarily need to be enabled, but the system has no way of knowing what those themes are, so the enabled flag is the only true method of identifying which themes can provide layouts.
-
hook
-
Defaults to: (dynamic value)
-
The name of the hook used to collect data for this plugin. Normally this is $module . '_' . $type -- but this can be changed here. If you change this, you MUST be sure to document this for your plugin implementors as it will change the format of the specially named hook. -
process
-
Defaults to: ''
-
An optional function callback to use for processing a plugin. This can be used to provide automated settings that must be calculated per-plugin instance (i.e., it is not enough to simply append an array via 'defaults'). The parameters on this callback are: callback(&$plugin, $info) where $plugin is a reference to the plugin as processed and $info is the fully processed result of hook_ctools_plugin_api_info(). -
extension
-
Defaults to: 'inc'
-
Can be used to change the extension on files containing plugins of this type. By default the extension will be "inc", though it will default to "info" if "info files" is set to true. Do not include the dot in the extension if changing it, that will be added automatically.
-
info file
-
Defaults to: FALSE
-
If set to TRUE, then the plugin will look for a .info file instead of a .inc. Internally, this will look exactly the same, though obviously a .info file cannot contain functions. This can be good for styles that may not need to contain code.
-
use hooks
-
Defaults to: TRUE*
-
Use to enable support for plugin definition hooks instead of plugin definition files. NOTE: using a central plugin definition hook is less optimal for the plugins system, and as such this will default to FALSE in later versions.
-
child plugins
-
Defaults to: FALSE
-
If set to TRUE, the plugin type can automatically have 'child plugins' meaning each plugin can actually provide multiple plugins. This is mostly used for plugins that store some of their information in the database, such as views, blocks or exportable custom versions of plugins.
-
To implement, each plugin can have a 'get child' and 'get children' callback. Both of these should be implemented for performance reasons, since it is best to avoid getting all children if necessary, but if 'get child' is not implemented, it will fall back to 'get children' if it has to.
-
Child plugins should be named parent:child, with the : being the separator, so that it knows which parent plugin to ask for teh child. The 'get children' method should at least return the parent plugin as part of the list, unless it wants the parent plugin itself to not be a choosable option, which is not unheard of.
-
'get children' arguments are ($plugin, $parent) and 'get child' arguments are ($plugin, $parent, $child). -
- -In addition, there is a 'module' and 'type' settings; these are for internal use of the plugin system and you should not change these. - -

Using the data

- -Each plugin returns a packet of data, which is added to with a few defaults. Each plugin is guaranteed to always have the following data: -
-
name
-
The name of the plugin. This is also the key in the array, of the full list of plugins, and is placed here since that is not always available.
-
module
-
The module that supplied the plugin.
-
file
-
The actual file containing the plugin.
-
path
-
The path to the file containing the plugin. This is useful for using secondary files, such as templates, css files, images, etc, that may come with a plugin.
-
- -Any of the above items can be overridden by the plugin itself, though the most likely one to be modified is the 'path'. - -The most likely data (beyond simple printable data) for a plugin to provide is a callback. The plugin system provides a pair of functions to make it easy and consistent for these callbacks to be used. The first is ctools_plugin_get_function, which requires the full $plugin object. - -
-/**
- * Get a function from a plugin, if it exists. If the plugin is not already
- * loaded, try ctools_plugin_load_function() instead.
- *
- * @param $plugin
- *   The loaded plugin type.
- * @param $callback_name
- *   The identifier of the function. For example, 'settings form'.
- *
- * @return
- *   The actual name of the function to call, or NULL if the function
- *   does not exist.
- */
-function ctools_plugin_get_function($plugin, $callback_name)
-
- -The second does not require the full $plugin object, and will load it: -
-/**
- * Load a plugin and get a function name from it, returning success only
- * if the function exists.
- *
- * @param $module
- *   The module that owns the plugin type.
- * @param $type
- *   The type of plugin.
- * @param $id
- *   The id of the specific plugin to load.
- * @param $callback_name
- *   The identifier of the function. For example, 'settings form'.
- *
- * @return
- *   The actual name of the function to call, or NULL if the function
- *   does not exist.
- */
-function ctools_plugin_load_function($module, $type, $id, $callback_name) {
-
- -Both of these functions will ensure any needed files are included. In fact, it allows each callback to specify alternative include files. The plugin implementation could include code like this: - -
-  'callback_name' => 'actual_name_of_function_here',
-
- -Or like this: -
-  'callback_name' => array(
-    'file' => 'filename',
-    'path' => 'filepath', // optional, will use plugin path if absent
-    'function' => 'actual_name_of_function_here',
-  ),
-
- -An example, for 'plugin_example' type - -
-$plugin = array(
-  'name' => 'my_plugin',
-  'module' => 'my_module',
-  'example_callback' => array(
-    'file' => 'my_plugin.extrafile.inc',
-    'function' => 'my_module_my_plugin_example_callback',
-  ),
-);
-
- -To utilize this callback on this plugin: - -
-if ($function = ctools_plugin_get_function($plugin, 'example_callback')) {
-  $function($arg1, $arg2, $etc);
-}
-
- -

Document your plugins!

-Since the data provided by your plugin tends to be specific to your plugin type, you really need to document what the data returned in the hook in the .inc file will be or nobody will figure it out. Use advanced help and document it there. If every system that utilizes plugins does this, then plugin implementors will quickly learn to expect the documentation to be in the advanced help. - diff --git a/help/plugins-implementing.html b/help/plugins-implementing.html deleted file mode 100644 index 0ea1269..0000000 --- a/help/plugins-implementing.html +++ /dev/null @@ -1,58 +0,0 @@ -To implement plugins, you need to implement a single hook in your module to tell the system where your plugins live, and then you need to implement one or more .inc files that contain the plugin data. - -

Telling it where your plugins live

-To implement any plugins at all, you must implement a single function for all plugins: hook_ctools_plugin_directory. Every time a module loads plugins, this hook will be called to see which modules implement those plugins and in what directory those plugins will live. - -
-function hook_ctools_plugin_directory($module, $plugin) {
-  if ($module == 'panels' && $plugin == 'content_types') {
-    return 'plugins/content_types';
-  }
-}
-
- -The directory returned should be relative to your module. Another common usage is to simply return that you implement all plugins owned by a given module (or modules): - -
-function hook_ctools_plugin_directory($module, $plugin) {
-  if ($module == 'panels') {
-    return 'plugins/' . $plugin;
-  }
-}
-
- -Typically, it is recommended that all plugins be placed into the 'plugins' directory for clarity and maintainability. Inside the directory, any number of subdirectories can be used. For plugins that require extra files, such as templates, css, javascript or image files, this is highly recommended: -
-mymodule.module
-mymodule.info
-plugins/
-    content_types/
-        my_content_type.inc
-    layouts/
-        my_layout.inc
-        my_laout.css
-        my_layout.tpl.php
-        my_layout_image.png
-
- -

How a theme can implement plugins

-Themes can implement plugins if the plugin owner specified that it's possible in its hook_ctools_api_TYPE() call. If so, it is generally exactly the same as modules, except for one important difference: themes don't get hook_ctools_plugin_directory(). Instead, themes add a line to their info file: - -
-plugins[module][type] = directory
-
- -

How to structure the .inc file

- -The top of the .inc file should contain an array that defines the plugin. This array is simply defined in the global namespace of the file and does not need a function. Note that previous versions of this plugin system required a specially named function. While this function will still work, its use is now discouraged, as it is annoying to name properly. - -This array should look something like this: -
-$plugin = array(
-  'key' => 'value',
-);
-
- -Several values will be filled in for you automatically, but you can override them if necessary. They include 'name', 'path', 'file' and 'module'. Additionally, the plugin can owner can provide other defaults as well. - -After this array, if your plugin needs functions, they can be declared. Different plugin types have different needs here, so exactly what else will be needed will change from type to type. diff --git a/help/plugins.html b/help/plugins.html deleted file mode 100644 index 906813e..0000000 --- a/help/plugins.html +++ /dev/null @@ -1,5 +0,0 @@ -The plugins tool allows a module to allow other modules (and themes!) to provide plugins which provide some kind of functionality or some kind of task. For example, in Panels there are several types of plugins: Content types (which are like blocks), layouts (which are page layouts) and styles (which can be used to style a panel). Each plugin is represented by a .inc file, and the functionality they offer can differ wildly. - -A module which uses plugins can implement a hook describing the plugin (which is not necessary, as defaults will be filled in) and then calls a ctools function which loads either all the known plugins (used for listing/choosing) or loads a specific plugin (used when its known which plugin is needed). From the perspective of the plugin system, a plugin is a packet of data, usually some printable info and a list of callbacks. It is up to the module implementing plugins to determine what that info means and what the callbacks do. - -A module which implements plugins must first implement the hook_ctools_plugin_directory function, which simply tells the system which plugins are supported and what directory to look in. Each plugin will then be in a .inc file in the directory supplied. The .inc file will contain a specially named hook which returns the data necessary to implement the plugin. \ No newline at end of file diff --git a/help/wizard.html b/help/wizard.html deleted file mode 100644 index a9ccde8..0000000 --- a/help/wizard.html +++ /dev/null @@ -1,287 +0,0 @@ -Form wizards, or multi-step forms, are a process by which the user goes through or can use an arbitrary number of different forms to create a single object or perform a single task. Traditionally the multi-step form is difficult in Drupal because there is no easy place to put data in between forms. No longer! The form wizard tool allows a single entry point to easily set up a wizard of multiple forms, provide callbacks to handle data storage and updates between forms and when forms are completed. This tool pairs well with the object cache tool for storage. - -

The form info array

-The wizard starts with an array of data that describes all of the forms available to the wizard and sets options for how the wizard will present and control the flow. Here is an example of the $form_info array as used in the delegator module: - -
-  $form_info = array(
-    'id' => 'delegator_page',
-    'path' => "admin/structure/pages/edit/$page_name/%step",
-    'show trail' => TRUE,
-    'show back' => TRUE,
-    'show return' => FALSE,
-    'next callback' => 'delegator_page_add_subtask_next',
-    'finish callback' => 'delegator_page_add_subtask_finish',
-    'return callback' => 'delegator_page_add_subtask_finish',
-    'cancel callback' => 'delegator_page_add_subtask_cancel',
-    'order' => array(
-      'basic' => t('Basic settings'),
-      'argument' => t('Argument settings'),
-      'access' => t('Access control'),
-      'menu' => t('Menu settings'),
-      'multiple' => t('Task handlers'),
-    ),
-    'forms' => array(
-      'basic' => array(
-        'form id' => 'delegator_page_form_basic'
-      ),
-      'access' => array(
-        'form id' => 'delegator_page_form_access'
-      ),
-      'menu' => array(
-        'form id' => 'delegator_page_form_menu'
-      ),
-      'argument' => array(
-        'form id' => 'delegator_page_form_argument'
-      ),
-      'multiple' => array(
-        'form id' => 'delegator_page_argument_form_multiple'
-      ),
-    ),
-  );
-
- -The above array starts with an id which is used to identify the wizard in various places and a path which is needed to redirect to the next step between forms. It then creates some settings which control which pieces are displayed. In this case, it displays a form trail and a 'back' button, but not the 'return' button. Then there are the wizard callbacks which allow the wizard to act appropriately when forms are submitted. Finally it contains a list of forms and their order so that it knows which forms to use and what order to use them by default. Note that the keys in the order and list of forms match; that key is called the step and is used to identify each individual step of the wizard. - -Here is a full list of every item that can be in the form info array: - -
-
id
-
An id for wizard. This is used like a hook to automatically name callbacks, as well as a form step's form building function. It is also used in trail theming.
-
path
-
The path to use when redirecting between forms. %step will be replaced with the key for the form.
-
return path
-
When a form is complete, this is the path to go to. This is required if the 'return' button is shown and not using AJAX. It is also used for the 'Finish' button. If it is not present and needed, the cancel path will also be checked.
-
cancel path
-
When a form is canceled, this is the path to go to. This is required if the 'cancel' is shown and not using AJAX.
-
show trail
-
If set to TRUE, the form trail will be shown like a breadcrumb at the top of each form. Defaults to FALSE.
-
show back
-
If set to TRUE, show a back button on each form. Defaults to FALSE.
-
show return
-
If set to TRUE, show a return button. Defaults to FALSE.
-
show cancel
-
If set to TRUE, show a cancel button. Defaults to FALSE.
-
back text
-
Set the text of the 'back' button. Defaults to t('Back').
-
next text
-
Set the text of the 'next' button. Defaults to t('Continue').
-
return text
-
Set the text of the 'return' button. Defaults to t('Update and return').
-
finish text
-
Set the text of the 'finish' button. Defaults to t('Finish').
-
cancel text
-
Set the text of the 'cancel' button. Defaults to t('Cancel').
-
ajax
-
Turn on AJAX capabilities, using CTools' ajax.inc. Defaults to FALSE.
-
modal
-
Put the wizard in the modal tool. The modal must already be open and called from an ajax button for this to work, which is easily accomplished using functions provided by the modal tool.
-
ajax render
-
A callback to display the rendered form via ajax. This is not required if using the modal tool, but is required otherwise since ajax by itself does not know how to render the results. Params: &$form_state, $output.
-
finish callback
-
-The function to call when a form is complete and the finish button has been clicked. This function should finalize all data. Params: &$form_state. -Defaults to $form_info['id']._finish if function exists. -
-
cancel callback
-
-The function to call when a form is canceled by the user. This function should clean up any data that is cached. Params: &$form_state. -Defaults to $form_info['id']._cancel if function exists.
-
return callback
-
-The function to call when a form is complete and the return button has been clicked. This is often the same as the finish callback. Params: &$form_state. -Defaults to $form_info['id']._return if function exists.
-
next callback
-
-The function to call when the next button has been clicked. This function should take the submitted data and cache it for later use by the finish callback. Params: &$form_state. -Defaults to $form_info['id']._next if function exists.
-
order
-
An optional array of forms, keyed by the step, which represents the default order the forms will be displayed in. If not set, the forms array will control the order. Note that submit callbacks can override the order so that branching logic can be used.
-
forms
-
An array of form info arrays, keyed by step, describing every form available to the wizard. If order array isn't set, the wizard will use this to set the default order. Each array contains: -
-
form id
-
- The id of the form, as used in the Drupal form system. This is also the name of the function that represents the form builder. - Defaults to $form_info['id']._.$step._form. -
-
include
-
The name of a file to include which contains the code for this form. This makes it easy to include the form wizard in another file or set of files. This must be the full path of the file, so be sure to use drupal_get_path() when setting this. This can also be an array of files if multiple files need to be included.
-
title
-
The title of the form, to be optionally set via drupal_get_title. This is required when using the modal if $form_state['title'] is not set.
-
-
-
- -

Invoking the form wizard

-Your module should create a page callback via hook_menu, and this callback should contain an argument for the step. The path that leads to this page callback should be the same as the 'path' set in the $form_info array. - -The page callback should set up the $form_info, and figure out what the default step should be if no step is provided (note that the wizard does not do this for you; you MUST specify a step). Then invoke the form wizard: - -
-  $form_state = array();
-  ctools_include('wizard');
-  $output = ctools_wizard_multistep_form($form_info, $step, $form_state);
-
- -If using AJAX or the modal, This part is actually done! If not, you have one more small step: -
-  return $output;
-
- -

Forms and their callbacks

-Each form within the wizard is a complete, independent form using Drupal's Form API system. It has a form builder callback as well as submit and validate callbacks and can be form altered. The primary difference between these forms and a normal Drupal form is that the submit handler should not save any data. Instead, it should make any changes to a cached object (usually placed on the $form_state) and only the _finish or _return handler should actually save any real data. - -How you handle this is completely up to you. The recommended best practice is to use the CTools Object cache, and a good way to do this is to write a couple of wrapper functions around the cache that look like these example functions: - -
-/**
- * Get the cached changes to a given task handler.
- */
-function delegator_page_get_page_cache($name) {
-  ctools_include('object-cache');
-  $cache = ctools_object_cache_get('delegator_page', $name);
-  if (!$cache) {
-    $cache = delegator_page_load($name);
-    $cache->locked = ctools_object_cache_test('delegator_page', $name);
-  }
-
-  return $cache;
-}
-
-/**
- * Store changes to a task handler in the object cache.
- */
-function delegator_page_set_page_cache($name, $page) {
-  ctools_include('object-cache');
-  $cache = ctools_object_cache_set('delegator_page', $name, $page);
-}
-
-/**
- * Remove an item from the object cache.
- */
-function delegator_page_clear_page_cache($name) {
-  ctools_include('object-cache');
-  ctools_object_cache_clear('delegator_page', $name);
-}
-
- -Using these wrappers, when performing a get_cache operation, it defaults to loading the real object. It then checks to see if another user has this object cached using the ctools_object_cache_test() function, which automatically sets a lock (which can be used to prevent writes later on). - -With this set up, the _next, _finish and _cancel callbacks are quite simple: - -
-/**
- * Callback generated when the add page process is finished.
- */
-function delegator_page_add_subtask_finish(&$form_state) {
-  $page = &$form_state['page'];
-
-  // Create a real object from the cache
-  delegator_page_save($page);
-
-  // Clear the cache
-  delegator_page_clear_page_cache($form_state['cache name']);
-}
-
-/**
- * Callback generated when the 'next' button is clicked.
- *
- * All we do here is store the cache.
- */
-function delegator_page_add_subtask_next(&$form_state) {
-  // Update the cache with changes.
-  delegator_page_set_page_cache($form_state['cache name'], $form_state['page']);
-}
-
-/**
- * Callback generated when the 'cancel' button is clicked.
- *
- * All we do here is clear the cache.
- */
-function delegator_page_add_subtask_cancel(&$form_state) {
-  // Update the cache with changes.
-  delegator_page_clear_page_cache($form_state['cache name']);
-}
-
- -All that's needed to tie this together is to understand how the changes made it into the cache in the first place. This happened in the various form _submit handlers, which made changes to $form_state['page'] based upon the values set in the form: - -
-/**
- * Store the values from the basic settings form.
- */
-function delegator_page_form_basic_submit(&$form, &$form_state) {
-  if (!isset($form_state['page']->pid) && empty($form_state['page']->import)) {
-    $form_state['page']->name = $form_state['values']['name'];
-  }
-
-  $form_state['page']->admin_title = $form_state['values']['admin_title'];
-  $form_state['page']->path = $form_state['values']['path'];
-}
-
- -No database operations were made during this _submit, and that's a very important distinction about this system. - -

Proper handling of back button

-When using 'show back' => TRUE the cached data should be assigned to the #default_value form property. Otherwise when the user goes back to the previous step the forms default values instead of his (cached) input is used. - -
-/**
- * Form builder function for wizard.
- */
-function wizardid_step2_form(&$form, &$form_state) {
-  $form_state['my data'] = my_module_get_cache($form_state['cache name']);
-  $form['example'] = array(
-    '#type' => 'radios',
-    '#title' => t('Title'),
-    '#default_value' => $form_state['my data']->example ? $form_state['my data']->example : default,
-    '#options' => array(
-      'default' => t('Default'),
-      'setting1' => t('Setting1'),
-    ),
-  );
-}
-
-/**
- * Submit handler to prepare needed values for storing in cache.
- */
-function wizardid_step2_form_submit($form, &$form_state) {
-  $form_state['my data']->example = $form_state['values']['example'];
-}
-
- -The data is stored in the my data object on submitting. If the user goes back to this step the cached my data is used as the default form value. The function my_module_get_cache() is like the cache functions explained above. - -

Required fields, cancel and back buttons

-If you have required fields in your forms, the back and cancel buttons will not work as expected since validation of the form will fail. You can add the following code to the top of your form validation to avoid this problem : -
-/**
- * Validation handler for step2 form
- */
-function wizardid_step2_form_validate(&$form, &$form_state) {
-  // if the clicked button is anything but the normal flow
-  if ($form_state['clicked_button']['#next'] != $form_state['next']) {
-    drupal_get_messages('error');
-    form_set_error(NULL, '', TRUE);
-    return;
-  }
-  // you form validation goes here
-  // ...
-}
-
- -

Wizard for anonymous users

-If you are creating a wizard which is be used by anonymous users, you might run into some issues with drupal's caching for anonymous users. You can circumvent this by using hook_init and telling drupal to not cache your wizard pages : -
-/**
- * Implementation of hook init
- */
-function mymodule_init() {
-  // if the path leads to the wizard
-  if (drupal_match_path($_GET['q'], 'path/to/your/wizard/*')) {
-    // set cache to false
-    $GLOBALS['conf']['cache'] = FALSE;   
-  }
-}
-
diff --git a/images/arrow-active.png b/images/arrow-active.png deleted file mode 100644 index 3bbd3c27f29f9a1781276a2ae8faa7afd5d2d36e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 313 zcwXxa@N?(olHy`uVBq!ia0vp^96-#^!3-qdU8!RPQY`6?zK#qG*KS<#k1zuAB}-f* zN`mv#O3D+9QW+dm@{>{(JaZG%Q-e|yQz{EjrrH1%xd!-zxO#bc1qB6pdwbu!dGq1J zhmRgT^6~LGa^%RaUAy+}+xPF^zmq3VUc7kG&(CkurcE0*Y)DB-@%Q&XfByW98#g9T zp6u!A`Tzg_bT_}9Km)5hT^vIyZY2pcGc_>$j@3?%=}IXVGIu?6^qxc>kDAIJlF_r}R z1v5B2yO9Ruh>$j@3?%=}IXVGIu?6^qxc>kDAIJlF_r}R z1v5B2yO9Ru2zk0VhE&W+{&76uaKb@_0}N~oA{!VF-#vS9IZ&3t)78&qol`;+0EMF; ATL1t6 diff --git a/images/expanded-options.png b/images/expanded-options.png deleted file mode 100644 index b7b755c0a44f7ebae4972e9489f7d004c0ab82c7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 228 zcwPbI02}{_P)ww{j7*Vo28PTTa|E`mIR+~;bCfMvxdsyM z(5ekkRsEa&-}g5%GyJU<0Jd$L=lM6Mlp>-Q0E7@k6hipggNVi$A_4$>6U(xA?~miC z(WYsvwNlDgvc9*j>oiUKzCXvV>zs3a-+$74R*X?=Jq&}^I;C`RuQW5~oX2r2rQEI4 eCv_nr-uDldTYa;G_K`FI0000iq z0IV%C^!fao008>^|L)Drv@$cSevPOvH1+WD^zif8ot?_h()RN6?e+VlH8rWRx4}_S z>Eq+2H$UR#=J@XJx!2^a&*a?J*5Baax6|XJA0GGX>#7wN?d9dM-~7hnfFvN$`qJUpqw(%<6b?d|i_j*rpq z|FJ(m+tbtf@bI-UF}+7e`|;AXyh1|0zrm`px0$`u?e_b> zOiZ*eF_^v6z=e*`nwsd~;OpVxt2H&U;r{6M{D+mE+1A*$J3IUS{=tTi+0xSEHoMkHoiwksV_9Fv$(S{F{rV(y2#O+9Z9zU00A*cL_t(|+F}r6KmlR^ z0mPunD6P)MEzZd)&dsJS&8QC$Knx6gJZzi-qWt`#0tRe6=92&dh=GBJO-fUdiJ6&6 zQB$ftgasggfGQFuM{AgHFjZ;vSL?*F00a;N19zC39-~Z5eiWmhntvAyKmai?1%$tYfNmRsaYfhDz6Tm24#=X67Cx zJC%4#V}Jl+FzibdoXEs1B*e_5E!b-{1t5SJio=_PMYPN$CB3vngq>{50Ro6YwaBAJ zUP6wSS588{BDl;2Ab=RAdUCO{va$mKkmBNM0SGVv{T(ma@e6-+00000NkvXXu0mjf Dl_$#h diff --git a/images/icon-configure.png b/images/icon-configure.png deleted file mode 100644 index e23d67cc04b84880d0437e23ffcba837d2dc4121..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 765 zcwPbh0s{SsP)-74EqOkY-{rmp^hMTIQ#@mCazW_yW+u-8> zPk}pYiU37!Rg=5ptkC8MYI{+_;Luo{p4KD>lDEyR&Etl&(Yn*)-~a#n{r!cl#v)~o)A;<=?*HNB<)Ead ztIy)#^#A()|Df6X+~MQJ*yDq%#H88$+~DJ&z|&y3EA;>X0V+vEK~#9!Vlc30L<05( z00G3n&A`LT!lJ;ypuoby%ERCa5I_u^+3YL~3=E2jK!SxmT@xUH7#LYu81xtzq@@{v zRB$0PKmai?vM}h|TJVXA@>$sGa|kj61Q1Ao!Aix>(9llBiUBA95I_u!>QW{q zQtA>69J$N@0mQ(_5G$l?V<|3fX`?LUA;t_4Knx)a$=0%3W(*8wTC&#pV$1*m#K4#p z$iS~1;Ow5F&CigO#|#ia42)@EI!Yn}8X5v3N;;7V%m4wz!045zrYp>4WW*(`tL7KS z3=lvJjGn%#a>fj%rVPe%s{T=$00G3n8RT7%DsRrqYc3z^mXpa05I_vv(M9oWk}{5t vGLmd;K28|`0mKjy&IAGu4q(b91|Yxy=@24rSbWX-00000NkvXXu0mjfu!oSb diff --git a/images/icon-delete.png b/images/icon-delete.png deleted file mode 100644 index 5f0cf695b0cac487efecfd7eae66e7492a2ba306..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 877 zcwPZ*1CsoSP)iq z0IV%C^!fao008>^|L)Drv@$cSevPOvH1+WD^zif8ot?_h()RN6?e+VlH8rWRx4}_S z>Eq+2H$UR#=J@XJx!2^a&*a?J*5Baax6|XJA0GGX>#7wN?d9dM-~7hnfFvN$`qJUpqw(%<6b?d|i_j*rpq z|FJ(m+tbtf@bI-UF}+7e`|;AXyh1|0zrm`px0$`u?e_b> zOiZ*eF_^v6z=e*`nwsd~;OpVxt2H&U;r{6M{D+mE+1A*$J3IUS{=tTi+0xSEHoMkHoiwksV_9Fv$(S{F{rV(y2#O+9Z9zU00A*cL_t(|+F}r6KmlR^ z0mPunD6P)MEzZd)&dsJS&8QC$Knx6gJZzi-qWt`#0tRe6=92&dh=GBJO-fUdiJ6&6 zQB$ftgasggfGQFuM{AgHFjZ;vSL?*F00a;N19zC39-~Z5eiWmhntvAyKmai?1%$tYfNmRsaYfhDz6Tm24#=X67Cx zJC%4#V}Jl+FzibdoXEs1B*e_5E!b-{1t5SJio=_PMYPN$CB3vngq>{50Ro6YwaBAJ zUP6wSS588{BDl;2Ab=RAdUCO{va$mKkmBNM0SGVv{T(ma@e6-+00000NkvXXu0mjf Dl_$#h diff --git a/images/no-icon.png b/images/no-icon.png deleted file mode 100644 index fa78ec179a83428e5b8e247890278cdf91a8cb3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 574 zcwXxa@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl;=8&~`zjDUQ}64!{5 z;QX|b^2DN42FH~Aq*MjZ+{ES{rGmAj8jfaD?v!i2UYjjvlpQJ*A1Jfmibqf^i?VA_L7&|Z+X1sot(Xnwu z!w#NRT}4?8j7JunOdXEg zItmI4IG$*KURlhB>e|rlEqG%3qu@s@KxgP$`nu(@>FI?n*t0}KS|4Q7%GJhQ zr!}-TZTjTdv1#K+psr@Qb}IpmMn>t`v&?`hUc4+UFfd-t$f&NazkZvXLjxnjnNaC9 Um!If;0EPpDr>mdKI;Vst09}j(6951J diff --git a/images/status-active.gif b/images/status-active.gif deleted file mode 100644 index 207e95c3fa8cc31a89af150ad74059b1667922b6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 2196 zcwX(4Urbw79LLW&_xASmFQt@HSs}NhO2-Jh1BM+kb4v^B62vmdY!-sIxUi{Y-eKaZ zd%2gEe>0H6h_VE=!^E(JL`)>X2jVS^Zcfvn5<-k2WvFCNG`ghG7rZ6$WnPVsKJ5E& z&fEF^exLLG{Z5~0cApFxfB|GdPWa6w{k0|AwWK|oJQ2I!Je@i}^Zo0eZod2F_QJwK zJhi*9v9}~^YcH8hrc$Ymjg76Xt@{st+t|%+?PYgm$!B(dPgZt6o6~-FKc|D|pXdpJ z|1SZ@zOJ>YquuKXG*wqI1e7av{7$MU`L4`Wof{K?uL6ik)&cufg_LoQqXqAfy0+3{ zVu1*Xj`x{1=h*=gnp+l!1#VSW%081}61N6b&=mGR)z{;t@N3_7K6G3}vFcNdTatPJ zWob=y{!lI487rJJ4j-9EtAH}quDdhK8$;Mx;ap5}%OZqIwQ#vwn2-m7VydFk6-NfXW;n}qaG_+h5lkKV%Xt# z1&Brn=)(*h11nLh>g@1v&J!Rv$(w`-=_&|b;2Dv9A9hnfFgqfIJ8$mCaK2L*M@3y7 zIA0Ja0OoCB(ShQ`v!#{_hE{Uz{s*cYCr0%(UH7mIb5whbUQ8#v;+Q%g&$(!E=(^4d zW-<4Q0La$*DZ1@e1VMmhst;H-vKD{vwwY}otMLqyJRf3}Y+q8~3M{sJq3vZzlmpDQ zeGKwY9zBQYnI=)gR{7|8bXQxUK_-Ur0K!;TR~a8C;26GIwa#UnXQIU_bBXdFb{&9) zpkEQJH5xuHcq6F9$qTVWf<$e`hTGLo3uGw>TnO-7KVZsheZlRXehm@sbDHQfXe5p? zzD#~75z(nBQmMU{52!-+@vJ^hRSL#; zD4p0@9zK~j`OQ~X(lF*QR4eBv_}`G?hG0JHi`vcn=Xe~PCW&&h#U=q&4A^^n{Tyl? z#fKX0vkCg^2`nO4{lCN}w-^+eo*fS7v%sJMCO7*lAfkFB6+FT?g-DgoIdxMK+3Wf` zt(>S8Nn=o3gPWfrAE1oqequ7nOBxFFoh{6uYaV5&CEn!bLAS_gUdJzZ^ zK}1VIAVebAZ6^hmTb%&La3I>TF8A%Q+Q)%Kvb`&+>hI9e~NEj*~rMIQVD7K+Bdac_tse6IC6l8bq4m7}7i@!a+ OGEh+T$MlG7_S~PPW2zkh diff --git a/images/throbber.gif b/images/throbber.gif deleted file mode 100644 index 8a084b8447d506e9b655ad52405cbf7a73034550..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 3208 zcwWVqX;2es0*0IPk)vA|yMq%5i~)%V<3LbhI8_J`ARvc;ARrQ>g0~z3K_DC<0Xajs z3@8aChUkch2k6Kkh@cJ>j<>EZFf%H6kL9f6IO~EtTGVdU{@JS8{@K;lUC;Bq?_1S8 zKOZOOcox6{UID=S_wRR|e0%@d@2Bs+yD{05Wi3vCm(Z`=Wx{|W)LsYlJBW&{ZRmVXgKJX7_XTedMMyaEE|0=qvlYOha&9QBC=-js&N~RgPq;Q zZR(xoqN;P>ag0fZu9p2Au0ew>$S44{1TCC*_Er(>=-S?gv=o7SCs zcKn!-PEJebxko{?O>`(f%~w!pwj1$qmvg8QF%2;?S1JhxTQm&^Ts3;7udY~q=x}3) zSsmx(i4=CFZ*tMzq$oGv9NS!?zvxsAwOcOumRMsV7zpy-@@Sk?=o^J&CNCC9qPC?oAC)QkFe8W+gVE_L>Wp#m z&zdg6c0S zn^y1t>Xg%{@t`^B4}8*0{AW}6*7j5Q5AAsl!dS_|YE|gKF-6$o62<0#g3P|FZY&~t z#9=g$-aSg=j2K%>jA^WZ&bcjqq{0{5Btzc1fpzrb5WExDgwxPmXzfNio07M-9UlDA zjD)0Ot^`RWB4u$3BAHZL(JBtOA%;mzt@@Ue z&1!a+>Ao}cvp#K!CHB1vj;u&5)n5K4>bR2F*XMLTz4%*s2~~99;))`?=%(AfL%=w& zZ{XbhA07d1-OMLWFCRv^wUtcb7c~^8SJHzq(qJRY6K6E$@^iE1d`tlN@9A%4s3(Uu z8GDBtHrBANH-$>$6=9x+w_9ctW8FKKS)HtI*+6-1DXX`Tf%F*Zd~bWM!FKWaGJ5{S z?3>pCf8#}S|GLN{zM7&pX$((WyVSss9enRTWp*kWGIz-mQYI%CNwg1>@Ze2prWsjm zP{y_jZD=I0CKU=(%OoZ4Dm|t>*mwwQ)*M{2|0J)5-KE%h`YcCFt0y}ALw86Vh`~aR z-+Aq}j4d*#FMWuhgvsKv1{anClACMC$20hiWyvS-Ck+$J66192vg^;bzjeQjkKehp z>(qnjMEvi8;pW2-9&hPE#_l*KS z1OLRpr*5NBqprobjuPTJp<5Lzh?JKS`Lo+Dt1sqw&i-`#@Jt1-rUxLjb!q@C{MoF= znhLr~>m9O2UvUKg9)BJnlo$W~%cvt-+Utb8nk|n)RC~k)xWiZ~-i|9dbFVw^A3<2}AWoy}_9d=2(&9*vQ1<0!iq^6eaI9)moQYJ3|b1HH%EHBufBqQk}D$~TQWKyT$*Db1W5iP z^R02oUv@^!>Fu%nxCF>d507VfkW58^Wuyx2U9+;tCfLT{(3tCW%iv5K#mc;%r!n3m z6+fF(a_qx{7T@!t*2g6|`u!rHsak%zcHXykpA*%y)|Gnfu!R*x->~NHos_e3fvK23 zpKHaJ6%k-bDV&zITvn<8E9LxZusl)ZSlr|Srswe?1c7rrxH=vAz=AC29P$x_oFa-b zgV7l1q)zYUz;I0mQM8MIb?qU!!iCrkfO;8i=dZ?ZVE82zDGu};C6LRY%2?U+Z@?F%rTuxRCn+oedc$yqSJSpuhTN&#y&;&#fa)4S8l8a#20D1+W_9GQC zco;Ljg5q%hKoL6J3)~~f{T+O8_&)v!@9dZTh&_4u{X~Dd=`gZzP#HYBZ+4^+wumw~ zaU*Y!oyEr~q|9{i;{W78;zA)8c-T#KALM2+m=LPf7N*7!NE?Q9FiBuSmO!ILVXs~j z2n73L=efgL9YID>9Ws@HK`=MM`YLLC1Hox`ijk`$;{-hD%muIhfIs$nz<-2R0I%_< z-|)2(b!sW~6h2^M%HdS3`W(EJ@@W&Pe|iz7f&imfMP-r5fmT_IRVhl#>xvI>B`#EO zS_F#1A4DK}{j>;j2TDH0^q%t2sz)3FO20`ooifiI(rY>qL<8OgR;MqpzJ?gz{NB%5 zM!t3!7+bM}3tuA>lVQvG_b*J`B7}FD&*?wMzB%Xlm8u8GYjUJ8MhECOvN|D*pY z1QhIo*yzI$7;-2}=EC|8MZ)z?B3~KbQ@fcJj>Bjs*KdpIHUWRWbUnXPj*FeB1)1^k zYNz_`%4$YkeU(O<7g6CNvx5<2mrGzSlSXc9|+Da|I&bP>|ZNL?PDnXdp5sWxj32cSWatKV#2+ChT=gZYt)!#7;ww?=xP-Y zbEJ|kea4SuXz~0fP3>}9N44;%j+sqDL{$m5d+FrVRC1D?BP-GY$@g=OD>O|(;h_26 z)XX5IQsx{%M%2v>`<ma~8MigNsc9 zcg*X=PoIIs+lL1P^CEje7d$)miwK*cZAL#q#{9U^pespy;AO|k6}G^n@`~_RAbWV% bi1x>MM6N0Br6zmc*o#serW)Y-=~v>PffBmW diff --git a/includes/ajax.inc b/includes/ajax.inc deleted file mode 100644 index 981ee23..0000000 --- a/includes/ajax.inc +++ /dev/null @@ -1,125 +0,0 @@ - $image)), $dest, $alt, $class); -} - -/** - * Render text as a link. This will automatically apply an AJAX class - * to the link and add the appropriate javascript to make this happen. - * - * Note: 'html' => true so be sure any text is vetted! Chances are these kinds of buttons will - * not use user input so this is a very minor concern. - * - * @param $text - * The text that will be displayed as the link. - * @param $dest - * The destination of the link. - * @param $alt - * The alt text of the link. - * @param $class - * Any class to apply to the link. @todo this should be a options array. - * @param $type - * A type to use, in case a different behavior should be attached. Defaults - * to ctools-use-ajax. - */ -function ctools_ajax_text_button($text, $dest, $alt, $class = '', $type = 'use-ajax') { - drupal_add_js('misc/ajax.js'); - return l($text, $dest, array('html' => TRUE, 'attributes' => array('class' => array($type, $class), 'title' => $alt))); -} - -/** - * Set a single property to a value, on all matched elements. - * - * @param $selector - * The CSS selector. This can be any selector jquery uses in $(). - * @param $name - * The name or key: of the data attached to this selector. - * @param $value - * The value of the data. - */ - function ctools_ajax_command_attr($selector, $name, $value) { - return array( - 'command' => 'attr', - 'selector' => $selector, - 'name' => $name, - 'value' => $value, - ); - } - -/** - * Force a client-side redirect. - * - * @param $url - * The url to be redirected to. This can be an absolute URL or a - * Drupal path. - * @param $delay - * A delay before applying the redirection, in milliseconds. - * @param $options - * An array of options to pass to the url() function. - */ -function ctools_ajax_command_redirect($url, $delay = 0, $options = array()) { - return array( - 'command' => 'redirect', - 'url' => url($url, $options), - 'delay' => $delay, - ); -} - -/** - * Force a reload of the current page. - */ -function ctools_ajax_command_reload() { - return array( - 'command' => 'reload', - ); -} - -/** - * Submit a form. - * - * This is useful for submitting a parent form after a child form has finished - * processing in a modal overlay. - * - * @param $selector - * The CSS selector to identify the form for submission. This can be any - * selector jquery uses in $(). - */ -function ctools_ajax_command_submit($selector) { - return array( - 'command' => 'submit', - 'selector' => $selector, - ); -} - -/** - * Send an error response back via AJAX and immediately exit. - */ -function ctools_ajax_render_error($error = '') { - $commands = array(); - $commands[] = ajax_command_alert($error); - print ajax_render($commands); - exit; -} - diff --git a/includes/cache.inc b/includes/cache.inc deleted file mode 100644 index ca6e6f3..0000000 --- a/includes/cache.inc +++ /dev/null @@ -1,169 +0,0 @@ - TRUE, - 'ignore words' => array(), - 'separator' => '-', - 'replacements' => array(), - 'transliterate' => FALSE, - 'reduce ascii' => TRUE, - 'max length' => FALSE, - 'lower case' => FALSE, - ); - - // Allow modules to make other changes to the settings. - if (isset($settings['clean id'])) { - drupal_alter('ctools_cleanstring_' . $settings['clean id'], $settings); - } - - drupal_alter('ctools_cleanstring', $settings); - - $output = $string; - - // Do any replacements the user selected up front. - if (!empty($settings['replacements'])) { - $output = strtr($output, $settings['replacements']); - } - - // Remove slashes if instructed to do so. - if ($settings['clean slash']) { - $output = str_replace('/', '', $output); - } - - if (!empty($settings['transliterate']) && module_exists('transliteration')) { - $output = transliteration_get($output); - } - - // Reduce to the subset of ASCII96 letters and numbers - if ($settings['reduce ascii']) { - $pattern = '/[^a-zA-Z0-9\/]+/'; - $output = preg_replace($pattern, $settings['separator'], $output); - } - - // Get rid of words that are on the ignore list - if (!empty($settings['ignore words'])) { - $ignore_re = '\b'. preg_replace('/,/', '\b|\b', $settings['ignore words']) .'\b'; - - if (function_exists('mb_eregi_replace')) { - $output = mb_eregi_replace($ignore_re, '', $output); - } - else { - $output = preg_replace("/$ignore_re/i", '', $output); - } - } - - // Always replace whitespace with the separator. - $output = preg_replace('/\s+/', $settings['separator'], $output); - - // In preparation for pattern matching, - // escape the separator if and only if it is not alphanumeric. - if (isset($settings['separator'])) { - if (preg_match('/^[^'. CTOOLS_PREG_CLASS_ALNUM .']+$/uD', $settings['separator'])) { - $seppattern = $settings['separator']; - } - else { - $seppattern = '\\'. $settings['separator']; - } - // Trim any leading or trailing separators (note the need to - $output = preg_replace("/^$seppattern+|$seppattern+$/", '', $output); - - // Replace multiple separators with a single one - $output = preg_replace("/$seppattern+/", $settings['separator'], $output); - } - - // Enforce the maximum component length - if (!empty($settings['max length'])) { - $output = ctools_cleanstring_truncate($output, $settings['max length'], $settings['separator']); - } - - if (!empty($settings['lower case'])) { - $output = drupal_strtolower($output); - } - return $output; -} - -/** - * A friendly version of truncate_utf8. - * - * @param $string - * The string to be truncated. - * @param $length - * An integer for the maximum desired length. - * @param $separator - * A string which contains the word boundary such as - or _. - * - * @return - * The string truncated below the maxlength. - */ -function ctools_cleanstring_truncate($string, $length, $separator) { - if (drupal_strlen($string) > $length) { - $string = drupal_substr($string, 0, $length + 1); // leave one more character - if ($last_break = strrpos($string, $separator)) { // space exists AND is not on position 0 - $string = substr($string, 0, $last_break); - } - else { - $string = drupal_substr($string, 0, $length); - } - } - return $string; -} diff --git a/includes/collapsible.theme.inc b/includes/collapsible.theme.inc deleted file mode 100644 index f7bbbb3..0000000 --- a/includes/collapsible.theme.inc +++ /dev/null @@ -1,79 +0,0 @@ - array('handle' => NULL, 'content' => NULL, 'collapsed' => FALSE), - 'file' => 'includes/collapsible.theme.inc', - ); - $items['ctools_collapsible_remembered'] = array( - 'variables' => array('id' => NULL, 'handle' => NULL, 'content' => NULL, 'collapsed' => FALSE), - 'file' => 'includes/collapsible.theme.inc', - ); -} - -/** - * Render a collapsible div. - * - * @param $handle - * Text to put in the handle/title area of the div. - * @param $content - * Text to put in the content area of the div, this is what will get - * collapsed - * @param $collapsed = FALSE - * If true, this div will start out collapsed. - */ -function theme_ctools_collapsible($vars) { - ctools_add_js('collapsible-div'); - ctools_add_css('collapsible-div'); - - $class = $vars['collapsed'] ? ' ctools-collapsed' : ''; - $output = '
'; - $output .= '
' . $vars['handle'] . '
'; - $output .= '
' . $vars['content'] . '
'; - $output .= '
'; - - return $output; -} - -/** - * Render a collapsible div whose state will be remembered. - * - * @param $id - * The CSS id of the container. This is required. - * @param $handle - * Text to put in the handle/title area of the div. - * @param $content - * Text to put in the content area of the div, this is what will get - * collapsed - * @param $collapsed = FALSE - * If true, this div will start out collapsed. - */ -function theme_ctools_collapsible_remembered($vars) { - $id = $vars['id']; - $handle = $vars['handle']; - $content = $vars['content']; - $collapsed = $vars['collapsed']; - ctools_add_js('collapsible-div'); - ctools_add_css('collapsible-div'); - - $class = $collapsed ? ' ctools-collapsed' : ''; - $output = '
'; - $output .= '
' . $handle . '
'; - $output .= '
' . $content . '
'; - $output .= '
'; - - return $output; -} - diff --git a/includes/content.inc b/includes/content.inc deleted file mode 100644 index c77f0a1..0000000 --- a/includes/content.inc +++ /dev/null @@ -1,773 +0,0 @@ - $plugin['title'], - 'description' => $plugin['description'], - 'icon' => ctools_content_admin_icon($plugin), - 'category' => $plugin['category'], - ); - - if (isset($plugin['required context'])) { - $type['required context'] = $plugin['required context']; - } - if (isset($plugin['top level'])) { - $type['top level'] = $plugin['top level']; - } - $plugin['content types'] = array($plugin['name'] => $type); - if (!isset($plugin['single'])) { - $plugin['single'] = TRUE; - } - } - } -} - -/** - * Fetch metadata on a specific content_type plugin. - * - * @param $content type - * Name of a panel content type. - * - * @return - * An array with information about the requested panel content type. - */ -function ctools_get_content_type($content_type) { - ctools_include('context'); - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'content_types', $content_type); -} - -/** - * Fetch metadata for all content_type plugins. - * - * @return - * An array of arrays with information about all available panel content types. - */ -function ctools_get_content_types() { - ctools_include('context'); - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'content_types'); -} - -/** - * Get all of the individual subtypes provided by a given content type. This - * would be all of the blocks for the block type, or all of the views for - * the view type. - * - * @param $type - * The content type to load. - * - * @return - * An array of all subtypes available. - */ -function ctools_content_get_subtypes($type) { - static $cache = array(); - - $subtypes = array(); - - if (is_array($type)) { - $plugin = $type; - } - else { - $plugin = ctools_get_content_type($type); - } - - if (empty($plugin) || empty($plugin['name'])) { - return; - } - - if (isset($cache[$plugin['name']])) { - return $cache[$plugin['name']]; - } - - if (isset($plugin['content types'])) { - $function = $plugin['content types']; - if (is_array($function)) { - $subtypes = $function; - } - else if (function_exists($function)) { - // Cast to array to prevent errors from non-array returns. - $subtypes = (array) $function($plugin); - } - } - - // Walk through the subtypes and ensure minimal settings are - // retained. - foreach ($subtypes as $id => $subtype) { - // Use exact name since this is a modify by reference. - ctools_content_prepare_subtype($subtypes[$id], $plugin); - } - - $cache[$plugin['name']] = $subtypes; - - return $subtypes; -} - -/** - * Given a content type and a subtype id, return the information about that - * content subtype. - * - * @param $type - * The content type being fetched. - * @param $subtype_id - * The id of the subtype being fetched. - * - * @return - * An array of information describing the content subtype. - */ -function ctools_content_get_subtype($type, $subtype_id) { - $subtype = array(); - if (is_array($type)) { - $plugin = $type; - } - else { - $plugin = ctools_get_content_type($type); - } - - $function = ctools_plugin_get_function($plugin, 'content type'); - if ($function) { - $subtype = $function($subtype_id, $plugin); - } - else { - $subtypes = ctools_content_get_subtypes($type); - if (isset($subtypes[$subtype_id])) { - $subtype = $subtypes[$subtype_id]; - } - // If there's only 1 and we somehow have the wrong subtype ID, do not - // care. Return the proper subtype anyway. - if (empty($subtype) && !empty($plugin['single'])) { - $subtype = current($subtypes); - } - } - - if ($subtype) { - ctools_content_prepare_subtype($subtype, $plugin); - } - return $subtype; -} - -/** - * Ensure minimal required settings on a content subtype exist. - */ -function ctools_content_prepare_subtype(&$subtype, $plugin) { - foreach (array('path', 'js', 'css') as $key) { - if (!isset($subtype[$key]) && isset($plugin[$key])) { - $subtype[$key] = $plugin[$key]; - } - } -} - -/** - * Get the content from a given content type. - * - * @param $type - * The content type. May be the name or an already loaded content type plugin. - * @param $subtype - * The name of the subtype being rendered. - * @param $conf - * The configuration for the content type. - * @param $keywords - * An array of replacement keywords that come from outside contexts. - * @param $args - * The arguments provided to the owner of the content type. Some content may - * wish to configure itself based on the arguments the panel or dashboard - * received. - * @param $context - * An array of context objects available for use. - * @param $incoming_content - * Any incoming content, if this display is a wrapper. - * - * @return - * The content as rendered by the plugin. This content should be an array - * with the following possible keys: - * - title: The safe to render title of the content. - * - content: The safe to render HTML content. - * - links: An array of links associated with the content suitable for - * theme('links'). - * - more: An optional 'more' link (destination only) - * - admin_links: Administrative links associated with the content, suitable - * for theme('links'). - * - feeds: An array of feed icons or links associated with the content. - * Each member of the array is rendered HTML. - * - type: The content type. - * - subtype: The content subtype. These two may be used together as - * module-delta for block style rendering. - */ -function ctools_content_render($type, $subtype, $conf, $keywords = array(), $args = array(), $context = array(), $incoming_content = '') { - if (is_array($type)) { - $plugin = $type; - } - else { - $plugin = ctools_get_content_type($type); - } - - $subtype_info = ctools_content_get_subtype($plugin, $subtype); - - $function = ctools_plugin_get_function($subtype_info, 'render callback'); - if (!$function) { - $function = ctools_plugin_get_function($plugin, 'render callback'); - } - - if ($function) { - $pane_context = ctools_content_select_context($plugin, $subtype, $conf, $context); - if ($pane_context === FALSE) { - return; - } - - $content = $function($subtype, $conf, $args, $pane_context, $incoming_content); - - // Set up some defaults and other massaging on the content before we hand - // it back to the caller. - if (!isset($content->type)) { - $content->type = $plugin['name']; - } - - if (!isset($content->subtype)) { - $content->subtype = $subtype; - } - - // Override the title if configured to - if (!empty($conf['override_title'])) { - // Give previous title as an available substitution here. - $keywords['%title'] = empty($content->title) ? '' : $content->title; - $content->original_title = $keywords['%title']; - $content->title = $conf['override_title_text']; - } - - if (!empty($content->title)) { - // Perform substitutions - if (!empty($keywords) || !empty($context)) { - $content->title = ctools_context_keyword_substitute($content->title, $keywords, $context); - } - - // Sterilize the title - $content->title = filter_xss_admin($content->title); - - // If a link is specified, populate. - if (!empty($content->title_link)) { - if (!is_array($content->title_link)) { - $url = array('href' => $content->title_link); - } - else { - $url = $content->title_link; - } - // set defaults so we don't bring up notices - $url += array('href' => '', 'attributes' => array(), 'query' => array(), 'fragment' => '', 'absolute' => NULL, 'html' => TRUE); - $content->title = l($content->title, $url['href'], $url); - } - } - - return $content; - } -} - -/** - * Determine if a content type can be edited or not. - * - * Some content types simply have their content and no options. This function - * lets a UI determine if it should display an edit link or not. - */ -function ctools_content_editable($type, $subtype, $conf) { - if (empty($type['edit form']) && empty($subtype['edit form'])) { - return FALSE; - } - - if ($function = ctools_plugin_get_function($subtype, 'check editable')) { - return $function($type, $subtype, $conf); - } - - return TRUE; -} - -/** - * Get the administrative title from a given content type. - * - * @param $type - * The content type. May be the name or an already loaded content type object. - * @param $subtype - * The subtype being rendered. - * @param $conf - * The configuration for the content type. - * @param $context - * An array of context objects available for use. These may be placeholders. - */ -function ctools_content_admin_title($type, $subtype, $conf, $context = NULL) { - if (is_array($type)) { - $plugin = $type; - } - else if (is_string($type)) { - $plugin = ctools_get_content_type($type); - } - else { - return; - } - - if ($function = ctools_plugin_get_function($plugin, 'admin title')) { - $pane_context = ctools_content_select_context($plugin, $subtype, $conf, $context); - if ($pane_context === FALSE) { - if ($plugin['name'] == $subtype) { - return t('@type will not display due to missing context', array('@type' => $plugin['name'])); - } - return t('@type:@subtype will not display due to missing context', array('@type' => $plugin['name'], '@subtype' => $subtype)); - } - - return $function($subtype, $conf, $pane_context); - } - else if (isset($plugin['admin title'])) { - return $plugin['admin title']; - } - else if (isset($plugin['title'])) { - return $plugin['title']; - } -} - -/** - * Get the proper icon path to use, falling back to default icons if no icon exists. - * - * $subtype - * The loaded subtype info. - */ -function ctools_content_admin_icon($subtype) { - $icon = ''; - - if (isset($subtype['icon'])) { - $icon = $subtype['icon']; - if (!file_exists($icon)) { - $icon = $subtype['path'] . '/' . $icon; - } - } - - if (empty($icon) || !file_exists($icon)) { - $icon = ctools_image_path('no-icon.png'); - } - - return $icon; -} - -/** - * Set up the default $conf for a new instance of a content type. - */ -function ctools_content_get_defaults($plugin, $subtype) { - if (isset($plugin['defaults'])) { - $defaults = $plugin['defaults']; - } - else if (isset($subtype['defaults'])) { - $defaults = $subtype['defaults']; - } - if (isset($defaults)) { - if (is_string($defaults) && function_exists($defaults)) { - if ($return = $defaults($pane)) { - return $return; - } - } - else if (is_array($defaults)) { - return $defaults; - } - } - - return array(); -} - -/** - * Get the administrative title from a given content type. - * - * @param $type - * The content type. May be the name or an already loaded content type object. - * @param $subtype - * The subtype being rendered. - * @param $conf - * The configuration for the content type. - * @param $context - * An array of context objects available for use. These may be placeholders. - */ -function ctools_content_admin_info($type, $subtype, $conf, $context = NULL) { - if (is_array($type)) { - $plugin = $type; - } - else { - $plugin = ctools_get_content_type($type); - } - - if ($function = ctools_plugin_get_function($plugin, 'admin info')) { - $output = $function($subtype, $conf, $context); - } - if (empty($output) || !is_object($output)) { - $output = new stdClass(); - $output->title = t('No info'); - $output->content = t('No info available.'); - } - return $output; -} - -/** - * Add the default FAPI elements to the content type configuration form - */ -function ctools_content_configure_form_defaults($form, &$form_state) { - $plugin = $form_state['plugin']; - $subtype = $form_state['subtype']; - $contexts = isset($form_state['contexts']) ? $form_state['contexts'] : NULL; - $conf = $form_state['conf']; - - $add_submit = FALSE; - if (!empty($subtype['required context']) && is_array($contexts)) { - $form['context'] = ctools_context_selector($contexts, $subtype['required context'], isset($conf['context']) ? $conf['context'] : array()); - $add_submit = TRUE; - } - - ctools_include('dependent'); - - // Unless we're not allowed to override the title on this content type, add this - // gadget to all panes. - if (empty($plugin['no title override']) && empty($subtype['no title override'])) { - $form['aligner_start'] = array( - '#markup' => '
', - ); - $form['override_title'] = array( - '#type' => 'checkbox', - '#default_value' => isset($conf['override_title']) ? $conf['override_title'] : '', - '#title' => t('Override title'), - '#id' => 'override-title-checkbox', - ); - $form['override_title_text'] = array( - '#type' => 'textfield', - '#default_value' => isset($conf['override_title_text']) ? $conf['override_title_text'] : '', - '#size' => 35, - '#id' => 'override-title-textfield', - '#process' => array('ctools_dependent_process'), - '#dependency' => array('override-title-checkbox' => array(1)), - '#dependency_type' => 'disable', - ); - $form['aligner_stop'] = array( - '#markup' => '
', - ); - if (is_array($contexts)) { - $form['override_title_markup'] = array( - '#prefix' => '
', - '#suffix' => '
', - '#markup' => t('You may use %keywords from contexts, as well as %title to contain the original title.'), - ); - } - $add_submit = TRUE; - } - - if ($add_submit) { - // '#submit' is already set up due to the wizard. - $form['#submit'][] = 'ctools_content_configure_form_defaults_submit'; - } - return $form; -} - -/** - * Submit handler to store context/title override info. - */ -function ctools_content_configure_form_defaults_submit(&$form, &$form_state) { - if (isset($form_state['values']['context'])) { - $form_state['conf']['context'] = $form_state['values']['context']; - } - if (isset($form_state['values']['override_title'])) { - $form_state['conf']['override_title'] = $form_state['values']['override_title']; - $form_state['conf']['override_title_text'] = $form_state['values']['override_title_text']; - } -} - -/** - * Get the config form. - * - * The $form_info and $form_state need to be preconfigured with data you'll need - * such as whether or not you're using ajax, or the modal. $form_info will need - * your next/submit callbacks so that you can cache your data appropriately. - * - * @return - * If this function returns false, no form exists. - */ -function ctools_content_form($op, $form_info, &$form_state, $plugin, $subtype_name, $subtype, &$conf, $step = NULL) { - $form_state += array( - 'plugin' => $plugin, - 'subtype' => $subtype, - 'subtype_name' => $subtype_name, - 'conf' => &$conf, - 'op' => $op, - ); - - $form_info += array( - 'id' => 'ctools_content_form', - 'show back' => TRUE, - ); - - // Turn the forms defined in the plugin into the format the wizard needs. - if ($op == 'add') { - if (!empty($subtype['add form'])) { - _ctools_content_create_form_info($form_info, $subtype['add form'], $subtype, $subtype, $op); - } - else if (!empty($plugin['add form'])) { - _ctools_content_create_form_info($form_info, $plugin['add form'], $plugin, $subtype, $op); - } - } - - if (empty($form_info['order'])) { - // Use the edit form for the add form if add form was completely left off. - if (!empty($subtype['edit form'])) { - _ctools_content_create_form_info($form_info, $subtype['edit form'], $subtype, $subtype, $op); - } - else if (!empty($plugin['edit form'])) { - _ctools_content_create_form_info($form_info, $plugin['edit form'], $plugin, $subtype, $op); - } - } - - if (empty($form_info['order'])) { - return FALSE; - } - - ctools_include('wizard'); - return ctools_wizard_multistep_form($form_info, $step, $form_state); - -} - -function _ctools_content_create_form_info(&$form_info, $info, $plugin, $subtype, $op) { - if (is_string($info)) { - if (empty($subtype['title'])) { - $title = t('Configure'); - } - else if ($op == 'add') { - $title = t('Configure new !subtype_title', array('!subtype_title' => $subtype['title'])); - } - else { - $title = t('Configure !subtype_title', array('!subtype_title' => $subtype['title'])); - } - $form_info['order'] = array('form' => $title); - $form_info['forms'] = array( - 'form' => array( - 'title' => $title, - 'form id' => $info, - 'wrapper' => 'ctools_content_configure_form_defaults', - ), - ); - } - else if (is_array($info)) { - $form_info['order'] = array(); - $form_info['forms'] = array(); - $count = 0; - $base = 'step'; - $wrapper = NULL; - foreach ($info as $form_id => $title) { - // @todo -- docs say %title can be used to sub for the admin title. - $step = $base . ++$count; - if (empty($wrapper)) { - $wrapper = $step; - } - - if (is_array($title)) { - if (!empty($title['default'])) { - $wrapper = $step; - } - $title = $title['title']; - } - - $form_info['order'][$step] = $title; - $form_info['forms'][$step] = array( - 'title' => $title, - 'form id' => $form_id, - ); - } - if ($wrapper) { - $form_info['forms'][$wrapper]['wrapper'] = 'ctools_content_configure_form_defaults'; - } - } -} - -/** - * Get an array of all available content types that can be fed into the - * display editor for the add content list. - * - * @param $context - * If a context is provided, content that requires that context can apepar. - * @param $has_content - * Whether or not the display will have incoming content - * @param $allowed_types - * An array of allowed content types (pane types) keyed by content_type . '-' . sub_type - * @param $default_types - * A default allowed/denied status for content that isn't known about - */ -function ctools_content_get_available_types($contexts = NULL, $has_content = FALSE, $allowed_types = NULL, $default_types = NULL) { - $plugins = ctools_get_content_types(); - $available = array(); - - foreach ($plugins as $id => $plugin) { - foreach (ctools_content_get_subtypes($plugin) as $subtype_id => $subtype) { - // exclude items that require content if we're saying we don't - // provide it. - if (!empty($subtype['requires content']) && !$has_content) { - continue; - } - - // Check to see if the content type can be used in this context. - if (!empty($subtype['required context'])) { - if (!ctools_context_match_requirements($contexts, $subtype['required context'])) { - continue; - } - } - - // Check to see if the passed-in allowed types allows this content. - if ($allowed_types) { - $key = $id . '-' . $subtype_id; - if (!isset($allowed_types[$key])) { - $allowed_types[$key] = isset($default_types[$id]) ? $default_types[$id] : $default_types['other']; - } - if (!$allowed_types[$key]) { - continue; - } - } - - // If we made it through all the tests, then we can use this content. - $available[$id][$subtype_id] = $subtype; - } - } - return $available; -} - -/** - * Get an array of all content types that can be fed into the - * display editor for the add content list, regardless of - * availability. - * - */ -function ctools_content_get_all_types() { - $plugins = ctools_get_content_types(); - $available = array(); - - foreach ($plugins as $id => $plugin) { - foreach (ctools_content_get_subtypes($plugin) as $subtype_id => $subtype) { - // If we made it through all the tests, then we can use this content. - $available[$id][$subtype_id] = $subtype; - } - } - return $available; -} - -/** - * Select the context to be used for a piece of content, based upon config. - * - * @param $plugin - * The content plugin - * @param $subtype - * The subtype of the content. - * @param $conf - * The configuration array that should contain the context. - * @param $contexts - * A keyed array of available contexts. - * - * @return - * The matching contexts or NULL if none or necessary, or FALSE if - * requirements can't be met. - */ -function ctools_content_select_context($plugin, $subtype, $conf, $contexts) { - // Identify which of our possible contexts apply. - if (empty($subtype)) { - return; - } - - $subtype_info = ctools_content_get_subtype($plugin, $subtype); - if (empty($subtype_info)) { - return; - } - - if (!empty($subtype_info['all contexts']) || !empty($plugin['all contexts'])) { - return $contexts; - } - - // If the content requires a context, fetch it; if no context is returned, - // do not display the pane. - if (empty($subtype_info['required context'])) { - return; - } - - // Deal with dynamic required contexts not getting updated in the panes. - // For example, Views let you dynamically change context info. While - // we cannot be perfect, one thing we can do is if no context at all - // was asked for, and then was later added but none is selected, make - // a best guess as to what context should be used. THis is right more - // than it's wrong. - if (is_array($subtype_info['required context'])) { - if (empty($conf['context']) || count($subtype_info['required context']) != count($conf['context'])) { - foreach($subtype_info['required context'] as $index => $required) { - if (!isset($conf['context'][$index])) { - $filtered = ctools_context_filter($contexts, $required); - if ($filtered) { - $keys = array_keys($filtered); - $conf['context'][$index] = array_shift($keys); - } - } - } - } - } - else { - if (empty($conf['context'])) { - $filtered = ctools_context_filter($contexts, $subtype_info['required context']); - if ($filtered) { - $keys = array_keys($filtered); - $conf['context'] = array_shift($keys); - } - } - } - - if (empty($conf['context'])) { - return; - } - - $context = ctools_context_select($contexts, $subtype_info['required context'], $conf['context']); - - return $context; -} diff --git a/includes/content.menu.inc b/includes/content.menu.inc deleted file mode 100644 index 0454a54..0000000 --- a/includes/content.menu.inc +++ /dev/null @@ -1,72 +0,0 @@ - array('access content'), - 'type' => MENU_CALLBACK, - 'file' => 'includes/content.menu.inc', - ); - $items['ctools/autocomplete/%'] = array( - 'page callback' => 'ctools_content_autocomplete_entity', - 'page arguments' => array(2), - ) + $base; -} - -/** - * Helper function for autocompletion of entity titles. - */ -function ctools_content_autocomplete_entity($type, $string = '') { - $entity = entity_get_info($type); - if ($string != '') { - // @todo verify the query logic here, it's untested. - // Set up the query - $query = db_select($entity['base table'], 'b'); - if ($entity['entity keys']['label']) { - $query->fields('b', array($entity['entity keys']['id'], $entity['entity keys']['label']))->range(0, 10); - } - else { - $query->fields('b', array($entity['entity keys']['id']))->range(0, 10); - } - - $preg_matches = array(); - $match = preg_match('/\[id: (\d+)\]/', $string, $preg_matches); - if (!$match) { - $match = preg_match('/^id: (\d+)/', $string, $preg_matches); - } - if ($match) { - $query->condition('b.' . $entity['entity keys']['id'], $preg_matches[1]); - } - elseif ($entity['entity keys']['label']) { - $query->condition('b.' . $entity['entity keys']['label'], '%' . db_like($string) . '%', 'LIKE'); - } - - $matches = array(); - if ($type == 'node') { - $query->addTag('node_access'); - foreach ($query->execute() as $nodeish) { - $name = empty($nodeish->name) ? variable_get('anonymous', t('Anonymous')) : check_plain($nodeish->name); - $matches[$nodeish->title . " [id: $nodeish->nid]"] = '' . check_plain($nodeish->title) . ' (' . t('by @user', array('@user' => $name)) . ')'; - } - } - else { - foreach ($query->execute() as $item) { - $id = $item->{$entity['entity keys']['id']}; - if ($entity['entity keys']['label']) { - $matches[$item->{$entity['entity keys']['label']} . " [id: $id]"] = '' . check_plain($item->{$entity['entity keys']['label']}) . ''; - } - else { - $matches["[id: $id]"] = '' . check_plain($item->{$entity['entity keys']['id']}) . ''; - } - } - } - drupal_json_output($matches); - } -} diff --git a/includes/content.plugin-type.inc b/includes/content.plugin-type.inc deleted file mode 100644 index 4c767ae..0000000 --- a/includes/content.plugin-type.inc +++ /dev/null @@ -1,17 +0,0 @@ - FALSE, - 'process' => array( - 'function' => 'ctools_content_process', - 'file' => 'export-ui.inc', - 'path' => drupal_get_path('module', 'ctools') . '/includes', - ), - ); -} \ No newline at end of file diff --git a/includes/content.theme.inc b/includes/content.theme.inc deleted file mode 100644 index ae4456a..0000000 --- a/includes/content.theme.inc +++ /dev/null @@ -1,21 +0,0 @@ - array( - * 0 => array( - * 'name' => 'name of access plugin', - * 'settings' => array(), // These will be set by the form - * ), - * // ... as many as needed - * ), - * 'logic' => 'AND', // or 'OR', - * ), - * @endcode - * - * To add this widget to your UI, you need to do a little bit of setup. - * - * The form will utilize two callbacks, one to get the cached version - * of the access settings, and one to store the cached version of the - * access settings. These will be used from AJAX forms, so they will - * be completely out of the context of this page load and will not have - * knowledge of anything sent to this form (the 'module' and 'argument' - * will be preserved through the URL only). - * - * The 'module' is used to determine the location of the callback. It - * does not strictly need to be a module, so that if your module defines - * multiple systems that use this callback, it can use anything within the - * module's namespace it likes. - * - * When retrieving the cache, the cache may not have already been set up; - * In order to efficiently use cache space, we want to cache the stored - * settings *only* when they have changed. Therefore, the get access cache - * callback should first look for cache, and if it finds nothing, return - * the original settings. - * - * The callbacks: - * - $module . _ctools_access_get($argument) -- get the 'access' settings - * from cache. Must return array($access, $contexts); This callback can - * perform access checking to make sure this URL is not being gamed. - * - $module . _ctools_access_set($argument, $access) -- set the 'access' - * settings in cache. - * - $module . _ctools_access_clear($argument) -- clear the cache. - * - * The ctools_object_cache is recommended for this purpose, but you can use - * any caching mechanism you like. An example: - * - * @code{ - * ctools_include('object-cache'); - * ctools_object_cache_set("$module:argument", $access); - * } - * - * To utilize this form: - * @code - * ctools_include('context-access-admin'); - * $form_state = array( - * 'access' => $access, - * 'module' => 'module name', - * 'callback argument' => 'some string', - * 'contexts' => $contexts, // an array of contexts. Optional if no contexts. - * // 'logged-in-user' will be added if not present as the access system - * // requires this context. - * ), - * $output = drupal_build_form('ctools_access_admin_form', $form_state); - * if (!empty($form_state['executed'])) { - * // save $form_state['access'] however you like. - * } - * @endcode - * - * Additionally, you may add 'no buttons' => TRUE if you wish to embed this - * form into your own, and instead call - * - * @code{ - * $form = array_merge($form, ctools_access_admin_form($form_state)); - * } - * - * You'll be responsible for adding a submit button. - * - * You may use ctools_access($access, $contexts) which will return - * TRUE if access is passed or FALSE if access is not passed. - */ - -/** - * Administrative form for access control. - */ -function ctools_access_admin_form($form, &$form_state) { - ctools_include('context'); - $argument = isset($form_state['callback argument']) ? $form_state['callback argument'] : ''; - $fragment = $form_state['module']; - if ($argument) { - $fragment .= '-' . $argument; - } - - $contexts = isset($form_state['contexts']) ? $form_state['contexts'] : array(); - - $form['access_table'] = array( - '#markup' => ctools_access_admin_render_table($form_state['access'], $fragment, $contexts), - ); - - $form['add-button'] = array( - '#theme' => 'ctools_access_admin_add', - ); - // This sets up the URL for the add access modal. - $form['add-button']['add-url'] = array( - '#attributes' => array('class' => array("ctools-access-add-url")), - '#type' => 'hidden', - '#value' => url("ctools/context/ajax/access/add/$fragment", array('absolute' => TRUE)), - ); - - $plugins = ctools_get_relevant_access_plugins($contexts); - $options = array(); - foreach ($plugins as $id => $plugin) { - $options[$id] = $plugin['title']; - } - - asort($options); - - $form['add-button']['type'] = array( - // This ensures that the form item is added to the URL. - '#attributes' => array('class' => array("ctools-access-add-url")), - '#type' => 'select', - '#options' => $options, - '#required' => FALSE, - ); - - $form['add-button']['add'] = array( - '#type' => 'submit', - '#attributes' => array('class' => array('ctools-use-modal')), - '#id' => "ctools-access-add", - '#value' => t('Add'), - ); - - $form['logic'] = array( - '#type' => 'radios', - '#options' => array( - 'and' => t('All criteria must pass.'), - 'or' => t('Only one criteria must pass.'), - ), - '#default_value' => isset($form_state['access']['logic']) ? $form_state['access']['logic'] : 'and', - ); - - if (empty($form_state['no buttons'])) { - $form['buttons']['save'] = array( - '#type' => 'submit', - '#value' => t('Save'), - '#submit' => array('ctools_access_admin_form_submit'), - ); - } - - return $form; -} - -/** - * Render the table. This is used both to render it initially and to rerender - * it upon ajax response. - */ -function ctools_access_admin_render_table($access, $fragment, $contexts) { - ctools_include('ajax'); - ctools_include('modal'); - $rows = array(); - - if (empty($access['plugins'])) { - $access['plugins'] = array(); - } - - foreach ($access['plugins'] as $id => $test) { - $row = array(); - $plugin = ctools_get_access_plugin($test['name']); - $title = isset($plugin['title']) ? $plugin['title'] : t('Broken/missing access plugin %plugin', array('%plugin' => $test['name'])); - - $row[] = array('data' => $title, 'class' => array('ctools-access-title')); - - $description = ctools_access_summary($plugin, $contexts, $test); - $row[] = array('data' => $description, 'class' => array('ctools-access-description')); - - $operations = ctools_modal_image_button(ctools_image_path('icon-configure.png'), "ctools/context/ajax/access/configure/$fragment/$id", t('Configure settings for this item.')); - $operations .= ctools_ajax_image_button(ctools_image_path('icon-delete.png'), "ctools/context/ajax/access/delete/$fragment/$id", t('Remove this item.')); - - $row[] = array('data' => $operations, 'class' => array('ctools-access-operations'), 'align' => 'right'); - - $rows[] = $row; - } - - $header = array( - array('data' => t('Title'), 'class' => array('ctools-access-title')), - array('data' => t('Description'), 'class' => array('ctools-access-description')), - array('data' => '', 'class' => array('ctools-access-operations'), 'align' => 'right'), - ); - - if (empty($rows)) { - $rows[] = array(array('data' => t('No criteria selected, this test will pass.'), 'colspan' => count($header))); - } - - ctools_modal_add_js(); - return theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'ctools-access-table'))); -} - -/** - * Theme the 'add' portion of the access form into a table. - */ -function theme_ctools_access_admin_add($vars) { - $rows = array(array(drupal_render_children($vars['form']))); - $output = '
'; - $output .= theme('table', array('rows' => $rows)); - $output .= '
'; - return $output; -} - -function ctools_access_admin_form_submit($form, &$form_state) { - $form_state['access']['logic'] = $form_state['values']['logic']; - - $function = $form_state['module'] . '_ctools_access_clear'; - if (function_exists($function)) { - $function($form_state['argument']); - } -} - -// -------------------------------------------------------------------------- -// AJAX menu entry points. - -/** - * AJAX callback to add a new access test to the list. - */ -function ctools_access_ajax_add($fragment = NULL, $name = NULL) { - ctools_include('ajax'); - ctools_include('modal'); - ctools_include('context'); - - if (empty($fragment) || empty($name)) { - ctools_ajax_render_error(); - } - - $plugin = ctools_get_access_plugin($name); - if (empty($plugin)) { - ctools_ajax_render_error(); - } - - // Separate the fragment into 'module' and 'argument' - if (strpos($fragment, '-') === FALSE) { - $module = $fragment; - $argument = NULL; - } - else { - list($module, $argument) = explode('-', $fragment, 2); - } - - $function = $module . '_ctools_access_get'; - if (!function_exists($function)) { - ctools_ajax_render_error(t('Missing callback hooks.')); - } - - list($access, $contexts) = $function($argument); - - // Make sure we have the logged in user context - if (!isset($contexts['logged-in-user'])) { - $contexts['logged-in-user'] = ctools_access_get_loggedin_context(); - } - - if (empty($access['plugins'])) { - $access['plugins'] = array(); - } - - $test = ctools_access_new_test($plugin); - - $id = $access['plugins'] ? max(array_keys($access['plugins'])) + 1 : 0; - $access['plugins'][$id] = $test; - - $form_state = array( - 'plugin' => $plugin, - 'id' => $id, - 'test' => &$access['plugins'][$id], - 'access' => &$access, - 'contexts' => $contexts, - 'title' => t('Add criteria'), - 'ajax' => TRUE, - 'modal' => TRUE, - 'modal return' => TRUE, - ); - - $output = ctools_modal_form_wrapper('ctools_access_ajax_edit_item', $form_state); - if (!isset($output[0])) { - $function = $module . '_ctools_access_set'; - if (function_exists($function)) { - $function($argument, $access); - } - - $table = ctools_access_admin_render_table($access, $fragment, $contexts); - $output = array(); - $output[] = ajax_command_replace('table#ctools-access-table', $table); - $output[] = ctools_modal_command_dismiss(); - } - - print ajax_render($output); -} - -/** - * AJAX callback to edit an access test in the list. - */ -function ctools_access_ajax_edit($fragment = NULL, $id = NULL) { - ctools_include('ajax'); - ctools_include('modal'); - ctools_include('context'); - - if (empty($fragment) || !isset($id)) { - ctools_ajax_render_error(); - } - - // Separate the fragment into 'module' and 'argument' - if (strpos($fragment, '-') === FALSE) { - $module = $fragment; - $argument = NULL; - } - else { - list($module, $argument) = explode('-', $fragment, 2); - } - - $function = $module . '_ctools_access_get'; - if (!function_exists($function)) { - ctools_ajax_render_error(t('Missing callback hooks.')); - } - - list($access, $contexts) = $function($argument); - - if (empty($access['plugins'][$id])) { - ctools_ajax_render_error(); - } - - // Make sure we have the logged in user context - if (!isset($contexts['logged-in-user'])) { - $contexts['logged-in-user'] = ctools_access_get_loggedin_context(); - } - - $plugin = ctools_get_access_plugin($access['plugins'][$id]['name']); - $form_state = array( - 'plugin' => $plugin, - 'id' => $id, - 'test' => &$access['plugins'][$id], - 'access' => &$access, - 'contexts' => $contexts, - 'title' => t('Edit criteria'), - 'ajax' => TRUE, - 'ajax' => TRUE, - 'modal' => TRUE, - 'modal return' => TRUE, - ); - - $output = ctools_modal_form_wrapper('ctools_access_ajax_edit_item', $form_state); - if (!isset($output[0])) { - $function = $module . '_ctools_access_set'; - if (function_exists($function)) { - $function($argument, $access); - } - - $table = ctools_access_admin_render_table($access, $fragment, $contexts); - $output = array(); - $output[] = ajax_command_replace('table#ctools-access-table', $table); - $output[] = ctools_modal_command_dismiss(); - } - - print ajax_render($output); -} - -/** - * Form to edit the settings of an access test. - */ -function ctools_access_ajax_edit_item($form, &$form_state) { - $test = &$form_state['test']; - $plugin = &$form_state['plugin']; - if (isset($plugin['required context'])) { - $form['context'] = ctools_context_selector($form_state['contexts'], $plugin['required context'], $test['context']); - } - $form['settings'] = array('#tree' => TRUE); - if ($function = ctools_plugin_get_function($plugin, 'settings form')) { - $form = $function($form, $form_state, $test['settings']); - } - - $form['not'] = array( - '#type' => 'checkbox', - '#title' => t('Reverse (NOT)'), - '#default_value' => !empty($test['not']), - ); - - $form['save'] = array( - '#type' => 'submit', - '#value' => t('Save'), - ); - - return $form; -} - -/** - * Validate handler for argument settings. - */ -function ctools_access_ajax_edit_item_validate($form, &$form_state) { - if ($function = ctools_plugin_get_function($form_state['plugin'], 'settings form validate')) { - $function($form, $form_state); - } -} - -/** - * Submit handler for argument settings. - */ -function ctools_access_ajax_edit_item_submit($form, &$form_state) { - if ($function = ctools_plugin_get_function($form_state['plugin'], 'settings form submit')) { - $function($form, $form_state); - } - - $form_state['test']['settings'] = $form_state['values']['settings']; - if (isset($form_state['values']['context'])) { - $form_state['test']['context'] = $form_state['values']['context']; - } - $form_state['test']['not'] = !empty($form_state['values']['not']); -} - -/** - * AJAX command to remove an access control item. - */ -function ctools_access_ajax_delete($fragment = NULL, $id = NULL) { - ctools_include('ajax'); - ctools_include('modal'); - ctools_include('context'); - - if (empty($fragment) || !isset($id)) { - ajax_render_error(); - } - - // Separate the fragment into 'module' and 'argument' - if (strpos($fragment, '-') === FALSE) { - $module = $fragment; - $argument = NULL; - } - else { - list($module, $argument) = explode('-', $fragment, 2); - } - - $function = $module . '_ctools_access_get'; - if (!function_exists($function)) { - ajax_render_error(t('Missing callback hooks.')); - } - - list($access, $contexts) = $function($argument); - - if (isset($access['plugins'][$id])) { - unset($access['plugins'][$id]); - } - - // re-cache - $function = $module . '_ctools_access_set'; - if (function_exists($function)) { - $function($argument, $access); - } - - $table = ctools_access_admin_render_table($access, $fragment, $contexts); - $output = array(); - $output[] = ajax_command_replace('table#ctools-access-table', $table); - - print ajax_render($output); -} diff --git a/includes/context-admin.inc b/includes/context-admin.inc deleted file mode 100644 index a3b4b80..0000000 --- a/includes/context-admin.inc +++ /dev/null @@ -1,782 +0,0 @@ - array( - 'title' => t('Arguments'), - 'singular title' => t('argument'), - 'description' => '', // t("Arguments are parsed from the URL and translated into contexts that may be added to the display via the 'content' tab. These arguments are parsed in the order received, and you may use % in your URL to hold the place of an object; the rest of the arguments will come after the URL. For example, if the URL is node/%/panel and your user visits node/1/panel/foo, the first argument will be 1, and the second argument will be foo."), - 'add button' => t('Add argument'), - 'context function' => 'ctools_get_argument', - 'key' => 'arguments', // the key that data will be stored on an object, eg $panel_page - 'sortable' => TRUE, - 'settings' => 'argument_settings', - ), - 'relationship' => array( - 'title' => t('Relationships'), - 'singular title' => t('relationship'), - 'description' => '', // t('Relationships are contexts that are created from already existing contexts; the add relationship button will only appear once there is another context available. Relationships can load objects based upon how they are related to each other; for example, the author of a node, or a taxonomy term attached to a node, or the vocabulary of a taxonomy term.'), - 'add button' => t('Add relationship'), - 'context function' => 'ctools_get_relationship', - 'key' => 'relationships', - 'sortable' => FALSE, - 'settings' => 'relationship_settings', - ), - 'context' => array( - 'title' => t('Contexts'), - 'singular title' => t('context'), - 'description' => '', // t('Contexts are embedded directly into the panel; you generally must select an object in the panel. For example, you could select node 5, or the term "animals" or the user "administrator"'), - 'add button' => t('Add context'), - 'context function' => 'ctools_get_context', - 'key' => 'contexts', - 'sortable' => FALSE, - 'settings' => 'context_settings', - ), - 'requiredcontext' => array( - 'title' => t('Required contexts'), - 'singular title' => t('required context'), - 'description' => '', // t('Required contexts are passed in from some external source, such as a containing panel. If a mini panel has required contexts, it can only appear when that context is available, and therefore will not show up as a standard Drupal block.'), - 'add button' => t('Add required context'), - 'context function' => 'ctools_get_context', - 'key' => 'requiredcontexts', - 'sortable' => FALSE, - ), - ); - } - - if ($type === NULL) { - return $info; - } - - return $info[$type]; -} - - -/** - * Get the data belonging to a particular context. - */ -function ctools_context_get_plugin($type, $name) { - $info = ctools_context_info($type); - if (function_exists($info['context function'])) { - return $info['context function']($name); - } -} - -/** - * Add the argument table plus gadget plus javascript to the form. - */ -function ctools_context_add_argument_form($module, &$form, &$form_state, &$form_location, $object, $cache_key = NULL) { - if (empty($cache_key)) { - $cache_key = $object->name; - } - - $form_location = array( - '#prefix' => '
', - '#suffix' => '
', - '#theme' => 'ctools_context_item_form', - '#cache_key' => $cache_key, - '#ctools_context_type' => 'argument', - '#ctools_context_module' => $module, - ); - - $args = ctools_get_arguments(); - $choices = array(); - foreach ($args as $name => $arg) { - $choices[$name] = $arg['title']; - } - - asort($choices); - - if (!empty($choices) || !empty($object->arguments)) { - ctools_context_add_item_table('argument', $form_location, $choices, $object->arguments); - } -} - -function ctools_context_add_context_form($module, &$form, &$form_state, &$form_location, $object, $cache_key = NULL) { - if (empty($cache_key)) { - $cache_key = $object->name; - } - - $form_location = array( - '#prefix' => '
', - '#suffix' => '
', - '#theme' => 'ctools_context_item_form', - '#cache_key' => $cache_key, - '#ctools_context_type' => 'context', - '#ctools_context_module' => $module, - ); - - // Store the order the choices are in so javascript can manipulate it. - $form_location['markup'] = array( - '#markup' => ' ', - ); - - $choices = array(); - foreach (ctools_get_contexts() as $name => $arg) { - if (empty($arg['no ui'])) { - $choices[$name] = $arg['title']; - } - } - - asort($choices); - - if (!empty($choices) || !empty($object->contexts)) { - ctools_context_add_item_table('context', $form_location, $choices, $object->contexts); - } - -} - -function ctools_context_add_required_context_form($module, &$form, &$form_state, &$form_location, $object, $cache_key = NULL) { - if (empty($cache_key)) { - $cache_key = $object->name; - } - - $form_location = array( - '#prefix' => '
', - '#suffix' => '
', - '#theme' => 'ctools_context_item_form', - '#cache_key' => $cache_key, - '#ctools_context_type' => 'requiredcontext', - '#ctools_context_module' => $module, - ); - - // Store the order the choices are in so javascript can manipulate it. - $form_location['markup'] = array( - '#value' => ' ', - ); - - $choices = array(); - foreach (ctools_get_contexts() as $name => $arg) { - $choices[$name] = $arg['title']; - } - - asort($choices); - - if (!empty($choices) || !empty($object->contexts)) { - ctools_context_add_item_table('requiredcontext', $form_location, $choices, $object->requiredcontexts); - } -} - -function ctools_context_add_relationship_form($module, &$form, &$form_state, &$form_location, $object, $cache_key = NULL) { - if (empty($cache_key)) { - $cache_key = $object->name; - } - - $form_location = array( - '#prefix' => '
', - '#suffix' => '
', - '#theme' => 'ctools_context_item_form', - '#cache_key' => $cache_key, - '#ctools_context_type' => 'relationship', - '#ctools_context_module' => $module, - ); - - // Store the order the choices are in so javascript can manipulate it. - $form_location['markup'] = array( - '#value' => ' ', - ); - - $base_contexts = isset($object->base_contexts) ? $object->base_contexts : array(); - $available_relationships = ctools_context_get_relevant_relationships(ctools_context_load_contexts($object, TRUE, $base_contexts)); - - ctools_context_add_item_table('relationship', $form_location, $available_relationships, $object->relationships); -} - -/** - * Include all context administrative include files, css, javascript. - */ -function ctools_context_admin_includes() { - ctools_include('context'); - ctools_include('modal'); - ctools_include('ajax'); - ctools_include('object-cache'); - ctools_modal_add_js(); - ctools_modal_add_plugin_js(ctools_get_contexts()); - ctools_modal_add_plugin_js(ctools_get_relationships()); -} - -/** - * Add the context table to the page. - */ -function ctools_context_add_item_table($type, &$form, $available_contexts, $items) { - $form[$type] = array( - '#tree' => TRUE, - ); - - $module = $form['#ctools_context_module']; - $cache_key = $form['#cache_key']; - - if (isset($items) && is_array($items)) { - foreach ($items as $position => $context) { - ctools_context_add_item_to_form($module, $type, $cache_key, $form[$type][$position], $position, $context); - } - } - - $type_info = ctools_context_info($type); - $form['description'] = array( - '#prefix' => '
', - '#suffix' => '
', - '#markup' => $type_info['description'], - ); - - ctools_context_add_item_table_buttons($type, $module, $form, $available_contexts); -} - -function ctools_context_add_item_table_buttons($type, $module, &$form, $available_contexts) { - drupal_add_js('misc/ajax.js'); - $form['buttons'] = array( - '#tree' => TRUE, - ); - - if (!empty($available_contexts)) { - $type_info = ctools_context_info($type); - - $module = $form['#ctools_context_module']; - $cache_key = $form['#cache_key']; - - // The URL for this ajax button - $form['buttons'][$type]['add-url'] = array( - '#attributes' => array('class' => array("ctools-$type-add-url")), - '#type' => 'hidden', - '#value' => url("ctools/context/ajax/add/$module/$type/$cache_key", array('absolute' => TRUE)), - ); - - // This also will be in the URL. - $form['buttons'][$type]['item'] = array( - '#attributes' => array('class' => array("ctools-$type-add-url")), - '#type' => 'select', - '#options' => $available_contexts, - '#required' => FALSE, - ); - - $form['buttons'][$type]['add'] = array( - '#type' => 'submit', - '#attributes' => array('class' => array('ctools-use-modal')), - '#id' => "ctools-$type-add", - '#value' => $type_info['add button'], - ); - } -} - -/** - * Add a row to the form. Used both in the main form and by - * the ajax to add an item. - */ -function ctools_context_add_item_to_form($module, $type, $cache_key, &$form, $position, $item) { - // This is the single function way to load any plugin by variable type. - $info = ctools_context_get_plugin($type, $item['name']); - $form['title'] = array( - '#markup' => check_plain($item['identifier']), - ); - - // Relationships not sortable. - $type_info = ctools_context_info($type); - - if (!empty($type_info['sortable'])) { - $form['position'] = array( - '#type' => 'weight', - '#default_value' => $position, - '#attributes' => array('class' => array('drag-position')), - ); - } - - $form['remove'] = array( - '#markup' => ctools_ajax_image_button(ctools_image_path('icon-delete.png'), "ctools/context/ajax/delete/$module/$type/$cache_key/$position", t('Remove this item.')), - ); - - $form['settings'] = array( - '#markup' => ctools_modal_image_button(ctools_image_path('icon-configure.png'), "ctools/context/ajax/configure/$module/$type/$cache_key/$position", t('Configure settings for this item.')), - ); -} - - -// --------------------------------------------------------------------------- -// AJAX forms and stuff. - -/** - * Ajax entry point to add an context - */ -function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_key = NULL, $name = NULL, $step = NULL) { - ctools_include('ajax'); - ctools_include('modal'); - ctools_include('context'); - ctools_include('cache'); - ctools_include('plugins-admin'); - - if (!$name) { - return ctools_ajax_render_error(); - } - - // Load stored object from cache. - if (!($object = ctools_cache_get($mechanism, $cache_key))) { - ctools_ajax_render_error(t('Invalid object name.')); - } - - // Get info about what we're adding, i.e, relationship, context, argument, etc. - $plugin_definition = ctools_context_get_plugin($type, $name); - if (empty($plugin_definition)) { - ctools_ajax_render_error(t('Invalid context type')); - } - - // Set up the $conf array for this plugin - if (empty($step) || empty($object->temporary)) { - // Create the basis for our new context. - $conf = ctools_context_get_defaults($plugin_definition); - $object->temporary = &$conf; - } - else { - $conf = &$object->temporary; - } - - // Load the contexts that may be used. - $base_contexts = isset($object->base_contexts) ? $object->base_contexts : array(); - $contexts = ctools_context_load_contexts($object, TRUE, $base_contexts); - - $type_info = ctools_context_info($type); - $form_state = array( - 'ajax' => TRUE, - 'modal' => TRUE, - 'modal return' => TRUE, - 'object' => &$object, - 'conf' => &$conf, - 'plugin' => $plugin_definition, - 'type' => $type, - 'contexts' => $contexts, - 'title' => t('Add @type "@context"', array('@type' => $type_info['singular title'], '@context' => $plugin_definition['title'])), - 'type info' => $type_info, - 'op' => 'add', - 'step' => $step, - ); - - $form_info = array( - 'path' => "ctools/context/ajax/add/$mechanism/$type/$cache_key/$name/%step", - 'show cancel' => TRUE, - 'default form' => 'ctools_edit_context_form_defaults', - 'auto caching' => TRUE, - 'cache mechanism' => $mechanism, - 'cache key' => $cache_key, - // This is stating what the cache will be referred to in $form_state - 'cache storage' => 'object', - ); - - $output = ctools_plugin_configure_form($form_info, $form_state); - - // If $rc is FALSE, there was no actual form. - if ($output === FALSE || !empty($form_state['complete'])) { - // Successful submit -- move temporary data to location. - - // Create a reference to the place our context lives. Since this is fairly - // generic, this is the easiest way to get right to the place of the - // object without knowing precisely what data we're poking at. - $ref = &$object->{$type_info['key']}; - - // Figure out the position for our new context. - $position = empty($ref) ? 0 : max(array_keys($ref)) + 1; - - $conf['id'] = ctools_context_next_id($ref, $name); - $ref[$position] = $conf; - - if (isset($object->temporary)) { - unset($object->temporary); - } - - ctools_cache_operation($mechanism, $cache_key, 'finalize', $object); - - // Very irritating way to update the form for our contexts. - $arg_form_state = array('values' => array()); - - $arg_form = array( - '#post' => array(), - '#programmed' => FALSE, - '#tree' => FALSE, - ); - - // Build a chunk of the form to merge into the displayed form - $arg_form[$type] = array( - '#tree' => TRUE, - ); - $arg_form[$type][$position] = array( - '#tree' => TRUE, - ); - - ctools_context_add_item_to_form($mechanism, $type, $cache_key, $arg_form[$type][$position], $position, $ref[$position]); - $arg_form = form_builder('ctools_context_form', $arg_form, $arg_form_state); - - // Build the relationships table so we can ajax it in. - // This is an additional thing that goes in here. - $rel_form = array( - '#theme' => 'ctools_context_item_form', - '#cache_key' => $cache_key, - '#ctools_context_type' => 'relationship', - '#ctools_context_module' => $mechanism, - '#only_buttons' => TRUE, - '#post' => array(), - '#programmed' => FALSE, - '#tree' => FALSE, - ); - - $rel_form['relationship'] = array( - '#tree' => TRUE, - ); - - // Allow an object to set some 'base' contexts that come from elsewhere. - $rel_contexts = isset($object->base_contexts) ? $object->base_contexts : array(); - $all_contexts = ctools_context_load_contexts($object, TRUE, $rel_contexts); - $available_relationships = ctools_context_get_relevant_relationships($all_contexts); - - $output = array(); - if (!empty($available_relationships)) { - ctools_context_add_item_table_buttons('relationship', $mechanism, $rel_form, $available_relationships); - $rel_form = form_builder('dummy_form_id', $rel_form, $arg_form_state); - $output[] = ajax_command_replace('div#ctools-relationships-table div.buttons', drupal_render($rel_form)); - } - - $theme_vars = array(); - $theme_vars['type'] = $type; - $theme_vars['form'] = $arg_form[$type][$position]; - $theme_vars['position'] = $position; - $theme_vars['count'] = $position; - $text = theme('ctools_context_item_row', $theme_vars); - $output[] = ajax_command_append('#' . $type . '-table tbody', $text); - $output[] = ajax_command_changed('#' . $type . '-row-' . $position, '.title'); - $output[] = ctools_modal_command_dismiss(); - } - else { - $output = ctools_modal_form_render($form_state, $output); - } - print ajax_render($output); - exit; -} - -/** - * Ajax entry point to edit an item - */ -function ctools_context_ajax_item_edit($mechanism = NULL, $type = NULL, $cache_key = NULL, $position = NULL, $step = NULL) { - ctools_include('ajax'); - ctools_include('modal'); - ctools_include('context'); - ctools_include('cache'); - ctools_include('plugins-admin'); - - if (!isset($position)) { - return ctools_ajax_render_error(); - } - - // Load stored object from cache. - if (!($object = ctools_cache_get($mechanism, $cache_key))) { - ctools_ajax_render_error(t('Invalid object name.')); - } - - $type_info = ctools_context_info($type); - - // Create a reference to the place our context lives. Since this is fairly - // generic, this is the easiest way to get right to the place of the - // object without knowing precisely what data we're poking at. - $ref = &$object->{$type_info['key']}; - - if (empty($step) || empty($object->temporary)) { - // Create the basis for our new context. - $conf = $object->{$type_info['key']}[$position]; - $object->temporary = &$conf; - } - else { - $conf = &$object->temporary; - } - - $name = $ref[$position]['name']; - if (empty($name)) { - ctools_ajax_render_error(); - } - - // load the plugin definition - $plugin_definition = ctools_context_get_plugin($type, $name); - if (empty($plugin_definition)) { - ctools_ajax_render_error(t('Invalid context type')); - } - - // Load the contexts - $base_contexts = isset($object->base_contexts) ? $object->base_contexts : array(); - $contexts = ctools_context_load_contexts($object, TRUE, $base_contexts); - - $form_state = array( - 'ajax' => TRUE, - 'modal' => TRUE, - 'modal return' => TRUE, - 'object' => &$object, - 'conf' => &$conf, - 'position' => $position, - 'plugin' => $plugin_definition, - 'type' => $type, - 'contexts' => $contexts, - 'title' => t('Edit @type "@context"', array('@type' => $type_info['singular title'], '@context' => $plugin_definition['title'])), - 'type info' => $type_info, - 'op' => 'add', - 'step' => $step, - ); - - $form_info = array( - 'path' => "ctools/context/ajax/configure/$mechanism/$type/$cache_key/$position/%step", - 'show cancel' => TRUE, - 'default form' => 'ctools_edit_context_form_defaults', - 'auto caching' => TRUE, - 'cache mechanism' => $mechanism, - 'cache key' => $cache_key, - // This is stating what the cache will be referred to in $form_state - 'cache storage' => 'object', - ); - - $output = ctools_plugin_configure_form($form_info, $form_state); - - // If $rc is FALSE, there was no actual form. - if ($output === FALSE || !empty($form_state['complete'])) { - // successful submit - $ref[$position] = $conf; - if (isset($object->temporary)) { - unset($object->temporary); - } - - ctools_cache_operation($mechanism, $cache_key, 'finalize', $object); - - $output = array(); - $output[] = ctools_modal_command_dismiss(); - - $arg_form = array( - '#post' => array(), - '#programmed' => FALSE, - '#tree' => FALSE, - ); - - // Build a chunk of the form to merge into the displayed form - $arg_form[$type] = array( - '#tree' => TRUE, - ); - $arg_form[$type][$position] = array( - '#tree' => TRUE, - ); - - ctools_context_add_item_to_form($mechanism, $type, $cache_key, $arg_form[$type][$position], $position, $ref[$position]); - $arg_form = form_builder('ctools_context_form', $arg_form, $arg_form_state); - - $theme_vars = array(); - $theme_vars['type'] = $type; - $theme_vars['form'] = $arg_form[$type][$position]; - $theme_vars['position'] = $position; - $theme_vars['count'] = $position; - $output[] = ajax_command_replace('#' . $type . '-row-' . $position, theme('ctools_context_item_row', $theme_vars)); - $output[] = ajax_command_changed('#' . $type . '-row-' . $position, '.title'); - } - else { - $output = ctools_modal_form_render($form_state, $output); - } - print ajax_render($output); - exit; -} - -function ctools_context_get_defaults($plugin_definition) { - $conf = array( - 'identifier' => $plugin_definition['title'] . ($id > 1 ? ' ' . $id : ''), - 'keyword' => ctools_get_keyword($object, $plugin_definition['keyword']), - 'name' => $plugin_definition['name'], - ); - - if (isset($plugin['defaults'])) { - $defaults = $plugin['defaults']; - } - else if (isset($subtype['defaults'])) { - $defaults = $subtype['defaults']; - } - - if (isset($defaults)) { - if (is_string($defaults) && function_exists($defaults)) { - if ($settings = $defaults($plugin_definition)) { - $conf += $settings; - } - } - else if (is_array($defaults)) { - $conf += $defaults; - } - } - - return $conf; -} - -/** - * Form wrapper for the edit context form. - * - * @todo: We should uncombine these. - */ -function ctools_edit_context_form_defaults($form, &$form_state) { - // Basic values required to orient ourselves - $object = $form_state['object']; - $plugin_definition = $form_state['plugin']; - $type_info = $form_state['type info']; - $position = $form_state['position']; - $contexts = $form_state['contexts']; - $conf = $form_state['conf']; - - if ($type_info['key'] == 'arguments' && !isset($conf['default'])) { - $conf['default'] = 'ignore'; - $conf['title'] = ''; - } - - $form['description'] = array( - '#prefix' => '
', - '#suffix' => '
', - '#markup' => check_plain($plugin_definition['description']), - ); - - if ($type_info['key'] == 'relationships') { - $form['context'] = ctools_context_selector($contexts, $plugin_definition['required context'], isset($conf['context']) ? $conf['context'] : ''); - } - if ($type_info['key'] == 'arguments') { - $form['default'] = array( - '#type' => 'select', - '#title' => t('Default'), - '#options' => array( - 'ignore' => t('Ignore it; content that requires this context will not be available.'), - '404' => t('Display page not found or display nothing at all.'), - ), - '#default_value' => $conf['default'], - '#description' => t('If the argument is missing or is not valid, select how this should behave.'), - ); - - $form['title'] = array( - '#type' => 'textfield', - '#title' => t('Title'), - '#default_value' => $conf['title'], - '#description' => t('Enter a title to use when this argument is present. You may use %KEYWORD substitution, where the keyword is specified below.'), - ); - } - - $form['identifier'] = array( - '#type' => 'textfield', - '#title' => t('Identifier'), - '#description' => t('Enter a name to identify this !type on administrative screens.', array('!type' => t('context'))), - '#default_value' => $conf['identifier'], - ); - - $form['keyword'] = array( - '#type' => 'textfield', - '#title' => t('Keyword'), - '#description' => t('Enter a keyword to use for substitution in titles.'), - '#default_value' => $conf['keyword'], - ); - - $form['#submit'][] = 'ctools_edit_context_form_defaults_submit'; - - return $form; -} - -/** - * Submit handler to store context identifier and keyword info. - */ -function ctools_edit_context_form_defaults_submit(&$form, &$form_state) { - if ($form_state['type info']['key'] == 'relationships') { - $form_state['conf']['context'] = $form_state['values']['context']; - } - if ($form_state['type info']['key'] == 'arguments') { - $form_state['conf']['default'] = $form_state['values']['default']; - $form_state['conf']['title'] = $form_state['values']['title']; - } - - $form_state['conf']['identifier'] = $form_state['values']['identifier']; - $form_state['conf']['keyword'] = $form_state['values']['keyword']; -} - -/** - * Ajax entry point to edit an item - */ -function ctools_context_ajax_item_delete($mechanism = NULL, $type = NULL, $cache_key = NULL, $position = NULL) { - ctools_include('ajax'); - ctools_include('context'); - ctools_include('cache'); - - if (!isset($position)) { - return ctools_ajax_render_error(); - } - - // Load stored object from cache. - if (!($object = ctools_cache_get($mechanism, $cache_key))) { - ctools_ajax_render_error(t('Invalid object name.')); - } - - $type_info = ctools_context_info($type); - - // Create a reference to the place our context lives. Since this is fairly - // generic, this is the easiest way to get right to the place of the - // object without knowing precisely what data we're poking at. - $ref = &$object->{$type_info['key']}; - - if (!array_key_exists($position, $ref)) { - ctools_ajax_render_error(t('Unable to delete missing item!')); - } - - unset($ref[$position]); - ctools_cache_operation($mechanism, $cache_key, 'finalize', $object); - - $output = array(); - $output[] = ajax_command_replace('#' . $type . '-row-' . $position, ''); - $output[] = ajax_command_restripe("#$type-table"); - print ajax_render($output); - exit; -} - -// --- End of contexts - -function ctools_save_context($type, &$ref, $form_values) { - $type_info = ctools_context_info($type); - - // Organize arguments - $new = array(); - $order = array(); - - foreach ($ref as $id => $context) { - $position = $form_values[$type][$id]['position']; - $order[$position] = $id; - } - - ksort($order); - foreach ($order as $id) { - $new[] = $ref[$id]; - } - $ref = $new; -} - -function ctools_get_keyword($page, $word) { - // Create a complete set of keywords - $keywords = array(); - foreach (array('arguments', 'relationships', 'contexts', 'requiredcontexts') as $type) { - if (!empty($page->$type) && is_array($page->$type)) { - foreach ($page->$type as $info) { - $keywords[$info['keyword']] = TRUE; - } - } - } - - $keyword = $word; - $count = 0; - while (!empty($keywords[$keyword])) { - $keyword = $word . '_' . ++$count; - } - return $keyword; -} - diff --git a/includes/context-task-handler.inc b/includes/context-task-handler.inc deleted file mode 100644 index aa11eab..0000000 --- a/includes/context-task-handler.inc +++ /dev/null @@ -1,486 +0,0 @@ - $handler) { - $plugin = page_manager_get_task_handler($handler->handler); - // First, see if the handler has a tester. - $function = ctools_plugin_get_function($plugin, 'test'); - if ($function) { - $test = $function($handler, $contexts, $args); - if ($test) { - return $id; - } - } - else { - // If not, if it's a 'context' type handler, use the default tester. - if ($plugin['handler type'] == 'context') { - $test = ctools_context_handler_default_test($handler, $contexts, $args); - } - if ($test) { - return $id; - } - } - } - - return FALSE; -} - -/** - * Default test function to see if a task handler should be rendered. - * - * This tests against the standard selection criteria that most task - * handlers should be implementing. - */ -function ctools_context_handler_default_test($handler, $base_contexts, $args) { - ctools_include('context'); - // Add my contexts - $contexts = ctools_context_handler_get_handler_contexts($base_contexts, $handler); - - // Test. - return ctools_context_handler_select($handler, $contexts); -} - -/** - * Render a task handler. - */ -function ctools_context_handler_render_handler($task, $subtask, $handler, $contexts, $args, $page = TRUE) { - $function = page_manager_get_renderer($handler); - if (!$function) { - return NULL; - } - - $info = $function($handler, $contexts, $args); - if (!$info) { - return NULL; - } - - $context = array( - 'args' => $args, - 'contexts' => $contexts, - 'task' => $task, - 'subtask' => $subtask, - 'handler' => $handler - ); - drupal_alter('ctools_render', $info, $page, $context); - - // If we don't own the page, let the caller deal with rendering. - if (!$page) { - return $info; - } - - if ($subtask) { - $task_name = page_manager_make_task_name($task['name'], $subtask['name']); - } - else { - $task_name = $task['name']; - } - - page_manager_get_current_page(array( - 'name' => $task_name, - 'task' => $task, - 'subtask' => $subtask, - 'contexts' => $contexts, - 'arguments' => $args, - 'handler' => $handler, - )); - - if (!empty($info['response code']) && $info['response code'] != 200) { - switch ($info['response code']) { - case 403: - return MENU_ACCESS_DENIED; - case 404: - return MENU_NOT_FOUND; - case 301: - case 302: - case 303: - case 304: - case 305: - case 307: - $info += array( - 'query' => '', - 'fragment' => '', - ); - $options = array( - 'query' => $info['query'], - 'fragment' => $info['fragment'], - ); - return drupal_goto($info['destination'], $options, $info['response code']); - // @todo -- should other response codes be supported here? - } - } - - foreach (ctools_context_handler_get_task_arguments($task, $subtask) as $id => $argument) { - $plugin = ctools_get_argument($argument['name']); - $cid = ctools_context_id($argument, 'argument'); - if (!empty($contexts[$cid]) && ($function = ctools_plugin_get_function($plugin, 'breadcrumb'))) { - $function($argument['settings'], $contexts[$cid]); - } - } - - if (isset($info['title'])) { - drupal_set_title($info['title']); - } - - // Only directly output if $page was set to true. - if (!empty($info['no_blocks'])) { - ctools_set_no_blocks(FALSE); - } - return $info['content']; -} - -/** - * Called to execute actions that should happen before a handler is rendered. - */ -function ctools_context_handler_pre_render($handler, $contexts, $args) { - $plugin = page_manager_get_task_handler($handler->handler); - - if (user_access('administer page manager') && isset($handler->task)) { - // Provide a tab to edit this context: - ctools_include('menu'); - $task = page_manager_get_task($handler->task); - - $title = !empty($task['tab title']) ? $task['tab title'] : t('Edit @type', array('@type' => $plugin['title'])); - $trail = array(); - if (!empty($plugin['tab operation'])) { - if (is_array($plugin['tab operation'])) { - $trail = $plugin['tab operation']; - } - else if (function_exists($plugin['tab operation'])) { - $trail = $plugin['tab operation']($handler, $contexts, $args); - } - } - - ctools_menu_add_tab(array( - 'title' => $title, - 'href' => page_manager_edit_url(page_manager_make_task_name($handler->task, $handler->subtask), $trail), - 'type' => MENU_LOCAL_ACTION - )); - } -} - -/** - * Compare arguments to contexts for selection purposes. - * - * @param $handler - * The handler in question. - * @param $contexts - * The context objects provided by the task. - * - * @return - * TRUE if these contexts match the selection rules. NULL or FALSE - * otherwise. - */ -function ctools_context_handler_select($handler, $contexts) { - if (empty($handler->conf['access'])) { - return TRUE; - } - - ctools_include('context'); - return ctools_access($handler->conf['access'], $contexts); -} - -/** - * Get the array of summary strings for the arguments. - * - * These summary strings are used to communicate to the user what - * arguments the task handlers are selecting. - * - * @param $task - * The loaded task plugin. - * @param $subtask - * The subtask id. - * @param $handler - * The handler to be checked. - */ -function ctools_context_handler_summary($task, $subtask, $handler) { - if (empty($handler->conf['access']['plugins'])) { - return array(); - } - - ctools_include('context'); - $strings = array(); - $contexts = ctools_context_handler_get_all_contexts($task, $subtask, $handler); - - foreach ($handler->conf['access']['plugins'] as $test) { - $plugin = ctools_get_access_plugin($test['name']); - if ($string = ctools_access_summary($plugin, $contexts, $test)) { - $strings[] = $string; - } - } - - return $strings; -} - -// -------------------------------------------------------------------------- -// Tasks and Task handlers can both have their own sources of contexts. -// Sometimes we need all of these contexts at once (when editing -// the task handler, for example) but sometimes we need them separately -// (when a task has contexts loaded and is trying out the task handlers, -// for example). Therefore there are two paths we can take to getting contexts. - -/** - * Load the contexts for a task, using arguments. - * - * This creates the base array of contexts, loaded from arguments, suitable - * for use in rendering. - */ -function ctools_context_handler_get_task_contexts($task, $subtask, $args) { - $contexts = ctools_context_handler_get_base_contexts($task, $subtask); - $arguments = ctools_context_handler_get_task_arguments($task, $subtask); - ctools_context_get_context_from_arguments($arguments, $contexts, $args); - - return $contexts; -} - -/** - * Load the contexts for a task handler. - * - * This expands a base set of contexts passed in from a task with the - * contexts defined on the task handler. The contexts from the task - * must already have been loaded. - */ -function ctools_context_handler_get_handler_contexts($contexts, $handler) { - $object = ctools_context_handler_get_handler_object($handler); - return ctools_context_load_contexts($object, FALSE, $contexts); -} - -/** - * Load the contexts for a task and task handler together. - * - * This pulls the arguments from a task and everything else from a task - * handler and loads them as a group. Since there is no data, this loads - * the contexts as placeholders. - */ -function ctools_context_handler_get_all_contexts($task, $subtask, $handler) { - $contexts = array(); - - $object = ctools_context_handler_get_task_object($task, $subtask, $handler); - $contexts = ctools_context_load_contexts($object, TRUE, $contexts); - ctools_context_handler_set_access_restrictions($task, $subtask, $handler, $contexts); - return $contexts; -} - -/** - * Create an object suitable for use with the context system that kind of - * expects things in a certain, kind of clunky format. - */ -function ctools_context_handler_get_handler_object($handler) { - $object = new stdClass; - $object->name = $handler->name; - $object->contexts = isset($handler->conf['contexts']) ? $handler->conf['contexts'] : array(); - $object->relationships = isset($handler->conf['relationships']) ? $handler->conf['relationships'] : array(); - - return $object; -} - -/** - * Create an object suitable for use with the context system that kind of - * expects things in a certain, kind of clunky format. This one adds in - * arguments from the task. - */ -function ctools_context_handler_get_task_object($task, $subtask, $handler) { - $object = new stdClass; - $object->name = !empty($handler->name) ? $handler->name : 'temp'; - $object->base_contexts = ctools_context_handler_get_base_contexts($task, $subtask, TRUE); - $object->arguments = ctools_context_handler_get_task_arguments($task, $subtask); - $object->contexts = isset($handler->conf['contexts']) ? $handler->conf['contexts'] : array(); - $object->relationships = isset($handler->conf['relationships']) ? $handler->conf['relationships'] : array(); - - return $object; -} - -/** - * Get base contexts from a task, if it has any. - * - * Tasks can get their contexts either from base contexts or arguments; base - * contexts extract their information from the environment. - */ -function ctools_context_handler_get_base_contexts($task, $subtask, $placeholders = FALSE) { - if ($function = ctools_plugin_get_function($task, 'get base contexts')) { - return $function($task, $subtask, $placeholders); - } - - return array(); -} - -/** - * Get the arguments from a task that are used to load contexts. - */ -function ctools_context_handler_get_task_arguments($task, $subtask) { - if ($function = ctools_plugin_get_function($task, 'get arguments')) { - return $function($task, $subtask); - } - - return array(); -} - -/** - * Set any access restrictions on the contexts for a handler. - * - * Both the task and the handler could add restrictions to the contexts - * based upon the access control. These restrictions might be useful - * to limit what kind of content appears in the add content dialog; - * for example, if we have an access item that limits a node context - * to only 'story' and 'page' types, there is no need for content that - * only applies to the 'poll' type to appear. - */ -function ctools_context_handler_set_access_restrictions($task, $subtask, $handler, &$contexts) { - // First, for the task: - if ($function = ctools_plugin_get_function($task, 'access restrictions')) { - $function($task, $subtask, $contexts); - } - - // Then for the handler: - if (isset($handler->conf['access'])) { - ctools_access_add_restrictions($handler->conf['access'], $contexts); - } -} - -/** - * Form to choose context based selection rules for a task handler. - * - * The configuration will be assumed to go simply in $handler->conf and - * will be keyed by the argument ID. - */ -function ctools_context_handler_edit_criteria($form, &$form_state) { - if (!isset($form_state['handler']->conf['access'])) { - $form_state['handler']->conf['access'] = array(); - } - - ctools_include('context'); - ctools_include('modal'); - ctools_include('ajax'); - ctools_modal_add_plugin_js(ctools_get_access_plugins()); - ctools_include('context-access-admin'); - $form_state['module'] = 'page_manager_task_handler'; - // Encode a bunch of info into the argument so we can get our cache later - $form_state['callback argument'] = $form_state['task_name'] . '*' . $form_state['handler']->name; - $form_state['access'] = $form_state['handler']->conf['access']; - $form_state['no buttons'] = TRUE; - $form_state['contexts'] = ctools_context_handler_get_all_contexts($form_state['task'], $form_state['subtask'], $form_state['handler']); - - $form['markup'] = array( - '#markup' => '
' . - t('If there is more than one variant on a page, when the page is visited each variant is given an opportunity to be displayed. Starting from the first variant and working to the last, each one tests to see if its selection rules will pass. The first variant that meets its criteria (as specified below) will be used.') . - '
', - ); - $form = ctools_access_admin_form($form, $form_state); - return $form; -} - -/** - * Submit handler for rules selection - */ -function ctools_context_handler_edit_criteria_submit(&$form, &$form_state) { - $form_state['handler']->conf['access']['logic'] = $form_state['values']['logic']; -} - -/** - * Edit contexts that go with this panel. - */ -function ctools_context_handler_edit_context($form, &$form_state) { - ctools_include('context-admin'); - ctools_context_admin_includes(); - - $handler = $form_state['handler']; - $page = $form_state['page']; - $cache_name = $handler->name ? $handler->name : 'temp'; - if (isset($page->context_cache[$cache_name])) { - $cache = $page->context_cache[$cache_name]; - } - else { - $cache = ctools_context_handler_get_task_object($form_state['task'], $form_state['subtask'], $form_state['handler']); - $form_state['page']->context_cache[$cache_name] = $cache; - } - - $form['right'] = array( - '#prefix' => '
', - '#suffix' => '
', - ); - - $form['left'] = array( - '#prefix' => '
', - '#suffix' => '
', - ); - - $module = 'page_manager_context::' . $page->task_name; - ctools_context_add_context_form($module, $form, $form_state, $form['right']['contexts_table'], $cache); - ctools_context_add_relationship_form($module, $form, $form_state, $form['right']['relationships_table'], $cache); - - $theme_vars = array(); - $theme_vars['object'] = $cache; - $theme_vars['header'] = t('Summary of contexts'); - $form['left']['summary'] = array( - '#prefix' => '
', - '#suffix' => '
', - '#markup' => theme('ctools_context_list', $theme_vars), - ); - - $form_state['context_object'] = &$cache; - return $form; -} - -/** - * Process submission of the context edit form. - */ -function ctools_context_handler_edit_context_submit(&$form, &$form_state) { - $handler = &$form_state['handler']; - - $cache_name = $handler->name ? $handler->name : 'temp'; - - $handler->conf['contexts'] = $form_state['context_object']->contexts; - $handler->conf['relationships'] = $form_state['context_object']->relationships; - if (isset($form_state['page']->context_cache[$cache_name])) { - unset($form_state['page']->context_cache[$cache_name]); - } -} - diff --git a/includes/context.inc b/includes/context.inc deleted file mode 100644 index cc46360..0000000 --- a/includes/context.inc +++ /dev/null @@ -1,1542 +0,0 @@ -type = $type; - $this->data = $data; - $this->title = t('Unknown context'); - } - - function is_type($type) { - if ($type == 'any' || $this->type == 'any') { - return TRUE; - } - - $a = is_array($type) ? $type : array($type); - $b = is_array($this->type) ? $this->type : array($this->type); - return (bool) array_intersect($a, $b); - } - - function get_argument() { - return $this->argument; - } - - function get_original_argument() { - if (!is_null($this->original_argument)) { - return $this->original_argument; - } - return $this->argument; - } - - function get_keyword() { - return $this->keyword; - } - - function get_identifier() { - return $this->identifier; - } - - function get_title() { - return $this->title; - } - - function get_page_title() { - return $this->page_title; - } -} - -/** - * Used to create a method of comparing if a list of contexts - * match a required context type. - */ -class ctools_context_required { - var $keywords = ''; - - /** - * If set, the title will be used in the selector to identify - * the context. This is very useful when multiple contexts - * are required to inform the user will be used for what. - */ - var $title = NULL; - - /** - * Test to see if this context is required. - */ - var $required = TRUE; - - /** - * - * @param $title - * The first parameter should be the 'title' of the context for use - * in UYI selectors when multiple contexts qualify. - * @param ... - * One or more keywords to use for matching which contexts are allowed. - */ - function ctools_context_required($title) { - $args = func_get_args(); - $this->title = array_shift($args); - - // If we were given restrictions at the end, store them. - if (count($args) > 1 && is_array(end($args))) { - $this->restrictions = array_pop($args); - } - - if (count($args) == 1) { - $args = array_shift($args); - } - $this->keywords = $args; - } - - function filter($contexts) { - $result = array(); - - // See which of these contexts are valid - foreach ((array) $contexts as $cid => $context) { - if ($context->is_type($this->keywords)) { - // Compare to see if our contexts were met. - if (!empty($this->restrictions) && !empty($context->restrictions)) { - foreach ($this->restrictions as $key => $values) { - // If we have a restriction, the context must either not have that - // restriction listed, which means we simply don't know what it is, - // or there must be an intersection of the restricted values on - // both sides. - if (!is_array($values)) { - $values = array($values); - } - if (!empty($context->restrictions[$key]) && !array_intersect($values, $context->restrictions[$key])) { - continue 2; - } - } - } - $result[$cid] = $context; - } - } - - return $result; - } - - function select($contexts, $context) { - if (!is_array($contexts)) { - $contexts = array($contexts); - } - - // Due to a bug, some contexts got recorded with an id of 0. This will - // convert them to the correct ID allowing for some earlier panels - // to continue to work. - if (!empty($context) && $context[strlen($context) - 1] === '0') { - $context[strlen($context) - 1] = 1; - } - - if (empty($context) || empty($contexts[$context])) { - return FALSE; - } - return $contexts[$context]; - } -} - -/** - * Used to compare to see if a list of contexts match an optional context. This - * can produce empty contexts to use as placeholders. - */ -class ctools_context_optional extends ctools_context_required { - var $required = FALSE; - function ctools_context_optional() { - $args = func_get_args(); - call_user_func_array(array($this, 'ctools_context_required'), $args); - } - - /** - * Add the 'empty' context which is possible for optional - */ - function add_empty(&$contexts) { - $context = new ctools_context('any'); - $context->title = t('No context'); - $context->identifier = t('No context'); - $contexts = array_merge(array('empty' => $context), $contexts); - } - - function filter($contexts) { - $this->add_empty($contexts); - return parent::filter($contexts); - } - - function select($contexts, $context) { - $this->add_empty($contexts); - if (empty($context)) { - return $contexts['empty']; - } - - $result = parent::select($contexts, $context); - - // Don't flip out if it can't find the context; this is optional, put - // in an empty. - if ($result == FALSE) { - $result = $contexts['empty']; - } - return $result; - } -} - -/** - * Return a keyed array of context that match the given 'required context' - * filters. - * - * Functions or systems that require contexts of a particular type provide a - * ctools_context_required or ctools_context_optional object. This function - * examines that object and an array of contexts to determine which contexts - * match the filter. - * - * Since multiple contexts can be required, this function will accept either - * an array of all required contexts, or just a single required context object. - * - * @param $contexts - * A keyed array of all available contexts. - * @param $required - * A ctools_context_required or ctools_context_optional object, or an array - * of such objects. - * - * @return - * A keyed array of contexts that match the filter. - */ -function ctools_context_filter($contexts, $required) { - if (is_array($required)) { - $result = array(); - foreach ($required as $r) { - $result = array_merge($result, _ctools_context_filter($contexts, $r)); - } - return $result; - } - - return _ctools_context_filter($contexts, $required); -} - -function _ctools_context_filter($contexts, $required) { - $result = array(); - - if (is_object($required)) { - $result = $required->filter($contexts); - } - - return $result; -} - -/** - * Create a select box to choose possible contexts. - * - * This only creates a selector if there is actually a choice; if there - * is only one possible context, that one is silently assigned. - * - * If an array of required contexts is provided, one selector will be - * provided for each context. - * - * @param $contexts - * A keyed array of all available contexts. - * @param $required - * The required context object or array of objects. - * - * @return - * A form element, or NULL if there are no contexts that satisfy the - * requirements. - */ -function ctools_context_selector($contexts, $required, $default) { - if (is_array($required)) { - $result = array('#tree' => TRUE); - $count = 1; - foreach ($required as $id => $r) { - $result[] = _ctools_context_selector($contexts, $r, isset($default[$id]) ? $default[$id] : '', $count++); - } - return $result; - } - - return _ctools_context_selector($contexts, $required, $default); -} - -function _ctools_context_selector($contexts, $required, $default, $num = 0) { - $filtered = ctools_context_filter($contexts, $required); - $count = count($filtered); - - $form = array(); - - if ($count >= 1) { - // If there's more than one to choose from, create a select widget. - foreach ($filtered as $cid => $context) { - $options[$cid] = $context->get_identifier(); - } - if (!empty($required->title)) { - $title = $required->title; - } - else { - $title = $num ? t('Context %count', array('%count' => $num)) : t('Context'); - } - - return array( - '#type' => 'select', - '#options' => $options, - '#title' => $title, - '#default_value' => $default, - ); - } -} - -/** - * Are there enough contexts for a plugin? - * - * Some plugins can have a 'required contexts' item which can either - * be a context requirement object or an array of them. When contexts - * are required, items that do not have enough contexts should not - * appear. This tests an item to see if it has enough contexts - * to actually appear. - * - * @param $contexts - * A keyed array of all available contexts. - * @param $required - * The required context object or array of objects. - * - * @return - * TRUE if there are enough contexts, FALSE if there are not. - */ -function ctools_context_match_requirements($contexts, $required) { - if (!is_array($required)) { - $required = array($required); - } - - // Get the keys to avoid bugs in PHP 5.0.8 with keys and loops. - // And use it to remove optional contexts. - $keys = array_keys($required); - foreach ($keys as $key) { - if (empty($required[$key]->required)) { - unset($required[$key]); - } - } - - $count = count($required); - return (count(ctools_context_filter($contexts, $required)) >= $count); -} - -/** - * Create a select box to choose possible contexts. - * - * This only creates a selector if there is actually a choice; if there - * is only one possible context, that one is silently assigned. - * - * If an array of required contexts is provided, one selector will be - * provided for each context. - * - * @param $contexts - * A keyed array of all available contexts. - * @param $required - * The required context object or array of objects. - * - * @return - * A form element, or NULL if there are no contexts that satisfy the - * requirements. - */ -function ctools_context_converter_selector($contexts, $required, $default) { - if (is_array($required)) { - $result = array('#tree' => TRUE); - $count = 1; - foreach ($required as $id => $r) { - $result[] = _ctools_context_converter_selector($contexts, $r, isset($default[$id]) ? $default[$id] : '', $count++); - } - return $result; - } - - return _ctools_context_converter_selector($contexts, $required, $default); -} - -function _ctools_context_converter_selector($contexts, $required, $default, $num = 0) { - $filtered = ctools_context_filter($contexts, $required); - $count = count($filtered); - - $form = array(); - - if ($count > 1) { - // If there's more than one to choose from, create a select widget. - $options = array(); - foreach ($filtered as $cid => $context) { - if ($context->type == 'any') { - $options[''] = t('No context'); - continue; - } - $key = $context->get_identifier(); - if ($converters = ctools_context_get_converters($cid . '.', $context)) { - $options[$key] = $converters; - } - } - if (empty($options)) { - return array( - '#type' => 'value', - '#value' => 'any', - ); - } - if (!empty($required->title)) { - $title = $required->title; - } - else { - $title = $num ? t('Context %count', array('%count' => $num)) : t('Context'); - } - - return array( - '#type' => 'select', - '#options' => $options, - '#title' => $title, - '#description' => t('Please choose which context and how you would like it converted.'), - '#default_value' => $default, - ); - } -} - -/** - * Get a list of converters available for a given context. - */ -function ctools_context_get_converters($cid, $context) { - if (empty($context->plugin)) { - return array(); - } - - return _ctools_context_get_converters($cid, $context->plugin); -} - -/** - * Get a list of converters available for a given context. - */ -function _ctools_context_get_converters($id, $plugin_name) { - $plugin = ctools_get_context($plugin_name); - if (empty($plugin['convert list'])) { - return array(); - } - - $converters = array(); - if (is_array($plugin['convert list'])) { - $converters = $plugin['convert list']; - } - else if ($function = ctools_plugin_get_function($plugin, 'convert list')) { - $converters = (array) $function($plugin); - } - - foreach (module_implements('ctools_context_convert_list_alter') as $module) { - $function = $module . '_ctools_context_convert_list_alter'; - $function($plugin, $converters); - } - - // Now, change them all to include the plugin: - $return = array(); - foreach ($converters as $key => $title) { - $return[$id . $key] = $title; - } - - natcasesort($return); - return $return; -} - -/** - * Get a list of all contexts + converters available. - */ -function ctools_context_get_all_converters() { - $contexts = ctools_get_contexts(); - $converters = array(); - foreach ($contexts as $name => $context) { - $context_converters = _ctools_context_get_converters($name . '.', $name); - if ($context_converters) { - $converters[$context['title']] = $context_converters; - } - } - - return $converters; -} - -/** - * Let the context convert an argument based upon the converter that was given. - */ -function ctools_context_convert_context($context, $converter) { - // Contexts without plugins might be optional placeholders. - if (empty($context->plugin)) { - return; - } - - $value = $context->argument; - if ($function = ctools_plugin_load_function('ctools', 'contexts', $context->plugin, 'convert')) { - $value = $function($context, $converter); - } - - foreach (module_implements('ctools_context_converter_alter') as $module) { - $function = $module . '_ctools_context_converter_alter'; - $function($context, $converter, $value); - } - - return $value; -} - -/** - * Choose a context or contexts based upon the selection made via - * ctools_context_filter. - * - * @param $contexts - * A keyed array of all available contexts - * @param $required - * The required context object provided by the plugin - * @param $context - * The selection made using ctools_context_selector - */ -function ctools_context_select($contexts, $required, $context) { - if (is_array($required)) { - $result = array(); - foreach ($required as $id => $r) { - if (($result[] = _ctools_context_select($contexts, $r, $context[$id])) === FALSE) { - return FALSE; - } - } - return $result; - } - - return _ctools_context_select($contexts, $required, $context); -} - -function _ctools_context_select($contexts, $required, $context) { - if (!is_object($required)) { - return FALSE; - } - - return $required->select($contexts, $context); -} - -/** - * Create a new context object. - * - * @param $type - * The type of context to create; this loads a plugin. - * @param $data - * The data to put into the context. - * @param $empty - * Whether or not this context is specifically empty. - * @param $conf - * A configuration structure if this context was created via UI. - * - * @return - * A $context or NULL if one could not be created. - */ -function ctools_context_create($type, $data = NULL, $conf = FALSE) { - ctools_include('plugins'); - $plugin = ctools_get_context($type); - if ($function = ctools_plugin_load_function('ctools', 'contexts', $type, 'context')) { - return $function(FALSE, $data, $conf, $plugin); - } -} - -/** - * Create an empty context object. - * - * Empty context objects are primarily used as placeholders in the UI where - * the actual contents of a context object may not be known. It may have - * additional text embedded to give the user clues as to how the context - * is used. - * - * @param $type - * The type of context to create; this loads a plugin. - * - * @return - * A $context or NULL if one could not be created. - */ -function ctools_context_create_empty($type) { - $plugin = ctools_get_context($type); - if ($function = ctools_plugin_get_function($plugin, 'context')) { - $context = $function(TRUE, NULL, FALSE, $plugin); - if (is_object($context)) { - $context->empty = TRUE; - } - - return $context; - } -} - -/** - * Perform keyword and context substitutions. - */ -function ctools_context_keyword_substitute($string, $keywords, $contexts) { - // Ensure a default keyword exists: - $keywords['%%'] = '%'; - - // Match contexts to the base keywords: - $context_keywords = array(); - foreach ($contexts as $context) { - if (isset($context->keyword)) { - $context_keywords[$context->keyword] = $context; - } - } - - // Look for context matches we we only have to convert known matches. - $matches = array(); - if (preg_match_all('/%([a-zA-Z0-9%:_-]+)/us', $string, $matches)) { - foreach ($matches[1] as $keyword) { - // Ignore anything it finds with %%. - if ($keyword[0] == '%') { - continue; - } - - // If the keyword is already set by something passed in, don't try to - // overwrite it. - if (!empty($keywords['%' . $keyword])) { - continue; - } - - // Figure out our keyword and converter, if specified. - if (strpos($keyword, ':')) { - list($context, $converter) = explode(':', $keyword, 2); - } - else { - $context = $keyword; - if (isset($context_keywords[$keyword])) { - $plugin = ctools_get_context($context_keywords[$context]->plugin); - - // Fall back to a default converter, if specified. - if ($plugin && !empty($plugin['convert default'])) { - $converter = $plugin['convert default']; - } - } - } - - if (empty($context_keywords[$context]) || !empty($context_keywords[$context]->empty)) { - $keywords['%' . $keyword] = ''; - } - else if (!empty($converter)) { - $keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter); - } - else { - $keywords['%' . $keyword] = $context_keywords[$keyword]->title; - } - } - } - return strtr($string, $keywords); -} - -/** - * Determine a unique context ID for a context - * - * Often contexts of many different types will be placed into a list. This - * ensures that even though contexts of multiple types may share IDs, they - * are unique in the final list. - */ -function ctools_context_id($context, $type = 'context') { - if (!$context['id']) { - $context['id'] = 1; - } - - return $type . '_' . $context['name'] . '_' . $context['id']; -} - -/** - * Get the next id available given a list of already existing objects. - * - * This finds the next id available for the named object. - * - * @param $objects - * A list of context descriptor objects, i.e, arguments, relationships, contexts, etc. - * @param $name - * The name being used. - */ -function ctools_context_next_id($objects, $name) { - $id = 0; - // Figure out which instance of this argument we're creating - if (!$objects) { - return $id + 1; - } - - foreach ($objects as $object) { - if (isset($object['name']) && $object['name'] == $name) { - if ($object['id'] > $id) { - $id = $object['id']; - } - } - } - - return $id + 1; -} - - -// --------------------------------------------------------------------------- -// Functions related to contexts from arguments. - -/** - * Fetch metadata on a specific argument plugin. - * - * @param $argument - * Name of an argument plugin. - * - * @return - * An array with information about the requested argument plugin. - */ -function ctools_get_argument($argument) { - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'arguments', $argument); -} - -/** - * Fetch metadata for all argument plugins. - * - * @return - * An array of arrays with information about all available argument plugins. - */ -function ctools_get_arguments() { - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'arguments'); -} - -/** - * Get a context from an argument. - * - * @param $argument - * The configuration of an argument. It must contain the following data: - * - name: The name of the argument plugin being used. - * - argument_settings: The configuration based upon the plugin forms. - * - identifier: The human readable identifier for this argument, usually - * defined by the UI. - * - keyword: The keyword used for this argument for substitutions. - * - * @param $arg - * The actual argument received. This is expected to be a string from a URL but - * this does not have to be the only source of arguments. - * @param $empty - * If true, the $arg will not be used to load the context. Instead, an empty - * placeholder context will be loaded. - * - * @return - * A context object if one can be loaded. - */ -function ctools_context_get_context_from_argument($argument, $arg, $empty = FALSE) { - ctools_include('plugins'); - if (empty($argument['name'])) { - return; - } - - if ($function = ctools_plugin_load_function('ctools', 'arguments', $argument['name'], 'context')) { - // Backward compatibility: Merge old style settings into new style: - if (!empty($argument['settings'])) { - $argument += $argument['settings']; - unset($argument['settings']); - } - - $context = $function($arg, $argument, $empty); - - if (is_object($context)) { - $context->identifier = $argument['identifier']; - $context->page_title = isset($argument['title']) ? $argument['title'] : ''; - $context->keyword = $argument['keyword']; - $context->id = ctools_context_id($argument, 'argument'); - $context->original_argument = $arg; - - if (!empty($context->empty)) { - $context->placeholder = array( - 'type' => 'argument', - 'conf' => $argument, - ); - } - } - return $context; - } -} - -/** - * Retrieve a list of empty contexts for all arguments. - */ -function ctools_context_get_placeholders_from_argument($arguments) { - $contexts = array(); - foreach ($arguments as $argument) { - $context = ctools_context_get_context_from_argument($argument, NULL, TRUE); - if ($context) { - $contexts[ctools_context_id($argument, 'argument')] = $context; - } - } - return $contexts; -} - -/** - * Load the contexts for a given list of arguments. - * - * @param $arguments - * The array of argument definitions. - * @param &$contexts - * The array of existing contexts. New contexts will be added to this array. - * @param $args - * The arguments to load. - * - * @return - * FALSE if an argument wants to 404. - */ -function ctools_context_get_context_from_arguments($arguments, &$contexts, $args) { - foreach ($arguments as $argument) { - // pull the argument off the list. - $arg = array_shift($args); - $id = ctools_context_id($argument, 'argument'); - - // For % arguments embedded in the URL, our context is already loaded. - // There is no need to go and load it again. - if (empty($contexts[$id])) { - if ($context = ctools_context_get_context_from_argument($argument, $arg)) { - $contexts[$id] = $context; - } - } - else { - $context = $contexts[$id]; - } - - if ((empty($context) || empty($context->data)) && !empty($argument['default']) && $argument['default'] == '404') { - return FALSE; - } - } - return TRUE; -} - -// --------------------------------------------------------------------------- -// Functions related to contexts from relationships. - -/** - * Fetch metadata on a specific relationship plugin. - * - * @param $content type - * Name of a panel content type. - * - * @return - * An array with information about the requested relationship. - */ -function ctools_get_relationship($relationship) { - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'relationships', $relationship); -} - -/** - * Fetch metadata for all relationship plugins. - * - * @return - * An array of arrays with information about all available relationships. - */ -function ctools_get_relationships() { - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'relationships'); -} - -/** - * - * @param $relationship - * The configuration of a relationship. It must contain the following data: - * - name: The name of the relationship plugin being used. - * - relationship_settings: The configuration based upon the plugin forms. - * - identifier: The human readable identifier for this relationship, usually - * defined by the UI. - * - keyword: The keyword used for this relationship for substitutions. - * - * @param $source_context - * The context this relationship is based upon. - * - * @param $placeholders - * If TRUE, placeholders are acceptable. - * - * @return - * A context object if one can be loaded. - */ -function ctools_context_get_context_from_relationship($relationship, $source_context, $placeholders = FALSE) { - ctools_include('plugins'); - if ($function = ctools_plugin_load_function('ctools', 'relationships', $relationship['name'], 'context')) { - // Backward compatibility: Merge old style settings into new style: - if (!empty($relationship['relationship_settings'])) { - $relationship += $relationship['relationship_settings']; - unset($relationship['relationship_settings']); - } - - $context = $function($source_context, $relationship, $placeholders); - if ($context) { - $context->identifier = $relationship['identifier']; - $context->page_title = isset($relationship['title']) ? $relationship['title'] : ''; - $context->keyword = $relationship['keyword']; - if (!empty($context->empty)) { - $context->placeholder = array( - 'type' => 'relationship', - 'conf' => $relationship, - ); - } - return $context; - } - } -} - -/** - * Fetch all relevant relationships. - * - * Relevant relationships are any relationship that can be created based upon - * the list of existing contexts. For example, the 'node author' relationship - * is relevant if there is a 'node' context, but makes no sense if there is - * not one. - * - * @param $contexts - * An array of contexts used to figure out which relationships are relevant. - * - * @return - * An array of relationship keys that are relevant for the given set of - * contexts. - */ -function ctools_context_get_relevant_relationships($contexts) { - $relevant = array(); - $relationships = ctools_get_relationships(); - - // Go through each relationship - foreach ($relationships as $rid => $relationship) { - // For each relationship, see if there is a context that satisfies it. - if (ctools_context_filter($contexts, $relationship['required context'])) { - $relevant[$rid] = $relationship['title']; - } - } - - return $relevant; -} - -/** - * Fetch all active relationships - * - * @param $relationships - * An keyed array of relationship data including: - * - name: name of relationship - * - context: context id relationship belongs to. This will be used to - * identify which context in the $contexts array to use to create the - * relationship context. - * - * @param $contexts - * A keyed array of contexts used to figure out which relationships - * are relevant. New contexts will be added to this. - * - * @param $placeholders - * If TRUE, placeholders are acceptable. - */ -function ctools_context_get_context_from_relationships($relationships, &$contexts, $placeholders = FALSE) { - $return = array(); - - foreach ($relationships as $rdata) { - if (!isset($rdata['context'])) { - continue; - } - - if (is_array($rdata['context'])) { - $rcontexts = array(); - foreach ($rdata['context'] as $cid) { - if (empty($contexts[$cid])) { - continue 2; - } - $rcontexts[] = $contexts[$cid]; - } - } - else { - if (empty($contexts[$rdata['context']])) { - continue; - } - $rcontexts = $contexts[$rdata['context']]; - } - - $cid = ctools_context_id($rdata, 'relationship'); - if ($context = ctools_context_get_context_from_relationship($rdata, $rcontexts)) { - $contexts[$cid] = $context; - } - } -} - -// --------------------------------------------------------------------------- -// Functions related to loading contexts from simple context definitions. - -/** - * Fetch metadata on a specific context plugin. - * - * @param $context - * Name of a context. - * - * @return - * An array with information about the requested panel context. - */ -function ctools_get_context($context) { - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'contexts', $context); -} - -/** - * Fetch metadata for all context plugins. - * - * @return - * An array of arrays with information about all available panel contexts. - */ -function ctools_get_contexts() { - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'contexts'); -} - -/** - * - * @param $context - * The configuration of a context. It must contain the following data: - * - name: The name of the context plugin being used. - * - context_settings: The configuration based upon the plugin forms. - * - identifier: The human readable identifier for this context, usually - * defined by the UI. - * - keyword: The keyword used for this context for substitutions. - * @param $type - * This is either 'context' which indicates the context will be loaded - * from data in the settings, or 'required_context' which means the - * context must be acquired from an external source. This is the method - * used to pass pure contexts from one system to another. - * - * @return - * A context object if one can be loaded. - */ -function ctools_context_get_context_from_context($context, $type = 'context', $argument = NULL) { - ctools_include('plugins'); - $plugin = ctools_get_context($context['name']); - if ($function = ctools_plugin_get_function($plugin, 'context')) { - // Backward compatibility: Merge old style settings into new style: - if (!empty($context['context_settings'])) { - $context += $context['context_settings']; - unset($context['context_settings']); - } - - if (isset($argument) && isset($plugin['placeholder name'])) { - $context[$plugin['placeholder name']] = $argument; - } - - $return = $function($type == 'requiredcontext', $context, TRUE, $plugin); - if ($return) { - $return->identifier = $context['identifier']; - $return->page_title = isset($context['title']) ? $context['title'] : ''; - $return->keyword = $context['keyword']; - - if (!empty($context->empty)) { - $context->placeholder = array( - 'type' => 'context', - 'conf' => $context, - ); - } - - return $return; - } - } -} - -/** - * Retrieve a list of base contexts based upon a simple 'contexts' definition. - * - * For required contexts this will always retrieve placeholders. - * - * @param $contexts - * The list of contexts defined in the UI. - * @param $type - * Either 'context' or 'requiredcontext', which indicates whether the contexts - * are loaded from internal data or copied from an external source. - * @param $placeholders - * If true, placeholders are acceptable. - */ -function ctools_context_get_context_from_contexts($contexts, $type = 'context', $placeholders = FALSE) { - $return = array(); - foreach ($contexts as $context) { - $ctext = ctools_context_get_context_from_context($context, $type); - if ($ctext) { - if ($placeholders) { - $ctext->placeholder = TRUE; - } - $return[ctools_context_id($context, $type)] = $ctext; - } - } - return $return; -} - -/** - * Match up external contexts to our required contexts. - * - * This function is used to create a list of contexts with proper - * IDs based upon a list of required contexts. - * - * These contexts passed in should match the numeric positions of the - * required contexts. The caller must ensure this has already happened - * correctly as this function will not detect errors here. - * - * @param $required - * A list of required contexts as defined by the UI. - * @param $contexts - * A list of matching contexts as passed in from the calling system. - */ -function ctools_context_match_required_contexts($required, $contexts) { - $return = array(); - if (!is_array($required)) { - return $return; - } - - foreach ($required as $r) { - $context = drupal_clone(array_shift($contexts)); - $context->identifier = $r['identifier']; - $context->page_title = isset($r['title']) ? $r['title'] : ''; - $context->keyword = $r['keyword']; - $return[ctools_context_id($r, 'requiredcontext')] = $context; - } - - return $return; -} - -/** - * Load a full array of contexts for an object. - * - * Not all of the types need to be supported by this object. - * - * This function is not used to load contexts from external data, but may - * be used to load internal contexts and relationships. Otherwise it can also - * be used to generate a full set of placeholders for UI purposes. - * - * @param $object - * An object that contains some or all of the following variables: - * - * - requiredcontexts: A list of UI configured contexts that are required - * from an external source. Since these require external data, they will - * only be added if $placeholders is set to TRUE, and empty contexts will - * be created. - * - arguments: A list of UI configured arguments that will create contexts. - * Since these require external data, they will only be added if $placeholders - * is set to TRUE. - * - contexts: A list of UI configured contexts that have no external source, - * and are essentially hardcoded. For example, these might configure a - * particular node or a particular taxonomy term. - * - relationships: A list of UI configured contexts to be derived from other - * contexts that already exist from other sources. For example, these might - * be used to get a user object from a node via the node author relationship. - * @param $placeholders - * If TRUE, this will generate placeholder objects for types this function - * cannot load. - * @param $contexts - * An array of pre-existing contexts that will be part of the return value. - */ -function ctools_context_load_contexts($object, $placeholders = TRUE, $contexts = array()) { - if (!empty($object->base_contexts)) { - $contexts += $object->base_contexts; - } - - if ($placeholders) { - // This will load empty contexts as placeholders for arguments that come - // from external sources. If this isn't set, it's assumed these context - // will already have been matched up and loaded. - if (!empty($object->requiredcontexts) && is_array($object->requiredcontexts)) { - $contexts += ctools_context_get_context_from_contexts($object->requiredcontexts, 'requiredcontext', $placeholders); - } - - if (!empty($object->arguments) && is_array($object->arguments)) { - $contexts += ctools_context_get_placeholders_from_argument($object->arguments); - } - } - - if (!empty($object->contexts) && is_array($object->contexts)) { - $contexts += ctools_context_get_context_from_contexts($object->contexts, 'context', $placeholders); - } - - // add contexts from relationships - if (!empty($object->relationships) && is_array($object->relationships)) { - ctools_context_get_context_from_relationships($object->relationships, $contexts, $placeholders); - } - - return $contexts; -} - -/** - * Return the first context with a form id from a list of contexts. - * - * This function is used to figure out which contexts represents 'the form' - * from a list of contexts. Only one contexts can actually be 'the form' for - * a given page, since the @code{
} tag can not be embedded within - * itself. - */ -function ctools_context_get_form($contexts) { - if (!empty($contexts)) { - foreach ($contexts as $id => $context) { - // if a form shows its id as being a 'required context' that means the - // the context is external to this display and does not count. - if (!empty($context->form_id) && substr($id, 0, 15) != 'requiredcontext') { - return $context; - } - } - } -} - -/** - * Replace placeholders with real contexts using data extracted from a form - * for the purposes of previews. - * - * @param $contexts - * All of the contexts, including the placeholders. - * @param $arguments - * The arguments. These will be acquired from $form_state['values'] and the - * keys must match the context IDs. - * - * @return - * A new $contexts array containing the replaced contexts. Not all contexts - * may be replaced if, for example, an argument was unable to be converted - * into a context. - */ -function ctools_context_replace_placeholders($contexts, $arguments) { - foreach ($contexts as $cid => $context) { - if (empty($context->empty)) { - continue; - } - - $new_context = NULL; - switch ($context->placeholder['type']) { - case 'relationship': - $relationship = $context->placeholder['conf']; - if (isset($contexts[$relationship['context']])) { - $new_context = ctools_context_get_context_from_relationship($relationship, $contexts[$relationship['context']]); - } - break; - case 'argument': - if (isset($arguments[$cid]) && $arguments[$cid] !== '') { - $argument = $context->placeholder['conf']; - $new_context = ctools_context_get_context_from_argument($argument, $arguments[$cid]); - } - break; - case 'context': - if (!empty($arguments[$cid])) { - $context_info = $context->placeholder['conf']; - $new_context = ctools_context_get_context_from_context($context_info, 'requiredcontext', $arguments[$cid]); - } - break; - } - - if ($new_context && empty($new_context->empty)) { - $contexts[$cid] = $new_context; - } - } - - return $contexts; -} - -/** - * Provide a form array for getting data to replace placeholder contexts - * with real data. - */ -function ctools_context_replace_form($form, $contexts) { - foreach ($contexts as $cid => $context) { - if (empty($context->empty)) { - continue; - } - - // Get plugin info from the context which should have been set when the - // empty context was created. - $info = NULL; - $plugin = NULL; - $settings = NULL; - switch ($context->placeholder['type']) { - case 'argument': - $info = $context->placeholder['conf']; - $plugin = ctools_get_argument($info['name']); - break; - - case 'context': - $info = $context->placeholder['conf']; - $plugin = ctools_get_context($info['name']); - break; - } - - // Ask the plugin where the form is. - if ($plugin && isset($plugin['placeholder form'])) { - if (is_array($plugin['placeholder form'])) { - $form[$cid] = $plugin['placeholder form']; - } - else if (function_exists($plugin['placeholder form'])) { - $widget = $plugin['placeholder form']($info); - if ($widget) { - $form[$cid] = $widget; - } - } - - if (!empty($form[$cid])) { - $form[$cid]['#title'] = t('@identifier (@keyword)', array('@keyword' => '%' . $context->keyword, '@identifier' => $context->identifier)); - } - } - } -} - -// --------------------------------------------------------------------------- -// Functions related to loading access control plugins - -/** - * Fetch metadata on a specific access control plugin. - * - * @param $name - * Name of a plugin. - * - * @return - * An array with information about the requested access control plugin. - */ -function ctools_get_access_plugin($name) { - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'access', $name); -} - -/** - * Fetch metadata for all access control plugins. - * - * @return - * An array of arrays with information about all available access control plugins. - */ -function ctools_get_access_plugins() { - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'access'); -} - -/** - * Fetch a list of access plugins that are available for a given list of - * contexts. - * - * if 'logged-in-user' is not in the list of contexts, it will be added as - * this is required. - */ -function ctools_get_relevant_access_plugins($contexts) { - if (!isset($contexts['logged-in-user'])) { - $contexts['logged-in-user'] = ctools_access_get_loggedin_context(); - } - - $all_plugins = ctools_get_access_plugins(); - $plugins = array(); - foreach ($all_plugins as $id => $plugin) { - if (!empty($plugin['required context']) && !ctools_context_match_requirements($contexts, $plugin['required context'])) { - continue; - } - $plugins[$id] = $plugin; - } - - return $plugins; -} - -/** - * Create a context for the logged in user. - */ -function ctools_access_get_loggedin_context() { - global $user; - $context = ctools_context_create('entity:user', $user); - $context->identifier = t('Logged in user'); - $context->keyword = 'viewer'; - $context->id = 0; - - return $context; -} - -/** - * Get a summary of an access plugin's settings. - */ -function ctools_access_summary($plugin, $contexts, $test) { - if (!isset($contexts['logged-in-user'])) { - $contexts['logged-in-user'] = ctools_access_get_loggedin_context(); - } - - $description = ''; - if ($function = ctools_plugin_get_function($plugin, 'summary')) { - $required_context = isset($plugin['required context']) ? $plugin['required context'] : array(); - $context = isset($test['context']) ? $test['context'] : array(); - $description = $function($test['settings'], ctools_context_select($contexts, $required_context, $context), $plugin); - } - - if (!empty($test['not'])) { - $description = "NOT ($description)"; - } - - return $description; -} - -/** - * Get a summary of a group of access plugin's settings. - */ -function ctools_access_group_summary($access, $contexts) { - if (empty($access['plugins'])) { - return; - } - - $descriptions = array(); - foreach ($access['plugins'] as $id => $test) { - $plugin = ctools_get_access_plugin($test['name']); - $descriptions[] = ctools_access_summary($plugin, $contexts, $test); - } - - $separator = $access['logic'] == 'and' ? t(', and ') : t(', or '); - return implode($separator, $descriptions); -} - -/** - * Determine if the current user has access via plugin. - * - * @param $settings - * An array of settings theoretically set by the user. - * @param $contexts - * An array of zero or more contexts that may be used to determine if - * the user has access. - * - * @return - * TRUE if access is granted, false if otherwise. - */ -function ctools_access($settings, $contexts = array()) { - if (empty($settings['plugins'])) { - return TRUE; - } - - if (!isset($settings['logic'])) { - $settings['logic'] = 'and'; - } - - if (!isset($contexts['logged-in-user'])) { - $contexts['logged-in-user'] = ctools_access_get_loggedin_context(); - } - - foreach ($settings['plugins'] as $test) { - $pass = FALSE; - $plugin = ctools_get_access_plugin($test['name']); - if ($plugin && $function = ctools_plugin_get_function($plugin, 'callback')) { - // Do we need just some contexts or all of them? - if (!empty($plugin['all contexts'])) { - $test_contexts = $contexts; - } - else { - $required_context = isset($plugin['required context']) ? $plugin['required context'] : array(); - $context = isset($test['context']) ? $test['context'] : array(); - $test_contexts = ctools_context_select($contexts, $required_context, $context); - } - - $pass = $function($test['settings'], $test_contexts, $plugin); - if (!empty($test['not'])) { - $pass = !$pass; - } - } - - if ($pass && $settings['logic'] == 'or') { - // Pass if 'or' and this rule passed. - return TRUE; - } - else if (!$pass && $settings['logic'] == 'and') { - // Fail if 'and' and htis rule failed. - return FALSE; - } - } - - // Return TRUE if logic was and, meaning all rules passed. - // Return FALSE if logic was or, meaning no rule passed. - return $settings['logic'] == 'and'; -} - -/** - * Create default settings for a new access plugin. - * - * @param $plugin - * The access plugin being used. - * - * @return - * A default configured test that should be placed in $access['plugins']; - */ -function ctools_access_new_test($plugin) { - $test = array( - 'name' => $plugin['name'], - 'settings' => array(), - ); - - // Set up required context defaults. - if (isset($plugin['required context'])) { - if (is_object($plugin['required context'])) { - $test['context'] = ''; - } - else { - $test['context'] = array(); - foreach ($plugin['required context'] as $required) { - $test['context'][] = ''; - } - } - } - - - $default = NULL; - if (isset($plugin['default'])) { - $default = $plugin['default']; - } - elseif (isset($plugin['defaults'])) { - $default = $plugin['defaults']; - } - - // Setup plugin defaults. - if (isset($default)) { - if (is_array($default)) { - $test['settings'] = $default; - } - else if (function_exists($default)) { - $test['settings'] = $default(); - } - else { - $test['settings'] = array(); - } - } - - return $test; -} - -/** - * Apply restrictions to contexts based upon the access control configured. - * - * These restrictions allow the UI to not show content that may not - * be relevant to all types of a particular context. - */ -function ctools_access_add_restrictions($settings, $contexts) { - if (empty($settings['plugins'])) { - return; - } - - if (!isset($settings['logic'])) { - $settings['logic'] = 'and'; - } - - // We're not going to try to figure out restrictions on the or. - if ($settings['logic'] == 'or' && count($settings['plugins']) > 1) { - return; - } - - foreach ($settings['plugins'] as $test) { - $plugin = ctools_get_access_plugin($test['name']); - if ($plugin && $function = ctools_plugin_get_function($plugin, 'restrictions')) { - $required_context = isset($plugin['required context']) ? $plugin['required context'] : array(); - $context = isset($test['context']) ? $test['context'] : array(); - $contexts = ctools_context_select($contexts, $required_context, $context); - $function($test['settings'], $contexts); - } - } -} diff --git a/includes/context.menu.inc b/includes/context.menu.inc deleted file mode 100644 index 3cba932..0000000 --- a/includes/context.menu.inc +++ /dev/null @@ -1,39 +0,0 @@ - array('access content'), - 'type' => MENU_CALLBACK, - 'file' => 'includes/context-admin.inc', - ); - $items['ctools/context/ajax/add'] = array( - 'page callback' => 'ctools_context_ajax_item_add', - ) + $base; - $items['ctools/context/ajax/configure'] = array( - 'page callback' => 'ctools_context_ajax_item_edit', - ) + $base; - $items['ctools/context/ajax/delete'] = array( - 'page callback' => 'ctools_context_ajax_item_delete', - ) + $base; - - // For the access system - $base['file'] = 'includes/context-access-admin.inc'; - $items['ctools/context/ajax/access/add'] = array( - 'page callback' => 'ctools_access_ajax_add', - ) + $base; - $items['ctools/context/ajax/access/configure'] = array( - 'page callback' => 'ctools_access_ajax_edit', - ) + $base; - $items['ctools/context/ajax/access/delete'] = array( - 'page callback' => 'ctools_access_ajax_delete', - ) + $base; - -} diff --git a/includes/context.plugin-type.inc b/includes/context.plugin-type.inc deleted file mode 100644 index 866def2..0000000 --- a/includes/context.plugin-type.inc +++ /dev/null @@ -1,24 +0,0 @@ - TRUE, - ); - $items['arguments'] = array( - 'child plugins' => TRUE, - ); - $items['relationships'] = array( - 'child plugins' => TRUE, - ); - $items['access'] = array( - 'child plugins' => TRUE, - ); -} diff --git a/includes/context.theme.inc b/includes/context.theme.inc deleted file mode 100644 index 8f660b8..0000000 --- a/includes/context.theme.inc +++ /dev/null @@ -1,344 +0,0 @@ - array('object' => NULL), - 'file' => 'includes/context.theme.inc', - ); - $theme['ctools_context_list_no_table'] = array( - 'variables' => array('object' => NULL), - 'file' => 'includes/context.theme.inc', - ); - $theme['ctools_context_item_form'] = array( - 'render element' => 'form', -// 'variables' => array('form' => NULL), - 'file' => 'includes/context.theme.inc', - ); - $theme['ctools_context_item_row'] = array( - 'variables' => array('type' => NULL, 'form' => NULL, 'position' => NULL, 'count' => NULL, 'with_tr' => TRUE), - 'file' => 'includes/context.theme.inc', - ); - - // For the access plugin - $theme['ctools_access_admin_add'] = array( - 'render element' => 'form', - 'file' => 'includes/context-access-admin.inc', - ); -} - -/** - * Theme the form item for the context entry. - */ -function theme_ctools_context_item_row($vars) { - $type = $vars['type']; - $form = $vars['form']; - $position = $vars['position']; - $count = $vars['count']; - $with_tr = $vars['with_tr']; - $output = ' ' . render($form['title']) . ''; - if (!empty($form['position'])) { - $output .= ' ' . render($form['position']) . ''; - } - $output .= '' . render($form['settings']); - $output .= render($form['remove']) . ''; - - if ($with_tr) { - $output = '' . $output . ''; - } - return $output; -} - -/** - * Display the context item. - */ -function theme_ctools_context_item_form($vars) { - $form = $vars['form']; - - $output = ''; - $type = $form['#ctools_context_type']; - $module = $form['#ctools_context_module']; - $cache_key = $form['#cache_key']; - - $type_info = ctools_context_info($type); - - if (!empty($form[$type]) && empty($form['#only_buttons'])) { - $count = 0; - $rows = ''; - foreach (array_keys($form[$type]) as $id) { - if (!is_numeric($id)) { - continue; - } - $theme_vars = array(); - $theme_vars['type'] = $type; - $theme_vars['form'] = $form[$type][$id]; - $theme_vars['position'] = $id; - $theme_vars['count'] = $count++; - $rows .= theme('ctools_context_item_row', $theme_vars); - } - - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - if (!empty($type_info['sortable']) && $count) { - $output .= ''; - } - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - - $output .= $rows; - - $output .= ''; - $output .= '
' . $type_info['title'] . '' . t('Weight') . '' . t('Operation') . '
'; - } - - if (!empty($form['buttons'])) { - // Display the add context item. - $row = array(); - $row[] = array('data' => render($form['buttons'][$type]['item']), 'class' => array('title')); - $row[] = array('data' => render($form['buttons'][$type]['add']), 'class' => array('add'), 'width' => "60%"); - $output .= '
'; - $output .= render($form['buttons'][$type]); - $theme_vars = array(); - $theme_vars['header'] = array(); - $theme_vars['rows'] = array($row); - $theme_vars['attributes'] = array('id' => $type . '-add-table'); - $output .= theme('table', $theme_vars); - $output .= '
'; - } - if (!empty($form['description'])) { - $output .= render($form['description']); - } - - if (!empty($type_info['sortable'])) { - drupal_add_tabledrag($type . '-table', 'order', 'sibling', 'drag-position'); - } - - return $output; -} - -/** - * Create a visible list of all the contexts available on an object. - * Assumes arguments, relationships and context objects. - * - * Contexts must be preloaded. - */ -function theme_ctools_context_list($vars) { - $object = $vars['object']; - $header = $vars['header']; - $description = (!empty($vars['description'])) ? $vars['description'] : NULL; - $titles = array(); - $output = ''; - $count = 1; - - $contexts = ctools_context_load_contexts($object); - - // Describe 'built in' contexts. - if (!empty($object->base_contexts)) { - foreach ($object->base_contexts as $id => $context) { - $output .= ''; - $output .= '' . t('Built in context') . ''; - $desc = check_plain($context->identifier); - if (isset($context->keyword)) { - $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $context->keyword)); - foreach (ctools_context_get_converters('%' . $context->keyword . ':', $context) as $keyword => $title) { - $desc .= '
' . t('@keyword --> @title', array('@keyword' => $keyword, '@title' => $title)); - } - $desc .= '
'; - - } - if (isset($context->description)) { - $desc .= '
' . filter_xss_admin($context->description) . '
'; - } - $output .= '' . $desc . ''; - $output .= ''; - $titles[$id] = $context->identifier; - } - } - - // First, make a list of arguments. Arguments are pretty simple. - if (!empty($object->arguments)) { - foreach ($object->arguments as $argument) { - $output .= ''; - $output .= '' . t('Argument @count', array('@count' => $count)) . ''; - $desc = check_plain($argument['identifier']); - if (isset($argument['keyword'])) { - $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $argument['keyword'])); - if (isset($contexts[ctools_context_id($argument, 'argument')])) { - foreach (ctools_context_get_converters('%' . $argument['keyword'] . ':', $contexts[ctools_context_id($argument, 'argument')]) as $keyword => $title) { - $desc .= '
' . t('@keyword --> @title', array('@keyword' => $keyword, '@title' => $title)); - } - } - $desc .= '
'; - } - $output .= '' . $desc . ''; - $output .= ''; - $titles[ctools_context_id($argument, 'argument')] = $argument['identifier']; - $count++; - } - } - - $count = 1; - // Then, make a nice list of contexts. - if (!empty($object->contexts)) { - foreach ($object->contexts as $context) { - $output .= ''; - $output .= '' . t('Context @count', array('@count' => $count)) . ''; - $desc = check_plain($context['identifier']); - if (isset($context['keyword'])) { - $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $context['keyword'])); - foreach (ctools_context_get_converters('%' . $context['keyword'] . ':', $contexts[ctools_context_id($context, 'context')]) as $keyword => $title) { - $desc .= '
' . t('@keyword --> @title', array('@keyword' => $keyword, '@title' => $title)); - } - $desc .= '
'; - } - $output .= '' . $desc . ''; - $output .= ''; - $titles[ctools_context_id($context)] = $context['identifier']; - $count++; - } - } - - // And relationships - if (!empty($object->relationships)) { - foreach ($object->relationships as $relationship) { - $output .= ''; - if (is_array($relationship['context'])) { - $rtitles = array(); - foreach ($relationship['context'] as $cid) { - $rtitles[$cid] = $titles[$cid]; - } - $title = implode(' + ', $rtitles); - } - else { - $title = $titles[$relationship['context']]; - } - $output .= '' . t('From "@title"', array('@title' => $title)) . ''; - $desc = check_plain($relationship['identifier']); - if (isset($relationship['keyword'])) { - $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $relationship['keyword'])); - foreach (ctools_context_get_converters('%' . $relationship['keyword'] . ':', $contexts[ctools_context_id($relationship, 'relationship')]) as $keyword => $title) { - $desc .= '
' . t('@keyword --> @title', array('@keyword' => $keyword, '@title' => $title)); - } - $desc .= '
'; - } - $output .= '' . $desc . ''; - $output .= ''; - $titles[ctools_context_id($relationship, 'relationship')] = $relationship['identifier']; - $count++; - } - } - - $head = ''; - if ($header) { - if ($description) { - $header .= '
' . $description . '
'; - } - $head .= ''; - $head .= '' . $header . ''; - $head .= ''; - } - - return $output ? "$head$output
\n" : "$head
\n"; -} - -/** - * ctools_context_list() but not in a table format because tabledrag - * won't let us have tables within tables and still drag. - */ -function theme_ctools_context_list_no_table($vars) { - $object = $vars['object']; - ctools_add_css('context'); - $titles = array(); - $output = ''; - $count = 1; - // Describe 'built in' contexts. - if (!empty($object->base_contexts)) { - foreach ($object->base_contexts as $id => $context) { - $output .= '
'; - $output .= '
' . t('Built in context') . '
'; - $desc = check_plain($context->identifier); - if (isset($context->keyword)) { - $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $context->keyword)) . '
'; - } - if (isset($context->description)) { - $desc .= '
' . filter_xss_admin($context->description) . '
'; - } - $output .= '
' . $desc . '
'; - $output .= '
'; - $titles[$id] = $context->identifier; - $count++; - } - } - - // First, make a list of arguments. Arguments are pretty simple. - if (!empty($object->arguments)) { - foreach ($object->arguments as $argument) { - $output .= '
'; - $output .= '
' . t('Argument @count', array('@count' => $count)) . '
'; - $desc = check_plain($argument['identifier']); - if (isset($argument['keyword'])) { - $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $argument['keyword'])) . '
'; - } - $output .= '
' . $desc . '
'; - $output .= '
'; - $titles[ctools_context_id($argument, 'argument')] = $argument['identifier']; - $count++; - } - } - $count = 1; - // Then, make a nice list of contexts. - if (!empty($object->contexts)) { - foreach ($object->contexts as $context) { - $output .= '
'; - $output .= '
' . t('Context @count', array('@count' => $count)) . '
'; - $desc = check_plain($context['identifier']); - if (isset($context['keyword'])) { - $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $context['keyword'])) . '
'; - } - $output .= '
' . $desc . '
'; - $output .= '
'; - $titles[ctools_context_id($context)] = $context['identifier']; - $count++; - } - } - // And relationships - if (!empty($object->relationships)) { - foreach ($object->relationships as $relationship) { - $output .= '
'; - if (is_array($relationship['context'])) { - $rtitles = array(); - foreach ($relationship['context'] as $cid) { - $rtitles[$cid] = $titles[$cid]; - } - $title = implode(' + ', $rtitles); - } - else { - $title = $titles[$relationship['context']]; - } - - $output .= '
' . t('From "@title"', array('@title' => $title)) . '
'; - $desc = check_plain($relationship['identifier']); - if (isset($relationship['keyword'])) { - $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $relationship['keyword'])) . '
'; - } - $output .= '
' . $desc . '
'; - $output .= '
'; - $titles[ctools_context_id($relationship, 'relationship')] = $relationship['identifier']; - $count++; - } - } - - return $output; -} - diff --git a/includes/css.inc b/includes/css.inc deleted file mode 100644 index bcb75a2..0000000 --- a/includes/css.inc +++ /dev/null @@ -1,562 +0,0 @@ - $id))->fetchField(); - if ($filename && file_exists($filename)) { - file_unmanaged_delete($filename); - } - // Remove any previous records. - db_delete('ctools_css_cache') - ->condition('cid', $id) - ->execute(); - - $filename = ctools_css_cache($css, $filter); - - db_insert('ctools_css_cache') - ->fields(array( - 'cid' => $id, - 'filename' => $filename, - 'css' => $css, - 'filter' => intval($filter), - )) - ->execute(); - - return $filename; -} - -/** - * Retrieve a filename associated with an id of previously cached CSS. - * - * This will ensure the file still exists and, if not, create it. - */ -function ctools_css_retrieve($id) { - $cache = db_query('SELECT * FROM {ctools_css_cache} WHERE cid = :cid', array(':cid' => $id))->fetchObject(); - if (!$cache) { - return; - } - - if (!file_exists($cache->filename)) { - $filename = ctools_css_cache($cache->css, $cache->filter); - if ($filename != $cache->filename) { - db_update('ctools_css_cache') - ->fields(array('filename' => $filename)) - ->condition('cid', $id) - ->execute(); - $cache->filename = $filename; - } - } - - return $cache->filename; -} - -/** - * Remove stored CSS and any associated file. - */ -function ctools_css_clear($id) { - $cache = db_query('SELECT * FROM {ctools_css_cache} WHERE cid = :cid', array(':cid' => $id))->fetchObject(); - if (!$cache) { - return; - } - - if (file_exists($cache->filename)) { - file_unmanaged_delete($cache->filename); - // If we remove an existing file, there may be cached pages that refer - // to it. We must get rid of them: FIXME same format in D7? - cache_clear_all(); - } - - db_delete('ctools_css_cache') - ->condition('cid', $id) - ->execute(); -} - -/** - * Write a chunk of CSS to a temporary cache file and return the file name. - * - * This function optionally filters the CSS (always compressed, if so) and - * generates a unique filename based upon md5. It returns that filename that - * can be used with drupal_add_css(). Note that as a cache file, technically - * this file is volatile so it should be checked before it is used to ensure - * that it exists. - * - * You can use file_exists() to test for the file and file_delete() to remove - * it if it needs to be cleared. - * - * @param $css - * A chunk of well-formed CSS text to cache. - * @param $filter - * If TRUE the css will be filtered. If FALSE the text will be cached - * as-is. - * - * @return $filename - * The filename the CSS will be cached in. - */ -function ctools_css_cache($css, $filter = TRUE) { - if ($filter) { - $css = ctools_css_filter($css); - } - - // Create the css/ within the files folder. - $path = 'public://ctools/css'; - if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) { -// if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) { - drupal_set_message(t('Unable to create CTools CSS cache directory. Check the permissions on your files directory.'), 'error'); - return; - } - - // @todo Is this slow? Does it matter if it is? - $filename = $path . '/' . md5($css) . '.css'; - - // This will do renames if the file already exists, ensuring we don't - // accidentally overwrite other files who share the same md5. Yes this - // is a very miniscule chance but it's safe. - $filename = file_unmanaged_save_data($css, $filename); - - return $filename; -} - -/** - * Filter a chunk of CSS text. - * - * This function disassembles the CSS into a raw format that makes it easier - * for our tool to work, then runs it through the filter and reassembles it. - * If you find that you want the raw data for some reason or another, you - * can use the disassemble/assemble functions yourself. - * - * @param $css - * The CSS text to filter. - * @param $compressed - * If true, generate compressed output; if false, generate pretty output. - * Defaults to TRUE. - */ -function ctools_css_filter($css, $compressed = TRUE) { - $css_data = ctools_css_disassemble($css); - - // Note: By using this function yourself you can control the allowed - // properties and values list. - $filtered = ctools_css_filter_css_data($css_data); - - return $compressed ? ctools_css_compress($filtered) : ctools_css_assemble($filtered); -} - -/** - * Re-assemble a css string and format it nicely. - * - * @param array $css_data - * An array of css data, as produced by @see ctools_css_disassemble() - * disassembler and the @see ctools_css_filter_css_data() filter. - * - * @return string $css - * css optimized for human viewing. - */ -function ctools_css_assemble($css_data) { - // Initialize the output. - $css = ''; - // Iterate through all the statements. - foreach ($css_data as $selector_str => $declaration) { - // Add the selectors, separating them with commas and line feeds. - $css .= strpos($selector_str, ',') === FALSE ? $selector_str : str_replace(", ", ",\n", $selector_str); - // Add the opening curly brace. - $css .= " {\n"; - // Iterate through all the declarations. - foreach ($declaration as $property => $value) { - $css .= " " . $property . ": " . $value . ";\n"; - } - // Add the closing curly brace. - $css .= "}\n\n"; - } - // Return the output. - return $css; -} - -/** - * Compress css data (filter it first!) to optimize for use on view. - * - * @param array $css_data - * An array of css data, as produced by @see ctools_css_disassemble() - * disassembler and the @see ctools_css_filter_css_data() filter. - * - * @return string $css - * css optimized for use. - */ -function ctools_css_compress($css_data) { - // Initialize the output. - $css = ''; - // Iterate through all the statements. - foreach ($css_data as $selector_str => $declaration) { - if (empty($declaration)) { - // Skip this statement if filtering removed all parts of the declaration. - continue; - } - // Add the selectors, separating them with commas. - $css .= $selector_str; - // And, the opening curly brace. - $css .= "{"; - // Iterate through all the statement properties. - foreach ($declaration as $property => $value) { - $css .= $property . ':' . $value . ';'; - } - // Add the closing curly brace. - $css .= "}"; - } - // Return the output. - return $css; -} - -/** - * Disassemble the css string. - * - * Strip the css of irrelevant characters, invalid/malformed selectors and - * declarations, and otherwise prepare it for processing. - * - * @param string $css - * A string containing the css to be disassembled. - * - * @return array $disassembled_css - * An array of disassembled, slightly cleaned-up/formatted css statements. - */ -function ctools_css_disassemble($css) { - $disassembled_css = array(); - // Remove comments. - $css = preg_replace("/\/\*(.*)?\*\//Usi", "", $css); - // Split out each statement - $statements = explode("}", $css); - // If we have any statements, parse them. - if (!empty($statements)) { - // Iterate through all of the statements. - foreach ($statements as $statement) { - // Get the selector(s) and declaration. - if (empty($statement) || !strpos($statement, '{')) { - continue; - } - - list($selector_str, $declaration) = explode('{', $statement); - - // If the selector exists, then disassemble it, check it, and regenerate - // the selector string. - $selector_str = empty($selector_str) ? FALSE : _ctools_css_disassemble_selector($selector_str); - if (empty($selector_str)) { - // No valid selectors. Bomb out and start the next item. - continue; - } - - // Disassemble the declaration, check it and tuck it into an array. - $disassembled_css[$selector_str] = _ctools_css_disassemble_declaration($declaration); - } - } - return $disassembled_css; -} - -function _ctools_css_disassemble_selector($selector_str) { - // Get all selectors individually. - $selectors = explode(",", trim($selector_str)); - // Iterate through all the selectors, sanity check them and return if they - // pass. Note that this handles 0, 1, or more valid selectors gracefully. - foreach ($selectors as $key => $selector) { - // Replace un-needed characters and do a little cleanup. - $selector = preg_replace("/[\n|\t|\\|\s]+/", ' ', trim($selector)); - // Make sure this is still a real selector after cleanup. - if (!empty($selector)) { - $selectors[$key] = $selector; - } - else { - // Selector is no good, so we scrap it. - unset($selectors[$key]); - } - } - // Check for malformed selectors; if found, we skip this declaration. - if (empty($selectors)) { - return FALSE; - } - return implode(', ', $selectors); -} - -function _ctools_css_disassemble_declaration($declaration) { - $formatted_statement = array(); - $propval_pairs = explode(";", $declaration); - // Make sure we actually have some properties to work with. - if (!empty($propval_pairs)) { - // Iterate through the remains and parse them. - foreach ($propval_pairs as $key => $propval_pair) { - // Check that we have a ':', otherwise it's an invalid pair. - if (strpos($propval_pair, ':') === FALSE) { - continue; - } - // Clean up the current property-value pair. - $propval_pair = preg_replace("/[\n|\t|\\|\s]+/", ' ', trim($propval_pair)); - // Explode the remaining fragements some more, but clean them up first. - list($property, $value) = explode(':', $propval_pair, 2); - // If the property survived, toss it onto the stack. - if (!empty($property)) { - $formatted_statement[trim($property)] = trim($value); - } - } - } - return $formatted_statement; -} - -/** - * Run disassembled $css through the filter. - * - * @param $css - * CSS code disassembled by ctools_dss_disassemble(). - * @param $allowed_properties - * A list of properties that are allowed by the filter. If empty - * ctools_css_filter_default_allowed_properties() will provide the - * list. - * @param $allowed_values - * A list of values that are allowed by the filter. If empty - * ctools_css_filter_default_allowed_values() will provide the - * list. - * - * @return - * An array of disassembled, filtered CSS. - */ -function ctools_css_filter_css_data($css, $allowed_properties = array(), $allowed_values = array(), $allowed_values_regex = '', $disallowed_values_regex = '') { -//function ctools_css_filter_css_data($css, &$filtered = NULL, $allowed_properties = array(), $allowed_values = array(), $allowed_values_regex = '', $disallowed_values_regex = '') { - // Retrieve the default list of allowed properties if none is provided. - $allowed_properties = !empty($allowed_properties) ? $allowed_properties : ctools_css_filter_default_allowed_properties(); - // Retrieve the default list of allowed values if none is provided. - $allowed_values = !empty($allowed_values) ? $allowed_values : ctools_css_filter_default_allowed_values(); - // Define allowed values regex if none is provided. - $allowed_values_regex = !empty($allowed_values_regex) ? $allowed_values_regex : '/(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)/'; - // Define disallowed url() value contents, if none is provided. - // $disallowed_values_regex = !empty($disallowed_values_regex) ? $disallowed_values_regex : '/[url|expression]\s*\(\s*[^\s)]+?\s*\)\s*/'; - $disallowed_values_regex = !empty($disallowed_values_regex) ? $disallowed_values_regex : '/(url|expression)/'; - - foreach ($css as $selector_str => $declaration) { - foreach ($declaration as $property => $value) { - if (!in_array($property, $allowed_properties)) { - // $filtered['properties'][$selector_str][$property] = $value; - unset($css[$selector_str][$property]); - continue; - } - $value = str_replace('!important', '', $value); - if (preg_match($disallowed_values_regex, $value) || !(in_array($value, $allowed_values) || preg_match($allowed_values_regex, $value))) { - // $filtered['values'][$selector_str][$property] = $value; - unset($css[$selector_str][$property]); - continue; - } - } - } - return $css; -} - -/** - * Provide a deafult list of allowed properties by the filter. - */ -function ctools_css_filter_default_allowed_properties() { - return array( - 'azimuth', - 'background', - 'background-color', - 'background-image', - 'background-repeat', - 'background-attachment', - 'background-position', - 'border', - 'border-top-width', - 'border-right-width', - 'border-bottom-width', - 'border-left-width', - 'border-width', - 'border-top-color', - 'border-right-color', - 'border-bottom-color', - 'border-left-color', - 'border-color', - 'border-top-style', - 'border-right-style', - 'border-bottom-style', - 'border-left-style', - 'border-style', - 'border-top', - 'border-right', - 'border-bottom', - 'border-left', - 'clear', - 'color', - 'cursor', - 'direction', - 'display', - 'elevation', - 'float', - 'font', - 'font-family', - 'font-size', - 'font-style', - 'font-variant', - 'font-weight', - 'height', - 'letter-spacing', - 'line-height', - 'margin', - 'margin-top', - 'margin-right', - 'margin-bottom', - 'margin-left', - 'overflow', - 'padding', - 'padding-top', - 'padding-right', - 'padding-bottom', - 'padding-left', - 'pause', - 'pause-after', - 'pause-before', - 'pitch', - 'pitch-range', - 'richness', - 'speak', - 'speak-header', - 'speak-numeral', - 'speak-punctuation', - 'speech-rate', - 'stress', - 'text-align', - 'text-decoration', - 'text-indent', - 'text-transform', - 'unicode-bidi', - 'vertical-align', - 'voice-family', - 'volume', - 'white-space', - 'width', - 'fill', - 'fill-opacity', - 'fill-rule', - 'stroke', - 'stroke-width', - 'stroke-linecap', - 'stroke-linejoin', - 'stroke-opacity', - ); -} - -/** - * Provide a default list of allowed values by the filter. - */ -function ctools_css_filter_default_allowed_values() { - return array( - 'auto', - 'aqua', - 'black', - 'block', - 'blue', - 'bold', - 'both', - 'bottom', - 'brown', - 'capitalize', - 'center', - 'collapse', - 'dashed', - 'dotted', - 'fuchsia', - 'gray', - 'green', - 'italic', - 'inherit', - 'left', - 'lime', - 'lowercase', - 'maroon', - 'medium', - 'navy', - 'normal', - 'nowrap', - 'olive', - 'pointer', - 'purple', - 'red', - 'right', - 'solid', - 'silver', - 'teal', - 'top', - 'transparent', - 'underline', - 'uppercase', - 'white', - 'yellow', - ); -} - -/** - * Delegated implementation of hook_flush_caches() - */ -function ctools_css_flush_caches() { - // Remove all generated files. - // @see http://drupal.org/node/573292 - // file_unmanaged_delete_recursive('public://render'); - $filedir = file_default_scheme() . '://ctools/css'; - file_unmanaged_delete_recursive($filedir); - - db_delete('ctools_css_cache')->execute(); -} diff --git a/includes/dependent.inc b/includes/dependent.inc deleted file mode 100644 index 7212e28..0000000 --- a/includes/dependent.inc +++ /dev/null @@ -1,154 +0,0 @@ - TRUE to the - * fieldset works around that. - * - * For radios, because they are selected a little bit differently, instead of - * using the CSS id, use: radio:NAME where NAME is the #name of the property. - * This can be quickly found by looking at the HTML of the generated form, but - * it is usually derived from the array which contains the item. For example, - * $form['menu']['type'] would have a name of menu[type]. This name is the same - * field that is used to determine where in $form_state['values'] you will find - * the value of the form. - * - * The item that is dependent on, should be set to #tree = TRUE. - * - * Usage: - * - * First, ensure this tool is loaded: - * @code { ctools_include('dependent'); } - * - * On any form item, add - * - @code '#process' => array('ctools_dependent_process'), @endcode - * - @code '#dependency' => array('id-of-form-without-the-#' => array(list, of, values, that, make, this, gadget, visible)), @endcode - * - * A fuller example, that hides the menu title when no menu is selected: - * @code - *function ctools_dependent_example() { - * $form = array(); - * $form['menu'] = array( - * '#type' => 'fieldset', - * '#title' => t('Menu settings'), - * '#tree' => TRUE, - * ); - * $form['menu']['type'] = array( - * '#title' => t('Menu type'), - * '#type' => 'radios', - * '#options' => array( - * 'none' => t('No menu entry'), - * 'normal' => t('Normal menu entry'), - * 'tab' => t('Menu tab'), - * 'default tab' => t('Default menu tab'), - * ), - * '#default_value' => 'none', - * ); - * - * $form['menu']['title'] = array( - * '#title' => t('Title'), - * '#type' => 'textfield', - * '#default_value' => '', - * '#description' => t('If set to normal or tab, enter the text to use for the menu item.'), - * '#process' => array('ctools_dependent_process'), - * '#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')), - * ); - * - * return system_settings_form($form); - *} - * @endcode - * - * An example for hiding checkboxes using #prefix and #suffix: - * @code - *function ctools_dependent_example_checkbox() { - * $form = array(); - * $form['object'] = array( - * '#type' => 'fieldset', - * '#title' => t('Select object type'), - * '#tree' => TRUE, - * ); - * $form['object']['type'] = array( - * '#title' => t('Object type'), - * '#type' => 'radios', - * '#options' => array( - * 'view' => t('View'), - * 'node' => t('Node'), - * 'field' => t('Field'), - * 'term' => t('Term'), - * ), - * '#default_value' => 'view', - * ); - * - * $form['object']['elements'] = array( - * '#title' => t('Select the elements to load from the node.'), - * '#type' => 'checkboxes', - * '#prefix' => '
', - * '#suffix' => '
', - * '#process' => array('ctools_dependent_process', 'expand_checkboxes'), - * '#dependency' => array('radio:menu[type]' => array('node')), - * '#options' => array( - * 'body' => t('Body'), - * 'fields' => t('Fields'), - * 'taxonomy' => t('Taxonomy'), - * ), - * '#default_value' => array('body', 'fields'), - * ); - * - * return system_settings_form($form); - *} - * @endcode - */ - -/** - * Process callback to add dependency to form items. - */ -function ctools_dependent_process($element, &$form_state, &$form) { - if (isset($element['#dependency'])) { - // Don't actually add any javascript until render time. - $element['#pre_render'][] = 'ctools_dependent_pre_render'; - } - - return $element; -} - -function ctools_dependent_pre_render($element) { - if (!isset($element['#dependency_count'])) { - $element['#dependency_count'] = 1; - } - if (!isset($element['#dependency_type'])) { - $element['#dependency_type'] = 'hide'; - } - - $js = array( - 'values' => $element['#dependency'], - 'num' => $element['#dependency_count'], - 'type' => $element['#dependency_type'], - ); - - ctools_add_js('dependent'); - $options['CTools']['dependent'][$element['#id']] = $js; - drupal_add_js($options, 'setting'); - - return $element; -} diff --git a/includes/dropdown.theme.inc b/includes/dropdown.theme.inc deleted file mode 100644 index 2e21559..0000000 --- a/includes/dropdown.theme.inc +++ /dev/null @@ -1,87 +0,0 @@ - .5 seconds, or can be immediately closed by - * clicking the link again. The code is smart enough that if the mouse - * moves away and then back within the .5 second window, it will not - * re-close. - * - * Multiple dropdowns can be placed per page. - * - * If the user does not have javascript enabled, the link will not appear, - * and instead by default the list of links will appear as a normal inline - * list. - * - * The menu is heavily styled by default, and to make it look different - * will require a little bit of CSS. You can apply your own class to the - * dropdown to help ensure that your CSS can override the dropdown's CSS. - * - * In particular, the text, link, background and border colors may need to - * be changed. Please see dropdown.css for information about the existing - * styling. - */ - -/** - * Delegated implementation of hook_theme() - */ -function ctools_dropdown_theme(&$items) { - $items['ctools_dropdown'] = array( - 'variables' => array('title' => NULL, 'links' => NULL, 'image' => FALSE, 'class' => ''), - 'file' => 'includes/dropdown.theme.inc', - ); -} - -/** - * Create a dropdown menu. - * - * @param $title - * The text to place in the clickable area to activate the dropdown. - * @param $links - * A list of links to provide within the dropdown, suitable for use - * in via Drupal's theme('links'). - * @param $image - * If true, the dropdown link is an image and will not get extra decorations - * that a text dropdown link will. - * @param $class - * An optional class to add to the dropdown's container div to allow you - * to style a single dropdown however you like without interfering with - * other dropdowns. - */ -function theme_ctools_dropdown($vars) { - // Provide a unique identifier for every dropdown on the page. - static $id = 0; - $id++; - - $class = 'ctools-dropdown-no-js ctools-dropdown' . ($vars['class'] ? (' ' . $vars['class']) : ''); - - ctools_add_js('dropdown'); - ctools_add_css('dropdown'); - - $output = ''; - - $output .= '
'; - $output .= ''; // wrapper - $output .= '
'; - $output .= '
'; - $output .= theme_links(array('links' => $vars['links'], 'attributes' => array(), 'heading' => '')); - $output .= '
'; // container - $output .= '
'; // container wrapper - $output .= '
'; // dropdown - return $output; -} - diff --git a/includes/export-ui.inc b/includes/export-ui.inc deleted file mode 100644 index 0987a15..0000000 --- a/includes/export-ui.inc +++ /dev/null @@ -1,466 +0,0 @@ - TRUE, - 'title' => $plugin['name'], - 'export' => array(), - 'allowed operations' => array(), - 'menu' => array(), - 'form' => array(), - 'strings' => array(), - 'list' => NULL, - 'access' => 'administer site configuration', - ); - - // Provide CRUD access defaults based on the base 'access' setting: - $plugin += array( - 'create access' => $plugin['access'], - 'delete access' => $plugin['access'], - ); - - if (empty($plugin['has menu'])) { - return; - } - - // The following keys are required and the plugin cannot be processed - // without them. - $keys = array( - 'title singular', - 'title plural', - 'title singular proper', - 'title plural proper', - 'schema', - ); - - foreach ($keys as $key) { - if (empty($plugin[$key])) { - drupal_set_message(t('The plugin definition of @plugin is missing the %key key.', array('%key' => $key, '@plugin' => $plugin['name'])), 'error'); - } - } - - // If we're on the modules page and building a menu, there is a design flaw - // in Drupal core that causes modules to be installed but the schema does - // not become available until AFTER menu rebuild. This helps smooth that - // out. This is a HACK but it should work: - $schema = ctools_export_get_schema($plugin['schema']); - - if (empty($schema)) { - // If we're updating the schema may not have been read yet, so don't report this error in that case. - if (!defined('MAINTENANCE_MODE')) { - drupal_set_message(t('The plugin definition of @plugin cannot locate schema %schema.', array('%schema' => $plugin['schema'], '@plugin' => $plugin['name'])), 'error'); - } - return; - } - - if (empty($schema['export'])) { - drupal_set_message(t('The plugin definition of @plugin uses %schema, but it has no export section.', array('%schema' => $plugin['schema'], '@plugin' => $plugin['name'])), 'error'); - return; - } - - $plugin['export'] += array( - // Add the identifier key from the schema so we don't have to call - // ctools_export_get_schema() just for that. - 'key' => $schema['export']['key'], - ); - - // Add some default fields that appear often in exports - // If these use different keys they can easily be specified in the - // $plugin. - - if (empty($plugin['export']['admin_title']) && !empty($schema['fields']['admin_title'])) { - $plugin['export']['admin_title'] = 'admin_title'; - } - if (empty($plugin['export']['admin_description']) && !empty($schema['fields']['admin_description'])) { - $plugin['export']['admin_description'] = 'admin_description'; - } - - // Define allowed operations, and the name of the operations. - $plugin['allowed operations'] += array( - 'edit' => array('title' => t('Edit')), - 'enable' => array('title' => t('Enable'), 'ajax' => TRUE, 'token' => TRUE), - 'disable' => array('title' => t('Disable'), 'ajax' => TRUE, 'token' => TRUE), - 'revert' => array('title' => t('Revert')), - 'delete' => array('title' => t('Delete')), - 'clone' => array('title' => t('Clone')), - 'import' => array('title' => t('Import')), - 'export' => array('title' => t('Export')), - ); - - $plugin['menu'] += array( - 'menu item' => str_replace(' ', '-', $plugin['name']), - 'menu prefix' => 'admin/structure', - 'menu title' => $plugin['title'], - 'menu description' => '', - ); - $base_path = ctools_export_ui_plugin_base_path($plugin); - $prefix_count = count(explode('/', $plugin['menu']['menu prefix'])); - - $plugin['menu'] += array( - // Default menu items that should be declared. - 'items' => array(), - ); - - $plugin['menu']['items'] += array( - 'list callback' => array( - 'path' => '', - // Menu items are translated by the menu system. - // TODO: We need more flexibility in title. The title of the admin page - // is not necessarily the title of the object, plus we need - // plural, singular, proper, not proper, etc. - 'title' => $plugin['menu']['menu title'], - 'description' => $plugin['menu']['menu description'], - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'list'), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'list'), - 'type' => MENU_NORMAL_ITEM, - ), - 'list' => array( - 'path' => 'list', - 'title' => 'List', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'list'), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'list'), - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ), - 'add' => array( - 'path' => 'add', - 'title' => 'Add', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'add'), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'add'), - 'type' => MENU_LOCAL_ACTION, - ), - 'edit callback' => array( - 'path' => 'list/%ctools_export_ui', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'edit', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'edit', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), - 'edit' => array( - 'path' => 'list/%ctools_export_ui/edit', - 'title' => 'Edit', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'edit', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'edit', $prefix_count + 2), - 'type' => MENU_DEFAULT_LOCAL_TASK, - ), - ); - - if ($plugin['allowed operations']['import']) { - $plugin['menu']['items'] += array( - 'import' => array( - 'path' => 'import', - 'title' => 'Import', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'import'), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'import'), - 'type' => MENU_LOCAL_ACTION, - ), - ); - } - - if ($plugin['allowed operations']['export']) { - $plugin['menu']['items'] += array( - 'export' => array( - 'path' => 'list/%ctools_export_ui/export', - 'title' => 'Export', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'export', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'export', $prefix_count + 2), - 'type' => MENU_LOCAL_TASK, - ), - ); - } - - if ($plugin['allowed operations']['revert']) { - $plugin['menu']['items'] += array( - 'revert' => array( - 'path' => 'list/%ctools_export_ui/revert', - 'title' => 'Revert', - 'page callback' => 'ctools_export_ui_switcher_page', - // Note: Yes, 'delete' op is correct. - 'page arguments' => array($plugin['name'], 'delete', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'revert', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), - ); - } - - if ($plugin['allowed operations']['delete']) { - $plugin['menu']['items'] += array( - 'delete' => array( - 'path' => 'list/%ctools_export_ui/delete', - 'title' => 'Delete', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'delete', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'delete', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), - ); - } - - if ($plugin['allowed operations']['clone']) { - $plugin['menu']['items'] += array( - 'clone' => array( - 'path' => 'list/%ctools_export_ui/clone', - 'title' => 'Clone', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'clone', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'clone', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), - ); - } - - if ($plugin['allowed operations']['enable']) { - $plugin['menu']['items'] += array( - 'enable' => array( - 'path' => 'list/%ctools_export_ui/enable', - 'title' => 'Enable', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'enable', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'enable', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), - ); - } - - if ($plugin['allowed operations']['disable']) { - $plugin['menu']['items'] += array( - 'disable' => array( - 'path' => 'list/%ctools_export_ui/disable', - 'title' => 'Disable', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'disable', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'disable', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), - ); - } - - // Define some redirects that should happen after edit/add/clone operations. - $plugin['redirect'] = array( - 'add' => $base_path, - 'clone' => $base_path, - 'edit' => $base_path, - 'import' => $base_path, - ); - - // Define form elements. - $plugin['form'] += array( - 'settings' => function_exists($plugin['name'] . '_form') ? $plugin['name'] . '_form' : '', - 'validate' => function_exists($plugin['name'] . '_form_validate') ? $plugin['name'] . '_form_validate' : '', - 'submit' => function_exists($plugin['name'] . '_form_submit') ? $plugin['name'] . '_form_submit' : '', - ); - - // Define strings. - - // For all strings, %title may be filled in at a later time via str_replace - // since we do not know the title now. - $plugin['strings'] += array( - 'title' => array(), - 'confirmation' => array(), - 'help' => array(), - 'message' => array(), - ); - - // Strings used in drupal_set_title(). - $plugin['strings']['title'] += array( - 'add' => t('Add a new @plugin', array('@plugin' => $plugin['title singular'])), - // The "%title" will be replaced in ctools_export_ui_form(), as in this - // stage we dont have the specific exportable object. - 'edit' => t('Edit @plugin %title', array('@plugin' => $plugin['title singular'])), - 'clone' => t('Clone @plugin %title', array('@plugin' => $plugin['title singular'])), - - 'import' => t('Import @plugin', array('@plugin' => $plugin['title singular'])), - 'export' => t('Export @plugin %title', array('@plugin' => $plugin['title singular'])), - ); - - // Strings used in confirmation pages. - $plugin['strings']['confirmation'] += array( - 'revert' => array(), - 'delete' => array(), - 'add' => array(), - 'edit' => array(), - ); - - $plugin['strings']['confirmation']['revert'] += array( - 'question' => t('Are you sure you want to revert %title?'), - 'information' => t('This action will permanently remove any customizations made to this item.'), - 'success' => t('The item has been reverted.'), - ); - - $plugin['strings']['confirmation']['delete'] += array( - 'question' => t('Are you sure you want to delete %title?'), - 'information' => t('This action will permanently remove this item from your database..'), - 'success' => t('The item has been deleted.'), - ); - - $plugin['strings']['confirmation']['add'] += array( - 'success' => t('%title has been created.'), - 'fail' => t('%title could not be created.'), - ); - - $plugin['strings']['confirmation']['edit'] += array( - 'success' => t('%title has been updated.'), - 'fail' => t('%title could not be updated.'), - ); - - // Strings used in $forms. - $plugin['strings']['help'] += array( - 'import' => t('You can import an exported definition by pasting the exported object code into the field below.'), - ); - - // Strings used in drupal_set_message(). - $plugin['strings']['message'] += array( - 'enable' => t('@plugin %title was enabled.', array('@plugin' => $plugin['title singular proper'])), - 'disable' => t('@plugin %title was disabled.', array('@plugin' => $plugin['title singular proper'])), - ); -} - -/** - * Get the class to handle creating a list of exportable items. - * - * If a plugin does not define a lister class at all, then the default - * lister class will be used. - * - * @return - * Either the lister class or FALSE if one could not be had. - */ -function ctools_export_ui_get_handler($plugin) { - $cache = &drupal_static(__FUNCTION__, array()); - if (empty($cache[$plugin['name']])) { - // If a list class is not specified by the plugin, fall back to the - // default ctools_export_ui plugin instead. - if (empty($plugin['handler'])) { - $default = ctools_get_export_ui('ctools_export_ui'); - $class = ctools_plugin_get_class($default, 'handler'); - } - else { - $class = ctools_plugin_get_class($plugin, 'handler'); - } - - if ($class) { - $cache[$plugin['name']] = new $class(); - $cache[$plugin['name']]->init($plugin); - } - } - return !empty($cache[$plugin['name']]) ? $cache[$plugin['name']] : FALSE; -} - -/** - * Get the base path from a plugin. - * - * @param $plugin - * The plugin. - * - * @return - * The menu path to the plugin's list. - */ -function ctools_export_ui_plugin_base_path($plugin) { - return $plugin['menu']['menu prefix'] . '/' . $plugin['menu']['menu item']; -} - -/** - * Get the path to a specific menu item from a plugin. - * - * @param $plugin - * The plugin name. - * @param $item_id - * The id in the menu items from the plugin. - * @param $export_key - * The export key of the item being edited, if it exists. - * @return - * The menu path to the plugin's list. - */ -function ctools_export_ui_plugin_menu_path($plugin, $item_id, $export_key = NULL) { - $path = $plugin['menu']['items'][$item_id]['path']; - if ($export_key) { - $path = str_replace('%ctools_export_ui', $export_key, $path); - } - return ctools_export_ui_plugin_base_path($plugin) . '/' . $path; -} - -/** - * Helper function to include CTools plugins and get an export-ui exportable. - * - * @param $plugin_name - * The plugin that should be laoded. - */ -function ctools_get_export_ui($plugin_name) { - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'export_ui', $plugin_name); - -} - -/** - * Helper function to include CTools plugins and get all export-ui exportables. - */ -function ctools_get_export_uis() { - ctools_include('plugins'); - return ctools_get_plugins('ctools', 'export_ui'); -} - -/** - * Main page callback to manipulate exportables. - * - * This simply loads the object defined in the plugin and hands it off to - * a method based upon the name of the operation in use. This can easily - * be used to add more ops. - */ -function ctools_export_ui_switcher_page($plugin_name, $op) { - $args = func_get_args(); - $js = !empty($_REQUEST['js']); - - // Load the $plugin information - $plugin = ctools_get_export_ui($plugin_name); - $handler = ctools_export_ui_get_handler($plugin); - - if ($handler) { - $method = $op . '_page'; - if (method_exists($handler, $method)) { - // replace the first two arguments: - $args[0] = $js; - $args[1] = $_POST; - return call_user_func_array(array($handler, $method), $args); - } - } - else { - return t('Configuration error. No handler found.'); - } -} diff --git a/includes/export-ui.menu.inc b/includes/export-ui.menu.inc deleted file mode 100644 index d27bf15..0000000 --- a/includes/export-ui.menu.inc +++ /dev/null @@ -1,24 +0,0 @@ -hook_menu($items); - } - } - } -} diff --git a/includes/export-ui.plugin-type.inc b/includes/export-ui.plugin-type.inc deleted file mode 100644 index f1a7510..0000000 --- a/includes/export-ui.plugin-type.inc +++ /dev/null @@ -1,20 +0,0 @@ - array( - 'function' => 'ctools_export_ui_process', - 'file' => 'export-ui.inc', - 'path' => drupal_get_path('module', 'ctools') . '/includes', - ), - 'classes' => array('handler'), - ); -} \ No newline at end of file diff --git a/includes/export.inc b/includes/export.inc deleted file mode 100644 index d93b2a4..0000000 --- a/includes/export.inc +++ /dev/null @@ -1,1015 +0,0 @@ -export_type & EXPORT_IN_DATABASE) { - // Existing record. - $update = array($key); - } - else { - // New record. - $update = array(); - $object->export_type = EXPORT_IN_DATABASE; - } - return drupal_write_record($table, $object, $update); - } -} - -/** - * Delete a single exportable object. - * - * This only deletes from the database, which means that if an item is in - * code, then this is actually a revert. - * - * @param $table - * The name of the table to use to retrieve $schema values. This table - * must have an 'export' section containing data or this function - * will fail. - * @param $object - * The fully populated object to delete, or the export key. - */ -function ctools_export_crud_delete($table, $object) { - $schema = ctools_export_get_schema($table); - $export = $schema['export']; - - if (!empty($export['delete callback']) && function_exists($export['delete callback'])) { - return $export['delete callback']($object); - } - else { - // If we were sent an object, get the export key from it. Otherwise - // assume we were sent the export key. - $value = is_object($object) ? $object->{$export['key']} : $object; - db_delete($table) - ->condition($export['key'], $value) - ->execute(); - } -} - -/** - * Get the exported code of a single exportable object. - * - * @param $table - * The name of the table to use to retrieve $schema values. This table - * must have an 'export' section containing data or this function - * will fail. - * @param $object - * The fully populated object to delete, or the export key. - * @param $indent - * Any indentation to apply to the code, in case this object is embedded - * into another, for example. - * - * @return - * A string containing the executable export of the object. - */ -function ctools_export_crud_export($table, $object, $indent = '') { - $schema = ctools_export_get_schema($table); - $export = $schema['export']; - - if (!empty($export['export callback']) && function_exists($export['export callback'])) { - return $export['export callback']($object, $indent); - } - else { - return ctools_export_object($table, $object, $indent); - } -} - -/** - * Turn exported code into an object. - * - * Note: If the code is poorly formed, this could crash and there is no - * way to prevent this. - * - * @param $table - * The name of the table to use to retrieve $schema values. This table - * must have an 'export' section containing data or this function - * will fail. - * @param $code - * The code to eval to create the object. - * - * @return - * An object created from the export. This object will NOT have been saved - * to the database. In the case of failure, a string containing all errors - * that the system was able to determine. - */ -function ctools_export_crud_import($table, $code) { - $schema = ctools_export_get_schema($table); - $export = $schema['export']; - - if (!empty($export['import callback']) && function_exists($export['import callback'])) { - return $export['import callback']($code); - } - else { - ob_start(); - eval($code); - ob_end_clean(); - - if (empty(${$export['identifier']})) { - $errors = ob_get_contents(); - if (empty($errors)) { - $errors = t('No item found.'); - } - return $errors; - } - - $item = ${$export['identifier']}; - - // Set these defaults just the same way that ctools_export_new_object sets - // them. - $item->export_type = NULL; - $item->type = t('Local'); - - return $item; - } -} - -/** - * @} - */ - -/** - * Load some number of exportable objects. - * - * This function will cache the objects, load subsidiary objects if necessary, - * check default objects in code and properly set them up. It will cache - * the results so that multiple calls to load the same objects - * will not cause problems. - * - * It attempts to reduce, as much as possible, the number of queries - * involved. - * - * @param $table - * The name of the table to be loaded from. Data is expected to be in the - * schema to make all this work. - * @param $type - * A string to notify the loader what the argument is - * - all: load all items. This is the default. $args is unused. - * - names: $args will be an array of specific named objects to load. - * - conditions: $args will be a keyed array of conditions. The conditions - * must be in the schema for this table or errors will result. - * @param $args - * An array of arguments whose actual use is defined by the $type argument. - */ -function ctools_export_load_object($table, $type = 'all', $args = array()) { - $cache = &drupal_static(__FUNCTION__); - $cached_database = &drupal_static('ctools_export_load_object_all'); - - $schema = ctools_export_get_schema($table); - if (empty($schema)) { - return array(); - } - - $export = $schema['export']; - - if (!isset($cache[$table])) { - $cache[$table] = array(); - } - - // If fetching all and cached all, we've done so and we are finished. - if ($type == 'all' && !empty($cached_database[$table])) { - return $cache[$table]; - } - - $return = array(); - - // Don't load anything we've already cached. - if ($type == 'names' && !empty($args)) { - foreach ($args as $id => $name) { - if (isset($cache[$table][$name])) { - $return[$name] = $cache[$table][$name]; - unset($args[$id]); - } - } - - // If nothing left to load, return the result. - if (empty($args)) { - return $return; - } - } - - // Build the query - $query = db_select($table, 't__0')->fields('t__0'); - $alias_count = 1; - if (!empty($schema['join'])) { - foreach ($schema['join'] as $join_key => $join) { - if ($join_schema = drupal_get_schema($join['table'])) { - $query->join($join['table'], 't__' . $alias_count, 't__0' . $join['left_key'] . ' = ' . 't__' . $alias_count . '.' . $join['right_key']); - $query->fields('t__' . $alias_count); - $alias_count++; - - // Allow joining tables to alter the query through a callback. - if (isset($join['callback']) && function_exists($join['callback'])) { - $join['callback']($query, $schema, $join_schema); - } - } - } - } - - $conditions = array(); - $query_args = array(); - - // If they passed in names, add them to the query. - if ($type == 'names') { - $query->condition($export['key'], $args, 'IN'); - } - else if ($type == 'conditions') { - foreach ($args as $key => $value) { - if (isset($schema['fields'][$key])) { - $query->condition($key, $value); - } - } - } - - $result = $query->execute(); - - $status = variable_get($export['status'], array()); - // Unpack the results of the query onto objects and cache them. - foreach ($result as $data) { - $object = _ctools_export_unpack_object($schema, $data, $export['object']); - $object->table = $table; - $object->type = t('Normal'); - $object->export_type = EXPORT_IN_DATABASE; - // Determine if default object is enabled or disabled. - if (isset($status[$object->{$export['key']}])) { - $object->disabled = $status[$object->{$export['key']}]; - } - - $cache[$table][$object->{$export['key']}] = $object; - if ($type == 'conditions') { - $return[$object->{$export['key']}] = $object; - } - } - - // Load subrecords. - if (isset($export['subrecords callback']) && function_exists($export['subrecords callback'])) { - $export['subrecords callback']($cache[$table]); - } - - if ($defaults = _ctools_export_get_defaults($table, $export)) { - - foreach ($defaults as $object) { - if ($type == 'conditions') { - // if this does not match all of our conditions, skip it. - foreach ($args as $key => $value) { - if (!isset($object->$key) || $object->$key != $value) { - continue 2; - } - } - } - else if ($type == 'names') { - if (!in_array($object->{$export['key']}, $args)) { - continue; - } - } - - // Determine if default object is enabled or disabled. - if (isset($status[$object->{$export['key']}])) { - $object->disabled = $status[$object->{$export['key']}]; - } - - if (!empty($cache[$table][$object->{$export['key']}])) { - $cache[$table][$object->{$export['key']}]->type = t('Overridden'); - $cache[$table][$object->{$export['key']}]->export_type |= EXPORT_IN_CODE; - if ($type == 'conditions') { - $return[$object->{$export['key']}] = $cache[$table][$object->{$export['key']}]; - } - } - else { - $object->type = t('Default'); - $object->export_type = EXPORT_IN_CODE; - $object->in_code_only = TRUE; - $object->table = $table; - - $cache[$table][$object->{$export['key']}] = $object; - if ($type == 'conditions') { - $return[$object->{$export['key']}] = $object; - } - } - } - } - - // If fetching all, we've done so and we are finished. - if ($type == 'all') { - $cached_database[$table] = TRUE; - return $cache[$table]; - } - - if ($type == 'names') { - foreach ($args as $name) { - if (isset($cache[$table][$name])) { - $return[$name] = $cache[$table][$name]; - } - } - } - - // For conditions, - return $return; -} - -/** - * Reset all static caches in ctools_export_load_object() or static caches for - * a given table in ctools_export_load_object(). - * - * @param $table - * String that is the name of a table. If not defined, all static caches in - * ctools_export_load_object() will be reset. - */ -function ctools_export_load_object_reset($table = NULL) { - // Reset plugin cache to make sure new include files are picked up. - ctools_include('plugins'); - ctools_get_plugins_reset(); - if (empty($table)) { - drupal_static_reset('ctools_export_load_object'); - drupal_static_reset('ctools_export_load_object_all'); - drupal_static_reset('_ctools_export_get_defaults'); - } - else { - $cache = &drupal_static('ctools_export_load_object'); - $cached_database = &drupal_static('ctools_export_load_object_all'); - $cached_defaults = &drupal_static('_ctools_export_get_defaults'); - unset($cache[$table]); - unset($cached_database[$table]); - unset($cached_defaults[$table]); - } -} - -/** - * Get the default version of an object, if it exists. - * - * This function doesn't care if an object is in the database or not and - * does not check. This means that export_type could appear to be incorrect, - * because a version could exist in the database. However, it's not - * incorrect for this function as it is *only* used for the default - * in code version. - */ -function ctools_get_default_object($table, $name) { - $schema = ctools_export_get_schema($table); - $export = $schema['export']; - - if (!$export['default hook']) { - return; - } - - // @todo add a method to load .inc files for this. - $defaults = _ctools_export_get_defaults($table, $export); - $status = variable_get($export['status'], array()); - - if (!isset($defaults[$name])) { - return; - } - - $object = $defaults[$name]; - - // Determine if default object is enabled or disabled. - if (isset($status[$object->{$export['key']}])) { - $object->disabled = $status[$object->{$export['key']}]; - } - - $object->type = t('Default'); - $object->export_type = EXPORT_IN_CODE; - $object->in_code_only = TRUE; - - return $object; -} - -/** - * Call the hook to get all default objects of the given type from the - * export. If configured properly, this could include loading up an API - * to get default objects. - */ -function _ctools_export_get_defaults($table, $export) { - $cache = &drupal_static(__FUNCTION__, array()); - - if (!isset($cache[$table])) { - $cache[$table] = array(); - - if ($export['default hook']) { - if (!empty($export['api'])) { - ctools_include('plugins'); - $info = ctools_plugin_api_include($export['api']['owner'], $export['api']['api'], - $export['api']['minimum_version'], $export['api']['current_version']); - $modules = array_keys($info); - } - else { - $modules = module_implements($export['default hook']); - } - - foreach ($modules as $module) { - $function = $module . '_' . $export['default hook']; - if (function_exists($function)) { - foreach ((array) $function($export) as $name => $object) { - // Record the module that provides this exportable. - $object->export_module = $module; - - if (empty($export['api'])) { - $cache[$table][$name] = $object; - } - else { - // If version checking is enabled, ensure that the object can be used. - if (isset($object->api_version) && - $object->api_version >= $export['api']['minimum_version'] && - $object->api_version <= $export['api']['current_version']) { - $cache[$table][$name] = $object; - } - } - } - } - } - - drupal_alter($export['default hook'], $cache[$table]); - } - } - - return $cache[$table]; -} - -/** - * Unpack data loaded from the database onto an object. - * - * @param $schema - * The schema from drupal_get_schema(). - * @param $data - * The data as loaded from the database. - * @param $object - * If an object, data will be unpacked onto it. If a string - * an object of that type will be created. - */ -function _ctools_export_unpack_object($schema, $data, $object = 'stdClass') { - if (is_string($object)) { - if (class_exists($object)) { - $object = new $object; - } - else { - $object = new stdClass; - } - } - - // Go through our schema and build correlations. - foreach ($schema['fields'] as $field => $info) { - $object->$field = empty($info['serialize']) ? $data->$field : unserialize($data->$field); - } - - if (isset($schema['join'])) { - foreach ($schema['join'] as $join_key => $join) { - $join_schema = ctools_export_get_schema($join['table']); - if (!empty($join['load'])) { - foreach ($join['load'] as $field) { - $info = $join_schema['fields'][$field]; - $object->$field = empty($info['serialize']) ? $data->$field : unserialize(db_decode_blob($data->$field)); - } - } - } - } - - return $object; -} - -/** - * Unpack data loaded from the database onto an object. - * - * @param $table - * The name of the table this object represents. - * @param $data - * The data as loaded from the database. - */ -function ctools_export_unpack_object($table, $data) { - $schema = ctools_export_get_schema($table); - return _ctools_export_unpack_object($schema, $data, $schema['export']['object']); -} - -/** - * Export a field. - * - * This is a replacement for var_export(), allowing us to more nicely - * format exports. It will recurse down into arrays and will try to - * properly export bools when it can, though PHP has a hard time with - * this since they often end up as strings or ints. - */ -function ctools_var_export($var, $prefix = '') { - if (is_array($var)) { - if (empty($var)) { - $output = 'array()'; - } - else { - $output = "array(\n"; - foreach ($var as $key => $value) { - $output .= $prefix . " " . ctools_var_export($key) . " => " . ctools_var_export($value, $prefix . ' ') . ",\n"; - } - $output .= $prefix . ')'; - } - } - else if (is_object($var) && get_class($var) === 'stdClass') { - // var_export() will export stdClass objects using an undefined - // magic method __set_state() leaving the export broken. This - // workaround avoids this by casting the object as an array for - // export and casting it back to an object when evaluated. - $output .= '(object) ' . ctools_var_export((array) $var); - } - else if (is_bool($var)) { - $output = $var ? 'TRUE' : 'FALSE'; - } - else { - $output = var_export($var, TRUE); - } - - return $output; -} - -/** - * Export an object into code. - */ -function ctools_export_object($table, $object, $indent = '', $identifier = NULL, $additions = array(), $additions2 = array()) { - $schema = ctools_export_get_schema($table); - if (!isset($identifier)) { - $identifier = $schema['export']['identifier']; - } - - $output = $indent . '$' . $identifier . ' = new ' . get_class($object) . ";\n"; - - if ($schema['export']['can disable']) { - $output .= $indent . '$' . $identifier . '->disabled = FALSE; /* Edit this to true to make a default ' . $identifier . ' disabled initially */' . "\n"; - } - if (!empty($schema['export']['api']['current_version'])) { - $output .= $indent . '$' . $identifier . '->api_version = ' . $schema['export']['api']['current_version'] . ";\n"; - } - - // Put top additions here: - foreach ($additions as $field => $value) { - $output .= $indent . '$' . $identifier . '->' . $field . ' = ' . ctools_var_export($value, $indent) . ";\n"; - } - - $fields = $schema['fields']; - if (!empty($schema['join'])) { - foreach ($schema['join'] as $join) { - if (!empty($join['load'])) { - foreach ($join['load'] as $join_field) { - $fields[$join_field] = $join['fields'][$join_field]; - } - } - } - } - - // Go through our schema and joined tables and build correlations. - foreach ($fields as $field => $info) { - if (!empty($info['no export'])) { - continue; - } - if (!isset($object->$field)) { - if (isset($info['default'])) { - $object->$field = $info['default']; - } - else { - $object->$field = ''; - } - } - - // Note: This is the *field* export callback, not the table one! - if (!empty($info['export callback']) && function_exists($info['export callback'])) { - $output .= $indent . '$' . $identifier . '->' . $field . ' = ' . $info['export callback']($object, $field, $value, $indent) . ";\n"; - } - else { - $value = $object->$field; - if ($info['type'] == 'int') { - $value = (isset($info['size']) && $info['size'] == 'tiny') ? (bool) $value : (int) $value; - } - - $output .= $indent . '$' . $identifier . '->' . $field . ' = ' . ctools_var_export($value, $indent) . ";\n"; - } - } - - // And bottom additions here - foreach ($additions2 as $field => $value) { - $output .= $indent . '$' . $identifier . '->' . $field . ' = ' . ctools_var_export($value, $indent) . ";\n"; - } - - return $output; -} - -/** - * Get the schema for a given table. - * - * This looks for data the export subsystem needs and applies defaults so - * that it's easily available. - */ -function ctools_export_get_schema($table) { - $cache = &drupal_static(__FUNCTION__); - if (empty($cache[$table])) { - $schema = drupal_get_schema($table); - - // If our schema isn't loaded, it's possible we're in a state where it - // simply hasn't been cached. If we've been asked, let's force the - // issue. - if (!$schema) { - // force a schema reset: - $schema = drupal_get_schema($table, TRUE); - } - - if (!isset($schema['export'])) { - return array(); - } - - if (empty($schema['module'])) { - return array(); - } - - // Add some defaults - $schema['export'] += array( - 'key' => 'name', - 'key name' => 'Name', - 'object' => 'stdClass', - 'status' => 'default_' . $table, - 'default hook' => 'default_' . $table, - 'can disable' => TRUE, - 'identifier' => $table, - 'primary key' => !empty($schema['primary key']) ? $schema['primary key'][0] : '', - 'bulk export' => TRUE, - 'list callback' => "$schema[module]_{$table}_list", - 'to hook code callback' => "$schema[module]_{$table}_to_hook_code", - ); - - // If the export definition doesn't have the "primary key" then the CRUD - // save callback won't work. - if (empty($schema['export']['primary key']) && user_access('administer site configuration')) { - drupal_set_message(t('The export definition of @table is missing the "primary key" property.', array('@table' => $table)), 'error'); - } - - // Notes: - // The following callbacks may be defined to override default behavior - // when using CRUD functions: - // - // create callback - // load callback - // load all callback - // save callback - // delete callback - // export callback - // import callback - // - // See the appropriate ctools_export_crud function for details on what - // arguments these callbacks should accept. Please do not call these - // directly, always use the ctools_export_crud_* wrappers to ensure - // that default implementations are honored. - $cache[$table] = $schema; - } - - return $cache[$table]; -} - -/** - * Gets the schemas for all tables with ctools object metadata. - */ -function ctools_export_get_schemas($for_export = FALSE) { - static $export_tables; - if (is_null($export_tables)) { - $export_tables = array(); - $schemas = drupal_get_schema(); - foreach ($schemas as $table => $schema) { - if (!isset($schema['export'])) { - unset($schemas[$table]); - continue; - } - $export_tables[$table] = ctools_export_get_schema($table); - } - } - return $for_export ? array_filter($export_tables, '_ctools_export_filter_export_tables') : $export_tables; -} - -function _ctools_export_filter_export_tables($schema) { - return !empty($schema['export']['bulk export']); -} - -function ctools_export_get_schemas_by_module($modules = array(), $for_export = FALSE) { - $export_tables = array(); - $list = ctools_export_get_schemas($for_export); - foreach ($list as $table => $schema) { - $export_tables[$schema['module']][$table] = $schema; - } - return empty($modules) ? $export_tables : array_keys($export_tables, $modules); -} - -/** - * Set the status of a default $object as a variable. - * - * The status, in this case, is whether or not it is 'disabled'. - * This function does not check to make sure $object actually - * exists. - */ -function ctools_export_set_status($table, $name, $new_status = TRUE) { - $schema = ctools_export_get_schema($table); - $status = variable_get($schema['export']['status'], array()); - - $status[$name] = $new_status; - variable_set($schema['export']['status'], $status); -} - -/** - * Set the status of a default $object as a variable. - * - * This is more efficient than ctools_export_set_status because it - * will actually unset the variable entirely if it's not necessary, - * this saving a bit of space. - */ -function ctools_export_set_object_status($object, $new_status = TRUE) { - $table = $object->table; - $schema = ctools_export_get_schema($table); - $export = $schema['export']; - $status = variable_get($schema['export']['status'], array()); - - // Compare - if (!$new_status && $object->export_type & EXPORT_IN_DATABASE) { - unset($status[$object->{$export['key']}]); - } - else { - $status[$object->{$export['key']}] = $new_status; - } - - variable_set($schema['export']['status'], $status); -} - -/** - * Provide a form for displaying an export. - * - * This is a simple form that should be invoked like this: - * @code - * $output = drupal_get_form('ctools_export_form', $code, $object_title); - * @endcode - */ -function ctools_export_form($form, &$form_state, $code, $title = '') { - $lines = substr_count($code, "\n"); - $form['code'] = array( - '#type' => 'textarea', - '#title' => $title, - '#default_value' => $code, - '#rows' => $lines, - ); - - return $form; -} - -/** - * Create a new object based upon schema values. - * - * Because 'default' has ambiguous meaning on some fields, we will actually - * use 'object default' to fill in default values if default is not set - * That's a little safer to use as it won't cause weird database default - * situations. - */ -function ctools_export_new_object($table, $set_defaults = TRUE) { - $schema = ctools_export_get_schema($table); - $export = $schema['export']; - - $object = new $export['object']; - foreach ($schema['fields'] as $field => $info) { - if (isset($info['object default'])) { - $object->$field = $info['object default']; - } - else if (isset($info['default'])) { - $object->$field = $info['default']; - } - else { - $object->$field = NULL; - } - } - - if ($set_defaults) { - // Set some defaults so this data always exists. - // We don't set the export_type property here, as this object is not saved - // yet. We do give it NULL so we don't generate notices trying to read it. - $object->export_type = NULL; - $object->type = t('Local'); - } - return $object; -} - -/** - * Convert a group of objects to code based upon input and return this as a larger - * export. - */ -function ctools_export_to_hook_code(&$code, $table, $names = array(), $name = 'foo') { - $schema = ctools_export_get_schema($table); - $export = $schema['export']; - // Use the schema-specified function for generating hook code, if one exists - if (function_exists($export['to hook code callback'])) { - $output = $export['to hook code callback']($names, $name); - } - // Otherwise, the following code generates basic hook code - else { - $output = ctools_export_default_to_hook_code($schema, $table, $names, $name); - } - - if (!empty($output)) { - if (isset($export['api'])) { - if (isset($code[$export['api']['owner']][$export['api']['api']]['version'])) { - $code[$export['api']['owner']][$export['api']['api']]['version'] = max($code[$export['api']['owner']][$export['api']['api']]['version'], $export['api']['minimum_version']); - } - else { - $code[$export['api']['owner']][$export['api']['api']]['version'] = $export['api']['minimum_version']; - $code[$export['api']['owner']][$export['api']['api']]['code'] = ''; - } - $code[$export['api']['owner']][$export['api']['api']]['code'] .= $output; - } - else { - if (empty($code['general'])) { - $code['general'] = ''; - } - $code['general'] .= $output; - } - } -} - -/** - * Default function to export objects to code. - * - * Note that if your module provides a 'to hook code callback' then it will - * receive only $names and $name as arguments. Your module is presumed to - * already know the rest. - */ -function ctools_export_default_to_hook_code($schema, $table, $names, $name) { - $export = $schema['export']; - $output = ''; - $objects = ctools_export_load_object($table, 'names', $names); - if ($objects) { - $output = "/**\n"; - $output .= " * Implementation of hook_{$export['default hook']}()\n"; - $output .= " */\n"; - $output .= "function " . $name . "_{$export['default hook']}() {\n"; - $output .= " \${$export['identifier']}s = array();\n\n"; - foreach ($objects as $object) { - $output .= ctools_export_crud_export($table, $object, ' '); - $output .= " \${$export['identifier']}s['" . check_plain($object->$export['key']) . "'] = \${$export['identifier']};\n\n"; - } - $output .= " return \${$export['identifier']}s;\n"; - $output .= "}\n"; - } - - return $output; -} -/** - * Default function for listing bulk exportable objects. - */ -function ctools_export_default_list($table, $schema) { - $list = array(); - - $items = ctools_export_crud_load_all($table); - $export_key = $schema['export']['key']; - - foreach ($items as $item) { - // Try a couple of possible obvious title keys: - if (!empty($item->admin_title)) { - $string = "$item->admin_title (" . $item->$export_key . ")"; - } - elseif (!empty($item->title)) { - $string = "$item->title (" . $item->$export_key . ")"; - } - else { - $string = $item->$export_key; - } - $list[$item->$export_key] = check_plain($string); - } - return $list; -} diff --git a/includes/fields.inc b/includes/fields.inc deleted file mode 100644 index 6e5dcc3..0000000 --- a/includes/fields.inc +++ /dev/null @@ -1,102 +0,0 @@ - $field_name, - 'entity_type' => 'ctools', - 'bundle' => 'ctools', - - // Use the default field settings for settings and widget. - 'settings' => field_info_instance_settings($field['type']), - 'widget' => array( - 'type' => $field_type['default_widget'], - 'settings' => array(), - ), - - // Build a dummy display mode. - 'display' => array( - $view_mode => array( - 'type' => $formatter, - 'settings' => $formatter_settings, - ), - ), - - // Set the other fields to their default values. - // @see _field_write_instance(). - 'required' => FALSE, - 'label' => $field_name, - 'description' => '', - 'deleted' => 0, - ); -} - -/** - * Helper function for calling hook_field_formatter_settings_form() without needing to load an instance of the field. - * - * @param $field - * A fully loaded field. - * @param $formatter_type - * The formatter key selected from the options provided by field_ui_formatter_options(). - * @param $form - * The full form from the function that's calling this function. - * @param $form_state - * The full form_state from the function that's calling this function. - * @param $view_mode - * We're passing a view mode from this function to the fake instance we're creating. Defaults to ctools, but we expect developers to actually name this something meaningful. - */ -function ctools_fields_get_field_formatter_settings_form($field, $formatter_type, &$form, $form_state, $view_mode = 'ctools') { - $conf = $form_state['conf']; - $formatter = field_info_formatter_types($formatter_type); - $function = $formatter['module'] . '_field_formatter_settings_form'; - if (function_exists($function)) { - $instance = ctools_fields_fake_field_instance($field['field_name'], $view_mode, $formatter_type, $conf['formatter_settings']); - $settings_form = $function($field, $instance, $view_mode, $form, $form_state); - if ($settings_form) { - $form['ctools_field_list']['#value'][] = $field; - $form += $settings_form; - } - } -} - -/** - * Helper function for generating all the formatter information associated with any fields. Especially useful for determining the fields that will be added to form that executes hook_ield_formatter_settings_form(). - * - * @param $fields - * An array of fully loaded fields. - */ - -function ctools_fields_get_field_formatter_info($fields) { - $info = array(); - foreach ($fields as $field) { - $field_info = module_invoke($field['module'], 'field_formatter_info'); - if ($field_info) { - $info += $field_info; - } - } - drupal_alter('field_formatter_info', $info); - return $info; -} diff --git a/includes/jump-menu.inc b/includes/jump-menu.inc deleted file mode 100644 index 4caa052..0000000 --- a/includes/jump-menu.inc +++ /dev/null @@ -1,120 +0,0 @@ - t('Go'), - 'choose' => t('- Choose -'), - 'inline' => TRUE, - 'hide' => TRUE, - ); - - ctools_add_js('jump-menu'); - - if (!empty($options['choose'])) { - $select = array('' => $options['choose']) + $select; - } - - $form['jump'] = array( - '#type' => 'select', - '#options' => $select, - '#attributes' => array( - 'class' => array('ctools-jump-menu-select'), - ), - ); - - if (!empty($options['title'])) { - $form['jump']['#title'] = $options['title']; - } - - if (!empty($options['description'])) { - $form['jump']['#description'] = $options['description']; - } - - if (!empty($options['default_value'])) { - $form['jump']['#default_value'] = $options['default_value']; - } - - if (isset($options['image'])) { - $form['go'] = array( - '#type' => 'image_button', - '#src' => $options['image'], - '#submit' => array('ctools_jump_menu_submit'), - '#attributes' => array( - 'class' => array('ctools-jump-menu-button'), - ), - ); - } - else { - $form['go'] = array( - '#type' => 'submit', - '#value' => $options['button'], - '#attributes' => array( - 'class' => array('ctools-jump-menu-button'), - ), - ); - } - - if ($options['inline']) { - $form['jump']['#prefix'] = '
'; - $form['go']['#suffix'] = '
'; - } - - if ($options['hide']) { - $form['jump']['#attributes']['class'][] = 'ctools-jump-menu-change'; - $form['go']['#attributes']['class'][] = 'ctools-jump-menu-hide'; - } - - return $form; -} - -/** - * Submit handler for the jump menu. - * - * This is normally only invoked upon submit without javascript enabled. - */ -function ctools_jump_menu_submit($form, &$form_state) { - $form_state['redirect'] = $form_state['values']['jump']; -} diff --git a/includes/math-expr.inc b/includes/math-expr.inc deleted file mode 100644 index 325d444..0000000 --- a/includes/math-expr.inc +++ /dev/null @@ -1,385 +0,0 @@ - - -================================================================================ - -NAME - ctools_math_expr - safely evaluate math expressions - -SYNOPSIS - include('ctools_math_expr.class.php'); - $m = new ctools_math_expr; - // basic evaluation: - $result = $m->evaluate('2+2'); - // supports: order of operation; parentheses; negation; built-in functions - $result = $m->evaluate('-8(5/2)^2*(1-sqrt(4))-8'); - // create your own variables - $m->evaluate('a = e^(ln(pi))'); - // or functions - $m->evaluate('f(x,y) = x^2 + y^2 - 2x*y + 1'); - // and then use them - $result = $m->evaluate('3*f(42,a)'); - -DESCRIPTION - Use the ctools_math_expr class when you want to evaluate mathematical expressions - from untrusted sources. You can define your own variables and functions, - which are stored in the object. Try it, it's fun! - -METHODS - $m->evalute($expr) - Evaluates the expression and returns the result. If an error occurs, - prints a warning and returns false. If $expr is a function assignment, - returns true on success. - - $m->e($expr) - A synonym for $m->evaluate(). - - $m->vars() - Returns an associative array of all user-defined variables and values. - - $m->funcs() - Returns an array of all user-defined functions. - -PARAMETERS - $m->suppress_errors - Set to true to turn off warnings when evaluating expressions - - $m->last_error - If the last evaluation failed, contains a string describing the error. - (Useful when suppress_errors is on). - -AUTHOR INFORMATION - Copyright 2005, Miles Kaufmann. - -LICENSE - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1 Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written - permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -*/ - -class ctools_math_expr { - var $suppress_errors = false; - var $last_error = null; - - var $v = array('e'=>2.71,'pi'=>3.14); // variables (and constants) - var $f = array(); // user-defined functions - var $vb = array('e', 'pi'); // constants - var $fb = array( // built-in functions - 'sin','sinh','arcsin','asin','arcsinh','asinh', - 'cos','cosh','arccos','acos','arccosh','acosh', - 'tan','tanh','arctan','atan','arctanh','atanh', - 'sqrt','abs','ln','log'); - - function ctools_math_expr() { - // make the variables a little more accurate - $this->v['pi'] = pi(); - $this->v['e'] = exp(1); - } - - function e($expr) { - return $this->evaluate($expr); - } - - function evaluate($expr) { - $this->last_error = null; - $expr = trim($expr); - if (substr($expr, -1, 1) == ';') $expr = substr($expr, 0, strlen($expr)-1); // strip semicolons at the end - //=============== - // is it a variable assignment? - if (preg_match('/^\s*([a-z]\w*)\s*=\s*(.+)$/', $expr, $matches)) { - if (in_array($matches[1], $this->vb)) { // make sure we're not assigning to a constant - return $this->trigger("cannot assign to constant '$matches[1]'"); - } - if (($tmp = $this->pfx($this->nfx($matches[2]))) === false) return false; // get the result and make sure it's good - $this->v[$matches[1]] = $tmp; // if so, stick it in the variable array - return $this->v[$matches[1]]; // and return the resulting value - //=============== - // is it a function assignment? - } elseif (preg_match('/^\s*([a-z]\w*)\s*\(\s*([a-z]\w*(?:\s*,\s*[a-z]\w*)*)\s*\)\s*=\s*(.+)$/', $expr, $matches)) { - $fnn = $matches[1]; // get the function name - if (in_array($matches[1], $this->fb)) { // make sure it isn't built in - return $this->trigger("cannot redefine built-in function '$matches[1]()'"); - } - $args = explode(",", preg_replace("/\s+/", "", $matches[2])); // get the arguments - if (($stack = $this->nfx($matches[3])) === false) return false; // see if it can be converted to postfix - for ($i = 0; $iv)) { - $stack[$i] = $this->v[$token]; - } else { - return $this->trigger("undefined variable '$token' in function definition"); - } - } - } - $this->f[$fnn] = array('args'=>$args, 'func'=>$stack); - return true; - //=============== - } else { - return $this->pfx($this->nfx($expr)); // straight up evaluation, woo - } - } - - function vars() { - $output = $this->v; - unset($output['pi']); - unset($output['e']); - return $output; - } - - function funcs() { - $output = array(); - foreach ($this->f as $fnn=>$dat) - $output[] = $fnn . '(' . implode(',', $dat['args']) . ')'; - return $output; - } - - //===================== HERE BE INTERNAL METHODS ====================\\ - - // Convert infix to postfix notation - function nfx($expr) { - - $index = 0; - $stack = new ctools_math_expr_stack; - $output = array(); // postfix form of expression, to be passed to pfx() - $expr = trim(strtolower($expr)); - - $ops = array('+', '-', '*', '/', '^', '_'); - $ops_r = array('+'=>0,'-'=>0,'*'=>0,'/'=>0,'^'=>1); // right-associative operator? - $ops_p = array('+'=>0,'-'=>0,'*'=>1,'/'=>1,'_'=>1,'^'=>2); // operator precedence - - $expecting_op = false; // we use this in syntax-checking the expression - // and determining when a - is a negation - - if (preg_match("/[^\w\s+*^\/()\.,-]/", $expr, $matches)) { // make sure the characters are all good - return $this->trigger("illegal character '{$matches[0]}'"); - } - - while(1) { // 1 Infinite Loop ;) - $op = substr($expr, $index, 1); // get the first character at the current index - // find out if we're currently at the beginning of a number/variable/function/parenthesis/operand - $ex = preg_match('/^([a-z]\w*\(?|\d+(?:\.\d*)?|\.\d+|\()/', substr($expr, $index), $match); - //=============== - if ($op == '-' and !$expecting_op) { // is it a negation instead of a minus? - $stack->push('_'); // put a negation on the stack - $index++; - } elseif ($op == '_') { // we have to explicitly deny this, because it's legal on the stack - return $this->trigger("illegal character '_'"); // but not in the input expression - //=============== - } elseif ((in_array($op, $ops) or $ex) and $expecting_op) { // are we putting an operator on the stack? - if ($ex) { // are we expecting an operator but have a number/variable/function/opening parethesis? - $op = '*'; $index--; // it's an implicit multiplication - } - // heart of the algorithm: - while($stack->count > 0 and ($o2 = $stack->last()) and in_array($o2, $ops) and ($ops_r[$op] ? $ops_p[$op] < $ops_p[$o2] : $ops_p[$op] <= $ops_p[$o2])) { - $output[] = $stack->pop(); // pop stuff off the stack into the output - } - // many thanks: http://en.wikipedia.org/wiki/Reverse_Polish_notation#The_algorithm_in_detail - $stack->push($op); // finally put OUR operator onto the stack - $index++; - $expecting_op = false; - //=============== - } elseif ($op == ')' and $expecting_op) { // ready to close a parenthesis? - while (($o2 = $stack->pop()) != '(') { // pop off the stack back to the last ( - if (is_null($o2)) return $this->trigger("unexpected ')'"); - else $output[] = $o2; - } - if (preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches)) { // did we just close a function? - $fnn = $matches[1]; // get the function name - $arg_count = $stack->pop(); // see how many arguments there were (cleverly stored on the stack, thank you) - $output[] = $stack->pop(); // pop the function and push onto the output - if (in_array($fnn, $this->fb)) { // check the argument count - if($arg_count > 1) - return $this->trigger("too many arguments ($arg_count given, 1 expected)"); - } elseif (array_key_exists($fnn, $this->f)) { - if ($arg_count != count($this->f[$fnn]['args'])) - return $this->trigger("wrong number of arguments ($arg_count given, " . count($this->f[$fnn]['args']) . " expected)"); - } else { // did we somehow push a non-function on the stack? this should never happen - return $this->trigger("internal error"); - } - } - $index++; - //=============== - } elseif ($op == ',' and $expecting_op) { // did we just finish a function argument? - while (($o2 = $stack->pop()) != '(') { - if (is_null($o2)) return $this->trigger("unexpected ','"); // oops, never had a ( - else $output[] = $o2; // pop the argument expression stuff and push onto the output - } - // make sure there was a function - if (!preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches)) - return $this->trigger("unexpected ','"); - $stack->push($stack->pop()+1); // increment the argument count - $stack->push('('); // put the ( back on, we'll need to pop back to it again - $index++; - $expecting_op = false; - //=============== - } elseif ($op == '(' and !$expecting_op) { - $stack->push('('); // that was easy - $index++; - $allow_neg = true; - //=============== - } elseif ($ex and !$expecting_op) { // do we now have a function/variable/number? - $expecting_op = true; - $val = $match[1]; - if (preg_match("/^([a-z]\w*)\($/", $val, $matches)) { // may be func, or variable w/ implicit multiplication against parentheses... - if (in_array($matches[1], $this->fb) or array_key_exists($matches[1], $this->f)) { // it's a func - $stack->push($val); - $stack->push(1); - $stack->push('('); - $expecting_op = false; - } else { // it's a var w/ implicit multiplication - $val = $matches[1]; - $output[] = $val; - } - } else { // it's a plain old var or num - $output[] = $val; - } - $index += strlen($val); - //=============== - } elseif ($op == ')') { // miscellaneous error checking - return $this->trigger("unexpected ')'"); - } elseif (in_array($op, $ops) and !$expecting_op) { - return $this->trigger("unexpected operator '$op'"); - } else { // I don't even want to know what you did to get here - return $this->trigger("an unexpected error occured"); - } - if ($index == strlen($expr)) { - if (in_array($op, $ops)) { // did we end with an operator? bad. - return $this->trigger("operator '$op' lacks operand"); - } else { - break; - } - } - while (substr($expr, $index, 1) == ' ') { // step the index past whitespace (pretty much turns whitespace - $index++; // into implicit multiplication if no operator is there) - } - - } - while (!is_null($op = $stack->pop())) { // pop everything off the stack and push onto output - if ($op == '(') return $this->trigger("expecting ')'"); // if there are (s on the stack, ()s were unbalanced - $output[] = $op; - } - return $output; - } - - // evaluate postfix notation - function pfx($tokens, $vars = array()) { - - if ($tokens == false) return false; - - $stack = new ctools_math_expr_stack; - - foreach ($tokens as $token) { // nice and easy - // if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on - if (in_array($token, array('+', '-', '*', '/', '^'))) { - if (is_null($op2 = $stack->pop())) return $this->trigger("internal error"); - if (is_null($op1 = $stack->pop())) return $this->trigger("internal error"); - switch ($token) { - case '+': - $stack->push($op1+$op2); break; - case '-': - $stack->push($op1-$op2); break; - case '*': - $stack->push($op1*$op2); break; - case '/': - if ($op2 == 0) return $this->trigger("division by zero"); - $stack->push($op1/$op2); break; - case '^': - $stack->push(pow($op1, $op2)); break; - } - // if the token is a unary operator, pop one value off the stack, do the operation, and push it back on - } elseif ($token == "_") { - $stack->push(-1*$stack->pop()); - // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on - } elseif (preg_match("/^([a-z]\w*)\($/", $token, $matches)) { // it's a function! - $fnn = $matches[1]; - if (in_array($fnn, $this->fb)) { // built-in function: - if (is_null($op1 = $stack->pop())) return $this->trigger("internal error"); - $fnn = preg_replace("/^arc/", "a", $fnn); // for the 'arc' trig synonyms - if ($fnn == 'ln') $fnn = 'log'; - eval('$stack->push(' . $fnn . '($op1));'); // perfectly safe eval() - } elseif (array_key_exists($fnn, $this->f)) { // user function - // get args - $args = array(); - for ($i = count($this->f[$fnn]['args'])-1; $i >= 0; $i--) { - if (is_null($args[$this->f[$fnn]['args'][$i]] = $stack->pop())) return $this->trigger("internal error"); - } - $stack->push($this->pfx($this->f[$fnn]['func'], $args)); // yay... recursion!!!! - } - // if the token is a number or variable, push it on the stack - } else { - if (is_numeric($token)) { - $stack->push($token); - } elseif (array_key_exists($token, $this->v)) { - $stack->push($this->v[$token]); - } elseif (array_key_exists($token, $vars)) { - $stack->push($vars[$token]); - } else { - return $this->trigger("undefined variable '$token'"); - } - } - } - // when we're out of tokens, the stack should have a single element, the final result - if ($stack->count != 1) return $this->trigger("internal error"); - return $stack->pop(); - } - - // trigger an error, but nicely, if need be - function trigger($msg) { - $this->last_error = $msg; - if (!$this->suppress_errors) trigger_error($msg, E_USER_WARNING); - return false; - } -} - -// for internal use -class ctools_math_expr_stack { - - var $stack = array(); - var $count = 0; - - function push($val) { - $this->stack[$this->count] = $val; - $this->count++; - } - - function pop() { - if ($this->count > 0) { - $this->count--; - return $this->stack[$this->count]; - } - return null; - } - - function last($n=1) { - return !empty($this->stack[$this->count-$n]) ? $this->stack[$this->count-$n] : NULL; - } -} - diff --git a/includes/menu.inc b/includes/menu.inc deleted file mode 100644 index e76a66d..0000000 --- a/includes/menu.inc +++ /dev/null @@ -1,98 +0,0 @@ - 'menu_local_action', - '#link' => $addition, - ); - } - else { - $data['tabs'][0]['output'][] = array( - '#theme' => 'menu_local_task', - '#link' => $addition, - '#active' => (!$has_active && $root_path === $addition['href']), - ); - } - } - if (!empty($data['tabs'][0]['output'])) { - uasort($data['tabs'][0]['output'], 'ctools_menu_sort'); - $data['tabs'][0]['count'] = count($data['tabs'][0]['output']); - } - - if (!empty($data['actions']['output'])) { - uasort($data['actions']['output'], 'ctools_menu_sort'); - $data['actions']['count'] = count($data['actions']['output']); - } - } -} diff --git a/includes/modal.inc b/includes/modal.inc deleted file mode 100644 index 75ffdb8..0000000 --- a/includes/modal.inc +++ /dev/null @@ -1,249 +0,0 @@ - array( - 'loadingText' => t('Loading...'), - 'closeText' => t('Close Window'), - 'closeImage' => theme('image', array( - 'path' => ctools_image_path('icon-close-window.png'), - 'title' => t('Close window'), - 'alt' => t('Close window'), - )), - 'throbber' => theme('image', array( - 'path' => ctools_image_path('throbber.gif'), - 'title' => t('Loading...'), - 'alt' => t('Loading'), - )), - ), - ); - - drupal_add_js($settings, 'setting'); - drupal_add_js('misc/jquery.form.js'); - drupal_add_js('misc/progress.js'); - drupal_add_js('misc/ajax.js'); - ctools_add_js('modal'); - - ctools_add_css('modal'); - $done = TRUE; -} - -/** - * @todo this is deprecated - */ -function ctools_modal_add_plugin_js($plugins) { - $css = array(); - $js = array(drupal_get_path('module', 'ctools') . '/js/dependent.js' => TRUE); - foreach ($plugins as $subtype) { - if (isset($subtype['js'])) { - foreach ($subtype['js'] as $file) { - if (file_exists($file)) { - $js[$file] = TRUE; - } - else if (file(exists($subtype['path'] . '/' . $file))) { - $js[$subtype['path'] . '/' . $file] = TRUE; - } - } - } - if (isset($subtype['css'])) { - foreach ($subtype['css'] as $file) { - if (file_exists($file)) { - $css[$file] = TRUE; - } - else if (file(exists($subtype['path'] . '/' . $file))) { - $css[$subtype['path'] . '/' . $file] = TRUE; - } - } - } - } - - foreach (array_keys($js) as $file) { - drupal_add_js($file); - } - foreach (array_keys($css) as $file) { - drupal_add_css($file); - } -} - -/** - * Place HTML within the modal. - * - * @param $title - * The title of the modal. - * @param $html - * The html to place within the modal. - */ -function ctools_modal_command_display($title, $html) { - if (is_array($html)) { - $html = drupal_render($html); - } - - return array( - 'command' => 'modal_display', - 'title' => $title, - 'output' => $html, - ); -} - -/** - * Dismiss the modal. - */ -function ctools_modal_command_dismiss() { - return array( - 'command' => 'modal_dismiss', - ); -} - -/** - * Display loading screen in the modal - */ -function ctools_modal_command_loading() { - return array( - 'command' => 'modal_loading', - ); -} - -/** - * Render an image as a button link. This will automatically apply an AJAX class - * to the link and add the appropriate javascript to make this happen. - * - * @param $image - * The path to an image to use that will be sent to theme('image') for rendering. - * @param $dest - * The destination of the link. - * @param $alt - * The alt text of the link. - * @param $class - * Any class to apply to the link. @todo this should be a options array. - */ -function ctools_modal_image_button($image, $dest, $alt, $class = '') { - return ctools_ajax_text_button(theme('image', array('path' => $image)), $dest, $alt, $class, 'ctools-use-modal'); -} - -/** - * Render text as a link. This will automatically apply an AJAX class - * to the link and add the appropriate javascript to make this happen. - * - * Note: 'html' => true so be sure any text is vetted! Chances are these kinds of buttons will - * not use user input so this is a very minor concern. - * - * @param $text - * The text that will be displayed as the link. - * @param $dest - * The destination of the link. - * @param $alt - * The alt text of the link. - * @param $class - * Any class to apply to the link. @todo this should be a options array. - */ -function ctools_modal_text_button($text, $dest, $alt, $class = '') { - return ctools_ajax_text_button($text, $dest, $alt, $class, 'ctools-use-modal'); -} - -/** - * Wrap a form so that we can use it properly with AJAX. Essentially if the - * form wishes to render, it automatically does that, otherwise it returns - * so we can see submission results. - * - * @return - * The output of the form, if it was rendered. If $form_state['ajax'] - * is set, this will use ctools_modal_form_render so it will be - * a $command object suitable for ajax_render already. - * - * The return will be NULL if the form was successfully submitted unless - * you specifically set re_render = TRUE. If ajax is set the - * form will never be redirected. - */ -function ctools_modal_form_wrapper($form_id, &$form_state) { - // This won't override settings already in. - $form_state += array( - 're_render' => FALSE, - 'no_redirect' => !empty($form_state['ajax']), - ); - - $output = drupal_build_form($form_id, $form_state); - if (!empty($form_state['ajax']) && empty($form_state['executed'])) { - return ctools_modal_form_render($form_state, $output); - } - - return $output; -} - -/** - * Render a form into an AJAX display. - */ -function ctools_modal_form_render($form_state, $output) { - if (is_array($output)) { - $output = drupal_render($output); - } - - $title = empty($form_state['title']) ? drupal_get_title() : $form_state['title']; - - // If there are messages for the form, render them. - if ($messages = theme('status_messages')) { - $output = '
' . $messages . '
' . $output; - } - - $commands = array(); - // If the form has not yet been rendered, render it. - $commands[] = ctools_modal_command_display($title, $output); - return $commands; -} - -/** - * Perform a simple modal render and immediately exit. - * - * This is primarily used for error displays, since usually modals will - * contain forms. - */ -function ctools_modal_render($title, $output) { - $commands = array(); - $commands[] = ctools_modal_command_display($title, $output); - ajax_render($commands); -} diff --git a/includes/object-cache.cron.inc b/includes/object-cache.cron.inc deleted file mode 100644 index 99f2276..0000000 --- a/includes/object-cache.cron.inc +++ /dev/null @@ -1,16 +0,0 @@ - session_id(), ':object' => $obj, ':name' => $name)) - ->fetchObject(); - if ($data) { - $cache[$key] = unserialize($data->data); - } - } - return isset($cache[$key]) ? $cache[$key] : NULL; -} - -/** - * Store an object in the non-volatile ctools cache. - * - * @param $obj - * A 32 character or less string to define what kind of object is being - * stored; primarily this is used to prevent collisions. - * @param $name - * The name of the object being stored. - * @param $cache - * The object to be cached. This will be serialized prior to writing. - */ -function ctools_object_cache_set($obj, $name, $cache) { - // Store the CTools session id in the user session to force a - // session for anonymous users in Drupal 7 and Drupal 6 Pressflow. - // see http://drupal.org/node/562374, http://drupal.org/node/861778 - if (empty($GLOBALS['user']->uid) && empty($_SESSION['ctools_session_id'])) { - $_SESSION['ctools_hold_session'] = TRUE; - } - - ctools_object_cache_clear($obj, $name); - db_insert('ctools_object_cache') - ->fields(array( - 'sid' => session_id(), - 'obj' => $obj, - 'name' => $name, - 'data' => serialize($cache), - 'updated' => REQUEST_TIME, - )) - ->execute(); -} - -/** - * Remove an object from the non-volatile ctools cache - * - * @param $obj - * A 32 character or less string to define what kind of object is being - * stored; primarily this is used to prevent collisions. - * @param $name - * The name of the object being removed. - */ -function ctools_object_cache_clear($obj, $name) { - db_delete('ctools_object_cache') - ->condition('sid', session_id()) - ->condition('obj', $obj) - ->condition('name', $name) - ->execute(); - // Ensure the static cache is emptied of this obj:name set. - drupal_static_reset('ctools_object_cache_get'); -} - - -/** - * Determine if another user has a given object cached. - * - * This is very useful for 'locking' objects so that only one user can - * modify them. - * - * @param $obj - * A 32 character or less string to define what kind of object is being - * stored; primarily this is used to prevent collisions. - * @param $name - * The name of the object being removed. - * - * @return - * An object containing the UID and updated date if found; NULL if not. - */ -function ctools_object_cache_test($obj, $name) { - return db_query('SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid <> :session_id AND c.obj = :obj AND c.name = :name ORDER BY c.updated ASC', array(':session_id' => session_id(), ':obj' => $obj, ':name' => $name)) - ->fetchObject(); -} - -/** - * Get the cache status of a group of objects. - * - * This is useful for displaying lock status when listing a number of objects - * an an administration UI. - * - * @param $obj - * A 32 character or less string to define what kind of object is being - * stored; primarily this is used to prevent collisions. - * @param $names - * An array of names of objects - * - * @return - * An array of objects containing the UID and updated date for each name found. - */ -function ctools_object_cache_test_objects($obj, $names) { - return db_query("SELECT c.name, s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE c.obj = :obj AND c.name IN (:names) ORDER BY c.updated ASC", array(':obj' => $obj, ':names' => $names)) - ->fetchAllAssoc('name'); -} - -/** - * Remove an object from the non-volatile ctools cache for all session IDs. - * - * This is useful for clearing a lock. - * - * @param $obj - * A 32 character or less string to define what kind of object is being - * stored; primarily this is used to prevent collisions. - * @param $name - * The name of the object being removed. - */ -function ctools_object_cache_clear_all($obj, $name) { - db_delete('ctools_object_cache') - ->condition('obj', $obj) - ->condition('name', $name) - ->execute(); - // Ensure the static cache is emptied of this obj:name set. - $cache = &drupal_static('ctools_object_cache_get', array()); - unset($cache["$obj:$name"]); -} - -/** - * Remove all objects in the object cache that are older than the - * specified age. - * - * @param $age - * The minimum age of objects to remove, in seconds. For example, 86400 is - * one day. Defaults to 7 days. - */ -function ctools_object_cache_clean($age = NULL) { - if (empty($age)) { - $age = 86400 * 7; // 7 days - } - db_delete('ctools_object_cache') - ->condition('updated', REQUEST_TIME - $age, '<') - ->execute(); -} diff --git a/includes/page-wizard.inc b/includes/page-wizard.inc deleted file mode 100644 index a211361..0000000 --- a/includes/page-wizard.inc +++ /dev/null @@ -1,194 +0,0 @@ -plugin = $plugin; - if ($function = ctools_plugin_get_function($plugin, 'default cache')) { - $function($cache); - } - - return $cache; -} - -/** - * Store changes to a task handler in the object cache. - */ -function page_manager_set_wizard_cache($cache) { - ctools_include('object-cache'); - ctools_object_cache_set('page_manager_page_wizard', $cache->plugin['name'], $cache); -} - -/** - * Remove an item from the object cache. - */ -function page_manager_clear_wizard_cache($name) { - ctools_include('object-cache'); - ctools_object_cache_clear('page_manager_page_wizard', $name); -} - -/** - * Menu callback for the page wizard. - */ -function page_manager_page_wizard($name, $step = NULL) { - $plugin = page_manager_get_page_wizard($name); - if (!$plugin) { - return MENU_NOT_FOUND; - } - - // Check for simple access string on plugin. - if (!empty($plugin['access']) && !user_access($plugin['access'])) { - return MENU_ACCESS_DENIED; - } - - // Check for possibly more complex access callback on plugin. - if ($function = ctools_plugin_get_function($plugin, 'access callback') && !$function($plugin)) { - return MENU_ACCESS_DENIED; - } - - // Create a basic wizard.in form info array and merge it with the - // plugin's. - $form_info = array( - 'id' => 'page_manager_page_wizard', - 'show trail' => TRUE, - 'show back' => TRUE, - 'show return' => FALSE, - 'show cancel' => FALSE, - 'next callback' => 'page_manager_page_wizard_next', - 'finish callback' => 'page_manager_page_wizard_finish', - - 'path' => "admin/structure/pages/wizard/$name/%step", - ); - - $form_info = array_merge_recursive($form_info, $plugin['form info']); - - // If step is unset, go with the basic step. - if (!isset($step)) { - $step = current(array_keys($form_info['order'])); - $cache = page_manager_make_wizard_cache($plugin); - } - else { - $cache = page_manager_get_wizard_cache($plugin); - } - - ctools_include('wizard'); - $form_state = array( - 'plugin' => $plugin, - 'wizard cache' => $cache, - 'type' => 'edit', - 'rerender' => TRUE, - 'step' => $step, - ); - - if (isset($plugin['page title'])) { - drupal_set_title($plugin['page title']); - } - - if ($function = ctools_plugin_get_function($form_state['plugin'], 'start')) { - $function($form_info, $step, $form_state); - } - - $output = ctools_wizard_multistep_form($form_info, $step, $form_state); - return $output; -} - -/** - * Callback generated when the add page process is finished. - */ -function page_manager_page_wizard_finish(&$form_state) { - if ($function = ctools_plugin_get_function($form_state['plugin'], 'finish')) { - $function($form_state); - } - - page_manager_clear_wizard_cache($form_state['wizard cache']->plugin['name']); -} - -/** - * Callback generated when the 'next' button is clicked. - * - * All we do here is store the cache. - */ -function page_manager_page_wizard_next(&$form_state) { - if ($function = ctools_plugin_get_function($form_state['plugin'], 'next')) { - $function($form_state); - } - - page_manager_set_wizard_cache($form_state['wizard cache']); -} - -/** - * Provide a simple administrative list of all wizards. - * - * This is called as a page callback, but can also be used by any module - * that wants to get a list of wizards for its type. - */ -function page_manager_page_wizard_list($type = NULL) { - $plugins = page_manager_get_page_wizards(); - if (empty($plugins)) { - return '

' . t('There are no wizards available at this time.') . '

'; - } - - uasort($plugins, 'ctools_plugin_sort'); - - $output = '
'; - foreach ($plugins as $id => $plugin) { - if (!$type || (isset($plugin['type']) && $plugin['type'] == $type)) { - $output .= '
' . l($plugin['title'], 'admin/structure/pages/wizard/' . $id) . '
'; - $output .= '
' . $plugin['description'] . '
'; - } - } - $output .= '
'; - - return $output; -} diff --git a/includes/page-wizard.menu.inc b/includes/page-wizard.menu.inc deleted file mode 100644 index 7ed932e..0000000 --- a/includes/page-wizard.menu.inc +++ /dev/null @@ -1,32 +0,0 @@ - array('use page manager'), - 'file' => 'includes/page-wizard.inc', - 'type' => MENU_CALLBACK, - ); - - $items['admin/structure/pages/wizard'] = array( - 'title' => 'Wizards', - 'page callback' => 'page_manager_page_wizard_list', - 'page arguments' => array(4), - 'weight' => -5, - 'type' => MENU_LOCAL_TASK, - ) + $base; - - $items['admin/structure/pages/wizard/%'] = array( - 'title' => 'Wizard', - 'page callback' => 'page_manager_page_wizard', - 'page arguments' => array(4), - ) + $base; -} diff --git a/includes/plugins-admin.inc b/includes/plugins-admin.inc deleted file mode 100644 index 06ee779..0000000 --- a/includes/plugins-admin.inc +++ /dev/null @@ -1,196 +0,0 @@ - TRUE and - * 'modal return' => TRUE should make this system work well in the modal. - * - * In addition to standard wizard fields, this supports one extra field: - * - 'default form': A callback to a 'wrapper' that will be applied to either - * the first or a marked form. This is useful for adding global features that - * are applicable to all instances of a plugin, such as identifiers, or - * contexts, or the like. - * - * @param array &$form_state - * This is a standard form state array. This system imposes some requirements - * on what will be in the form state: - * - * - 'plugin': The plugin definition being edited. - * - 'conf': The configuration that is being edited, presumed to be an array. - * Ultimately at the end, this is where the modified config will be - * found. - * - 'op': The operation, either 'add' or 'edit'. This is used to derive form - * names and can also be used to derive default values from the plugin. - * - 'step': The current step. May be null if it is the 'first' step, but - * generally needs to be defined in the path. - * - * @param string $default_form - * An optional default form that can be added. - * - * @return - * If this function returns false, no form exists. - */ -function ctools_plugin_configure_form($form_info, &$form_state) { - // Turn the forms defined in the plugin into the format the wizard needs. - _ctools_plugin_configure_create_form_info($form_info, $form_state['plugin'], $form_state['op']); - - if (empty($form_info['order'])) { - return FALSE; - } - - ctools_include('wizard'); - return ctools_wizard_multistep_form($form_info, $form_state['step'], $form_state); -} - -function _ctools_plugin_configure_create_form_info(&$form_info, $plugin_definition, $op) { - // Provide a few extra defaults. - $form_info += array( - 'id' => 'ctools_plugin_configure_form', - 'show back' => TRUE, - ); - - // Figure out what the forms should actually be. Since they can be specified - // in a couple of different ways (in order to support simple declarations for - // the minimal forms but more complex declarations for powerful wizards). - if ($op == 'add') { - if (!empty($plugin_definition['add form'])) { - $info = $plugin_definition['add form']; - } - } - if (!isset($info) || $op == 'edit') { - // Use the edit form for the add form if add form was completely left off. - if (!empty($plugin_definition['edit form'])) { - $info = $plugin_definition['edit form']; - } - } - - // If there is a default form wrapper, but no form is supplied, - // use the wrapper as the form. - if (empty($info) && !empty($form_info['default form'])) { - $info = $form_info['default form']; - } - - // @todo we may want to make these titles more settable? - if (is_string($info)) { - if (empty($plugin_definition['title'])) { - $title = t('Configure'); - } - else if ($op == 'add') { - $title = t('Configure new !plugin_title', array('!plugin_title' => $plugin_definition['title'])); - } - else { - $title = t('Configure !plugin_title', array('!plugin_title' => $plugin_definition['title'])); - } - $form_info['order'] = array('form' => $title); - $form_info['forms'] = array( - 'form' => array( - 'title' => $title, - 'form id' => $info, - ), - ); - - // Add the default form if one is specified. - if (!empty($form_info['default form']) && $form_info['forms']['form']['form id'] != $form_info['default form']) { - $form_info['forms']['form']['wrapper'] = $form_info['default form']; - } - - // If no submit is supplied, supply the default submit which will do the - // most obvious task. - if (!function_exists($form_info['forms']['form']['form id'] . '_submit')) { - // Store the original wrapper so we can chain it. - if (!empty($form_info['forms']['form']['wrapper'])) { - $form_info['forms']['form']['original wrapper'] = $form_info['forms']['form']['wrapper']; - } - $form_info['forms']['form']['wrapper'] = 'ctools_plugins_default_form_wrapper'; - } - } - else if (is_array($info)) { - $form_info['order'] = array(); - $form_info['forms'] = array(); - $count = 0; - $base = 'step'; - $wrapper = NULL; - foreach ($info as $form_id => $title) { - $step = $base . ++$count; - if (empty($wrapper)) { - $wrapper = $step; - } - - if (is_array($title)) { - if (!empty($title['default'])) { - $wrapper = $step; - } - $title = $title['title']; - } - - $form_info['order'][$step] = $title; - $form_info['forms'][$step] = array( - 'title' => $title, - 'form id' => $form_id, - ); - } - if ($wrapper && !empty($form_info['default form'])) { - $form_info['forms'][$wrapper]['wrapper'] = $form_info['default form']; - } - } -} - -/** - * A wrapper to provide a default submit so that plugins don't have to duplicate - * a whole bunch of code to do what most of them want to do anyway. - */ -function ctools_plugins_default_form_wrapper($form, &$form_state) { - $form_info = &$form_state['form_info']; - $info = $form_info['forms'][$form_state['step']]; - - if (isset($info['original wrapper']) && function_exists($info['original wrapper'])) { - $form = $info['original wrapper']($form, $form_state); - } - - if (isset($form['buttons']['next'])) { - if (empty($form['buttons']['next']['#submit'])) { - $form['buttons']['next']['#submit'] = $form['#submit']; - } - $form['buttons']['next']['#submit'][] = 'ctools_plugins_default_form_wrapper_submit'; - } - if (isset($form['buttons']['return'])) { - if (empty($form['buttons']['return']['#submit'])) { - $form['buttons']['return']['#submit'] = $form['#submit']; - } - $form['buttons']['return']['#submit'][] = 'ctools_plugins_default_form_wrapper_submit'; - } - return $form; -} - -/** - * Provide a default storage mechanism. - */ -function ctools_plugins_default_form_wrapper_submit(&$form, &$form_state) { - foreach (array_keys($form_state['plugin']['defaults']) as $key) { - if (isset($form_state['values'][$key])) { - $form_state['conf'][$key] = $form_state['values'][$key]; - } - } -} diff --git a/includes/plugins.inc b/includes/plugins.inc deleted file mode 100644 index 404d859..0000000 --- a/includes/plugins.inc +++ /dev/null @@ -1,880 +0,0 @@ -=') && version_compare($version, $current_version, '<=')) { - if (!isset($info['path'])) { - $info['path'] = drupal_get_path('module', $module); - } - $cache[$owner][$api][$module] = $info; - } - } - - // And allow themes to implement these as well. - $themes = _ctools_list_themes(); - foreach ($themes as $name => $theme) { - if (!empty($theme->info['api'][$owner][$api])) { - $info = $theme->info['api'][$owner][$api]; - if (!isset($info['version'])) { - continue; - } - - // Only process if version is between minimum and current, inclusive. - if (version_compare($info['version'], $minimum_version, '>=') && version_compare($info['version'], $current_version, '<=')) { - if (!isset($info['path'])) { - $info['path'] = ''; - } - // Because themes can't easily specify full path, we add it here - // even though we do not for modules: - $info['path'] = drupal_get_path('theme', $name) . '/' . $info['path']; - $cache[$owner][$api][$name] = $info; - } - } - } - } - - return $cache[$owner][$api]; -} - -/** - * Load a group of API files. - * - * This will ask each module if they support the given API, and if they do - * it will load the specified file name. The API and the file name - * coincide by design. - * - * @param $owner - * The name of the module that controls the API. - * @param $api - * The name of the api. The api name forms the file name: - * $module.$api.inc, though this can be overridden by the module's response. - * @param $minimum_version - * The lowest version API that is compatible with this one. If a module - * reports its API as older than this, its files will not be loaded. This - * should never change during operation. - * @param $current_version - * The current version of the api. If a module reports its minimum API as - * higher than this, its files will not be loaded. This should never change - * during operation. - * - * @return - * The API information, in case you need it. - */ -function ctools_plugin_api_include($owner, $api, $minimum_version, $current_version) { - static $already_done = array(); - - $info = ctools_plugin_api_info($owner, $api, $minimum_version, $current_version); - foreach ($info as $module => $plugin_info) { - if (!isset($already_done[$owner][$api][$module])) { - if (isset($plugin_info["$api file"])) { - $file = isset($plugin_info["$api file"]); - } - else if (isset($plugin_info['file'])) { - $file = isset($plugin_info['file']); - } - else { - $file = "$module.$api.inc"; - } - - if (file_exists(DRUPAL_ROOT . "/$plugin_info[path]/$file")) { - require_once DRUPAL_ROOT . "/$plugin_info[path]/$file"; - } - else if (file_exists(DRUPAL_ROOT . "/$file")) { - require_once DRUPAL_ROOT . "/$plugin_info[path]/$file"; - } - $already_done[$owner][$api][$module] = TRUE; - } - } - - return $info; -} - -/** - * Fetch a group of plugins by name. - * - * @param $module - * The name of the module that utilizes this plugin system. It will be - * used to call hook_ctools_plugin_$plugin() to get more data about the plugin. - * @param $type - * The type identifier of the plugin. - * @param $id - * If specified, return only information about plugin with this identifier. - * The system will do its utmost to load only plugins with this id. - * - * @return - * An array of information arrays about the plugins received. The contents - * of the array are specific to the plugin. - */ -function ctools_get_plugins($module, $type, $id = NULL) { - // Store local caches of plugins and plugin info so we don't have to do full - // lookups everytime. - $plugins = &drupal_static('ctools_plugins', array()); - $info = ctools_plugin_get_plugin_type_info(); - - // Bail out noisily if an invalid module/type combination is requested. - if (!isset($info[$module][$type])) { - watchdog('ctools', 'Invalid plugin module/type combination requested: module @module and type @type', array('@module' => $module, '@type' => $type), WATCHDOG_ERROR); - return array(); - } - - // Make sure our plugins array is populated. - if (!isset($plugins[$module][$type])) { - $plugins[$module][$type] = array(); - } - - // Attempt to shortcut this whole piece of code if we already have - // the requested plugin: - if ($id && array_key_exists($id, $plugins[$module][$type])) { - return $plugins[$module][$type][$id]; - } - - // Store the status of plugin loading. If a module plugin type pair is true, - // then it is fully loaded and no searching or setup needs to be done. - $setup = &drupal_static('ctools_plugin_setup', array()); - - // We assume we don't need to build a cache. - $build_cache = FALSE; - - // If the plugin info says this can be cached, check cache first. - if ($info[$module][$type]['cache'] && empty($setup[$module][$type])) { - $cache = cache_get("plugins:$module:$type", $info[$module][$type]['cache table']); - - if (!empty($cache->data)) { - // Cache load succeeded so use the cached plugin list. - $plugins[$module][$type] = $cache->data; - // Set $setup to true so we know things where loaded. - $setup[$module][$type] = TRUE; - } - else { - // Cache load failed so store that we need to build and write the cache. - $build_cache = TRUE; - } - } - - // Always load all hooks if we need them. Note we only need them now if the - // plugin asks for them. We can assume that if we have plugins we've already - // called the global hook. - if (!empty($info[$module][$type]['use hooks']) && empty($plugins[$module][$type])) { - $plugins[$module][$type] = ctools_plugin_load_hooks($info[$module][$type]); - } - - // Then see if we should load all files. We only do this if we - // want a list of all plugins or there was a cache miss. - if (empty($setup[$module][$type]) && ($build_cache || !$id)) { - $setup[$module][$type] = TRUE; - $plugins[$module][$type] = array_merge($plugins[$module][$type], ctools_plugin_load_includes($info[$module][$type])); - // If the plugin can have child plugins, and we're loading all plugins, - // go through the list of plugins we have and find child plugins. - if (!$id && !empty($info[$module][$type]['child plugins'])) { - // If a plugin supports children, go through each plugin and ask. - $temp = array(); - foreach ($plugins[$module][$type] as $name => $plugin) { - if (!empty($plugin['get children']) && function_exists($plugin['get children'])) { - $temp = array_merge($plugin['get children']($plugin, $name), $temp); - } - else { - $temp[$name] = $plugin; - } - } - $plugins[$module][$type] = $temp; - } - } - - - // If we were told earlier that this is cacheable and the cache was - // empty, give something back. - if ($build_cache) { - cache_set("plugins:$module:$type", $plugins[$module][$type], $info[$module][$type]['cache table']); - } - - // If no id was requested, we are finished here: - if (!$id) { - // Use array_filter because looking for unknown plugins could cause NULL - // entries to appear in the list later. - return array_filter($plugins[$module][$type]); - } - - // Check to see if we need to look for the file - if (!array_key_exists($id, $plugins[$module][$type])) { - // If we can have child plugins, check to see if the plugin name is in the - // format of parent:child and break it up if it is. - if (!empty($info[$module][$type]['child plugins']) && strpos($id, ':') !== FALSE) { - list($parent, $child) = explode(':', $id, 2); - } - else { - $parent = $id; - } - - if (!array_key_exists($parent, $plugins[$module][$type])) { - $result = ctools_plugin_load_includes($info[$module][$type], $parent); - // Set to either what was returned or NULL. - $plugins[$module][$type][$parent] = isset($result[$parent]) ? $result[$parent] : NULL; - } - - // If we are looking for a child, and have the parent, ask the parent for the child. - if (!empty($child) && !empty($plugins[$module][$type][$parent]) && function_exists($plugins[$module][$type][$parent]['get child'])) { - $plugins[$module][$type][$id] = $plugins[$module][$type][$parent]['get child']($plugins[$module][$type][$parent], $parent, $child); - } - } - - // At this point we should either have the plugin, or a NULL. - return $plugins[$module][$type][$id]; -} - -/** - * Return the full list of plugin type info for all plugin types registered in - * the current system. - * - * This function manages its own cache getting/setting, and should always be - * used as the way to initially populate the list of plugin types. Make sure you - * call this function to properly populate the ctools_plugin_type_info static - * variable. - * - * @return array - * A multilevel array of plugin type info, the outer array keyed on module - * name and each inner array keyed on plugin type name. - */ -function ctools_plugin_get_plugin_type_info($flush = FALSE) { - $info_loaded = &drupal_static('ctools_plugin_type_info_loaded', FALSE); - $all_type_info = &drupal_static('ctools_plugin_type_info', array()); - - // Only trigger info loading once. - if ($info_loaded && !$flush) { - return $all_type_info; - } - $info_loaded = TRUE; - - $cache = cache_get('ctools_plugin_type_info'); - if (!empty($cache->data) && !$flush) { - // Plugin type info cache is warm, use it. - $all_type_info = $cache->data; - } - else { - // Cache expired, refill it. - foreach (module_implements('ctools_plugin_type') as $module) { - $module_infos = array(); - $function = $module . '_ctools_plugin_type'; - $module_infos = $function(); - - foreach ($module_infos as $plugin_type_name => $plugin_type_info) { - // Apply defaults. Array addition will not overwrite pre-existing keys. - $plugin_type_info += array( - 'module' => $module, - 'type' => $plugin_type_name, - 'cache' => FALSE, - 'cache table' => 'cache', - 'classes' => array(), - 'use hooks' => FALSE, - 'defaults' => array(), - 'process' => '', - 'extension' => 'inc', - 'info file' => FALSE, - 'hook' => $module . '_' . $plugin_type_name, - 'load themes' => FALSE, - ); - $all_type_info[$module][$plugin_type_name] = $plugin_type_info; - } - } - cache_set('ctools_plugin_type_info', $all_type_info); - } - - return $all_type_info; -} - -/** - * Reset all static caches that affect the result of ctools_get_plugins(). - */ -function ctools_get_plugins_reset() { - drupal_static_reset('ctools_plugin_setup'); - drupal_static_reset('ctools_plugin_load_includes'); - drupal_static_reset('ctools_plugin_api_info'); -} - -/** - * Load plugins from a directory. - * - * @param $info - * The plugin info as returned by ctools_plugin_get_info() - * @param $file - * The file to load if we're looking for just one particular plugin. - * - * @return - * An array of information created for this plugin. - */ -function ctools_plugin_load_includes($info, $filename = NULL) { - // Keep a static array so we don't hit drupal_system_listing more than necessary. - $all_files = &drupal_static(__FUNCTION__, array()); - - // store static of plugin arrays for reference because they can't be reincluded. - static $plugin_arrays = array(); - - // If we're being asked for all plugins of a type, skip any caching - // we may have done because this is an admin task and it's ok to - // spend the extra time. - if (!isset($filename)) { - $all_files[$info['module']][$info['type']] = NULL; - } - - if (!isset($all_files[$info['module']][$info['type']])) { - // If a filename was set, we will try to load our list of files from - // cache. This is considered normal operation and we try to reduce - // the time spent finding files. - if (isset($filename)) { - $cache = cache_get("ctools_plugin_files:$info[module]:$info[type]"); - if ($cache) { - $all_files[$info['module']][$info['type']] = $cache->data; - } - } - - if (!isset($all_files[$info['module']][$info['type']])) { - $all_files[$info['module']][$info['type']] = array(); - // Load all our plugins. - $directories = ctools_plugin_get_directories($info); - $extension = empty($info['info file']) ? $info['extension'] : 'info'; - - foreach ($directories as $module => $path) { - $all_files[$info['module']][$info['type']][$module] = drupal_system_listing('/\.' . $extension . '$/', $path, 'name', 0); - } - - cache_set("ctools_plugin_files:$info[module]:$info[type]", $all_files[$info['module']][$info['type']]); - } - } - $file_list = $all_files[$info['module']][$info['type']]; - $plugins = array(); - - // Iterate through all the plugin .inc files, load them and process the hook - // that should now be available. - foreach (array_filter($file_list) as $module => $files) { - if ($filename) { - $files = isset($files[$filename]) ? array($filename => $files[$filename]) : array(); - } - foreach ($files as $file) { - if (!empty($info['info file'])) { - // Parse a .info file - $result = ctools_plugin_process_info($info, $module, $file); - } - else { - // Parse a hook. - $plugin = NULL; // ensure that we don't have something leftover from earlier. - - if (isset($plugin_arrays[$file->uri])) { - $identifier = $plugin_arrays[$file->uri]; - } - else { - - require_once DRUPAL_ROOT . '/' . $file->uri; - // .inc files have a special format for the hook identifier. - // For example, 'foo.inc' in the module 'mogul' using the plugin - // whose hook is named 'borg_type' should have a function named (deep breath) - // mogul_foo_borg_type() - - // If, however, the .inc file set the quasi-global $plugin array, we - // can use that and not even call a function. Set the $identifier - // appropriately and ctools_plugin_process() will handle it. - if (isset($plugin)) { - $plugin_arrays[$file->uri] = $plugin; - $identifier = $plugin; - } - else { - $identifier = $module . '_' . $file->name; - } - } - - $result = ctools_plugin_process($info, $module, $identifier, dirname($file->uri), basename($file->uri), $file->name); - } - if (is_array($result)) { - $plugins = array_merge($plugins, $result); - } - } - } - return $plugins; -} - -/** - * Get a list of directories to search for plugins of the given type. - * - * This utilizes hook_ctools_plugin_directory() to determine a complete list of - * directories. Only modules that implement this hook and return a string - * value will have their directories included. - * - * @param $info - * The $info array for the plugin as returned by ctools_plugin_get_info(). - * - * @return array $directories - * An array of directories to search. - */ -function ctools_plugin_get_directories($info) { - $directories = array(); - - foreach (module_implements('ctools_plugin_directory') as $module) { - $function = $module . '_ctools_plugin_directory'; - $result = $function($info['module'], $info['type']); - if ($result && is_string($result)) { - $directories[$module] = drupal_get_path('module', $module) . '/' . $result; - } - } - - if (!empty($info['load themes'])) { - $themes = _ctools_list_themes(); - foreach ($themes as $name => $theme) { - if (!empty($theme->info['plugins'][$info['module']][$info['type']])) { - $directories[$name] = drupal_get_path('theme', $name) . '/' . $theme->info['plugins'][$info['module']][$info['type']]; - } - } - } - return $directories; -} - -/** - * Helper function to build a ctools-friendly list of themes capable of - * providing plugins. - * - * @return array $themes - * A list of themes that can act as plugin providers, sorted parent-first with - * the active theme placed last. - */ -function _ctools_list_themes() { - static $themes; - if (is_null($themes)) { - $current = variable_get('theme_default', FALSE); - $themes = $active = array(); - $all_themes = list_themes(); - foreach ($all_themes as $name => $theme) { - // Only search from active themes - if (empty($theme->status) && $theme->name != $current) { - continue; - } - $active[$name] = $theme; - // Prior to drupal 6.14, $theme->base_themes does not exist. Build it. - if (!isset($theme->base_themes) && !empty($theme->base_theme)) { - $active[$name]->base_themes = ctools_find_base_themes($all_themes, $name); - } - } - - // Construct a parent-first list of all themes - foreach ($active as $name => $theme) { - $base_themes = isset($theme->base_themes) ? $theme->base_themes : array(); - $themes = array_merge($themes, $base_themes, array($name => $theme->info['name'])); - } - // Put the actual theme info objects into the array - foreach (array_keys($themes) as $name) { - $themes[$name] = $all_themes[$name]; - } - - // Make sure the current default theme always gets the last word - if ($current_key = array_search($current, array_keys($themes))) { - $themes += array_splice($themes, $current_key, 1); - } - } - return $themes; -} - - -/** - * Find all the base themes for the specified theme. - * - * Themes can inherit templates and function implementations from earlier themes. - * - * NOTE: this is a verbatim copy of system_find_base_themes(), which was not - * implemented until 6.14. It is included here only as a fallback for outdated - * versions of drupal core. - * - * @param $themes - * An array of available themes. - * @param $key - * The name of the theme whose base we are looking for. - * @param $used_keys - * A recursion parameter preventing endless loops. - * @return - * Returns an array of all of the theme's ancestors; the first element's value - * will be NULL if an error occurred. - */ -function ctools_find_base_themes($themes, $key, $used_keys = array()) { - $base_key = $themes[$key]->info['base theme']; - // Does the base theme exist? - if (!isset($themes[$base_key])) { - return array($base_key => NULL); - } - - $current_base_theme = array($base_key => $themes[$base_key]->info['name']); - - // Is the base theme itself a child of another theme? - if (isset($themes[$base_key]->info['base theme'])) { - // Do we already know the base themes of this theme? - if (isset($themes[$base_key]->base_themes)) { - return $themes[$base_key]->base_themes + $current_base_theme; - } - // Prevent loops. - if (!empty($used_keys[$base_key])) { - return array($base_key => NULL); - } - $used_keys[$base_key] = TRUE; - return ctools_find_base_themes($themes, $base_key, $used_keys) + $current_base_theme; - } - // If we get here, then this is our parent theme. - return $current_base_theme; -} - - -/** - * Load plugin info for the provided hook; this is handled separately from - * plugins from files. - * - * @param $info - * The info array about the plugin as created by ctools_plugin_get_info() - * - * @return - * An array of info supplied by any hook implementations. - */ -function ctools_plugin_load_hooks($info) { - $hooks = array(); - foreach (module_implements($info['hook']) as $module) { - $result = ctools_plugin_process($info, $module, $module, drupal_get_path('module', $module)); - if (is_array($result)) { - $hooks = array_merge($hooks, $result); - } - } - return $hooks; -} - -/** - * Process a single hook implementation of a ctools plugin. - * - * @param $info - * The $info array about the plugin as returned by ctools_plugin_get_info() - * @param $module - * The module that implements the plugin being processed. - * @param $identifier - * The plugin identifier, which is used to create the name of the hook - * function being called. - * @param $path - * The path where files utilized by this plugin will be found. - * @param $file - * The file that was loaded for this plugin, if it exists. - * @param $base - * The base plugin name to use. If a file was loaded for the plugin, this - * is the plugin to assume must be present. This is used to automatically - * translate the array to make the syntax more friendly to plugin - * implementors. - */ -function ctools_plugin_process($info, $module, $identifier, $path, $file = NULL, $base = NULL) { - if (is_array($identifier)) { - $result = $identifier; - } - else { - $function = $identifier . '_' . $info['hook']; - if (!function_exists($function)) { - return NULL; - } - $result = $function(); - if (!isset($result) || !is_array($result)) { - return NULL; - } - } - - // Automatically convert to the proper format that lets plugin implementations - // not nest arrays as deeply as they used to, but still support the older - // format where they do: - if ($base && (!isset($result[$base]) || !is_array($result[$base]))) { - $result = array($base => $result); - } - - return _ctools_process_data($result, $info, $module, $path, $file); -} - -/** - * Fill in default values and run hooks for data loaded for one or - * more plugins. - */ -function _ctools_process_data($result, $plugin_type_info, $module, $path, $file) { - // Fill in global defaults. - foreach ($result as $name => $plugin) { - $result[$name] += array( - 'module' => $module, - 'name' => $name, - 'path' => $path, - 'file' => $file, - 'plugin module' => $plugin_type_info['module'], - 'plugin type' => $plugin_type_info['type'], - ); - - // Fill in plugin-specific defaults, if they exist. - if (!empty($plugin_type_info['defaults'])) { - if (is_array($plugin_type_info['defaults'])) { - $result[$name] += $plugin_type_info['defaults']; - } - } - - // Allow the plugin owner to do additional processing. - if (!empty($plugin_type_info['process']) && $function = ctools_plugin_get_function($plugin_type_info, 'process')) { - $function($result[$name], $plugin_type_info); - } - } - return $result; -} - - -/** - * Process an info file for plugin information, rather than a hook. - */ -function ctools_plugin_process_info($info, $module, $file) { - $result = drupal_parse_info_file($file->uri); - if ($result) { - $result = array($file->name => $result); - return _ctools_process_data($result, $info, $module, dirname($file->uri), basename($file->uri)); - } -} - -/** - * Ask a module for info about a particular plugin type. - */ -function ctools_plugin_get_info($module, $type) { - $all_info = ctools_plugin_get_plugin_type_info(); - return isset($all_info[$module][$type]) ? $all_info[$module][$type] : array(); -} - -/** - * Get a function from a plugin, if it exists. If the plugin is not already - * loaded, try ctools_plugin_load_function() instead. - * - * @param $plugin_definition - * The loaded plugin type. - * @param $function_name - * The identifier of the function. For example, 'settings form'. - * - * @return - * The actual name of the function to call, or NULL if the function - * does not exist. - */ -function ctools_plugin_get_function($plugin_definition, $function_name) { - // If cached the .inc file may not have been loaded. require_once is quite safe - // and fast so it's okay to keep calling it. - if (isset($plugin_definition['file'])) { - // Plugins that are loaded from info files have the info file as - // $plugin['file']. Don't try to run those. - $info = ctools_plugin_get_info($plugin_definition['plugin module'], $plugin_definition['plugin type']); - if (empty($info['info file'])) { - require_once DRUPAL_ROOT . '/' . $plugin_definition['path'] . '/' . $plugin_definition['file']; - } - } - - if (!isset($plugin_definition[$function_name])) { - return; - } - - if (is_array($plugin_definition[$function_name]) && isset($plugin_definition[$function_name]['function'])) { - $function = $plugin_definition[$function_name]['function']; - if (isset($plugin_definition[$function_name]['file'])) { - $file = $plugin_definition[$function_name]['file']; - if (isset($plugin_definition[$function_name]['path'])) { - $file = $plugin_definition[$function_name]['path'] . '/' . $file; - } - require_once DRUPAL_ROOT . '/' . $file; - } - } - else { - $function = $plugin_definition[$function_name]; - } - - if (function_exists($function)) { - return $function; - } -} - -/** - * Load a plugin and get a function name from it, returning success only - * if the function exists. - * - * @param $module - * The module that owns the plugin type. - * @param $type - * The type of plugin. - * @param $id - * The id of the specific plugin to load. - * @param $function_name - * The identifier of the function. For example, 'settings form'. - * - * @return - * The actual name of the function to call, or NULL if the function - * does not exist. - */ -function ctools_plugin_load_function($module, $type, $id, $function_name) { - $plugin = ctools_get_plugins($module, $type, $id); - return ctools_plugin_get_function($plugin, $function_name); -} - -/** - * Get a class from a plugin, if it exists. If the plugin is not already - * loaded, try ctools_plugin_load_class() instead. - * - * @param $plugin_definition - * The loaded plugin type. - * @param $class_name - * The identifier of the class. For example, 'handler'. - * - * @return - * The actual name of the class to call, or NULL if the class does not exist. - */ -function ctools_plugin_get_class($plugin_definition, $class_name) { - // If cached the .inc file may not have been loaded. require_once is quite safe - // and fast so it's okay to keep calling it. - if (isset($plugin_definition['file'])) { - // Plugins that are loaded from info files have the info file as - // $plugin['file']. Don't try to run those. - $info = ctools_plugin_get_info($plugin_definition['plugin module'], $plugin_definition['plugin type']); - if (empty($info['info file'])) { - require_once DRUPAL_ROOT . '/' . $plugin_definition['path'] . '/' . $plugin_definition['file']; - } - } - - $return = FALSE; - if (!isset($plugin_definition[$class_name])) { - return; - } - else if (is_string($plugin_definition[$class_name])) { - // Plugin uses the string form shorthand. - $return = $plugin_definition[$class_name]; - } - else if (isset($plugin_definition[$class_name]['class'])) { - // Plugin uses the verbose array form. - $return = $plugin_definition[$class_name]['class']; - } - // @todo consider adding an else {watchdog(...)} here - - return ($return && class_exists($return)) ? $return : NULL; -} - -/** - * Load a plugin and get a class name from it, returning success only if the - * class exists. - * - * @param $module - * The module that owns the plugin type. - * @param $type - * The type of plugin. - * @param $id - * The id of the specific plugin to load. - * @param $class_name - * The identifier of the class. For example, 'handler'. - * - * @return - * The actual name of the class to call, or NULL if the class does not exist. - */ -function ctools_plugin_load_class($module, $type, $id, $class_name) { - $plugin = ctools_get_plugins($module, $type, $id); - return ctools_plugin_get_class($plugin, $class_name); -} - -/** - * Sort callback for sorting plugins naturally. - * - * Sort first by weight, then by title. - */ -function ctools_plugin_sort($a, $b) { - if (is_object($a)) { - $a = (array) $a; - } - if (is_object($b)) { - $b = (array) $b; - } - - if (empty($a['weight'])) { - $a['weight'] = 0; - } - - if (empty($b['weight'])) { - $b['weight'] = 0; - } - - if ($a['weight'] == $b['weight']) { - return strnatcmp(strtolower($a['title']), strtolower($b['title'])); - } - return ($a['weight'] < $b['weight']) ? -1 : 1; -} diff --git a/includes/registry.inc b/includes/registry.inc deleted file mode 100644 index 9d4328e..0000000 --- a/includes/registry.inc +++ /dev/null @@ -1,77 +0,0 @@ -name] = $module_object; - } - - $all_type_info = ctools_plugin_get_plugin_type_info(TRUE); - foreach ($all_type_info as $module => $plugin_types) { - foreach ($plugin_types as $plugin_type_name => $plugin_type_info) { - if (empty($plugin_type_info['classes'])) { - // This plugin type does not use classes, so skip it. - continue; - } - - // Retrieve the full list of plugins of this type. - $plugins = ctools_get_plugins($module, $plugin_type_name); - foreach ($plugins as $plugin_name => $plugin_definition) { - foreach ($plugin_type_info['classes'] as $class_key) { - if (empty($plugin_definition[$class_key])) { - // Plugin doesn't provide a class for this class key, so skip it. - continue; - } - - if (is_string($plugin_definition[$class_key])) { - // Plugin definition uses the shorthand for defining a class name - // and location; look for the containing file by following naming - // convention. - $path = $plugin_definition['path'] . '/' . $plugin_definition[$class_key] . '.class.php'; - } - else { - // Plugin uses the verbose definition to indicate where its class - // files are. - $class = $plugin_definition[$class_key]['class']; - // Use the filename if it's explicitly set, else follow the naming - // conventions. - $filename = isset($plugin_definition[$class_key]['file']) ? $plugin_definition[$class_key]['file'] : $class . '.class.php'; - $base_path = isset($plugin_definition[$class_key]['path']) ? $plugin_definition[$class_key]['path'] : $plugin_definition['path']; - $path = "$base_path/$filename"; - } - - if (file_exists($path)) { - // If the file exists, add it to the files for registry building. - $files[$path] = array('module' => $plugin_definition['module'], 'weight' => $modules[$plugin_definition['module']]->weight); - } - else { - // Else, watchdog that we've got some erroneous plugin info. - $args = array( - '@plugin' => $plugin_definition['name'], - '@owner' => $module, - '@type' => $plugin_type_name, - '@file' => $path, - '@class' => $class_key, - ); - watchdog('ctools', 'Plugin @plugin of plugin type @owner:@type points to nonexistent file @file for class handler @class.', $args); - } - } - } - } - } -} diff --git a/includes/stylizer.inc b/includes/stylizer.inc deleted file mode 100644 index 7c00b11..0000000 --- a/includes/stylizer.inc +++ /dev/null @@ -1,1655 +0,0 @@ - theme('image', array('path' => $file)), 'title' => $title)); -} - -/** - * Theme the style icon image - */ -function theme_ctools_style_icon($vars) { - $image = $vars['image']; - ctools_add_css('stylizer'); - ctools_add_js('stylizer'); - $output = '
'; - $output .= $vars['image']; - if ($vars['title']) { - $output .= '
' . $vars['title'] . '
'; - } - $output .= '
'; - return $output; -} - -/** - * Add the necessary CSS for a stylizer plugin to the page. - * - * This will check to see if the images directory and the cached CSS - * exists and, if not, will regenerate everything needed. - */ -function ctools_stylizer_add_css($plugin, $settings) { - if (!file_exists(ctools_stylizer_get_image_path($plugin, $settings, FALSE))) { - ctools_stylizer_build_style($plugin, $settings, TRUE); - return; - } - - ctools_include('css'); - $filename = ctools_css_retrieve(ctools_stylizer_get_css_id($plugin, $settings)); - if (!$filename) { - ctools_stylizer_build_style($plugin, $settings, TRUE); - } - else { - drupal_add_css($filename); - } -} - -/** - * Build the files for a stylizer given the proper settings. - */ -function ctools_stylizer_build_style($plugin, $settings, $add_css = FALSE) { - $path = ctools_stylizer_get_image_path($plugin, $settings); - if (!$path) { - return; - } - - $replacements = array(); - - // Set up palette conversions - foreach ($settings['palette'] as $key => $color) { - $replacements['%' . $key ] = $color; - } - - // Process image actions: - if (!empty($plugin['actions'])) { - $processor = new ctools_stylizer_image_processor; - $processor->execute($path, $plugin, $settings); - -// @todo -- there needs to be an easier way to get at this. -// dsm($processor->message_log); - // Add filenames to our conversions. - } - - // Convert and write the CSS file. - $css = file_get_contents($plugin['path'] . '/' . $plugin['css']); - - // Replace %style keyword with our generated class name. - // @todo We need one more unique identifier I think. - $class = ctools_stylizer_get_css_class($plugin, $settings); - $replacements['%style'] = '.' . $class; - - if (!empty($processor) && !empty($processor->paths)) { - foreach ($processor->paths as $file => $image) { - $replacements[$file] = file_create_url($image); - } - } - - if (!empty($plugin['build']) && function_exists($plugin['build'])) { - $plugin['build']($plugin, $settings, $css, $replacements); - } - - $css = strtr($css, $replacements); - ctools_include('css'); - $filename = ctools_css_store(ctools_stylizer_get_css_id($plugin, $settings), $css, FALSE); - - if ($add_css) { - drupal_add_css($filename); - } -} - -/** - * Clean up no longer used files. - * - * To prevent excess clutter in the files directory, this should be called - * whenever a style is going out of use. When being deleted, but also when - * the palette is being changed. - */ -function ctools_stylizer_cleanup_style($plugin, $settings) { - ctools_include('css'); - $path = ctools_stylizer_get_image_path($plugin, $settings, FALSE); - if ($path) { - ctools_stylizer_recursive_delete($path); - } - - ctools_css_clear(ctools_stylizer_get_css_id($plugin, $settings)); -} - -/** - * Recursively delete all files and folders in the specified filepath, then - * delete the containing folder. - * - * Note that this only deletes visible files with write permission. - * - * @param string $path - * A filepath relative to file_directory_path. - */ -function ctools_stylizer_recursive_delete($path) { - if (empty($path)) { - return; - } - - $listing = $path . '/*'; - - foreach (glob($listing) as $file) { - if (is_file($file) === TRUE) { - @unlink($file); - } - elseif (is_dir($file) === TRUE) { - ctools_stylizer_recursive_delete($file); - } - } - - @rmdir($path); -} - -/** - * Get a safe name for the settings. - * - * This uses an md5 of the palette if the name is temporary so - * that multiple temporary styles on the same page can coexist - * safely. - */ -function ctools_stylizer_get_settings_name($settings) { - if ($settings['name'] != '_temporary') { - return $settings['name']; - } - - return $settings['name'] . '-' . md5(serialize($settings['palette'])); -} - -/** - * Get the path where images will be stored for a given style plugin and settings. - * - * This function will make sure the path exists. - */ -function ctools_stylizer_get_image_path($plugin, $settings, $check = TRUE) { - $path = 'public://ctools/style/' . $settings['name'] . '/' . md5(serialize($settings['palette'])); - if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) { - drupal_set_message(t('Unable to create CTools styles cache directory @path. Check the permissions on your files directory.', array('@path' => $path)), 'error'); - return; - } - - return $path; -} - -/** - * Get the id used to cache CSS for a given style plugin and settings. - */ -function ctools_stylizer_get_css_id($plugin, $settings) { - return 'ctools-stylizer:' . $settings['name'] . ':' . md5(serialize($settings['palette'])); -} - -/** - * Get the class to use for a stylizer plugin. - */ -function ctools_stylizer_get_css_class($plugin, $settings) { - ctools_include('cleanstring'); - return ctools_cleanstring($plugin['name'] . '-' . ctools_stylizer_get_settings_name($settings)); -} - -class ctools_stylizer_image_processor { - var $workspace = NULL; - var $name = NULL; - - var $workspaces = array(); - - var $message_log = array(); - var $error_log = array(); - - function execute($path, $plugin, $settings) { - $this->path = $path; - $this->plugin = $plugin; - $this->settings = $settings; - $this->palette = $settings['palette']; - - if (is_string($plugin['actions']) && function_exists($plugin['actions'])) { - $actions = $plugin['actions']($plugin, $settings); - } - else if (is_array($plugin['actions'])) { - $actions = $plugin['actions']; - } - - if (!empty($actions) && is_array($actions)) { - foreach ($plugin['actions'] as $action) { - $command = 'command_' . array_shift($action); - if (method_exists($this, $command)) { - call_user_func_array(array($this, $command), $action); - } - } - } - - // Clean up buffers. - foreach ($this->workspaces as $name => $workspace) { - imagedestroy($this->workspaces[$name]); - } - } - - function log($message, $type = 'normal') { - $this->message_log[] = $message; - if ($type == 'error') { - $this->error_log[] = $message; - } - } - - function set_current_workspace($workspace) { - $this->log("Set current workspace: $workspace"); - $this->workspace = &$this->workspaces[$workspace]; - $this->name = $workspace; - } - - /** - * Create a new workspace. - */ - function command_new($name, $width, $height) { - $this->log("New workspace: $name ($width x $height)"); - // Clean up if there was already a workspace there. - if (isset($this->workspaces[$name])) { - imagedestroy($this->workspaces[$name]); - } - - $this->workspaces[$name] = imagecreatetruecolor($width, $height); - $this->set_current_workspace($name); - - // Make sure the new workspace has a transparent color. - - // Turn off transparency blending (temporarily) - imagealphablending($this->workspace, FALSE); - - // Create a new transparent color for image - $color = imagecolorallocatealpha($this->workspace, 0, 0, 0, 127); - - // Completely fill the background of the new image with allocated color. - imagefill($this->workspace, 0, 0, $color); - - // Restore transparency blending - imagesavealpha($this->workspace, TRUE); - - } - - /** - * Create a new workspace a file. - * - * This will make the new workspace the current workspace. - */ - function command_load($name, $file) { - $this->log("New workspace: $name (from $file)"); - if (!file_exists($file)) { - // Try it relative to the plugin - $file = $this->plugin['path'] . '/' . $file; - if (!file_exists($file)) { - $this->log("Unable to open $file"); - return; - } - } - - // Clean up if there was already a workspace there. - if (isset($this->workspaces[$name])) { - imagedestroy($this->workspaces[$name]); - } - - $this->workspaces[$name] = imagecreatefrompng($file); - $this->set_current_workspace($name); - } - - /** - * Create a new workspace using the properties of an existing workspace - */ - function command_new_from($name, $workspace) { - $this->log("New workspace: $name from existing $workspace"); - if (empty($this->workspaces[$workspace])) { - $this->log("Workspace $name does not exist.", 'error'); - return; - } - - // Clean up if there was already a workspace there. - if (isset($this->workspaces[$name])) { - imagedestroy($this->workspaces[$name]); - } - - $this->workspaces[$name] = $this->new_image($this->workspace[$workspace]); - $this->set_current_workspace($name); - } - - /** - * Set the current workspace. - */ - function command_workspace($name) { - $this->log("Set workspace: $name"); - if (empty($this->workspaces[$name])) { - $this->log("Workspace $name does not exist.", 'error'); - return; - } - $this->set_current_workspace($name); - } - - /** - * Copy the contents of one workspace into the current workspace. - */ - function command_merge_from($workspace, $x = 0, $y = 0) { - $this->log("Merge from: $workspace ($x, $y)"); - if (empty($this->workspaces[$workspace])) { - $this->log("Workspace $name does not exist.", 'error'); - return; - } - - $this->merge($this->workspaces[$workspace], $this->workspace, $x, $y); - } - - function command_merge_to($workspace, $x = 0, $y = 0) { - $this->log("Merge to: $workspace ($x, $y)"); - if (empty($this->workspaces[$workspace])) { - $this->log("Workspace $name does not exist.", 'error'); - return; - } - - $this->merge($this->workspace, $this->workspaces[$workspace], $x, $y); - $this->set_current_workspace($workspace); - } - - /** - * Blend an image into the current workspace. - */ - function command_merge_from_file($file, $x = 0, $y = 0) { - $this->log("Merge from file: $file ($x, $y)"); - if (!file_exists($file)) { - // Try it relative to the plugin - $file = $this->plugin['path'] . '/' . $file; - if (!file_exists($file)) { - $this->log("Unable to open $file"); - return; - } - } - - $source = imagecreatefrompng($file); - - $this->merge($source, $this->workspace, $x, $y); - - imagedestroy($source); - } - - function command_fill($color, $x, $y, $width, $height) { - $this->log("Fill: $color ($x, $y, $width, $height)"); - imagefilledrectangle($this->workspace, $x, $y, $x + $width, $y + $height, _color_gd($this->workspace, $this->palette[$color])); - } - - function command_gradient($from, $to, $x, $y, $width, $height, $direction = 'down') { - $this->log("Gradient: $from to $to ($x, $y, $width, $height) $direction"); - - if ($direction == 'down') { - for ($i = 0; $i < $height; ++$i) { - $color = _color_blend($this->workspace, $this->palette[$from], $this->palette[$to], $i / ($height - 1)); - imagefilledrectangle($this->workspace, $x, $y + $i, $x + $width, $y + $i + 1, $color); - } - } - else { - for ($i = 0; $i < $width; ++$i) { - $color = _color_blend($this->workspace, $this->palette[$from], $this->palette[$to], $i / ($width - 1)); - imagefilledrectangle($this->workspace, $x + $i, $y, $x + $i + 1, $y + $height, $color); - } - } - } - - /** - * Colorize the current workspace with the given location. - * - * This uses simple color blending to colorize the image. - * - * @todo it is possible that this colorize could allow different methods for - * determining how to blend colors? - */ - function command_colorize($color, $x = NULL, $y = NULL, $width = NULL, $height = NULL) { - if (!isset($x)) { - $whole_image = TRUE; - $x = $y = 0; - $width = imagesx($this->workspace); - $height = imagesy($this->workspace); - } - $this->log("Colorize: $color ($x, $y, $width, $height)"); - - $c = _color_unpack($this->palette[$color]); - - imagealphablending($this->workspace, FALSE); - imagesavealpha($this->workspace, TRUE); - - // If PHP 5 use the nice imagefilter which is faster. - if (!empty($whole_image) && version_compare(phpversion(), '5.2.5', '>=') && function_exists('imagefilter')) { - imagefilter($this->workspace, IMG_FILTER_COLORIZE, $c[0], $c[1], $c[2]); - } - else { - // Otherwise we can do it the brute force way. - for ($j = 0; $j < $height; $j++) { - for ($i = 0; $i < $width; $i++) { - $current = imagecolorsforindex($this->workspace, imagecolorat($this->workspace, $i, $j)); - $new_index = imagecolorallocatealpha($this->workspace, $c[0], $c[1], $c[2], $current['alpha']); - imagesetpixel($this->workspace, $i, $j, $new_index); - } - } - } - } - - /** - * Colorize the current workspace with the given location. - * - * This uses a color replacement algorithm that retains luminosity but - * turns replaces all color with the specified color. - */ - function command_hue($color, $x = NULL, $y = NULL, $width = NULL, $height = NULL) { - if (!isset($x)) { - $whole_image = TRUE; - $x = $y = 0; - $width = imagesx($this->workspace); - $height = imagesy($this->workspace); - } - $this->log("Hue: $color ($x, $y, $width, $height)"); - - list($red, $green, $blue) = _color_unpack($this->palette[$color]); - - // We will create a monochromatic palette based on the input color - // which will go from black to white. - - // Input color luminosity: this is equivalent to the position of the - // input color in the monochromatic palette - $luminosity_input = round(255 * ($red + $green + $blue) / 765); // 765 = 255 * 3 - - // We fill the palette entry with the input color at itscorresponding position - $palette[$luminosity_input]['red'] = $red; - $palette[$luminosity_input]['green'] = $green; - $palette[$luminosity_input]['blue'] = $blue; - - // Now we complete the palette, first we'll do it tothe black, and then to - // the white. - - // From input to black - $steps_to_black = $luminosity_input; - - // The step size for each component - if ($steps_to_black) { - $step_size_red = $red / $steps_to_black; - $step_size_green = $green / $steps_to_black; - $step_size_blue = $blue / $steps_to_black; - - for ($i = $steps_to_black; $i >= 0; $i--) { - $palette[$steps_to_black-$i]['red'] = $red - round($step_size_red * $i); - $palette[$steps_to_black-$i]['green'] = $green - round($step_size_green * $i); - $palette[$steps_to_black-$i]['blue'] = $blue - round($step_size_blue * $i); - } - } - - // From input to white - $steps_to_white = 255 - $luminosity_input; - - if ($steps_to_white) { - $step_size_red = (255 - $red) / $steps_to_white; - $step_size_green = (255 - $green) / $steps_to_white; - $step_size_blue = (255 - $blue) / $steps_to_white; - } - else { - $step_size_red=$step_size_green=$step_size_blue=0; - } - - // The step size for each component - for($i = ($luminosity_input + 1); $i <= 255; $i++) { - $palette[$i]['red'] = $red + round($step_size_red * ($i - $luminosity_input)); - $palette[$i]['green'] = $green + round($step_size_green * ($i - $luminosity_input)); - $palette[$i]['blue']= $blue + round($step_size_blue * ($i - $luminosity_input)); - } - - // Go over the specified area of the image and update the colors. - for ($j = $x; $j < $height; $j++) { - for ($i = $y; $i < $width; $i++) { - $color = imagecolorsforindex($this->workspace, imagecolorat($this->workspace, $i, $j)); - $luminosity = round(255 * ($color['red'] + $color['green'] + $color['blue']) / 765); - $new_color = imagecolorallocatealpha($this->workspace, $palette[$luminosity]['red'], $palette[$luminosity]['green'], $palette[$luminosity]['blue'], $color['alpha']); - imagesetpixel($this->workspace, $i, $j, $new_color); - } - } - } - - /** - * Take a slice out of the current workspace and save it as an image. - */ - function command_slice($file, $x = NULL, $y = NULL, $width = NULL, $height = NULL) { - if (!isset($x)) { - $x = $y = 0; - $width = imagesx($this->workspace); - $height = imagesy($this->workspace); - } - - $this->log("Slice: $file ($x, $y, $width, $height)"); - - $base = basename($file); - $image = $this->path . '/' . $base; - - $slice = $this->new_image($this->workspace, $width, $height); - imagecopy($slice, $this->workspace, 0, 0, $x, $y, $width, $height); - - // Make sure alphas are saved: - imagealphablending($slice, FALSE); - imagesavealpha($slice, TRUE); - - // Save image. - $temp_name = drupal_tempnam('temporary://', 'file'); - - imagepng($slice, drupal_realpath($temp_name)); - file_unmanaged_move($temp_name, $image); - imagedestroy($slice); - - // Set standard file permissions for webserver-generated files - @chmod(realpath($image), 0664); - - $this->paths[$file] = $image; - } - - /** - * Prepare a new image for being copied or worked on, preserving transparency. - */ - function &new_image(&$source, $width = NULL, $height = NULL) { - if (!isset($width)) { - $width = imagesx($source); - } - - if (!isset($height)) { - $height = imagesy($source); - } - - $target = imagecreatetruecolor($width, $height); - imagealphablending($target, FALSE); - imagesavealpha($target, TRUE); - - $transparency_index = imagecolortransparent($source); - - // If we have a specific transparent color - if ($transparency_index >= 0) { - // Get the original image's transparent color's RGB values - $transparent_color = imagecolorsforindex($source, $transparency_index); - - // Allocate the same color in the new image resource - $transparency_index = imagecolorallocate($target, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); - - // Completely fill the background of the new image with allocated color. - imagefill($target, 0, 0, $transparency_index); - - // Set the background color for new image to transparent - imagecolortransparent($target, $transparency_index); - } - // Always make a transparent background color for PNGs that don't have one allocated already - else { - // Create a new transparent color for image - $color = imagecolorallocatealpha($target, 0, 0, 0, 127); - - // Completely fill the background of the new image with allocated color. - imagefill($target, 0, 0, $color); - } - - return $target; - } - - /** - * Merge two images together, preserving alpha transparency. - */ - function merge(&$from, &$to, $x, $y) { - // Blend over template. - $width = imagesx($from); - $height = imagesy($from); - - // Re-enable alpha blending to make sure transparency merges. - imagealphablending($to, TRUE); - imagecopy($to, $from, $x, $y, 0, 0, $width, $height); - imagealphablending($to, FALSE); - } -} - -/** - * Get the cached changes to a given task handler. - */ -function ctools_stylizer_get_settings_cache($name) { - ctools_include('object-cache'); - return ctools_object_cache_get('ctools_stylizer_settings', $name); -} - -/** - * Store changes to a task handler in the object cache. - */ -function ctools_stylizer_set_settings_cache($name, $settings) { - ctools_include('object-cache'); - ctools_object_cache_set('ctools_stylizer_settings', $name, $settings); -} - -/** - * Remove an item from the object cache. - */ -function ctools_stylizer_clear_settings_cache($name) { - ctools_include('object-cache'); - ctools_object_cache_clear('ctools_stylizer_settings', $name); -} - -/** - * Add a new style of the specified type. - */ -function ctools_stylizer_edit_style(&$info, $js, $step = NULL) { - $name = '::new'; - $form_info = array( - 'id' => 'ctools_stylizer_edit_style', - 'path' => $info['path'], - 'show trail' => TRUE, - 'show back' => TRUE, - 'show return' => FALSE, - 'next callback' => 'ctools_stylizer_edit_style_next', - 'finish callback' => 'ctools_stylizer_edit_style_finish', - 'return callback' => 'ctools_stylizer_edit_style_finish', - 'cancel callback' => 'ctools_stylizer_edit_style_cancel', - 'forms' => array( - 'choose' => array( - 'form id' => 'ctools_stylizer_edit_style_form_choose', - ), - ), - ); - - if (empty($info['settings'])) { - $form_info['order'] = array( - 'choose' => t('Select base style'), - ); - if (empty($step)) { - $step = 'choose'; - } - - if ($step != 'choose') { - $cache = ctools_stylizer_get_settings_cache($name); - if (!$cache) { - $output = t('Missing settings cache.'); - if ($js) { - return ctools_modal_form_render($form_state, $output); - } - else { - return $output; - } - } - - if (!empty($cache['owner settings'])) { - $info['owner settings'] = $cache['owner settings']; - } - $settings = $cache['settings']; - } - else { - $settings = array( - 'name' => '_temporary', - 'style_base' => NULL, - 'palette' => array(), - ); - ctools_stylizer_clear_settings_cache($name); - } - $op = 'add'; - } - else { - $cache = ctools_stylizer_get_settings_cache($info['settings']['name']); - - if (!empty($cache)) { - if (!empty($cache['owner settings'])) { - $info['owner settings'] = $cache['owner settings']; - } - $settings = $cache['settings']; - } - else { - $settings = $info['settings']; - } - $op = 'edit'; - } - - if (!empty($info['op'])) { - // Allow this to override. Necessary to allow cloning properly. - $op = $info['op']; - } - - $plugin = NULL; - if (!empty($settings['style_base'])) { - $plugin = ctools_get_style_base($settings['style_base']); - $info['type'] = $plugin['type']; - ctools_stylizer_add_plugin_forms($form_info, $plugin, $op); - } - else { - // This is here so the 'finish' button does not show up, and because - // we don't have the selected style we don't know what the next form(s) - // will be. - $form_info['order']['next'] = t('Configure style'); - } - - if (count($form_info['order']) < 2 || $step == 'choose') { - $form_info['show trail'] = FALSE; - } - - $form_state = array( - 'module' => $info['module'], - 'type' => $info['type'], - 'owner info' => &$info, - 'base_style_plugin' => $plugin, - 'name' => $name, - 'step' => $step, - 'settings' => $settings, - 'ajax' => $js, - 'op' => $op, - ); - - if (!empty($info['modal'])) { - $form_state['modal'] = TRUE; - $form_state['title'] = $info['modal']; - $form_state['modal return'] = TRUE; - } - - ctools_include('wizard'); - $output = ctools_wizard_multistep_form($form_info, $step, $form_state); - - if (!empty($form_state['complete'])) { - $info['complete'] = TRUE; - $info['settings'] = $form_state['settings']; - } - - if ($js && !$output && !empty($form_state['clicked_button']['#next'])) { - // We have to do a separate redirect here because the formula that adds - // stuff to the wizard after being chosen hasn't happened. The wizard - // tried to go to the next step which did not exist. - return ctools_stylizer_edit_style($info, $js, $form_state['clicked_button']['#next']); - } - - if ($js) { - return ctools_modal_form_render($form_state, $output); - } - else { - return $output; - } -} - -/** - * Add wizard forms specific to a style base plugin. - * - * The plugin can store forms either as a simple 'edit form' - * => 'form callback' or if it needs the more complicated wizard - * functionality, it can set 'forms' and 'order' with values suitable - * for the wizard $form_info array. - * - * @param &$form_info - * The form info to modify. - * @param $plugin - * The plugin to use. - * @param $op - * Either 'add' or 'edit' so we can get the right forms. - */ -function ctools_stylizer_add_plugin_forms(&$form_info, $plugin, $op) { - if (empty($plugin['forms'])) { - if ($op == 'add' && isset($plugin['add form'])) { - $id = $plugin['add form']; - } - else if (isset($plugin['edit form'])) { - $id = $plugin['edit form']; - } - else { - $id = 'ctools_stylizer_edit_style_form_default'; - } - - $form_info['forms']['settings'] = array( - 'form id' => $id, - ); - $form_info['order']['settings'] = t('Settings'); - } - else { - $form_info['forms'] += $plugin['forms']; - $form_info['order'] += $plugin['order']; - } -} - -/** - * Callback generated when the add style process is finished. - */ -function ctools_stylizer_edit_style_finish(&$form_state) { - $form_state['complete'] = TRUE; - ctools_stylizer_clear_settings_cache($form_state['name']); - - if (isset($form_state['settings']['old_settings'])) { - unset($form_state['settings']['old_settings']); - } -} - -/** - * Callback generated when the 'next' button is clicked. - */ -function ctools_stylizer_edit_style_next(&$form_state) { - $form_state['form_info']['path'] = str_replace('%name', $form_state['name'], $form_state['form_info']['path']); - $form_state['redirect'] = ctools_wizard_get_path($form_state['form_info'], $form_state['clicked_button']['#next']); - - // Update the cache with changes. - $cache = array('settings' => $form_state['settings']); - if (!empty($form_state['owner info']['owner settings'])) { - $cache['owner settings'] = $form_state['owner info']['owner settings']; - } - ctools_stylizer_set_settings_cache($form_state['name'], $cache); -} - -/** - * Callback generated when the 'cancel' button is clicked. - * - * We might have some temporary data lying around. We must remove it. - */ -function ctools_stylizer_edit_style_cancel(&$form_state) { - if (!empty($form_state['name'])) { - ctools_stylizer_clear_settings_cache($form_state['name']); - } -} - -/** - * Choose which plugin to use to create a new style. - */ -function ctools_stylizer_edit_style_form_choose($form, &$form_state) { - $plugins = ctools_get_style_bases(); - $options = array(); - - $categories = array(); - foreach ($plugins as $name => $plugin) { - if ($form_state['module'] == $plugin['module'] && $form_state['type'] == $plugin['type']) { - $categories[$plugin['category']] = $plugin['category']; - $unsorted_options[$plugin['category']][$name] = ctools_stylizer_print_style_icon($plugin, TRUE); - } - } - - asort($categories); - - foreach ($categories as $category) { - $options[$category] = $unsorted_options[$category]; - } - - $form['style_base'] = array( - '#prefix' => '
', - '#suffix' => '
', - ); - - ctools_include('cleanstring'); - foreach ($options as $category => $radios) { - $cat = ctools_cleanstring($category); - $form['style_base'][$cat] = array( - '#prefix' => '
', - '#suffix' => '
', - ); - - foreach ($radios as $key => $choice) { - // Generate the parents as the autogenerator does, so we will have a - // unique id for each radio button. - $form['style_base'][$cat][$key] = array( - '#type' => 'radio', - '#title' => $choice, - '#parents' => array('style_base'), - '#id' => drupal_clean_css_identifier('edit-style-base-' . $key), - '#return_value' => check_plain($key), - ); - } - } - - return $form; -} - -function ctools_stylizer_edit_style_form_choose_submit($form, &$form_state) { - $form_state['settings']['style_base'] = $form_state['values']['style_base']; - - // The 'next' form will show up as 'next' but that's not accurate now that - // we have a style. Figure out what next really is and update. - $plugin = ctools_get_style_base($form_state['settings']['style_base']); - if (empty($plugin['forms'])) { - $form_state['clicked_button']['#next'] = 'settings'; - } - else { - $forms = array_keys($form_info['forms']); - $form_state['clicked_button']['#next'] = array_shift($forms); - } - - // Fill in the defaults for the settings. - if (!empty($plugin['defaults'])) { - // @todo allow a callback - $form_state['settings'] += $plugin['defaults']; - } - - return $form; -} - -/** - * The default stylizer style editing form. - * - * Even when not using this, styles should call through to this form in - * their own edit forms. - */ -function ctools_stylizer_edit_style_form_default($form, &$form_state) { - ctools_add_js('stylizer'); - ctools_add_css('stylizer'); - drupal_add_js('misc/farbtastic/farbtastic.js'); - drupal_add_css('misc/farbtastic/farbtastic.css'); - - $plugin = &$form_state['base_style_plugin']; - $settings = &$form_state['settings']; - - $form['top box'] = array( - '#prefix' => '
', - '#suffix' => '
', - ); - $form['top box']['left'] = array( - '#prefix' => '
', - '#suffix' => '
', - ); - $form['top box']['preview'] = array( - // We have a copy of the $form_state on $form because form theme functions - // do not get $form_state. - '#theme' => 'ctools_stylizer_preview_form', - '#form_state' => &$form_state, - ); - - $form['top box']['preview']['submit'] = array( - '#type' => 'submit', - '#value' => t('Preview'), - ); - - if (!empty($plugin['palette'])) { - $form['top box']['color'] = array( - '#type' => 'fieldset', - '#title' => t('Color scheme'), - '#attributes' => array('id' => 'ctools_stylizer_color_scheme_form', 'class' => array('ctools-stylizer-color-edit')), - '#theme' => 'ctools_stylizer_color_scheme_form', - ); - - $form['top box']['color']['palette']['#tree'] = true; - - foreach ($plugin['palette'] as $key => $color) { - if (empty($settings['palette'][$key])) { - $settings['palette'][$key] = $color['default_value']; - } - - $form['top box']['color']['palette'][$key] = array( - '#type' => 'textfield', - '#title' => $color['label'], - '#default_value' => $settings['palette'][$key], - '#size' => 8, - ); - } - } - - if (!empty($plugin['settings form']) && function_exists($plugin['settings form'])) { - $plugin['settings form']($form, $form_state); - } - - if (!empty($form_state['owner info']['owner form']) && function_exists($form_state['owner info']['owner form'])) { - $form_state['owner info']['owner form']($form, $form_state); - } - - return $form; -} - -/** - * Theme the stylizer color scheme form. - */ -function theme_ctools_stylizer_color_scheme_form($vars) { - $form = &$vars['form']; - $output = ''; - - // Wrapper - $output .= '
'; - - // Color schemes -// $output .= drupal_render($form['scheme']); - - // Palette - $output .= '
'; - foreach (element_children($form['palette']) as $name) { - $output .= render($form['palette'][$name]); - } - $output .= '
'; // palette - - $output .= '
'; // color form - - return $output; -} - -/** - * Theme the stylizer preview form. - */ -function theme_ctools_stylizer_preview_form($vars) { - $form = &$vars['form']; - - $plugin = $form['#form_state']['base_style_plugin']; - $settings = $form['#form_state']['settings']; - - if (!empty($form['#form_state']['settings']['old_settings'])) { - ctools_stylizer_cleanup_style($plugin, $form['#form_state']['settings']['old_settings']); - } - $preview = ''; - if (!empty($plugin['preview'])) { - $preview = $plugin['preview']; - } - else { - $base_types = ctools_get_style_base_types(); - if (!empty($base_types[$plugin['module']][$plugin['type']]['preview'])) { - $preview = $base_types[$plugin['module']][$plugin['type']]['preview']; - } - } - - if (!empty($preview) && function_exists($preview)) { - $output = '
' . t('Preview') . ''; - $output .= $preview($plugin, $settings); - $output .= drupal_render_children($form); - $output .= '
'; - - return $output; - } -} - -function ctools_stylizer_edit_style_form_default_validate($form, &$form_state) { - if (!empty($form_state['owner info']['owner form validate']) && function_exists($form_state['owner info']['owner form validate'])) { - $form_state['owner info']['owner form validate']($form, $form_state); - } - - if (!empty($form_state['base_style_plugin']['settings form validate']) && function_exists($form_state['base_style_plugin']['settings form validate'])) { - $form_state['base_style_plugin']['settings form validate']($form, $form_state); - } -} - -function ctools_stylizer_edit_style_form_default_submit($form, &$form_state) { - // Store old settings for the purposes of cleaning up. - $form_state['settings']['old_settings'] = $form_state['settings']; - $form_state['settings']['palette'] = $form_state['values']['palette']; - - if (!empty($form_state['owner info']['owner form submit']) && function_exists($form_state['owner info']['owner form submit'])) { - $form_state['owner info']['owner form submit']($form, $form_state); - } - - if (!empty($form_state['base_style_plugin']['settings form submit']) && function_exists($form_state['base_style_plugin']['settings form submit'])) { - $form_state['base_style_plugin']['settings form submit']($form, $form_state); - } - - if ($form_state['clicked_button']['#value'] == t('Preview')) { - $form_state['rerender'] = TRUE; - // Update the cache with changes. - if (!empty($form_state['name'])) { - $cache = array('settings' => $form_state['settings']); - if (!empty($form_state['owner info']['owner settings'])) { - $cache['owner settings'] = $form_state['owner info']['owner settings']; - } - ctools_stylizer_set_settings_cache($form_state['name'], $cache); - } - } -} - -// -------------------------------------------------------------------------- -// CSS forms and tools that plugins can use. - -/** - * Font selector form - */ -function ctools_stylizer_font_selector_form(&$form, &$form_state, $label, $settings) { - // Family - $form['#prefix'] = '
'; - $form['#type'] = 'fieldset'; - $form['#title'] = $label; - $form['#suffix'] = '
'; - $form['#tree'] = TRUE; - - $form['font'] = array( - '#title' => t('Font family'), - '#type' => 'select', - '#default_value' => isset($settings['font']) ? $settings['font'] : '', - '#options' => array( - '' => '', - 'Arial, Helvetica, sans-serif' => t('Arial, Helvetica, sans-serif'), - 'Times New Roman, Times, serif' => t('Times New Roman, Times, serif'), - 'Courier New, Courier, monospace' => t('Courier New, Courier, monospace'), - 'Georgia, Times New Roman, Times, serif' => t('Georgia, Times New Roman, Times, serif'), - 'Verdana, Arial, Helvetica, sans-serif' => t('Verdana, Arial, Helvetica, sans-serif'), - 'Geneva, Arial, Helvetica, sans-serif' => t('Geneva, Arial, Helvetica, sans-serif'), - 'Trebuchet MS, Trebuchet, Verdana, sans-serif' => t('Trebuchet MS, Trebuchet, Verdana, sans-serif'), - ), - ); - - // size - $form['size'] = array( - '#title' => t('Size'), - '#type' => 'select', - '#default_value' => isset($settings['size']) ? $settings['size'] : '', - '#options' => array( - '' => '', - 'xx-small' => t('XX-Small'), - 'x-small' => t('X-Small'), - 'small' => t('Small'), - 'medium' => t('Medium'), - 'large' => t('Large'), - 'x-large' => t('X-Large'), - 'xx-large' => t('XX-Large'), - ), - ); - - // letter spacing - $form['letter_spacing'] = array( - '#title' => t('Letter spacing'), - '#type' => 'select', - '#default_value' => isset($settings['letter_spacing']) ? $settings['letter_spacing'] : '', - '#options' => array( - '' => '', - "-10px" => '10px', - "-9px" => '9px', - "-8px" => '8px', - "-7px" => '7px', - "-6px" => '6px', - "-5px" => '5px', - "-4px" => '4px', - "-3px" => '3px', - "-2px" => '2px', - "-1px" => '1px', - "0" => '0', - "1px" => '1px', - "2px" => '2px', - "3px" => '3px', - "4px" => '4px', - "5px" => '5px', - "6px" => '6px', - "7px" => '7px', - "8px" => '8px', - "9px" => '9px', - "10px" => '10px', - "11px" => '11px', - "12px" => '12px', - "13px" => '13px', - "14px" => '14px', - "15px" => '15px', - "16px" => '16px', - "17px" => '17px', - "18px" => '18px', - "19px" => '19px', - "20px" => '20px', - "21px" => '21px', - "22px" => '22px', - "23px" => '23px', - "24px" => '24px', - "25px" => '25px', - "26px" => '26px', - "27px" => '27px', - "28px" => '28px', - "29px" => '29px', - "30px" => '30px', - "31px" => '31px', - "32px" => '32px', - "33px" => '33px', - "34px" => '34px', - "35px" => '35px', - "36px" => '36px', - "37px" => '37px', - "38px" => '38px', - "39px" => '39px', - "40px" => '40px', - "41px" => '41px', - "42px" => '42px', - "43px" => '43px', - "44px" => '44px', - "45px" => '45px', - "46px" => '46px', - "47px" => '47px', - "48px" => '48px', - "49px" => '49px', - "50px" => '50px', - ), - ); - - // word space - $form['word_spacing'] = array( - '#title' => t('Word spacing'), - '#type' => 'select', - '#default_value' => isset($settings['word_spacing']) ? $settings['word_spacing'] : '', - '#options' => array( - '' => '', - "-1em" => '-1em', - "-0.95em" => '-0.95em', - "-0.9em" => '-0.9em', - "-0.85em" => '-0.85em', - "-0.8em" => '-0.8em', - "-0.75em" => '-0.75em', - "-0.7em" => '-0.7em', - "-0.65em" => '-0.65em', - "-0.6em" => '-0.6em', - "-0.55em" => '-0.55em', - "-0.5em" => '-0.5em', - "-0.45em" => '-0.45em', - "-0.4em" => '-0.4em', - "-0.35em" => '-0.35em', - "-0.3em" => '-0.3em', - "-0.25em" => '-0.25em', - "-0.2em" => '-0.2em', - "-0.15em" => '-0.15em', - "-0.1em" => '-0.1em', - "-0.05em" => '-0.05em', - "normal" => 'normal', - "0.05em" => '0.05em', - "0.1em" => '0.1em', - "0.15em" => '0.15em', - "0.2em" => '0.2em', - "0.25em" => '0.25em', - "0.3em" => '0.3em', - "0.35em" => '0.35em', - "0.4em" => '0.4em', - "0.45em" => '0.45em', - "0.5em" => '0.5em', - "0.55em" => '0.55em', - "0.6em" => '0.6em', - "0.65em" => '0.65em', - "0.7em" => '0.7em', - "0.75em" => '0.75em', - "0.8em" => '0.8em', - "0.85em" => '0.85em', - "0.9em" => '0.9em', - "0.95em" => '0.95em', - "1em" => '1em', - ), - ); - - // decoration - $form['decoration'] = array( - '#title' => t('Decoration'), - '#type' => 'select', - '#default_value' => isset($settings['decoration']) ? $settings['decoration'] : '', - '#options' => array( - '' => '', - 'none' => t('None'), - 'underline' => t('Underline'), - 'overline' => t('Overline'), - 'line-through' => t('Line-through'), - ), - ); - - // weight - $form['weight'] = array( - '#title' => t('Weight'), - '#type' => 'select', - '#default_value' => isset($settings['weight']) ? $settings['weight'] : '', - '#options' => array( - '' => '', - 'normal' => t('Normal'), - 'bold' => t('Bold'), - 'bolder' => t('Bolder'), - 'lighter' => t('Lighter'), - ), - ); - - // style - $form['style'] = array( - '#title' => t('Style'), - '#type' => 'select', - '#default_value' => isset($settings['style']) ? $settings['style'] : '', - '#options' => array( - '' => '', - 'normal' => t('Normal'), - 'italic' => t('Italic'), - 'oblique' => t('Oblique'), - ), - ); - - // variant - $form['variant'] = array( - '#title' => t('Variant'), - '#type' => 'select', - '#default_value' => isset($settings['variant']) ? $settings['variant'] : '', - '#options' => array( - '' => '', - 'normal' => t('Normal'), - 'small-caps' => t('Small-caps'), - ), - ); - - // case - $form['case'] = array( - '#title' => t('Case'), - '#type' => 'select', - '#default_value' => isset($settings['case']) ? $settings['case'] : '', - '#options' => array( - '' => '', - 'capitalize' => t('Capitalize'), - 'uppercase' => t('Uppercase'), - 'lowercase' => t('Lowercase'), - 'none' => t('None'), - ), - ); - - // alignment - $form['alignment'] = array( - '#title' => t('Align'), - '#type' => 'select', - '#default_value' => isset($settings['alignment']) ? $settings['alignment'] : '', - '#options' => array( - '' => '', - 'justify' => t('Justify'), - 'left' => t('Left'), - 'right' => t('Right'), - 'center' => t('Center'), - ), - ); -} - -/** - * Copy font selector information into the settings - */ -function ctools_stylizer_font_selector_form_submit(&$form, &$form_state, &$values, &$settings) { - $settings = $values; -} - -function ctools_stylizer_font_apply_style(&$stylesheet, $selector, $settings) { - $css = ''; - if (isset($settings['font']) && $settings['font'] !== '') { - $css .= ' font-family: ' . $settings['font'] . ";\n"; - } - - if (isset($settings['size']) && $settings['size'] !== '') { - $css .= ' font-size: ' . $settings['size'] . ";\n"; - } - - if (isset($settings['weight']) && $settings['weight'] !== '') { - $css .= ' font-weight: ' . $settings['weight'] . ";\n"; - } - - if (isset($settings['style']) && $settings['style'] !== '') { - $css .= ' font-style: ' . $settings['style'] . ";\n"; - } - - if (isset($settings['variant']) && $settings['variant'] !== '') { - $css .= ' font-variant: ' . $settings['variant'] . ";\n"; - } - - if (isset($settings['case']) && $settings['case'] !== '') { - $css .= ' text-transform: ' . $settings['case'] . ";\n"; - } - - if (isset($settings['decoration']) && $settings['decoration'] !== '') { - $css .= ' text-decoration: ' . $settings['decoration'] . ";\n"; - } - - if (isset($settings['alignment']) && $settings['alignment'] !== '') { - $css .= ' text-align: ' . $settings['alignment'] . ";\n"; - } - - if (isset($settings['letter_spacing']) && $settings['letter_spacing'] !== '') { - $css .= ' letter-spacing: ' . $settings['letter_spacing'] . ";\n"; - } - - if (isset($settings['word_spacing']) && $settings['word_spacing'] !== '') { - $css .= ' word-spacing: ' . $settings['word_spacing'] . ";\n"; - } - - if ($css) { - $stylesheet .= $selector . " {\n" . $css . "}\n"; - } -} - -/** - * Border selector form - */ -function ctools_stylizer_border_selector_form(&$form, &$form_state, $label, $settings) { - // Family - $form['#prefix'] = '
'; - $form['#type'] = 'fieldset'; - $form['#title'] = $label; - $form['#suffix'] = '
'; - $form['#tree'] = TRUE; - - $form['thickness'] = array( - '#title' => t('Thickness'), - '#type' => 'select', - '#default_value' => isset($settings['thickness']) ? $settings['thickness'] : '', - '#options' => array( - '' => '', - "none" => t('None'), - "1px" => '1px', - "2px" => '2px', - "3px" => '3px', - "4px" => '4px', - "5px" => '5px', - ), - ); - - $form['style'] = array( - '#title' => t('style'), - '#type' => 'select', - '#default_value' => isset($settings['style']) ? $settings['style'] : '', - '#options' => array( - '' => '', - 'solid' => t('Solid'), - 'dotted' => t('Dotted'), - 'dashed' => t('Dashed'), - 'double' => t('Double'), - 'groove' => t('Groove'), - 'ridge' => t('Ridge'), - 'inset' => t('Inset'), - 'outset' => t('Outset'), - ), - ); -} - -/** - * Copy border selector information into the settings - */ -function ctools_stylizer_border_selector_form_submit(&$form, &$form_state, &$values, &$settings) { - $settings = $values; -} - -function ctools_stylizer_border_apply_style(&$stylesheet, $selector, $settings, $color, $which = NULL) { - $border = 'border'; - if ($which) { - $border .= '-' . $which; - } - - $css = ''; - if (isset($settings['thickness']) && $settings['thickness'] !== '') { - if ($settings['thickness'] == 'none') { - $css .= ' ' . $border . ': none'; - } - else { - $css .= ' ' . $border . '-width: ' . $settings['thickness'] . ";\n"; - - if (isset($settings['style']) && $settings['style'] !== '') { - $css .= ' ' . $border . '-style: ' . $settings['style'] . ";\n"; - } - - $css .= ' ' . $border . '-color: ' . $color . ";\n"; - } - } - - if ($css) { - $stylesheet .= $selector . " {\n" . $css . "}\n"; - } - -} - -/** - * padding selector form - */ -function ctools_stylizer_padding_selector_form(&$form, &$form_state, $label, $settings) { - // Family - $form['#prefix'] = '
'; - $form['#type'] = 'fieldset'; - $form['#title'] = $label; - $form['#suffix'] = '
'; - $form['#tree'] = TRUE; - - $options = array( - '' => '', - "0.05em" => '0.05em', - "0.1em" => '0.1em', - "0.15em" => '0.15em', - "0.2em" => '0.2em', - "0.25em" => '0.25em', - "0.3em" => '0.3em', - "0.35em" => '0.35em', - "0.4em" => '0.4em', - "0.45em" => '0.45em', - "0.5em" => '0.5em', - "0.55em" => '0.55em', - "0.6em" => '0.6em', - "0.65em" => '0.65em', - "0.7em" => '0.7em', - "0.75em" => '0.75em', - "0.8em" => '0.8em', - "0.85em" => '0.85em', - "0.9em" => '0.9em', - "0.95em" => '0.95em', - "1.0em" => '1.0em', - "1.05em" => '1.05em', - "1.1em" => '1.1em', - "1.15em" => '1.15em', - "1.2em" => '1.2em', - "1.25em" => '1.25em', - "1.3em" => '1.3em', - "1.35em" => '1.35em', - "1.4em" => '1.4em', - "1.45em" => '1.45em', - "1.5em" => '1.5em', - "1.55em" => '1.55em', - "1.6em" => '1.6em', - "1.65em" => '1.65em', - "1.7em" => '1.7em', - "1.75em" => '1.75em', - "1.8em" => '1.8em', - "1.85em" => '1.85em', - "1.9em" => '1.9em', - "1.95em" => '1.95em', - "2.0em" => '2.0em', - "2.05em" => '2.05em', - "2.1em" => '2.1em', - "2.15em" => '2.15em', - "2.2em" => '2.2em', - "2.25em" => '2.25em', - "2.3em" => '2.3em', - "2.35em" => '2.35em', - "2.4em" => '2.4em', - "2.45em" => '2.45em', - "2.5em" => '2.5em', - "2.55em" => '2.55em', - "2.6em" => '2.6em', - "2.65em" => '2.65em', - "2.7em" => '2.7em', - "2.75em" => '2.75em', - "2.8em" => '2.8em', - "2.85em" => '2.85em', - "2.9em" => '2.9em', - "2.95em" => '2.95em', - "3.0em" => '3.0em', - "3.05em" => '3.05em', - "3.1em" => '3.1em', - "3.15em" => '3.15em', - "3.2em" => '3.2em', - "3.25em" => '3.25em', - "3.3em" => '3.3em', - "3.35em" => '3.35em', - "3.4em" => '3.4em', - "3.45em" => '3.45em', - "3.5em" => '3.5em', - "3.55em" => '3.55em', - "3.6em" => '3.6em', - "3.65em" => '3.65em', - "3.7em" => '3.7em', - "3.75em" => '3.75em', - "3.8em" => '3.8em', - "3.85em" => '3.85em', - "3.9em" => '3.9em', - "3.95em" => '3.95em', - ); - - $form['top'] = array( - '#title' => t('Top'), - '#type' => 'select', - '#default_value' => isset($settings['top']) ? $settings['top'] : '', - '#options' => $options, - ); - - $form['right'] = array( - '#title' => t('Right'), - '#type' => 'select', - '#default_value' => isset($settings['right']) ? $settings['right'] : '', - '#options' => $options, - ); - - $form['bottom'] = array( - '#title' => t('Bottom'), - '#type' => 'select', - '#default_value' => isset($settings['bottom']) ? $settings['bottom'] : '', - '#options' => $options, - ); - - $form['left'] = array( - '#title' => t('Left'), - '#type' => 'select', - '#default_value' => isset($settings['left']) ? $settings['left'] : '', - '#options' => $options, - ); -} - -/** - * Copy padding selector information into the settings - */ -function ctools_stylizer_padding_selector_form_submit(&$form, &$form_state, &$values, &$settings) { - $settings = $values; -} - -function ctools_stylizer_padding_apply_style(&$stylesheet, $selector, $settings) { - $css = ''; - - if (isset($settings['top']) && $settings['top'] !== '') { - $css .= ' padding-top: ' . $settings['top'] . ";\n"; - } - - if (isset($settings['right']) && $settings['right'] !== '') { - $css .= ' padding-right: ' . $settings['right'] . ";\n"; - } - - if (isset($settings['bottom']) && $settings['bottom'] !== '') { - $css .= ' padding-bottom: ' . $settings['bottom'] . ";\n"; - } - - if (isset($settings['left']) && $settings['left'] !== '') { - $css .= ' padding-left: ' . $settings['left'] . ";\n"; - } - - if ($css) { - $stylesheet .= $selector . " {\n" . $css . "}\n"; - } - -} diff --git a/includes/stylizer.theme.inc b/includes/stylizer.theme.inc deleted file mode 100644 index 85346c1..0000000 --- a/includes/stylizer.theme.inc +++ /dev/null @@ -1,28 +0,0 @@ - 'form', - 'file' => 'includes/stylizer.inc', - ); - - $theme['ctools_stylizer_preview_form'] = array( - 'render element' => 'form', - 'file' => 'includes/stylizer.inc', - ); - - $theme['ctools_style_icon'] = array( - 'variables' => array('image' => NULL, 'title' => NULL), - 'file' => 'includes/stylizer.inc', - ); -} - diff --git a/includes/utility.inc b/includes/utility.inc deleted file mode 100644 index 9ef0796..0000000 --- a/includes/utility.inc +++ /dev/null @@ -1,44 +0,0 @@ -uri; - list($tool) = explode('.', $file->name, 2); - - $function = 'ctools_' . str_replace ('-', '_', $tool) . '_' . str_replace('-', '_', $type); - if (function_exists($function)) { - $function($items); - } - } -} - -/** - * Implementation of hook_theme_registry_alter() - */ -function ctools_theme_registry_alter(&$registry) { - // Move this one last last last so it can catch changes made by modules and themes. - $key = array_search('ctools_preprocess_page', $registry['page']['preprocess functions']); - if ($key) { - unset($registry['page']['preprocess functions'][$key]); - } - $registry['page']['preprocess functions'][] = 'ctools_preprocess_page'; -} - diff --git a/includes/wizard.inc b/includes/wizard.inc deleted file mode 100644 index d47d4f0..0000000 --- a/includes/wizard.inc +++ /dev/null @@ -1,515 +0,0 @@ - TRUE with these forms as that validation - * cannot be skipped for the CANCEL button. - * - * @param $form_info - * An array of form info. @todo document the array. - * @param $step - * The current form step. - * @param &$form_state - * The form state array; this is a reference so the caller can get back - * whatever information the form(s) involved left for it. - */ -function ctools_wizard_multistep_form($form_info, $step, &$form_state) { - // allow order array to be optional - if (empty($form_info['order'])) { - foreach($form_info['forms'] as $step_id => $params) { - $form_info['order'][$step_id] = $params['title']; - } - } - - if (!isset($step)) { - $keys = array_keys($form_info['order']); - $step = array_shift($keys); - } - - ctools_wizard_defaults($form_info); - - // If automated caching is enabled, ensure that everything is as it - // should be. - if (!empty($form_info['auto cache'])) { - // If the cache mechanism hasn't been set, default to the simple - // mechanism and use the wizard ID to ensure uniqueness so cache - // objects don't stomp on each other. - if (!isset($form_info['cache mechanism'])) { - $form_info['cache mechanism'] = 'simple::wizard::' . $form_info['id']; - } - - // If not set, default the cache key to the wizard ID. This is often - // a unique ID of the object being edited or similar. - if (!isset($form_info['cache key'])) { - $form_info['cache key'] = $form_info['id']; - } - - // If not set, default the cache location to storage. This is often - // somnething like 'conf'. - if (!isset($form_info['cache location'])) { - $form_info['cache location'] = 'storage'; - } - - // If absolutely nothing was set for the cache area to work on - if (!isset($form_state[$form_info['cache location']])) { - ctools_include('cache'); - $form_state[$form_info['cache location']] = ctools_cache_get($form_info['cache mechanism'], $form_info['cache key']); - } - } - - $form_state['step'] = $step; - $form_state['form_info'] = $form_info; - - // Ensure we have form information for the current step. - if (!isset($form_info['forms'][$step])) { - return; - } - - // Ensure that whatever include file(s) were requested by the form info are - // actually included. - $info = $form_info['forms'][$step]; - - if (!empty($info['include'])) { - if (is_array($info['include'])) { - foreach ($info['include'] as $file) { - require_once DRUPAL_ROOT . '/' . $file; - } - } - else { - require_once DRUPAL_ROOT . '/' . $info['include']; - } - } - - // This tells drupal_build_form to apply our wrapper to the form. It - // will give it buttons and the like. - $form_state['wrapper_callback'] = 'ctools_wizard_wrapper'; - if (!isset($form_state['rerender'])) { - $form_state['rerender'] = FALSE; - } - - $form_state['no_redirect'] = TRUE; - - $output = drupal_build_form($info['form id'], $form_state); - - if (empty($form_state['executed']) || !empty($form_state['rerender'])) { - if (empty($form_state['title']) && !empty($info['title'])) { - $form_state['title'] = $info['title']; - } - - if (!empty($form_state['ajax render'])) { - // Any include files should already be included by this point: - return $form_state['ajax render']($form_state, $output); - } - - // Automatically use the modal tool if set to true. - if (!empty($form_state['modal']) && empty($form_state['modal return'])) { - ctools_include('modal'); - - // This overwrites any previous commands. - $form_state['commands'] = ctools_modal_form_render($form_state, $output); - } - } - - if (!empty($form_state['executed'])) { - // We use the plugins get_function format because it's powerful and - // not limited to just functions. - ctools_include('plugins'); - - if (isset($form_state['clicked_button']['#wizard type'])) { - $type = $form_state['clicked_button']['#wizard type']; - // If we have a callback depending upon the type of button that was - // clicked, call it. - if ($function = ctools_plugin_get_function($form_info, "$type callback")) { - $function($form_state); - } - - // If auto-caching is on, we need to write the cache on next and - // clear the cache on finish. - if (!empty($form_info['auto cache'])) { - if ($type == 'next') { - ctools_include('cache'); - ctools_cache_set($form_info['cache mechanism'], $form_info['cache key'], $form_state[$form_info['cache location']]); - } - elseif ($type == 'finish') { - ctools_include('cache'); - ctools_cache_clear($form_info['cache mechanism'], $form_info['cache key']); - } - } - - // Set a couple of niceties: - if ($type == 'finish') { - $form_state['complete'] = TRUE; - } - - if ($type == 'cancel') { - $form_state['cancel'] = TRUE; - } - - // If the modal is in use, some special code for it: - if (!empty($form_state['modal']) && empty($form_state['modal return'])) { - if ($type != 'next') { - // Automatically dismiss the modal if we're not going to another form. - ctools_include('modal'); - $form_state['commands'][] = ctools_modal_command_dismiss(); - } - } - } - - if (empty($form_state['ajax'])) { - // redirect, if one is set. - if ($form_state['redirect']) { - if (is_array($form_state['redirect'])) { - call_user_func_array('drupal_goto', $form_state['redirect']); - } - else { - drupal_goto($form_state['redirect']); - } - } - } - else if (isset($form_state['ajax next'])) { - // Clear a few items off the form state so we don't double post: - $next = $form_state['ajax next']; - unset($form_state['ajax next']); - unset($form_state['executed']); - unset($form_state['post']); - unset($form_state['next']); - return ctools_wizard_multistep_form($form_info, $next, $form_state); - } - - // If the callbacks wanted to do something besides go to the next form, - // it needs to have set $form_state['commands'] with something that can - // be rendered. - } - - // Render ajax commands if we have any. - if (isset($form_state['ajax']) && isset($form_state['commands']) && empty($form_state['modal return'])) { - return ajax_render($form_state['commands']); - } - - // Otherwise, return the output. - return $output; -} - -/** - * Provide a wrapper around another form for adding multi-step information. - */ -function ctools_wizard_wrapper($form, &$form_state) { - $form_info = &$form_state['form_info']; - $info = $form_info['forms'][$form_state['step']]; - - // Determine the next form from this step. - // Create a form trail if we're supposed to have one. - $trail = array(); - $previous = TRUE; - foreach ($form_info['order'] as $id => $title) { - if ($id == $form_state['step']) { - $previous = FALSE; - $class = 'wizard-trail-current'; - } - elseif ($previous) { - $not_first = TRUE; - $class = 'wizard-trail-previous'; - $form_state['previous'] = $id; - } - else { - $class = 'wizard-trail-next'; - if (!isset($form_state['next'])) { - $form_state['next'] = $id; - } - if (empty($form_info['show trail'])) { - break; - } - } - - if (!empty($form_info['show trail'])) { - if (!empty($form_info['free trail'])) { - // ctools_wizard_get_path() returns results suitable for #redirect - // which can only be directly used in drupal_goto. We have to futz - // with it. - $path = ctools_wizard_get_path($form_info, $id); - $options = array(); - if (!empty($path[1])) { - $options['query'] = $path[1]; - } - if (!empty($path[2])) { - $options['fragment'] = $path[2]; - } - $title = l($title, $path[0], $options); - } - $trail[] = '' . $title . ''; - } - } - - // Display the trail if instructed to do so. - if (!empty($form_info['show trail'])) { - ctools_add_css('wizard'); - $form['ctools_trail'] = array( - '#markup' => theme(array('ctools_wizard_trail__' . $form_info['id'], 'ctools_wizard_trail'), array('trail' => $trail)), - '#weight' => -1000, - ); - } - - if (empty($form_info['no buttons'])) { - // Ensure buttons stay on the bottom. - $form['buttons'] = array( - '#prefix' => '
', - '#suffix' => '
', - '#weight' => 1000, - ); - - $button_attributes = array(); - if (!empty($form_state['ajax']) && empty($form_state['modal'])) { - $button_attributes = array('class' => array('ctools-use-ajax')); - } - - if (!empty($form_info['show back']) && isset($form_state['previous'])) { - $form['buttons']['previous'] = array( - '#type' => 'submit', - '#value' => $form_info['back text'], - '#next' => $form_state['previous'], - '#wizard type' => 'next', - '#weight' => -2000, - '#limit_validation_errors' => array(), - // hardcode the submit so that it doesn't try to save data. - '#submit' => array('ctools_wizard_submit'), - '#attributes' => $button_attributes, - ); - - if (isset($form_info['no back validate']) || isset($info['no back validate'])) { - $form['buttons']['previous']['#validate'] = array(); - } - } - - // If there is a next form, place the next button. - if (isset($form_state['next']) || !empty($form_info['free trail'])) { - $form['buttons']['next'] = array( - '#type' => 'submit', - '#value' => $form_info['next text'], - '#next' => !empty($form_info['free trail']) ? $form_state['step'] : $form_state['next'], - '#wizard type' => 'next', - '#weight' => -1000, - '#attributes' => $button_attributes, - ); - } - - // There are two ways the return button can appear. If this is not the - // end of the form list (i.e, there is a next) then it's "update and return" - // to be clear. If this is the end of the path and there is no next, we - // call it 'Finish'. - - // Even if there is no direct return path (some forms may not want you - // leaving in the middle) the final button is always a Finish and it does - // whatever the return action is. - if (!empty($form_info['show return']) && !empty($form_state['next'])) { - $form['buttons']['return'] = array( - '#type' => 'submit', - '#value' => $form_info['return text'], - '#wizard type' => 'return', - '#attributes' => $button_attributes, - ); - } - else if (empty($form_state['next']) || !empty($form_info['free trail'])) { - $form['buttons']['return'] = array( - '#type' => 'submit', - '#value' => $form_info['finish text'], - '#wizard type' => 'finish', - '#attributes' => $button_attributes, - ); - } - - // If we are allowed to cancel, place a cancel button. - if ((isset($form_info['cancel path']) && !isset($form_info['show cancel'])) || !empty($form_info['show cancel'])) { - $form['buttons']['cancel'] = array( - '#type' => 'submit', - '#value' => $form_info['cancel text'], - '#wizard type' => 'cancel', - // hardcode the submit so that it doesn't try to save data. - '#limit_validation_errors' => array(), - '#submit' => array('ctools_wizard_submit'), - '#attributes' => $button_attributes, - ); - } - - // Set up optional validate handlers. - $form['#validate'] = array(); - if (function_exists($info['form id'] . '_validate')) { - $form['#validate'][] = $info['form id'] . '_validate'; - } - if (isset($info['validate']) && function_exists($info['validate'])) { - $form['#validate'][] = $info['validate']; - } - - // Set up our submit handler after theirs. Since putting something here will - // skip Drupal's autodetect, we autodetect for it. - - // We make sure ours is after theirs so that they get to change #next if - // the want to. - $form['#submit'] = array(); - if (function_exists($info['form id'] . '_submit')) { - $form['#submit'][] = $info['form id'] . '_submit'; - } - if (isset($info['submit']) && function_exists($info['submit'])) { - $form['#submit'][] = $info['submit']; - } - $form['#submit'][] = 'ctools_wizard_submit'; - } - - if (!empty($form_state['ajax'])) { - $params = ctools_wizard_get_path($form_state['form_info'], $form_state['step']); - if (count($params) > 1) { - $url = array_shift($params); - $options = array(); - - $keys = array(0 => 'query', 1 => 'fragment'); - foreach ($params as $key => $value) { - if (isset($keys[$key]) && isset($value)) { - $options[$keys[$key]] = $value; - } - } - - $params = array($url, $options); - } - $form['#action'] = call_user_func_array('url', $params); - } - - if (isset($info['wrapper']) && function_exists($info['wrapper'])) { - $form = $info['wrapper']($form, $form_state); - } - - if (isset($form_info['wrapper']) && function_exists($form_info['wrapper'])) { - $form = $form_info['wrapper']($form, $form_state); - } - return $form; -} - -/** - * On a submit, go to the next form. - */ -function ctools_wizard_submit(&$form, &$form_state) { - if (isset($form_state['clicked_button']['#wizard type'])) { - $type = $form_state['clicked_button']['#wizard type']; - - // if AJAX enabled, we proceed slightly differently here. - if (!empty($form_state['ajax'])) { - if ($type == 'next') { - $form_state['ajax next'] = $form_state['clicked_button']['#next']; - } - } - else { - if ($type == 'cancel' && isset($form_state['form_info']['cancel path'])) { - $form_state['redirect'] = $form_state['form_info']['cancel path']; - } - else if ($type == 'next') { - $form_state['redirect'] = ctools_wizard_get_path($form_state['form_info'], $form_state['clicked_button']['#next']); - } - else if (isset($form_state['form_info']['return path'])) { - $form_state['redirect'] = $form_state['form_info']['return path']; - } - else if ($type == 'finish' && isset($form_state['form_info']['cancel path'])) { - $form_state['redirect'] = $form_state['form_info']['cancel path']; - } - } - } -} - -/** - * Create a path from the form info and a given step. - */ -function ctools_wizard_get_path($form_info, $step) { - if (is_array($form_info['path'])) { - foreach ($form_info['path'] as $id => $part) { - $form_info['path'][$id] = str_replace('%step', $step, $form_info['path'][$id]); - } - return $form_info['path']; - } - else { - return array(str_replace('%step', $step, $form_info['path'])); - } -} - -/** - * Set default parameters and callbacks if none are given. - * Callbacks follows pattern: - * $form_info['id']_$hook - * $form_info['id']_$form_info['forms'][$step_key]_$hook - */ -function ctools_wizard_defaults(&$form_info) { - $hook = $form_info['id']; - $defaults = array( - 'show trail' => FALSE, - 'free trail' => FALSE, - 'show back' => FALSE, - 'show cancel' => FALSE, - 'show return' => FALSE, - 'next text' => t('Continue'), - 'back text' => t('Back'), - 'return text' => t('Update and return'), - 'finish text' => t('Finish'), - 'cancel text' => t('Cancel'), - ); - - if (!empty($form_info['free trail'])) { - $defaults['next text'] = t('Update'); - $defaults['finish text'] = t('Save'); - } - - $form_info = $form_info + $defaults; - // set form callbacks if they aren't defined - foreach($form_info['forms'] as $step => $params) { - if (!$params['form id']) { - $form_callback = $hook . '_' . $step . '_form'; - $form_info['forms'][$step]['form id'] = $form_callback; - } - } - - // set button callbacks - $callbacks = array( - 'back callback' => '_back', - 'next callback' => '_next', - 'return callback' => '_return', - 'cancel callback' => '_cancel', - 'finish callback' => '_finish', - ); - - foreach($callbacks as $key => $callback) { - // never overwrite if explicity defined - if (empty($form_info[$key])) { - $wizard_callback = $hook . $callback; - if (function_exists($wizard_callback)) { - $form_info[$key] = $wizard_callback; - } - } - } -} diff --git a/includes/wizard.theme.inc b/includes/wizard.theme.inc deleted file mode 100644 index 304906c..0000000 --- a/includes/wizard.theme.inc +++ /dev/null @@ -1,25 +0,0 @@ - array('trail' => NULL), - 'file' => 'includes/wizard.theme.inc', - ); -} - -/** - * Themable display of the 'breadcrumb' trail to show the order of the - * forms. - */ -function theme_ctools_wizard_trail($vars) { - $trail = $vars['trail']; - if (!empty($trail)) { - return '
' . implode(' » ', $trail) . '
'; - } -} - diff --git a/js/ajax-responder.js b/js/ajax-responder.js deleted file mode 100644 index 4202118..0000000 --- a/js/ajax-responder.js +++ /dev/null @@ -1,122 +0,0 @@ -/** - * @file - * - * CTools flexible AJAX responder object. - */ - -(function ($) { - /** - * Grab the response from the server and store it. - * - * @todo restore the warm cache functionality - */ - Drupal.CTools.AJAX.warmCache = function () { - // Store this expression for a minor speed improvement. - $this = $(this); - var old_url = $this.attr('href'); - // If we are currently fetching, or if we have fetched this already which is - // ideal for things like pagers, where the previous page might already have - // been seen in the cache. - if ($this.hasClass('ctools-fetching') || Drupal.CTools.AJAX.commandCache[old_url]) { - return false; - } - - // Grab all the links that match this url and add the fetching class. - // This allows the caching system to grab each url once and only once - // instead of grabbing the url once per . - var $objects = $('a[href=' + old_url + ']') - $objects.addClass('ctools-fetching'); - try { - url = old_url.replace(/\/nojs(\/|$)/g, '/ajax$1'); - $.ajax({ - type: "POST", - url: url, - data: { 'js': 1, 'ctools_ajax': 1}, - global: true, - success: function (data) { - Drupal.CTools.AJAX.commandCache[old_url] = data; - $objects.addClass('ctools-cache-warmed').trigger('ctools-cache-warm', [data]); - }, - complete: function() { - $objects.removeClass('ctools-fetching'); - }, - dataType: 'json' - }); - } - catch (err) { - $objects.removeClass('ctools-fetching'); - return false; - } - - return false; - }; - - /** - * Cachable click handler to fetch the commands out of the cache or from url. - */ - Drupal.CTools.AJAX.clickAJAXCacheLink = function () { - $this = $(this); - if ($this.hasClass('ctools-fetching')) { - $this.bind('ctools-cache-warm', function (event, data) { - Drupal.CTools.AJAX.respond(data); - }); - return false; - } - else { - if ($this.hasClass('ctools-cache-warmed') && Drupal.CTools.AJAX.commandCache[$this.attr('href')]) { - Drupal.CTools.AJAX.respond(Drupal.CTools.AJAX.commandCache[$this.attr('href')]); - return false; - } - else { - return Drupal.CTools.AJAX.clickAJAXLink.apply(this); - } - } - }; - - /** - * Find a URL for an AJAX button. - * - * The URL for this gadget will be composed of the values of items by - * taking the ID of this item and adding -url and looking for that - * class. They need to be in the form in order since we will - * concat them all together using '/'. - */ - Drupal.CTools.AJAX.findURL = function(item) { - var url = ''; - var url_class = '.' + $(item).attr('id') + '-url'; - $(url_class).each( - function() { - if (url && $(this).val()) { - url += '/'; - } - url += $(this).val(); - }); - return url; - }; - - - Drupal.CTools.AJAX.commands.attr = function(data) { - $(data.selector).attr(data.name, data.value); - }; - - - Drupal.CTools.AJAX.commands.redirect = function(data) { - if (data.delay > 0) { - setTimeout(function () { - location.href = data.url; - }, data.delay); - } - else { - location.href = data.url; - } - }; - - Drupal.CTools.AJAX.commands.reload = function(data) { - location.reload(); - }; - - Drupal.CTools.AJAX.commands.submit = function(data) { - $(data.selector).submit(); - } - -})(jQuery); diff --git a/js/auto-submit.js b/js/auto-submit.js deleted file mode 100644 index d85a7c4..0000000 --- a/js/auto-submit.js +++ /dev/null @@ -1,74 +0,0 @@ -(function($){ -/** - * To make a form auto submit, all you have to do is 3 things: - * - * ctools_add_js('auto-submit'); - * - * On gadgets you want to auto-submit when changed, add the ctools-auto-submit - * class. With FAPI, add: - * @code - * '#attributes' => array('class' => 'ctools-auto-submit'), - * @endcode - * - * If you want to have auto-submit for every form element, - * add the ctools-auto-submit-full-form to the form. With FAPI, add: - * @code - * '#attributes' => array('class' => 'ctools-auto-submit-full-form'), - * @endcode - * - * Finally, you have to identify which button you want clicked for autosubmit. - * The behavior of this button will be honored if it's ajaxy or not: - * @code - * '#attributes' => array('class' => 'ctools-use-ajax ctools-auto-submit-click'), - * @endcode - * - * Currently only 'select' and 'textfield' types are supported. We probably - * could use additional support for radios and checkboxes. - */ - -Drupal.behaviors.CToolsAutoSubmit = { - attach: function() { - var timeoutID = 0; - - // Bind to any select widgets that will be auto submitted. - $('select.ctools-auto-submit:not(.ctools-auto-submit-processed),.ctools-auto-submit-full-form select:not(.ctools-auto-submit-processed)') - .addClass('.ctools-auto-submit-processed') - .change(function() { - $(this.form).find('.ctools-auto-submit-click').click(); - }); - - // Bind to any textfield widgets that will be auto submitted. - $('input[type=text].ctools-auto-submit:not(.ctools-auto-submit-processed),.ctools-auto-submit-full-form input[type=text]:not(.ctools-auto-submit-processed)') - .addClass('.ctools-auto-submit-processed') - .keyup(function(e) { - var form = this.form; - switch (e.keyCode) { - case 16: // shift - case 17: // ctrl - case 18: // alt - case 20: // caps lock - case 33: // page up - case 34: // page down - case 35: // end - case 36: // home - case 37: // left arrow - case 38: // up arrow - case 39: // right arrow - case 40: // down arrow - case 9: // tab - case 13: // enter - case 27: // esc - return false; - default: - if (!$(form).hasClass('ctools-ajaxing')) { - if ((timeoutID)) { - clearTimeout(timeoutID); - } - - timeoutID = setTimeout(function() { $(form).find('.ctools-auto-submit-click').click(); }, 300); - } - } - }); - } -} -})(jQuery); diff --git a/js/collapsible-div.js b/js/collapsible-div.js deleted file mode 100644 index 2a240ae..0000000 --- a/js/collapsible-div.js +++ /dev/null @@ -1,240 +0,0 @@ -/** - * @file - * Javascript required for a simple collapsible div. - * - * Creating a collapsible div with this doesn't take too much. There are - * three classes necessary: - * - * - ctools-collapsible-container: This is the overall container that will be - * collapsible. This must be a div. - * - ctools-collapsible-handle: This is the title area, and is what will be - * visible when it is collapsed. This can be any block element, such as div - * or h2. - * - ctools-collapsible-content: This is the ocntent area and will only be - * visible when expanded. This must be a div. - * - * Adding 'ctools-collapsible-remember' to the container class will cause the - * state of the container to be stored in a cookie, and remembered from page - * load to page load. This will only work if the container has a unique ID, so - * very carefully add IDs to your containers. - * - * If the class 'ctools-no-container' is placed on the container, the container - * will be the handle. The content will be found by appending '-content' to the - * id of the handle. The ctools-collapsible-handle and - * ctools-collapsible-content classes will not be required in that case, and no - * restrictions on what of data the container is are placed. Like - * ctools-collapsible-remember this requires an id to eist. - * - * The content will be 'open' unless the container class has 'ctools-collapsed' - * as a class, which will cause the container to draw collapsed. - */ - -(function ($) { - // All CTools tools begin with this if they need to use the CTools namespace. - if (!Drupal.CTools) { - Drupal.CTools = {}; - } - - /** - * Object to store state. - * - * This object will remember the state of collapsible containers. The first - * time a state is requested, it will check the cookie and set up the variable. - * If a state has been changed, when the window is unloaded the state will be - * saved. - */ - Drupal.CTools.Collapsible = { - state: {}, - stateLoaded: false, - stateChanged: false, - cookieString: 'ctools-collapsible-state=', - - /** - * Get the current collapsed state of a container. - * - * If set to 1, the container is open. If set to -1, the container is - * collapsed. If unset the state is unknown, and the default state should - * be used. - */ - getState: function (id) { - if (!this.stateLoaded) { - this.loadCookie(); - } - - return this.state[id]; - }, - - /** - * Set the collapsed state of a container for subsequent page loads. - * - * Set the state to 1 for open, -1 for collapsed. - */ - setState: function (id, state) { - if (!this.stateLoaded) { - this.loadCookie(); - } - - this.state[id] = state; - - if (!this.stateChanged) { - this.stateChanged = true; - $(window).unload(this.unload); - } - }, - - /** - * Check the cookie and load the state variable. - */ - loadCookie: function () { - // If there is a previous instance of this cookie - if (document.cookie.length > 0) { - // Get the number of characters that have the list of values - // from our string index. - offset = document.cookie.indexOf(this.cookieString); - - // If its positive, there is a list! - if (offset != -1) { - offset += this.cookieString.length; - var end = document.cookie.indexOf(';', offset); - if (end == -1) { - end = document.cookie.length; - } - - // Get a list of all values that are saved on our string - var cookie = unescape(document.cookie.substring(offset, end)); - - if (cookie != '') { - var cookieList = cookie.split(','); - for (var i = 0; i < cookieList.length; i++) { - var info = cookieList[i].split(':'); - this.state[info[0]] = info[1]; - } - } - } - } - - this.stateLoaded = true; - }, - - /** - * Turn the state variable into a string and store it in the cookie. - */ - storeCookie: function () { - var cookie = ''; - - // Get a list of IDs, saparated by comma - for (i in this.state) { - if (cookie != '') { - cookie += ','; - } - cookie += i + ':' + this.state[i]; - } - - // Save this values on the cookie - document.cookie = this.cookieString + escape(cookie) + ';path=/'; - }, - - /** - * Respond to the unload event by storing the current state. - */ - unload: function() { - Drupal.CTools.Collapsible.storeCookie(); - } - }; - - // Set up an array for callbacks. - Drupal.CTools.CollapsibleCallbacks = []; - Drupal.CTools.CollapsibleCallbacksAfterToggle = []; - - /** - * Bind collapsible behavior to a given container. - */ - Drupal.CTools.bindCollapsible = function () { - var $container = $(this); - - // Allow the specification of the 'no container' class, which means the - // handle and the container can be completely independent. - if ($container.hasClass('ctools-no-container') && $container.attr('id')) { - // In this case, the container *is* the handle and the content is found - // by adding '-content' to the id. Obviously, an id is required. - var handle = $container; - var content = $('#' + $container.attr('id') + '-content'); - } - else { - var handle = $container.children('.ctools-collapsible-handle'); - var content = $container.children('div.ctools-collapsible-content'); - } - - if (content.length) { - // Create the toggle item and place it in front of the toggle. - var toggle = $(''); - handle.before(toggle); - - // If the remember class is set, check to see if we have a remembered - // state stored. - if ($container.hasClass('ctools-collapsible-remember') && $container.attr('id')) { - var state = Drupal.CTools.Collapsible.getState($container.attr('id')); - if (state == 1) { - $container.removeClass('ctools-collapsed'); - } - else if (state == -1) { - $container.addClass('ctools-collapsed'); - } - } - - // If we should start collapsed, do so: - if ($container.hasClass('ctools-collapsed')) { - toggle.toggleClass('ctools-toggle-collapsed'); - content.hide(); - } - - var afterToggle = function () { - if (Drupal.CTools.CollapsibleCallbacksAfterToggle) { - for (i in Drupal.CTools.CollapsibleCallbacksAfterToggle) { - Drupal.CTools.CollapsibleCallbacksAfterToggle[i]($container, handle, content, toggle); - } - } - } - - var clickMe = function () { - if (Drupal.CTools.CollapsibleCallbacks) { - for (i in Drupal.CTools.CollapsibleCallbacks) { - Drupal.CTools.CollapsibleCallbacks[i]($container, handle, content, toggle); - } - } - - // If the container is a table element slideToggle does not do what - // we want, so use toggle() instead. - if ($container.is('table')) { - content.toggle(0, afterToggle); - } - else { - content.slideToggle(100, afterToggle); - } - - toggle.toggleClass('ctools-toggle-collapsed'); - - // If we're supposed to remember the state of this class, do so. - if ($container.hasClass('ctools-collapsible-remember') && $container.attr('id')) { - var state = toggle.hasClass('ctools-toggle-collapsed') ? -1 : 1; - Drupal.CTools.Collapsible.setState($container.attr('id'), state); - } - } - - // Let both the toggle and the handle be clickable. - toggle.click(clickMe); - handle.click(clickMe); - } - }; - - /** - * Support Drupal's 'behaviors' system for binding. - */ - Drupal.behaviors.CToolsCollapsible = { - attach: function(context) { - $('.ctools-collapsible-container:not(.ctools-collapsible-processed)', context) - .each(Drupal.CTools.bindCollapsible) - .addClass('ctools-collapsible-processed'); - } - } -})(jQuery); diff --git a/js/dependent.js b/js/dependent.js deleted file mode 100644 index 3e95848..0000000 --- a/js/dependent.js +++ /dev/null @@ -1,215 +0,0 @@ -/** - * @file - * - * Written by dmitrig01 (Dmitri Gaskin) for CTools; this provides dependent - * visibility for form items in CTools' ajax forms. - * - * To your $form item definition add: - * - '#process' => array('CTools_process_dependency'), - * - Add '#dependency' => array('id-of-form-item' => array(list, of, values, that, - make, this, item, show), - * - * Special considerations: - * - radios are harder. Because Drupal doesn't give radio groups individual ids, - * use 'radio:name-of-radio' - * - * - Checkboxes don't have their own id, so you need to add one in a div - * around the checkboxes via #prefix and #suffix. You actually need to add TWO - * divs because it's the parent that gets hidden. Also be sure to retain the - * 'expand_checkboxes' in the #process array, because the CTools process will - * override it. - */ - -(function ($) { - Drupal.CTools = Drupal.CTools || {}; - Drupal.CTools.dependent = {}; - - Drupal.CTools.dependent.bindings = {}; - Drupal.CTools.dependent.activeBindings = {}; - Drupal.CTools.dependent.activeTriggers = []; - - Drupal.CTools.dependent.inArray = function(array, search_term) { - var i = array.length; - if (i > 0) { - do { - if (array[i] == search_term) { - return true; - } - } while (i--); - } - return false; - } - - - Drupal.CTools.dependent.autoAttach = function() { - // Clear active bindings and triggers. - for (i in Drupal.CTools.dependent.activeTriggers) { - $(Drupal.CTools.dependent.activeTriggers[i]).unbind('change'); - } - Drupal.CTools.dependent.activeTriggers = []; - Drupal.CTools.dependent.activeBindings = {}; - Drupal.CTools.dependent.bindings = {}; - - if (!Drupal.settings.CTools) { - return; - } - - // Iterate through all relationships - for (id in Drupal.settings.CTools.dependent) { - - // Drupal.CTools.dependent.activeBindings[id] is a boolean, - // whether the binding is active or not. Defaults to no. - Drupal.CTools.dependent.activeBindings[id] = 0; - // Iterate through all possible values - for(bind_id in Drupal.settings.CTools.dependent[id].values) { - // This creates a backward relationship. The bind_id is the ID - // of the element which needs to change in order for the id to hide or become shown. - // The id is the ID of the item which will be conditionally hidden or shown. - // Here we're setting the bindings for the bind - // id to be an empty array if it doesn't already have bindings to it - if (!Drupal.CTools.dependent.bindings[bind_id]) { - Drupal.CTools.dependent.bindings[bind_id] = []; - } - // Add this ID - Drupal.CTools.dependent.bindings[bind_id].push(id); - // Big long if statement. - // Drupal.settings.CTools.dependent[id].values[bind_id] holds the possible values - - if (bind_id.substring(0, 6) == 'radio:') { - var trigger_id = "input[name='" + bind_id.substring(6) + "']"; - } - else { - var trigger_id = '#' + bind_id; - } - - Drupal.CTools.dependent.activeTriggers.push(trigger_id); - - if ($(trigger_id).attr('type') == 'checkbox') { - $(trigger_id).siblings('label').addClass('hidden-options'); - } - - var getValue = function(item, trigger) { - if (item.substring(0, 6) == 'radio:') { - var val = $(trigger + ':checked').val(); - } - else { - switch ($(trigger).attr('type')) { - case 'checkbox': - var val = $(trigger).attr('checked') || 0; - - if (val) { - $(trigger).siblings('label').removeClass('hidden-options').addClass('expanded-options'); - } - else { - $(trigger).siblings('label').removeClass('expanded-options').addClass('hidden-options'); - } - - break; - default: - var val = $(trigger).val(); - } - } - return val; - } - - var setChangeTrigger = function(trigger_id, bind_id) { - // Triggered when change() is clicked. - var changeTrigger = function() { - var val = getValue(bind_id, trigger_id); - - for (i in Drupal.CTools.dependent.bindings[bind_id]) { - var id = Drupal.CTools.dependent.bindings[bind_id][i]; - - // Fix numerous errors - if (typeof id != 'string') { - continue; - } - - // This bit had to be rewritten a bit because two properties on the - // same set caused the counter to go up and up and up. - if (!Drupal.CTools.dependent.activeBindings[id]) { - Drupal.CTools.dependent.activeBindings[id] = {}; - } - - if (val != null && Drupal.CTools.dependent.inArray(Drupal.settings.CTools.dependent[id].values[bind_id], val)) { - Drupal.CTools.dependent.activeBindings[id][bind_id] = 'bind'; - } - else { - delete Drupal.CTools.dependent.activeBindings[id][bind_id]; - } - - var len = 0; - for (i in Drupal.CTools.dependent.activeBindings[id]) { - len++; - } - - var object = $('#' + id + '-wrapper'); - if (!object.size()) { - object = $('#' + id).parent(); - } - - if (Drupal.settings.CTools.dependent[id].type == 'disable') { - if (Drupal.settings.CTools.dependent[id].num <= len) { - // Show if the element if criteria is matched - object.attr('disabled', false); - object.addClass('dependent-options'); - object.children().attr('disabled', false); - } - else { - // Otherwise hide. Use css rather than hide() because hide() - // does not work if the item is already hidden, for example, - // in a collapsed fieldset. - object.attr('disabled', true); - object.children().attr('disabled', true); - } - } - else { - if (Drupal.settings.CTools.dependent[id].num <= len) { - // Show if the element if criteria is matched - object.show(0); - } - else { - // Otherwise hide. Use css rather than hide() because hide() - // does not work if the item is already hidden, for example, - // in a collapsed fieldset. - object.css('display', 'none'); - } - } - } - } - - $(trigger_id).change(function() { - // Trigger the internal change function - // the attr('id') is used because closures are more confusing - changeTrigger(trigger_id, bind_id); - }); - // Trigger initial reaction - changeTrigger(trigger_id, bind_id); - } - setChangeTrigger(trigger_id, bind_id); - } - } - } - - Drupal.behaviors.CToolsDependent = { - attach: function (context) { - Drupal.CTools.dependent.autoAttach(); - - // Really large sets of fields are too slow with the above method, so this - // is a sort of hacked one that's faster but much less flexible. - $("select.ctools-master-dependent:not(.ctools-processed)") - .addClass('ctools-processed') - .change(function() { - var val = $(this).val(); - if (val == 'all') { - $('.ctools-dependent-all').show(0); - } - else { - $('.ctools-dependent-all').hide(0); - $('.ctools-dependent-' + val).show(0); - } - }) - .trigger('change'); - } - } -})(jQuery); diff --git a/js/dropdown.js b/js/dropdown.js deleted file mode 100644 index 522f4d5..0000000 --- a/js/dropdown.js +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @file - * Implement a simple, clickable dropdown menu. - * - * See dropdown.theme.inc for primary documentation. - * - * The javascript relies on four classes: - * - The dropdown must be fully contained in a div with the class - * ctools-dropdown. It must also contain the class ctools-dropdown-no-js - * which will be immediately removed by the javascript; this allows for - * graceful degradation. - * - The trigger that opens the dropdown must be an a tag wit hthe class - * ctools-dropdown-link. The href should just be '#' as this will never - * be allowed to complete. - * - The part of the dropdown that will appear when the link is clicked must - * be a div with class ctools-dropdown-container. - * - Finally, ctools-dropdown-hover will be placed on any link that is being - * hovered over, so that the browser can restyle the links. - * - * This tool isn't meant to replace click-tips or anything, it is specifically - * meant to work well presenting menus. - */ - -(function ($) { - Drupal.behaviors.CToolsDropdown = { - attach: function() { - $('div.ctools-dropdown:not(.ctools-dropdown-processed)') - .removeClass('ctools-dropdown-no-js') - .addClass('ctools-dropdown-processed') - .each(function() { - var $dropdown = $(this); - var open = false; - var hovering = false; - var timerID = 0; - - var toggle = function(close) { - // if it's open or we're told to close it, close it. - if (open || close) { - // If we're just toggling it, close it immediately. - if (!close) { - open = false; - $("div.ctools-dropdown-container", $dropdown).slideUp(100); - } - else { - // If we were told to close it, wait half a second to make - // sure that's what the user wanted. - // Clear any previous timer we were using. - if (timerID) { - clearTimeout(timerID); - } - timerID = setTimeout(function() { - if (!hovering) { - open = false; - $("div.ctools-dropdown-container", $dropdown).slideUp(100); - }}, 500); - } - } - else { - // open it. - open = true; - $("div.ctools-dropdown-container", $dropdown) - .animate({height: "show", opacity: "show"}, 100); - } - } - $("a.ctools-dropdown-link", $dropdown).click(function() { - toggle(); - return false; - }); - - $dropdown.hover( - function() { - hovering = true; - }, // hover in - function() { // hover out - hovering = false; - toggle(true); - return false; - }); - // @todo -- just use CSS for this noise. - $("div.ctools-dropdown-container a").hover( - function() { $(this).addClass('ctools-dropdown-hover'); }, - function() { $(this).removeClass('ctools-dropdown-hover'); } - ); - }); - } - } -})(jQuery); diff --git a/js/jump-menu.js b/js/jump-menu.js deleted file mode 100644 index f515c8c..0000000 --- a/js/jump-menu.js +++ /dev/null @@ -1,34 +0,0 @@ - -(function($) { - Drupal.behaviors.CToolsJumpMenu = { - attach: function(context) { - $('.ctools-jump-menu-hide:not(.ctools-jump-menu-processed)') - .addClass('ctools-jump-menu-processed') - .hide(); - - $('.ctools-jump-menu-change:not(.ctools-jump-menu-processed)') - .addClass('ctools-jump-menu-processed') - .change(function() { - var loc = $(this).val(); - if (loc) { - location.href = loc; - } - return false; - }); - - $('.ctools-jump-menu-button:not(.ctools-jump-menu-processed)') - .addClass('ctools-jump-menu-processed') - .click(function() { - // Instead of submitting the form, just perform the redirect. - - // Find our sibling value. - var $select = $(this).parents('form').find('.ctools-jump-menu-select'); - var loc = $select.val(); - if (loc) { - location.href = loc; - } - return false; - }); - } - } -})(jQuery); diff --git a/js/modal.js b/js/modal.js deleted file mode 100644 index 2fbdb5c..0000000 --- a/js/modal.js +++ /dev/null @@ -1,494 +0,0 @@ -/** - * @file - * - * Implement a modal form. - * - * @see modal.inc for documentation. - * - * This javascript relies on the CTools ajax responder. - */ - -(function ($) { - // Make sure our objects are defined. - Drupal.CTools = Drupal.CTools || {}; - Drupal.CTools.Modal = Drupal.CTools.Modal || {}; - - /** - * Display the modal - * - * @todo -- document the settings. - */ - Drupal.CTools.Modal.show = function(choice) { - var opts = {}; - - if (choice && typeof choice == 'string' && Drupal.settings[choice]) { - // This notation guarantees we are actually copying it. - $.extend(true, opts, Drupal.settings[choice]); - } - else if (choice) { - $.extend(true, opts, choice); - } - - var defaults = { - modalTheme: 'CToolsModalDialog', - throbberTheme: 'CToolsModalThrobber', - animation: 'show', - animationSpeed: 'fast', - modalSize: { - type: 'scale', - width: .8, - height: .8, - addWidth: 0, - addHeight: 0, - // How much to remove from the inner content to make space for the - // theming. - contentRight: 25, - contentBottom: 45 - }, - modalOptions: { - opacity: .55, - background: '#fff' - } - }; - - var settings = {}; - $.extend(true, settings, defaults, Drupal.settings.CToolsModal, opts); - - if (Drupal.CTools.Modal.currentSettings && Drupal.CTools.Modal.currentSettings != settings) { - Drupal.CTools.Modal.modal.remove(); - Drupal.CTools.Modal.modal = null; - } - - Drupal.CTools.Modal.currentSettings = settings; - - var resize = function(e) { - // When creating the modal, it actually exists only in a theoretical - // place that is not in the DOM. But once the modal exists, it is in the - // DOM so the context must be set appropriately. - var context = e ? document : Drupal.CTools.Modal.modal; - - if (Drupal.CTools.Modal.currentSettings.modalSize.type == 'scale') { - var width = $(window).width() * Drupal.CTools.Modal.currentSettings.modalSize.width; - var height = $(window).height() * Drupal.CTools.Modal.currentSettings.modalSize.height; - } - else { - var width = Drupal.CTools.Modal.currentSettings.modalSize.width; - var height = Drupal.CTools.Modal.currentSettings.modalSize.height; - } - - // Use the additionol pixels for creating the width and height. - $('div.ctools-modal-content', context).css({ - 'width': width + Drupal.CTools.Modal.currentSettings.modalSize.addWidth + 'px', - 'height': height + Drupal.CTools.Modal.currentSettings.modalSize.addHeight + 'px' - }); - $('div.ctools-modal-content .modal-content', context).css({ - 'width': (width - Drupal.CTools.Modal.currentSettings.modalSize.contentRight) + 'px', - 'height': (height - Drupal.CTools.Modal.currentSettings.modalSize.contentBottom) + 'px' - }); - } - - if (!Drupal.CTools.Modal.modal) { - Drupal.CTools.Modal.modal = $(Drupal.theme(settings.modalTheme)); - if (settings.modalSize.type == 'scale') { - $(window).bind('resize', resize); - } - } - - resize(); - - $('span.modal-title', Drupal.CTools.Modal.modal).html(Drupal.CTools.Modal.currentSettings.loadingText); - Drupal.CTools.Modal.modalContent(Drupal.CTools.Modal.modal, settings.modalOptions, settings.animation, settings.animationSpeed); - $('#modalContent .modal-content').html(Drupal.theme(settings.throbberTheme)); - }; - - /** - * Hide the modal - */ - Drupal.CTools.Modal.dismiss = function() { - if (Drupal.CTools.Modal.modal) { - Drupal.CTools.Modal.unmodalContent(Drupal.CTools.Modal.modal); - } - }; - - /** - * Provide the HTML to create the modal dialog. - */ - Drupal.theme.prototype.CToolsModalDialog = function () { - var html = '' - html += ' '; - - return html; - } - - /** - * Provide the HTML to create the throbber. - */ - Drupal.theme.prototype.CToolsModalThrobber = function () { - var html = ''; - html += ' '; - - return html; - }; - - /** - * Figure out what settings string to use to display a modal. - */ - Drupal.CTools.Modal.getSettings = function (object) { - var match = $(object).attr('class').match(/ctools-modal-(\S+)/); - if (match) { - return match[1]; - } - } - - /** - * Click function for modals that can be cached. - */ - Drupal.CTools.Modal.clickAjaxCacheLink = function () { - Drupal.CTools.Modal.show(Drupal.CTools.Modal.getSettings(this)); - return Drupal.CTools.AJAX.clickAJAXCacheLink.apply(this); - }; - - /** - * Handler to prepare the modal for the response - */ - Drupal.CTools.Modal.clickAjaxLink = function () { - Drupal.CTools.Modal.show(Drupal.CTools.Modal.getSettings(this)); - return false; - }; - - /** - * Submit responder to do an AJAX submit on all modal forms. - */ - Drupal.CTools.Modal.submitAjaxForm = function(e) { - var url = $(this).attr('action'); - var form = $(this); - - setTimeout(function() { Drupal.CTools.AJAX.ajaxSubmit(form, url); }, 1); - return false; - } - - /** - * Bind links that will open modals to the appropriate function. - */ - Drupal.behaviors.ZZCToolsModal = { - attach: function(context) { - // Bind links - // Note that doing so in this order means that the two classes can be - // used together safely. - /* - * @todo remimplement the warm caching feature - $('a.ctools-use-modal-cache:not(.ctools-use-modal-processed)', context) - .addClass('ctools-use-modal-processed') - .click(Drupal.CTools.Modal.clickAjaxCacheLink) - .each(function () { - Drupal.CTools.AJAX.warmCache.apply(this); - }); - */ - - $('a.ctools-use-modal:not(.ctools-use-modal-processed)', context) - .addClass('ctools-use-modal-processed') - .click(Drupal.CTools.Modal.clickAjaxLink) - .each(function () { - // Create a drupal ajax object - var element_settings = {}; - if ($(this).attr('href')) { - element_settings.url = $(this).attr('href'); - element_settings.event = 'click'; - element_settings.progress = { type: 'throbber' }; - } - var base = $(this).attr('href'); - Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); - - // Attach the display behavior to the ajax object - } - ); - - // Bind buttons - $('input.ctools-use-modal:not(.ctools-use-modal-processed), button.ctools-use-modal:not(.ctools-use-modal-processed)', context) - .addClass('ctools-use-modal-processed') - .click(Drupal.CTools.Modal.clickAjaxLink) - .each(function() { - var button = this; - var element_settings = {}; - - // AJAX submits specified in this manner automatically submit to the - // normal form action. - element_settings.url = Drupal.CTools.Modal.findURL(this); - element_settings.event = 'click'; - - var base = $(this).attr('id'); - Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); - - // Make sure changes to settings are reflected in the URL. - $('.' + $(button).attr('id') + '-url').change(function() { - Drupal.ajax[base].options.url = Drupal.CTools.Modal.findURL(button); - }); - }); - - // Bind our custom event to the form submit - $('#modal-content form:not(.ctools-use-modal-processed)', context) - .addClass('ctools-use-modal-processed') - .each(function() { - $('input[type=submit], button', this).click(function() { - this.form.clk = this; - }); - - var element_settings = {}; - - element_settings.url = $(this).attr('action'); - element_settings.event = 'submit'; - element_settings.progress = { 'type': 'throbber' } - var base = $(this).attr('id'); - - Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); - Drupal.ajax[base].form = $(this); - }); - } - }; - - // The following are implementations of AJAX responder commands. - - /** - * AJAX responder command to place HTML within the modal. - */ - Drupal.CTools.Modal.modal_display = function(ajax, response, status) { - $('#modal-title').html(response.title); - $('#modal-content').html(response.output); - Drupal.attachBehaviors(); - } - - /** - * AJAX responder command to dismiss the modal. - */ - Drupal.CTools.Modal.modal_dismiss = function(command) { - Drupal.CTools.Modal.dismiss(); - $('link.ctools-temporary-css').remove(); - } - - /** - * Display loading - */ - //Drupal.CTools.AJAX.commands.modal_loading = function(command) { - Drupal.CTools.Modal.modal_loading = function(command) { - Drupal.CTools.Modal.modal_display({ - output: Drupal.theme(Drupal.CTools.Modal.currentSettings.throbberTheme), - title: Drupal.CTools.Modal.currentSettings.loadingText - }); - } - - /** - * Find a URL for an AJAX button. - * - * The URL for this gadget will be composed of the values of items by - * taking the ID of this item and adding -url and looking for that - * class. They need to be in the form in order since we will - * concat them all together using '/'. - */ - Drupal.CTools.Modal.findURL = function(item) { - var url = ''; - var url_class = '.' + $(item).attr('id') + '-url'; - $(url_class).each( - function() { - if (url && $(this).val()) { - url += '/'; - } - url += $(this).val(); - }); - return url; - }; - - - /** - * modalContent - * @param content string to display in the content box - * @param css obj of css attributes - * @param animation (fadeIn, slideDown, show) - * @param speed (valid animation speeds slow, medium, fast or # in ms) - */ - Drupal.CTools.Modal.modalContent = function(content, css, animation, speed) { - // If our animation isn't set, make it just show/pop - if (!animation) { - animation = 'show'; - } - else { - // If our animation isn't "fadeIn" or "slideDown" then it always is show - if (animation != 'fadeIn' && animation != 'slideDown') { - animation = 'show'; - } - } - - if (!speed) { - speed = 'fast'; - } - - // Build our base attributes and allow them to be overriden - css = jQuery.extend({ - position: 'absolute', - left: '0px', - margin: '0px', - background: '#000', - opacity: '.55' - }, css); - - // Add opacity handling for IE. - css.filter = 'alpha(opacity=' + (100 * css.opacity) + ')'; - content.hide(); - - // if we already ahve a modalContent, remove it - if ( $('#modalBackdrop')) $('#modalBackdrop').remove(); - if ( $('#modalContent')) $('#modalContent').remove(); - - // position code lifted from http://www.quirksmode.org/viewport/compatibility.html - if (self.pageYOffset) { // all except Explorer - var wt = self.pageYOffset; - } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict - var wt = document.documentElement.scrollTop; - } else if (document.body) { // all other Explorers - var wt = document.body.scrollTop; - } - - // Get our dimensions - - // Get the docHeight and (ugly hack) add 50 pixels to make sure we dont have a *visible* border below our div - var docHeight = $(document).height() + 50; - var docWidth = $(document).width(); - var winHeight = $(window).height(); - var winWidth = $(window).width(); - if( docHeight < winHeight ) docHeight = winHeight; - - // Create our divs - $('body').append('
' + $(content).html() + '
'); - - // Keyboard and focus event handler ensures focus stays on modal elements only - modalEventHandler = function( event ) { - target = null; - if ( event ) { //Mozilla - target = event.target; - } else { //IE - event = window.event; - target = event.srcElement; - } - if( $(target).filter('*:visible').parents('#modalContent').size()) { - // allow the event only if target is a visible child node of #modalContent - return true; - } - if ( $('#modalContent')) $('#modalContent').get(0).focus(); - return false; - }; - $('body').bind( 'focus', modalEventHandler ); - $('body').bind( 'keypress', modalEventHandler ); - - // Create our content div, get the dimensions, and hide it - var modalContent = $('#modalContent').css('top','-1000px'); - var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2); - var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2); - $('#modalBackdrop').css(css).css('top', 0).css('height', docHeight + 'px').css('width', docWidth + 'px').show(); - modalContent.css({top: mdcTop + 'px', left: mdcLeft + 'px'}).hide()[animation](speed); - - // Bind a click for closing the modalContent - modalContentClose = function(){close(); return false;}; - $('.close').bind('click', modalContentClose); - - // Close the open modal content and backdrop - function close() { - // Unbind the events - $(window).unbind('resize', modalContentResize); - $('body').unbind( 'focus', modalEventHandler); - $('body').unbind( 'keypress', modalEventHandler ); - $('.close').unbind('click', modalContentClose); - $(document).trigger('CToolsDetachBehaviors', $('#modalContent')); - - // Set our animation parameters and use them - if ( animation == 'fadeIn' ) animation = 'fadeOut'; - if ( animation == 'slideDown' ) animation = 'slideUp'; - if ( animation == 'show' ) animation = 'hide'; - - // Close the content - modalContent.hide()[animation](speed); - - // Remove the content - $('#modalContent').remove(); - $('#modalBackdrop').remove(); - }; - - // Move and resize the modalBackdrop and modalContent on resize of the window - modalContentResize = function(){ - // Get our heights - var docHeight = $(document).height(); - var docWidth = $(document).width(); - var winHeight = $(window).height(); - var winWidth = $(window).width(); - if( docHeight < winHeight ) docHeight = winHeight; - - // Get where we should move content to - var modalContent = $('#modalContent'); - var mdcTop = ( winHeight / 2 ) - ( modalContent.outerHeight() / 2); - var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2); - - // Apply the changes - $('#modalBackdrop').css('height', docHeight + 'px').css('width', docWidth + 'px').show(); - modalContent.css('top', mdcTop + 'px').css('left', mdcLeft + 'px').show(); - }; - $(window).bind('resize', modalContentResize); - - $('#modalContent').focus(); - }; - - /** - * unmodalContent - * @param content (The jQuery object to remove) - * @param animation (fadeOut, slideUp, show) - * @param speed (valid animation speeds slow, medium, fast or # in ms) - */ - Drupal.CTools.Modal.unmodalContent = function(content, animation, speed) - { - // If our animation isn't set, make it just show/pop - if (!animation) { var animation = 'show'; } else { - // If our animation isn't "fade" then it always is show - if (( animation != 'fadeOut' ) && ( animation != 'slideUp')) animation = 'show'; - } - // Set a speed if we dont have one - if ( !speed ) var speed = 'fast'; - - // Unbind the events we bound - $(window).unbind('resize', modalContentResize); - $('body').unbind('focus', modalEventHandler); - $('body').unbind('keypress', modalEventHandler); - $('.close').unbind('click', modalContentClose); - $(document).trigger('CToolsDetachBehaviors', $('#modalContent')); - - // jQuery magic loop through the instances and run the animations or removal. - content.each(function(){ - if ( animation == 'fade' ) { - $('#modalContent').fadeOut(speed,function(){$('#modalBackdrop').fadeOut(speed, function(){$(this).remove();});$(this).remove();}); - } else { - if ( animation == 'slide' ) { - $('#modalContent').slideUp(speed,function(){$('#modalBackdrop').slideUp(speed, function(){$(this).remove();});$(this).remove();}); - } else { - $('#modalContent').remove();$('#modalBackdrop').remove(); - } - } - }); - }; - -$(function() { - Drupal.ajax.prototype.commands.modal_display = Drupal.CTools.Modal.modal_display; - Drupal.ajax.prototype.commands.modal_dismiss = Drupal.CTools.Modal.modal_dismiss; -}); - -})(jQuery); diff --git a/js/stylizer.js b/js/stylizer.js deleted file mode 100644 index dc1caaa..0000000 --- a/js/stylizer.js +++ /dev/null @@ -1,219 +0,0 @@ - -(function ($) { - Drupal.CTools = Drupal.CTools || {}; - Drupal.CTools.Stylizer = {}; - - Drupal.CTools.Stylizer.addFarbtastic = function(context) { - // This behavior attaches by ID, so is only valid once on a page. - if ($('ctools_stylizer_color_scheme_form .color-form.Stylizer-processed').size()) { - return; - } - - var form = $('.color-form', context); - var inputs = []; - var hooks = []; - var locks = []; - var focused = null; - - // Add Farbtastic - $(form).prepend('
').addClass('color-processed'); - var farb = $.farbtastic('#placeholder'); - - // Decode reference colors to HSL - /*var reference = Drupal.settings.Stylizer.reference.clone(); - for (i in reference) { - reference[i] = farb.RGBToHSL(farb.unpack(reference[i])); - } */ - - // Set up colorscheme selector - $('#edit-scheme', form).change(function () { - var colors = this.options[this.selectedIndex].value; - if (colors != '') { - colors = colors.split(','); - for (i in colors) { - callback(inputs[i], colors[i], false, true); - } - } - }); - - /** - * Shift a given color, using a reference pair (ref in HSL). - * - * This algorithm ensures relative ordering on the saturation and luminance - * axes is preserved, and performs a simple hue shift. - * - * It is also symmetrical. If: shift_color(c, a, b) == d, - * then shift_color(d, b, a) == c. - */ - function shift_color(given, ref1, ref2) { - // Convert to HSL - given = farb.RGBToHSL(farb.unpack(given)); - - // Hue: apply delta - given[0] += ref2[0] - ref1[0]; - - // Saturation: interpolate - if (ref1[1] == 0 || ref2[1] == 0) { - given[1] = ref2[1]; - } - else { - var d = ref1[1] / ref2[1]; - if (d > 1) { - given[1] /= d; - } - else { - given[1] = 1 - (1 - given[1]) * d; - } - } - - // Luminance: interpolate - if (ref1[2] == 0 || ref2[2] == 0) { - given[2] = ref2[2]; - } - else { - var d = ref1[2] / ref2[2]; - if (d > 1) { - given[2] /= d; - } - else { - given[2] = 1 - (1 - given[2]) * d; - } - } - - return farb.pack(farb.HSLToRGB(given)); - } - - /** - * Callback for Farbtastic when a new color is chosen. - */ - function callback(input, color, propagate, colorscheme) { - // Set background/foreground color - $(input).css({ - backgroundColor: color, - 'color': farb.RGBToHSL(farb.unpack(color))[2] > 0.5 ? '#000' : '#fff' - }); - - // Change input value - if (input.value && input.value != color) { - input.value = color; - - // Update locked values - if (propagate) { - var i = input.i; - for (j = i + 1; ; ++j) { - if (!locks[j - 1] || $(locks[j - 1]).is('.unlocked')) break; - var matched = shift_color(color, reference[input.key], reference[inputs[j].key]); - callback(inputs[j], matched, false); - } - for (j = i - 1; ; --j) { - if (!locks[j] || $(locks[j]).is('.unlocked')) break; - var matched = shift_color(color, reference[input.key], reference[inputs[j].key]); - callback(inputs[j], matched, false); - } - - } - - // Reset colorscheme selector - if (!colorscheme) { - resetScheme(); - } - } - - } - - /** - * Reset the color scheme selector. - */ - function resetScheme() { - $('#edit-scheme', form).each(function () { - this.selectedIndex = this.options.length - 1; - }); - } - - // Focus the Farbtastic on a particular field. - function focus() { - var input = this; - // Remove old bindings - focused && $(focused).unbind('keyup', farb.updateValue) - .unbind('keyup', resetScheme) - .parent().removeClass('item-selected'); - - // Add new bindings - focused = this; - farb.linkTo(function (color) { callback(input, color, true, false); }); - farb.setColor(this.value); - $(focused).keyup(farb.updateValue).keyup(resetScheme) - .parent().addClass('item-selected'); - } - - // Initialize color fields - $('#palette input.form-text', form) - .each(function () { - // Extract palette field name - this.key = this.id.substring(13); - - // Link to color picker temporarily to initialize. - farb.linkTo(function () {}).setColor('#000').linkTo(this); - - // Add lock - var i = inputs.length; - if (inputs.length) { - var lock = $('
').toggle( - function () { - $(this).addClass('unlocked'); - $(hooks[i - 1]).attr('class', - locks[i - 2] && $(locks[i - 2]).is(':not(.unlocked)') ? 'hook up' : 'hook' - ); - $(hooks[i]).attr('class', - locks[i] && $(locks[i]).is(':not(.unlocked)') ? 'hook down' : 'hook' - ); - }, - function () { - $(this).removeClass('unlocked'); - $(hooks[i - 1]).attr('class', - locks[i - 2] && $(locks[i - 2]).is(':not(.unlocked)') ? 'hook both' : 'hook down' - ); - $(hooks[i]).attr('class', - locks[i] && $(locks[i]).is(':not(.unlocked)') ? 'hook both' : 'hook up' - ); - } - ); - $(this).after(lock); - locks.push(lock); - }; - - // Add hook - var hook = $('
'); - $(this).after(hook); - hooks.push(hook); - - $(this).parent().find('.lock').click(); - this.i = i; - inputs.push(this); - }) - .focus(focus); - - $('#palette label', form); - - // Focus first color - focus.call(inputs[0]); - }; - - Drupal.behaviors.CToolsColorSettings = { - attach: function() { - $('.ctools-stylizer-color-edit:not(.ctools-color-processed)') - .addClass('ctools-color-processed') - .each(function() { - Drupal.CTools.Stylizer.addFarbtastic('#' + $(this).attr('id')); - }); - - $('div.form-item div.ctools-style-icon:not(.ctools-color-processed)') - .addClass('ctools-color-processed') - .click(function() { - $widget = $('input', $(this).parent()); - // Toggle if a checkbox, turn on if a radio. - $widget.attr('checked', !$widget.attr('checked') || $widget.is('input[type=radio]')); - }); - } - } -})(jQuery); diff --git a/page_manager/css/page-manager.css b/page_manager/css/page-manager.css deleted file mode 100644 index 0c42611..0000000 --- a/page_manager/css/page-manager.css +++ /dev/null @@ -1,341 +0,0 @@ -body form#page-manager-list-pages-form { - margin: 0 0 20px 0; -} - -#page-manager-list-pages-form .form-item { - padding-right: 1em; /* LTR */ - float: left; /* LTR */ - margin-top: 0; - margin-bottom: 0; -} - -#page-manager-list-pages { - width: 100%; -} - -#edit-order-wrapper { - clear: left; /* LTR */ -} - -#edit-pages-apply, -#edit-pages-reset { - margin-top: 1.65em; - float: left; /* LTR */ -} - -#page-manager-edit { - margin-top: 1em; -} - -#page-manager-edit table { - width: 100%; -} - -#page-manager-edit table tr.even { - background-color: #fafafa; -} - -#page-manager-list-pages tr.page-manager-disabled td { - color: #999; -} - -#page-manager-list-pages tr.page-manager-locked td.page-manager-page-name { - font-style: italic; - color: green; - padding-left: 22px; /* LTR */ - background: url(../images/locked.png) no-repeat scroll left center; /* LTR */ -} - -#page-manager-list-pages tr.page-manager-locked-other td.page-manager-page-name { - font-style: italic; - color: red; - padding-left: 22px; /* LTR */ - background: url(../images/locked-other.png) no-repeat scroll left center; /* LTR */ -} - -#page-manager-edit .page-manager-wrapper { - margin: 0; - padding: 0 0 0 149px; - color: #494949; -} - -#page-manager-edit .page-manager-tabs { - border: 1px solid #aaa; -} - -#page-manager-edit .page-manager-edit-operations { - float: left; /* LTR */ - width: 150px; - margin-left: -150px; - margin-top: -1px; - height: 100%; - font-size: 90%; -} - -#page-manager-edit .page-manager-edit-operations .inside { - border-top: 1px solid #aaa; - border-bottom: 1px solid #aaa; -} - -#page-manager-edit .page-manager-edit-operations ul { - margin-top: 0; - margin-bottom: 0; - padding: 0; - margin-left: 0; -} - -#page-manager-edit .page-manager-edit-operations li { - list-style: none; - background: #F6F6F6; - border-top: 1px solid #aaa; - border-left: 1px solid #aaa; - border-right: 1px solid #aaa; - padding: 0 0 0 0; - margin: 0; - line-height: 2em; -} - -#page-manager-edit .page-manager-edit-operations li.active, -#page-manager-edit .page-manager-edit-operations li.active-group .page-manager-group-title { - background: #FFFFFF url(../images/arrow-active.png) no-repeat scroll right center; -} - -#page-manager-edit .page-manager-edit-operations li.changed, -#page-manager-edit .page-manager-edit-operations li.changed-group .page-manager-group-title { - background-color: #ffe; - font-weight: bold; -} - -/** provide a reset for non active stray paths */ -#page-manager-edit .page-manager-edit-operations li.active-group li.not-active .page-manager-group-title, -#page-manager-edit .page-manager-edit-operations li.changed-group li.not-changed .page-manager-group-title { - background: #F6F6F6; -} - -#page-manager-edit .page-manager-edit-operations li.active { - border-right: 1px solid white; -} - -#page-manager-edit .page-manager-edit-operations li.active a, -#page-manager-edit .page-manager-edit-operations li.active a:hover { - background: #FFFFFF url(../images/arrow-active.png) no-repeat scroll right center; - color: #000000; - font-weight: bold; -} - -#page-manager-edit .page-manager-edit-operations li.operation-first { - border-top: none; -} - -#page-manager-edit .page-manager-edit-operations li li.operation-first { - border-top: 1px solid #aaa; -} - -#page-manager-edit .page-manager-edit-operations li a { - display: block; - padding: 0 0 0 .5em; - color: #494949; -} - -#page-manager-edit .page-manager-edit-operations li a:hover { - background-color: #eee; - text-decoration: none; -} - -#page-manager-edit .ctools-collapsible-container { - display: inline-block; - position: relative; - *float: left; /* LTR */ - width: 100%; -} - -#page-manager-edit .page-manager-edit-operations li .ctools-collapsible-handle:hover { - background-color: #eee; -} - -#page-manager-edit .page-manager-edit-operations li li { - border-right: none; - border-left: none; - margin-left: 1em; -} - -#page-manager-edit .page-manager-edit-operations li ul { -} - -#page-manager-edit .page-manager-group-title { - line-height: 2em; - font-weight: bold; - padding: 0 0 0 .5em; -} - -/* Change the position of the arrow on the dropdown to look nicer with our defaults. */ -#page-manager-edit .page-manager-edit-operations .ctools-toggle { - background-position: 0 9px; - width: 10px; -} - -#page-manager-edit .page-manager-ajax-pad { - float: left; /* LTR */ - width: 100%; - border-left: none; - height: 100%; - background: white; -} - -/** A riser to force the ajax pad to a minimum height. **/ -#page-manager-edit .page-manager-ajax-pad .page-manager-riser { - width: 1px; - float: right; /* LTR */ - height: 400px; -} - -#page-manager-edit .page-manager-ajax-pad .page-manager-riser span { - display: none; -} - -#page-manager-edit .page-manager-ajax-pad .content-title { - font-weight: bold; - font-size: 120%; - background-color: #fafafa; - border-bottom: 1px solid #aaa; - border-left: 1px solid #aaa; - margin-left: -1px; - padding: 2px 5px 2px 20px; -} - -#page-manager-edit .actions { - padding: 0 0 0 20px; -} - -#page-manager-edit .primary-actions li { - border-top: 1px solid #aaa; -} - -#page-manager-edit .secondary-actions { - border-bottom: 1px solid #aaa; -} - -#page-manager-edit .handler-actions { - float: right; /* LTR */ -} - -#page-manager-edit .actions .page-manager-group-title { - float: left; /* LTR */ - padding-left: 0; -} - -#page-manager-edit .actions ul { - float: right; /* LTR */ - text-align: right; /* LTR */ - padding: 0; - margin: 0; - border-right: 1px solid #aaa; -} - -#page-manager-edit .handler-title .actions ul { - border-right: none; -} - -#page-manager-edit .actions li { - float: left; /* LTR */ - background: none; - list-style: none; - border-left: 1px solid #aaa; - margin: 0; - padding: 0; -} - -#page-manager-edit .actions ul li.operation-last { - border-right: none; -} - -#page-manager-edit .actions li a:hover { - background-color: #eee; - text-decoration: none; -} - -#page-manager-edit .actions li a { - display: block; - padding: 0.2em 0.5em; - color:#0062A0; - background-color: #F6F6F6; -} - -#page-manager-edit .page-manager-changed { - float: right; /* LTR */ - font-style: italic; - color: #f93; - padding-left: 1em; - padding-right: 22px; - background: url(../images/locked.png) no-repeat scroll right center; -} - -#page-manager-edit .page-manager-ajax-pad .content-content { - padding: .5em 20px; -} - -#page-manager-edit .page-manager-ajax-pad textarea { - width: 100%; -} - -#page-manager-edit .changed-notification { - border: 1px solid #aaa; - background-color: #ffe; - color: #494949; - padding: 1em; - margin-top: 1em; -} - -#page-manager-edit .ctools-locked { - margin-bottom: 2em; -} - -#page-manager-page-summary .title { - font-weight: bold; - font-size: 160%; -} - -#page-manager-page-summary .handler-summary { -} - -#page-manager-page-summary .page-summary-operation { - text-align: right; -} - -#page-manager-page-summary .page-summary-label { - width: 8em; - font-weight: bold; -} - - -.handler-summary dl { - margin: 0; -} - -.handler-summary dt { - margin: 0; - padding: 0; -} - -.handler-summary dd { - margin: 0; -} - -.handler-summary ol { - margin: 0; -} - -.handler-summary .handler-title { - border-top: 1px solid #ddd; - border-bottom: 1px solid #ddd; - background: #fafafa; - padding: 0 0 0 5px; - margin-top: .5em; -} - -.handler-summary .handler-title .title-label { - font-weight: bold; - font-size: 120%; - line-height: 1.75em; -} - diff --git a/page_manager/help/about.html b/page_manager/help/about.html deleted file mode 100644 index fa58aca..0000000 --- a/page_manager/help/about.html +++ /dev/null @@ -1,11 +0,0 @@ -The Page Manager module creates and manages pages in your Drupal site. Pages are defined as items that have a path and provide output to the user. It is a complete round trip from getting user input to providing user output. - -There are two types of pages that the Page Manager currently supports: -
-
Custom pages
-
Custom pages are defined completely by the administrator. Their path, access control and visible menu characteristics are completely arbitrary.
-
System pages
-
System pages are defined by Drupal and Drupal modules. They primarily override pre-existing pages to provide different functionality. They often do not allow such features as access control in favor of what already exists, and they will usually 'fall back' to default Drupal behavior. -
- -Both types of pages figure out what to show the user by using Variants. Variants are output handlers, and every page should have at least one. Most pages will simply have only one. Pages with multiple variants will choose one and only one Variant to display content to the user and will use the Selection Rules to figure out which Variant to display. \ No newline at end of file diff --git a/page_manager/help/api-task-handler.html b/page_manager/help/api-task-handler.html deleted file mode 100644 index 4544a2a..0000000 --- a/page_manager/help/api-task-handler.html +++ /dev/null @@ -1,43 +0,0 @@ -task handler definition: - title -- visible title of the task handler. - description -- description of the task handler. - task type -- The type of the task this handler can service. - render -- callback of the function to render the handler. The arguments to this callback are specific to the task type. - admin title -- callback to render the admin title as this handler is listed. - params: $handler, $task, $subtask_id - admin summary -- callback to render what's in the collapsible info as the handler is listed. Optional. - params: $handler, $task, $subtask_id - default conf -- either an array() of default conf data or a callback that returns an array. - params: $handler, $task, $subtask_id - save -- callback to call just prior to the task handler being saved so it can adjust its data. - params: &$handler, $update (as drupal_write_record would receive) - export -- callback to call just prior to the task being exported. It should return text to append to the export if necessary. - params: &$handler, $indent - - forms => array( - 'id' => array( - 'form' => form callback (receives $form, $form_state) - 'submit' => submit callback - 'validate' => validate callback - 'include' => an optional file to include to get functionality for this form. Must include full path. - 'no return' => hide the 'return' button, meaning that the form requires extra steps if submitted - 'alternate next' => an alternate next form. Used for hidden edit forms that don't have tabs. - 'no blocks' => if TRUE, use Drupal's mechanism to not render blocks for this form. - ) - ) - ), - - 'add forms' => array( - 'form1', => t('form title'), - 'form2', => t('form title'), - // ...etc.../ -), - 'edit forms' => array( - 'id' => t('tab name'), - 'id2' => t('tab name'), - ), - - If a form name is blank it is a 'hidden' form -- it has no tab but can still be reached. - - -Notes: Because #required validation cannot be skipped when clicking cancel, please don't use it. \ No newline at end of file diff --git a/page_manager/help/api-task-type.html b/page_manager/help/api-task-type.html deleted file mode 100644 index eb87265..0000000 --- a/page_manager/help/api-task-type.html +++ /dev/null @@ -1,2 +0,0 @@ - -defines a task type, grouping tasks together and providing a common UI for them. \ No newline at end of file diff --git a/page_manager/help/api-task.html b/page_manager/help/api-task.html deleted file mode 100644 index cd6e3d0..0000000 --- a/page_manager/help/api-task.html +++ /dev/null @@ -1,38 +0,0 @@ -task definition: - title -- visible title of the task. - description -- description of the task. - hook menu -- function to delegate from hook_menu. Params: &$items, $task - hook menu alter -- function to delegate from hook_menu_alter. Params: &$items, $task - hook theme -- function to delegate from hook_theme. Params: &$items, $task - - admin name -- if set an admin menu will appear in the delegator UI - admin description -- to describe the admin menu - - admin access callback -- if set, the callback to use to determine administrative - access to this task. Defaults to user_access. Note that this is required even - if delegator isn't handling administration, since this gets used to on handler - edit forms. - admin access arguments -- If set, the arguments to use to determine administrative - access to this task. Defaults to array('administer delegator'); - - type -- The type of the task, used to determine which handlers can service it. - - subtasks -- can be TRUE in which case it supports subtasks with the default - configuration or a string (array?) with callbacks to fetch subtask data. - subtask callback -- A callback which returns just one subtask. Param: $task, $subtask_id - subtasks callback -- A callback which returns an array of all subtasks. - This MUST return an array, even if it's empty.Param: $task - - default handlers -- If the task contains any default handlers, they can be included here. - -task names must not contain a - as that is used to separate the task name from the subtask ID. - -subtasks implement data very similar to their parent task. In particular, they -implement the following items exactly like their task: - hook menu - hook menu alter - description - admin name - admin description - admin access callback - admin access arguments diff --git a/page_manager/help/custom-pages-access.html b/page_manager/help/custom-pages-access.html deleted file mode 100644 index a2643c2..0000000 --- a/page_manager/help/custom-pages-access.html +++ /dev/null @@ -1,2 +0,0 @@ - -Please visit http://drupal.org/node/528072 to help provide this documentation page. \ No newline at end of file diff --git a/page_manager/help/custom-pages-arguments.html b/page_manager/help/custom-pages-arguments.html deleted file mode 100644 index 516a429..0000000 --- a/page_manager/help/custom-pages-arguments.html +++ /dev/null @@ -1,2 +0,0 @@ - -Please visit http://drupal.org/node/528058 to help provide this documentation page. \ No newline at end of file diff --git a/page_manager/help/custom-pages-menu.html b/page_manager/help/custom-pages-menu.html deleted file mode 100644 index 48cf9c3..0000000 --- a/page_manager/help/custom-pages-menu.html +++ /dev/null @@ -1,2 +0,0 @@ - -Please visit http://drupal.org/node/528078 to help provide this documentation page. \ No newline at end of file diff --git a/page_manager/help/custom-pages.html b/page_manager/help/custom-pages.html deleted file mode 100644 index 18e66d4..0000000 --- a/page_manager/help/custom-pages.html +++ /dev/null @@ -1,2 +0,0 @@ - -Please visit http://drupal.org/node/528050 to help provide this documentation page. \ No newline at end of file diff --git a/page_manager/help/getting-started-create.html b/page_manager/help/getting-started-create.html deleted file mode 100644 index a3d295e..0000000 --- a/page_manager/help/getting-started-create.html +++ /dev/null @@ -1,2 +0,0 @@ - -Please visit http://drupal.org/node/528038 to help provide this documentation page. \ No newline at end of file diff --git a/page_manager/help/getting-started-custom-nodes.html b/page_manager/help/getting-started-custom-nodes.html deleted file mode 100644 index d62eb0f..0000000 --- a/page_manager/help/getting-started-custom-nodes.html +++ /dev/null @@ -1,2 +0,0 @@ - -Please visit http://drupal.org/node/528044 to help provide this documentation page. \ No newline at end of file diff --git a/page_manager/help/getting-started-custom-vocabulary.html b/page_manager/help/getting-started-custom-vocabulary.html deleted file mode 100644 index 7148cd9..0000000 --- a/page_manager/help/getting-started-custom-vocabulary.html +++ /dev/null @@ -1,2 +0,0 @@ - -Please visit http://drupal.org/node/528046 to help provide this documentation page. \ No newline at end of file diff --git a/page_manager/help/getting-started-members.html b/page_manager/help/getting-started-members.html deleted file mode 100644 index 87b2122..0000000 --- a/page_manager/help/getting-started-members.html +++ /dev/null @@ -1,2 +0,0 @@ - -Please visit http://drupal.org/node/528040 to help provide this documentation page. \ No newline at end of file diff --git a/page_manager/help/getting-started-page-list.html b/page_manager/help/getting-started-page-list.html deleted file mode 100644 index d60bea4..0000000 --- a/page_manager/help/getting-started-page-list.html +++ /dev/null @@ -1,2 +0,0 @@ - -Please visit http://drupal.org/node/528036 to help provide this documentation page. \ No newline at end of file diff --git a/page_manager/help/getting-started.html b/page_manager/help/getting-started.html deleted file mode 100644 index 4e4f24a..0000000 --- a/page_manager/help/getting-started.html +++ /dev/null @@ -1,15 +0,0 @@ - -Note: this page is currently very preliminary. Please visit http://drupal.org/node/528034 to help provide this documentation page! - -This is a quick summary: - -
    -
  • Visit administer >> site building >> pages to get to the primary page manager interface.
  • -
  • You can add custom pages for your basic landing pages, front pages, whatever you like for normal content display.
  • -
  • You can use the system pages to create finer control of how taxonomy vocabularies, nodes and user profiles are displayed.
  • -
  • When you add your first custom page, do not bother with the optional features. You will not need these until you get to more advanced tasks.
  • -
  • The selection rules are the key to creating node displays for just one node type.
  • -
  • Everything in this system is pluggable. A little PHP knowledge and exploration of the plugins directories can take you a long way.
  • -
- - diff --git a/page_manager/help/page-task-type.html b/page_manager/help/page-task-type.html deleted file mode 100644 index c382c76..0000000 --- a/page_manager/help/page-task-type.html +++ /dev/null @@ -1,4 +0,0 @@ - -Additional 'task' keys support: - -operations -- a list of operations suitable for theme('links') \ No newline at end of file diff --git a/page_manager/help/page_manager.help.ini b/page_manager/help/page_manager.help.ini deleted file mode 100644 index 05cadb4..0000000 --- a/page_manager/help/page_manager.help.ini +++ /dev/null @@ -1,59 +0,0 @@ -[advanced help settings] -line break = TRUE - -[about] -title = About Page Manager -weight = -100 - -[getting-started] -title = Getting Started -weight = -80 - -[getting-started-page-list] -title = The page list -weight = -90 -parent = getting-started - -[getting-started-create] -title = Creating a page -weight = -80 -parent = getting-started - -[getting-started-members] -title = Tutorial: Make a page that looks different for members -weight = -70 -parent = getting-started - -[getting-started-custom-nodes] -title = Tutorial: Customize the look of a single node type -weight = -60 -parent = getting-started - -[getting-started-custom-vocabulary] -title = Tutorial: Customize the look of a single taxonomy vocabulary -weight = -50 -parent = getting-started - -[custom-pages] -title = Custom pages -weight = -50 - -[custom-pages-arguments] -title = Arguments -weight = -100 -parent = custom-pages - -[custom-pages-access] -title = Access control -weight = -90 -parent = custom-pages - -[custom-pages-menu] -title = Menu items -weight = -80 -parent = custom-pages - -[variants] -title = Variants -weight = -40 - diff --git a/page_manager/help/variants.html b/page_manager/help/variants.html deleted file mode 100644 index 48cf9c3..0000000 --- a/page_manager/help/variants.html +++ /dev/null @@ -1,2 +0,0 @@ - -Please visit http://drupal.org/node/528078 to help provide this documentation page. \ No newline at end of file diff --git a/page_manager/images/arrow-active.png b/page_manager/images/arrow-active.png deleted file mode 100644 index 3bbd3c27f29f9a1781276a2ae8faa7afd5d2d36e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 313 zcwXxa@N?(olHy`uVBq!ia0vp^96-#^!3-qdU8!RPQY`6?zK#qG*KS<#k1zuAB}-f* zN`mv#O3D+9QW+dm@{>{(JaZG%Q-e|yQz{EjrrH1%xd!-zxO#bc1qB6pdwbu!dGq1J zhmRgT^6~LGa^%RaUAy+}+xPF^zmq3VUc7kG&(CkurcE0*Y)DB-@%Q&XfByW98#g9T zp6u!A`Tzg_bT_}9Km)5hT^vIyZY2pcGc_8m~*JFP%mn}{Fn2|XLioa2OdkOs2Uu5v-^B)=B#D=-rH|1&NKdS0Y%`(K*41-{V}iTua{_dok8$^Nt`d zuS}WamGk(Y?^?I{+Pe3vw(etC7qRy1vFd+kYR~9bG0W|D&-h)~vK8bVPgg&ebxsLQ E0Q%5o6#xJL diff --git a/page_manager/images/locked.png b/page_manager/images/locked.png deleted file mode 100644 index 2116eb1c810d4f76eefeebb920f3764ea443c0fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 273 zcwXxa@N?(olHy`uVBq!ia0vp^fqT}bgHU1MC)~&?)>e$``iC%%XABtN+f$NnesfZQg7|+S97YLM!jx+SXlABR^Exh z!G*zz array(), 'tasks' => array()); - - page_manager_get_pages($tasks, $pages); - - // Add lock icon to all locked tasks. - global $user; - - ctools_include('object-cache'); - $locks = ctools_object_cache_test_objects('page_manager_page', $pages['tasks']); - foreach ($locks as $task_name => $lock) { - if ($lock->uid == $user->uid) { - $pages['rows'][$task_name]['class'][] = ' page-manager-locked'; - $pages['rows'][$task_name]['title'] = t('This page is currently locked for editing by you. Nobody else may edit this page until these changes are saved or canceled.'); - } - else { - $pages['rows'][$task_name]['class'][] = ' page-manager-locked-other'; - $pages['rows'][$task_name]['title'] = t('This page is currently locked for editing by another user. You may not edit this page without breaking the lock.'); - } - } - - $input = $_POST; - - // Respond to a reset command by clearing session and doing a drupal goto - // back to the base URL. - if (isset($input['op']) && $input['op'] == t('Reset')) { - unset($_SESSION['page_manager']['#admin']); - if (!$js) { - return drupal_goto($_GET['q']); - } - // clear everything but form id, form build id and form token: - $keys = array_keys($input); - foreach ($keys as $id) { - if ($id != 'form_id' && $id != 'form_build_id' && $id != 'form_token') { - unset($input[$id]); - } - } - $replace_form = TRUE; - } - if (count($input) <= 1) { - if (isset($_SESSION['page_manager']['#admin']) && is_array($_SESSION['page_manager']['#admin'])) { - $input = $_SESSION['page_manager']['#admin']; - } - } - else { - $_SESSION['page_manager']['#admin'] = $input; - unset($_SESSION['page_manager']['#admin']['q']); - } - - $form_state = array( - 'pages' => &$pages, - 'input' => $input, - 'rerender' => TRUE, - 'no_redirect' => TRUE, - ); - - // This form will sort and filter the pages. - $form = drupal_build_form('page_manager_list_pages_form', $form_state); - - $header = array( - array('data' => t('Type'), 'class' => array('page-manager-page-type')), - array('data' => t('Name'), 'class' => array('page-manager-page-name')), - array('data' => t('Title'), 'class' => array('page-manager-page-title')), - array('data' => t('Path'), 'class' => array('page-manager-page-path')), - array('data' => t('Storage'), 'class' => array('page-manager-page-storage')), - ); - - $header[] = array('data' => t('Operations'), 'class' => array('page-manager-page-operations')); - $table = theme('table', array('header' => $header, 'rows' => $pages['rows'], 'attributes' => array('id' => 'page-manager-list-pages'))); - - $operations = ''; - - drupal_add_css(drupal_get_path('module', 'page_manager') . '/css/page-manager.css'); - - - if (!$js) { - return array('#markup' => drupal_render($form) . $table . $operations); - } - - ctools_include('ajax'); - $commands = array(); - $commands[] = ajax_command_replace('#page-manager-list-pages', $table); - if (!empty($replace_form)) { - $commands[] = ajax_command_replace('#page-manager-list-pages-form', $form); - } - print ajax_render($commands); - ajax_footer(); -} - -/** - * Sort tasks into buckets based upon whether or not they have subtasks. - */ -function page_manager_get_pages($tasks, &$pages, $task_id = NULL) { - foreach ($tasks as $id => $task) { - if (empty($task_id) && !empty($task['page operations'])) { - $pages['operations'] = array_merge($pages['operations'], $task['page operations']); - } - - // If a type has subtasks, add its subtasks in its own table. - if (!empty($task['subtasks'])) { - page_manager_get_pages(page_manager_get_task_subtasks($task), $pages, $task['name']); - continue; - } - - if (isset($task_id)) { - $task_name = page_manager_make_task_name($task_id, $task['name']); - } - else { - $task_name = $task['name']; - } - - $class = array('page-task-' . $id); - if (isset($task['row class'])) { - $class[] = $task['row class']; - } - - if (!empty($task['disabled'])) { - $class[] = 'page-manager-disabled'; - } - - $path = array(); - $visible_path = ''; - if (!empty($task['admin path'])) { - foreach (explode('/', $task['admin path']) as $bit) { - if ($bit[0] != '!') { - $path[] = $bit; - } - } - - $path = implode('/', $path); - if (empty($task['disabled']) && strpos($path, '%') === FALSE) { - $visible_path = l('/' . $task['admin path'], $path); - } - else { - $visible_path = '/' . $task['admin path']; - } - } - - $row = array('data' => array(), 'class' => $class, 'title' => strip_tags($task['admin description'])); - - $type = isset($task['admin type']) ? $task['admin type'] : t('System'); - $pages['types'][$type] = $type; - $row['data']['type'] = array('data' => $type, 'class' => array('page-manager-page-type')); - - $row['data']['name'] = array('data' => $task_name, 'class' => array('page-manager-page-name')); - $row['data']['title'] = array('data' => $task['admin title'], 'class' => array('page-manager-page-title')); - $row['data']['path'] = array('data' => $visible_path, 'class' => array('page-manager-page-path')); - - $storage = isset($task['storage']) ? $task['storage'] : t('In code'); - $pages['storages'][$storage] = $storage; - $row['data']['storage'] = array('data' => $storage, 'class' => array('page-manager-page-storage')); - - -/* - if (empty($task['disabled'])) { - $item = menu_get_item($path); - if (empty($item)) { - dsm($path); - } - else { - dsm($item); - } - } -*/ - $operations = array( - array( - 'title' => t('Edit'), - 'href' => page_manager_edit_url($task_name), - ), - ); - - if (!empty($task['enable callback'])) { - if (!empty($task['disabled'])) { - $operations[] = array( - 'title' => t('Enable'), - 'href' => 'admin/structure/pages/nojs/enable/' . $task_name, - 'query' => array('token' => drupal_get_token($task_name)), - ); - } - else { - $operations[] = array( - 'title' => t('Disable'), - 'href' => 'admin/structure/pages/nojs/disable/' . $task_name, - 'query' => array('token' => drupal_get_token($task_name)), - ); - } - } - - $row['data']['operations'] = array('data' => theme('links', array('links' => $operations)), 'class' => array('page-manager-page-operations')); - - $pages['disabled'][$task_name] = !empty($task['disabled']); - $pages['tasks'][] = $task_name; - $pages['rows'][$task_name] = $row; - } -} - -/** - * Provide a form for sorting and filtering the list of pages. - */ -function page_manager_list_pages_form($form, &$form_state) { - // This forces the form to *always* treat as submitted which is - // necessary to make it work. - if (empty($_POST)) { - $form["#programmed"] = TRUE; - } - $form['#action'] = url('admin/structure/pages/nojs/', array('absolute' => TRUE)); - if (!variable_get('clean_url', FALSE)) { - $form['q'] = array( - '#type' => 'hidden', - '#value' => $_GET['q'], - ); - } - - $all = array('all' => t('')); - - $form['type'] = array( - '#type' => 'select', - '#title' => t('Type'), - '#options' => $all + $form_state['pages']['types'], - '#default_value' => 'all', - ); - - $form['storage'] = array( - '#type' => 'select', - '#title' => t('Storage'), - '#options' => $all + $form_state['pages']['storages'], - '#default_value' => 'all', - ); - - $form['disabled'] = array( - '#type' => 'select', - '#title' => t('Enabled'), - '#options' => $all + array('0' => t('Enabled'), '1' => t('Disabled')), - '#default_value' => 'all', - ); - - $form['search'] = array( - '#type' => 'textfield', - '#title' => t('Search'), - ); - - $form['order'] = array( - '#type' => 'select', - '#title' => t('Sort by'), - '#options' => array( - 'disabled' => t('Enabled, title'), - 'title' => t('Title'), - 'name' => t('Name'), - 'path' => t('Path'), - 'type' => t('Type'), - 'storage' => t('Storage'), - ), - '#default_value' => 'disabled', - ); - - $form['sort'] = array( - '#type' => 'select', - '#title' => t('Order'), - '#options' => array( - 'asc' => t('Up'), - 'desc' => t('Down'), - ), - '#default_value' => 'asc', - ); - - $form['submit'] = array( - '#name' => '', // so it won't in the $_GET args - '#type' => 'submit', - '#id' => 'edit-pages-apply', - '#value' => t('Apply'), - '#attributes' => array('class' => array('use-ajax-submit ctools-auto-submit-click')), - ); - - $form['reset'] = array( - '#type' => 'submit', - '#id' => 'edit-pages-reset', - '#value' => t('Reset'), - '#attributes' => array('class' => array('use-ajax-submit')), - ); - - $form['#attached']['js'] = array('misc/ajax.js', 'misc/progress.js', 'misc/jquery.form.js', ctools_attach_js('auto-submit'), ctools_attach_js('page-list', 'page_manager')); - $form['#prefix'] = '
'; - $form['#suffix'] = '
'; - $form['#attributes'] = array('class' => array('ctools-auto-submit-full-form')); - - return $form; -} - -/** - * Accept submission from the page manager sort/filter form and apply it - * to the list of pages. - */ -function page_manager_list_pages_form_submit(&$form, &$form_state) { - // Filter and re-sort the pages. - - // This is a copy. - $rows = $form_state['pages']['rows']; - - $sorts = array(); - foreach ($rows as $name => $data) { - // Filter - if ($form_state['values']['type'] != 'all' && $form_state['values']['type'] != $data['data']['type']['data']) { - continue; - } - - if ($form_state['values']['storage'] != 'all' && $form_state['values']['storage'] != $data['data']['storage']['data']) { - continue; - } - - if ($form_state['values']['disabled'] != 'all' && $form_state['values']['disabled'] != $form_state['pages']['disabled'][$name]) { - continue; - } - - if ($form_state['values']['search'] && - strpos($data['data']['name']['data'], $form_state['values']['search']) === FALSE && - strpos($data['data']['path']['data'], $form_state['values']['search']) === FALSE && - strpos($data['data']['title']['data'], $form_state['values']['search']) === FALSE) { - continue; - } - // Set up sorting - switch ($form_state['values']['order']) { - case 'disabled': - $sorts[$name] = !$form_state['pages']['disabled'][$name] . $data['data']['title']['data']; - break; - case 'title': - $sorts[$name] = $data['data']['title']['data']; - break; - case 'name': - $sorts[$name] = $data['data']['name']['data']; - break; - case 'path': - $sorts[$name] = $data['data']['path']['data']; - break; - case 'type': - $sorts[$name] = $data['data']['type']['data']; - break; - case 'storage': - $sorts[$name] = $data['data']['storage']['data']; - break; - } - } - - // Now actually sort - if ($form_state['values']['sort'] == 'desc') { - arsort($sorts); - } - else { - asort($sorts); - } - - // Nuke the original. - $form_state['pages']['rows'] = array(); - // And restore. - foreach ($sorts as $name => $title) { - $form_state['pages']['rows'][$name] = $rows[$name]; - } - -} - -/** - * Render the edit page for a a page, custom or system. - */ -function page_manager_edit_page($page) { - drupal_set_title($page->subtask['admin title']); - // Provide and process the save page form before anything else. - $form_state = array('page' => &$page); - $form = drupal_render(drupal_build_form('page_manager_save_page_form', $form_state)); - - $operations = page_manager_get_operations($page); - $args = array('summary'); - $rendered_operations = page_manager_render_operations($page, $operations, $args, array('class' => array('operations-main')), 'nav'); - $content = page_manager_get_operation_content(FALSE, $page, $args, $operations); - $output = theme('page_manager_edit_page', array('page' => $page, 'save' => $form, 'operations' => $rendered_operations, 'content' => $content)); - return array('#markup' => $output); -} - -/** - * Entry point to edit a single operation for a page. - * - * @param $js - * Whether or not the page was called via javascript. - * @param $page - * The cached page that is being edited. - * @param ... - * A number of items used to drill down into the actual operation called. - */ -function page_manager_edit_page_operation() { - $args = func_get_args(); - $js = array_shift($args); - $page = array_shift($args); - - $operations = page_manager_get_operations($page); - $content = page_manager_get_operation_content($js, $page, $args, $operations); - - // If the operation requested we go somewhere else afterward, oblige it. - if (isset($content['new trail'])) { - $args = $content['new trail']; - // Get operations again, for the operation may have changed their availability. - $operations = page_manager_get_operations($page); - $content = page_manager_get_operation_content($js, $page, $args, $operations); - } - - // Rendering the content may have been a form submission that changed the - // operations, such as renaming or adding a handler. Thus we get a new set - // of operations. - $operations = page_manager_get_operations($page); - $rendered_operations = page_manager_render_operations($page, $operations, $args, array('class' => array('operations-main')), 'nav'); - - // Since this form should never be submitted to this page, process it late so - // that we can be sure it notices changes. - $form_state = array('page' => &$page); - $form = drupal_render(drupal_build_form('page_manager_save_page_form', $form_state)); - - $output = theme('page_manager_edit_page', array('page' => $page, 'save' => $form, 'operations' => $rendered_operations, 'content' => $content)); - - if ($js) { - $commands = array(); - $commands[] = ajax_command_replace('#page-manager-edit', $output); - - print ajax_render($commands); - ajax_footer(); - return; - } - - drupal_set_title($page->subtask['admin title']); - return $output; -} - -/** - * Take the operations array from a task and expand it. - * - * This allows some of the operations to be dynamic, based upon settings - * on the task or the task's handlers. Each operation should have a type. In - * addition to all the types allowed in page_manager_render_operations, these - * types will be dynamically replaced with something else: - * - 'handlers': An automatically created group that contains all the task's - * handlers and appropriate links. - * - 'function': A callback (which will be placed in the 'function' parameter - * that should return an array of operations. This can be used to provide - * additional, dynamic links if needed. - */ -function page_manager_get_operations($page, $operations = NULL) { - if (!isset($operations)) { - // All tasks have at least these 2 ops: - $operations = array( - 'summary' => array( - 'title' => t('Summary'), - 'description' => t('Get a summary of the information about this page.'), - 'path' => 'admin/structure/pages/edit', - 'ajax' => FALSE, - 'no operations' => TRUE, - 'form info' => array( - 'no buttons' => TRUE, - ), - 'form' => 'page_manager_page_summary', - ), - 'actions' => array( - 'type' => 'group', - 'title' => '', - 'class' => array('operations-actions'), - 'location' => 'primary', - 'children' => array(), - ), - ); - - if (isset($page->subtask['operations'])) { - $operations += $page->subtask['operations']; - // add actions separately. - if (!empty($page->subtask['operations']['actions'])) { - $operations['actions']['children'] += $page->subtask['operations']['actions']['children']; - } - } - $operations['handlers'] = array('type' => 'handlers'); - } - - $result = array(); - foreach ($operations as $id => $operation) { - if (empty($operation['type'])) { - $operation['type'] = 'operation'; - } - switch ($operation['type']) { - case 'handlers': - $result[$id] = page_manager_get_handler_operations($page); - break; - case 'function': - if (function_exists($operation['function'])) { - $retval = $function($page, $operation); - if (is_array($retval)) { - $result[$id] = $retval; - } - } - break; - default: - $result[$id] = $operation; - } - } - - if (!empty($page->subtask['enable callback']) && !empty($page->subtask['disabled']) && empty($result['actions']['children']['enable'])) { - $result['actions']['children']['enable'] = array( - 'title' => t('Enable'), - 'description' => t('Activate this page so that it will be in use in your system.'), - 'form' => 'page_manager_enable_form', - 'ajax' => FALSE, - 'silent' => TRUE, - 'no update and save' => TRUE, - 'form info' => array( - 'finish text' => t('Enable'), - ), - ); - } - - if (!empty($page->subtask['enable callback']) && empty($page->subtask['disabled']) && empty($result['actions']['children']['disable'])) { - $result['actions']['children']['disable'] = array( - 'title' => t('Disable'), - 'description' => t('De-activate this page. The data will remain but the page will not be in use on your system.'), - 'form' => 'page_manager_disable_form', - 'ajax' => FALSE, - 'silent' => TRUE, - 'no update and save' => TRUE, - 'form info' => array( - 'finish text' => t('Disable'), - ), - ); - } - - $result['actions']['children']['add'] = array( - 'title' => t('Add variant'), - 'description' => t('Add a new variant to this page.'), - 'form' => 'page_manager_handler_add', - 'ajax' => FALSE, - 'silent' => TRUE, // prevents a message about updating and prevents this item from showing as changed. - 'no update and save' => TRUE, // get rid of update and save button which is bad here. - 'form info' => array( - 'finish text' => t('Create variant'), - ), - ); - - // Restrict variant import to users who can already execute arbitrary PHP - if (user_access('use PHP for settings')) { - $result['actions']['children']['import'] = array( - 'title' => t('Import variant'), - 'description' => t('Add a new variant to this page from code exported from another page.'), - 'form' => 'page_manager_handler_import', - ); - } - - if (count($page->handlers) > 1) { - $result['actions']['children']['rearrange'] = array( - 'title' => t('Reorder variants'), - 'ajax' => FALSE, - 'description' => t('Change the priority of the variants to ensure that the right one gets selected.'), - 'form' => 'page_manager_handler_rearrange', - ); - } - - // This is a special operation used to configure a new task handler before - // it is added. - if (isset($page->new_handler)) { - $plugin = page_manager_get_task_handler($page->new_handler->handler); - $result['actions']['children']['configure'] = array( - 'title' => t('Configure'), - 'description' => t('Configure a newly created variant prior to actually adding it to the page.'), - 'ajax' => FALSE, - 'no update and save' => TRUE, // get rid of update and save button which is bad here. - 'form info' => array( - // We use our own cancel and finish callback to handle the fun stuff. - 'finish callback' => 'page_manager_handler_add_finish', - 'cancel callback' => 'page_manager_handler_add_cancel', - 'show trail' => TRUE, - 'show back' => TRUE, - 'finish text' => t('Create variant'), - ), - 'form' => array( - 'forms' => $plugin['forms'], - ), - ); - - foreach ($page->forms as $id) { - if (isset($plugin['add features'][$id])) { - $result['actions']['children']['configure']['form']['order'][$id] = $plugin['add features'][$id]; - } - else if (isset($plugin['required forms'][$id])) { - $result['actions']['children']['configure']['form']['order'][$id] = $plugin['required forms'][$id]; - } - } - } - - if ($page->locked) { - $result['actions']['children']['break-lock'] = array( - 'title' => t('Break lock'), - 'description' => t('Break the lock on this page so that you can edit it.'), - 'form' => 'page_manager_break_lock', - 'ajax' => FALSE, - 'no update and save' => TRUE, // get rid of update and save button which is bad here. - 'form info' => array( - 'finish text' => t('Break lock'), - ), - 'even locked' => TRUE, // show button even if locked - 'silent' => TRUE, - ); - } - - drupal_alter('page_manager_operations', $result, $page); - return $result; -} - -/** - * Collect all the operations related to task handlers (variants) and - * build a menu. - */ -function page_manager_get_handler_operations(&$page) { - ctools_include('export'); - $group = array( - 'type' => 'group', - 'class' => array('operations-handlers'), - 'title' => t('Variants'), - ); - - $operations = array(); - - // If there is only one variant, let's not have it collapsible. - $collapsible = count($page->handler_info) != 1; - foreach ($page->handler_info as $id => $info) { - if ($info['changed'] & PAGE_MANAGER_CHANGED_DELETED) { - continue; - } - $handler = $page->handlers[$id]; - $plugin = page_manager_get_task_handler($handler->handler); - - $operations[$id] = array( - 'type' => 'group', - 'class' => array('operations-handlers-' . $id), - 'title' => page_manager_get_handler_title($plugin, $handler, $page->task, $page->subtask_id), - 'collapsible' => $collapsible, - 'children' => array(), - ); - - $operations[$id]['children']['actions'] = array( - 'type' => 'group', - 'class' => array('operations-handlers-actions-' . $id), - 'title' => t('Variant operations'), - 'children' => array(), - 'location' => $id, - ); - - // There needs to be a 'summary' item here for variants. - $operations[$id]['children']['summary'] = array( - 'title' => t('Summary'), - 'description' => t('Get a summary of the information about this variant.'), - 'form info' => array( - 'no buttons' => TRUE, - ), - 'form' => 'page_manager_handler_summary', - ); - - if ($plugin && isset($plugin['operations'])) { - $operations[$id]['children'] += $plugin['operations']; - } - - $actions = &$operations[$id]['children']['actions']['children']; - - $actions['clone'] = array( - 'title' => t('Clone'), - 'description' => t('Make an exact copy of this variant.'), - 'form' => 'page_manager_handler_clone', - ); - $actions['export'] = array( - 'title' => t('Export'), - 'description' => t('Export this variant into code to import into another page.'), - 'form' => 'page_manager_handler_export', - ); - if ($handler->export_type == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) { - $actions['delete'] = array( - 'title' => t('Revert'), - 'description' => t('Remove all changes to this variant and revert to the version in code.'), - 'form' => 'page_manager_handler_delete', - 'no update and save' => TRUE, - 'form info' => array( - 'finish text' => t('Revert'), - ), - ); - } - else if ($handler->export_type != EXPORT_IN_CODE) { - $actions['delete'] = array( - 'title' => t('Delete'), - 'description' => t('Remove this variant from the page completely.'), - 'form' => 'page_manager_handler_delete', - 'form info' => array( - 'finish text' => t('Delete'), - 'save text' => t('Delete and save'), - ), - ); - } - if (!empty($handler->disabled)) { - $actions['enable'] = array( - 'title' => t('Enable'), - 'description' => t('Activate this variant so that it will be in use in your system.'), - 'form' => 'page_manager_handler_enable', - 'silent' => TRUE, - 'form info' => array( - 'finish text' => t('Enable'), - 'save text' => t('Enable and save'), - ), - ); - } - else { - $actions['disable'] = array( - 'title' => t('Disable'), - 'description' => t('De-activate this variant. The data will remain but the variant will not be in use on your system.'), - 'form' => 'page_manager_handler_disable', - 'silent' => TRUE, - 'form info' => array( - 'finish text' => t('Disable'), - 'save text' => t('Disable and save'), - ), - ); - } - - drupal_alter('page_manager_variant_operations', $operations[$id], $handler); - } - if (empty($operations)) { - $operations['empty'] = array( - 'type' => 'text', - 'title' => t('No variants'), - ); - } - - $group['children'] = $operations; - return $group; -} - -/** - * Get an operation from a trail. - * - * @return array($operation, $active, $args) - */ -function page_manager_get_operation($operations, $trail) { - $args = $trail; - $stop = FALSE; - $active = array(); - $titles = array(); - // Drill down into operations array: - while (!$stop) { - $check = reset($args); - $stop = TRUE; - if (is_array($operations)) { - if (isset($operations[$check])) { - $active[] = $check; - $operation = array_shift($args); - // check to see if this operation has children. If so, we continue. - if (!isset($operations[$check]['children'])) { - $operations = $operations[$check]; - } - else { - $titles[] = $operations[$check]['title']; - $operations = $operations[$check]['children']; - // continue only if the operation hs children. - $stop = FALSE; - } - } - } - } - - return array($operations, $active, $args, $titles); -} - -/** - * Fetch the content for an operation. - * - * First, this drills down through the arguments to find the operation, and - * turns whatever it finds into the active trail which is then used to - * hilite where we are when rendering the operation list. - * - * The arguments are discovered from the URL, and are an exact match for where - * the operation is in the hierarchy. For example, handlers/foo/settings will - * be the operation to edit the settings for the handler named foo. This comes - * in as an array ('handlers', 'foo', 'settings') and is used to find where the - * data for that operation is in the array. - */ -function page_manager_get_operation_content($js, &$page, $trail, $operations) { - list($operation, $active, $args, $titles) = page_manager_get_operation($operations, $trail); - // Once we've found the operation, send it off to render. - if ($operation) { - $content = _page_manager_get_operation_content($js, $page, $active, $operation, $titles, $args); - } - - if (empty($content)) { - $content = _page_manager_get_operation_content($js, $page, array('summary'), $operations['summary']); - } - - return $content; -} - -/** - * Fetch the content for an operation, after it's been discovered from arguments. - * - * This system runs through the CTools form wizard. Each operation specifies a form - * or set of forms that it may use. Operations may also specify wrappers and can - * set their own next/finish handlers so that they can make additional things happen - * at the end. - */ -function _page_manager_get_operation_content($js, &$page, $active, $operation, $titles = array(), $args = array()) { - if (isset($operation['form'])) { - $form_info = array( - 'id' => 'page_manager_page', - 'finish text' => t('Update'), - 'show trail' => FALSE, - 'show back' => FALSE, - 'show return' => FALSE, - 'show cancel' => FALSE, - 'next callback' => 'page_manager_edit_page_next', - 'finish callback' => 'page_manager_edit_page_finish', - // Items specific to the 'edit' routines that will get moved over: - 'path' => page_manager_edit_url($page->task_name, $active) . "/%step", - // wrapper function to add an extra finish button. - 'wrapper' => 'page_manager_operation_wrapper', - ); - - // If $operation['form'] is simply a string, then it is the function - // name of the form. - if (!is_array($operation['form'])) { - $form_info['order'] = array( - 'form' => $operation['title'], - ); - $form_info['forms'] = array( - 'form' => array('form id' => $operation['form']), - ); - if (isset($operation['wrapper'])) { - $form_info['forms']['form']['wrapper'] = $operation['wrapper']; - } - } - // Otherwise it's the order and forms arrays directly. - else { - $form_info['order'] = $operation['form']['order']; - $form_info['forms'] = $operation['form']['forms']; - } - - // Allow the operation to override any form info settings: - if (isset($operation['form info'])) { - foreach ($operation['form info'] as $key => $setting) { - $form_info[$key] = $setting; - } - } - - if (!empty($page->subtask['operations include'])) { - // Quickly load any files necessary to display the forms. - $page->subtask['operations include']['function'] = 'nop'; - ctools_plugin_get_function($page->subtask, 'operations include'); - } - - $step = array_shift($args); - // If step is unset, go with the basic step. - if (!isset($step)) { - $step = current(array_keys($form_info['order'])); - } - - // If it is locked, hide the buttonzzz! - if ($page->locked && empty($operation['even locked'])) { - $form_info['no buttons'] = TRUE; - } - - ctools_include('wizard'); - $form_state = array( - 'page' => $page, - 'type' => 'edit', - 'ajax' => $js && (!isset($operation['ajax']) || !empty($operation['ajax'])), - 'rerender' => TRUE, - 'trail' => $active, - 'task_name' => $page->task_name, - 'task_id' => $page->task_id, - 'task' => $page->task, - 'subtask_id' => $page->subtask_id, - 'subtask' => $page->subtask, - 'operation' => $operation, - ); - - if ($active && $active[0] == 'handlers' && isset($form_state['page']->handlers[$form_state['trail'][1]])) { - $form_state['handler_id'] = $form_state['trail'][1]; - $form_state['handler'] = &$form_state['page']->handlers[$form_state['handler_id']]; - } - - if ($active && $active[0] == 'actions' && $active[1] == 'configure' && isset($form_state['page']->new_handler)) { - $form_state['handler_id'] = $form_state['page']->new_handler->name; - $form_state['handler'] = &$form_state['page']->new_handler; - } - - $output = drupal_render(ctools_wizard_multistep_form($form_info, $step, $form_state)); - $title = empty($form_state['title']) ? $operation['title'] : $form_state['title']; - $titles[] = $title; - $title = implode(' » ', array_filter($titles)); - - // If there are messages for the form, render them. - if ($messages = theme('status_messages')) { - $output = $messages . $output; - } - - $description = isset($operation['admin description']) ? $operation['admin description'] : (isset($operation['description']) ? $operation['description'] : ''); - $return = array( - 'title' => $title, - 'content' => $output, - 'description' => $description, - ); - - // Append any extra content, used for the preview which is submitted then - // rendered. - if (isset($form_state['content'])) { - $return['content'] .= $form_state['content']; - } - - // If the form wanted us to go somewhere else next, pass that along. - if (isset($form_state['new trail'])) { - $return['new trail'] = $form_state['new trail']; - } - } - else { - $return = array( - 'title' => t('Error'), - 'content' => t('This operation trail does not exist.'), - ); - } - - $return['active'] = $active; - return $return; -} - -function page_manager_operation_wrapper($form, &$form_state) { - if (empty($form_state['operation']['no update and save']) && !empty($form['buttons']['return']['#wizard type']) && $form['buttons']['return']['#wizard type']) { - $form['buttons']['save'] = array( - '#type' => 'submit', - '#value' => !empty($form_state['form_info']['save text']) ? $form_state['form_info']['save text'] : t('Update and save'), - '#wizard type' => 'finish', - '#attributes' => $form['buttons']['return']['#attributes'], - '#save' => TRUE, - ); - } - - return $form; -} - -/** - * Callback generated when the an operation edit finished. - */ -function page_manager_edit_page_finish(&$form_state) { - if (empty($form_state['operation']['silent'])) { - if (empty($form_state['clicked_button']['#save'])) { - drupal_set_message(t('The page has been updated. Changes will not be permanent until you save.')); - } - else { - drupal_set_message(t('The page has been updated and saved.')); - } - $path = array(); - foreach ($form_state['trail'] as $operation) { - $path[] = $operation; - $form_state['page']->changes[implode('/', $path)] = TRUE; - } - } - - // If a handler was modified, set it to changed so we know to overwrite it. - if (isset($form_state['handler_id'])) { - $form_state['page']->handler_info[$form_state['handler_id']]['changed'] |= PAGE_MANAGER_CHANGED_CACHED; - } - - // While we make buttons go away on locked pages, it is still possible to - // have a lock a appear while you were editing, and have your changes - // disappear. This at least warns the user that this has happened. - if (!empty($page->locked)) { - drupal_set_message(t('Unable to update changes due to lock.')); - } - - // If the 'Update and Save' button was selected, write our cache out. - if (!empty($form_state['clicked_button']['#save'])) { - page_manager_save_page_cache($form_state['page']); - page_manager_clear_page_cache($form_state['page']->task_name); - $form_state['page'] = page_manager_get_page_cache($form_state['page']->task_name); - } - else { - if (empty($form_state['do not cache'])) { - page_manager_set_page_cache($form_state['page']); - } - } - - // We basically always want to force a rerender when the forms - // are finished, so make sure there is a new trail. - if (empty($form_state['new trail'])) { - // force a rerender to get rid of old form items that may have changed - // during save. - $form_state['new trail'] = $form_state['trail']; - } - - if (isset($form_state['new trail']) && empty($form_state['ajax'])) { - $form_state['redirect'] = page_manager_edit_url($form_state['page']->task_name, $form_state['new trail']); - } - - $form_state['complete'] = TRUE; -} - -/** - * Callback generated when the 'next' button is clicked. - * - * All we do here is store the cache. - */ -function page_manager_edit_page_next(&$form_state) { - page_manager_set_page_cache($form_state['page']); -} - -/** - * Callback generated when the 'cancel' button is clicked. - * - * All we do here is clear the cache. - */ -function page_manager_edit_page_cancel(&$form_state) { - $page = $form_state['page']; -} - -/** - * Render an operations array. - * - * This renders an array of operations into a series of nested UL statements, - * with ajax automatically on unless specified otherwise. Operations will - * automatically have the URLs generated nested. - * - * Each operation should have a 'type', which tells the renderer how to deal - * with it: - * - 'operation': An AJAX link to render. This is the default and is - * assumed if a type is not specified. Other fields for the operation: - * - - 'title': The text to display. Can be an image. Must be pre-sanitized. - * - - 'description': Text to place in the hover box over the link using the - * title attribute. - * - - 'arguments': Anything optional to put at the end of the URL. - * - - 'path': If set, overrides the default path. - * - - 'no operations': If set, the path will not have operations appended. - * - - 'no task': If set, the path will not have the task id. - * - - 'no link': If set, this item will just be text, not a link. - * - - 'ajax': If set to TRUE, ajax will be used. The default is TRUE. - * - - 'class': An optional class to specify for the link. - * - - 'form': The form to display for this operation, if using a single form. - * - - 'forms': An array of forms that must be paired with 'order' of this - * operation uses multiple forms. See wizard tool for details. - * - - 'order': The form order to use for multiple forms. See wizard tool for - * details. - * - - 'form info': Form info overrides for the wizard. See the wizard tool - * for available settings - * - 'group': - * - - 'title': The title of the link. May be HTML. - * - - 'title class': A class to apply to the title. - * - - 'children': An array of more operations that this group represents. - * All operations within this group will have this group's ID as part - * of the AJAX url to make it easier to find. - * - - 'class': A class to apply to the UL of the children. - * - - 'collapsible': If TRUE the collapsible tool will be used. - */ -function page_manager_render_operations(&$page, $operations, $active_trail, $attributes, $location, $parents = array()) { - drupal_add_js('misc/ajax.js'); - - if (!isset($output[$location])) { - $output[$location] = ''; - } - - $keys = array_keys($operations); - $first = array_shift($keys); - $last = array_pop($keys); - - // Make sure the 'first' and 'last' operations are part of THIS nav tree: - while ($keys && isset($operations[$first]['location']) && $operations[$first]['location'] != $location) { - $first = array_shift($keys); - } - while ($keys && isset($operations[$last]['location']) && $operations[$last]['location'] != $location) { - $last = array_pop($keys); - } - - $active = reset($active_trail); - foreach ($operations as $id => $operation) { - $current_path = ''; - if ($parents) { - $current_path .= implode('/', $parents) . '/'; - } - $current_path .= $id; - - if (empty($operation['type'])) { - $operation['type'] = 'operation'; - } - - // We only render an li for things in the same nav tree. - if (empty($operation['location']) || $operation['location'] == $location) { - if (!is_array($attributes['class'])) { - dsm($attributes['class']); - } - $class = empty($attributes['class']) || !is_array($attributes['class']) ? array() : $attributes['class']; - if ($id == $first) { - $class[] = 'operation-first'; - } - else if ($id == $last) { - $class[] = 'operation-last'; - } - - if (empty($operation['silent']) && !empty($page->changes[$current_path])) { - $class[] = $operation['type'] == 'group' ? 'changed-group' : 'changed'; - } - else { - $class[] = 'not-changed'; - } - - if ($active == $id) { - $class[] = $operation['type'] == 'group' ? 'active-group' : 'active'; - } - else { - $class[] = 'not-active'; - } - - $output[$location] .= '
  • '; - } - - switch ($operation['type']) { - case 'text': - $output[$location] .= $operation['title']; - break; - case 'operation': - $path = isset($operation['path']) ? $operation['path'] : 'admin/structure/pages/nojs/operation'; - if (!isset($operation['no task'])) { - $path .= '/' . $page->task_name; - } - - if (!isset($operation['no operations'])) { - $path .= '/' . $current_path; - if (isset($operation['arguments'])) { - $path .= '/' . $arguments; - } - } - - $class = array('page-manager-operation'); - if (!isset($operation['ajax']) || !empty($operation['ajax'])) { - $class[] = 'use-ajax'; - } - if (!empty($operation['class'])) { - $class[] = $operation['class']; - } - - $description = isset($operation['description']) ? $operation['description'] : ''; - if (empty($operation['silent']) && !empty($page->changes[$current_path])) { - $description .= ' ' . t('This setting contains unsaved changes.'); - } - - $output[$location] .= l($operation['title'], $path, array('attributes' => array('id' => 'page-manager-operation-' . $id, 'class' => $class, 'title' => $description), 'html' => TRUE)); - break; - case 'group': - if ($active == $id) { - $trail = $active_trail; - array_shift($trail); - } - else { - $trail = array(); - } - $group_location = isset($operation['location']) ? $operation['location'] : $location; - $temp = page_manager_render_operations($page, $operation['children'], $trail, $operation, $group_location, array_merge($parents, array($id))); - if ($temp) { - foreach ($temp as $id => $text) { - if (empty($output[$id])) { - $output[$id] = ''; - } - $output[$id] .= $text; - } - } - break; - } - - if (empty($operation['location']) || $operation['location'] == $location) { - $output[$location] .= '
  • '; - } - } - - if ($output[$location]) { - $output[$location] = '
      ' . $output[$location] . '
    '; - - if (!empty($attributes['title'])) { - $class = ''; - if (isset($attributes['title class'])) { - $class = $attributes['title class']; - } - $title = '
    ' . $attributes['title'] . '
    '; - - if (!empty($attributes['collapsible'])) { - $output[$location] = theme('ctools_collapsible', array('handle' => $title, 'content' => $output[$location], 'collapsed' => empty($active_trail))); - } - else { - $output[$location] = $title . $output[$location]; - } - } - return $output; - } -} - -/** - * Provide a simple form for saving the page manager info out of the cache. - */ -function page_manager_save_page_form($form, &$form_state) { - if (!empty($form_state['page']->changed)) { - $form['markup'] = array( - '#markup' => '
    ' . t('You have unsaved changes to this page. You must select Save to write them to the database, or Cancel to discard these changes. Please note that if you have changed any form, you must submit that form before saving.') . '
    ', - ); - - // Always make sure we submit back to the proper page. - $form['#action'] = url('admin/structure/pages/edit/' . $form_state['page']->task_name); - $form['save'] = array( - '#type' => 'submit', - '#value' => t('Save'), - '#submit' => array('page_manager_save_page_form_submit'), - ); - - $form['cancel'] = array( - '#type' => 'submit', - '#value' => t('Cancel'), - '#submit' => array('page_manager_save_page_form_cancel'), - ); - return $form; - } -} - -/** - * Save the page. - */ -function page_manager_save_page_form_submit(&$form, &$form_state) { - page_manager_save_page_cache($form_state['page']); -} - -/** - * Discard changes to the page. - */ -function page_manager_save_page_form_cancel($form, &$form_state) { - drupal_set_message(t('All pending changes have been discarded, and the page is now unlocked.')); - page_manager_clear_page_cache($form_state['page']->task_name); - - if (!empty($form_state['page']->new)) { - $form_state['redirect'] = 'admin/structure/pages'; - } -} - -// -------------------------------------------------------------------------- -// Handler (variant) related forms. - -/** - * Add a new task handler. - */ -function page_manager_handler_add($form, &$form_state) { - // Get a list of possible task handlers for this task. - return page_manager_handler_add_form($form, $form_state); -} - -/** - * Handler related forms. - */ -function page_manager_handler_add_submit(&$form, &$form_state) { - $cache = $form_state['page']; - $plugin = page_manager_get_task_handler($form_state['values']['handler']); - - // Create a new handler. - $handler = page_manager_new_task_handler($plugin); - if (!empty($form_state['values']['title'])) { - $handler->conf['title'] = $form_state['values']['title']; - } - else { - $handler->conf['title'] = $plugin['title']; - } - $cache->new_handler = $handler; - - // Figure out which forms to present them with - $cache->forms = array(); - - $features = $form_state['values']['features']; - if (isset($features[$form_state['values']['handler']])) { - $cache->forms = array_merge($cache->forms, array_keys(array_filter($features[$form_state['values']['handler']]))); - } - - if (isset($plugin['required forms'])) { - $cache->forms = array_merge($cache->forms, array_keys($plugin['required forms'])); - } - - $form_state['no_rerender'] = TRUE; - if (!empty($cache->forms)) { - // Tell the form to go to the config page. - drupal_set_message(t('Before this variant can be added, it must be configured. When you are finished, click "Create variant" at the end of this wizard to add this to your page.')); - $form_state['new trail'] = array('actions', 'configure'); - } - else { - // It has no forms at all. Add the variant and go to its first operation. - page_manager_handler_add_finish($form_state); - } -} - -/** - * Finish the add process and make the new handler official. - */ -function page_manager_handler_add_finish(&$form_state) { - $page = &$form_state['page']; - $handler = $page->new_handler; - page_manager_handler_add_to_page($page, $handler); - - // Remove the temporary page. - unset($page->new_handler); - unset($page->forms); - - // Set the new destination - $plugin = page_manager_get_task_handler($handler->handler); - if (!empty($plugin['add finish'])) { - $location = $plugin['add finish']; - } - else { - $keys = array_keys($plugin['operations']); - $location = reset($keys); - } - - $form_state['new trail'] = array('handlers', $handler->name, $location); - - // Pass through. - page_manager_edit_page_finish($form_state); -} - -/** - * Throw away a new handler and return to the add form - */ -function page_manager_handler_add_cancel(&$form_state) { - $form_state['new trail'] = array('handlers', 'add'); - - // Remove the temporary page. - unset($page->new_handler); - unset($page->forms); -} - -/** - * Provide a consistent UI for adding handlers. - */ -function page_manager_handler_add_form($form, $form_state, $features = array()) { - $task = $form_state['task']; - $task_handler_plugins = page_manager_get_task_handler_plugins($task); - if (empty($task_handler_plugins)) { - drupal_set_message(t('There are currently no variants available and a page may not be added. Perhaps you need to install the Panels module to get a variant?'), 'error'); - $form['buttons']['return']['#disabled'] = TRUE; - return; - } - - foreach ($task_handler_plugins as $id => $plugin) { - $options[$id] = $plugin['title']; - if (isset($plugin['add features'])) { - $features[$id] = $plugin['add features']; - } - } - - if (!isset($form_state['type']) || $form_state['type'] != 'add') { - $form['title'] = array( - '#type' => 'textfield', - '#title' => t('Title'), - '#description' => t('Administrative title of this variant. If you leave blank it will be automatically assigned.'), - ); - } - - $form['handler'] = array( - '#title' => t('Variant type'), - '#type' => 'select', - '#options' => $options, - ); - - // This set of checkboxes is not dangerous at all. - $form['features'] = array( - '#type' => 'checkboxes', - '#validated' => TRUE, - '#title' => t('Optional features'), - '#options' => array(), - '#description' => t('Check any optional features you need to be presented with forms for configuring them. If you do not check them here you will still be able to utilize these features once the new page is created. If you are not sure, leave these unchecked.'), - '#tree' => TRUE, - ); - - ctools_include('dependent'); - foreach ($features as $plugin => $feature_list) { - foreach ($feature_list as $feature_id => $feature) { - $form['features'][$plugin][$feature_id] = array( - '#type' => 'checkbox', - '#title' => $feature, - ); - if (!empty($form_state['page']->forms) && in_array($feature_id, $form_state['page']->forms)) { - $form['features'][$plugin][$feature_id]['#default_value'] = TRUE; - } - - if ($plugin != 'default') { - $form['features'][$plugin][$feature_id] += array( - '#process' => array('ctools_dependent_process'), - '#dependency' => array('edit-handler' => array($plugin)), - ); - } - } - } - - return $form; -} - -/** - * Rearrange the order of variants. - */ -function page_manager_handler_import($form, &$form_state) { - $form['title'] = array( - '#type' => 'textfield', - '#title' => t('Variant name'), - '#description' => t('Enter the name of the new variant.'), - ); - - if (user_access('use PHP for settings')) { - $form['object'] = array( - '#type' => 'textarea', - '#title' => t('Paste variant code here'), - '#rows' => 15, - ); - } - // Users ordinarily can't get here without the PHP block visibility perm. - // In case they somehow do, though, disable the form widget for extra safety. - else { - $form['shoveoff'] = array( - '#markup' => '
    ' . t('You do not have sufficient permissions to perform this action.') . '
    ', - ); - } - - return $form; -} - -/** - * Make sure that an import actually provides a handler. - */ -function page_manager_handler_import_validate($form, &$form_state) { - if (!user_access('use PHP for settings')) { - form_error($form['shoveoff'], t('You account permissions do not permit you to import.')); - return; - } - ob_start(); - eval($form_state['values']['object']); - ob_end_clean(); - - if (empty($handler)) { - $errors = ob_get_contents(); - if (empty($errors)) { - $errors = t('No variant found.'); - } - - form_error($form['object'], t('Unable to get a variant from the import. Errors reported: @errors', array('@errors' => $errors))); - } - - $form_state['handler'] = $handler; -} - -/** - * Clone an existing task handler into a new handler. - */ -function page_manager_handler_import_submit(&$form, &$form_state) { - $handler = $form_state['handler']; - - page_manager_handler_add_to_page($form_state['page'], $handler, $form_state['values']['title']); - - $plugin = page_manager_get_task_handler($handler->handler); - // It has no forms at all. Add the variant and go to its first operation. - $keys = array_keys($plugin['operations']); - $form_state['new trail'] = array('handlers', $handler->name, reset($keys)); -} - -/** - * Rearrange the order of variants. - */ -function page_manager_handler_rearrange($form, &$form_state) { - $page = $form_state['page']; - - $form['handlers'] = array('#tree' => TRUE); - - foreach ($page->handler_info as $id => $info) { - if ($info['changed'] & PAGE_MANAGER_CHANGED_DELETED) { - continue; - } - $handler = $page->handlers[$id]; - $plugin = page_manager_get_task_handler($handler->handler); - - $form['handlers'][$id]['title'] = array( - '#markup' => page_manager_get_handler_title($plugin, $handler, $page->task, $page->subtask_id), - ); - - $form['handlers'][$id]['weight'] = array( - '#type' => 'weight', - '#default_value' => $info['weight'], - '#delta' => 30, - ); - } - - return $form; -} - -function page_manager_handler_rearrange_submit(&$form, &$form_state) { - $handler_info = &$form_state['page']->handler_info; - - foreach ($form_state['values']['handlers'] as $id => $info) { - if ($handler_info[$id]['weight'] = $info['weight']) { - $handler_info[$id]['weight'] = $info['weight']; - $handler_info[$id]['changed'] |= PAGE_MANAGER_CHANGED_MOVED; - } - } - - // Sort the new cache. - uasort($handler_info, '_page_manager_handler_sort'); - -} - -/** - * Used as a callback to uasort to sort the task cache by weight. - * - * The 'name' field is used as a backup when weights are the same, which - * can happen when multiple modules put items out there at the same - * weight. - */ -function _page_manager_handler_sort($a, $b) { - if ($a['weight'] < $b['weight']) { - return -1; - } - elseif ($a['weight'] > $b['weight']) { - return 1; - } - elseif ($a['name'] < $b['name']) { - return -1; - } - elseif ($a['name'] > $b['name']) { - return 1; - } -} - -/** - * Rearrange the order of variants. - */ -function page_manager_handler_delete($form, &$form_state) { - if ($form_state['handler']->type == t('Overridden')) { - $text = t('Reverting the variant will delete the variant that is in the database, reverting it to the original default variant. This deletion will not be made permanent until you click Save.'); - } - else { - $text = t('Are you sure you want to delete this variant? This deletion will not be made permanent until you click Save.'); - } - $form['markup'] = array( - '#markup' => '

    ' . $text . '

    ', - ); - - return $form; -} - -/** - * Submit handler to delete a view. - */ -function page_manager_handler_delete_submit(&$form, &$form_state) { - $form_state['page']->handler_info[$form_state['handler_id']]['changed'] |= PAGE_MANAGER_CHANGED_DELETED; - $form_state['new trail'] = array('summary'); -} - -/** - * Entry point to export a page. - */ -function page_manager_handler_export($form, &$form_state) { - $export = page_manager_export_task_handler($form_state['handler']); - - $lines = substr_count($export, "\n"); - $form['code'] = array( - '#type' => 'textarea', - '#default_value' => $export, - '#rows' => $lines, - ); - - unset($form['buttons']); - return $form; -} - -/** - * Rearrange the order of variants. - */ -function page_manager_handler_clone($form, &$form_state) { - // This provides its own button because it does something totally different. - $form['title'] = array( - '#type' => 'textfield', - '#title' => t('Variant name'), - '#description' => t('Enter the name of the new variant.'), - ); - - return $form; -} - -/** - * Clone an existing task handler into a new handler. - */ -function page_manager_handler_clone_submit(&$form, &$form_state) { - $export = page_manager_export_task_handler($form_state['handler']); - ob_start(); - eval($export); - ob_end_clean(); - - page_manager_handler_add_to_page($form_state['page'], $handler, $form_state['values']['title']); - - $plugin = page_manager_get_task_handler($handler->handler); - // It has no forms at all. Add the variant and go to its first operation. - $keys = array_keys($plugin['operations']); - $form_state['new trail'] = array('handlers', $handler->name, reset($keys)); -} - -/** - * Form to enable a handler. - */ -function page_manager_handler_enable($form, &$form_state) { - $form['markup'] = array( - '#markup' => t('This variant is currently disabled. Enabling it will make it available in your system. This will not take effect until you save this page.'), - ); - - return $form; -} - -/** - * Enable the page after it has been confirmed. - */ -function page_manager_handler_enable_submit(&$form, &$form_state) { - $form_state['handler']->disabled = FALSE; - $form_state['page']->handler_info[$form_state['handler_id']]['disabled'] = FALSE; - $form_state['page']->handler_info[$form_state['handler_id']]['changed'] |= PAGE_MANAGER_CHANGED_STATUS; - $form_state['new trail'] = array('handlers', $form_state['handler_id'], 'actions', 'disable'); -} - -/** - * Form to disable a page. - */ -function page_manager_handler_disable($form, &$form_state) { - $form['markup'] = array( - '#markup' => t('This variant is currently enabled. Disabling it will make it unavailable in your system, and it will not be used. This will not take effect until you save this page.'), - ); - - return $form; -} - -/** - * Form to disable a page. - */ -function page_manager_handler_summary($form, &$form_state) { - $handler = $form_state['handler']; - $page = $form_state['page']; - $plugin = page_manager_get_task_handler($handler->handler); - - $form['markup'] = array( - '#markup' => page_manager_get_handler_summary($plugin, $handler, $page, FALSE), - ); - - return $form; -} - -/** - * Disable the page after it has been confirmed. - */ -function page_manager_handler_disable_submit(&$form, &$form_state) { - $form_state['handler']->disabled = TRUE; - $form_state['page']->handler_info[$form_state['handler_id']]['disabled'] = TRUE; - $form_state['page']->handler_info[$form_state['handler_id']]['changed'] |= PAGE_MANAGER_CHANGED_STATUS; - $form_state['new trail'] = array('handlers', $form_state['handler_id'], 'actions', 'enable'); -} - -/** - * Break the lock on a page so that it can be edited. - */ -function page_manager_break_lock($form, &$form_state) { - $form['markup'] = array( - '#markup' => t('Breaking the lock on this page will discard any pending changes made by the locking user. Are you REALLY sure you want to do this?') - ); - - return $form; -} - -/** - * Submit to break the lock on a page. - */ -function page_manager_break_lock_submit(&$form, &$form_state) { - $page = &$form_state['page']; - $form_state['page']->locked = FALSE; - ctools_object_cache_clear_all('page_manager_page', $page->task_name); - $form_state['do not cache'] = TRUE; - drupal_set_message(t('The lock has been cleared and all changes discarded. You may now make changes to this page.')); - - $form_state['new trail'] = array('summary'); -} - -/** - * Form to enable a page. - */ -function page_manager_enable_form($form, &$form_state) { - $form['markup'] = array( - '#markup' => t('Enabling this page will immediately make it available in your system (there is no need to wait for a save.)'), - ); - - return $form; -} - -/** - * Enable the page after it has been confirmed. - */ -function page_manager_enable_form_submit(&$form, &$form_state) { - $page = &$form_state['page']; - if ($function = ctools_plugin_get_function($page->subtask, 'enable callback')) { - $result = $function($page, FALSE); - menu_rebuild(); - } - $form_state['new trail'] = array('actions', 'disable'); - - // We don't want to cause this to cache if it wasn't already. If it was - // cached, however, we want to update the enabled state. - if (empty($form_state['page']->changed)) { - $form_state['do not cache'] = TRUE; - } -} - -/** - * Form to disable a page. - */ -function page_manager_disable_form($form, &$form_state) { - $form['markup'] = array( - '#markup' => t('Disabling this page will immediately make it unavailable in your system (there is no need to wait for a save.)'), - ); - - return $form; -} - -/** - * Disable the page after it has been confirmed. - */ -function page_manager_disable_form_submit(&$form, &$form_state) { - $page = &$form_state['page']; - if ($function = ctools_plugin_get_function($page->subtask, 'enable callback')) { - $result = $function($page, TRUE); - menu_rebuild(); - $form_state['new trail'] = array('actions', 'enable'); - - // We don't want to cause this to cache if it wasn't already. If it was - // cached, however, we want to update the enabled state. - if (empty($form_state['page']->changed)) { - $form_state['do not cache'] = TRUE; - } - } -} - -/** - * Print the summary information for a page. - */ -function page_manager_page_summary($form, &$form_state) { - $page = $form_state['page']; - - $output = ''; - -/* - if (isset($form_state['subtask']['admin title'])) { - $form_state['title'] = $form_state['subtask']['admin title']; - } -*/ - - if (isset($form_state['subtask']['admin description'])) { - $output .= '
    ' . $form_state['subtask']['admin description'] . '
    '; - } - - $output .= page_manager_get_page_summary($page->task, $page->subtask); - - if (!empty($page->handlers)) { - foreach ($page->handler_info as $id => $info) { - if ($info['changed'] & PAGE_MANAGER_CHANGED_DELETED) { - continue; - } - - $handler = $page->handlers[$id]; - $plugin = page_manager_get_task_handler($handler->handler); - - $output .= '
    '; - $output .= page_manager_get_handler_summary($plugin, $handler, $page); - $output .= '
    '; - - } - } - else { - $output .= '

    ' . t('This page has no variants and thus no output of its own.') . '

    '; - } - - $links = array( - array( - 'title' => ' » ' . t('Add a new variant'), - 'href' => page_manager_edit_url($page->task_name, array('actions', 'add')), - 'html' => TRUE, - ), - ); - - $output .= ''; - $form['markup'] = array( - '#markup' => $output, - ); - - return $form; -} - -/** - * Menu callback to enable or disable a page - */ -function page_manager_enable_page($disable, $js, $page) { - if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], $page->task_name)) { - return MENU_ACCESS_DENIED; - } - if ($page->locked) { - if ($disable) { - drupal_set_message(t('Unable to disable due to lock.')); - } - else { - drupal_set_message(t('Unable to enable due to lock.')); - } - } - else { - if ($function = ctools_plugin_get_function($page->subtask, 'enable callback')) { - $result = $function($page, $disable); - menu_rebuild(); - - // We want to re-cache this if it's changed so that status is properly - // updated on the changed form. - if (!empty($page->changed)) { - page_manager_set_page_cache($page); - } - } - } - - // For now $js is not actually in use on this. - drupal_goto('admin/structure/pages'); -} diff --git a/page_manager/page_manager.info b/page_manager/page_manager.info deleted file mode 100644 index 4398f5c..0000000 --- a/page_manager/page_manager.info +++ /dev/null @@ -1,5 +0,0 @@ -name = Page manager -description = Provides a UI and API to manage pages within the site. -core = 7.x -dependencies[] = ctools -package = Chaos tool suite diff --git a/page_manager/page_manager.install b/page_manager/page_manager.install deleted file mode 100644 index ad2781c..0000000 --- a/page_manager/page_manager.install +++ /dev/null @@ -1,202 +0,0 @@ - array( - 'identifier' => 'handler', - 'bulk export' => TRUE, - 'export callback' => 'page_manager_export_task_handler', - 'primary key' => 'did', - 'api' => array( - 'owner' => 'page_manager', - 'api' => 'pages_default', - 'minimum_version' => 1, - 'current_version' => 1, - ), - ), - 'fields' => array( - 'did' => array( - 'type' => 'serial', - 'not null' => TRUE, - 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.', - 'no export' => TRUE, - ), - 'name' => array( - 'type' => 'varchar', - 'length' => '255', - 'description' => 'Unique ID for this task handler. Used to identify it programmatically.', - ), - 'task' => array( - 'type' => 'varchar', - 'length' => '64', - 'description' => 'ID of the task this handler is for.', - ), - 'subtask' => array( - 'type' => 'varchar', - 'length' => '64', - 'description' => 'ID of the subtask this handler is for.', - 'not null' => TRUE, - 'default' => '', - ), - 'handler' => array( - 'type' => 'varchar', - 'length' => '64', - 'description' => 'ID of the task handler being used.', - ), - 'weight' => array( - 'type' => 'int', - 'description' => 'The order in which this handler appears. Lower numbers go first.', - ), - 'conf' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Serialized configuration of the handler, if needed.', - 'not null' => TRUE, - 'serialize' => TRUE, - 'object default' => array(), - ), - ), - 'primary key' => array('did'), - 'unique keys' => array( - 'name' => array('name'), - ), - 'indexes' => array('fulltask' => array('task', 'subtask', 'weight')), - ); - - $schema['page_manager_weights'] = array( - 'description' => 'Contains override weights for page_manager handlers that are in code.', - 'fields' => array( - 'name' => array( - 'type' => 'varchar', - 'length' => '255', - 'description' => 'Unique ID for this task handler. Used to identify it programmatically.', - 'not null' => TRUE, - 'default' => '', - ), - 'weight' => array( - 'type' => 'int', - 'description' => 'The order in which this handler appears. Lower numbers go first.', - ), - ), - 'primary key' => array('name'), - 'indexes' => array( - 'weights' => array('name', 'weight'), - ), - ); - - $schema['page_manager_pages'] = array( - 'description' => 'Contains page subtasks for implementing pages with arbitrary tasks.', - 'export' => array( - 'identifier' => 'page', - 'bulk export' => TRUE, - 'export callback' => 'page_manager_page_export', - 'api' => array( - 'owner' => 'page_manager', - 'api' => 'pages_default', - 'minimum_version' => 1, - 'current_version' => 1, - ), - ), - 'fields' => array( - 'pid' => array( - 'type' => 'serial', - 'not null' => TRUE, - 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.', - 'no export' => TRUE, - ), - 'name' => array( - 'type' => 'varchar', - 'length' => '255', - 'description' => 'Unique ID for this subtask. Used to identify it programmatically.', - ), - 'task' => array( - 'type' => 'varchar', - 'length' => '64', - 'description' => 'What type of page this is, so that we can use the same mechanism for creating tighter UIs for targeted pages.', - 'default' => 'page', - ), - 'admin_title' => array( - 'type' => 'varchar', - 'length' => '255', - 'description' => 'Human readable title for this page subtask.', - ), - 'admin_description' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Administrative description of this item.', - 'object default' => '', - ), - 'path' => array( - 'type' => 'varchar', - 'length' => '255', - 'description' => 'The menu path that will invoke this task.', - ), - 'access' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Access configuration for this path.', - 'not null' => TRUE, - 'serialize' => TRUE, - 'object default' => array(), - ), - 'menu' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Serialized configuration of Drupal menu visibility settings for this item.', - 'not null' => TRUE, - 'serialize' => TRUE, - 'object default' => array(), - ), - 'arguments' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Configuration of arguments for this menu item.', - 'not null' => TRUE, - 'serialize' => TRUE, - 'object default' => array(), - ), - 'conf' => array( - 'type' => 'text', - 'size' => 'big', - 'description' => 'Serialized configuration of the page, if needed.', - 'not null' => TRUE, - 'serialize' => TRUE, - 'object default' => array(), - ), - ), - 'primary key' => array('pid'), - 'unique keys' => array( - 'name' => array('name'), - ), - 'indexes' => array('task' => array('task')), - ); - - return $schema; -} - -/** - * Implements hook_install(). - */ -function page_manager_install() { - db_update('system') - ->fields(array('weight' => 99)) - ->condition('name', 'page_manager') - ->execute(); -} diff --git a/page_manager/page_manager.module b/page_manager/page_manager.module deleted file mode 100644 index 672b802..0000000 --- a/page_manager/page_manager.module +++ /dev/null @@ -1,1177 +0,0 @@ - array( - 'title' => t('Use Page Manager'), - 'description' => t("Allows users to use most of Page Manager's features, though restricts some of the most powerful, potentially site-damaging features. Note that even the reduced featureset still allows for enormous control over your website."), - 'restrict access' => TRUE, - ), - 'administer page manager' => array( - 'title' => t('Administer Page Manager'), - 'description' => t('Allows complete control over Page Manager, i.e., complete control over your site. Grant with extreme caution.'), - 'restrict access' => TRUE, - ), - ); - -} - -/** - * Implements hook_ctools_plugin_directory() to let the system know - * where our task and task_handler plugins are. - */ -function page_manager_ctools_plugin_directory($owner, $plugin_type) { - if ($owner == 'page_manager') { - return 'plugins/' . $plugin_type; - } - if ($owner == 'ctools' && $plugin_type == 'cache') { - return 'plugins/' . $plugin_type; - } -} - -/** - * Implements hook_ctools_plugin_type() to inform the plugin system that Page - * Manager owns task, task_handler, and page_wizard plugin types. - * - * All of these are empty because the defaults all work. - */ -function page_manager_ctools_plugin_type() { - return array( - 'tasks' => array(), - 'task_handlers' => array(), - 'page_wizards' => array(), - ); -} - -/** - * Delegated implementation of hook_menu(). - */ -function page_manager_menu() { - // For some reason, some things can activate modules without satisfying - // dependencies. I don't know how, but this helps prevent things from - // whitescreening when this happens. - if (!module_exists('ctools')) { - return; - } - - $items = array(); - $base = array( - 'access arguments' => array('use page manager'), - 'file' => 'page_manager.admin.inc', - ); - - $items['admin/structure/pages'] = array( - 'title' => 'Pages', - 'description' => 'Add, edit and remove overridden system pages and user defined pages from the system.', - 'page callback' => 'page_manager_list_page', - ) + $base; - - $items['admin/structure/pages/list'] = array( - 'title' => 'List', - 'page callback' => 'page_manager_list_page', - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ) + $base; - - $items['admin/structure/pages/edit/%page_manager_cache'] = array( - 'title' => 'Edit', - 'page callback' => 'page_manager_edit_page', - 'page arguments' => array(4), - 'type' => MENU_CALLBACK, - ) + $base; - - $items['admin/structure/pages/%ctools_js/operation/%page_manager_cache'] = array( - 'page callback' => 'page_manager_edit_page_operation', - 'page arguments' => array(3, 5), - 'type' => MENU_CALLBACK, - ) + $base; - - $items['admin/structure/pages/%ctools_js/enable/%page_manager_cache'] = array( - 'page callback' => 'page_manager_enable_page', - 'page arguments' => array(FALSE, 3, 5), - 'type' => MENU_CALLBACK, - ) + $base; - - $items['admin/structure/pages/%ctools_js/disable/%page_manager_cache'] = array( - 'page callback' => 'page_manager_enable_page', - 'page arguments' => array(TRUE, 3, 5), - 'type' => MENU_CALLBACK, - ) + $base; - - $tasks = page_manager_get_tasks(); - - // Provide menu items for each task. - foreach ($tasks as $task_id => $task) { - $handlers = page_manager_get_task_handler_plugins($task); - // Allow the task to add its own menu items. - if ($function = ctools_plugin_get_function($task, 'hook menu')) { - $function($items, $task); - } - - // And for those that provide subtasks, provide menu items for them, as well. - foreach (page_manager_get_task_subtasks($task) as $subtask_id => $subtask) { - // Allow the task to add its own menu items. - if ($function = ctools_plugin_get_function($task, 'hook menu')) { - $function($items, $subtask); - } - } - } - - return $items; -} - -/** - * Implements hook_menu_alter. - * - * Get a list of all tasks and delegate to them. - */ -function page_manager_menu_alter(&$items) { - // For some reason, some things can activate modules without satisfying - // dependencies. I don't know how, but this helps prevent things from - // whitescreening when this happens. - if (!module_exists('ctools')) { - return; - } - - $tasks = page_manager_get_tasks(); - - foreach ($tasks as $task) { - if ($function = ctools_plugin_get_function($task, 'hook menu alter')) { - $function($items, $task); - } - // let the subtasks alter the menu items too. - foreach (page_manager_get_task_subtasks($task) as $subtask_id => $subtask) { - if ($function = ctools_plugin_get_function($subtask, 'hook menu alter')) { - $function($items, $subtask); - } - } - } - - return $items; -} - -/* - * Implements hook_theme() - */ -function page_manager_theme() { - // For some reason, some things can activate modules without satisfying - // dependencies. I don't know how, but this helps prevent things from - // whitescreening when this happens. - if (!module_exists('ctools')) { - return; - } - - $base = array( - 'path' => drupal_get_path('module', 'page_manager') . '/theme', - 'file' => 'page_manager.theme.inc', - ); - - $items = array( - 'page_manager_handler_rearrange' => array( - 'render element' => 'form', - ) + $base, - 'page_manager_edit_page' => array( - 'template' => 'page-manager-edit-page', - 'variables' => array('page' => NULL, 'save' => NULL, 'operations' => array(), 'content' => array()), - ) + $base, - 'page_manager_lock' => array( - 'variables' => array('page' => array()), - ) + $base, - 'page_manager_changed' => array( - 'variables' => array('text' => NULL, 'description' => NULL), - ) + $base, - ); - - // Allow task plugins to have theme registrations by passing through: - $tasks = page_manager_get_tasks(); - - // Provide menu items for each task. - foreach ($tasks as $task_id => $task) { - if ($function = ctools_plugin_get_function($task, 'hook theme')) { - $function($items, $task); - } - } - - return $items; -} - -// -------------------------------------------------------------------------- -// Page caching -// -// The page cache is used to store a page temporarily, using the ctools object -// cache. When loading from the page cache, it will either load the cached -// version, or if there is not one, load the real thing and create a cache -// object which can then be easily stored. - -/** - * Get the cached changes to a given task handler. - */ -function page_manager_get_page_cache($task_name) { - $caches = drupal_static(__FUNCTION__, array()); - if (!isset($caches[$task_name])) { - ctools_include('object-cache'); - $cache = ctools_object_cache_get('page_manager_page', $task_name); - if (!$cache) { - $cache = new stdClass(); - $cache->task_name = $task_name; - list($cache->task_id, $cache->subtask_id) = page_manager_get_task_id($cache->task_name); - - $cache->task = page_manager_get_task($cache->task_id); - if (empty($cache->task)) { - return FALSE; - } - - if ($cache->subtask_id) { - $cache->subtask = page_manager_get_task_subtask($cache->task, $cache->subtask_id); - if (empty($cache->subtask)) { - return FALSE; - } - } - else { - $cache->subtask = $cache->task; - $cache->subtask['name'] = ''; - } - - $cache->handlers = page_manager_load_sorted_handlers($cache->task, $cache->subtask_id); - $cache->handler_info = array(); - foreach ($cache->handlers as $id => $handler) { - $cache->handler_info[$id] = array( - 'weight' => $handler->weight, - 'changed' => FALSE, - 'name' => $id, - ); - } - } - else { - // ensure the task is loaded. - page_manager_get_task($cache->task_id); - } - - if ($task_name != '::new') { - $cache->locked = ctools_object_cache_test('page_manager_page', $task_name); - } - else { - $cache->locked = FALSE; - } - - $caches[$task_name] = $cache; - } - - return $caches[$task_name]; -} - -/** - * Store changes to a task handler in the object cache. - */ -function page_manager_set_page_cache($page) { - if (!empty($page->locked)) { - return; - } - - if (empty($page->task_name)) { - return; - } - - ctools_include('object-cache'); - $page->changed = TRUE; - $cache = ctools_object_cache_set('page_manager_page', $page->task_name, $page); -} - -/** - * Remove an item from the object cache. - */ -function page_manager_clear_page_cache($name) { - ctools_include('object-cache'); - ctools_object_cache_clear('page_manager_page', $name); -} - -/** - * Write all changes from the page cache and clear it out. - */ -function page_manager_save_page_cache($cache) { - // Save the subtask: - if ($function = ctools_plugin_get_function($cache->task, 'save subtask callback')) { - $function($cache->subtask, $cache); - } - - // Iterate through handlers and save/delete/update as necessary. - // Go through each of the task handlers, check to see if it needs updating, - // and update it if so. - foreach ($cache->handler_info as $id => $info) { - $handler = &$cache->handlers[$id]; - // If it has been marked for deletion, delete it. - - if ($info['changed'] & PAGE_MANAGER_CHANGED_DELETED) { - page_manager_delete_task_handler($handler); - } - // If it has been somehow edited (or added), write the cached version - elseif ($info['changed'] & PAGE_MANAGER_CHANGED_CACHED) { - // Make sure we get updated weight from the form for this. - $handler->weight = $info['weight']; - page_manager_save_task_handler($handler); - } - // Otherwise, check to see if it has moved and, if so, update the weight. - elseif ($info['weight'] != $handler->weight) { - // Theoretically we could only do this for in code objects, but since our - // load mechanism checks for all, this is less database work. - page_manager_update_task_handler_weight($handler, $info['weight']); - } - - // Set enable/disabled status. - if ($info['changed'] & PAGE_MANAGER_CHANGED_STATUS) { - ctools_include('export'); - ctools_export_set_object_status($cache->handlers[$id], $info['disabled']); - } - } - - page_manager_clear_page_cache($cache->task_name); - - if (!empty($cache->path_changed) || !empty($cache->new)) { - // Force a menu rebuild to make sure the menu entries are set. - menu_rebuild(); - } - cache_clear_all(); -} - -/** - * Menu callback to load a page manager cache object for menu callbacks. - */ -function page_manager_cache_load($task_name) { - // load context plugin as there may be contexts cached here. - ctools_include('context'); - return page_manager_get_page_cache($task_name); -} - -/** - * Generate a unique name for a task handler. - * - * Task handlers need to be named but they aren't allowed to set their own - * names. Instead, they are named based upon their parent task and type. - */ -function page_manager_handler_get_name($task_name, $handlers, $handler) { - $base = str_replace('-', '_', $task_name); - // Generate a unique name. Unlike most named objects, we don't let people choose - // names for task handlers because they mostly don't make sense. - $base .= '_' . $handler->handler; - - // Once we have a base, check to see if it is used. If it is, start counting up. - $name = $base; - $count = 1; - // If taken - while (isset($handlers[$name])) { - $name = $base . '_' . ++$count; - } - - return $name; -} - -/** - * Import a handler into a page. - * - * This is used by both import and clone, since clone just exports the - * handler and immediately imports it. - */ -function page_manager_handler_add_to_page(&$page, &$handler, $title = NULL) { - $last = end($page->handler_info); - $handler->weight = $last ? $last['weight'] + 1 : 0; - $handler->task = $page->task_id; - $handler->subtask = $page->subtask_id; - $handler->export_type = EXPORT_IN_DATABASE; - $handler->type = t('Normal'); - - if ($title) { - $handler->conf['title'] = $title; - } - - $name = page_manager_handler_get_name($page->task_name, $page->handlers, $handler); - - $handler->name = $name; - - $page->handlers[$name] = $handler; - $page->handler_info[$name] = array( - 'weight' => $handler->weight, - 'name' => $handler->name, - 'changed' => PAGE_MANAGER_CHANGED_CACHED, - ); -} - -// -------------------------------------------------------------------------- -// Database routines -// -// This includes fetching plugins and plugin info as well as specialized -// fetch methods to get groups of task handlers per task. - -/** - * Load a single task handler by name. - * - * Handlers can come from multiple sources; either the database or by normal - * export method, which is handled by the ctools library, but handlers can - * also be bundled with task/subtask. We have to check there and perform - * overrides as appropriate. - * - * Handlers bundled with the task are of a higher priority than default - * handlers provided by normal code, and are of a lower priority than - * the database, so we have to check the source of handlers when we have - * multiple to choose from. - */ -function page_manager_load_task_handler($task, $subtask_id, $name) { - ctools_include('export'); - $result = ctools_export_load_object('page_manager_handlers', 'names', array($name)); - $handlers = page_manager_get_default_task_handlers($task, $subtask_id); - return page_manager_compare_task_handlers($result, $handlers, $name); -} - -/** - * Load all task handlers for a given task/subtask. - */ -function page_manager_load_task_handlers($task, $subtask_id = NULL, $default_handlers = NULL) { - ctools_include('export'); - $conditions = array( - 'task' => $task['name'], - ); - - if (isset($subtask_id)) { - $conditions['subtask'] = $subtask_id; - } - - $handlers = ctools_export_load_object('page_manager_handlers', 'conditions', $conditions); - $defaults = isset($default_handlers) ? $default_handlers : page_manager_get_default_task_handlers($task, $subtask_id); - foreach ($defaults as $name => $default) { - $result = page_manager_compare_task_handlers($handlers, $defaults, $name); - - if ($result) { - $handlers[$name] = $result; - // Ensure task and subtask are correct, because it's easy to change task - // names when editing a default and fail to do it on the associated handlers. - $result->task = $task['name']; - $result->subtask = $subtask_id; - } - } - - // Override weights from the weight table. - if ($handlers) { - $names = array(); - $placeholders = array(); - foreach ($handlers as $handler) { - $names[] = $handler->name; - $placeholders[] = "'%s'"; - } - - $result = db_query('SELECT name, weight FROM {page_manager_weights} WHERE name IN (:names)', array(':names' => $names)); - foreach ($result as $weight) { - $handlers[$weight->name]->weight = $weight->weight; - } - } - - return $handlers; -} - -/** - * Get the default task handlers from a task, if they exist. - * - * Tasks can contain 'default' task handlers which are provided by the - * default task. Because these can come from either the task or the - * subtask, the logic is abstracted to reduce code duplication. - */ -function page_manager_get_default_task_handlers($task, $subtask_id) { - // Load default handlers that are provied by the task/subtask itself. - $handlers = array(); - if ($subtask_id) { - $subtask = page_manager_get_task_subtask($task, $subtask_id); - if (isset($subtask['default handlers'])) { - $handlers = $subtask['default handlers']; - } - } - else if (isset($task['default handlers'])) { - $handlers = $task['default handlers']; - } - - return $handlers; -} - -/** - * Compare a single task handler from two lists and provide the correct one. - * - * Task handlers can be gotten from multiple sources. As exportable objects, - * they can be provided by default hooks and the database. But also, because - * they are tightly bound to tasks, they can also be provided by default - * tasks. This function reconciles where to pick up a task handler between - * the exportables list and the defaults provided by the task itself. - * - * @param $result - * A list of handlers provided by export.inc - * @param $handlers - * A list of handlers provided by the default task. - * @param $name - * Which handler to compare. - * @return - * Which handler to use, if any. May be NULL. - */ -function page_manager_compare_task_handlers($result, $handlers, $name) { - // Compare our special default handler against the actual result, if - // any, and do the right thing. - if (!isset($result[$name]) && isset($handlers[$name])) { - $handlers[$name]->type = t('Default'); - $handlers[$name]->export_type = EXPORT_IN_CODE; - return $handlers[$name]; - } - else if (isset($result[$name]) && !isset($handlers[$name])) { - return $result[$name]; - } - else if (isset($result[$name]) && isset($handlers[$name])) { - if ($result[$name]->export_type & EXPORT_IN_DATABASE) { - $result[$name]->type = t('Overridden'); - $result[$name]->export_type = $result[$name]->export_type | EXPORT_IN_CODE; - return $result[$name]; - } - else { - // In this case, our default is a higher priority than the standard default. - $handlers[$name]->type = t('Default'); - $handlers[$name]->export_type = EXPORT_IN_CODE; - return $handlers[$name]; - } - } -} - -/** - * Load all task handlers for a given task and subtask and sort them. - */ -function page_manager_load_sorted_handlers($task, $subtask_id = NULL, $enabled = FALSE) { - $handlers = page_manager_load_task_handlers($task, $subtask_id); - if ($enabled) { - foreach ($handlers as $id => $handler) { - if (!empty($handler->disabled)) { - unset($handlers[$id]); - } - } - } - uasort($handlers, 'page_manager_sort_task_handlers'); - return $handlers; -} - -/** - * Callback for uasort to sort task handlers. - * - * Task handlers are sorted by weight then by name. - */ -function page_manager_sort_task_handlers($a, $b) { - if ($a->weight < $b->weight) { - return -1; - } - elseif ($a->weight > $b->weight) { - return 1; - } - elseif ($a->name < $b->name) { - return -1; - } - elseif ($a->name > $b->name) { - return 1; - } - - return 0; -} - -/** - * Write a task handler to the database. - */ -function page_manager_save_task_handler(&$handler) { - $update = (isset($handler->did)) ? array('did') : array(); - // Let the task handler respond to saves: - if ($function = ctools_plugin_load_function('page_manager', 'task_handlers', $handler->handler, 'save')) { - $function($handler, $update); - } - - drupal_write_record('page_manager_handlers', $handler, $update); - db_delete('page_manager_weights') - ->condition('name', $handler->name) - ->execute(); - - // If this was previously a default handler, we may have to write task handlers. - if (!$update) { - // @todo wtf was I going to do here? - } - return $handler; -} - -/** - * Remove a task handler. - */ -function page_manager_delete_task_handler($handler) { - // Let the task handler respond to saves: - if ($function = ctools_plugin_load_function('page_manager', 'task_handlers', $handler->handler, 'delete')) { - $function($handler); - } - db_delete('page_manager_handlers') - ->condition('name', $handler->name) - ->execute(); - db_delete('page_manager_weights') - ->condition('name', $handler->name) - ->execute(); -} - -/** - * Export a task handler into code suitable for import or use as a default - * task handler. - */ -function page_manager_export_task_handler($handler, $indent = '') { - ctools_include('export'); - ctools_include('plugins'); - $handler = clone $handler; - - $append = ''; - if ($function = ctools_plugin_load_function('page_manager', 'task_handlers', $handler->handler, 'export')) { - $append = $function($handler, $indent); - } - - $output = ctools_export_object('page_manager_handlers', $handler, $indent); - $output .= $append; - - return $output; -} - -/** - * Create a new task handler object. - * - * @param $plugin - * The plugin this task handler is created from. - */ -function page_manager_new_task_handler($plugin) { - // Generate a unique name. Unlike most named objects, we don't let people choose - // names for task handlers because they mostly don't make sense. - - // Create a new, empty handler object. - $handler = new stdClass; - $handler->title = $plugin['title']; - $handler->task = NULL; - $handler->subtask = NULL; - $handler->name = NULL; - $handler->handler = $plugin['name']; - $handler->weight = 0; - $handler->conf = array(); - - // These are provided by the core export API provided by ctools and we - // set defaults here so that we don't cause notices. Perhaps ctools should - // provide a way to do this for us so we don't have to muck with it. - $handler->export_type = EXPORT_IN_DATABASE; - $handler->type = t('Local'); - - if (isset($plugin['default conf'])) { - if (is_array($plugin['default conf'])) { - $handler->conf = $plugin['default conf']; - } - else if (function_exists($plugin['default conf'])) { - $handler->conf = $plugin['default conf']($handler); - } - } - - return $handler; -} - -/** - * Set an overidden weight for a task handler. - * - * We do this so that in-code task handlers don't need to get written - * to the database just because they have their weight changed. - */ -function page_manager_update_task_handler_weight($handler, $weight) { - db_delete('page_manager_weights') - ->condition('name', $handler->name) - ->execute(); - db_insert('page_manager_weights') - ->fields(array( - 'name' => $handler->name, - 'weight' => $weight, - )) - ->execute(); -} - - -/** - * Shortcut function to get task plugins. - */ -function page_manager_get_tasks() { - ctools_include('plugins'); - return ctools_get_plugins('page_manager', 'tasks'); -} - -/** - * Shortcut function to get a task plugin. - */ -function page_manager_get_task($id) { - ctools_include('plugins'); - return ctools_get_plugins('page_manager', 'tasks', $id); -} - -/** - * Get all tasks for a given type. - */ -function page_manager_get_tasks_by_type($type) { - ctools_include('plugins'); - $all_tasks = ctools_get_plugins('page_manager', 'tasks'); - $tasks = array(); - foreach ($all_tasks as $id => $task) { - if (isset($task['task type']) && $task['task type'] == $type) { - $tasks[$id] = $task; - } - } - - return $tasks; -} - -/** - * Fetch all subtasks for a page managertask. - * - * @param $task - * A loaded $task plugin object. - */ -function page_manager_get_task_subtasks($task) { - if (empty($task['subtasks'])) { - return array(); - } - - if ($function = ctools_plugin_get_function($task, 'subtasks callback')) { - $retval = $function($task); - if (is_array($retval)) { - return $retval; - } - else { - dsm($retval); - } - } - - return array(); -} - -/** - * Fetch all subtasks for a page managertask. - * - * @param $task - * A loaded $task plugin object. - * @param $subtask_id - * The subtask ID to load. - */ -function page_manager_get_task_subtask($task, $subtask_id) { - if (empty($task['subtasks'])) { - return; - } - - if ($function = ctools_plugin_get_function($task, 'subtask callback')) { - return $function($task, $subtask_id); - } -} - -/** - * Shortcut function to get task handler plugins. - */ -function page_manager_get_task_handlers() { - ctools_include('plugins'); - return ctools_get_plugins('page_manager', 'task_handlers'); -} - -/** - * Shortcut function to get a task handler plugin. - */ -function page_manager_get_task_handler($id) { - ctools_include('plugins'); - return ctools_get_plugins('page_manager', 'task_handlers', $id); -} - -/** - * Retrieve a list of all applicable task handlers for a given task. - * - * This looks at the $task['handler type'] and compares that to $task_handler['handler type']. - * If the task has no type, the id of the task is used instead. - */ -function page_manager_get_task_handler_plugins($task, $all = FALSE) { - $type = isset($task['handler type']) ? $task['handler type'] : $task['name']; - $name = $task['name']; - - $handlers = array(); - $task_handlers = page_manager_get_task_handlers(); - foreach ($task_handlers as $id => $handler) { - $task_type = is_array($handler['handler type']) ? $handler['handler type'] : array($handler['handler type']); - if (in_array($type, $task_type) || in_array($name, $task_type)) { - if ($all || !empty($handler['visible'])) { - $handlers[$id] = $handler; - } - } - } - - return $handlers; -} - -/** - * Get the title for a given handler. - * - * If the plugin has no 'admin title' function, the generic title of the - * plugin is used instead. - */ -function page_manager_get_handler_title($plugin, $handler, $task, $subtask_id) { - $function = ctools_plugin_get_function($plugin, 'admin title'); - if ($function) { - return $function($handler, $task, $subtask_id); - } - else { - return $plugin['title']; - } -} - -/** - * Get the admin summary (additional info) for a given handler. - */ -function page_manager_get_handler_summary($plugin, $handler, $page, $title = TRUE) { - if ($function = ctools_plugin_get_function($plugin, 'admin summary')) { - return $function($handler, $page->task, $page->subtask, $page, $title); - } -} - -/** - * Get the admin summary (additional info) for a given page. - */ -function page_manager_get_page_summary($task, $subtask) { - if ($function = ctools_plugin_get_function($subtask, 'admin summary')) { - return $function($task, $subtask); - } -} - -/** - * Split a task name into a task id and subtask id, if applicable. - */ -function page_manager_get_task_id($task_name) { - if (strpos($task_name, '-') !== FALSE) { - return explode('-', $task_name, 2); - } - else { - return array($task_name, NULL); - } -} - -/** - * Turn a task id + subtask_id into a task name. - */ -function page_manager_make_task_name($task_id, $subtask_id) { - if ($subtask_id) { - return $task_id . '-' . $subtask_id; - } - else { - return $task_id; - } -} - -/** - * Get the render function for a handler. - */ -function page_manager_get_renderer($handler) { - return ctools_plugin_load_function('page_manager', 'task_handlers', $handler->handler, 'render'); -} - -// -------------------------------------------------------------------------- -// Functions existing on behalf of tasks and task handlers - - -/** - * Page manager arg load function because menu system will not load extra - * files for these; they must be in a .module. - */ -function pm_arg_load($value, $subtask, $argument) { - page_manager_get_task('page'); - return _pm_arg_load($value, $subtask, $argument); -} - -/** - * Special arg_load function to use %menu_tail like functionality to - * get everything after the arg together as a single value. - */ -function pm_arg_tail_load($value, $subtask, $argument, $map) { - $value = implode('/', array_slice($map, $argument)); - page_manager_get_task('page'); - return _pm_arg_load($value, $subtask, $argument); -} - -/** - * Special menu _load() function for the user:uid argument. - * - * This is just the normal page manager argument. It only exists so that - * the to_arg can exist. - */ -function pm_uid_arg_load($value, $subtask, $argument) { - page_manager_get_task('page'); - return _pm_arg_load($value, $subtask, $argument); -} - -/** - * to_arg function for the user:uid argument to provide the arg for the - * current global user. - */ -function pm_uid_arg_to_arg($arg) { - return user_uid_optional_to_arg($arg); -} - -/** - * Callback for access control ajax form on behalf of page.inc task. - * - * Returns the cached access config and contexts used. - */ -function page_manager_page_ctools_access_get($argument) { - $page = page_manager_get_page_cache($argument); - - $contexts = array(); - - // Load contexts based on argument data: - if ($arguments = _page_manager_page_get_arguments($page->subtask['subtask'])) { - $contexts = ctools_context_get_placeholders_from_argument($arguments); - } - - return array($page->subtask['subtask']->access, $contexts); -} - -/** - * Callback for access control ajax form on behalf of page.inc task. - * - * Writes the changed access to the cache. - */ -function page_manager_page_ctools_access_set($argument, $access) { - $page = page_manager_get_page_cache($argument); - $page->subtask['subtask']->access = $access; - page_manager_set_page_cache($page); -} - -/** - * Callback for access control ajax form on behalf of context task handler. - * - * Returns the cached access config and contexts used. - */ -function page_manager_task_handler_ctools_access_get($argument) { - list($task_name, $name) = explode('*', $argument); - $page = page_manager_get_page_cache($task_name); - if (empty($name)) { - $handler = &$page->new_handler; - } - else { - $handler = &$page->handlers[$name]; - } - - if (!isset($handler->conf['access'])) { - $handler->conf['access'] = array(); - } - - ctools_include('context-task-handler'); - - $contexts = ctools_context_handler_get_all_contexts($page->task, $page->subtask, $handler); - - return array($handler->conf['access'], $contexts); -} - -/** - * Callback for access control ajax form on behalf of context task handler. - * - * Writes the changed access to the cache. - */ -function page_manager_task_handler_ctools_access_set($argument, $access) { - list($task_name, $name) = explode('*', $argument); - $page = page_manager_get_page_cache($task_name); - if (empty($name)) { - $handler = &$page->new_handler; - } - else { - $handler = &$page->handlers[$name]; - } - - $handler->conf['access'] = $access; - page_manager_set_page_cache($page); -} - -/** - * Form a URL to edit a given page given the trail. - */ -function page_manager_edit_url($task_name, $trail = array()) { - if (!is_array($trail)) { - $trail = array($trail); - } - - if (empty($trail) || $trail == array('summary')) { - return "admin/structure/pages/edit/$task_name"; - } - - return 'admin/structure/pages/nojs/operation/' . $task_name . '/' . implode('/', $trail); -} - -/** - * Watch menu links during the menu rebuild, and re-parent things if we need to. - */ -function page_manager_menu_link_alter(&$item) { - return; -/** -- disabled, concept code -- - static $mlids = array(); - // Keep an array of mlids as links are saved that we can use later. - if (isset($item['mlid'])) { - $mlids[$item['path']] = $item['mlid']; - } - - if (isset($item['parent_path'])) { - if (isset($mlids[$item['parent_path']])) { - $item['plid'] = $mlids[$item['parent_path']]; - } - else { - // Since we didn't already see an mlid, let's check the database for one. - $mlid = db_query('SELECT mlid FROM {menu_links} WHERE router_path = :path', array('path' => $item['parent_path']))->fetchField(); - if ($mlid) { - $item['plid'] = $mlid; - } - } - } - */ -} - -/** - * Callback to list handlers available for export. - */ -function page_manager_page_manager_handlers_list() { - $list = $types = array(); - $tasks = page_manager_get_tasks(); - foreach ($tasks as $type => $info) { - if (empty($info['non-exportable'])) { - $types[] = $type; - } - } - - $handlers = ctools_export_load_object('page_manager_handlers'); - foreach ($handlers as $handler) { - if (in_array($handler->task, $types)) { - $list[$handler->name] = check_plain("$handler->task: " . $handler->conf['title'] . " ($handler->name)"); - } - } - return $list; -} - -/** - * Callback to bulk export page manager pages. - */ -function page_manager_page_manager_pages_to_hook_code($names = array(), $name = 'foo') { - $schema = ctools_export_get_schema('page_manager_pages'); - $export = $schema['export']; - $objects = ctools_export_load_object('page_manager_pages', 'names', array_values($names)); - if ($objects) { - $code = "/**\n"; - $code .= " * Implements hook_{$export['default hook']}()\n"; - $code .= " */\n"; - $code .= "function " . $name . "_{$export['default hook']}() {\n"; - foreach ($objects as $object) { - // Have to implement our own because this export func sig requires it - $code .= $export['export callback']($object, TRUE, ' '); - $code .= " \${$export['identifier']}s['" . check_plain($object->$export['key']) . "'] = \${$export['identifier']};\n\n"; - } - $code .= " return \${$export['identifier']}s;\n"; - $code .= "}\n"; - return $code; - } -} - -/** - * Get the current page information. - * - * @return $page - * An array containing the following information. - * - * - 'name': The name of the page as used in the page manager admin UI. - * - 'task': The plugin for the task in use. If this is a system page it - * will contain information about that page, such as what functions - * it uses. - * - 'subtask': The plugin for the subtask. If this is a custom page, this - * will contain information about that custom page. See 'subtask' in this - * array to get the actual page object. - * - 'handler': The actual handler object used. If using panels, see - * $page['handler']->conf['display'] for the actual panels display - * used to render. - * - 'contexts': The context objects used to render this page. - * - 'arguments': The raw arguments from the URL used on this page. - */ -function page_manager_get_current_page($page = NULL) { - static $current = array(); - if (isset($page)) { - $current = $page; - } - - return $current; -} - -/** - * Implementation of hook_panels_dashboard_blocks(). - * - * Adds page information to the Panels dashboard. - */ -function page_manager_panels_dashboard_blocks(&$vars) { - $vars['links']['page_manager'] = array( - 'weight' => -100, - 'title' => l(t('Panel page'), 'admin/structure/pages/add'), - 'description' => t('Panel pages can be used as landing pages. They have a URL path, accept arguments and can have menu entries.'), - ); - - module_load_include('inc', 'page_manager', 'page_manager.admin'); - $tasks = page_manager_get_tasks_by_type('page'); - $pages = array('operations' => array()); - - page_manager_get_pages($tasks, $pages); - $count = 0; - $rows = array(); - foreach ($pages['rows'] as $id => $info) { - $rows[] = array( - 'data' => array( - $info['data']['title'], - $info['data']['operations'], - ), - 'class' => $info['class'], - ); - - // Only show 10. - if (++$count >= 10) { - break; - } - } - - $vars['blocks']['page_manager'] = array( - 'weight' => -100, - 'title' => t('Manage pages'), - 'link' => l(t('Go to list'), 'admin/structure/pages'), - 'content' => theme('table', array('header' => array(), 'rows' => $rows, 'attributes' => array('class' => 'panels-manage'))), - 'class' => 'dashboard-pages', - 'section' => 'right', - ); -} diff --git a/page_manager/plugins/cache/page_manager_context.inc b/page_manager/plugins/cache/page_manager_context.inc deleted file mode 100644 index 2f01b56..0000000 --- a/page_manager/plugins/cache/page_manager_context.inc +++ /dev/null @@ -1,70 +0,0 @@ - t('Page manager context'), - 'cache get' => 'page_manager_cache_page_manager_context_cache_get', - 'cache set' => 'page_manager_cache_page_manager_context_cache_set', - 'cache finalize' => 'page_manager_cache_page_manager_context_cache_finalize', - - // We don't support a clear because the general uses of clear have no effect - // on us. -); - -function page_manager_cache_page_manager_context_cache_get($data, $key) { - $page = page_manager_get_page_cache($data); - if ($page) { - if (!empty($page->context_cache[$key])) { - return $page->context_cache[$key]; - } - else { - ctools_include('context-task-handler'); - if ($key == 'temp') { - $handler = $page->new_handler; - } - else { - $handler = $page->handlers[$key]; - } - return ctools_context_handler_get_task_object($page->task, $page->subtask, $handler); - } - } -} - -function page_manager_cache_page_manager_context_cache_set($data, $key, $object) { - $page = page_manager_get_page_cache($data); - if ($page) { - $page->context_cache[$key] = $object; - return page_manager_set_page_cache($page); - } -} - -/** - * Copy temporary data from the page manager cache - */ -function page_manager_cache_page_manager_context_cache_finalize($data, $key, $object) { - // Statically cached so there shouldn't be any worries. It's an object so - // referencing ensures that we'll get the right one. - $page = page_manager_get_page_cache($data); - if ($page) { - if ($key == 'temp') { - $handler = $page->new_handler; - } - else { - $handler = $page->handlers[$key]; - } - $handler->conf['contexts'] = $object->contexts; - $handler->conf['relationships'] = $object->relationships; - - if (isset($page->context_cache[$key])) { - unset($page->context_cache[$key]); - } - return page_manager_set_page_cache($page); - } -} diff --git a/page_manager/plugins/task_handlers/http_response.inc b/page_manager/plugins/task_handlers/http_response.inc deleted file mode 100644 index 3e74ace..0000000 --- a/page_manager/plugins/task_handlers/http_response.inc +++ /dev/null @@ -1,286 +0,0 @@ - 'context', - 'visible' => TRUE, // may be added up front. - - // Administrative fields. - 'title' => t('HTTP response code'), - 'admin summary' =>'page_manager_http_response_admin_summary', - 'admin title' => 'page_manager_http_response_title', - 'operations' => array( - 'settings' => array( - 'title' => t('General'), - 'description' => t('Change general settings for this variant.'), - 'form' => 'page_manager_http_response_edit_settings', - ), - 'criteria' => array( - 'title' => t('Selection rules'), - 'description' => t('Control the criteria used to decide whether or not this variant is used.'), - 'ajax' => FALSE, - 'form' => array( - 'order' => array( - 'form' => t('Selection rules'), - ), - 'forms' => array( - 'form' => array( - 'include' => drupal_get_path('module', 'ctools') . '/includes/context-task-handler.inc', - 'form id' => 'ctools_context_handler_edit_criteria', - ), - ), - ), - ), - 'context' => array( - 'title' => t('Contexts'), - 'ajax' => FALSE, - 'description' => t('Add additional context objects to this variant that can be used by the content.'), - 'form' => array( - 'order' => array( - 'form' => t('Context'), - ), - 'forms' => array( - 'form' => array( - 'include' => drupal_get_path('module', 'ctools') . '/includes/context-task-handler.inc', - 'form id' => 'ctools_context_handler_edit_context', - ), - ), - ), - ), - ), - - // Callback to render the data. - 'render' => 'page_manager_http_response_render', - - 'add features' => array( - 'criteria' => t('Selection rules'), - 'context' => t('Contexts'), - ), - // Where to go when finished. - 'add finish' => 'settings', - - 'required forms' => array( - 'settings' => t('Panel settings'), - ), - - 'edit forms' => array( - 'criteria' => t('Selection rules'), - 'settings' => t('General'), - 'context' => t('Contexts'), - ), - 'forms' => array( - 'settings' => array( - 'form id' => 'page_manager_http_response_edit_settings', - ), - 'context' => array( - 'include' => drupal_get_path('module', 'ctools') . '/includes/context-task-handler.inc', - 'form id' => 'ctools_context_handler_edit_context', - ), - 'criteria' => array( - 'include' => drupal_get_path('module', 'ctools') . '/includes/context-task-handler.inc', - 'form id' => 'ctools_context_handler_edit_criteria', - ), - ), - 'default conf' => array( - 'title' => t('HTTP response code'), - 'contexts' => array(), - 'relationships' => array(), - 'code' => '404', - 'destination' => '', - ), -); - -/** - * Provide a list of the response codes we support. - * - * Abstracted so it can be more readily used both on input and output. - */ -function page_manager_http_response_codes() { - return array( - 404 => t('404 Page not found'), - 403 => t('403 Access denied'), - 301 => t('301 Redirect'), - ); -} - -function page_manager_http_response_admin_summary($handler, $task, $subtask, $page, $show_title = TRUE) { - $task_name = page_manager_make_task_name($task['name'], $subtask['name']); - $output = ''; - - ctools_include('context'); - ctools_include('context-task-handler'); - - // Get the operations - $operations = page_manager_get_operations($page); - - // Get operations for just this handler. - $operations = $operations['handlers']['children'][$handler->name]['children']['actions']['children']; - $args = array('handlers', $handler->name, 'actions'); - $rendered_operations = page_manager_render_operations($page, $operations, array(), array('class' => array('actions')), 'actions', $args); - - $plugin = page_manager_get_task_handler($handler->handler); - - $object = ctools_context_handler_get_task_object($task, $subtask, $handler); - $display->context = ctools_context_load_contexts($object, TRUE); - - $access = ctools_access_group_summary(!empty($handler->conf['access']) ? $handler->conf['access'] : array(), $display->context); - if ($access) { - $access = t('This panel will be selected if @conditions.', array('@conditions' => $access)); - } - else { - $access = t('This panel will always be selected.'); - } - - $rows = array(); - - $type = $handler->type == t('Default') ? t('In code') : $handler->type; - $rows[] = array( - array('class' => array('page-summary-label'), 'data' => t('Storage')), - array('class' => array('page-summary-data'), 'data' => $type), - array('class' => array('page-summary-operation'), 'data' => ''), - ); - - if (!empty($handler->disabled)) { - $link = l(t('Enable'), page_manager_edit_url($task_name, array('handlers', $handler->name, 'actions', 'enable'))); - $text = t('Disabled'); - } - else { - $link = l(t('Disable'), page_manager_edit_url($task_name, array('handlers', $handler->name, 'actions', 'disable'))); - $text = t('Enabled'); - } - - $rows[] = array( - array('class' => array('page-summary-label'), 'data' => t('Status')), - array('class' => array('page-summary-data'), 'data' => $text), - array('class' => array('page-summary-operation'), 'data' => $link), - ); - - $link = l(t('Edit'), page_manager_edit_url($task_name, array('handlers', $handler->name, 'criteria'))); - $rows[] = array( - array('class' => array('page-summary-label'), 'data' => t('Selection rule')), - array('class' => array('page-summary-data'), 'data' => $access), - array('class' => array('page-summary-operation'), 'data' => $link), - ); - - $link = l(t('Edit'), page_manager_edit_url($task_name, array('handlers', $handler->name, 'settings'))); - $codes = page_manager_http_response_codes(); - $rows[] = array( - array('class' => array('page-summary-label'), 'data' => t('Response code')), - array('class' => array('page-summary-data'), 'data' => $codes[$handler->conf['code']]), - array('class' => array('page-summary-operation'), 'data' => $link), - ); - - $info = theme('table', array('header' => array(), 'rows' => $rows, 'attributes' => array('class' => array('page-manager-handler-summary')))); - - $title = $handler->conf['title']; - if ($title != t('Panel')) { - $title = t('Panel: @title', array('@title' => $title)); - } - - $output .= '
    '; - if ($show_title) { - $output .= '
    '; - $output .= '
    ' . $rendered_operations['actions'] . '
    '; - $output .= '' . $title . ''; - } - - $output .= '
    '; - $output .= $info; - $output .= '
    '; - - return $output; -} - -/** - * Set up a title for the panel based upon the selection rules. - */ -function page_manager_http_response_title($handler, $task, $subtask) { - if (isset($handler->conf['title'])) { - return check_plain($handler->conf['title']); - } - else { - return t('HTTP response code'); - } -} - -/** - * General settings for the panel - */ -function page_manager_http_response_edit_settings(&$form, &$form_state) { - $conf = $form_state['handler']->conf; - $form['title'] = array( - '#type' => 'textfield', - '#default_value' => $conf['title'], - '#title' => t('Administrative title'), - '#description' => t('Administrative title of this variant.'), - ); - - $form['code'] = array( - '#title' => t('Response code'), - '#type' => 'select', - '#options' => page_manager_http_response_codes(), - '#default_value' => $conf['code'], - ); - - ctools_include('dependent'); - $form['destination'] = array( - '#type' => 'textfield', - '#title' => t('Redirect destination'), - '#default_value' => $conf['destination'], - '#process' => array('ctools_dependent_process'), - '#dependency' => array('edit-code' => array(301)), - '#description' => t('Enter the path to redirect to. You may use keyword substitutions from contexts. You can use external urls (http://www.example.com/foo) or internal urls (node/1).'), - ); - - return $form; -} - -function page_manager_http_response_edit_settings_submit(&$form, &$form_state) { - $form_state['handler']->conf['title'] = $form_state['values']['title']; - $form_state['handler']->conf['code'] = $form_state['values']['code']; - $form_state['handler']->conf['destination'] = $form_state['values']['destination']; -} - -function page_manager_http_response_render($handler, $base_contexts, $args, $test = TRUE) { - // Go through arguments and see if they match. - ctools_include('context'); - ctools_include('context-task-handler'); - - // Add my contexts - $contexts = ctools_context_handler_get_handler_contexts($base_contexts, $handler); - - // Test. - if ($test && !ctools_context_handler_select($handler, $contexts)) { - return; - } - - if (isset($handler->handler)) { - ctools_context_handler_pre_render($handler, $contexts, $args); - } - - $info['response code'] = $handler->conf['code']; - if ($info['response code'] == 301) { - $path = ctools_context_keyword_substitute($handler->conf['destination'], array(), $contexts); - $url = parse_url($path); - if (isset($url['query'])) { - $path = strtr($path, array('?' . $url['query'] => '')); - $info['query'] = $url['query']; - } - if (isset($url['fragment'])) { - $path = strtr($path, array('#' . $url['fragment'] => '')); - $info['fragment'] = $url['fragment']; - } - - $info['destination'] = $path; - } - - return $info; -} \ No newline at end of file diff --git a/page_manager/plugins/tasks/blog.inc b/page_manager/plugins/tasks/blog.inc deleted file mode 100644 index 8d62e98..0000000 --- a/page_manager/plugins/tasks/blog.inc +++ /dev/null @@ -1,104 +0,0 @@ - 'page', - - 'title' => t('All blogs'), - 'admin title' => t('All blogs'), - 'admin description' => t('When enabled, this overrides the default Drupal behavior for the all blogs at /blog. If no variant is selected, the default Drupal most recent blog posts will be shown.'), - 'admin path' => 'blog', - - // Menu hooks so that we can alter the node/%node menu entry to point to us. - 'hook menu alter' => 'page_manager_blog_menu_alter', - - // This is task uses 'context' handlers and must implement these to give the - // handler data it needs. - 'handler type' => 'context', - - // Allow this to be enabled or disabled: - 'disabled' => variable_get('page_manager_blog_disabled', TRUE), - 'enable callback' => 'page_manager_blog_enable', - ); -} - -/** - * Callback defined by page_manager_blog_page_manager_tasks(). - * - * Alter the node edit input so that node edit comes to us rather than the - * normal node edit process. - */ -function page_manager_blog_menu_alter(&$items, $task) { - if (variable_get('page_manager_blog_disabled', TRUE)) { - return; - } - - $callback = $items['blog']['page callback']; - // Override the node edit handler for our purpose. - if ($callback == 'blog_page_last' || variable_get('page_manager_override_anyway', FALSE)) { - $items['blog']['page callback'] = 'page_manager_blog'; - $items['blog']['file path'] = $task['path']; - $items['blog']['file'] = $task['file']; - } - else { - variable_set('page_manager_blog_disabled', TRUE); - if (!empty($GLOBALS['page_manager_enabling_blog'])) { - drupal_set_message(t('Page manager module is unable to enable blog because some other module already has overridden with %callback.', array('%callback' => $callback)), 'warning'); - } - return; - } - -} - -/** - * Entry point for our overridden node edit. - * - * This function asks its assigned handlers who, if anyone, would like - * to run with it. If no one does, it passes through to Drupal core's - * node edit, which is node_page_edit(). - */ -function page_manager_blog() { - // Load my task plugin - $task = page_manager_get_task('blog'); - - ctools_include('context'); - ctools_include('context-task-handler'); - $output = ctools_context_handler_render($task, '', array(), array()); - if ($output !== FALSE) { - return $output; - } - - module_load_include('inc', 'blog', 'blog.pages'); - $function = 'blog_page_last'; - foreach (module_implements('page_manager_override') as $module) { - $call = $module . '_page_manager_override'; - if (($rc = $call('blog')) && function_exists($rc)) { - $function = $rc; - break; - } - } - - // Otherwise, fall back. - return $function(); -} - -/** - * Callback to enable/disable the page from the UI. - */ -function page_manager_blog_enable($cache, $status) { - variable_set('page_manager_blog_disabled', $status); - // Set a global flag so that the menu routine knows it needs - // to set a message if enabling cannot be done. - if (!$status) { - $GLOBALS['page_manager_enabling_blog'] = TRUE; - } -} diff --git a/page_manager/plugins/tasks/blog_user.inc b/page_manager/plugins/tasks/blog_user.inc deleted file mode 100644 index 8ad43d0..0000000 --- a/page_manager/plugins/tasks/blog_user.inc +++ /dev/null @@ -1,134 +0,0 @@ - 'page', - 'title' => t('User blog'), - 'admin title' => t('User blog'), - 'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying user blogs at blog/%user. If no variant is selected, the default Drupal user blog will be used.'), - 'admin path' => 'blog/%user', - - // Callback to add items to the page managertask administration form: - 'task admin' => 'page_manager_blog_user_task_admin', - - 'hook menu alter' => 'page_manager_blog_user_menu_alter', - - // This is task uses 'context' handlers and must implement these to give the - // handler data it needs. - 'handler type' => 'context', // handler type -- misnamed - 'get arguments' => 'page_manager_blog_user_get_arguments', - 'get context placeholders' => 'page_manager_blog_user_get_contexts', - - // Allow this to be enabled or disabled: - 'disabled' => variable_get('page_manager_blog_user_disabled', TRUE), - 'enable callback' => 'page_manager_blog_user_enable', - ); -} - -/** - * Callback defined by page_manager_blog_user_page_manager_tasks(). - * - * Alter the user view input so that user view comes to us rather than the - * normal user view process. - */ -function page_manager_blog_user_menu_alter(&$items, $task) { - if (variable_get('page_manager_blog_user_disabled', TRUE)) { - return; - } - - // Override the user view handler for our purpose. - if ($items['blog/%user_uid_optional']['page callback'] == 'blog_page_user' || variable_get('page_manager_override_anyway', FALSE)) { - $items['blog/%user_uid_optional']['page callback'] = 'page_manager_blog_user'; - $items['blog/%user_uid_optional']['file path'] = $task['path']; - $items['blog/%user_uid_optional']['file'] = $task['file']; - } - else { - // automatically disable this task if it cannot be enabled. - variable_set('page_manager_blog_user_disabled', TRUE); - if (!empty($GLOBALS['page_manager_enabling_blog_user'])) { - drupal_set_message(t('Page manager module is unable to enable blog/%user because some other module already has overridden with %callback.', array('%callback' => $items['blog/%user']['page callback'])), 'error'); - } - } -} - -/** - * Entry point for our overridden user view. - * - * This function asks its assigned handlers who, if anyone, would like - * to run with it. If no one does, it passes through to Drupal core's - * user view, which is user_page_view(). - */ -function page_manager_blog_user($account) { - // Load my task plugin: - $task = page_manager_get_task('blog_user'); - - // Load the account into a context. - ctools_include('context'); - ctools_include('context-task-handler'); - $contexts = ctools_context_handler_get_task_contexts($task, '', array($account)); - - $output = ctools_context_handler_render($task, '', $contexts, array($account->uid)); - if ($output !== FALSE) { - return $output; - } - - module_load_include('inc', 'blog', 'blog.pages'); - $function = 'blog_page_user'; - foreach (module_implements('page_manager_override') as $module) { - $call = $module . '_page_manager_override'; - if (($rc = $call('blog_user')) && function_exists($rc)) { - $function = $rc; - break; - } - } - - // Otherwise, fall back. - return $function($account); -} - -/** - * Callback to get arguments provided by this task handler. - * - * Since this is the node view and there is no UI on the arguments, we - * create dummy arguments that contain the needed data. - */ -function page_manager_blog_user_get_arguments($task, $subtask_id) { - return array( - array( - 'keyword' => 'user', - 'identifier' => t('User being viewed'), - 'id' => 1, - 'name' => 'uid', - 'settings' => array(), - ), - ); -} - -/** - * Callback to get context placeholders provided by this handler. - */ -function page_manager_blog_user_get_contexts($task, $subtask_id) { - return ctools_context_get_placeholders_from_argument(page_manager_blog_user_get_arguments($task, $subtask_id)); -} - -/** - * Callback to enable/disable the page from the UI. - */ -function page_manager_blog_user_enable($cache, $status) { - variable_set('page_manager_blog_user_disabled', $status); - - // Set a global flag so that the menu routine knows it needs - // to set a message if enabling cannot be done. - if (!$status) { - $GLOBALS['page_manager_enabling_blog_user'] = TRUE; - } -} diff --git a/page_manager/plugins/tasks/contact_site.inc b/page_manager/plugins/tasks/contact_site.inc deleted file mode 100644 index d55f4c4..0000000 --- a/page_manager/plugins/tasks/contact_site.inc +++ /dev/null @@ -1,104 +0,0 @@ - 'page', - - 'title' => t('Site contact page'), - 'admin title' => t('Site contact page'), - 'admin description' => t('When enabled, this overrides the default Drupal behavior for the site contact page at /contact. If no variant is selected, the default Drupal contact form will be used.'), - 'admin path' => 'contact', - - // Menu hooks so that we can alter the node/%node menu entry to point to us. - 'hook menu alter' => 'page_manager_contact_site_menu_alter', - - // This is task uses 'context' handlers and must implement these to give the - // handler data it needs. - 'handler type' => 'context', - - // Allow this to be enabled or disabled: - 'disabled' => variable_get('page_manager_contact_site_disabled', TRUE), - 'enable callback' => 'page_manager_contact_site_enable', - ); -} - -/** - * Callback defined by page_manager_contact_site_page_manager_tasks(). - * - * Alter the node edit input so that node edit comes to us rather than the - * normal node edit process. - */ -function page_manager_contact_site_menu_alter(&$items, $task) { - if (variable_get('page_manager_contact_site_disabled', TRUE)) { - return; - } - - $callback = $items['contact']['page callback']; - // Override the node edit handler for our purpose. - if ($callback == 'contact_site_page' || variable_get('page_manager_override_anyway', FALSE)) { - $items['contact']['page callback'] = 'page_manager_contact_site'; - $items['contact']['file path'] = $task['path']; - $items['contact']['file'] = $task['file']; - } - else { - variable_set('page_manager_contact_site_disabled', TRUE); - if (!empty($GLOBALS['page_manager_enabling_contact_site'])) { - drupal_set_message(t('Page manager module is unable to enable contact because some other module already has overridden with %callback.', array('%callback' => $callback)), 'warning'); - } - return; - } - -} - -/** - * Entry point for our overridden node edit. - * - * This function asks its assigned handlers who, if anyone, would like - * to run with it. If no one does, it passes through to Drupal core's - * node edit, which is node_page_edit(). - */ -function page_manager_contact_site() { - // Load my task plugin - $task = page_manager_get_task('contact_site'); - - ctools_include('context'); - ctools_include('context-task-handler'); - $output = ctools_context_handler_render($task, '', array(), array()); - if ($output !== FALSE) { - return $output; - } - - module_load_include('inc', 'contact', 'contact.pages'); - $function = 'contact_site_page'; - foreach (module_implements('page_manager_override') as $module) { - $call = $module . '_page_manager_override'; - if (($rc = $call('contact_site')) && function_exists($rc)) { - $function = $rc; - break; - } - } - - // Otherwise, fall back. - return $function(); -} - -/** - * Callback to enable/disable the page from the UI. - */ -function page_manager_contact_site_enable($cache, $status) { - variable_set('page_manager_contact_site_disabled', $status); - // Set a global flag so that the menu routine knows it needs - // to set a message if enabling cannot be done. - if (!$status) { - $GLOBALS['page_manager_enabling_contact_site'] = TRUE; - } -} diff --git a/page_manager/plugins/tasks/contact_user.inc b/page_manager/plugins/tasks/contact_user.inc deleted file mode 100644 index e376a26..0000000 --- a/page_manager/plugins/tasks/contact_user.inc +++ /dev/null @@ -1,133 +0,0 @@ - 'page', - 'title' => t('User contact'), - 'admin title' => t('User contact'), - 'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying the user contact form at user/%user/contact. If no variant is selected, the default Drupal user contact form will be used.'), - 'admin path' => 'user/%user/contact', - - // Callback to add items to the page managertask administration form: - 'task admin' => 'page_manager_contact_user_task_admin', - - 'hook menu alter' => 'page_manager_contact_user_menu_alter', - - // This is task uses 'context' handlers and must implement these to give the - // handler data it needs. - 'handler type' => 'context', // handler type -- misnamed - 'get arguments' => 'page_manager_contact_user_get_arguments', - 'get context placeholders' => 'page_manager_contact_user_get_contexts', - - // Allow this to be enabled or disabled: - 'disabled' => variable_get('page_manager_contact_user_disabled', TRUE), - 'enable callback' => 'page_manager_contact_user_enable', - ); -} - -/** - * Callback defined by page_manager_contact_user_page_manager_tasks(). - * - * Alter the user view input so that user view comes to us rather than the - * normal user view process. - */ -function page_manager_contact_user_menu_alter(&$items, $task) { - if (variable_get('page_manager_contact_user_disabled', TRUE)) { - return; - } - - // Override the user view handler for our purpose. - if ($items['user/%user/contact']['page callback'] == 'contact_user_page' || variable_get('page_manager_override_anyway', FALSE)) { - $items['user/%user/contact']['page callback'] = 'page_manager_contact_user'; - $items['user/%user/contact']['file path'] = $task['path']; - $items['user/%user/contact']['file'] = $task['file']; - } - else { - // automatically disable this task if it cannot be enabled. - variable_set('page_manager_contact_user_disabled', TRUE); - if (!empty($GLOBALS['page_manager_enabling_contact_user'])) { - drupal_set_message(t('Page manager module is unable to enable user/%user/contact because some other module already has overridden with %callback.', array('%callback' => $items['user/%user/contact']['page callback'])), 'error'); - } - } -} - -/** - * Entry point for our overridden user view. - * - * This function asks its assigned handlers who, if anyone, would like - * to run with it. If no one does, it passes through to Drupal core's - * user view, which is user_page_view(). - */ -function page_manager_contact_user($account) { - // Load my task plugin: - $task = page_manager_get_task('contact_user'); - - // Load the account into a context. - ctools_include('context'); - ctools_include('context-task-handler'); - $contexts = ctools_context_handler_get_task_contexts($task, '', array($account)); - - $output = ctools_context_handler_render($task, '', $contexts, array($account->uid)); - if ($output !== FALSE) { - return $output; - } - - module_load_include('inc', 'contact', 'contact.pages'); - $function = 'contact_user_page'; - foreach (module_implements('page_manager_override') as $module) { - $call = $module . '_page_manager_override'; - if (($rc = $call('contact_user')) && function_exists($rc)) { - $function = $rc; - break; - } - } - - // Otherwise, fall back. - return $function($account); -} - -/** - * Callback to get arguments provided by this task handler. - * - * Since this is the node view and there is no UI on the arguments, we - * create dummy arguments that contain the needed data. - */ -function page_manager_contact_user_get_arguments($task, $subtask_id) { - return array( - array( - 'keyword' => 'user', - 'identifier' => t('User being viewed'), - 'id' => 1, - 'name' => 'uid', - 'settings' => array(), - ), - ); -} - -/** - * Callback to get context placeholders provided by this handler. - */ -function page_manager_contact_user_get_contexts($task, $subtask_id) { - return ctools_context_get_placeholders_from_argument(page_manager_contact_user_get_arguments($task, $subtask_id)); -} - -/** - * Callback to enable/disable the page from the UI. - */ -function page_manager_contact_user_enable($cache, $status) { - variable_set('page_manager_contact_user_disabled', $status); - - // Set a global flag so that the menu routine knows it needs - // to set a message if enabling cannot be done. - if (!$status) { - $GLOBALS['page_manager_enabling_contact_user'] = TRUE; - } -} diff --git a/page_manager/plugins/tasks/node_edit.inc b/page_manager/plugins/tasks/node_edit.inc deleted file mode 100644 index 2aa3cc1..0000000 --- a/page_manager/plugins/tasks/node_edit.inc +++ /dev/null @@ -1,167 +0,0 @@ - 'page', - - 'title' => t('Node add/edit form'), - 'admin title' => t('Node add/edit form'), - 'admin description' => t('When enabled, this overrides the default Drupal behavior for adding or edit nodes at node/%node/edit and node/add/%node_type. If you add variants, you may use selection criteria such as node type or language or user access to provide different edit forms for nodes. If no variant is selected, the default Drupal node edit will be used.'), - 'admin path' => 'node/%node/edit', - - // Menu hooks so that we can alter the node/%node menu entry to point to us. - 'hook menu' => 'page_manager_node_edit_menu', - 'hook menu alter' => 'page_manager_node_edit_menu_alter', - - // This is task uses 'context' handlers and must implement these to give the - // handler data it needs. - 'handler type' => 'context', - 'get arguments' => 'page_manager_node_edit_get_arguments', - 'get context placeholders' => 'page_manager_node_edit_get_contexts', - - // Allow this to be enabled or disabled: - 'disabled' => variable_get('page_manager_node_edit_disabled', TRUE), - 'enable callback' => 'page_manager_node_edit_enable', - ); -} - -/** - * Callback defined by page_manager_node_edit_page_manager_tasks(). - * - * Alter the node edit input so that node edit comes to us rather than the - * normal node edit process. - */ -function page_manager_node_edit_menu_alter(&$items, $task) { - if (variable_get('page_manager_node_edit_disabled', TRUE)) { - return; - } - - $callback = $items['node/%node/edit']['page callback']; - // Override the node edit handler for our purpose. - if ($callback == 'node_page_edit' || variable_get('page_manager_override_anyway', FALSE)) { - $items['node/%node/edit']['page callback'] = 'page_manager_node_edit'; - $items['node/%node/edit']['file path'] = $task['path']; - $items['node/%node/edit']['file'] = $task['file']; - } - else { - variable_set('page_manager_node_edit_disabled', TRUE); - if (!empty($GLOBALS['page_manager_enabling_node_edit'])) { - drupal_set_message(t('Page manager module is unable to enable node/%node/edit because some other module already has overridden with %callback.', array('%callback' => $callback)), 'warning'); - } - return; - } - - // Also catch node/add handling: - foreach (node_type_get_types() as $type) { - $path = 'node/add/' . str_replace('_', '-', $type->type); - if ($items[$path]['page callback'] != 'node_add') { - if (!empty($GLOBALS['page_manager_enabling_node_edit'])) { - drupal_set_message(t('Page manager module is unable to override @path because some other module already has overridden with %callback. Node edit will be enabled but that edit path will not be overridden.', array('@path' => $path, '%callback' => $items[$path]['page callback'])), 'warning'); - } - continue; - } - - $items[$path]['page callback'] = 'page_manager_node_add'; - $items[$path]['file path'] = $task['path']; - $items[$path]['file'] = $task['file']; - // Why str_replace things back? - $items[$path]['page arguments'] = array($type->type); - } -} - -/** - * Entry point for our overridden node edit. - * - * This function asks its assigned handlers who, if anyone, would like - * to run with it. If no one does, it passes through to Drupal core's - * node edit, which is node_page_edit(). - */ -function page_manager_node_edit($node) { - // Load my task plugin - $task = page_manager_get_task('node_edit'); - - // Load the node into a context. - ctools_include('context'); - ctools_include('context-task-handler'); - $contexts = ctools_context_handler_get_task_contexts($task, '', array($node)); - - $arg = array(isset($node->nid) ? $node->nid : $node->type); - $output = ctools_context_handler_render($task, '', $contexts, $arg); - if ($output === FALSE) { - // Fall back! - // We've already built the form with the context, so we can't build it again, or - // form_clean_id will mess up our ids. But we don't really need to, either: - $context = current($contexts); - $output = drupal_render_form($context->form_id, $context->form); - } - - return $output; -} - -/** - * Callback to handle the process of adding a node. - * - * This creates a basic $node and passes that off to page_manager_node_edit(). - * It is modeled after Drupal's node_add() function. - * - * Unlike node_add() we do not need to check node_access because that was - * already checked by the menu system. - */ -function page_manager_node_add($type) { - global $user; - - $types = node_type_get_types(); - - // Initialize settings: - $node = (object) array( - 'uid' => $user->uid, - 'name' => (isset($user->name) ? $user->name : ''), - 'type' => $type, - 'language' => '', - ); - - drupal_set_title(t('Create @name', array('@name' => $types[$type]->name))); - return page_manager_node_edit($node); -} - -/** - * Callback to get arguments provided by this task handler. - * - * Since this is the node edit and there is no UI on the arguments, we - * create dummy arguments that contain the needed data. - */ -function page_manager_node_edit_get_arguments($task, $subtask_id) { - return array( - array( - 'keyword' => 'node', - 'identifier' => t('Node being edited'), - 'id' => 1, - 'name' => 'node_edit', - 'settings' => array(), - ), - ); -} - -/** - * Callback to get context placeholders provided by this handler. - */ -function page_manager_node_edit_get_contexts($task, $subtask_id) { - return ctools_context_get_placeholders_from_argument(page_manager_node_edit_get_arguments($task, $subtask_id)); -} - -/** - * Callback to enable/disable the page from the UI. - */ -function page_manager_node_edit_enable($cache, $status) { - variable_set('page_manager_node_edit_disabled', $status); - // Set a global flag so that the menu routine knows it needs - // to set a message if enabling cannot be done. - if (!$status) { - $GLOBALS['page_manager_enabling_node_edit'] = TRUE; - } -} diff --git a/page_manager/plugins/tasks/node_view.inc b/page_manager/plugins/tasks/node_view.inc deleted file mode 100644 index 0fa71c4..0000000 --- a/page_manager/plugins/tasks/node_view.inc +++ /dev/null @@ -1,143 +0,0 @@ - 'page', - - 'title' => t('Node template'), - - 'admin title' => t('Node template'), - 'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying nodes at node/%node. If you add variants, you may use selection criteria such as node type or language or user access to provide different views of nodes. If no variant is selected, the default Drupal node view will be used. This page only affects nodes viewed as pages, it will not affect nodes viewed in lists or at other locations. Also please note that if you are using pathauto, aliases may make a node to be somewhere else, but as far as Drupal is concerned, they are still at node/%node.'), - 'admin path' => 'node/%node', - - // Menu hooks so that we can alter the node/%node menu entry to point to us. - 'hook menu' => 'page_manager_node_view_menu', - 'hook menu alter' => 'page_manager_node_view_menu_alter', - - // This is task uses 'context' handlers and must implement these to give the - // handler data it needs. - 'handler type' => 'context', - 'get arguments' => 'page_manager_node_view_get_arguments', - 'get context placeholders' => 'page_manager_node_view_get_contexts', - - // Allow this to be enabled or disabled: - 'disabled' => variable_get('page_manager_node_view_disabled', TRUE), - 'enable callback' => 'page_manager_node_view_enable', - ); -} - -/** - * Callback defined by page_manager_node_view_page_manager_tasks(). - * - * Alter the node view input so that node view comes to us rather than the - * normal node view process. - */ -function page_manager_node_view_menu_alter(&$items, $task) { - if (variable_get('page_manager_node_view_disabled', TRUE)) { - return; - } - - // Override the node view handler for our purpose. - $callback = $items['node/%node']['page callback']; - if ($callback == 'node_page_view' || variable_get('page_manager_override_anyway', FALSE)) { - $items['node/%node']['page callback'] = 'page_manager_node_view_page'; - $items['node/%node']['file path'] = $task['path']; - $items['node/%node']['file'] = $task['file']; - } - else { - // automatically disable this task if it cannot be enabled. - variable_set('page_manager_node_view_disabled', TRUE); - if (!empty($GLOBALS['page_manager_enabling_node_view'])) { - drupal_set_message(t('Page manager module is unable to enable node/%node because some other module already has overridden with %callback.', array('%callback' => $callback)), 'error'); - } - } - - // @todo override node revision handler as well? -} - -/** - * Entry point for our overridden node view. - * - * This function asks its assigned handlers who, if anyone, would like - * to run with it. If no one does, it passes through to Drupal core's - * node view, which is node_page_view(). - */ -function page_manager_node_view_page($node) { - // Load my task plugin - $task = page_manager_get_task('node_view'); - - // Load the node into a context. - ctools_include('context'); - ctools_include('context-task-handler'); - $contexts = ctools_context_handler_get_task_contexts($task, '', array($node)); - - $output = ctools_context_handler_render($task, '', $contexts, array($node->nid)); - if ($output != FALSE) { - node_tag_new($node); - return $output; - } - - $function = 'node_page_view'; - foreach (module_implements('page_manager_override') as $module) { - $call = $module . '_page_manager_override'; - if (($rc = $call('node_view')) && function_exists($rc)) { - $function = $rc; - break; - } - } - - // Otherwise, fall back. - return $function($node); -} - -/** - * Callback to get arguments provided by this task handler. - * - * Since this is the node view and there is no UI on the arguments, we - * create dummy arguments that contain the needed data. - */ -function page_manager_node_view_get_arguments($task, $subtask_id) { - return array( - array( - 'keyword' => 'node', - 'identifier' => t('Node being viewed'), - 'id' => 1, - 'name' => 'nid', - 'settings' => array(), - ), - ); -} - -/** - * Callback to get context placeholders provided by this handler. - */ -function page_manager_node_view_get_contexts($task, $subtask_id) { - return ctools_context_get_placeholders_from_argument(page_manager_node_view_get_arguments($task, $subtask_id)); -} - -/** - * Callback to enable/disable the page from the UI. - */ -function page_manager_node_view_enable($cache, $status) { - variable_set('page_manager_node_view_disabled', $status); - - // Set a global flag so that the menu routine knows it needs - // to set a message if enabling cannot be done. - if (!$status) { - $GLOBALS['page_manager_enabling_node_view'] = TRUE; - } -} diff --git a/page_manager/plugins/tasks/page.admin.inc b/page_manager/plugins/tasks/page.admin.inc deleted file mode 100644 index dd88a77..0000000 --- a/page_manager/plugins/tasks/page.admin.inc +++ /dev/null @@ -1,1517 +0,0 @@ - $access_callback, - 'access arguments' => $access_arguments, - 'file' => 'plugins/tasks/page.admin.inc', - ); - - $items['admin/structure/pages/add'] = array( - 'title' => 'Add custom page', - 'page callback' => 'page_manager_page_add_subtask', - 'page arguments' => array(), - 'type' => MENU_LOCAL_ACTION, - ) + $base; - - $items['admin/structure/pages/import'] = array( - 'title' => 'Import page', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('page_manager_page_import_subtask', 'page'), - 'type' => MENU_LOCAL_ACTION, - ) + $base; - if ($access_callback == 'user_access') { - $items['admin/structure/pages/import']['access callback'] = 'ctools_access_multiperm'; - $items['admin/structure/pages/import']['access arguments'][] = 'use PHP for settings'; - } - - // AJAX callbacks for argument modal. - $items['admin/structure/pages/argument'] = array( - 'page callback' => 'page_manager_page_subtask_argument_ajax', - 'type' => MENU_CALLBACK, - ) + $base; - - // Add menu entries for each subtask - foreach (page_manager_page_load_all() as $subtask_id => $subtask) { - if (!empty($subtask->disabled)) { - continue; - } - - if (!isset($subtask->access['type'])) { - $subtask->access['type'] = 'none'; - } - if (!isset($subtask->access['settings'])) { - $subtask->access['settings'] = NULL; - } - - $path = array(); - $page_arguments = array($subtask_id); - $access_arguments = array($subtask->access); - $load_arguments = array($subtask_id, '%index', '%map'); - - // Replace named placeholders with our own placeholder to load contexts. - $position = 0; - - foreach (explode('/', $subtask->path) as $bit) { - // Remove things like double slashes completely. - if (!isset($bit) || $bit === '') { - continue; - } - - if ($bit[0] == '%' && $bit != '%') { - $placeholder = '%pm_arg'; - - // Chop off that %. - $name = substr($bit, 1); - - // Check to see if the argument plugin wants to use a different - // placholder. This will allow to_args. - if (!empty($subtask->arguments[$name])) { - ctools_include('context'); - if (!empty($subtask->arguments[$name]['name'])) { - $plugin = ctools_get_argument($subtask->arguments[$name]['name']); - if (isset($plugin['path placeholder'])) { - if (function_exists($plugin['path placeholder'])) { - $placeholder = $plugin['path placeholder']($subtask->arguments[$name]); - } - else { - $placeholder = $plugin['path placeholder']; - } - } - } - } - // If an argument, swap it out with our argument loader and make sure - // the argument gets passed through to the page callback. - $path[] = $placeholder; - $page_arguments[] = $position; - $access_arguments[] = $position; - } - else if ($bit[0] != '!') { - $path[] = $bit; - } - - // Increment position. We do it like this to skip empty items that - // could happen from erroneous paths like: this///that - $position++; - } - - $menu_path = implode('/', $path); - - $items[$menu_path] = page_manager_page_menu_item($task, $subtask->menu, $access_arguments, $page_arguments, $load_arguments); - - // Add a parent menu item if one is configured. - if (isset($subtask->menu['type']) && $subtask->menu['type'] == 'default tab' && $subtask->menu['parent']['type'] != 'none') { - array_pop($path); - $parent_path = implode('/', $path); - $items[$parent_path] = page_manager_page_menu_item($task, $subtask->menu['parent'], $access_arguments, $page_arguments, $load_arguments); - } - } -} - -/** - * Create a menu item for page manager pages. - * - * @param $menu - * The configuration to use. It will contain a type, and depending on the - * type may also contain weight, title and name. These are presumed to have - * been configured from the UI. - * @param $access_arguments - * Arguments that go with ctools_access_menu; it should be loaded with - * the access plugin type, settings, and positions of any arguments that - * may produce contexts. - * @param $page_arguments - * This should be seeded with the subtask name for easy loading and like - * the access arguments above should contain positions of arguments so - * that the menu system passes contexts through. - * @param $load_arguments - * Arguments to send to the arg loader; should be the subtask id and '%index'. - */ -function page_manager_page_menu_item($task, $menu, $access_arguments, $page_arguments, $load_arguments) { - $item = array( - 'access callback' => 'ctools_access_menu', - 'access arguments' => $access_arguments, - 'page callback' => 'page_manager_page_execute', - 'page arguments' => $page_arguments, - 'load arguments' => $load_arguments, - 'file' => 'plugins/tasks/page.inc', - ); - - if (isset($menu['title'])) { - $item['title'] = $menu['title']; - } - if (isset($menu['weight'])) { - $item['weight'] = $menu['weight']; - } - - if (empty($menu['type'])) { - $menu['type'] = 'none'; - } - - switch ($menu['type']) { - case 'none': - default: - $item['type'] = MENU_CALLBACK; - break; - - case 'normal': - $item['type'] = MENU_NORMAL_ITEM; - // Insert item into the proper menu - $item['menu_name'] = $menu['name']; - break; - - case 'tab': - $item['type'] = MENU_LOCAL_TASK; - break; - - case 'action': - $item['type'] = MENU_LOCAL_ACTION; - break; - - case 'default tab': - $item['type'] = MENU_DEFAULT_LOCAL_TASK; - break; - } - - return $item; -} - -/** - * Page callback to add a subtask. - */ -function page_manager_page_add_subtask($task_name = NULL, $step = NULL) { - ctools_include('context'); - $task = page_manager_get_task('page'); - $task_handler_plugins = page_manager_get_task_handler_plugins($task); - if (empty($task_handler_plugins)) { - drupal_set_message(t('There are currently no variants available and a page may not be added. Perhaps you need to install the Panels module to get a variant?'), 'error'); - return ' '; - } - - $form_info = array( - 'id' => 'page_manager_add_page', - 'show trail' => TRUE, - 'show back' => TRUE, - 'show return' => FALSE, - 'next callback' => 'page_manager_page_add_subtask_next', - 'finish callback' => 'page_manager_page_add_subtask_finish', - 'return callback' => 'page_manager_page_add_subtask_finish', - 'cancel callback' => 'page_manager_page_add_subtask_cancel', - 'add order' => array( - 'basic' => t('Basic settings'), - 'argument' => t('Argument settings'), - 'access' => t('Access control'), - 'menu' => t('Menu settings'), - ), - 'forms' => array( - 'basic' => array( - 'form id' => 'page_manager_page_form_basic', - ), - 'access' => array( - 'form id' => 'page_manager_page_form_access', - ), - 'menu' => array( - 'form id' => 'page_manager_page_form_menu', - ), - 'argument' => array( - 'form id' => 'page_manager_page_form_argument', - ), - ), - ); - - if ($task_name) { - $page = page_manager_get_page_cache($task_name); - if (empty($page)) { - return drupal_not_found(); - } - - $form_info['path'] = "admin/structure/pages/add/$task_name/%step"; - } - else { - $new_page = page_manager_page_new(); - $new_page->name = NULL; - - $page = new stdClass(); - page_manager_page_new_page_cache($new_page, $page); - $form_info['path'] = 'admin/structure/pages/add/%task_name/%step'; - } - - if ($step && $step != 'basic') { - $handler_plugin = page_manager_get_task_handler($page->handler); - - $form_info['forms'] += $handler_plugin['forms']; - - if (isset($page->forms)) { - foreach ($page->forms as $id) { - if (isset($form_info['add order'][$id])) { - $form_info['order'][$id] = $form_info['add order'][$id]; - } - else if (isset($handler_plugin['add features'][$id])) { - $form_info['order'][$id] = $handler_plugin['add features'][$id]; - } - else if (isset($handler_plugin['required forms'][$id])) { - $form_info['order'][$id] = $handler_plugin['required forms'][$id]; - } - } - } - else { - $form_info['order'] = $form_info['add order']; - } - - // This means we just submitted our form from the default list - // of steps, which we've traded in for a newly generated list of - // steps above. We need to translate this 'next' step into what - // our questions determined would be next. - if ($step == 'next') { - $keys = array_keys($form_info['order']); - // get rid of 'basic' from the list of forms. - array_shift($keys); - $step = array_shift($keys); - - // If $step == 'basic' at this point, we were not presented with any - // additional forms at all. Let's just save and go! - if ($step == 'basic') { - page_manager_save_page_cache($page); - // Redirect to the new page's task handler editor. - drupal_goto(page_manager_edit_url($page->task_name)); - } - } - } - else { - $form_info['show trail'] = FALSE; - $form_info['order'] = array( - 'basic' => t('Basic settings'), - 'next' => t('A meaningless second page'), - ); - } - - ctools_include('wizard'); - $form_state = array( - 'task' => $task, - 'subtask' => $page->subtask, - 'page' => &$page, - 'type' => 'add', - 'task_id' => 'page', - 'task_name' => $page->task_name, - 'creating' => TRUE, - ); - - if (!empty($page->handlers)) { - $keys = array_keys($page->handlers); - $key = array_shift($keys); - $form_state['handler'] = &$page->handlers[$key]; - $form_state['handler_id'] = $key; - } - - $output = ctools_wizard_multistep_form($form_info, $step, $form_state); - - if (!$output) { - // redirect. - drupal_redirect_form(array(), $form_state['redirect']); - } - - return $output; -} - -/** - * Callback generated when the add page process is finished. - */ -function page_manager_page_add_subtask_finish(&$form_state) { - $page = &$form_state['page']; - // Update the cache with changes. - page_manager_set_page_cache($page); - - $handler = $form_state['handler']; - $handler_plugin = page_manager_get_task_handler($handler->handler); - - // Redirect to the new page's task handler editor. - if (isset($handler_plugin['add finish'])) { - $form_state['redirect'] = page_manager_edit_url($page->task_name, array('handlers', $handler->name, $handler_plugin['add finish'])); - } - else { - $form_state['redirect'] = page_manager_edit_url($page->task_name); - } - return; -} - -/** - * Callback generated when the 'next' button is clicked. - * - * All we do here is store the cache. - */ -function page_manager_page_add_subtask_next(&$form_state) { - if (empty($form_state['task_name']) || $form_state['task_name'] == 'page') { - // We may not have known the path to go next, because we didn't yet know the - // task name. This fixes that. - $form_state['form_info']['path'] = str_replace('%task_name', $form_state['page']->task_name, $form_state['form_info']['path']); - - $form_state['redirect'] = ctools_wizard_get_path($form_state['form_info'], $form_state['clicked_button']['#next']); - } - - // Update the cache with changes. - page_manager_set_page_cache($form_state['page']); -} - -/** - * Callback generated when the 'cancel' button is clicked. - * - * All we do here is clear the cache. - */ -function page_manager_page_add_subtask_cancel(&$form_state) { - // Wipe all our stored changes. - if (isset($form_state['page']->task_name)) { - page_manager_clear_page_cache($form_state['page']->task_name); - } -} - -/** - * Basic settings form for a page manager page. - */ -function page_manager_page_form_basic($form, &$form_state) { - $page = &$form_state['page']->subtask['subtask']; - $task = $form_state['task']; - - $form['admin_title'] = array( - '#type' => 'textfield', - '#title' => t('Administrative title'), - '#description' => t('The name of this page. This will appear in the administrative interface to easily identify it.'), - '#default_value' => $page->admin_title, - ); - - $form['name'] = array( - '#type' => 'machine_name', - '#title' => t('Machine name'), - '#machine_name' => array( - 'exists' => 'page_manager_page_load', - 'source' => array('admin_title'), - ), - '#description' => t('The machine readable name of this page. It must be unique, and it must contain only alphanumeric characters and underscores. Once created, you will not be able to change this value!'), - '#default_value' => $page->name, - ); - - if (isset($page->pid) || empty($form_state['creating'])) { - $form['name']['#disabled'] = TRUE; - $form['name']['#value'] = $page->name; - } - - $form['admin_description'] = array( - '#type' => 'textarea', - '#title' => t('Administrative description'), - '#description' => t('A description of what this page is, does or is for, for administrative use.'), - '#default_value' => $page->admin_description, - ); - - // path - $form['path'] = array( - '#type' => 'textfield', - '#title' => t('Path'), - '#description' => t('The URL path to get to this page. You may create named placeholders for variable parts of the path by using %name for required elements and !name for optional elements. For example: "node/%node/foo", "forum/%forum" or "dashboard/!input". These named placeholders can be turned into contexts on the arguments form.'), - '#default_value' => $page->path, - '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), - ); - - $frontpage = variable_get('site_frontpage', 'node'); - - $path = array(); - if ($page->path) { - foreach (explode('/', $page->path) as $bit) { - if ($bit[0] != '!') { - $path[] = $bit; - } - } - } - - $path = implode('/', $path); - - if (empty($path) || $path != $frontpage) { - $form['frontpage'] = array( - '#type' => 'checkbox', - '#default_value' => !empty($page->make_frontpage), - '#title' => t('Make this your site home page.'), - '#description' => t('To set this panel as your home page you must create a unique path name with no % placeholders in the path. The site home page is currently set to %homepage on the !siteinfo configuration form.', array('!siteinfo' => l('Site Information', 'admin/settings/site-information'), '%homepage' => '/' . $frontpage)), - ); - } - else if ($path == $frontpage) { - $form['frontpage_markup'] = array( - '#value' => '' . t('This page is currently set to be your site home page. This can be modified on the !siteinfo configuration form.', array('!siteinfo' => l('Site Information', 'admin/settings/site-information'))) . '', - ); - - $form['frontpage'] = array( - '#type' => 'value', - '#value' => TRUE, - ); - } - - if (!isset($page->pid) && !empty($form_state['creating'])) { - $features['default'] = array( - 'access' => t('Access control'), - 'menu' => t('Visible menu item'), - ); - - module_load_include('inc', 'page_manager', 'page_manager.admin'); - $form = page_manager_handler_add_form($form, $form_state, $features); - } - - return $form; -} - -function page_manager_page_form_basic_validate_filter($value) { - return $value === -1; -} - -/** - * Validate the basic form. - */ -function page_manager_page_form_basic_validate(&$form, &$form_state) { - // Ensure path is unused by other pages. - $page = $form_state['page']->subtask['subtask']; - $name = !empty($form_state['values']['name']) ? $form_state['values']['name'] : $page->name; - if (empty($name)) { - form_error($form['name'], t('Name is required.')); - } - - // If this is new, make sure the name is unique: - if (empty($page->name)) { - $test = page_manager_page_load($name); - if ($test) { - form_error($form['name'], t('That name is used by another page: @page', array('@page' => $test->admin_title))); - } - - // Ensure name fits the rules: - if (preg_match('/[^a-zA-Z0-9_]/', $form_state['values']['name'])) { - form_error($form['name'], t('Page name must be alphanumeric or underscores only.')); - } - } - - $pages = page_manager_page_load_all(); - foreach ($pages as $test) { - if ($test->name != $name && $test->path == $form_state['values']['path'] && empty($test->disabled)) { - form_error($form['path'], t('That path is used by another page: @page', array('@page' => $test->admin_title))); - } - } - - // Ensure path is unused by things NOT pages. We do the double check because - // we're checking against our page callback. - $path = array(); - if (empty($form_state['values']['path'])) { - form_error($form['path'], t('Path is required.')); - // stop processing here if there is no path. - return; - } - - $found = FALSE; - $error = FALSE; - foreach (explode('/', $form_state['values']['path']) as $position => $bit) { - if (!isset($bit) || $bit === '') { - continue; - } - - if ($bit == '%' || $bit == '!') { - form_error($form['path'], t('You cannot have an unnamed placeholder (% or ! by itself). Please name your placeholder by adding a short piece of descriptive text to the % or !, such as %user or %node.')); - } - - if ($bit[0] == '%') { - if ($found) { - form_error($form['path'], t('You cannot have a dynamic path element after an optional path element.')); - } - - if ($position == 0) { - form_error($form['path'], t('The first element in a path may not be dynamic.')); - } - - $path[] = '%'; - } - else if ($bit[0] == '!') { - $found = TRUE; - } - else { - if ($found) { - form_error($form['path'], t('You cannot have a static path element after an optional path element.')); - } - $path[] = $bit; - } - } - - // Check to see if something that isn't a page manager page is using the path. - $path = implode('/', $path); - $result = db_query('SELECT * FROM {menu_router} WHERE path = :path', array(':path' => $path)); - foreach ($result as $router) { - if ($router->page_callback != 'page_manager_page_execute') { - form_error($form['path'], t('That path is already in use. This system cannot override existing paths.')); - } - } - - // Ensure the path is not already an alias to something else. - if (strpos($path, '%') === FALSE) { - $alias = db_query('SELECT alias, source FROM {url_alias} WHERE alias = :path', array(':path' => $path))->fetchObject(); - if ($alias) { - form_error($form['path'], t('That path is currently assigned to be an alias for @alias. This system cannot override existing aliases.', array('@alias' => $alias->src))); - } - } - else { - if (!empty($form_state['values']['frontpage'])) { - form_error($form['path'], t('You cannot make this page your site home page if it uses % placeholders.')); - } - } - - // Ensure path is properly formed. - $args = page_manager_page_get_named_arguments($form_state['values']['path']); - if ($invalid_args = array_filter($args, 'page_manager_page_form_basic_validate_filter')) { - foreach ($invalid_args as $arg => $position) { - form_error($form['path'], t('Duplicated argument %arg', array('%arg' => $arg))); - } - } - - if (isset($args['%'])) { - form_error($form['path'], t('Invalid arg %. All arguments must be named with keywords.')); - } - - $form_state['arguments'] = $args; -} - -/** - * Store the values from the basic settings form. - */ -function page_manager_page_form_basic_submit(&$form, &$form_state) { - $page = &$form_state['page']->subtask['subtask']; - $cache = &$form_state['page']; - - // If this is a new thing, then we have to do a bunch of setup to create - // the cache record with the right ID and some basic data that we could - // not know until we asked the user some questions. - if (!isset($page->pid) && !empty($form_state['creating'])) { - // Update the data with our new name. - $page->name = $form_state['values']['name']; - $form_state['page']->task_name = page_manager_make_task_name($form_state['task_id'], $page->name); - $cache->handler = $form_state['values']['handler']; - $cache->subtask_id = $page->name; - $plugin = page_manager_get_task_handler($cache->handler); - - // If they created and went back, there might be old, dead handlers - // that are not going to be added. - // - // Remove them: - $cache->handlers = array(); - $cache->handler_info = array(); - - // Create a new handler. - $handler = page_manager_new_task_handler($plugin); - $title = !empty($form_state['values']['title']) ? $form_state['values']['title'] : $plugin['title']; - page_manager_handler_add_to_page($cache, $handler, $title); - - // Figure out which forms to present them with - $cache->forms = array(); - $cache->forms[] = 'basic'; // This one is always there. - if (!empty($form_state['arguments'])) { - $cache->forms[] = 'argument'; - } - - $features = $form_state['values']['features']; - $cache->forms = array_merge($cache->forms, array_keys(array_filter($features['default']))); - if (isset($features[$form_state['values']['handler']])) { - $cache->forms = array_merge($cache->forms, array_keys(array_filter($features[$form_state['values']['handler']]))); - } - - if (isset($plugin['required forms'])) { - $cache->forms = array_merge($cache->forms, array_keys($plugin['required forms'])); - } - } - - $page->admin_title = $form_state['values']['admin_title']; - $cache->subtask['admin title'] = check_plain($form_state['values']['admin_title']); - - $page->admin_description = $form_state['values']['admin_description']; - $cache->subtask['admin description'] = filter_xss_admin($form_state['values']['admin_description']); - - if ($page->path != $form_state['values']['path']) { - $page->path = $form_state['values']['path']; - page_manager_page_recalculate_arguments($page); - $cache->path_changed = TRUE; - } - - $page->make_frontpage = !empty($form_state['values']['frontpage']); -} - -/** - * Form to handle menu item controls. - */ -function page_manager_page_form_menu($form, &$form_state) { - ctools_include('dependent'); - $form['menu'] = array( - '#prefix' => '
    ', - '#suffix' => '
    ', - '#tree' => TRUE, - ); - - $menu = $form_state['page']->subtask['subtask']->menu; - if (empty($menu)) { - $menu = array( - 'type' => 'none', - 'title' => '', - 'weight' => 0, - 'name' => 'navigation', - 'parent' => array( - 'type' => 'none', - 'title' => '', - 'weight' => 0, - 'name' => 'navigation', - ), - ); - } - - $form['menu']['type'] = array( - '#title' => t('Type'), - '#type' => 'radios', - '#options' => array( - 'none' => t('No menu entry'), - 'normal' => t('Normal menu entry'), - 'tab' => t('Menu tab'), - 'default tab' => t('Default menu tab'), - 'action' => t('Local action'), - ), - '#default_value' => $menu['type'], - ); - - $form['menu']['title'] = array( - '#title' => t('Title'), - '#type' => 'textfield', - '#default_value' => $menu['title'], - '#description' => t('If set to normal or tab, enter the text to use for the menu item.'), - '#process' => array('ctools_dependent_process'), - '#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab', 'action')), - ); - - list($major, $minor) = explode('.', VERSION, 2); - - // Only display the menu selector if menu module is enabled. - if (module_exists('menu')) { - $form['menu']['name'] = array( - '#title' => t('Menu'), - '#type' => 'select', - '#options' => menu_get_menus(), - '#default_value' => $menu['name'], - '#description' => t('Insert item into an available menu.'), - '#process' => array('ctools_dependent_process'), - '#dependency' => array('radio:menu[type]' => array('normal')), - ); - } - else { - $form['menu']['name'] = array( - '#type' => 'value', - '#value' => $menu['name'], - ); - $form['menu']['markup'] = array( - '#value' => t('Menu selection requires the activation of menu module.'), - ); - } - $form['menu']['weight'] = array( - '#title' => t('Weight'), - '#type' => 'textfield', - '#default_value' => isset($menu['weight']) ? $menu['weight'] : 0, - '#description' => t('The lower the weight the higher/further left it will appear.'), - '#process' => array('ctools_dependent_process'), - '#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab', 'action')), - ); - - $form['menu']['parent']['type'] = array( - '#prefix' => '
    ', - '#suffix' => '
    ', - '#title' => t('Parent menu item'), - '#type' => 'radios', - '#options' => array('none' => t('Already exists'), 'normal' => t('Normal menu item'), 'tab' => t('Menu tab')), - '#default_value' => $menu['parent']['type'], - '#description' => t('When providing a menu item as a default tab, Drupal needs to know what the parent menu item of that tab will be. Sometimes the parent will already exist, but other times you will need to have one created. The path of a parent item will always be the same path with the last part left off. i.e, if the path to this view is foo/bar/baz, the parent path would be foo/bar.'), - '#process' => array('form_process_radios', 'ctools_dependent_process'), - '#dependency' => array('radio:menu[type]' => array('default tab')), - ); - $form['menu']['parent']['title'] = array( - '#title' => t('Parent item title'), - '#type' => 'textfield', - '#default_value' => $menu['parent']['title'], - '#description' => t('If creating a parent menu item, enter the title of the item.'), - '#process' => array('ctools_dependent_process'), - '#dependency' => array('radio:menu[type]' => array('default tab'), 'radio:menu[parent][type]' => array('normal', 'tab')), - '#dependency_count' => 2, - ); - // Only display the menu selector if menu module is enabled. - if (module_exists('menu')) { - $form['menu']['parent']['name'] = array( - '#title' => t('Parent item menu'), - '#type' => 'select', - '#options' => menu_get_menus(), - '#default_value' => $menu['parent']['name'], - '#description' => t('Insert item into an available menu.'), - '#process' => array('ctools_dependent_process'), - '#dependency' => array('radio:menu[type]' => array('default tab'), 'radio:menu[parent][type]' => array('normal')), - '#dependency_count' => 2, - ); - } - else { - $form['menu']['parent']['name'] = array( - '#type' => 'value', - '#value' => $menu['parent']['name'], - ); - } - $form['menu']['parent']['weight'] = array( - '#title' => t('Tab weight'), - '#type' => 'textfield', - '#default_value' => $menu['parent']['weight'], - '#size' => 5, - '#description' => t('If the parent menu item is a tab, enter the weight of the tab. The lower the number, the more to the left it will be.'), - '#process' => array('ctools_dependent_process'), - '#dependency' => array('radio:menu[type]' => array('default tab'), 'radio:menu[parent][type]' => array('tab')), - '#dependency_count' => 2, - ); - - return $form; -} - -/** - * Validate handler for the menu form for add/edit page task. - */ -function page_manager_page_form_menu_validate(&$form, &$form_state) { - // If setting a 'normal' menu entry, make sure that any placeholders - // support the to_arg stuff. - - if ($form_state['values']['menu']['type'] == 'normal') { - $page = $form_state['page']->subtask['subtask']; - - foreach (explode('/', $page->path) as $bit) { - if (!isset($bit) || $bit === '') { - continue; - } - - if ($bit[0] == '%') { - // Chop off that %. - $name = substr($bit, 1); - - // Check to see if the argument plugin allows to arg: - if (!empty($page->arguments[$name])) { - ctools_include('context'); - $plugin = ctools_get_argument($page->arguments[$name]['name']); - if (!empty($plugin['path placeholder to_arg'])) { - continue; - } - } - - form_error($form['menu']['type'], t('Paths with non optional placeholders cannot be used as normal menu items unless the selected argument handler provides a default argument to use for the menu item.')); - return; - } - } - } -} - -/** - * Submit handler for the menu form for add/edit page task. - */ -function page_manager_page_form_menu_submit(&$form, &$form_state) { - $form_state['page']->subtask['subtask']->menu = $form_state['values']['menu']; - $form_state['page']->path_changed = TRUE; -} - -/** - * Form to handle menu item controls. - */ -function page_manager_page_form_access($form, &$form_state) { - ctools_include('context'); - $form_state['module'] = 'page_manager_page'; - $form_state['callback argument'] = $form_state['page']->task_name; - $form_state['access'] = $form_state['page']->subtask['subtask']->access; - $form_state['no buttons'] = TRUE; - $form_state['contexts'] = array(); - - // Load contexts based on argument data: - if ($arguments = _page_manager_page_get_arguments($form_state['page']->subtask['subtask'])) { - $form_state['contexts'] = ctools_context_get_placeholders_from_argument($arguments); - } - - ctools_include('context-access-admin'); - $form = ctools_access_admin_form($form, $form_state); - - return $form; -} - -/** - * Submit handler to deal with access control changes. - */ -function page_manager_page_form_access_submit(&$form, &$form_state) { - $form_state['page']->subtask['subtask']->access['logic'] = $form_state['values']['logic']; - $form_state['page']->path_changed = TRUE; -} - -/** - * Form to handle assigning argument handlers to named arguments. - */ -function page_manager_page_form_argument($form, &$form_state) { - $page = &$form_state['page']->subtask['subtask']; - $path = $page->path; - - $arguments = page_manager_page_get_named_arguments($path); - - $form['table'] = array( - '#theme' => 'page_manager_page_form_argument_table', - '#page-manager-path' => $path, - 'argument' => array(), - ); - - $task_name = $form_state['page']->task_name; - foreach ($arguments as $keyword => $position) { - $conf = array(); - - if (isset($page->temporary_arguments[$keyword]) && !empty($form_state['allow temp'])) { - $conf = $page->temporary_arguments[$keyword]; - } - else if (isset($page->arguments[$keyword])) { - $conf = $page->arguments[$keyword]; - } - - $context = t('No context assigned'); - - $plugin = array(); - if ($conf && isset($conf['name'])) { - ctools_include('context'); - $plugin = ctools_get_argument($conf['name']); - - if (isset($plugin['title'])) { - $context = $plugin['title']; - } - } - - $form['table']['argument'][$keyword]['#keyword'] = $keyword; - $form['table']['argument'][$keyword]['#position'] = $position; - $form['table']['argument'][$keyword]['#context'] = $context; - - // The URL for this ajax button - $form['table']['argument'][$keyword]['change-url'] = array( - '#attributes' => array('class' => array("page-manager-context-$keyword-change-url")), - '#type' => 'hidden', - '#value' => url("admin/structure/pages/argument/change/$task_name/$keyword", array('absolute' => TRUE)), - ); - $form['table']['argument'][$keyword]['change'] = array( - '#type' => 'submit', - '#value' => t('Change'), - '#attributes' => array('class' => array('ctools-use-modal')), - '#id' => "page-manager-context-$keyword-change", - ); - - $form['table']['argument'][$keyword]['settings'] = array(); - - // Only show the button if this has a settings form available: - if (!empty($plugin)) { - // The URL for this ajax button - $form['table']['argument'][$keyword]['settings-url'] = array( - '#attributes' => array('class' => array("page-manager-context-$keyword-settings-url")), - '#type' => 'hidden', - '#value' => url("admin/structure/pages/argument/settings/$task_name/$keyword", array('absolute' => TRUE)), - ); - $form['table']['argument'][$keyword]['settings'] = array( - '#type' => 'submit', - '#value' => t('Settings'), - '#attributes' => array('class' => array('ctools-use-modal')), - '#id' => "page-manager-context-$keyword-settings", - ); - } - } - - return $form; -} - -/** - * Theme the table for this form. - */ -function theme_page_manager_page_form_argument_table($vars) { - $form = $vars['form']; - $header = array( - array('data' => t('Argument'), 'class' => array('page-manager-argument')), - array('data' => t('Position in path'), 'class' => array('page-manager-position')), - array('data' => t('Context assigned'), 'class' => array('page-manager-context')), - array('data' => t('Operations'), 'class' => array('page-manager-operations')), - ); - - $rows = array(); - - ctools_include('modal'); - ctools_modal_add_js(); - foreach (element_children($form['argument']) as $key) { - $row = array(); - $row[] = '%' . check_plain($form['argument'][$key]['#keyword']); - $row[] = check_plain($form['argument'][$key]['#position']); - $row[] = $form['argument'][$key]['#context'] . '   ' . drupal_render($form['argument'][$key]['change']);; - $row[] = drupal_render($form['argument'][$key]['settings']) . drupal_render($form['argument'][$key]); - - $rows[] = array('data' => $row); - } - - if (!$rows) { - $rows[] = array(array('data' => t('The path %path has no arguments to configure.', array('%path' => $form['#page-manager-path'])), 'colspan' => 4)); - } - - $attributes = array( - 'id' => 'page-manager-argument-table', - ); - - $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes)); - return $output; -} - -/** - * Ajax entry point to edit an item - */ -function page_manager_page_subtask_argument_ajax($step = NULL, $task_name = NULL, $keyword = NULL) { - ctools_include('ajax'); - ctools_include('modal'); - ctools_include('context'); - ctools_include('wizard'); - - if (!$step) { - return ctools_ajax_render_error(); - } - - if (!$cache = page_manager_get_page_cache($task_name)) { - return ctools_ajax_render_error(t('Invalid object name.')); - } - - $page = &$cache->subtask['subtask']; - $path = $page->path; - $arguments = page_manager_page_get_named_arguments($path); - - // Load stored object from cache. - if (!isset($arguments[$keyword])) { - return ctools_ajax_render_error(t('Invalid keyword.')); - } - - // Set up wizard info - $form_info = array( - 'id' => 'page_manager_page_argument', - 'path' => "admin/structure/pages/argument/%step/$task_name/$keyword", - 'show cancel' => TRUE, - 'next callback' => 'page_manager_page_argument_next', - 'finish callback' => 'page_manager_page_argument_finish', - 'cancel callback' => 'page_manager_page_argument_cancel', - 'order' => array( - 'change' => t('Change context type'), - 'settings' => t('Argument settings'), - ), - 'forms' => array( - 'change' => array( - 'title' => t('Change argument'), - 'form id' => 'page_manager_page_argument_form_change', - ), - 'settings' => array( - 'title' => t('Argument settings'), - 'form id' => 'page_manager_page_argument_form_settings', - ), - ), - ); - - $form_state = array( - 'page' => $cache, - 'keyword' => $keyword, - 'ajax' => TRUE, - 'modal' => TRUE, - 'modal return' => TRUE, - 'commands' => array(), - ); - - $output = ctools_wizard_multistep_form($form_info, $step, $form_state); - if (!empty($form_state['complete'])) { - if (isset($page->temporary_arguments[$keyword])) { - $page->arguments[$keyword] = $page->temporary_arguments[$keyword]; - } - - if (isset($page->temporary_arguments)) { - unset($page->temporary_arguments); - } - - // Update the cache with changes. - page_manager_set_page_cache($cache); - - // Rerender the table so we can ajax it back in. - // Go directly to the form and retrieve it using a blank form and - // a clone of our current form state. This is an abbreviated - // drupal_get_form that is halted prior to render and is never - // fully processed, but is guaranteed to produce the same form we - // started with so we don't have to do crazy stuff to rerender - // just part of it. - - // @todo should there be a tool to do this? - - $clone_state = $form_state; - $clone_state['allow temp'] = TRUE; - page_manager_page_form_argument($form, $clone_state); - $form = drupal_build_form('page_manager_page_form_argument', $form_state); - - // Render just the table portion. - $output = drupal_render($form['table']); - $commands = array( - ajax_command_replace('#page-manager-argument-table', $output), - ctools_modal_command_dismiss(), - ); - } - else { - $commands = ctools_modal_form_render($form_state, $output); - } - print ajax_render($commands); - ajax_footer(); - exit; -} - -/** - * Callback generated when the add page process is finished. - */ -function page_manager_page_argument_finish(&$form_state) { -} - -/** - * Callback generated when the 'next' button is clicked. - * - * All we do here is store the cache. - */ -function page_manager_page_argument_next(&$form_state) { - // Update the cache with changes. - page_manager_set_page_cache($form_state['page']); -} - -/** - * Callback generated when the 'cancel' button is clicked. - * - * We might have some temporary data lying around. We must remove it. - */ -function page_manager_page_argument_cancel(&$form_state) { - $page = &$form_state['page']->subtask['subtask']; - if (isset($page->temporary_arguments)) { - unset($page->temporary_arguments); - // Update the cache with changes. - page_manager_set_page_cache($page); - } -} - -/** - * Basic settings form for a page manager page. - */ -function page_manager_page_argument_form_change($form, &$form_state) { - $page = &$form_state['page']->subtask['subtask']; - $keyword = &$form_state['keyword']; - - ctools_include('context'); - $plugins = ctools_get_arguments(); - - $options = array(); - foreach ($plugins as $id => $plugin) { - $options[$id] = $plugin['title']; - } - - asort($options); - - $options = array('' => t('No context selected')) + $options; - - $argument = ''; - if (isset($page->arguments[$keyword]) && isset($page->arguments[$keyword]['name'])) { - $argument = $page->arguments[$keyword]['name']; - } - - $form['argument'] = array( - '#type' => 'radios', - '#options' => $options, - '#default_value' => $argument, - ); - - return $form; -} - -/** - * Submit handler to change an argument. - */ -function page_manager_page_argument_form_change_submit(&$form, &$form_state) { - $page = &$form_state['page']->subtask['subtask']; - $keyword = &$form_state['keyword']; - $argument = $form_state['values']['argument']; - - // If the argument is not changing, we do not need to do anything. - if (isset($page->arguments[$keyword]['name']) && $page->arguments[$keyword]['name'] == $argument) { - // Set the task to cancel since no change means do nothing: - $form_state['clicked_button']['#wizard type'] = 'cancel'; - return; - } - - ctools_include('context'); - - // If switching to the no context, just wipe out the old data. - if (empty($argument)) { - $form_state['clicked_button']['#wizard type'] = 'finish'; - $page->temporary_arguments[$keyword] = array( - 'settings' => array(), - 'identifier' => t('No context'), - ); - return; - } - - $plugin = ctools_get_argument($argument); - - // Acquire defaults. - $settings = array(); - - if (isset($plugin['default'])) { - if (is_array($plugin['default'])) { - $settings = $plugin['default']; - } - else if (function_exists($plugin['default'])) { - $settings = $plugin['default'](); - } - } - - $id = ctools_context_next_id($page->arguments, $argument); - $title = isset($plugin['title']) ? $plugin['title'] : t('No context'); - - // Set the new argument in a temporary location. - $page->temporary_arguments[$keyword] = array( - 'id' => $id, - 'identifier' => $title . ($id > 1 ? ' ' . $id : ''), - 'name' => $argument, - 'settings' => $settings, - ); -} - -/** - * Basic settings form for a page manager page. - */ -function page_manager_page_argument_form_settings($form, &$form_state) { - $page = &$form_state['page']->subtask['subtask']; - $keyword = &$form_state['keyword']; - - if (isset($page->temporary_arguments[$keyword])) { - $conf = $page->temporary_arguments[$keyword]; - } - else if (isset($page->arguments[$keyword])) { - $conf = $page->temporary_arguments[$keyword] = $page->arguments[$keyword]; - } - - if (!isset($conf)) { - // This should be impossible and thus never seen. - $form['error'] = array('#value' => t('Error: missing argument.')); - return; - } - - ctools_include('context'); - $plugin = ctools_get_argument($conf['name']); - - $form['settings'] = array( - '#tree' => TRUE, - ); - - $form['identifier'] = array( - '#type' => 'textfield', - '#title' => t('Context identifier'), - '#description' => t('This is the title of the context used to identify it later in the administrative process. This will never be shown to a user.'), - '#default_value' => $conf['identifier'], - ); - - if (!$plugin) { - // This should be impossible and thus never seen. - $form['error'] = array('#value' => t('Error: missing or invalid argument plugin %argument.', array('%argument', $argument))); - return; - } - - if ($function = ctools_plugin_get_function($plugin, 'settings form')) { - $function($form, $form_state, $conf['settings']); - } - - $form_state['plugin'] = $plugin; - return $form; -} - -/** - * Validate handler for argument settings. - */ -function page_manager_page_argument_form_settings_validate(&$form, &$form_state) { - if ($function = ctools_plugin_get_function($form_state['plugin'], 'settings form validate')) { - $function($form, $form_state); - } -} - -/** - * Submit handler for argument settings. - */ -function page_manager_page_argument_form_settings_submit(&$form, &$form_state) { - if ($function = ctools_plugin_get_function($form_state['plugin'], 'settings form submit')) { - $function($form, $form_state); - } - - $page = &$form_state['page']->subtask['subtask']; - $keyword = &$form_state['keyword']; - // Copy the form to our temporary location which will get moved again when - // finished. Yes, finished is always next but finish can happen from other - // locations so we funnel through that path rather than duplicate. - $page->temporary_arguments[$keyword]['identifier'] = $form_state['values']['identifier']; - if (isset($form_state['values']['settings'])) { - $page->temporary_arguments[$keyword]['settings'] = $form_state['values']['settings']; - } - else { - $page->temporary_arguments[$keyword]['settings'] = array(); - } -} - -/** - * Import a task handler from cut & paste - */ -function page_manager_page_import_subtask($form, &$form_state, $task_name) { - $form_state['task'] = page_manager_get_task($task_name); - - drupal_set_title(t('Import page')); - $form['name'] = array( - '#type' => 'textfield', - '#title' => t('Page name'), - '#description' => t('Enter the name to use for this page if it is different from the source page. Leave blank to use the original name of the page.'), - ); - - $form['path'] = array( - '#type' => 'textfield', - '#title' => t('Path'), - '#description' => t('Enter the path to use for this page if it is different from the source page. Leave blank to use the original path of the page.'), - ); - - $form['overwrite'] = array( - '#type' => 'checkbox', - '#title' => t('Allow overwrite of an existing page'), - '#description' => t('If the name you selected already exists in the database, this page will be allowed to overwrite the existing page.'), - ); - - $form['object'] = array( - '#type' => 'textarea', - '#title' => t('Paste page code here'), - '#rows' => 15, - ); - - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Import'), - ); - return $form; -} - -/** - * Ensure we got a valid page. - */ -function page_manager_page_import_subtask_validate(&$form, &$form_state) { - ob_start(); - eval($form_state['values']['object']); - ob_end_clean(); - - if (!isset($page) || !is_object($page)) { - $errors = ob_get_contents(); - if (empty($errors)) { - $errors = t('No handler found.'); - } - form_error($form['object'], t('Unable to get a page from the import. Errors reported: @errors', array('@errors' => $errors))); - } - - if (empty($form_state['values']['name'])) { - $form_state['values']['name'] = $page->name; - } - - $task_name = page_manager_make_task_name('page', $form_state['values']['name']); - $form_state['cache'] = page_manager_get_page_cache($task_name); - - if ($form_state['cache'] && $form_state['cache']->locked) { - form_error($form['name'], t('That page name is in use and locked by another user. You must break the lock on that page before proceeding, or choose a different name.', array('!break' => url(page_manager_edit_url($task_name, array('actions', 'break-lock')))))); - return; - } - - if (empty($form_state['values']['path'])) { - $form_state['values']['path'] = $page->path; - } - - if (empty($form_state['values']['overwrite'])) { - $page->name = NULL; - } - - $form_state['page'] = new stdClass(); - $form_state['page']->subtask['subtask'] = $page; - page_manager_page_form_basic_validate($form, $form_state); -} - -/** - * Submit the import page to create the new page and redirect. - */ -function page_manager_page_import_subtask_submit($form, &$form_state) { - $page = &$form_state['page']->subtask['subtask']; - $page->name = $form_state['values']['name']; - $page->path = $form_state['values']['path']; - - $task_name = page_manager_make_task_name('page', $page->name); - $cache = page_manager_get_page_cache($task_name); - if (!$cache) { - $cache = new stdClass(); - } - - page_manager_page_new_page_cache($page, $cache); - page_manager_set_page_cache($cache); - - $form_state['redirect'] = page_manager_edit_url($task_name); -} - -/** - * Entry point to export a page. - */ -function page_manager_page_form_export($form, &$form_state) { - $page = $form_state['page']->subtask['subtask']; - - $export = page_manager_page_export($page, $form_state['page']->handlers); - - $lines = substr_count($export, "\n"); - $form['code'] = array( - '#type' => 'textarea', - '#default_value' => $export, - '#rows' => $lines, - ); - - unset($form['buttons']); - return $form; -} - -/** - * Entry point to clone a page. - */ -function page_manager_page_form_clone($form, &$form_state) { - $page = &$form_state['page']->subtask['subtask']; - - // This provides its own button because it does something totally different. - unset($form['buttons']); - - $form['admin_title'] = array( - '#type' => 'textfield', - '#title' => t('Administrative title'), - '#description' => t('The name of this page. This will appear in the administrative interface to easily identify it.'), - '#default_value' => $page->admin_title, - ); - - $form['name'] = array( - '#type' => 'machine_name', - '#title' => t('Page name'), - '#machine_name' => array( - 'exists' => 'page_manager_page_load', - 'source' => array('admin_title'), - ), - '#description' => t('Enter the name to the new page It must be unique and contain only alphanumeric characters and underscores.'), - ); - - // path - $form['path'] = array( - '#type' => 'textfield', - '#title' => t('Path'), - '#description' => t('The URL path to get to this page. You may create named placeholders for variable parts of the path by using %name for required elements and !name for optional elements. For example: "node/%node/foo", "forum/%forum" or "dashboard/!input". These named placeholders can be turned into contexts on the arguments form. You cannot use the same path as the original page.'), - '#default_value' => $page->path, - ); - - $form['handlers'] = array( - '#type' => 'checkbox', - '#title' => t('Clone variants'), - '#description' => t('If checked all variants associated with the page will be cloned as well. If not checked the page will be cloned without variants.'), - '#default_value' => TRUE, - ); - - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Clone'), - ); - - return $form; -} - -/** - * Validate clone page form. - */ -function page_manager_page_form_clone_validate(&$form, &$form_state) { - $page = &$form_state['page']->subtask['subtask']; - - $page->old_name = $page->name; - $page->name = NULL; - page_manager_page_form_basic_validate($form, $form_state); -} - -/** - * submit clone page form. - * - * Load the page, change the name(s) to protect the innocent, and if - * requested, load all the task handlers so that they get saved properly too. - */ -function page_manager_page_form_clone_submit(&$form, &$form_state) { - $original = $form_state['page']->subtask['subtask']; - - $original->name = $form_state['values']['name']; - $original->admin_title = $form_state['values']['admin_title']; - $original->path = $form_state['values']['path'];