From 438237e8521264f207c5964c9b2cd3cf6a6f4a76 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Tue, 9 Jul 2019 12:22:32 +0200 Subject: [PATCH] updated contrib modules --- sites/all/modules/context/context.core.inc | 26 +- sites/all/modules/context/context.info | 7 +- sites/all/modules/context/context.install | 2 +- sites/all/modules/context/context.module | 65 +- sites/all/modules/context/context.plugins.inc | 4 +- .../context_layouts/context_layouts.info | 7 +- .../context/context_ui/context_ui.info | 7 +- .../modules/context/context_ui/context_ui.js | 4 +- .../context/context_ui/context_ui.module | 20 +- .../context/context_ui/context_ui_dialog.js | 4 +- .../export_ui/context_export_ui.class.php | 22 +- .../context/context_ui/tests/context_ui.test | 2 +- .../plugins/context_condition_bookroot.inc | 2 +- .../plugins/context_condition_menu.inc | 2 +- .../context_condition_node_taxonomy.inc | 14 +- .../context_condition_query_string.inc | 2 +- .../plugins/context_reaction_block.inc | 21 +- .../context/plugins/context_reaction_block.js | 11 +- .../plugins/context_reaction_breadcrumb.inc | 1 + .../context/plugins/context_reaction_menu.inc | 4 +- .../plugins/context_reaction_region.inc | 6 +- .../context_reaction_template_suggestions.inc | 2 +- .../context/tests/context.conditions.test | 22 - .../theme/context_reaction_block.theme.inc | 7 +- sites/all/modules/link/README.txt | 101 ++ sites/all/modules/link/link-rtl.css | 7 + sites/all/modules/link/link.css | 5 +- .../all/modules/link/link.devel_generate.inc | 32 + sites/all/modules/link/link.diff.inc | 22 + sites/all/modules/link/link.info | 12 +- sites/all/modules/link/link.install | 82 +- sites/all/modules/link/link.migrate.inc | 139 ++ sites/all/modules/link/link.module | 1248 +++++++++++++---- .../modules/link/tests/link.attribute.test | 862 +++++------- sites/all/modules/link/tests/link.crud.test | 55 +- .../modules/link/tests/link.crud_browser.test | 506 ++++--- .../modules/link/tests/link.entity_token.test | 164 +++ sites/all/modules/link/tests/link.test | 39 +- sites/all/modules/link/tests/link.token.test | 313 +++-- .../all/modules/link/tests/link.validate.test | 535 ++++--- sites/all/modules/link/views/link.views.inc | 3 + .../link_views_handler_argument_target.inc | 25 +- .../link_views_handler_filter_protocol.inc | 71 +- sites/all/modules/module_filter/CHANGELOG.txt | 109 +- sites/all/modules/module_filter/README.txt | 4 +- .../module_filter/css/dynamic_position.css | 2 - .../module_filter/css/module_filter.css | 6 + .../module_filter/css/module_filter_tab.css | 19 +- .../all/modules/module_filter/css/modules.css | 53 + .../module_filter/images/collapsed.png | Bin 0 -> 105 bytes .../modules/module_filter/images/expanded.png | Bin 0 -> 106 bytes .../module_filter/js/dynamic_position.js | 46 +- .../modules/module_filter/js/module_filter.js | 13 +- .../module_filter/js/module_filter_tab.js | 176 ++- sites/all/modules/module_filter/js/modules.js | 11 + .../module_filter/module_filter.admin.inc | 36 +- .../modules/module_filter/module_filter.info | 8 +- .../module_filter/module_filter.install | 7 +- .../module_filter/module_filter.module | 101 +- .../module_filter/module_filter.pages.inc | 17 +- .../module_filter/module_filter.theme.inc | 138 +- sites/all/modules/uuid/composer.json | 13 + sites/all/modules/uuid/uuid.info | 6 +- sites/all/modules/uuid/uuid.test | 33 +- .../all/modules/uuid/uuid_path/uuid_path.info | 6 +- .../uuid/uuid_services/uuid_services.info | 8 +- .../uuid/uuid_services/uuid_services.module | 9 +- .../uuid_services.user_services.test | 231 +++ .../uuid_services_example.info | 6 +- .../modules/views/css/ie/views-admin.ie7.css | 2 +- .../views/css/views-admin.bartik-rtl.css | 2 +- .../modules/views/css/views-admin.bartik.css | 143 +- sites/all/modules/views/css/views-admin.css | 16 +- .../views/css/views-admin.ctools-rtl.css | 2 +- .../modules/views/css/views-admin.ctools.css | 18 +- .../views/css/views-admin.garland-rtl.css | 4 +- .../modules/views/css/views-admin.garland.css | 143 +- .../modules/views/css/views-admin.seven.css | 163 ++- .../modules/views/css/views-admin.theme.css | 111 +- sites/all/modules/views/css/views-rtl.css | 1 - sites/all/modules/views/drush/views.drush.inc | 149 +- .../views/handlers/views_handler_area.inc | 84 +- .../handlers/views_handler_area_messages.inc | 2 +- .../handlers/views_handler_area_result.inc | 29 +- .../handlers/views_handler_area_text.inc | 49 +- .../views_handler_area_text_custom.inc | 32 +- .../handlers/views_handler_area_view.inc | 14 +- .../views/handlers/views_handler_argument.inc | 435 +++--- .../handlers/views_handler_argument_date.inc | 53 +- .../views_handler_argument_formula.inc | 23 +- ...iews_handler_argument_group_by_numeric.inc | 19 +- .../views_handler_argument_many_to_one.inc | 56 +- .../handlers/views_handler_argument_null.inc | 21 +- .../views_handler_argument_numeric.inc | 39 +- .../views_handler_argument_string.inc | 71 +- .../views/handlers/views_handler_field.inc | 398 ++++-- .../handlers/views_handler_field_boolean.inc | 38 +- .../views_handler_field_contextual_links.inc | 14 +- .../handlers/views_handler_field_counter.inc | 31 +- .../views_handler_field_ctools_dropdown.inc | 25 +- .../handlers/views_handler_field_custom.inc | 26 +- .../handlers/views_handler_field_date.inc | 143 +- .../handlers/views_handler_field_entity.inc | 15 +- .../handlers/views_handler_field_links.inc | 21 +- .../views_handler_field_machine_name.inc | 32 +- .../handlers/views_handler_field_markup.inc | 22 +- .../handlers/views_handler_field_math.inc | 27 +- .../handlers/views_handler_field_numeric.inc | 31 +- .../views_handler_field_prerender_list.inc | 54 +- .../views_handler_field_serialized.inc | 24 +- .../views_handler_field_time_interval.inc | 17 +- .../handlers/views_handler_field_url.inc | 16 +- .../views/handlers/views_handler_filter.inc | 502 ++++--- .../views_handler_filter_boolean_operator.inc | 66 +- ...handler_filter_boolean_operator_string.inc | 7 +- .../handlers/views_handler_filter_combine.inc | 80 +- .../handlers/views_handler_filter_date.inc | 57 +- .../views_handler_filter_entity_bundle.inc | 26 +- .../views_handler_filter_equality.inc | 18 +- .../views_handler_filter_fields_compare.inc | 46 +- .../views_handler_filter_group_by_numeric.inc | 35 +- .../views_handler_filter_in_operator.inc | 110 +- .../views_handler_filter_many_to_one.inc | 42 +- .../handlers/views_handler_filter_numeric.inc | 202 ++- .../handlers/views_handler_filter_string.inc | 149 +- .../handlers/views_handler_relationship.inc | 79 +- ...ews_handler_relationship_groupwise_max.inc | 125 +- .../views/handlers/views_handler_sort.inc | 99 +- .../handlers/views_handler_sort_date.inc | 21 +- .../views_handler_sort_group_by_numeric.inc | 16 +- .../views_handler_sort_menu_hierarchy.inc | 17 +- .../handlers/views_handler_sort_random.inc | 12 +- sites/all/modules/views/help/about.html | 4 +- .../views/help/alter-exposed-filter.html | 11 +- sites/all/modules/views/help/api-example.html | 2 +- sites/all/modules/views/help/api-tables.html | 7 +- .../all/modules/views/help/api-upgrading.html | 10 +- sites/all/modules/views/help/embed.html | 4 +- sites/all/modules/views/help/ui-crashes.html | 6 +- sites/all/modules/views/includes/admin.inc | 716 ++++++---- sites/all/modules/views/includes/ajax.inc | 78 +- sites/all/modules/views/includes/analyze.inc | 14 +- sites/all/modules/views/includes/base.inc | 144 +- sites/all/modules/views/includes/cache.inc | 29 +- sites/all/modules/views/includes/handlers.inc | 731 ++++++---- sites/all/modules/views/includes/plugins.inc | 58 +- sites/all/modules/views/includes/view.inc | 666 +++++---- sites/all/modules/views/js/ajax.js | 80 +- sites/all/modules/views/js/ajax_view.js | 260 ++-- sites/all/modules/views/js/base.js | 178 +-- .../views/js/jquery.ui.dialog.patch.js | 12 +- sites/all/modules/views/js/views-admin.js | 45 +- .../all/modules/views/js/views-contextual.js | 18 +- sites/all/modules/views/js/views-list.js | 26 +- .../views/modules/aggregator.views.inc | 199 ++- ...ndler_argument_aggregator_category_cid.inc | 4 +- .../views_handler_argument_aggregator_fid.inc | 4 +- .../views_handler_argument_aggregator_iid.inc | 4 +- ...iews_handler_field_aggregator_category.inc | 18 +- ...ws_handler_field_aggregator_title_link.inc | 28 +- .../views_handler_field_aggregator_xss.inc | 7 +- ...handler_filter_aggregator_category_cid.inc | 7 +- .../views_plugin_row_aggregator_rss.inc | 38 +- .../all/modules/views/modules/book.views.inc | 27 +- ...iews_plugin_argument_default_book_root.inc | 10 +- .../modules/views/modules/comment.views.inc | 130 +- .../views/modules/comment.views_default.inc | 6 +- ...iews_handler_argument_comment_user_uid.inc | 22 +- .../comment/views_handler_field_comment.inc | 25 +- .../views_handler_field_comment_depth.inc | 6 +- .../views_handler_field_comment_link.inc | 31 +- ...ews_handler_field_comment_link_approve.inc | 16 +- ...iews_handler_field_comment_link_delete.inc | 16 +- .../views_handler_field_comment_link_edit.inc | 19 +- ...views_handler_field_comment_link_reply.inc | 18 +- .../views_handler_field_comment_node_link.inc | 40 +- .../views_handler_field_comment_username.inc | 24 +- ...s_handler_field_last_comment_timestamp.inc | 14 +- ...ws_handler_field_ncs_last_comment_name.inc | 28 +- .../views_handler_field_ncs_last_updated.inc | 8 +- .../views_handler_field_node_comment.inc | 7 +- .../views_handler_field_node_new_comments.inc | 44 +- .../views_handler_filter_comment_user_uid.inc | 7 +- .../views_handler_filter_ncs_last_updated.inc | 7 +- .../views_handler_filter_node_comment.inc | 7 +- .../views_handler_sort_comment_thread.inc | 13 +- ...ews_handler_sort_ncs_last_comment_name.inc | 19 +- .../views_handler_sort_ncs_last_updated.inc | 7 +- .../comment/views_plugin_row_comment_rss.inc | 43 +- .../comment/views_plugin_row_comment_view.inc | 42 +- .../views_handler_field_contact_link.inc | 22 +- .../all/modules/views/modules/field.views.inc | 58 +- .../views_handler_argument_field_list.inc | 27 +- ...ews_handler_argument_field_list_string.inc | 29 +- .../field/views_handler_field_field.inc | 136 +- .../field/views_handler_filter_field_list.inc | 15 +- ...iews_handler_filter_field_list_boolean.inc | 6 +- ...ws_handler_relationship_entity_reverse.inc | 13 +- .../modules/views/modules/filter.views.inc | 7 +- ...views_handler_field_filter_format_name.inc | 19 +- .../modules/views/modules/locale.views.inc | 30 +- .../views_handler_argument_locale_group.inc | 18 +- ...views_handler_argument_locale_language.inc | 18 +- .../views_handler_field_locale_group.inc | 7 +- .../views_handler_field_locale_language.inc | 19 +- .../views_handler_field_locale_link_edit.inc | 39 +- .../views_handler_field_node_language.inc | 19 +- .../views_handler_filter_locale_group.inc | 9 +- .../views_handler_filter_locale_language.inc | 9 +- .../views_handler_filter_locale_version.inc | 9 +- .../views_handler_filter_node_language.inc | 9 +- .../views_handler_sort_node_language.inc | 22 +- .../all/modules/views/modules/node.views.inc | 223 +-- .../views/modules/node.views_default.inc | 8 +- .../views/modules/node.views_template.inc | 10 +- .../views_handler_argument_dates_various.inc | 91 +- .../views_handler_argument_node_language.inc | 16 +- .../node/views_handler_argument_node_nid.inc | 6 +- .../node/views_handler_argument_node_type.inc | 22 +- ...ews_handler_argument_node_uid_revision.inc | 13 +- .../node/views_handler_argument_node_vid.inc | 6 +- ...s_handler_field_history_user_timestamp.inc | 29 +- .../modules/node/views_handler_field_node.inc | 30 +- .../node/views_handler_field_node_link.inc | 21 +- .../views_handler_field_node_link_delete.inc | 3 +- .../views_handler_field_node_link_edit.inc | 3 +- .../node/views_handler_field_node_path.inc | 28 +- .../views_handler_field_node_revision.inc | 21 +- ...views_handler_field_node_revision_link.inc | 18 +- ...andler_field_node_revision_link_delete.inc | 11 +- ...andler_field_node_revision_link_revert.inc | 11 +- .../node/views_handler_field_node_type.inc | 20 +- ...views_handler_field_node_version_count.inc | 8 +- ..._handler_filter_history_user_timestamp.inc | 29 +- .../node/views_handler_filter_node_access.inc | 23 +- .../node/views_handler_filter_node_status.inc | 28 +- .../node/views_handler_filter_node_type.inc | 7 +- ...views_handler_filter_node_uid_revision.inc | 7 +- ...iews_handler_filter_node_version_count.inc | 27 +- .../views_handler_sort_node_version_count.inc | 7 +- .../views_plugin_argument_default_node.inc | 11 +- .../views_plugin_argument_validate_node.inc | 37 +- .../node/views_plugin_row_node_rss.inc | 59 +- .../node/views_plugin_row_node_view.inc | 58 +- .../all/modules/views/modules/poll.views.inc | 5 +- .../modules/views/modules/profile.views.inc | 31 +- .../views_handler_field_profile_date.inc | 25 +- .../views_handler_field_profile_list.inc | 19 +- ...views_handler_filter_profile_selection.inc | 7 +- .../modules/views/modules/search.views.inc | 50 +- .../views/modules/search.views_default.inc | 4 +- .../search/views_handler_argument_search.inc | 16 +- .../views_handler_field_search_score.inc | 25 +- .../search/views_handler_filter_search.inc | 74 +- .../views_handler_sort_search_score.inc | 17 +- .../search/views_plugin_row_search_view.inc | 16 +- .../views/modules/statistics.views.inc | 166 ++- .../modules/statistics.views_default.inc | 4 +- .../views_handler_field_accesslog_path.inc | 23 +- ...s_handler_field_node_counter_timestamp.inc | 2 + ...views_handler_field_statistics_numeric.inc | 2 + .../modules/views/modules/system.views.inc | 160 ++- .../views_handler_argument_file_fid.inc | 4 +- .../system/views_handler_field_file.inc | 20 +- .../views_handler_field_file_extension.inc | 14 +- .../views_handler_field_file_filemime.inc | 19 +- .../views_handler_field_file_status.inc | 7 +- .../system/views_handler_field_file_uri.inc | 20 +- .../views_handler_filter_file_status.inc | 7 +- .../views_handler_filter_system_type.inc | 7 +- .../modules/views/modules/taxonomy.views.inc | 75 +- .../views/modules/taxonomy.views_default.inc | 4 +- .../views_handler_argument_taxonomy.inc | 5 +- .../views_handler_argument_term_node_tid.inc | 22 +- ...s_handler_argument_term_node_tid_depth.inc | 31 +- ...dler_argument_term_node_tid_depth_join.inc | 31 +- ..._argument_term_node_tid_depth_modifier.inc | 27 +- ...ndler_argument_vocabulary_machine_name.inc | 4 +- .../views_handler_argument_vocabulary_vid.inc | 4 +- .../taxonomy/views_handler_field_taxonomy.inc | 22 +- .../views_handler_field_term_link_edit.inc | 57 +- .../views_handler_field_term_node_tid.inc | 46 +- .../views_handler_filter_term_node_tid.inc | 115 +- ...ews_handler_filter_term_node_tid_depth.inc | 27 +- ...andler_filter_term_node_tid_depth_join.inc | 31 +- ...handler_filter_vocabulary_machine_name.inc | 7 +- .../views_handler_filter_vocabulary_vid.inc | 7 +- ...ws_handler_relationship_node_term_data.inc | 25 +- ...s_plugin_argument_default_taxonomy_tid.inc | 27 +- ...plugin_argument_validate_taxonomy_term.inc | 47 +- .../modules/views/modules/tracker.views.inc | 9 +- ...dler_argument_tracker_comment_user_uid.inc | 6 +- ...andler_filter_tracker_boolean_operator.inc | 12 +- ...andler_filter_tracker_comment_user_uid.inc | 7 +- .../views/modules/translation.views.inc | 11 +- .../views_handler_argument_node_tnid.inc | 8 +- ...iews_handler_field_node_link_translate.inc | 12 +- ...ws_handler_field_node_translation_link.inc | 22 +- .../views_handler_filter_node_tnid.inc | 43 +- .../views_handler_filter_node_tnid_child.inc | 28 +- ...views_handler_relationship_translation.inc | 16 +- .../all/modules/views/modules/user.views.inc | 151 +- .../user/views_handler_argument_user_uid.inc | 6 +- ...views_handler_argument_users_roles_rid.inc | 7 +- .../modules/user/views_handler_field_user.inc | 27 +- .../views_handler_field_user_language.inc | 9 +- .../user/views_handler_field_user_link.inc | 37 +- .../views_handler_field_user_link_cancel.inc | 6 +- .../views_handler_field_user_link_edit.inc | 7 +- .../user/views_handler_field_user_mail.inc | 17 +- .../user/views_handler_field_user_name.inc | 31 +- .../views_handler_field_user_permissions.inc | 50 +- .../user/views_handler_field_user_picture.inc | 42 +- .../user/views_handler_field_user_roles.inc | 32 +- .../views_handler_filter_user_current.inc | 12 +- .../user/views_handler_filter_user_name.inc | 63 +- .../views_handler_filter_user_permissions.inc | 13 +- .../user/views_handler_filter_user_roles.inc | 9 +- ...s_plugin_argument_default_current_user.inc | 11 +- .../views_plugin_argument_default_user.inc | 27 +- .../views_plugin_argument_validate_user.inc | 37 +- .../user/views_plugin_row_user_view.inc | 85 +- .../all/modules/views/modules/views.views.inc | 6 +- .../plugins/export_ui/views_ui.class.php | 120 +- .../views/plugins/views_plugin_access.inc | 51 +- .../plugins/views_plugin_access_none.inc | 9 +- .../plugins/views_plugin_access_perm.inc | 29 +- .../plugins/views_plugin_access_role.inc | 38 +- .../plugins/views_plugin_argument_default.inc | 45 +- .../views_plugin_argument_default_fixed.inc | 21 +- .../views_plugin_argument_default_php.inc | 28 +- .../views_plugin_argument_default_raw.inc | 19 +- .../views_plugin_argument_validate.inc | 47 +- ...views_plugin_argument_validate_numeric.inc | 9 +- .../views_plugin_argument_validate_php.inc | 26 +- .../views/plugins/views_plugin_cache.inc | 117 +- .../views/plugins/views_plugin_cache_none.inc | 25 +- .../views/plugins/views_plugin_cache_time.inc | 49 +- .../views/plugins/views_plugin_display.inc | 735 ++++++---- .../views_plugin_display_attachment.inc | 120 +- .../plugins/views_plugin_display_block.inc | 64 +- .../plugins/views_plugin_display_default.inc | 37 +- .../plugins/views_plugin_display_embed.inc | 3 +- .../plugins/views_plugin_display_extender.inc | 38 +- .../plugins/views_plugin_display_feed.inc | 72 +- .../plugins/views_plugin_display_page.inc | 115 +- .../plugins/views_plugin_exposed_form.inc | 83 +- .../views_plugin_exposed_form_basic.inc | 4 +- ...ews_plugin_exposed_form_input_required.inc | 30 +- .../plugins/views_plugin_localization.inc | 81 +- .../views_plugin_localization_core.inc | 36 +- .../views_plugin_localization_none.inc | 15 +- .../views/plugins/views_plugin_pager.inc | 120 +- .../views/plugins/views_plugin_pager_full.inc | 104 +- .../views/plugins/views_plugin_pager_mini.inc | 34 +- .../views/plugins/views_plugin_pager_none.inc | 51 +- .../views/plugins/views_plugin_pager_some.inc | 31 +- .../views/plugins/views_plugin_query.inc | 75 +- .../plugins/views_plugin_query_default.inc | 689 ++++----- .../views/plugins/views_plugin_row.inc | 43 +- .../views/plugins/views_plugin_row_fields.inc | 15 +- .../plugins/views_plugin_row_rss_fields.inc | 32 +- .../views/plugins/views_plugin_style.inc | 150 +- .../plugins/views_plugin_style_default.inc | 13 +- .../views/plugins/views_plugin_style_grid.inc | 10 +- .../plugins/views_plugin_style_jump_menu.inc | 28 +- .../views/plugins/views_plugin_style_list.inc | 10 +- .../plugins/views_plugin_style_mapping.inc | 15 +- .../views/plugins/views_plugin_style_rss.inc | 34 +- .../plugins/views_plugin_style_summary.inc | 30 +- .../views_plugin_style_summary_jump_menu.inc | 26 +- ...views_plugin_style_summary_unformatted.inc | 14 +- .../plugins/views_plugin_style_table.inc | 39 +- .../plugins/views_wizard/file_managed.inc | 3 +- .../views/plugins/views_wizard/node.inc | 2 +- .../plugins/views_wizard/node_revision.inc | 3 +- .../plugins/views_wizard/taxonomy_term.inc | 3 +- .../views_ui_base_views_wizard.class.php | 80 +- .../views_ui_comment_views_wizard.class.php | 1 + ...ews_ui_file_managed_views_wizard.class.php | 2 + ...ws_ui_node_revision_views_wizard.class.php | 1 + .../views_ui_node_views_wizard.class.php | 4 + ...ws_ui_taxonomy_term_views_wizard.class.php | 1 + .../views_ui_users_views_wizard.class.php | 2 + .../views-view--frontpage.tpl.php | 2 +- sites/all/modules/views/tests/README.txt | 29 + ...ews_handler_argument_comment_user_uid.test | 14 +- ...views_handler_filter_comment_user_uid.test | 1 + .../views/tests/field/views_fieldapi.test | 72 +- .../handlers/views_handler_area_text.test | 2 +- .../handlers/views_handler_argument_null.test | 2 +- .../views_handler_argument_string.test | 2 + .../tests/handlers/views_handler_field.test | 23 +- .../handlers/views_handler_field_boolean.test | 3 +- .../handlers/views_handler_field_counter.test | 5 +- .../handlers/views_handler_field_custom.test | 1 + .../handlers/views_handler_field_date.test | 24 +- .../views_handler_field_file_extension.test | 1 + .../views_handler_field_file_size.test | 1 + .../handlers/views_handler_field_math.test | 1 + .../handlers/views_handler_field_url.test | 1 + .../handlers/views_handler_field_xss.test | 3 +- .../views_handler_filter_combine.test | 1 + .../handlers/views_handler_filter_date.test | 5 +- .../views_handler_filter_equality.test | 8 +- .../views_handler_filter_numeric.test | 62 +- .../handlers/views_handler_filter_string.test | 62 +- .../handlers/views_handler_manytoone.test | 1099 +++++++++++++++ .../tests/handlers/views_handler_sort.test | 9 +- .../handlers/views_handler_sort_date.test | 125 +- .../handlers/views_handler_sort_random.test | 8 +- .../views/tests/handlers/views_handlers.test | 6 +- .../node/views_node_revision_relations.test | 1 + .../tests/plugins/views_plugin_display.test | 9 +- .../tests/styles/views_plugin_style.test | 10 +- .../styles/views_plugin_style_jump_menu.test | 17 +- .../styles/views_plugin_style_mapping.test | 2 +- .../views_plugin_style_unformatted.test | 2 +- ...s_handler_relationship_node_term_data.test | 8 +- .../test_handlers/views_test_area_access.inc | 11 +- .../views_test_plugin_access_test_dynamic.inc | 17 +- .../views_test_plugin_access_test_static.inc | 17 +- .../views_test_plugin_style_test_mapping.inc | 3 +- .../user/views_handler_field_user_name.test | 67 +- .../modules/views/tests/user/views_user.test | 23 +- .../user/views_user_argument_default.test | 16 +- .../user/views_user_argument_validate.test | 16 +- .../all/modules/views/tests/views_access.test | 3 + .../modules/views/tests/views_analyze.test | 3 +- .../views/tests/views_argument_default.test | 7 +- .../views/tests/views_argument_validator.test | 90 +- .../all/modules/views/tests/views_basic.test | 11 +- .../all/modules/views/tests/views_cache.test | 12 +- .../modules/views/tests/views_cache.test.js | 1 + .../all/modules/views/tests/views_clone.test | 277 ++++ .../views/tests/views_exposed_form.test | 35 +- .../modules/views/tests/views_glossary.test | 5 +- .../modules/views/tests/views_groupby.test | 153 +- .../views/tests/views_handler_filter.test | 161 +++ .../modules/views/tests/views_handlers.test | 13 +- .../all/modules/views/tests/views_module.test | 8 +- .../all/modules/views/tests/views_pager.test | 83 +- .../tests/views_plugin_localization_test.inc | 11 +- .../all/modules/views/tests/views_query.test | 145 +- sites/all/modules/views/tests/views_test.info | 7 +- .../all/modules/views/tests/views_test.module | 2 +- .../views/tests/views_test.views_default.inc | 10 +- .../views/tests/views_translatable.test | 6 +- sites/all/modules/views/tests/views_ui.test | 95 +- .../modules/views/tests/views_upgrade.test | 53 +- sites/all/modules/views/tests/views_view.test | 47 +- sites/all/modules/views/theme/theme.inc | 180 ++- .../modules/views/theme/views-more.tpl.php | 3 +- .../theme/views-ui-display-tab-bucket.tpl.php | 2 +- .../views/theme/views-ui-edit-view.tpl.php | 46 - .../views/theme/views-view-grid.tpl.php | 4 +- .../views/theme/views-view-list.tpl.php | 1 + .../theme/views-view-row-comment.tpl.php | 2 +- .../views-view-summary-unformatted.tpl.php | 2 +- .../views/theme/views-view-summary.tpl.php | 2 +- .../views/theme/views-view-table.tpl.php | 11 +- .../theme/views-view-unformatted.tpl.php | 2 +- .../modules/views/theme/views-view.tpl.php | 2 +- sites/all/modules/views/views.api.php | 324 +++-- sites/all/modules/views/views.info | 10 +- sites/all/modules/views/views.install | 69 +- sites/all/modules/views/views.module | 698 +++++---- sites/all/modules/views/views_ui.info | 7 +- sites/all/modules/views/views_ui.module | 19 +- 469 files changed, 17307 insertions(+), 8396 deletions(-) create mode 100644 sites/all/modules/link/README.txt create mode 100644 sites/all/modules/link/link-rtl.css create mode 100644 sites/all/modules/link/link.devel_generate.inc create mode 100644 sites/all/modules/link/link.diff.inc create mode 100644 sites/all/modules/link/link.migrate.inc create mode 100644 sites/all/modules/link/tests/link.entity_token.test create mode 100644 sites/all/modules/module_filter/css/modules.css create mode 100644 sites/all/modules/module_filter/images/collapsed.png create mode 100644 sites/all/modules/module_filter/images/expanded.png create mode 100644 sites/all/modules/uuid/composer.json create mode 100644 sites/all/modules/uuid/uuid_services/uuid_services.user_services.test create mode 100644 sites/all/modules/views/tests/README.txt create mode 100644 sites/all/modules/views/tests/handlers/views_handler_manytoone.test create mode 100644 sites/all/modules/views/tests/views_clone.test create mode 100644 sites/all/modules/views/tests/views_handler_filter.test delete mode 100644 sites/all/modules/views/theme/views-ui-edit-view.tpl.php diff --git a/sites/all/modules/context/context.core.inc b/sites/all/modules/context/context.core.inc index 41ed93a..9e19831 100644 --- a/sites/all/modules/context/context.core.inc +++ b/sites/all/modules/context/context.core.inc @@ -94,11 +94,27 @@ function context_theme_registry_alter(&$theme_registry) { */ function context_ctools_render_alter($info, $page, $data) { extract($data); - if ($page && in_array($task['name'], array('node_view', 'node_edit'), TRUE)) { - foreach ($contexts as $ctools_context) { - if (in_array('node', $ctools_context->type) && !empty($ctools_context->data)) { - context_node_condition($ctools_context->data, $task['name'] === 'node_view' ? 'view' : 'form'); - break; + + // Check for page handlers. + if ($page) { + // Check for node page handler. + if (in_array($task['name'], array('node_view', 'node_edit'), TRUE)) { + foreach ($contexts as $ctools_context) { + if (in_array('node', $ctools_context->type) && !empty($ctools_context->data)) { + context_node_condition($ctools_context->data, $task['name'] === 'node_view' ? 'view' : 'form'); + break; + } + } + } + // Check for taxonomy term page handler. + elseif (in_array($task['name'], array('term_view', 'term_edit'), TRUE)) { + foreach ($contexts as $ctools_context) { + if (in_array('taxonomy_term', $ctools_context->type) && !empty($ctools_context->data)) { + if ($plugin = context_get_plugin('condition', 'taxonomy_term')) { + $plugin->execute($ctools_context->data, $task['name'] === 'term_view' ? 'view' : 'form'); + } + break; + } } } } diff --git a/sites/all/modules/context/context.info b/sites/all/modules/context/context.info index a980c87..eef3a9c 100644 --- a/sites/all/modules/context/context.info +++ b/sites/all/modules/context/context.info @@ -8,9 +8,8 @@ files[] = tests/context.test files[] = tests/context.conditions.test files[] = tests/context.reactions.test -; Information added by Drupal.org packaging script on 2015-01-06 -version = "7.x-3.6" +; Information added by Drupal.org packaging script on 2019-02-26 +version = "7.x-3.10" core = "7.x" project = "context" -datestamp = "1420573188" - +datestamp = "1551220089" diff --git a/sites/all/modules/context/context.install b/sites/all/modules/context/context.install index 0a5a145..0d902ef 100644 --- a/sites/all/modules/context/context.install +++ b/sites/all/modules/context/context.install @@ -103,7 +103,7 @@ function context_update_7000() { } } if (empty($updated)) { - $ret = t('No contexts requiring migration detected'); + $ret = t('No contexts requiring migration detected.'); } else { $ret = t('The following contexts had theme reaction data migrated: @names', array('@names' => join(', ', $updated))); diff --git a/sites/all/modules/context/context.module b/sites/all/modules/context/context.module index 96808dd..c83b15e 100644 --- a/sites/all/modules/context/context.module +++ b/sites/all/modules/context/context.module @@ -192,11 +192,66 @@ function context_init() { * theme('menu_link') for the menu rendering to html. */ function context_preprocess_menu_link(&$variables) { - if($contexts = context_active_contexts()){ - foreach($contexts as $context){ - if((isset($context->reactions['menu']))){ - if ($variables['element']['#href'] == $context->reactions['menu']) { - $variables['element']['#localized_options']['attributes']['class'][] = "active"; + if ($contexts = context_active_contexts()) { + foreach ($contexts as $context) { + if (isset($context->reactions['menu'])) { + // In context module < v3.2 the url was a string. In version 3.3+ this is + // an array of urls. Implement interims BC layer. + // + // Examples: + // - OLD < v3.2 context reaction structure: + // array('menu' => 'taxonomy/term/1') + // + // - NEW 3.3+ context reaction structure: + // array( + // 'menu' => array( + // 0 => 'navigation:taxonomy/term/1' + // 1 => 'foo-menu:taxonomy/term/1' + // ) + // ) + $reactions_menu = is_array($context->reactions['menu']) ? array_values($context->reactions['menu']) : array($context->reactions['menu']); + + // Get everything after the first ':' character (if found) as the url to + // match against element '#href'. + $urls = array(); + foreach ($reactions_menu as $url) { + if (strpos($url, ':') !== FALSE) { + // Get unique menu name 'navigation' from 'navigation:taxonomy/term/1' + $reaction_menu = explode(':', $url); + $path = $reaction_menu[1]; + $urls[$path] = $reaction_menu[0]; + } + else { + // BC layer for menu contexts that have not re-saved. This is for + // urls like 'taxonomy/term/1'. We need to add a fake menu key + // 'bc-context-menu-layer' or the BC link get's removed by + // array_intersect below. + // + // @TODO: Remove BC layer in 4.x + $urls[$url] = 'context-reaction-menu-bc-layer'; + } + } + + // Filter urls by the menu name of the current link. The link reaction + // can be configured per menu link in specific menus and the contect + // reaction should not applied to other menus with the same menu link. + $menu_name = $variables['element']['#original_link']['menu_name']; + $menu_paths = array_intersect($urls, array($menu_name, 'context-reaction-menu-bc-layer')); + $reaction_menu_paths = array_keys($menu_paths); + + // - If menu href and context reaction menu url match, add the 'active' + // css class to the link of this menu. + // - Do not add class twice on current page. + if (in_array($variables['element']['#href'], $reaction_menu_paths) && $variables['element']['#href'] != $_GET['q']) { + // Initialize classes array if not set. + if (!isset($variables['element']['#localized_options']['attributes']['class'])) { + $variables['element']['#localized_options']['attributes']['class'] = array(); + } + + // Do not add the 'active' class twice in views tabs. + if (!in_array('active', $variables['element']['#localized_options']['attributes']['class'])) { + $variables['element']['#localized_options']['attributes']['class'][] = 'active'; + } } } } diff --git a/sites/all/modules/context/context.plugins.inc b/sites/all/modules/context/context.plugins.inc index a0849bb..95d003d 100644 --- a/sites/all/modules/context/context.plugins.inc +++ b/sites/all/modules/context/context.plugins.inc @@ -37,7 +37,7 @@ function _context_context_registry() { 'plugin' => 'context_condition_path', ), 'query_string' => array( - 'title' => t('Query String'), + 'title' => t('Query string'), 'description' => t('Set this context when any of the query strings above match the page query string. Put each query string on a separate line. You can use the "*" character as a wildcard and ~ to exclude one or more query strings.'), 'plugin' => 'context_condition_query_string', ), @@ -119,7 +119,7 @@ function _context_context_registry() { 'plugin' => 'context_reaction_template_suggestions', ), 'theme' => array( - 'title' => t('Theme Page'), + 'title' => t('Theme page'), 'description' => t('Control page theme variables using context.'), 'plugin' => 'context_reaction_theme', ), diff --git a/sites/all/modules/context/context_layouts/context_layouts.info b/sites/all/modules/context/context_layouts/context_layouts.info index 5ddb2cf..65880e3 100644 --- a/sites/all/modules/context/context_layouts/context_layouts.info +++ b/sites/all/modules/context/context_layouts/context_layouts.info @@ -6,9 +6,8 @@ core = 7.x files[] = plugins/context_layouts_reaction_block.inc -; Information added by Drupal.org packaging script on 2015-01-06 -version = "7.x-3.6" +; Information added by Drupal.org packaging script on 2019-02-26 +version = "7.x-3.10" core = "7.x" project = "context" -datestamp = "1420573188" - +datestamp = "1551220089" diff --git a/sites/all/modules/context/context_ui/context_ui.info b/sites/all/modules/context/context_ui/context_ui.info index 0006699..e5d17f8 100644 --- a/sites/all/modules/context/context_ui/context_ui.info +++ b/sites/all/modules/context/context_ui/context_ui.info @@ -8,9 +8,8 @@ configure = admin/structure/context files[] = context.module files[] = tests/context_ui.test -; Information added by Drupal.org packaging script on 2015-01-06 -version = "7.x-3.6" +; Information added by Drupal.org packaging script on 2019-02-26 +version = "7.x-3.10" core = "7.x" project = "context" -datestamp = "1420573188" - +datestamp = "1551220089" diff --git a/sites/all/modules/context/context_ui/context_ui.js b/sites/all/modules/context/context_ui/context_ui.js index 308164f..56aa62a 100644 --- a/sites/all/modules/context/context_ui/context_ui.js +++ b/sites/all/modules/context/context_ui/context_ui.js @@ -12,11 +12,11 @@ function DrupalContextPlugins(form) { $('.context-plugin-list > li', this.form).each(function() { var plugin = $(this).attr('class').split('context-plugin-')[1].split(' ')[0]; if ($(this).is('.disabled')) { - $('.context-plugin-selector select option[value='+plugin+']', this.form).show(); + $('.context-plugin-selector select option[value="'+plugin+'"]', this.form).show(); } else { state.push(plugin); - $('.context-plugin-selector select option[value='+plugin+']', this.form).hide(); + $('.context-plugin-selector select option[value="'+plugin+'"]', this.form).hide(); } }); // Set the hidden plugin list state. diff --git a/sites/all/modules/context/context_ui/context_ui.module b/sites/all/modules/context/context_ui/context_ui.module index 2ed2aa6..d694870 100644 --- a/sites/all/modules/context/context_ui/context_ui.module +++ b/sites/all/modules/context/context_ui/context_ui.module @@ -81,7 +81,7 @@ function context_ui_permission() { 'description' => 'Associate menus, views, blocks, etc. with different contexts to structure your site.' ); $permissions['context ajax block access'] = array( - 'title' => t('Access All Blocks'), + 'title' => t('Access all blocks'), 'description' => t('Allows users to access all rendered blocks via an AJAX callback. If you have some blocks that should not be rendered for some users but need those users to be able to use context UI, then implement hook_context_allow_ajax_block_access with the necessary logic.'), ); return $permissions; @@ -143,7 +143,7 @@ function context_ui_editor($form, &$form_state, $contexts) { $form['title'] = array( '#prefix' => '

', - '#markup' => t('Select the Context/Layer to Edit'), + '#markup' => t('Select the context/layer to edit'), '#suffix' => '

', '#weight' => -2, ); @@ -151,10 +151,7 @@ function context_ui_editor($form, &$form_state, $contexts) { //add some help text to the top of the form $form['help'] = array ( '#prefix' => '

', - '#markup' => t('Select which context, or layer of blocks, to edit. - Each context is configured to appear on different sets of pages so read the description carefully. - When you are done editing click Done and save your changes. - You may use the Stop Editing Layout link to close the editor.'), + '#markup' => t('Select which context, or layer of blocks, to edit. Each context is configured to appear on different sets of pages so read the description carefully. When you are done editing click Done and save your changes. You may use the Stop Editing Layout link to close the editor.'), '#suffix' => '

', '#weight' => -1, ); @@ -166,10 +163,9 @@ function context_ui_editor($form, &$form_state, $contexts) { $edit = l(t('Edit'), $_GET['q'], array('fragment' => $context->name, 'attributes' => array('class' => array('edit')))); $done = l(t('Done'), $_GET['q'], array('fragment' => $context->name, 'attributes' => array('class' => array('done')))); $readable_name = ucwords(str_replace('_', ' ', $context->name)); - $description = empty($context->description) ? '' : - "
".check_plain($context->description)."
"; + $description = empty($context->description) ? '' : '
' . check_plain($context->description) . '
'; $items[] = array( - 'data' => "
" . $readable_name. "
" . $description, + 'data' => '
' . $readable_name. "
" . $description, 'class' => array('context-editable clearfix'), 'id' => "context-editable-trigger-{$context->name}", ); @@ -306,9 +302,9 @@ function context_ui_settings($form, &$form_state) { } $form['context_ui_dialog_enabled'] = array( '#type' => 'checkbox', - '#title' => t('Use Context Editor Dialog'), + '#title' => t('Use context editor dialog'), '#default_value' => context_ui_dialog_is_enabled(), - '#description' => t('When enabled all contextual links will have a Edit Layout link that will refresh the page with the context editor in a dialog box.'), + '#description' => t('When enabled all contextual links will have a Edit layout link that will refresh the page with the context editor in a dialog box.'), ); $form = system_settings_form($form); $form['#submit'][] = 'context_ui_settings_submit'; @@ -374,7 +370,7 @@ function context_ui_menu_contextual_links_alter(&$links, $router_item, $root_pat !context_isset('context_ui', 'context_ui_editor_present') && user_access('administer contexts')) { $links['layout'] = array( 'href' => 'context-ui/activate', - 'title' => t('Configure Layout'), + 'title' => t('Configure layout'), 'localized_options' => array( 'query' => array('destination'=> $_GET['q']), 'options' => array('html' => FALSE, 'attributes' => array()), diff --git a/sites/all/modules/context/context_ui/context_ui_dialog.js b/sites/all/modules/context/context_ui/context_ui_dialog.js index dc73f91..1dfc4f8 100644 --- a/sites/all/modules/context/context_ui/context_ui_dialog.js +++ b/sites/all/modules/context/context_ui/context_ui_dialog.js @@ -9,11 +9,11 @@ selector.detach(); $('#page').prepend(selector); - var labelOpen = Drupal.t('Select Context'); + var labelOpen = Drupal.t('Select context'); var labelClose = Drupal.t('Hide'); // Create a tab to show/hide our edit area - var tab = $(''+labelClose+''); + var tab = $(''+labelClose+''); selector.append(tab); selector.toggled = false; diff --git a/sites/all/modules/context/context_ui/export_ui/context_export_ui.class.php b/sites/all/modules/context/context_ui/export_ui/context_export_ui.class.php index db5cf86..a6c9f79 100644 --- a/sites/all/modules/context/context_ui/export_ui/context_export_ui.class.php +++ b/sites/all/modules/context/context_ui/export_ui/context_export_ui.class.php @@ -22,7 +22,7 @@ class context_export_ui extends ctools_export_ui { function list_render(&$form_state) { $table = array( 'header' => $this->list_table_header(), - 'rows' => $this->rows, + 'rows' => $this->rows, 'attributes' => array( 'class' => array('context-admin'), 'id' => 'ctools-export-ui-list-items', @@ -104,17 +104,17 @@ class context_export_ui extends ctools_export_ui { * @param $form_state * Form state array */ -function context_ui_form(&$form, &$form_state) { +function context_ui_form(&$form, &$form_state) { $conditions = array_keys(context_conditions()); sort($conditions); $reactions = array_keys(context_reactions()); sort($reactions); - + $context = $form_state['item']; if (!empty($form_state['input'])) { $context = _context_ui_rebuild_from_input($context, $form_state['input'], $conditions, $reactions); } - + $form['#base'] = 'context_ui_form'; $form['#theme'] = 'context_ui_form'; @@ -131,7 +131,7 @@ function context_ui_form(&$form, &$form_state) { '#required' => FALSE, '#maxlength' => 255, '#default_value' => isset($context->tag) ? $context->tag : '', - '#description' => t('Example: theme') .'
'. t('A tag to group this context with others.'), + '#description' => t('Example: theme') . '
' . t('A tag to group this context with others.'), ); $form['info']['description'] = array( @@ -155,11 +155,11 @@ function context_ui_form(&$form, &$form_state) { $form['conditions'] = array( '#theme' => 'context_ui_plugins', '#title' => t('Conditions'), - '#description' => t('Trigger the activation of this context'), + '#description' => t('Trigger the activation of this context.'), '#tree' => TRUE, 'selector' => array( '#type' => 'select', - '#options' => array(0 => '<'. t('Add a condition') .'>'), + '#options' => array(0 => '<' . t('Add a condition') . '>'), '#default_value' => 0, ), 'state' => array( @@ -185,11 +185,11 @@ function context_ui_form(&$form, &$form_state) { $form['reactions'] = array( '#theme' => 'context_ui_plugins', '#title' => t('Reactions'), - '#description' => t('Actions to take when this context is active'), + '#description' => t('Actions to take when this context is active.'), '#tree' => TRUE, 'selector' => array( '#type' => 'select', - '#options' => array(0 => '<'. t('Add a reaction') .'>'), + '#options' => array(0 => '<' . t('Add a reaction') . '>'), '#default_value' => 0, ), 'state' => array( @@ -225,7 +225,7 @@ function context_ui_form(&$form, &$form_state) { * A context object */ function _context_ui_rebuild_from_input($context, $input, $conditions, $reactions) { - $condition_defaults = array(); + $condition_defaults = array(); foreach ($conditions as $condition) { if ($plugin = context_get_plugin('condition', $condition)) { $condition_defaults[$condition] = array( @@ -235,7 +235,7 @@ function _context_ui_rebuild_from_input($context, $input, $conditions, $reaction } } $input['conditions']['plugins'] = array_merge($condition_defaults, $input['conditions']['plugins']); - + $reaction_defaults = array(); foreach ($reactions as $reaction) { if ($plugin = context_get_plugin('reaction', $reaction)) { diff --git a/sites/all/modules/context/context_ui/tests/context_ui.test b/sites/all/modules/context/context_ui/tests/context_ui.test index 06c7a5e..76ae7d5 100644 --- a/sites/all/modules/context/context_ui/tests/context_ui.test +++ b/sites/all/modules/context/context_ui/tests/context_ui.test @@ -48,7 +48,7 @@ class ContextUiTestCase extends DrupalWebTestCase { 'description' => $context->description, 'tag' => $context->tag, 'conditions[plugins][node][values][blog]' => 'blog', - 'reactions[plugins][menu]' => 'node/add/blog', + 'reactions[plugins][menu][]' => 'navigation:node/add/blog', ); $this->drupalPost('admin/structure/context/add', $edit, 'Save'); $this->assertText($context->name . ' has been created.', 'Context saved.'); diff --git a/sites/all/modules/context/plugins/context_condition_bookroot.inc b/sites/all/modules/context/plugins/context_condition_bookroot.inc index 200326c..778b826 100644 --- a/sites/all/modules/context/plugins/context_condition_bookroot.inc +++ b/sites/all/modules/context/plugins/context_condition_bookroot.inc @@ -8,7 +8,7 @@ class context_condition_bookroot extends context_condition_node { if ($this->condition_used() && !empty($node->book['bid'])) { $type = db_select('node') ->fields('node', array('type')) - ->condition('nid', $node->book['nid']) + ->condition('nid', $node->book['bid']) ->execute() ->fetchField(); $book = new stdClass(); diff --git a/sites/all/modules/context/plugins/context_condition_menu.inc b/sites/all/modules/context/plugins/context_condition_menu.inc index 0df8811..4b19e02 100644 --- a/sites/all/modules/context/plugins/context_condition_menu.inc +++ b/sites/all/modules/context/plugins/context_condition_menu.inc @@ -14,7 +14,7 @@ class context_condition_menu extends context_condition { foreach ($menus as $key => $name) { $id = explode(':', $key); if ($id[1] == '0') { - $root_menus[$id[0]] = check_plain($name); + $root_menus[$id[0]] = $name; } else { $link = menu_link_load($id[1]); diff --git a/sites/all/modules/context/plugins/context_condition_node_taxonomy.inc b/sites/all/modules/context/plugins/context_condition_node_taxonomy.inc index cfb214f..00905aa 100644 --- a/sites/all/modules/context/plugins/context_condition_node_taxonomy.inc +++ b/sites/all/modules/context/plugins/context_condition_node_taxonomy.inc @@ -45,24 +45,28 @@ class context_condition_node_taxonomy extends context_condition_node { $check_fields = array(); foreach ($instance_fields as $key => $field_info) { if ($fields[$key]['type'] == 'taxonomy_term_reference') { - $check_fields[] = $key; + $check_fields[$key] = 'tid'; + } + else if ($fields[$key]['type'] == 'entityreference' && + $fields[$key]['settings']['target_type'] == 'taxonomy_term') { + $check_fields[$key] = 'target_id'; } } if ($this->condition_used() && !empty($check_fields)) { - foreach ($check_fields as $field) { + foreach ($check_fields as $field => $term_id_key) { if ($terms = field_get_items('node', $node, $field)) { foreach ($terms as $term) { - foreach ($this->get_contexts($term['tid']) as $context) { + foreach ($this->get_contexts($term[$term_id_key]) as $context) { // Check the node form option. if ($op === 'form') { $options = $this->fetch_from_context($context, 'options'); if (!empty($options['node_form'])) { - $this->condition_met($context, $term['tid']); + $this->condition_met($context, $term[$term_id_key]); } } else { - $this->condition_met($context, $term['tid']); + $this->condition_met($context, $term[$term_id_key]); } } } diff --git a/sites/all/modules/context/plugins/context_condition_query_string.inc b/sites/all/modules/context/plugins/context_condition_query_string.inc index 781d4cb..b7bf5d5 100644 --- a/sites/all/modules/context/plugins/context_condition_query_string.inc +++ b/sites/all/modules/context/plugins/context_condition_query_string.inc @@ -16,7 +16,7 @@ class context_condition_query_string extends context_condition_path { */ function execute() { if ($this->condition_used()) { - $current_query_string = $_SERVER["QUERY_STRING"]; + $current_query_string = empty($_SERVER["QUERY_STRING"]) ? '' : $_SERVER["QUERY_STRING"]; foreach ($this->get_contexts() as $context) { $query_strings = $this->fetch_from_context($context, 'values'); if ($this->match($current_query_string, $query_strings, TRUE)) { diff --git a/sites/all/modules/context/plugins/context_reaction_block.inc b/sites/all/modules/context/plugins/context_reaction_block.inc index abcafd8..90c005c 100644 --- a/sites/all/modules/context/plugins/context_reaction_block.inc +++ b/sites/all/modules/context/plugins/context_reaction_block.inc @@ -400,13 +400,17 @@ class context_reaction_block extends context_reaction { unset($_context_blocks); foreach ($context_blocks as $r => $blocks) { - //only render blocks in an active region + // Only render blocks in an active region. if (array_key_exists($r, $active_regions)) { $context_blocks[$r] = _block_render_blocks($blocks); - // Make blocks editable if allowed. - if ($this->is_editable_region($r)) { - foreach ($context_blocks[$r] as $key => $block) { + $editable = $this->is_editable_region($r); + foreach ($context_blocks[$r] as $key => $block) { + // Add the region property to each block. + $context_blocks[$r][$key]->region = $r; + + // Make blocks editable if allowed. + if ($editable) { $context_blocks[$r][$key] = $this->editable_block($block); } } @@ -450,12 +454,9 @@ class context_reaction_block extends context_reaction { */ protected function max_block_weight() { $blocks = $this->get_blocks(); - $block_count = 0; - foreach ($blocks as $region => $block_list) { - $block_count += count($block_list); - } - // Add 2 to make sure there's space at either end of the block list - return round(($block_count + 2) / 2); + + // Add 2 to make sure there's space at either end of the block list. + return round((count($blocks) + 2) / 2); } /** diff --git a/sites/all/modules/context/plugins/context_reaction_block.js b/sites/all/modules/context/plugins/context_reaction_block.js index 10e25a2..192b956 100644 --- a/sites/all/modules/context/plugins/context_reaction_block.js +++ b/sites/all/modules/context/plugins/context_reaction_block.js @@ -68,8 +68,8 @@ DrupalContextBlockForm = function(blockForm) { // Hide enabled blocks from selector that are used $('table.context-blockform-region tr').each(function() { - var bid = $(this).attr('id'); - $('div.context-blockform-selector input[value='+bid+']').parents('div.form-item').eq(0).hide(); + var bid = Drupal.checkPlain($(this).attr('id')); + $('div.context-blockform-selector input[value="'+bid+'"]').parents('div.form-item').eq(0).hide(); }); // Show blocks in selector that are unused $('div.context-blockform-selector input').each(function() { @@ -159,7 +159,7 @@ DrupalContextBlockForm = function(blockForm) { $(this).removeAttr('checked'); }); if (weight_warn) { - alert(Drupal.t('Desired block weight exceeds available weight options, please check weights for blocks before saving')); + alert(Drupal.t('Desired block weight exceeds available weight options, please check weights for blocks before saving.')); } } return false; @@ -426,9 +426,8 @@ DrupalContextBlockEditor.prototype = { $('.editing-context-label').remove(); var label = $('#context-editable-trigger-'+context+' .label').text(); - label = Drupal.t('Now Editing: ') + label; - editor.parent().parent() - .prepend('
'+ label + '
'); + label = Drupal.t('Now editing: @label', {'@label': label}); + editor.parent().parent().prepend('
' + label + '
'); // First pass, enable sortables on all regions. $(this.regions).each(function() { diff --git a/sites/all/modules/context/plugins/context_reaction_breadcrumb.inc b/sites/all/modules/context/plugins/context_reaction_breadcrumb.inc index 66d121c..e6ce6fd 100644 --- a/sites/all/modules/context/plugins/context_reaction_breadcrumb.inc +++ b/sites/all/modules/context/plugins/context_reaction_breadcrumb.inc @@ -8,6 +8,7 @@ class context_reaction_breadcrumb extends context_reaction_menu { * Overrides set_active_trail_from_link to set the breadcrumb instead of the menu path. */ function set_active_trail_from_link($item) { + $breadcrumb = array(l(t('Home'), '')); $result = db_select('menu_links') ->fields('menu_links', array('p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8')) ->condition('hidden', 0) diff --git a/sites/all/modules/context/plugins/context_reaction_menu.inc b/sites/all/modules/context/plugins/context_reaction_menu.inc index 0d82adc..4f0e54c 100644 --- a/sites/all/modules/context/plugins/context_reaction_menu.inc +++ b/sites/all/modules/context/plugins/context_reaction_menu.inc @@ -22,19 +22,21 @@ class context_reaction_menu extends context_reaction { $link = menu_link_load($mlid); $identifier = $link['link_path']; $root_menu = $menu_names[$menu_name]; - while (isset($options[$root_menu][$identifier])) { + while (isset($options[$root_menu][$menu_name . ':' . $identifier])) { $identifier .= "'"; } $options[$root_menu][$menu_name . ':' . $identifier] = $title; } } } + $menu_count = count($options, COUNT_RECURSIVE); return array( '#title' => $this->title, '#description' => $this->description, '#options' => $options, '#type' => 'select', '#multiple' => TRUE, + '#size' => $menu_count > 20 ? 20 : $menu_count, '#default_value' => $this->fetch_from_context($context), ); } diff --git a/sites/all/modules/context/plugins/context_reaction_region.inc b/sites/all/modules/context/plugins/context_reaction_region.inc index c4f0fd7..d9c0a8e 100644 --- a/sites/all/modules/context/plugins/context_reaction_region.inc +++ b/sites/all/modules/context/plugins/context_reaction_region.inc @@ -17,7 +17,7 @@ class context_reaction_region extends context_reaction { '#type' => 'fieldset', '#title' => "Disable Regions in {$theme->name} Theme", '#collapsible' => TRUE, - '#collapsed' => !array_reduce($default, create_function('$a, $b', 'return $a || $b;')), + '#collapsed' => !array_reduce($default, 'context_reaction_region::collapseRegion'), ); $form[$theme->name]['disable'] = array( '#type' => 'checkboxes', @@ -29,6 +29,10 @@ class context_reaction_region extends context_reaction { } return $form; } + + function collapseRegion($a, $b) { + return $a || $b; + } function execute(&$page) { global $theme; diff --git a/sites/all/modules/context/plugins/context_reaction_template_suggestions.inc b/sites/all/modules/context/plugins/context_reaction_template_suggestions.inc index 0376f0a..03a7ba6 100644 --- a/sites/all/modules/context/plugins/context_reaction_template_suggestions.inc +++ b/sites/all/modules/context/plugins/context_reaction_template_suggestions.inc @@ -14,7 +14,7 @@ class context_reaction_template_suggestions extends context_reaction { return array( '#title' => t('Template suggestions'), '#type' => 'textarea', - '#description' => t('Enter template suggestions such as "page__front", one per line, in order of preference (using underscores instead of hyphens). For more information, please visit ') . l(t('Drupal 7 Template (Theme Hook) Suggestions'), 'http://drupal.org/node/1089656', array(array('target' => '_blank'), 'html' => TRUE,)) . '.', + '#description' => t('Enter template suggestions such as "page__front", one per line, in order of preference (using underscores instead of hyphens). For more information, please visit Drupal 7 Template (Theme Hook) Suggestions.', array('@template-suggestions' => 'http://drupal.org/node/1089656')), '#default_value' => is_string($default_value) ? $default_value : '', ); } diff --git a/sites/all/modules/context/tests/context.conditions.test b/sites/all/modules/context/tests/context.conditions.test index e2cee73..a55276b 100644 --- a/sites/all/modules/context/tests/context.conditions.test +++ b/sites/all/modules/context/tests/context.conditions.test @@ -36,13 +36,6 @@ class ContextConditionUserTest extends DrupalWebTestCase { $this->assertTrue($saved, "Context 'testcontext' saved."); } - function tearDown() { - parent::tearDown(); - context_delete($this->context); - user_delete($this->user1->uid); - user_delete($this->user2->uid); - } - function test() { // User 1 triggers the context. $this->drupalLogin($this->user1); @@ -82,14 +75,6 @@ class ContextConditionUserPageTest extends DrupalWebTestCase { $this->assertTrue($saved, "Context 'testcontext' saved."); } - function tearDown() { - parent::tearDown(); - context_delete($this->context); - $edit = array(); - user_delete($this->user1->uid); - user_delete($this->user2->uid); - } - function test() { // Viewing any user profile triggers context. $this->drupalLogin($this->user1); @@ -157,13 +142,6 @@ class ContextConditionNodeTaxonomyTest extends DrupalWebTestCase { $this->assertTrue($saved, "Context 'testcontext' saved."); } - function tearDown() { - parent::tearDown(); - context_delete($this->context); - taxonomy_term_delete($this->terms['apples']->tid); - taxonomy_term_delete($this->terms['oranges']->tid); - } - function test() { // Apples does trigger the context. $edit = array( diff --git a/sites/all/modules/context/theme/context_reaction_block.theme.inc b/sites/all/modules/context/theme/context_reaction_block.theme.inc index 4f538bc..e5fe9de 100644 --- a/sites/all/modules/context/theme/context_reaction_block.theme.inc +++ b/sites/all/modules/context/theme/context_reaction_block.theme.inc @@ -52,7 +52,7 @@ function theme_context_block_regions_form($vars) { $output .= "
"; $output .= l(t('+') . ' ' . t('Add'), $_GET['q'], array('fragment' => $region, 'attributes' => array('class' => array('add-block')))); $output .= $form[$region]['#title']; - $output .= "
"; + $output .= ''; $output .= theme('table', array('rows' => $rows, 'attributes' => $attr)); } return $output; @@ -100,14 +100,13 @@ function template_preprocess_context_block_browser(&$vars) { //add help text to tell people how to use the block browser $help_text = array( '#prefix' => '
', - '#markup' => t('To add a block to the current region, simply click on the block. You may use the category filter to filter by - block type or the search filter to find the block that you wish to add.'), + '#markup' => t('To add a block to the current region, simply click on the block. You may use the category filter to filter by block type or the search filter to find the block that you wish to add.'), '#suffix' => '
', ); $filter_label = array( '#prefix' => '
', - '#markup' => t('Search Filter'), + '#markup' => t('Search filter'), '#suffix' => '
', ); diff --git a/sites/all/modules/link/README.txt b/sites/all/modules/link/README.txt new file mode 100644 index 0000000..a258d4d --- /dev/null +++ b/sites/all/modules/link/README.txt @@ -0,0 +1,101 @@ +CONTENTS OF THIS FILE +--------------------- + + * Introduction + * Requirements + * Installation + * Configuration + * Example + * Theming and Output + * Maintainers + + +INTRODUCTION +------------ + +The link can be count to the top 50 projects in Drupal installations and +provides a standard custom content field for links. With this module links can +be added easily to any content types and profiles and include advanced +validating and different ways of storing internal or external links and URLs. It +also supports additional link text title, site wide tokens for titles and title +attributes, target attributes, css class attribution, static repeating values, +input conversion, and many more. + + + +REQUIREMENTS +------------ + +Project in Drupal 7 requires the following modules: + + * Fields API (Fields API is provided already by core) + * Panels (https://drupal.org/project/panels) + +Drupal 8: + + * Link is in core now. No installation needed. Yay! Don't forget to activate + it. It's deactivated by default. + + +INSTALLATION +------------ + +Install as you would normally install a contributed Drupal module. See: +https://drupal.org/documentation/install/modules-themes/modules-7 for further +information. + + +CONFIGURATION +------------- + + * Configuration is only slightly more complicated than a text field. Link text + titles for URLs can be made required, set as instead of URL, optional + (default), or left out entirely. If no link text title is provided, the + trimmed version of the complete URL will be displayed. The target attribute + should be set to "_blank", "top", or left out completely (checkboxes provide + info). The rel=nofollow attribute prevents the link from being followed by + certain search engines. More info at Wikipedia + (http://en.wikipedia.org/wiki/Spam_in_blogs#rel.3D.22nofollow.22). + + +EXAMPLE +------- +If you were to create a field named 'My New Link', the default display of the +link would be: + where items between [] characters would be customized +based on the user input. + +The link project supports both, internal and external URLs. URLs are validated +on input. Here are some examples of data input and the default view of a link: +http://drupal.org results in http://drupal.org, but drupal.org results in +http://drupal.org, while will convert into http://drupal.org and +node/74971 into http://drupal.org/project/link + +Anchors and query strings may also be used in any of these cases, including: +node/74971/edit?destination=node/74972#pager + + +THEMING AND OUTPUT +------------------ +Since link module is mainly a data storage field in a modular framework, the +theming and output is up to the site builder and other additional modules. There +are many modules in the Drupal repository, which control the output of fields +perfectly and can handle rules, user actions, markup dependencies, and can vary +the output under many different conditions, with much more efficience and +flexibility for different scenarios. Please check out modules like views, +display suite, panels, etc for such needs + + +MAINTAINERS +----------- + +Current maintainers: + * John C Fiala (jcfiala) - https://www.drupal.org/user/163643 + * Renato Gonçalves (RenatoG) - https://www.drupal.org/user/3326031 + * Clemens Tolboom (clemens.tolboom) - https://www.drupal.org/user/125814 + * diqidoq - https://www.drupal.org/user/1001934 + * dropcube - https://www.drupal.org/user/37031 + * Tom Kirkpatrick (mrfelton) - https://www.drupal.org/user/305669 + * Sumit Madan (sumitmadan) - https://www.drupal.org/user/1538790 + * Daniel Kudwien (sun) - https://www.drupal.org/user/54136 diff --git a/sites/all/modules/link/link-rtl.css b/sites/all/modules/link/link-rtl.css new file mode 100644 index 0000000..613db5d --- /dev/null +++ b/sites/all/modules/link/link-rtl.css @@ -0,0 +1,7 @@ +.link-field-column { + float: right; +} +.link-field-column.link-field-url .form-text { + direction: ltr; + text-align: left; +} diff --git a/sites/all/modules/link/link.css b/sites/all/modules/link/link.css index 7bdec9e..6250df7 100644 --- a/sites/all/modules/link/link.css +++ b/sites/all/modules/link/link.css @@ -1,8 +1,7 @@ -div.link-field-column { +.link-field-column { float: left; width: 48%; } - -div.link-field-column .form-text { +.link-field-column .form-text { width: 95%; } diff --git a/sites/all/modules/link/link.devel_generate.inc b/sites/all/modules/link/link.devel_generate.inc new file mode 100644 index 0000000..af0e2d5 --- /dev/null +++ b/sites/all/modules/link/link.devel_generate.inc @@ -0,0 +1,32 @@ + url('', array('absolute' => TRUE)), + 'attributes' => _link_default_attributes(), + ); + if ($instance['settings']['title'] != 'none') { + $link['title'] = devel_create_greeking(mt_rand(1, 3), TRUE); + } + return $link; +} diff --git a/sites/all/modules/link/link.diff.inc b/sites/all/modules/link/link.diff.inc new file mode 100644 index 0000000..b01ba6e --- /dev/null +++ b/sites/all/modules/link/link.diff.inc @@ -0,0 +1,22 @@ + $item) { + if ($item['url'] && isset($item['title'])) { + $diff_items[$delta] = $item['title'] . ' (' . $item['url'] . ')'; + } + else { + $diff_items[$delta] = $item['url']; + } + } + return $diff_items; +} diff --git a/sites/all/modules/link/link.info b/sites/all/modules/link/link.info index 8a5d0c1..351e178 100644 --- a/sites/all/modules/link/link.info +++ b/sites/all/modules/link/link.info @@ -3,23 +3,23 @@ description = Defines simple link field types. core = 7.x package = Fields -files[] = link.module -files[] = link.install +files[] = link.migrate.inc + ; Tests files[] = tests/link.test files[] = tests/link.attribute.test files[] = tests/link.crud.test files[] = tests/link.crud_browser.test files[] = tests/link.token.test +files[] = tests/link.entity_token.test files[] = tests/link.validate.test ; Views Handlers files[] = views/link_views_handler_argument_target.inc files[] = views/link_views_handler_filter_protocol.inc -; Information added by drupal.org packaging script on 2011-10-23 -version = "7.x-1.0" +; Information added by Drupal.org packaging script on 2019-02-20 +version = "7.x-1.6" core = "7.x" project = "link" -datestamp = "1319392535" - +datestamp = "1550680687" diff --git a/sites/all/modules/link/link.install b/sites/all/modules/link/link.install index fdfc5d1..8125b69 100644 --- a/sites/all/modules/link/link.install +++ b/sites/all/modules/link/link.install @@ -6,10 +6,38 @@ */ /** - * Upgrade notes: - * Things we need to make sure work when upgrading from Drupal 6 to Drupal 7: + * Upgrade notes. + * + * Things we need to make sure work when upgrading from Drupal 6 to Drupal 7:. */ +/** + * Implements hook_uninstall(). + */ +function link_install() { + // Notify the user they may want to install token. + if (!module_exists('token')) { + $t = get_t(); + drupal_set_message($t('If you install the Token, static title can use any other entity field as its value.', array( + '!url' => 'http://drupal.org/project/token', + ))); + } +} + +/** + * Removes unused link_extra_domains variable. + */ +function link_update_7002() { + variable_del('link_extra_domains'); +} + +/** + * Implements hook_uninstall(). + */ +function link_uninstall() { + variable_del('link_allowed_domains'); +} + /** * Implements hook_field_schema(). */ @@ -18,20 +46,21 @@ function link_field_schema($field) { 'columns' => array( 'url' => array( 'type' => 'varchar', - 'length' => 2048, // Maximum URLs length. + // Maximum URLs length. + 'length' => 2048, 'not null' => FALSE, - 'sortable' => TRUE + 'sortable' => TRUE, ), 'title' => array( 'type' => 'varchar', 'length' => 255, 'not null' => FALSE, - 'sortable' => TRUE + 'sortable' => TRUE, ), 'attributes' => array( 'type' => 'text', 'size' => 'medium', - 'not null' => FALSE + 'not null' => FALSE, ), ), ); @@ -45,19 +74,21 @@ function link_update_last_removed() { } /** - * Handles moving settings data from field_config.data to field_config_instance.data. + * Implements hook_update_N(). + * + * Handles moving settings data from field_config.data to + * field_config_instance.data. */ function link_update_7000() { - - // For each field that is a link field, we need to copy the settings from the general field level down to the instance. - //$field_data = array(); + + // For each field that is a link field, we need to copy the settings from the + // general field level down to the instance. $result = db_query("SELECT id, field_name, data FROM {field_config} WHERE module = 'link' AND type = 'link_field'"); foreach ($result as $field) { - $field_id = $field->id; - $name = $field->field_name; + $field_data = unserialize($field->data); - - $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field_id)); + + $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field->id)); foreach ($instances as $instance) { // If this field has been updated already, we want to skip it. $instance_data = unserialize($instance->data); @@ -70,8 +101,8 @@ function link_update_7000() { } } if ($update_instance) { - // update the database. - $num_updated = db_update('field_config_instance') + // Update the database. + db_update('field_config_instance') ->fields(array('data' => serialize($instance_data))) ->condition('id', $instance->id) ->execute(); @@ -79,36 +110,31 @@ function link_update_7000() { } } } - + return t("Instance settings have been set with the data from the field settings."); } /** - * Renames all displays from foobar to link_foobar + * Renames all displays from foobar to link_foobar. */ function link_update_7001() { - // for each field that is a link field, we need to update the display types: - + // Update the display type for each link field type. $result = db_query("SELECT id, field_name, data FROM {field_config} WHERE module = 'link' AND type = 'link_field'"); foreach ($result as $field) { - $field_id = $field->id; - $name = $field->field_name; - $field_data = unserialize($field->data); - - $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field_id)); + + $instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field->id)); foreach ($instances as $instance) { // If this field has been updated already, we want to skip it. $instance_data = unserialize($instance->data); $update_instance = FALSE; foreach ($instance_data['display'] as $display_name => $display_data) { if ($display_data['type'] && (0 !== strpos($display_data['type'], 'link_'))) { - $instance_data['display'][$display_name]['type'] = 'link_'. $display_data['type']; + $instance_data['display'][$display_name]['type'] = 'link_' . $display_data['type']; $update_instance = TRUE; } } if ($update_instance) { - // update the database. - $num_updated = db_update('field_config_instance') + db_update('field_config_instance') ->fields(array('data' => serialize($instance_data))) ->condition('id', $instance->id) ->execute(); diff --git a/sites/all/modules/link/link.migrate.inc b/sites/all/modules/link/link.migrate.inc new file mode 100644 index 0000000..4900051 --- /dev/null +++ b/sites/all/modules/link/link.migrate.inc @@ -0,0 +1,139 @@ +addFieldMapping('field_my_link', 'source_url'); + * $this->addFieldMapping('field_my_link:title', 'source_title'); + * $this->addFieldMapping('field_my_link:attributes', 'source_attributes'); + * + * # With earlier versions of Migrate, you must pass an arguments array: + * + * $link_args = array( + * 'title' => array('source_field' => 'source_title'), + * 'attributes' => array('source_field' => 'source_attributes'), + * ); + * $this->addFieldMapping('field_my_link', 'source_url') + * ->arguments($link_args); + * @endcode + */ + +if (!class_exists('MigrateFieldHandler')) { + return; +} + +/** + * Implements hook_migrate_api(). + */ +function link_migrate_api() { + return array( + 'api' => 2, + 'field handlers' => array('MigrateLinkFieldHandler'), + ); +} + +// @codingStandardsIgnoreLine +class MigrateLinkFieldHandler extends MigrateFieldHandler { + + /** + * Construct. + */ + public function __construct() { + $this->registerTypes(array('link_field')); + } + + /** + * Arguments. + */ + public static function arguments($title = NULL, $attributes = NULL, $language = NULL) { + $arguments = array(); + if (!is_null($title)) { + $arguments['title'] = $title; + } + if (!is_null($attributes)) { + $arguments['attributes'] = $attributes; + } + if (!is_null($language)) { + $arguments['language'] = $language; + } + return $arguments; + } + + /** + * Implementation of MigrateFieldHandler::fields(). + * + * @param array $type + * The field type. + * @param array $instance + * Instance info for the field. + * @param Migration $migration + * The migration context for the parent field. We can look at the mappings + * and determine which subfields are relevant. + * + * @return array + * Array with values. + * + * @codingStandardsIgnoreStart + */ + public function fields($type, $instance, $migration = NULL) { + // @codingStandardsIgnoreEnd + return array( + 'title' => t('Subfield: The link title attribute'), + 'attributes' => t('Subfield: The attributes for this link'), + 'language' => t('Subfield: The language for the field'), + ); + } + + /** + * Prepare. + */ + public function prepare($entity, array $field_info, array $instance, array $values) { + if (isset($values['arguments'])) { + $arguments = $values['arguments']; + unset($values['arguments']); + } + else { + $arguments = array(); + } + + $language = $this->getFieldLanguage($entity, $field_info, $arguments); + $values = array_filter($values); + + foreach ($values as $delta => $value) { + $item = array(); + if (isset($arguments['title'])) { + if (!is_array($arguments['title'])) { + $item['title'] = $arguments['title']; + } + elseif (isset($arguments['title'][$delta])) { + $item['title'] = $arguments['title'][$delta]; + } + } + if (isset($arguments['attributes'])) { + if (is_array($arguments['attributes']) && isset($arguments['attributes'][$delta])) { + $item['attributes'] = $arguments['attributes'][$delta]; + } + else { + $item['attributes'] = $arguments['attributes']; + } + } + $item['url'] = $value; + + if (is_array($language)) { + $current_language = $language[$delta]; + } + else { + $current_language = $language; + } + $return[$current_language][$delta] = $item; + } + + return isset($return) ? $return : NULL; + } + +} diff --git a/sites/all/modules/link/link.module b/sites/all/modules/link/link.module index c7af1ff..8b3094f 100644 --- a/sites/all/modules/link/link.module +++ b/sites/all/modules/link/link.module @@ -10,8 +10,6 @@ define('LINK_INTERNAL', 'internal'); define('LINK_FRONT', 'front'); define('LINK_EMAIL', 'email'); define('LINK_NEWS', 'news'); -define('LINK_DOMAINS', 'aero|arpa|asia|biz|com|cat|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|mobi|local'); - define('LINK_TARGET_DEFAULT', 'default'); define('LINK_TARGET_NEW_WINDOW', '_blank'); define('LINK_TARGET_TOP', '_top'); @@ -22,6 +20,22 @@ define('LINK_TARGET_USER', 'user'); */ define('LINK_URL_MAX_LENGTH', 2048); +/** + * Implements hook_help(). + */ +function link_help($path, $arg) { + switch ($path) { + case 'admin/help#link': + $output = '

About

'; + $output .= '

' . 'The link provides a standard custom content field for links. Links can be easily added to any content types and profiles and include advanced validating and different ways of storing internal or external links and URLs. It also supports additional link text title, site wide tokens for titles and title attributes, target attributes, css class attribution, static repeating values, input conversion, and many more.' . '

'; + $output .= '

' . 'Requirements / Dependencies' . '

'; + $output .= '

' . 'Fields API is provided already by core [no dependencies].' . '

'; + $output .= '

Configuration

'; + $output .= '

' . 'Configuration is only slightly more complicated than a text field. Link text titles for URLs can be made required, set as instead of URL, optional (default), or left out entirely. If no link text title is provided, the trimmed version of the complete URL will be displayed. The target attribute should be set to "_blank", "top", or left out completely (checkboxes provide info). The rel=nofollow attribute prevents the link from being followed by certain search engines.' . '

'; + return $output; + } +} + /** * Implements hook_field_info(). */ @@ -35,7 +49,7 @@ function link_field_info() { 'url' => 0, 'title' => 'optional', 'title_value' => '', - 'title_maxlength' => 128, //patch #1307788 from nmc + 'title_maxlength' => 128, 'enable_tokens' => 1, 'display' => array( 'url_cutoff' => 80, @@ -46,12 +60,14 @@ function link_field_info() { 'url' => 0, 'title' => 'optional', 'title_value' => '', - 'title_maxlength' => 128, // patch #1307788 from nmc + 'title_label_use_field_label' => FALSE, + 'title_maxlength' => 128, 'enable_tokens' => 1, 'display' => array( 'url_cutoff' => 80, ), 'validate_url' => 1, + 'absolute_url' => 1, ), 'default_widget' => 'link_field', 'default_formatter' => 'link_default', @@ -69,7 +85,14 @@ function link_field_instance_settings_form($field, $instance) { $form = array( '#element_validate' => array('link_field_settings_form_validate'), ); - + + $form['absolute_url'] = array( + '#type' => 'checkbox', + '#title' => t('Absolute URL'), + '#default_value' => isset($instance['settings']['absolute_url']) && ($instance['settings']['absolute_url'] !== '') ? $instance['settings']['absolute_url'] : TRUE, + '#description' => t('If checked, the URL will always render as an absolute URL.'), + ); + $form['validate_url'] = array( '#type' => 'checkbox', '#title' => t('Validate URL'), @@ -89,6 +112,7 @@ function link_field_instance_settings_form($field, $instance) { 'optional' => t('Optional Title'), 'required' => t('Required Title'), 'value' => t('Static Title'), + 'select' => t('Selected Title'), 'none' => t('No Title'), ); @@ -97,51 +121,65 @@ function link_field_instance_settings_form($field, $instance) { '#title' => t('Link Title'), '#default_value' => isset($instance['settings']['title']) ? $instance['settings']['title'] : 'optional', '#options' => $title_options, - '#description' => t('If the link title is optional or required, a field will be displayed to the end user. If the link title is static, the link will always use the same title. If token module is installed, the static title value may use any other node field as its value. Static and token-based titles may include most inline XHTML tags such as strong, em, img, span, etc.'), + '#description' => t('If the link title is optional or required, a field will be displayed to the end user. If the link title is static, the link will always use the same title. If token module is installed, the static title value may use any other entity field as its value. Static and token-based titles may include most inline XHTML tags such as strong, em, img, span, etc.'), ); $form['title_value'] = array( '#type' => 'textfield', - '#title' => t('Static title'), + '#title' => t('Static or default title'), '#default_value' => isset($instance['settings']['title_value']) ? $instance['settings']['title_value'] : '', - '#description' => t('This title will always be used if “Static Title” is selected above.'), + '#description' => t('This title will 1) always be used if "Static Title" is selected above, or 2) used if "Optional title" is selected above and no title is entered when creating content.'), + '#states' => array( + 'visible' => array( + ':input[name="instance[settings][title]"]' => array('value' => 'value'), + ), + ), ); - $form['title_maxlength'] = array( // patch #1307788 from nmc + $form['title_allowed_values'] = array( + '#type' => 'textarea', + '#title' => t('Title allowed values'), + '#default_value' => isset($instance['settings']['title_allowed_values']) ? $instance['settings']['title_allowed_values'] : '', + '#description' => t('When using "Selected Title", you can allow users to select the title from a limited set of values (eg. Home, Office, Other). Enter here all possible values that title can take, one value per line.'), + '#states' => array( + 'visible' => array( + ':input[name="instance[settings][title]"]' => array('value' => 'select'), + ), + ), + ); + + $form['title_label_use_field_label'] = array( + '#type' => 'checkbox', + '#title' => t('Use field label as the label for the title field'), + '#default_value' => isset($instance['settings']['title_label_use_field_label']) ? $instance['settings']['title_label_use_field_label'] : FALSE, + '#description' => t('If this is checked the field label will be hidden.'), + ); + + $form['title_maxlength'] = array( '#type' => 'textfield', '#title' => t('Max length of title field'), '#default_value' => isset($instance['settings']['title_maxlength']) ? $instance['settings']['title_maxlength'] : '128', '#description' => t('Set a maximum length on the title field (applies only if Link Title is optional or required). The maximum limit is 255 characters.'), '#maxlength' => 3, '#size' => 3, - ); + ); if (module_exists('token')) { - // Add token module replacements fields - $form['tokens'] = array( - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#title' => t('Placeholder tokens'), - '#description' => t("The following placeholder tokens can be used in both paths and titles. When used in a path or title, they will be replaced with the appropriate values."), - ); - $token_type = array( - 'theme' => 'token_tree', - 'token_types' => array($instance['entity_type']), - 'global_types' => TRUE, - 'click_insert' => TRUE, - 'recursion_limit' => 2, - ); - $form['tokens']['help'] = array( - '#type' => 'markup', - '#markup' => theme('token_tree', $token_type), - ); - + // Add token module replacements fields. $form['enable_tokens'] = array( '#type' => 'checkbox', '#title' => t('Allow user-entered tokens'), '#default_value' => isset($instance['settings']['enable_tokens']) ? $instance['settings']['enable_tokens'] : 1, - '#description' => t('Checking will allow users to enter tokens in URLs and Titles on the node edit form. This does not affect the field settings on this page.'), + '#description' => t('Checking will allow users to enter tokens in URLs and Titles on the entity edit form. This does not affect the field settings on this page.'), + ); + + $entity_info = entity_get_info($instance['entity_type']); + $form['tokens_help'] = array( + '#theme' => 'token_tree', + '#token_types' => array($entity_info['token type']), + '#global_types' => TRUE, + '#click_insert' => TRUE, + '#dialog' => TRUE, ); } @@ -154,7 +192,7 @@ function link_field_instance_settings_form($field, $instance) { '#default_value' => isset($instance['settings']['display']['url_cutoff']) ? $instance['settings']['display']['url_cutoff'] : '80', '#description' => t('If the user does not include a title for this link, the URL will be used as the title. When should the link title be trimmed and finished with an elipsis (…)? Leave blank for no limit.'), '#maxlength' => 3, - '#size' => 3, + '#size' => 3, ); $target_options = array( @@ -175,16 +213,33 @@ function link_field_instance_settings_form($field, $instance) { $form['attributes']['rel'] = array( '#type' => 'textfield', '#title' => t('Rel Attribute'), - '#description' => t('When output, this link will have this rel attribute. The most common usage is rel="nofollow" which prevents some search engines from spidering entered links.'), + '#description' => t('When output, this link will have this rel attribute. The most common usage is rel="nofollow" which prevents some search engines from spidering entered links.'), '#default_value' => empty($instance['settings']['attributes']['rel']) ? '' : $instance['settings']['attributes']['rel'], '#field_prefix' => 'rel = "', '#field_suffix' => '"', '#size' => 20, ); + $rel_remove_options = array( + 'default' => t('Keep rel as set up above (untouched/default)'), + 'rel_remove_external' => t('Remove rel if given link is external'), + 'rel_remove_internal' => t('Remove rel if given link is internal'), + ); + $form['rel_remove'] = array( + '#type' => 'radios', + '#title' => t('Remove rel attribute automatically'), + '#default_value' => !isset($instance['settings']['rel_remove']) ? 'default' : $instance['settings']['rel_remove'], + '#description' => t('Turn on/off if rel attribute should be removed automatically, if user given link is internal/external'), + '#options' => $rel_remove_options, + ); + $form['attributes']['configurable_class'] = array( + '#title' => t("Allow the user to enter a custom link class per link"), + '#type' => 'checkbox', + '#default_value' => empty($instance['settings']['attributes']['configurable_class']) ? '' : $instance['settings']['attributes']['configurable_class'], + ); $form['attributes']['class'] = array( '#type' => 'textfield', '#title' => t('Additional CSS Class'), - '#description' => t('When output, this link will have this class attribute. Multiple classes should be separated by spaces.'), + '#description' => t('When output, this link will have this class attribute. Multiple classes should be separated by spaces. Only alphanumeric characters and hyphens are allowed'), '#default_value' => empty($instance['settings']['attributes']['class']) ? '' : $instance['settings']['attributes']['class'], ); $form['attributes']['configurable_title'] = array( @@ -195,7 +250,7 @@ function link_field_instance_settings_form($field, $instance) { $form['attributes']['title'] = array( '#title' => t("Default link 'title' Attribute"), '#type' => 'textfield', - '#description' => t('When output, links will use this "title" attribute if the user does not provide one and when different from the link text. Read WCAG 1.0 Guidelines for links comformances. Tokens values will be evaluated.'), + '#description' => t('When output, links will use this "title" attribute if the user does not provide one and when different from the link text. Read WCAG 1.0 Guidelines for links comformances. Tokens values will be evaluated.'), '#default_value' => empty($instance['settings']['attributes']['title']) ? '' : $instance['settings']['attributes']['title'], '#field_prefix' => 'title = "', '#field_suffix' => '"', @@ -205,29 +260,34 @@ function link_field_instance_settings_form($field, $instance) { } /** - * Validate the field settings form. + * Form validate. + * + * #element_validate handler for link_field_instance_settings_form(). */ function link_field_settings_form_validate($element, &$form_state, $complete_form) { - if ($form_state['values']['instance']['settings']['title'] === 'value' - && empty($form_state['values']['instance']['settings']['title_value'])) { - form_set_error('title_value', t('A default title must be provided if the title is a static value.')); + if ($form_state['values']['instance']['settings']['title'] === 'value' && empty($form_state['values']['instance']['settings']['title_value'])) { + form_set_error('instance][settings][title_value', t('A default title must be provided if the title is a static value.')); } - if (!empty($form_state['values']['instance']['settings']['display']['url_cutoff']) // patch #1307788 from nmc - && !is_numeric($form_state['values']['instance']['settings']['display']['url_cutoff'])) { + if ($form_state['values']['instance']['settings']['title'] === 'select' + && empty($form_state['values']['instance']['settings']['title_allowed_values'])) { + form_set_error('instance][settings][title_allowed_values', t('You must enter one or more allowed values for link Title, the title is a selected value.')); + } + if (!empty($form_state['values']['instance']['settings']['display']['url_cutoff']) && !is_numeric($form_state['values']['instance']['settings']['display']['url_cutoff'])) { form_set_error('display', t('URL Display Cutoff value must be numeric.')); } - if (empty($form_state['values']['instance']['settings']['title_maxlength'])) { // patch #1307788 from nmc + if (empty($form_state['values']['instance']['settings']['title_maxlength'])) { form_set_value($element['title_maxlength'], '128', $form_state); - } elseif (!is_numeric($form_state['values']['instance']['settings']['title_maxlength'])) { + } + elseif (!is_numeric($form_state['values']['instance']['settings']['title_maxlength'])) { form_set_error('title_maxlength', t('The max length of the link title must be numeric.')); - } elseif ($form_state['values']['instance']['settings']['title_maxlength'] > 255) { + } + elseif ($form_state['values']['instance']['settings']['title_maxlength'] > 255) { form_set_error('title_maxlength', t('The max length of the link title cannot be greater than 255 characters.')); } - } /** - * Implement hook_field_is_empty(). + * Implements hook_field_is_empty(). */ function link_field_is_empty($item, $field) { return empty($item['title']) && empty($item['url']); @@ -251,21 +311,44 @@ function link_field_validate($entity_type, $entity, $field, $instance, $langcode $optional_field_found = FALSE; if ($instance['settings']['validate_url'] !== 0 || is_null($instance['settings']['validate_url']) || !isset($instance['settings']['validate_url'])) { foreach ($items as $delta => $value) { - _link_validate($items[$delta], $delta, $field, $entity, $instance, $optional_field_found); + _link_validate($items[$delta], $delta, $field, $entity, $instance, $langcode, $optional_field_found, $errors); + } + } + + foreach ($items as $delta => $value) { + if (isset($value['attributes']) && is_string($value['attributes'])) { + $errors[$field['field_name']][$langcode][$delta][] = array( + 'error' => 'link_required', + 'message' => t('String values are not acceptable for attributes.'), + 'error_element' => array('url' => TRUE, 'title' => FALSE), + ); } } if ($instance['settings']['url'] === 'optional' && $instance['settings']['title'] === 'optional' && $instance['required'] && !$optional_field_found) { - form_set_error($field['field_name'] .'][0][title', t('At least one title or URL must be entered.')); + $errors[$field['field_name']][$langcode][0][] = array( + 'error' => 'link_required', + 'message' => t('At least one title or URL must be entered.'), + 'error_element' => array('url' => FALSE, 'title' => TRUE), + ); } } /** - * Implements hook_field_presave(). + * Implements hook_field_insert(). */ -function link_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { +function link_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { foreach ($items as $delta => $value) { - _link_process($items[$delta], $delta, $field, $entity); + _link_process($items[$delta], $delta, $field, $entity, $instance); + } +} + +/** + * Implements hook_field_update(). + */ +function link_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { + foreach ($items as $delta => $value) { + _link_process($items[$delta], $delta, $field, $entity, $instance); } } @@ -304,17 +387,29 @@ function link_field_widget_form(&$form, &$form_state, $field, $instance, $langco return $element; } +/** + * Implements hook_field_widget_error(). + */ +function link_field_widget_error($element, $error, $form, &$form_state) { + if (!empty($error['error_element']['title'])) { + form_error($element['title'], $error['message']); + } + elseif (!empty($error['error_element']['url'])) { + form_error($element['url'], $error['message']); + } +} + /** * Unpacks the item attributes for use. */ function _link_load($field, $item, $instance) { - /*return $item['attributes'] = isset($item['attributes']) ? - unserialize($item['attributes']) : - $instance['settings']['attributes'];*/ if (isset($item['attributes'])) { - return unserialize($item['attributes']); + if (!is_array($item['attributes'])) { + $item['attributes'] = unserialize($item['attributes']); + } + return $item['attributes']; } - else if (isset($instance['settings']['attributes'])) { + elseif (isset($instance['settings']['attributes'])) { return $instance['settings']['attributes']; } else { @@ -324,12 +419,29 @@ function _link_load($field, $item, $instance) { /** * Prepares the item attributes and url for storage. + * + * @param array $item + * Link field values. + * @param array $delta + * The sequence number for current values. + * @param array $field + * The field structure array. + * @param object $entity + * Entity object. + * @param array $instance + * The instance structure for $field on $entity's bundle. + * + * @codingStandardsIgnoreStart */ -function _link_process(&$item, $delta = 0, $field, $entity) { +function _link_process(&$item, $delta, $field, $entity, $instance) { + // @codingStandardsIgnoreEnd // Trim whitespace from URL. - $item['url'] = trim($item['url']); + if (!empty($item['url'])) { + $item['url'] = trim($item['url']); + } - // if no attributes are set then make sure $item['attributes'] is an empty array - this lets $field['attributes'] override it. + // If no attributes are set then make sure $item['attributes'] is an empty + // array, so $field['attributes'] can override it. if (empty($item['attributes'])) { $item['attributes'] = array(); } @@ -340,9 +452,9 @@ function _link_process(&$item, $delta = 0, $field, $entity) { } // Don't save an invalid default value (e.g. 'http://'). - if ((isset($field['widget']['default_value'][$delta]['url']) && $item['url'] == $field['widget']['default_value'][$delta]['url']) - && is_object($node)) { - if (!link_validate_url($item['url'])) { + if ((isset($field['widget']['default_value'][$delta]['url']) && $item['url'] == $field['widget']['default_value'][$delta]['url']) && is_object($entity)) { + $langcode = !empty($entity) ? field_language($instance['entity_type'], $entity, $instance['field_name']) : LANGUAGE_NONE; + if (!link_validate_url($item['url'], $langcode)) { unset($item['url']); } } @@ -351,128 +463,190 @@ function _link_process(&$item, $delta = 0, $field, $entity) { /** * Validates that the link field has been entered properly. */ -function _link_validate(&$item, $delta, $field, $node, $instance, &$optional_field_found) { - if ($item['url'] - && !(isset($instance['default_value'][$delta]['url']) - && $item['url'] === $instance['default_value'][$delta]['url'] - && !$instance['required'])) { +function _link_validate(&$item, $delta, $field, $entity, $instance, $langcode, &$optional_field_found, &$errors) { + if ($item['url'] && !(isset($instance['default_value'][$delta]['url']) && $item['url'] === $instance['default_value'][$delta]['url'] && !$instance['required'])) { // Validate the link. - if (link_validate_url(trim($item['url'])) == FALSE) { - form_set_error($field['field_name'] .']['. $delta .'][url', t('Not a valid URL.')); + if (!link_validate_url(trim($item['url']), $langcode)) { + $errors[$field['field_name']][$langcode][$delta][] = array( + 'error' => 'link_required', + 'message' => t('The value %value provided for %field is not a valid URL.', array( + '%value' => trim($item['url']), + '%field' => $instance['label'], + )), + 'error_element' => array('url' => TRUE, 'title' => FALSE), + ); } // Require a title for the link if necessary. if ($instance['settings']['title'] == 'required' && strlen(trim($item['title'])) == 0) { - form_set_error($field['field_name'] .']['. $delta .'][title', t('Titles are required for all links.')); + $errors[$field['field_name']][$langcode][$delta][] = array( + 'error' => 'link_required', + 'message' => t('Titles are required for all links.'), + 'error_element' => array('url' => FALSE, 'title' => TRUE), + ); } } // Require a link if we have a title. - if ($instance['settings']['url'] !== 'optional' - && strlen(isset($item['title']) ? $item['title'] : NULL) > 0 - && strlen(trim($item['url'])) == 0) { - form_set_error($field['field_name'] .']['. $delta .'][url', t('You cannot enter a title without a link url.')); + if ($instance['settings']['url'] !== 'optional' && strlen(isset($item['title']) ? $item['title'] : NULL) > 0 && strlen(trim($item['url'])) == 0) { + $errors[$field['field_name']][$langcode][$delta][] = array( + 'error' => 'link_required', + 'message' => t('You cannot enter a title without a link url.'), + 'error_element' => array('url' => TRUE, 'title' => FALSE), + ); } - // In a totally bizzaro case, where URLs and titles are optional but the field is required, ensure there is at least one link. - if ($instance['settings']['url'] === 'optional' - && $instance['settings']['title'] === 'optional' - && (strlen(trim($item['url'])) !== 0 || strlen(trim($item['title'])) !== 0)) { + // In a totally bizzaro case, where URLs and titles are optional but the field + // is required, ensure there is at least one link. + if ($instance['settings']['url'] === 'optional' && $instance['settings']['title'] === 'optional' + && (strlen(trim($item['url'])) !== 0 || strlen(trim($item['title'])) !== 0)) { $optional_field_found = TRUE; } - // Require entire field - if ($instance['settings']['url'] === 'optional' - && $instance['settings']['title'] === 'optional' - && $instance['required'] == 1 - && !$optional_field_found - && isset($instance['id'])) { - form_set_error($instance['field_name'] .'][0][title', - t('At least one title or URL must be entered.')); + // Require entire field. + if ($instance['settings']['url'] === 'optional' && $instance['settings']['title'] === 'optional' && $instance['required'] == 1 && !$optional_field_found && isset($instance['id'])) { + $errors[$field['field_name']][$langcode][$delta][] = array( + 'error' => 'link_required', + 'message' => t('At least one title or URL must be entered.'), + 'error_element' => array('url' => FALSE, 'title' => TRUE), + ); } } /** - * Cleanup user-entered values for a link field according to field settings. + * Clean up user-entered values for a link field according to field settings. * - * @param $item + * @param array $item * A single link item, usually containing url, title, and attributes. - * @param $delta + * @param int $delta * The delta value if this field is one of multiple fields. - * @param $field + * @param array $field * The CCK field definition. - * @param $node - * The node containing this link. + * @param object $entity + * The entity containing this link. + * + * @codingStandardsIgnoreStart */ -function _link_sanitize(&$item, $delta, &$field, $instance, &$node) { +function _link_sanitize(&$item, $delta, &$field, $instance, &$entity) { + // @codingStandardsIgnoreEnd // Don't try to process empty links. if (empty($item['url']) && empty($item['title'])) { return; } - - // Replace URL tokens. - if (isset($instance['settings']['enable_tokens']) && $instance['settings']['enable_tokens']) { - global $user; - // Load the node if necessary for nodes in views. - $token_node = isset($node->nid) ? node_load($node->nid) : $node; - $item['url'] = token_replace($item['url'], array('node' => $token_node)); + if (empty($item['html'])) { + $item['html'] = FALSE; } - $type = link_validate_url($item['url']); - // If we can't determine the type of url, and we've been told not to validate it, - // then we assume it's a LINK_EXTERNAL type for later processing. #357604 + // Replace URL tokens. + $entity_type = $instance['entity_type']; + $entity_info = entity_get_info($entity_type); + $property_id = $entity_info['entity keys']['id']; + $entity_token_type = isset($entity_info['token type']) ? $entity_info['token type'] : ( + $entity_type == 'taxonomy_term' || $entity_type == 'taxonomy_vocabulary' ? str_replace('taxonomy_', '', $entity_type) : $entity_type + ); + if (isset($instance['settings']['enable_tokens']) && $instance['settings']['enable_tokens']) { + $text_tokens = token_scan($item['url']); + if (!empty($text_tokens)) { + // Load the entity if necessary for entities in views. + if (isset($entity->{$property_id})) { + $entity_loaded = entity_load($entity_type, array($entity->{$property_id})); + $entity_loaded = array_pop($entity_loaded); + } + else { + $entity_loaded = $entity; + } + $item['url'] = token_replace($item['url'], array($entity_token_type => $entity_loaded)); + } + } + + $type = link_url_type($item['url']); + // If the type of the URL cannot be determined and URL validation is disabled, + // then assume LINK_EXTERNAL for later processing. if ($type == FALSE && $instance['settings']['validate_url'] === 0) { $type = LINK_EXTERNAL; } $url = link_cleanup_url($item['url']); + $url_parts = _link_parse_url($url); - // Separate out the anchor if any. - if (strpos($url, '#') !== FALSE) { - $item['fragment'] = substr($url, strpos($url, '#') + 1); - $url = substr($url, 0, strpos($url, '#')); + if (!empty($url_parts['url'])) { + $item['url'] = url($url_parts['url'], + array( + 'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL, + 'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL, + 'absolute' => !empty($instance['settings']['absolute_url']), + 'html' => TRUE, + ) + ); } - // Separate out the query string if any. - if (strpos($url, '?') !== FALSE) { - $query = substr($url, strpos($url, '?') + 1); - parse_str($query, $query_array); - $item['query'] = $query_array; - $url = substr($url, 0, strpos($url, '?')); - } - - $item['url'] = check_plain($url); // Create a shortened URL for display. - $display_url = $type == LINK_EMAIL ? - str_replace('mailto:', '', $url) : - url($url, array('query' => isset($item['query']) ? - $item['query'] : - NULL, - 'fragment' => isset($item['fragment']) ? - $item['fragment'] : - NULL, - 'absolute' => TRUE)); + if ($type == LINK_EMAIL) { + $display_url = str_replace('mailto:', '', $url); + } + else { + $display_url = url($url_parts['url'], + array( + 'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL, + 'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL, + 'absolute' => !empty($instance['settings']['absolute_url']), + ) + ); + } if ($instance['settings']['display']['url_cutoff'] && strlen($display_url) > $instance['settings']['display']['url_cutoff']) { - $display_url = substr($display_url, 0, $instance['settings']['display']['url_cutoff']) ."..."; + $display_url = substr($display_url, 0, $instance['settings']['display']['url_cutoff']) . "..."; } $item['display_url'] = $display_url; // Use the title defined at the instance level. if ($instance['settings']['title'] == 'value' && strlen(trim($instance['settings']['title_value']))) { $title = $instance['settings']['title_value']; + if (function_exists('i18n_string_translate')) { + $i18n_string_name = "field:{$instance['field_name']}:{$instance['bundle']}:title_value"; + $title = i18n_string_translate($i18n_string_name, $title); + } } // Use the title defined by the user at the widget level. - else if (isset($item['title'])) { + elseif (drupal_strlen(trim($item['title']))) { $title = $item['title']; } + // Use the static title if a user-defined title is optional and a static title + // has been defined. + elseif ($instance['settings']['title'] == 'optional' && drupal_strlen(trim($instance['settings']['title_value']))) { + $title = $instance['settings']['title_value']; + } else { $title = ''; } - // Replace tokens. + // Replace title tokens. + if ($title && $instance['settings']['enable_tokens']) { + $text_tokens = token_scan($title); + if (!empty($text_tokens)) { + // Load the entity if necessary for entities in views. + if (isset($entity->{$property_id})) { + $entity_loaded = entity_load($entity_type, array($entity->{$property_id})); + $entity_loaded = array_pop($entity_loaded); + } + else { + $entity_loaded = $entity; + } + $title = token_replace($title, array($entity_token_type => $entity_loaded)); + } + } if ($title && ($instance['settings']['title'] == 'value' || $instance['settings']['enable_tokens'])) { - // Load the node if necessary for nodes in views. - $token_node = isset($node->nid) ? node_load($node->nid) : $node; - $title = filter_xss(token_replace($title, array('node' => $token_node)), - array('b', 'br', 'code', 'em', 'i', 'img', 'span', 'strong', 'sub', 'sup', 'tt', 'u')); + $title = filter_xss($title, array( + 'b', + 'br', + 'code', + 'em', + 'i', + 'img', + 'span', + 'strong', + 'sub', + 'sup', + 'tt', + 'u', + )); $item['html'] = TRUE; } - $item['title'] = empty($title) ? $item['display_url'] : $title; + $item['title'] = empty($title) && $title !== '0' ? $item['display_url'] : $title; if (!isset($item['attributes'])) { $item['attributes'] = array(); @@ -480,11 +654,11 @@ function _link_sanitize(&$item, $delta, &$field, $instance, &$node) { // Unserialize attributtes array if it has not been unserialized yet. if (!is_array($item['attributes'])) { - $item['attributes'] = (array)unserialize($item['attributes']); + $item['attributes'] = (array) unserialize($item['attributes']); } // Add default attributes. - if (!is_array($instance['settings']['attributes'])){ + if (!is_array($instance['settings']['attributes'])) { $instance['settings']['attributes'] = _link_default_attributes(); } else { @@ -499,24 +673,62 @@ function _link_sanitize(&$item, $delta, &$field, $instance, &$node) { if ($instance['settings']['attributes']['target'] != LINK_TARGET_USER) { $item['attributes']['target'] = $instance['settings']['attributes']['target']; } + elseif ($item['attributes']['target'] == LINK_TARGET_USER) { + $item['attributes']['target'] = LINK_TARGET_DEFAULT; + } // Remove the target attribute if the default (no target) is selected. - if (empty($item['attributes']) || $item['attributes']['target'] == LINK_TARGET_DEFAULT) { + if (empty($item['attributes']) || (isset($item['attributes']['target']) && $item['attributes']['target'] == LINK_TARGET_DEFAULT)) { unset($item['attributes']['target']); } - // Remove the rel=nofollow for internal links. - if ($type != LINK_EXTERNAL && strpos($item['attributes']['rel'], 'nofollow') !== FALSE) { - $item['attributes']['rel'] = str_replace('nofollow', '', $item['attributes']); + // Remove rel attribute for internal or external links if selected. + if (isset($item['attributes']['rel']) && isset($instance['settings']['rel_remove']) && $instance['settings']['rel_remove'] != 'default') { + if (($instance['settings']['rel_remove'] != 'rel_remove_internal' && $type != LINK_INTERNAL) || + ($instance['settings']['rel_remove'] != 'rel_remove_external' && $type != LINK_EXTERNAL)) { + unset($item['attributes']['rel']); + } } // Handle "title" link attribute. if (!empty($item['attributes']['title']) && module_exists('token')) { - // Load the node (necessary for nodes in views). - $token_node = isset($node->nid) ? node_load($node->nid) : $node; - $item['attributes']['title'] = filter_xss(token_replace($item['attributes']['title'], array('node' => $token_node)), - array('b', 'br', 'code', 'em', 'i', 'img', 'span', 'strong', 'sub', 'sup', 'tt', 'u')); + $text_tokens = token_scan($item['attributes']['title']); + if (!empty($text_tokens)) { + // Load the entity (necessary for entities in views). + if (isset($entity->{$property_id})) { + $entity_loaded = entity_load($entity_type, array($entity->{$property_id})); + $entity_loaded = array_pop($entity_loaded); + } + else { + $entity_loaded = $entity; + } + $item['attributes']['title'] = token_replace($item['attributes']['title'], array($entity_token_type => $entity_loaded)); + } + $item['attributes']['title'] = filter_xss($item['attributes']['title'], array( + 'b', + 'br', + 'code', + 'em', + 'i', + 'img', + 'span', + 'strong', + 'sub', + 'sup', + 'tt', + 'u', + )); } + // Handle attribute classes. + if (!empty($item['attributes']['class'])) { + $classes = explode(' ', $item['attributes']['class']); + foreach ($classes as &$class) { + $class = drupal_clean_css_identifier($class); + } + $item['attributes']['class'] = implode(' ', $classes); + } + unset($item['attributes']['configurable_class']); + // Remove title attribute if it's equal to link text. if (isset($item['attributes']['title']) && $item['attributes']['title'] == $item['title']) { unset($item['attributes']['title']); @@ -525,16 +737,66 @@ function _link_sanitize(&$item, $delta, &$field, $instance, &$node) { // Remove empty attributes. $item['attributes'] = array_filter($item['attributes']); +} - // Sets title to trimmed url if one exists - // @TODO: Do we need this? It seems not. - /*if(!empty($item['display_url']) && empty($item['title'])) { - $item['title'] = $item['display_url']; +/** + * Because parse_url doesn't work with relative urls. + * + * @param string $url + * URL to parse. + * + * @return array + * Array of url pieces - only 'url', 'query', and 'fragment'. + */ +function _link_parse_url($url) { + $url_parts = array(); + // Separate out the anchor, if any. + if (strpos($url, '#') !== FALSE) { + $url_parts['fragment'] = substr($url, strpos($url, '#') + 1); + $url = substr($url, 0, strpos($url, '#')); } - elseif(!isset($item['title'])) { - $item['title'] = $item['url']; - }*/ + // Separate out the query string, if any. + if (strpos($url, '?') !== FALSE) { + $query = substr($url, strpos($url, '?') + 1); + $url_parts['query'] = _link_parse_str($query); + $url = substr($url, 0, strpos($url, '?')); + } + $url_parts['url'] = $url; + return $url_parts; +} +/** + * Replaces the PHP parse_str() function. + * + * Because parse_str replaces the following characters in query parameters name + * in order to maintain compatibility with deprecated register_globals + * directive: + * + * - chr(32) ( ) (space) + * - chr(46) (.) (dot) + * - chr(91) ([) (open square bracket) + * - chr(128) - chr(159) (various) + * + * @param string $query + * Query to parse. + * + * @return array + * Array of query parameters. + * + * @see http://php.net/manual/en/language.variables.external.php#81080 + */ +function _link_parse_str($query) { + $query_array = array(); + + $pairs = explode('&', $query); + foreach ($pairs as $pair) { + $name_value = explode('=', $pair, 2); + $name = urldecode($name_value[0]); + $value = isset($name_value[1]) ? urldecode($name_value[1]) : NULL; + $query_array[$name] = $value; + } + + return $query_array; } /** @@ -542,29 +804,42 @@ function _link_sanitize(&$item, $delta, &$field, $instance, &$node) { */ function link_theme() { return array( - /*'link_field_settings' => array( - 'variables' => array('element' => NULL), - ),*/ 'link_formatter_link_default' => array( - 'variables' => array('element' => NULL), + 'variables' => array('element' => NULL, 'field' => NULL), ), 'link_formatter_link_plain' => array( + 'variables' => array('element' => NULL, 'field' => NULL), + ), + 'link_formatter_link_host' => array( 'variables' => array('element' => NULL), ), + 'link_formatter_link_absolute' => array( + 'variables' => array('element' => NULL, 'field' => NULL), + ), + 'link_formatter_link_domain' => array( + 'variables' => array( + 'element' => NULL, + 'display' => NULL, + 'field' => NULL, + ), + ), + 'link_formatter_link_no_protocol' => array( + 'variables' => array('element' => NULL, 'field' => NULL), + ), 'link_formatter_link_title_plain' => array( - 'variables' => array('element' => NULL), + 'variables' => array('element' => NULL, 'field' => NULL), ), 'link_formatter_link_url' => array( - 'variables' => array('element' => NULL), + 'variables' => array('element' => NULL, 'field' => NULL), ), 'link_formatter_link_short' => array( - 'variables' => array('element' => NULL), + 'variables' => array('element' => NULL, 'field' => NULL), ), 'link_formatter_link_label' => array( - 'variables' => array('element' => NULL), + 'variables' => array('element' => NULL, 'field' => NULL), ), 'link_formatter_link_separate' => array( - 'variables' => array('element' => NULL), + 'variables' => array('element' => NULL, 'field' => NULL), ), 'link_field' => array( 'render element' => 'element', @@ -573,32 +848,35 @@ function link_theme() { } /** - * FAPI theme for an individual text elements. + * Formats a link field widget. */ function theme_link_field($vars) { - drupal_add_css(drupal_get_path('module', 'link') .'/link.css'); - + drupal_add_css(drupal_get_path('module', 'link') . '/link.css'); $element = $vars['element']; // Prefix single value link fields with the name of the field. if (empty($element['#field']['multiple'])) { if (isset($element['url']) && !isset($element['title'])) { - unset($element['url']['#title']); + $element['url']['#title_display'] = 'invisible'; } } $output = ''; $output .= ''; if (!empty($element['attributes']['target'])) { - $output .= ''; + $output .= ''; } if (!empty($element['attributes']['title'])) { - $output .= ''; + $output .= ''; } + if (!empty($element['attributes']['class'])) { + $output .= ''; + } + $output .= drupal_render_children($element); return $output; } @@ -607,7 +885,7 @@ function theme_link_field($vars) { */ function link_element_info() { $elements = array(); - $elements['link_field'] = array( + $elements['link_field'] = array( '#input' => TRUE, '#process' => array('link_field_process'), '#theme' => 'link_field', @@ -616,6 +894,9 @@ function link_element_info() { return $elements; } +/** + * Returns the default attributes and their values. + */ function _link_default_attributes() { return array( 'target' => LINK_TARGET_DEFAULT, @@ -625,12 +906,13 @@ function _link_default_attributes() { } /** - * Process the link type element before displaying the field. + * Processes the link type element before displaying the field. * * Build the form element. When creating a form using FAPI #process, * note that $element['#value'] is already set. * - * The $fields array is in $complete_form['#field_info'][$element['#field_name']]. + * The $fields array is in + * $complete_form['#field_info'][$element['#field_name']]. */ function link_field_process($element, $form_state, $complete_form) { $instance = field_widget_instance($element, $form_state); @@ -642,16 +924,43 @@ function link_field_process($element, $form_state, $complete_form) { '#required' => ($element['#delta'] == 0 && $settings['url'] !== 'optional') ? $element['#required'] : FALSE, '#default_value' => isset($element['#value']['url']) ? $element['#value']['url'] : NULL, ); - if ($settings['title'] !== 'none' && $settings['title'] !== 'value') { + if (in_array($settings['title'], array('optional', 'required'))) { + // Figure out the label of the title field. + if (!empty($settings['title_label_use_field_label'])) { + // Use the element label as the title field label. + $title_label = $element['#title']; + // Hide the field label because there is no need for the duplicate labels. + $element['#title_display'] = 'invisible'; + } + else { + $title_label = t('Title'); + } + + // Default value. + $title_maxlength = 128; + if (!empty($settings['title_maxlength'])) { + $title_maxlength = $settings['title_maxlength']; + } + $element['title'] = array( '#type' => 'textfield', - '#maxlength' => $settings['title_maxlength'], // patch #1307788 from nmc - '#title' => t('Title'), - '#description' => t('The link title is limited to '.$settings['title_maxlength'].' characters maximum.'), // patch #1307788 from nmc - '#required' => ($settings['title'] == 'required' && (($element['#delta'] == 0 && $element['#required']) || !empty($element['#value']['url']))) ? TRUE : FALSE, // davereids patch from jan 2011 + '#maxlength' => $title_maxlength, + '#title' => $title_label, + '#description' => t('The link title is limited to @maxlength characters maximum.', array('@maxlength' => $title_maxlength)), + '#required' => ($settings['title'] == 'required' && (($element['#delta'] == 0 && $element['#required']) || !empty($element['#value']['url']))) ? TRUE : FALSE, '#default_value' => isset($element['#value']['title']) ? $element['#value']['title'] : NULL, ); } + elseif ($settings['title'] == 'select') { + $options = drupal_map_assoc(array_filter(explode("\n", str_replace("\r", "\n", trim($settings['title_allowed_values']))))); + $element['title'] = array( + '#type' => 'select', + '#title' => t('Title'), + '#description' => t('Select the a title for this link.'), + '#default_value' => isset($element['#value']['title']) ? $element['#value']['title'] : NULL, + '#options' => $options, + ); + } // Initialize field attributes as an array if it is not an array yet. if (!is_array($settings['attributes'])) { @@ -677,16 +986,30 @@ function link_field_process($element, $form_state, $complete_form) { '#field_suffix' => '"', ); } + if (!empty($settings['attributes']['configurable_class']) && $settings['attributes']['configurable_class'] == 1) { + $element['attributes']['class'] = array( + '#type' => 'textfield', + '#title' => t('Custom link class'), + '#default_value' => isset($attributes['class']) ? $attributes['class'] : '', + '#field_prefix' => 'class = "', + '#field_suffix' => '"', + ); + } - // To prevent an extra required indicator, disable the required flag on the - // base element since all the sub-fields are already required if desired. - $element['#required'] = FALSE; // davereids patch from jan 2011 + // If the title field is available or there are field accepts multiple values + // then allow the individual field items display the required asterisk if + // needed. + if (isset($element['title']) || isset($element['_weight'])) { + // To prevent an extra required indicator, disable the required flag on the + // base element since all the sub-fields are already required if desired. + $element['#required'] = FALSE; + } return $element; } /** - * Implementation of hook_field_formatter_info(). + * Implements hook_field_formatter_info(). */ function link_field_formatter_info() { return array( @@ -700,6 +1023,11 @@ function link_field_formatter_info() { 'field types' => array('link_field'), 'multiple values' => FIELD_BEHAVIOR_DEFAULT, ), + 'link_host' => array( + 'label' => t('Host, as plain text'), + 'field types' => array('link_field'), + 'multiple values' => FIELD_BEHAVIOR_DEFAULT, + ), 'link_url' => array( 'label' => t('URL, as link'), 'field types' => array('link_field'), @@ -710,6 +1038,24 @@ function link_field_formatter_info() { 'field types' => array('link_field'), 'multiple values' => FIELD_BEHAVIOR_DEFAULT, ), + 'link_absolute' => array( + 'label' => t('URL, absolute'), + 'field types' => array('link_field'), + 'multiple values' => FIELD_BEHAVIOR_DEFAULT, + ), + 'link_domain' => array( + 'label' => t('Domain, as link'), + 'field types' => array('link_field'), + 'multiple values' => FIELD_BEHAVIOR_DEFAULT, + 'settings' => array( + 'strip_www' => FALSE, + ), + ), + 'link_no_protocol' => array( + 'label' => t('URL with the protocol removed'), + 'field types' => array('link_field'), + 'multiple values' => FIELD_BEHAVIOR_DEFAULT, + ), 'link_short' => array( 'label' => t('Short, as link with title "Link"'), 'field types' => array('link_field'), @@ -728,6 +1074,41 @@ function link_field_formatter_info() { ); } +/** + * Implements hook_field_formatter_settings_form(). + */ +function link_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) { + $display = $instance['display'][$view_mode]; + $settings = $display['settings']; + $element = array(); + if ($display['type'] == 'link_domain') { + $element['strip_www'] = array( + '#title' => t('Strip www. from domain'), + '#type' => 'checkbox', + '#default_value' => $settings['strip_www'], + ); + } + return $element; +} + +/** + * Implements hook_field_formatter_settings_summary(). + */ +function link_field_formatter_settings_summary($field, $instance, $view_mode) { + + $display = $instance['display'][$view_mode]; + + if ($display['type'] == 'link_domain') { + if ($display['settings']['strip_www']) { + return t('Strip www. from domain'); + } + else { + return t('Leave www. in domain'); + } + } + return ''; +} + /** * Implements hook_field_formatter_view(). */ @@ -735,32 +1116,33 @@ function link_field_formatter_view($entity_type, $entity, $field, $instance, $la $elements = array(); foreach ($items as $delta => $item) { $elements[$delta] = array( - '#markup' => theme('link_formatter_'. $display['type'], array('element' => $item, 'field' => $instance)), + '#theme' => 'link_formatter_' . $display['type'], + '#element' => $item, + '#field' => $instance, + '#display' => $display, ); } return $elements; } /** - * Theme function for 'default' text field formatter. + * Formats a link. */ function theme_link_formatter_link_default($vars) { $link_options = $vars['element']; - unset($link_options['element']['title']); - unset($link_options['element']['url']); - - // Issue #1199806 by ss81: Fixes fatal error when the link URl is equal to page URL + unset($link_options['title']); + unset($link_options['url']); + if (isset($link_options['attributes']['class'])) { $link_options['attributes']['class'] = array($link_options['attributes']['class']); } - // Display a normal link if both title and URL are available. if (!empty($vars['element']['title']) && !empty($vars['element']['url'])) { return l($vars['element']['title'], $vars['element']['url'], $link_options); } // If only a title, display the title. elseif (!empty($vars['element']['title'])) { - return check_plain($vars['element']['title']); + return !empty($link_options['html']) ? $vars['element']['title'] : check_plain($vars['element']['title']); } elseif (!empty($vars['element']['url'])) { return l($vars['element']['title'], $vars['element']['url'], $link_options); @@ -768,93 +1150,149 @@ function theme_link_formatter_link_default($vars) { } /** - * Theme function for 'plain' text field formatter. + * Formats a link (or its title) as plain text. */ function theme_link_formatter_link_plain($vars) { $link_options = $vars['element']; - unset($link_options['element']['title']); - unset($link_options['element']['url']); - return empty($vars['element']['url']) ? - check_plain($vars['element']['title']) : - url($vars['element']['url'], $link_options); + if (isset($link_options['title'])) { + unset($link_options['title']); + } + else { + $vars['element']['title'] = ''; + } + unset($link_options['url']); + return empty($vars['element']['url']) ? check_plain($vars['element']['title']) : url($vars['element']['url'], $link_options); } /** - * Theme function for 'title_plain' text field formatter. + * Theme function for 'host' text field formatter. + */ +function theme_link_formatter_link_host($vars) { + $host = @parse_url($vars['element']['url']); + return isset($host['host']) ? check_plain($host['host']) : ''; +} + +/** + * Formats a link as an absolute URL. + */ +function theme_link_formatter_link_absolute($vars) { + $absolute = array('absolute' => TRUE); + return empty($vars['element']['url']) ? '' : url($vars['element']['url'], $absolute + $vars['element']); +} + +/** + * Formats a link using the URL's domain for it's link text. + */ +function theme_link_formatter_link_domain($vars) { + $link_options = $vars['element']; + unset($link_options['title']); + unset($link_options['url']); + $domain = parse_url($vars['element']['display_url'], PHP_URL_HOST); + if (!empty($vars['display']['settings']['strip_www'])) { + $domain = str_replace('www.', '', $domain); + } + return $vars['element']['url'] ? l($domain, $vars['element']['url'], $link_options) : ''; +} + +/** + * Formats a link without the http:// or https://. + */ +function theme_link_formatter_link_no_protocol($vars) { + $link_options = $vars['element']; + unset($link_options['title']); + unset($link_options['url']); + // We drop any scheme of the url. + $scheme = parse_url($vars['element']['url']); + $search = '/' . preg_quote($scheme['scheme'] . '://', '/') . '/'; + $replace = ''; + $display_url = preg_replace($search, $replace, $vars['element']['url'], 1); + + return $vars['element']['url'] ? l($display_url, $vars['element']['url'], $link_options) : ''; +} + +/** + * Formats a link's title as plain text. */ function theme_link_formatter_link_title_plain($vars) { - return empty($vars['element']['title']) ? '' : check_plain($vars['element']['title']); + return empty($vars['element']['title']) ? '' : check_plain(decode_entities($vars['element']['title'])); } /** - * Theme function for 'url' text field formatter. + * Formats a link using an alternate display URL for its link text. */ function theme_link_formatter_link_url($vars) { $link_options = $vars['element']; - unset($link_options['element']['title']); - unset($link_options['element']['url']); + unset($link_options['title']); + unset($link_options['url']); return $vars['element']['url'] ? l($vars['element']['display_url'], $vars['element']['url'], $link_options) : ''; } /** - * Theme function for 'short' text field formatter. + * Formats a link using "Link" as the link text. */ function theme_link_formatter_link_short($vars) { $link_options = $vars['element']; - unset($link_options['element']['title']); - unset($link_options['element']['url']); + unset($link_options['title']); + unset($link_options['url']); return $vars['element']['url'] ? l(t('Link'), $vars['element']['url'], $link_options) : ''; } /** - * Theme function for 'label' text field formatter. + * Formats a link using the field's label as link text. */ function theme_link_formatter_link_label($vars) { $link_options = $vars['element']; - unset($link_options['element']['title']); - unset($link_options['element']['url']); + unset($link_options['title']); + unset($link_options['url']); return $vars['element']['url'] ? l($vars['field']['label'], $vars['element']['url'], $link_options) : ''; } /** - * Theme function for 'separate' text field formatter. + * Formats a link as separate title and URL elements. */ - function theme_link_formatter_link_separate($vars) { - $class = empty($vars['element']['attributes']['class']) ? '' : ' '. $vars['element']['attributes']['class']; + $class = empty($vars['element']['attributes']['class']) ? '' : ' ' . $vars['element']['attributes']['class']; unset($vars['element']['attributes']['class']); $link_options = $vars['element']; - unset($link_options['element']['title']); - unset($link_options['element']['url']); + unset($link_options['title']); + unset($link_options['url']); $title = empty($vars['element']['title']) ? '' : check_plain($vars['element']['title']); - - /** - * @TODO static html markup looks not very elegant to me (who takes it off?) - * needs smarter output solution and an optional title/url seperator (digidog) - */ + + // @TODO static html markup looks not very elegant + // needs smarter output solution and an optional title/url seperator + $url_parts = _link_parse_url($vars['element']['url']); $output = ''; - $output .= '', ); if (module_exists('update_advanced')) { $options = $form['module_filter']['show']['#options']; diff --git a/sites/all/modules/module_filter/module_filter.theme.inc b/sites/all/modules/module_filter/module_filter.theme.inc index ac7e9d9..2d00ab7 100644 --- a/sites/all/modules/module_filter/module_filter.theme.inc +++ b/sites/all/modules/module_filter/module_filter.theme.inc @@ -11,45 +11,6 @@ function theme_module_filter($variables) { return '
' . drupal_render_children($element) . '
'; } -/** - * A router theme function. - * - * Appropriately themes the system modules page with alterations and based on - * set variables - * - * @param $form - * An associative array containing the structure of the form. - * - * @return - * An output string. - */ -function theme_module_filter_system_modules($variables) { - $form = $variables['form']; - - $output = ''; - if (variable_get('module_filter_tabs', 1)) { - $form['module_filter']['#attached']['css'][] = drupal_get_path('module', 'module_filter') .'/css/module_filter_tab.css'; - $form['module_filter']['#attached']['js'][] = 'misc/jquery.ba-bbq.js'; - $form['module_filter']['#attached']['js'][] = drupal_get_path('module', 'module_filter') .'/js/module_filter_tab.js'; - - if (!module_exists('page_actions') && variable_get('module_filter_dynamic_save_position', 1)) { - $form['module_filter']['#attached']['css'][] = drupal_get_path('module', 'module_filter') .'/css/dynamic_position.css'; - $form['module_filter']['#attached']['js'][] = drupal_get_path('module', 'module_filter') .'/js/dynamic_position.js'; - } - - $output .= theme('module_filter_system_modules_tabs', $form); - } - else { - $form['#theme'] = 'system_modules'; - - $output .= drupal_render($form['module_filter']); - $output .= drupal_render($form['modules']); - $output .= drupal_render($form['actions']); - } - - return $output; -} - /** * Theme callback for the modules tabbed form. */ @@ -71,18 +32,21 @@ function theme_module_filter_system_modules_tabs($variables) { } $header = array( - t('Enabled'), - t('Name'), - t('Version'), - t('Description') + array('data' => '', 'class' => array('checkbox')), + array('data' => t('Name'), 'class' => array('name')), + array('data' => t('Description'), 'class' => array('description')), + array('data' => t('Links'), 'class' => array('links')), ); + if (variable_get('module_filter_version_column', 0)) { + array_splice($header, 2, 0, array(array('data' => t('Version'), 'class' => array('version')))); + } $package_ids = array('all'); $enabled['all'] = array(); if (variable_get('module_filter_track_recent_modules', 1)) { $recent_modules = array_filter(variable_get('module_filter_recent_modules', array()), 'module_filter_recent_filter'); // Save the filtered results. - variable_get('module_filter_recent_modules', $recent_modules); + variable_set('module_filter_recent_modules', $recent_modules); $package_ids[] = 'recent'; $enabled['recent'] = array(); @@ -118,6 +82,11 @@ function theme_module_filter_system_modules_tabs($variables) { } $row = array(); + + $version = !empty($module['version']['#markup']); + $requires = !empty($module['#requires']); + $required_by = !empty($module['#required_by']); + $toggle_enable = ''; if (isset($module['enable']['#type']) && $module['enable']['#type'] == 'checkbox') { unset($module['enable']['#title']); @@ -128,26 +97,39 @@ function theme_module_filter_system_modules_tabs($variables) { $toggle_enable = '
 
'; } $row[] = array('class' => array('checkbox'), 'data' => $toggle_enable . drupal_render($module['enable'])); + $label = ' array('name'), 'data' => $label . '>' . drupal_render($module['name']) . '
(' . $key . ')'); - $row[] = array('class' => array('version'), 'data' => drupal_render($module['version'])); - // Add the description, along with any modules it requires and any - // operation links. - $description = drupal_render($module['description']); - if ($module['#requires']) { - $description .= '
' . t('Requires: !module-list', array('!module-list' => implode(', ', $module['#requires']))) . '
'; + $row[] = array('class' => array('name'), 'data' => $label . '>' . drupal_render($module['name']) . ' (' . $key . ')'); + + if (variable_get('module_filter_version_column', 0) && $version) { + $row[] = array('class' => array('version'), 'data' => drupal_render($module['version'])); } - if ($module['#required_by']) { - $description .= '
' . t('Required by: !module-list', array('!module-list' => implode(', ', $module['#required_by']))) . '
'; + + // Add the description, along with any modules it requires. + if (empty($module['description']['#markup'])) { + $module['description']['#markup'] = '' . t('No description available.') . ''; } + $description = '' . drupal_render($module['description']) . ''; + if ($requires || $required_by || (!variable_get('module_filter_version_column', 0) && $version)) { + $description .= '
'; + if (!variable_get('module_filter_version_column', 0) && $version) { + $description .= '
' . t('Version: !module-version', array('!module-version' => drupal_render($module['version']))) . '
'; + } + if ($requires) { + $description .= '
' . t('Requires: !module-list', array('!module-list' => implode(', ', $module['#requires']))) . '
'; + } + if ($required_by) { + $description .= '
' . t('Required by: !module-list', array('!module-list' => implode(', ', $module['#required_by']))) . '
'; + } + $description .= '
'; + } + $row[] = array('data' => '
' . $description . '
', 'class' => array('description')); + $operations = (module_exists('ctools')) ? theme('module_filter_operations', array('links' => $module['links'], 'dropbutton' => TRUE)) : theme('module_filter_operations', array('links' => $module['links'])); - if (!empty($operations)) { - $description .= $operations; - } - $row[] = array('data' => $description, 'class' => array('description')); + $row[] = array('data' => '', 'class' => array('links')); $class = array(module_filter_get_id($package) . '-tab', 'module', $stripe); if (isset($recent_modules[$key])) { @@ -164,21 +146,20 @@ function theme_module_filter_system_modules_tabs($variables) { $form['modules'][$package]['#printed'] = TRUE; } - if (variable_get('module_filter_count_enabled', 1)) { - $enabled_counts = array(); - foreach ($enabled as $package_id => $value) { - $enabled_counts[$package_id] = array( - 'enabled' => count(array_filter($value)), - 'total' => count($value), - ); - } - drupal_add_js(array( - 'moduleFilter' => array( - 'packageIDs' => $package_ids, - 'enabledCounts' => $enabled_counts, - ) - ), 'setting'); + //Get packages and count number of modules + $enabled_counts = array(); + foreach ($enabled as $package_id => $value) { + $enabled_counts[$package_id] = array( + 'enabled' => count(array_filter($value)), + 'total' => count($value), + ); } + drupal_add_js(array( + 'moduleFilter' => array( + 'packageIDs' => $package_ids, + 'enabledCounts' => $enabled_counts, + ) + ), 'setting'); // Add first and last class to rows. $rows[0]['class'][] = 'first'; @@ -193,25 +174,34 @@ function theme_module_filter_system_modules_tabs($variables) { return $output; } +/** + * Theme function for module filter operations. + * @param $variables + * @return + * HTML for admin status operations. + */ function theme_module_filter_operations(&$vars) { $links = &$vars['links']; $dropbutton = $vars['dropbutton']; $operations = array(); - foreach (array('configure', 'permissions', 'help') as $key) { + foreach (element_children($links) as $key) { if ($dropbutton) { hide($links[$key]); if (!empty($links[$key]['#href'])) { - $operations[] = array( + $operations[$key] = array( 'title' => $links[$key]['#title'], 'href' => $links[$key]['#href'], ); + if (isset($links[$key]['#options'])) { + $operations[$key] += $links[$key]['#options']; + } } } else { $data = drupal_render($links[$key]); if (!empty($data)) { - $operations[] = array('data' => $data); + $operations[$key] = array('data' => $data); } } } diff --git a/sites/all/modules/uuid/composer.json b/sites/all/modules/uuid/composer.json new file mode 100644 index 0000000..306e496 --- /dev/null +++ b/sites/all/modules/uuid/composer.json @@ -0,0 +1,13 @@ +{ + "name": "drupal/uuid", + "description": "Extends the entity functionality and adds support for universally unique identifiers.", + "type": "drupal-module", + "license": "GPL-2.0+", + "minimum-stability": "dev", + "require-dev": { + "drupal/ctools": "1.x-dev", + "drupal/rest_server": "~3.0", + "drupal/services": "~3.0", + "drupal/entity": "~1.0" + } +} diff --git a/sites/all/modules/uuid/uuid.info b/sites/all/modules/uuid/uuid.info index cefaf29..08f429c 100644 --- a/sites/all/modules/uuid/uuid.info +++ b/sites/all/modules/uuid/uuid.info @@ -7,8 +7,8 @@ files[] = uuid.test dependencies[] = node dependencies[] = user -; Information added by Drupal.org packaging script on 2018-07-19 -version = "7.x-1.2" +; Information added by Drupal.org packaging script on 2019-05-29 +version = "7.x-1.3" core = "7.x" project = "uuid" -datestamp = "1531990689" +datestamp = "1559150887" diff --git a/sites/all/modules/uuid/uuid.test b/sites/all/modules/uuid/uuid.test index 6c1481a..26f3c83 100644 --- a/sites/all/modules/uuid/uuid.test +++ b/sites/all/modules/uuid/uuid.test @@ -6,11 +6,9 @@ */ /** - * UUID test helper trait. - * - * Contains methods that assist with running UUID tests. + * Base class with some helper methods. */ -trait UUIDTestHelper { +abstract class UUIDTestCase extends DrupalWebTestCase { /** * Helper function that asserts a UUID. @@ -21,15 +19,6 @@ trait UUIDTestHelper { } -/** - * Base class with some helper methods. - */ -abstract class UUIDTestCase extends DrupalWebTestCase { - - use UUIDTestHelper; - -} - /** * Tests the UUID API functions. */ @@ -488,8 +477,6 @@ class UUIDNodeTestCase extends UUIDTestCase { */ class UUIDCommentTestCase extends CommentHelperCase { - use UUIDTestHelper; - /** * {@inheritdoc} */ @@ -501,6 +488,13 @@ class UUIDCommentTestCase extends CommentHelperCase { ); } + /** + * Helper function that asserts a UUID. + */ + protected function assertUuid($uuid, $message = NULL) { + $this->assertTrue(uuid_is_valid($uuid), $message); + } + /** * Test CRUD on comments with UUID functions. */ @@ -559,8 +553,6 @@ class UUIDCommentTestCase extends CommentHelperCase { */ class UUIDTaxonomyTestCase extends TaxonomyWebTestCase { - use UUIDTestHelper; - /** * {@inheritdoc} */ @@ -588,6 +580,13 @@ class UUIDTaxonomyTestCase extends TaxonomyWebTestCase { parent::setUp($modules); } + /** + * Helper function that asserts a UUID. + */ + protected function assertUuid($uuid, $message = NULL) { + $this->assertTrue(uuid_is_valid($uuid), $message); + } + /** * Test CRUD on comments with UUID functions. */ diff --git a/sites/all/modules/uuid/uuid_path/uuid_path.info b/sites/all/modules/uuid/uuid_path/uuid_path.info index 77ad15c..e37d927 100644 --- a/sites/all/modules/uuid/uuid_path/uuid_path.info +++ b/sites/all/modules/uuid/uuid_path/uuid_path.info @@ -5,8 +5,8 @@ package = UUID dependencies[] = uuid -; Information added by Drupal.org packaging script on 2018-07-19 -version = "7.x-1.2" +; Information added by Drupal.org packaging script on 2019-05-29 +version = "7.x-1.3" core = "7.x" project = "uuid" -datestamp = "1531990689" +datestamp = "1559150887" diff --git a/sites/all/modules/uuid/uuid_services/uuid_services.info b/sites/all/modules/uuid/uuid_services/uuid_services.info index dd1ae42..65ddd3b 100644 --- a/sites/all/modules/uuid/uuid_services/uuid_services.info +++ b/sites/all/modules/uuid/uuid_services/uuid_services.info @@ -3,6 +3,8 @@ description = Provides integration with the Services module, like exposing a UUI core = 7.x package = Services - resources +files[] = uuid_services.user_services.test + dependencies[] = services dependencies[] = uuid dependencies[] = entity @@ -13,8 +15,8 @@ test_dependencies[] = file test_dependencies[] = field test_dependencies[] = file_entity -; Information added by Drupal.org packaging script on 2018-07-19 -version = "7.x-1.2" +; Information added by Drupal.org packaging script on 2019-05-29 +version = "7.x-1.3" core = "7.x" project = "uuid" -datestamp = "1531990689" +datestamp = "1559150887" diff --git a/sites/all/modules/uuid/uuid_services/uuid_services.module b/sites/all/modules/uuid/uuid_services/uuid_services.module index 5a0e628..eee362d 100644 --- a/sites/all/modules/uuid/uuid_services/uuid_services.module +++ b/sites/all/modules/uuid/uuid_services/uuid_services.module @@ -170,6 +170,13 @@ function _uuid_services_entity_update($entity_type, $uuid, $entity) { } } } + + // Sanitize user roles if user is not allowed to modify them. + if ($entity_type == 'user' && !empty($entity->roles) && !user_access('administer permissions')) { + $original_user = user_load(entity_get_id_by_uuid('user', array($entity->uuid))[$entity->uuid]); + $entity->roles = $original_user->roles; + } + entity_uuid_save($entity_type, $entity); return $entity; } @@ -194,7 +201,7 @@ function _uuid_services_entity_delete($entity_type, $uuid) { return TRUE; } - $return = entity_uuid_delete($entity_type, array($uuid)) !== FALSE; + $return = entity_uuid_delete($entity_type, $uuid) !== FALSE; return $return; } catch (Exception $exception) { diff --git a/sites/all/modules/uuid/uuid_services/uuid_services.user_services.test b/sites/all/modules/uuid/uuid_services/uuid_services.user_services.test new file mode 100644 index 0000000..b7f327c --- /dev/null +++ b/sites/all/modules/uuid/uuid_services/uuid_services.user_services.test @@ -0,0 +1,231 @@ + 'UUID User Services tests', + 'description' => 'Test the user services resource UUID methods and actions.', + 'group' => 'UUID', + ); + } + + /** + * {@inheritdoc} + */ + public function setUp() { + parent::setUp( + 'ctools', + 'services', + 'rest_server', + 'uuid_services' + ); + $this->endpoint = $this->saveNewEndpoint(); + } + + /** + * {@inheritdoc} + */ + public function saveNewEndpoint() { + $edit = $this->populateEndpointFAPI(); + $endpoint = new stdClass(); + $endpoint->disabled = FALSE; + $endpoint->api_version = 3; + $endpoint->name = $edit['name']; + $endpoint->server = $edit['server']; + $endpoint->path = $edit['path']; + $endpoint->authentication = array( + 'services' => 'services', + ); + $endpoint->server_settings = array( + 'formatters' => array( + 'json' => TRUE, + 'bencode' => TRUE, + 'rss' => TRUE, + 'plist' => TRUE, + 'xmlplist' => TRUE, + 'php' => TRUE, + 'yaml' => TRUE, + 'jsonp' => FALSE, + 'xml' => FALSE, + ), + 'parsers' => array( + 'application/x-yaml' => TRUE, + 'application/json' => TRUE, + 'application/vnd.php.serialized' => TRUE, + 'application/plist' => TRUE, + 'application/plist+xml' => TRUE, + 'application/x-www-form-urlencoded' => TRUE, + 'multipart/form-data' => TRUE, + ), + ); + $endpoint->resources = array( + 'user' => array( + 'operations' => array( + 'create' => array( + 'enabled' => 1, + ), + 'retrieve' => array( + 'enabled' => 1, + ), + 'update' => array( + 'enabled' => 1, + ), + 'delete' => array( + 'enabled' => 1, + ), + 'index' => array( + 'enabled' => 1, + ), + ), + ), + ); + $endpoint->debug = 1; + $endpoint->export_type = FALSE; + services_endpoint_save($endpoint); + $endpoint = services_endpoint_load($endpoint->name); + $this->assertTrue($endpoint->name == $edit['name'], 'Endpoint successfully created'); + return $endpoint; + } + + /** + * Tests user Retrieve. + */ + public function testUserRetrieve() { + $admin_user = $this->drupalCreateUser(array( + 'administer services', + 'administer users', + )); + $this->drupalLogin($admin_user); + $other_user = $this->drupalCreateUser(); + + // Verify user is found. + $response = $this->servicesGet($this->endpoint->path . '/user/' . $other_user->uuid); + $this->assertTrue($other_user->uuid == $response['body']->uuid, + 'Successfully received User info'); + } + + /** + * Tests user Update his own account. + */ + public function testUserUpdate() { + $admin_user = $this->drupalCreateUser(array( + 'administer services', + 'administer users', + 'administer permissions', + )); + $this->drupalLogin($admin_user); + + $other_user = $this->drupalCreateUser(); + $update = array( + 'uuid' => $other_user->uuid, + 'roles' => array( + '2' => 'authenticated user', + '3' => 'administrator', + ), + ); + $this->servicesPut($this->endpoint->path . '/user/' . $other_user->uuid, $update); + $user_after_update = user_load($other_user->uid, TRUE); + $this->assertTrue(in_array('administrator', $user_after_update->roles), 'Administrator role successfully added'); + } + + /** + * Tests user Update another account fail with no permissions. + */ + public function testUserUpdatePermFail() { + $user = $this->drupalCreateUser(); + $this->drupalLogin($user); + + $other_user = $this->drupalCreateUser(); + + $update = array( + 'uuid' => $other_user->uuid, + 'name' => 'test_edit', + 'roles' => array( + '2' => 'authenticated user', + '3' => 'administrator', + ), + ); + $response = $this->servicesPut($this->endpoint->path . '/user/' . $other_user->uuid, $update); + $user_after_update = user_load($other_user->uid, TRUE); + $this->assertNotEqual($update['name'], $user_after_update->name, 'User name was not updated without the needed permissions'); + $this->assertFalse(in_array('administrator', $user_after_update->roles), 'Administrator role was not added without the needed permissions'); + $this->assertTrue($response['code'] == 403, + 'Updating the user failed without the needed permissions'); + } + + /** + * Tests user Update his own account fail with no permissions. + */ + public function testUserOwnUpdatePermFail() { + $user = $this->drupalCreateUser([ + 'access user profiles', + ]); + $this->drupalLogin($user); + $user = user_load($user->uid, TRUE); + + $update = array( + 'uuid' => $user->uuid, + 'roles' => array( + '2' => 'authenticated user', + '3' => 'administrator', + ), + ); + $this->servicesPut($this->endpoint->path . '/user/' . $user->uuid, $update); + $user_after_update = user_load($user->uid, TRUE); + $this->assertFalse(in_array('administrator', $user_after_update->roles), 'Administrator role was not added without the needed permissions'); + $this->assertEqual($user->roles, $user_after_update->roles, 'Existing roles persist after update.'); + } + + /** + * Tests user Delete. + */ + public function testUserDelete() { + $admin_user = $this->drupalCreateUser(array( + 'administer services', + 'administer users', + )); + $this->drupalLogin($admin_user); + + $other_user = $this->drupalCreateUser(); + + $this->servicesDelete($this->endpoint->path . '/user/' . $other_user->uuid); + $user_after_update = user_load($other_user->uid, TRUE); + $this->assertTrue(empty($user_after_update), 'User was deleted'); + } + + /** + * Tests user Delete fail with no permissions. + */ + public function testUserDeletePermFail() { + $user = $this->drupalCreateUser(); + $this->drupalLogin($user); + + $other_user = $this->drupalCreateUser(); + + $response = $this->servicesDelete($this->endpoint->path . '/user/' . $other_user->uuid); + $user_after_update = user_load($other_user->uid, TRUE); + $this->assertTrue(!empty($user_after_update), 'User was not deleted without the needed permissions'); + $this->assertTrue($response['code'] == 403, + 'Deleting the user failed without the needed permissions'); + } + +} diff --git a/sites/all/modules/uuid/uuid_services_example/uuid_services_example.info b/sites/all/modules/uuid/uuid_services_example/uuid_services_example.info index 5874051..f8e88d1 100644 --- a/sites/all/modules/uuid/uuid_services_example/uuid_services_example.info +++ b/sites/all/modules/uuid/uuid_services_example/uuid_services_example.info @@ -11,8 +11,8 @@ features[ctools][] = services:services:3 features[features_api][] = api:2 features[services_endpoint][] = uuid_services_example -; Information added by Drupal.org packaging script on 2018-07-19 -version = "7.x-1.2" +; Information added by Drupal.org packaging script on 2019-05-29 +version = "7.x-1.3" core = "7.x" project = "uuid" -datestamp = "1531990689" +datestamp = "1559150887" diff --git a/sites/all/modules/views/css/ie/views-admin.ie7.css b/sites/all/modules/views/css/ie/views-admin.ie7.css index 9a8852a..417a28a 100644 --- a/sites/all/modules/views/css/ie/views-admin.ie7.css +++ b/sites/all/modules/views/css/ie/views-admin.ie7.css @@ -17,7 +17,7 @@ /** * IE7 has no idea how large this container should be and it doesn't - * apply has-layout. Expand it's width to 100% and trigger has-layout. + * apply has-layout. Expand its width to 100% and trigger has-layout. */ .views-edit-view .views-displays { height: 1%; diff --git a/sites/all/modules/views/css/views-admin.bartik-rtl.css b/sites/all/modules/views/css/views-admin.bartik-rtl.css index abf2a30..7075978 100644 --- a/sites/all/modules/views/css/views-admin.bartik-rtl.css +++ b/sites/all/modules/views/css/views-admin.bartik-rtl.css @@ -3,7 +3,7 @@ * in the Bartik theme. */ - /* @group Lists */ +/* @group Lists */ .views-display-top .secondary .action-list { padding-right: 0; diff --git a/sites/all/modules/views/css/views-admin.bartik.css b/sites/all/modules/views/css/views-admin.bartik.css index c6f0692..d5cfeb6 100644 --- a/sites/all/modules/views/css/views-admin.bartik.css +++ b/sites/all/modules/views/css/views-admin.bartik.css @@ -42,7 +42,7 @@ } .views-displays .secondary .open > a:hover { - color: #0071B3; + color: #0071b3; } .views-displays .secondary input.form-submit { @@ -57,7 +57,7 @@ */ .views-filterable-options .even .form-type-checkbox { - background-color: #F9F9F9; + background-color: #f9f9f9; } .views-ui-dialog .ui-dialog-titlebar-close, @@ -83,29 +83,28 @@ /* @group Buttons */ .ctools-button-processed { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; @@ -114,29 +113,28 @@ } .ctools-button-processed:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(241, 241, 241, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(241, 241, 241, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); } .ctools-button-processed li a, @@ -150,29 +148,28 @@ } .ctools-dropbutton-processed.open:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); } .ctools-dropbutton-processed.open { @@ -220,12 +217,12 @@ } .views-ui-display-tab-actions .ctools-button input { - color: #0071B3; + color: #0071b3; } .views-ui-display-tab-actions .ctools-button input:hover, .views-ui-display-tab-actions .ctools-button input:focus { - color: #018FE2; + color: #018fe2; } /* @end */ diff --git a/sites/all/modules/views/css/views-admin.css b/sites/all/modules/views/css/views-admin.css index 7ce7088..6a1603f 100644 --- a/sites/all/modules/views/css/views-admin.css +++ b/sites/all/modules/views/css/views-admin.css @@ -117,12 +117,12 @@ * * The tabs that switch between sections */ - .views-displays .secondary { - border-bottom: 0 none; - margin: 0; - overflow: visible; - padding: 0; - } +.views-displays .secondary { + border-bottom: 0 none; + margin: 0; + overflow: visible; + padding: 0; +} .views-displays .secondary > li { border-right: 0 none; @@ -312,9 +312,7 @@ div.form-item-options-value-all { /* @end */ - - -/* @group Javascript dependent styling */ +/* @group JavaScript dependent styling */ .js-only { display: none; diff --git a/sites/all/modules/views/css/views-admin.ctools-rtl.css b/sites/all/modules/views/css/views-admin.ctools-rtl.css index 338b2fb..7fc8649 100644 --- a/sites/all/modules/views/css/views-admin.ctools-rtl.css +++ b/sites/all/modules/views/css/views-admin.ctools-rtl.css @@ -10,7 +10,7 @@ } .ctools-dropbutton .ctools-link { - border-right: 1px solid #ffffff; + border-right: 1px solid #fff; } .ctools-dropbutton li { diff --git a/sites/all/modules/views/css/views-admin.ctools.css b/sites/all/modules/views/css/views-admin.ctools.css index b1f0e29..4c994ce 100644 --- a/sites/all/modules/views/css/views-admin.ctools.css +++ b/sites/all/modules/views/css/views-admin.ctools.css @@ -1,8 +1,8 @@ /* @group Buttons */ .ctools-button-processed { - background-color: #ffffff; - border-color: #cccccc; + background-color: #fff; + border-color: #ccc; font-size: 11px; padding-bottom: 2px; padding-top: 2px; @@ -46,7 +46,7 @@ } .ctools-dropbutton-processed.open:hover { - border-color: #D0D0D0; + border-color: #d0d0d0; } .ctools-dropbutton-processed.open { @@ -54,11 +54,11 @@ } .ctools-dropbutton-processed .ctools-link { - border-left: 1px solid #ffffff; + border-left: 1px solid #fff; } .ctools-dropbutton-processed.open .ctools-content { - padding-bottom: 4px; + padding-bottom: 4px; } .ctools-dropbutton-processed li a, @@ -132,7 +132,7 @@ .ctools-toggle.ctools-toggle-collapsed { border-bottom-color: transparent; - border-left: 4px solid; + border-left: 4px solid; border-right-color: transparent; border-top-color: transparent; border-width: 5px 0 5px 5px; @@ -158,7 +158,7 @@ } .views-display-settings .ctools-toggle { - color: #000000; + color: #000; } .views-display-column > .ctools-toggle { @@ -173,7 +173,7 @@ } .views-display-column > .ctools-collapsible-handle { - border-color: #F3F3F3; + border-color: #f3f3f3; border-style: solid; border-width: 1px 1px 0; font-size: 13px; @@ -225,7 +225,7 @@ h2.ctools-collapsible-handle { /* @group Jump list */ -#views-live-preview .ctools-jump-menu-select{ +#views-live-preview .ctools-jump-menu-select { max-width: 450px; } diff --git a/sites/all/modules/views/css/views-admin.garland-rtl.css b/sites/all/modules/views/css/views-admin.garland-rtl.css index 9a8de6d..99a761e 100644 --- a/sites/all/modules/views/css/views-admin.garland-rtl.css +++ b/sites/all/modules/views/css/views-admin.garland-rtl.css @@ -3,11 +3,11 @@ * in the Garland theme. */ - /* @group Lists */ +/* @group Lists */ .views-displays .secondary .action-list { left: auto; right: 1px; } - /* @end */ +/* @end */ diff --git a/sites/all/modules/views/css/views-admin.garland.css b/sites/all/modules/views/css/views-admin.garland.css index cd9010a..dc2734f 100644 --- a/sites/all/modules/views/css/views-admin.garland.css +++ b/sites/all/modules/views/css/views-admin.garland.css @@ -54,7 +54,7 @@ .views-displays .secondary .open > a:hover { border-color: #e9e9e9 #e9e9e9 #f1f1f1 #e9e9e9; border-width: 1px 1px 1px 1px; - color: #0071B3; + color: #0071b3; } .views-displays .secondary input.form-submit { @@ -84,7 +84,7 @@ } .views-filterable-options .even .form-type-checkbox { - background-color: #F9F9F9; + background-color: #f9f9f9; } .views-ui-dialog .ui-dialog-titlebar-close, @@ -101,29 +101,28 @@ /* @group Buttons */ .ctools-button-processed { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; @@ -132,29 +131,28 @@ } .ctools-button-processed:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(241, 241, 241, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(241, 241, 241, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); } .ctools-button-processed ol li, @@ -172,29 +170,28 @@ } .ctools-dropbutton-processed.open:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); } .ctools-dropbutton-processed.open { @@ -249,13 +246,13 @@ } .views-ui-display-tab-actions .ctools-button input { - color: #027AC6; + color: #027ac6; font-size: 12px; } .views-ui-display-tab-actions .ctools-button input:hover, .views-ui-display-tab-actions .ctools-button input:focus { - color: #0062A0; + color: #0062a0; } /* @end */ diff --git a/sites/all/modules/views/css/views-admin.seven.css b/sites/all/modules/views/css/views-admin.seven.css index d58bb1b..3f879a2 100644 --- a/sites/all/modules/views/css/views-admin.seven.css +++ b/sites/all/modules/views/css/views-admin.seven.css @@ -213,14 +213,14 @@ fieldset.fieldset-no-legend { /* Override for input elements that are themed like ctools-buttons */ .ctools-button-processed input.form-submit:hover { background-image: none; - color: #0074BD; + color: #0074bd; text-shadow: none; } .ctools-button-processed input.form-submit:active { background: none; border: medium none; - color: #0074BD; + color: #0074bd; text-shadow: none; } @@ -238,7 +238,7 @@ table th { /* @group Attachment details */ #edit-display-settings-title { - color: #008BCB; + color: #008bcb; } /* @end */ @@ -249,11 +249,11 @@ table th { */ .views-displays .secondary { - text-align: left; /* LTR */ + text-align: left; /* LTR */ } .views-displays .secondary > li:first-child { - padding-left: 0; + padding-left: 0; } .views-admin .icon.add { @@ -265,7 +265,7 @@ table th { -moz-border-radius: 7px; -webkit-border-radius: 7px; border-radius: 7px; - color: #008BCB; + color: #008bcb; } .views-displays .secondary a:hover > .icon.add { @@ -280,7 +280,7 @@ table th { .views-displays .secondary .open > a:hover { background-color: #f1f1f1; - color: #008BCB; + color: #008bcb; } .views-displays .secondary .action-list li:first-child { @@ -299,7 +299,7 @@ table th { -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; - color: #008BCB; + color: #008bcb; } /* @end */ @@ -349,11 +349,11 @@ table th { } #views-ui-rearrange-filter-form tr.drag td { - background-color: #FFEE77 !important; + background-color: #ffee77 !important; } #views-ui-rearrange-filter-form tr.drag-previous td { - background-color: #FFFFBB !important; + background-color: #ffffbb !important; } /* @end */ @@ -402,7 +402,7 @@ table th { -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; - border-color: #cccccc; + border-color: #ccc; right: -27px; top: -1px; } @@ -429,84 +429,81 @@ table th { /* @group Buttons */ .ctools-button-processed { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); -moz-border-radius: 11px 11px 11px 11px; -webkit-border-radius: 11px 11px 11px 11px; border-radius: 11px 11px 11px 11px; } .ctools-button-processed:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(241, 241, 241, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(241, 241, 241, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); } .ctools-dropbutton-processed.open:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); } .ctools-dropbutton-processed.open { @@ -528,7 +525,7 @@ table th { } .views-display-settings .ctools-toggle { - color: #008BCB; + color: #008bcb; } .views-display-column > .ctools-toggle { @@ -540,11 +537,11 @@ table th { } .views-display-column > .ctools-collapsible-handle { - color: #008BCB; + color: #008bcb; } .views-ui-display-tab-actions .ctools-button-processed input { - color: #0074BD; + color: #0074bd; } /* @end */ diff --git a/sites/all/modules/views/css/views-admin.theme.css b/sites/all/modules/views/css/views-admin.theme.css index 8611783..d92a47e 100644 --- a/sites/all/modules/views/css/views-admin.theme.css +++ b/sites/all/modules/views/css/views-admin.theme.css @@ -39,35 +39,34 @@ .views-admin .icon, .views-admin .icon-text { background-attachment: scroll; - background-image: url("../images/sprites.png"); + background-image: url('../images/sprites.png'); background-position: left top; /* LTR */ background-repeat: no-repeat; } .views-admin a.icon { - background-image: - url("../images/sprites.png"), - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #e8e8e8 100%); - background-image: - url("../images/sprites.png"), - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(232, 232, 232, 1.0)) - ); - background-image: - url("../images/sprites.png"), - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #e8e8e8 100%); + background-image: url('../images/sprites.png'), + -moz-linear-gradient( + -90deg, + #fff 0px, + #e8e8e8 100% + ); + background-image: url('../images/sprites.png'), + -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(232, 232, 232, 1.0)) + ); + background-image: url('../images/sprites.png'), + -webkit-linear-gradient( + -90deg, + #fff 0px, + #e8e8e8 100% + ); background-repeat: no-repeat, repeat-y; - border: 1px solid #dddddd; + border: 1px solid #ddd; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; @@ -206,7 +205,7 @@ input.form-radio { /* Hide 'remove' checkboxes. */ .views-remove-checkbox { - display: none; + display: none; } /* sizes the labels of checkboxes and radio button to the height of the text */ @@ -406,13 +405,13 @@ td.group-title { /* @group Attachments */ .views-displays { - border: 1px solid #CCC; + border: 1px solid #ccc; padding-bottom: 36px; } .views-display-top { - background-color: #F9F9F9; - border-bottom: 1px solid #CCCCCC; + background-color: #f9f9f9; + border-bottom: 1px solid #ccc; padding: 8px 8px 8px; /* LTR */ position: relative; } @@ -453,7 +452,7 @@ ul#views-display-menu-tabs li { margin-bottom: 5px; } -ul#views-display-menu-tabs li.add ul.action-list li{ +ul#views-display-menu-tabs li.add ul.action-list li { margin: 0; } @@ -470,7 +469,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ */ .views-displays ul.secondary li.active a.active.error, .views-displays .secondary a.error { - border: 2px solid #ED541D; + border: 2px solid #ed541d; padding: 1px 6px; } @@ -480,8 +479,8 @@ ul#views-display-menu-tabs li.add ul.action-list li{ .views-displays .secondary a:hover, .views-displays .secondary .active a { - background-color: #666666; - color: #ffffff; + background-color: #666; + color: #fff; border-bottom-width: 1px; } @@ -523,7 +522,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } .views-displays .secondary .action-list li:hover { - background-color: #dddddd; + background-color: #ddd; } /* @end */ @@ -556,10 +555,10 @@ ul#views-display-menu-tabs li.add ul.action-list li{ */ .views-display-column + .views-display-column { - margin-top: 0; - } + margin-top: 0; +} - /* @end */ +/* @end */ /* @group Auto preview * @@ -683,7 +682,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ */ .views-ui-display-tab-bucket .views-display-setting { - color: #666666; + color: #666; font-size: 12px; padding-bottom: 2px; } @@ -753,8 +752,8 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } .views-ui-dialog .ui-dialog-titlebar-close { - background: url("../images/close.png") no-repeat scroll 6px 3px #F3F4EE; - border-color: #aaaaaa; + background: url('../images/close.png') no-repeat scroll 6px 3px #f3f4ee; + border-color: #aaa; -moz-border-radius: 0 10px 12px 0; -webkit-border-radius: 0 10px 12px 0; border-radius: 0 10px 12px 0; @@ -774,17 +773,17 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } .views-filterable-options .form-type-checkbox { - border: 1px solid #CCC; + border: 1px solid #ccc; padding: 5px 8px; border-top: none; } .views-filterable-options { - border-top: 1px solid #CCC; + border-top: 1px solid #ccc; } .views-filterable-options .even .form-type-checkbox { - background-color: #F3F4EE; + background-color: #f3f4ee; } .filterable-option .form-item { @@ -830,7 +829,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ .views-ui-dialog #views-ajax-title, .views-ui-dialog .views-override { - background-color: #F3F4EE; + background-color: #f3f4ee; } .views-ui-dialog .views-override { @@ -862,7 +861,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } .views-ui-dialog .scroll { - border: 1px solid #CCC; + border: 1px solid #ccc; border-width: 1px 0; padding: 8px 13px; } @@ -872,7 +871,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } .views-ui-dialog .form-buttons { - background-color: #F3F4EE; + background-color: #f3f4ee; padding: 8px 13px; } .views-ui-dialog .form-buttons input { @@ -888,7 +887,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ /* @todo Make this a class to be used anywhere there's node types? */ .form-type-checkboxes #edit-options-value, .form-type-checkboxes #edit-options-validate-options-node-types { - border-color: #CCCCCC; + border-color: #ccc; border-style: solid; border-width: 1px; max-height: 210px; @@ -907,25 +906,25 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } #views-ui-rearrange-filter-form tr td[rowspan] { - border-color: #CDCDCD; + border-color: #cdcdcd; border-style: solid; border-width: 0 1px 1px 1px; } #views-ui-rearrange-filter-form tr[id^="views-row"] { - border-right: 1px solid #CDCDCD; + border-right: 1px solid #cdcdcd; } #views-ui-rearrange-filter-form tr[id^="views-row"].even td { - background-color: #F3F4ED; + background-color: #f3f4ed; } #views-ui-rearrange-filter-form .views-group-title { - border-top: 1px solid #CDCDCD; + border-top: 1px solid #cdcdcd; } #views-ui-rearrange-filter-form .group-empty { - border-bottom: 1px solid #CDCDCD; + border-bottom: 1px solid #cdcdcd; } /* @end */ @@ -945,8 +944,8 @@ ul#views-display-menu-tabs li.add ul.action-list li{ /* @group Live preview elements */ #views-preview-wrapper { - border: 1px solid #CCC; - border-top: 2px solid #CCC; + border: 1px solid #ccc; + border-top: 2px solid #ccc; padding-bottom: 12px; padding-top: 12px; } @@ -979,7 +978,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } #views-live-preview .preview-section { - border: 1px dashed #DEDEDE; + border: 1px dashed #dedede; margin: 0 -5px; padding: 3px 5px; } @@ -997,7 +996,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ .views-query-info table { border-collapse: separate; - border-color: #dddddd; + border-color: #ddd; border-spacing: 0; margin: 10px 0; } @@ -1008,7 +1007,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ .views-query-info table th, .views-query-info table td { - color: #666666; + color: #666; padding: 4px 10px; } @@ -1058,7 +1057,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ .ajax-progress-throbber { background-color: #232323; - background-image: url("../images/loading-small.gif"); + background-image: url('../images/loading-small.gif'); background-position: center center; background-repeat: no-repeat; -moz-border-radius: 7px; diff --git a/sites/all/modules/views/css/views-rtl.css b/sites/all/modules/views/css/views-rtl.css index f804639..0c0c0e0 100644 --- a/sites/all/modules/views/css/views-rtl.css +++ b/sites/all/modules/views/css/views-rtl.css @@ -1,4 +1,3 @@ - .views-exposed-form .views-exposed-widget { float: right; /* RTL */ padding: .5em 1em 0 0; /* RTL */ diff --git a/sites/all/modules/views/drush/views.drush.inc b/sites/all/modules/views/drush/views.drush.inc index eb2ecc2..a3954b8 100644 --- a/sites/all/modules/views/drush/views.drush.inc +++ b/sites/all/modules/views/drush/views.drush.inc @@ -2,14 +2,15 @@ /** * @file - * Drush integration of views. + * Drush integration for Views. * - * drush cache-clear views - Clears the views specific caches. - * views-revert - Drush command to revert views overridden in the system. + * Useful commands: + * - drush cache-clear views - Clears the views specific caches. + * - views-revert - Drush command to revert views overridden in the system. */ /** - * Implement hook_drush_help(). + * Implements hook_drush_help(). */ function views_drush_help($section) { switch ($section) { @@ -18,17 +19,20 @@ function views_drush_help($section) { $help .= dt('If no view names are specified, you will be presented with a list of overridden views to choose from. '); $help .= dt('To revert all views, do not specify any view names, and choose the option "All" from the options presented.'); return $help; + case 'drush:views-list': return dt('Show a list of available views with information about them.'); + case 'drush:views-enable': return dt('Enable the specified views. Follow the command with a space delimited list of view names'); + case 'drush:views-disable': return dt('Disable the specified views. Follow the command with a space delimited list of view names'); } } /** - * Implement hook_drush_command(). + * Implements hook_drush_command(). */ function views_drush_command() { $items = array(); @@ -70,7 +74,7 @@ function views_drush_command() { 'tags' => 'A comma-separated list of views tags by which to filter the results.', 'status' => 'Status of the views by which to filter the results. Choices: enabled, disabled.', 'type' => 'Type of the views by which to filter the results. Choices: normal, default or overridden.', - ), + ), 'examples' => array( 'drush vl' => 'Show a list of all available views.', 'drush vl --name=blog' => 'Show a list of views which names contain "blog".', @@ -115,10 +119,11 @@ function views_drush_command() { * Callback function for views-revert command. */ function views_revert_views() { + $args = func_get_args(); + // The provided views names specified in the command. + $viewnames = _convert_csv_to_array($args); $views = views_get_all_views(); $i = 0; - // The provided views names specified in the command. - $viewnames = _convert_csv_to_array(func_get_args()); // Find all overridden views. foreach ($views as $view) { @@ -143,10 +148,10 @@ function views_revert_views() { // If the user specified a list of views on the CLI, revert those. elseif (!empty($viewnames)) { foreach ($viewnames as $key => $viewname) { - $is_overridden = key_exists($viewname, $overridden); + $is_overridden = array_key_exists($viewname, $overridden); - // Check if the provided view name is in the system - if ($viewname && !key_exists($viewname, $views)) { + // Check if the provided view name is in the system. + if ($viewname && !array_key_exists($viewname, $views)) { drush_set_error(dt("'@viewname' view is not present in the system.", array('@viewname' => $viewname))); } // Check if the provided view is overridden. @@ -158,7 +163,7 @@ function views_revert_views() { views_revert_view($views[$viewname]); $i++; } - // We should never get here but well... + // We should never get here but well. else { drush_set_error(dt( "The view specified '@viewname' is not provided in code, and thus cannot be reverted.", @@ -168,19 +173,20 @@ function views_revert_views() { } } - // The user neither selected the "--all" option, nor provided a list of views to revert. - // Prompt the user. + // The user neither selected the "--all" option, nor provided a list of views + // to revert. Prompt the user. else { - // list of choices for the user - $overridden['all'] = dt('Revert all overridden views'); // add a choice at the end - $choice = drush_choice($overridden, 'Enter a number to choose which view to revert.', '!key'); // prompt the user - + // List of choices for the user. + $overridden['all'] = dt('Revert all overridden views'); + // Add a choice at the end. + $choice = drush_choice($overridden, 'Enter a number to choose which view to revert.', '!key'); + // Prompt the user. if ($choice !== FALSE) { - // revert all views option + // Revert all views option. if ($choice == 'all') { $i = views_revert_allviews($views); } - // else the user specified a single view + // Else the user specified a single view. else { views_revert_view($views[$choice]); $i++; @@ -189,7 +195,7 @@ function views_revert_views() { } - // final results output + // Final results output. if ($i == 0) { drush_log(dt('No views were reverted.'), 'ok'); } @@ -199,9 +205,10 @@ function views_revert_views() { } /** - * Reverts all views - * @param $views - * All views in the system as provided by views_get_all_views(). + * Reverts all views. + * + * @param array $views + * All views in the system as provided by views_get_all_views(). */ function views_revert_allviews($views) { $i = 0; @@ -219,15 +226,17 @@ function views_revert_allviews($views) { } /** - * Revert a specified view - * @param $view - * The view object to be reverted + * Revert a specified view. * - * Checks on wether or not the view is overridden is handled in views_revert_views_revert() - * We perform a check here anyway in case someone somehow calls this function on their own... + * Checks on wether or not the view is overridden is handled in + * views_revert_views_revert(). We perform a check here anyway in case someone + * somehow calls this function on their own... + * + * @param object $view + * The view object to be reverted. */ function views_revert_view($view) { - // check anyway just in case + // Check anyway just in case. if ($view->type == t('Overridden')) { // Revert the view. $view->delete(); @@ -269,7 +278,7 @@ function views_development_settings() { * Callback function for views-list command. */ function drush_views_list() { - // Initialize stuf + // Initialize stuff. $rows = array(); $disabled_views = array(); $enabled_views = array(); @@ -281,19 +290,18 @@ function drush_views_list() { $views = views_get_all_views(); - // get the --name option - // TODO : take into account the case off a comma-separated list of names + // Get the --name option. + // @todo Take into account the case off a comma-separated list of names. $name = drush_get_option_list('name'); $with_name = !empty($name) ? TRUE : FALSE; - // get the --tags option + // Get the --tags option. $tags = drush_get_option_list('tags'); $with_tags = !empty($tags) ? TRUE : FALSE; - // get the --status option - // store user input appart to reuse it after + // Get the --status option. Store user input appart to reuse it after. $status_opt = drush_get_option_list('status'); - // use the same logic than $view->disabled + // Use the same logic than $view->disabled. if (in_array('disabled', $status_opt)) { $status = TRUE; $with_status = TRUE; @@ -304,19 +312,19 @@ function drush_views_list() { } else { $status = NULL; - // wrong or empty --status option + // Wrong or empty --status option. $with_status = FALSE; } - // get the --type option + // Get the --type option. $type = drush_get_option_list('type'); - // use the same logic than $view->type + // Use the same logic than $view->type. $with_type = FALSE; if (in_array('normal', $type) || in_array('default', $type)|| in_array('overridden', $type)) { $with_type = TRUE; } - // set the table headers + // Set the table headers. $header = array( dt('Machine name'), dt('Description'), @@ -325,10 +333,10 @@ function drush_views_list() { dt('Tag'), ); - // setup a row for each view - foreach($views as $id => $view){ - // if options were specified, check that first - // mismatch push the loop to the next view + // Setup a row for each view. + foreach ($views as $id => $view) { + // If options were specified, check that first mismatch push the loop to + // the next view. if ($with_tags && !in_array($view->tag, $tags)) { continue; } @@ -343,25 +351,25 @@ function drush_views_list() { } $row = array(); - // each row entry should be in the same order as the header + // Each row entry should be in the same order as the header. $row[] = $view->name; $row[] = $view->description; $row[] = $view->type; $row[] = $view->disabled ? dt('Disabled') : dt('Enabled'); $row[] = $view->tag; - // place the row in the appropiate array, - // so we can have disabled views at the bottom - if($view->disabled) { + // Place the row in the appropiate array so we can have disabled views at + // the bottom. + if ($view->disabled) { $disabled_views[] = $row; - } - else{ + } + else { $enabled_views[] = $row; } unset($row); - // gather some statistics - switch($view->type) { + // Gather some statistics. + switch ($view->type) { case dt('Normal'): $indb++; break; @@ -379,11 +387,11 @@ function drush_views_list() { $disabled = count($disabled_views); - // sort alphabeticaly + // Sort alphabeticaly. asort($disabled_views); asort($enabled_views); - // if options were used + // If options were used. $summary = ""; if ($with_name || $with_tags || $with_status || $with_type) { $summary = "Views"; @@ -412,23 +420,26 @@ function drush_views_list() { drush_print($summary . "\n"); } - // print all rows as a table + // Print all rows as a table. if ($total > 0) { $rows = array_merge($enabled_views, $disabled_views); - // put the headers as first row + // Put the headers as first row. array_unshift($rows, $header); drush_print_table($rows, TRUE); } - // print the statistics messages + // Print the statistics messages. drush_print(dt("A total of @total views were found in this Drupal installation:", array('@total' => $total))); - drush_print(dt(" @indb views reside only in the database", array('@indb' => $indb ))); + drush_print(dt(" @indb views reside only in the database", array('@indb' => $indb))); drush_print(dt(" @over views are overridden", array('@over' => $overridden))); drush_print(dt(" @incode views are in their default state", array('@incode' => $incode))); drush_print(dt(" @dis views are disabled\n", array('@dis' => $disabled))); } +/** + * Analyze all installed views. + */ function drush_views_analyze() { views_include('analyze'); $messages_count = 0; @@ -440,7 +451,7 @@ function drush_views_analyze() { drush_print($view_name); foreach ($messages as $message) { $messages_count++; - drush_print($message['type'] .': '. $message['message'], 2); + drush_print($message['type'] . ': ' . $message['message'], 2); } } } @@ -448,7 +459,7 @@ function drush_views_analyze() { } /** - * Enables views + * Enables views. */ function drush_views_enable() { $viewnames = _convert_csv_to_array(func_get_args()); @@ -460,7 +471,7 @@ function drush_views_enable() { } /** - * Disables views + * Disables views. */ function drush_views_disable() { $viewnames = _convert_csv_to_array(func_get_args()); @@ -472,9 +483,12 @@ function drush_views_disable() { } /** - * Helper function to enable / disable views - * @param $viewnames: array of viewnames to process - * @param $status: TRUE to disable or FALSE to enable the view + * Helper function to enable / disable views. + * + * @param array $viewnames + * Names of the views to process. + * @param bool $status + * TRUE to disable or FALSE to enable the view. */ function _views_drush_changestatus($viewnames = array(), $status = NULL) { if ($status !== NULL && !empty($viewnames)) { @@ -492,7 +506,7 @@ function _views_drush_changestatus($viewnames = array(), $status = NULL) { drush_set_error(dt("The view '!name' is already !processed", array('!name' => $viewname, '!processed' => $processed))); } } - // If we made changes to views status, save them and clear caches + // If we made changes to views status, save them and clear caches. if ($changed) { variable_set('views_defaults', $views_status); views_invalidate_cache(); @@ -504,6 +518,9 @@ function _views_drush_changestatus($viewnames = array(), $status = NULL) { /** * Adds a cache clear option for views. + * + * @param array $types + * The list of cache types that are available. */ function views_drush_cache_clear(&$types) { $types['views'] = 'views_invalidate_cache'; diff --git a/sites/all/modules/views/handlers/views_handler_area.inc b/sites/all/modules/views/handlers/views_handler_area.inc index 9fed11c..95f51a1 100644 --- a/sites/all/modules/views/handlers/views_handler_area.inc +++ b/sites/all/modules/views/handlers/views_handler_area.inc @@ -2,7 +2,7 @@ /** * @file - * Views area handlers. + * Definition of views_handler_area and views_handler_area_broken. */ /** @@ -20,29 +20,31 @@ class views_handler_area extends views_handler { /** - * Overrides views_handler::init(). - * - * Make sure that no result area handlers are set to be shown when the result - * is empty. + * {@inheritdoc} */ - function init(&$view, &$options) { + public function init(&$view, &$options) { parent::init($view, $options); + // Make sure that no result area handlers are set to be shown when the + // result is empty. if ($this->handler_type == 'empty') { $this->options['empty'] = TRUE; } } /** - * Get this field's label. + * {@inheritdoc} */ - function label() { + public function label() { if (!isset($this->options['label'])) { return $this->ui_name(); } return $this->options['label']; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : ''; @@ -54,17 +56,17 @@ class views_handler_area extends views_handler { } /** - * Provide extra data to the administration form + * Provide extra data to the administration form. */ - function admin_summary() { + public function admin_summary() { return $this->label(); } /** - * Default options form that provides the label widget that all fields - * should have. + * Default options form that provides the label widget that all fields should + * have. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['label'] = array( '#type' => 'textfield', @@ -83,23 +85,25 @@ class views_handler_area extends views_handler { } /** - * Don't run a query + * Don't run a query. */ - function query() { } + public function query() { + } /** - * Render the area + * Render the area. */ - function render($empty = FALSE) { + public function render($empty = FALSE) { return ''; } /** * Area handlers shouldn't have groupby. */ - function use_group_by() { + public function use_group_by() { return FALSE; } + } /** @@ -108,14 +112,39 @@ class views_handler_area extends views_handler { * @ingroup views_area_handlers */ class views_handler_area_broken extends views_handler_area { - function ui_name($short = FALSE) { + + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return t('Broken/missing handler'); } - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function render($empty = FALSE) { return ''; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function ensure_my_table() { + // No table to ensure! + } + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { + // No query to run. + } + + /** + * {@inheritdoc} + */ + public function render($empty = FALSE) { + return ''; + } + + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['markup'] = array( '#prefix' => '
', '#value' => t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.'), @@ -123,9 +152,12 @@ class views_handler_area_broken extends views_handler_area { } /** - * Determine if the handler is considered 'broken' + * {@inheritdoc} */ - function broken() { return TRUE; } + public function broken() { + return TRUE; + } + } /** diff --git a/sites/all/modules/views/handlers/views_handler_area_messages.inc b/sites/all/modules/views/handlers/views_handler_area_messages.inc index eb1e22a..2c8bd49 100644 --- a/sites/all/modules/views/handlers/views_handler_area_messages.inc +++ b/sites/all/modules/views/handlers/views_handler_area_messages.inc @@ -2,7 +2,7 @@ /** * @file - * Contains views_handler_area_messages. + * Definition of views_handler_area_messages. */ /** diff --git a/sites/all/modules/views/handlers/views_handler_area_result.inc b/sites/all/modules/views/handlers/views_handler_area_result.inc index 9c6f875..6c98c0e 100644 --- a/sites/all/modules/views/handlers/views_handler_area_result.inc +++ b/sites/all/modules/views/handlers/views_handler_area_result.inc @@ -12,7 +12,10 @@ */ class views_handler_area_result extends views_handler_area { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['content'] = array( @@ -23,7 +26,10 @@ class views_handler_area_result extends views_handler_area { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $variables = array( 'items' => array( @@ -47,11 +53,10 @@ class views_handler_area_result extends views_handler_area { ); } - /** * Find out the information to render. */ - function render($empty = FALSE) { + public function render($empty = FALSE) { // Must have options and does not work on summaries. if (!isset($this->options['content']) || $this->view->plugin_name == 'default_summary') { return; @@ -61,7 +66,7 @@ class views_handler_area_result extends views_handler_area { // Calculate the page totals. $current_page = (int) $this->view->get_current_page() + 1; $per_page = (int) $this->view->get_items_per_page(); - // @TODO: Maybe use a possible is views empty functionality. + // @todo Maybe use a possible is views empty functionality. // Not every view has total_rows set, use view->result instead. $total = isset($this->view->total_rows) ? $this->view->total_rows : count($this->view->result); $name = check_plain($this->view->human_name); @@ -81,15 +86,25 @@ class views_handler_area_result extends views_handler_area { } $current_record_count = ($end - $start) + 1; // Get the search information. - $items = array('start', 'end', 'total', 'name', 'per_page', 'current_page', 'current_record_count', 'page_count'); + $items = array( + 'start', + 'end', + 'total', + 'name', + 'per_page', + 'current_page', + 'current_record_count', + 'page_count', + ); $replacements = array(); foreach ($items as $item) { $replacements["@$item"] = ${$item}; } // Send the output. - if (!empty($total)) { + if (!empty($total) || !empty($this->options['empty'])) { $output .= filter_xss_admin(str_replace(array_keys($replacements), array_values($replacements), $format)); } return $output; } + } diff --git a/sites/all/modules/views/handlers/views_handler_area_text.inc b/sites/all/modules/views/handlers/views_handler_area_text.inc index edb282f..cad4a59 100644 --- a/sites/all/modules/views/handlers/views_handler_area_text.inc +++ b/sites/all/modules/views/handlers/views_handler_area_text.inc @@ -12,15 +12,30 @@ */ class views_handler_area_text extends views_handler_area { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); - $options['content'] = array('default' => '', 'translatable' => TRUE, 'format_key' => 'format'); - $options['format'] = array('default' => NULL); - $options['tokenize'] = array('default' => FALSE, 'bool' => TRUE); + $options['content'] = array( + 'default' => '', + 'translatable' => TRUE, + 'format_key' => 'format', + ); + $options['format'] = array( + 'default' => NULL, + ); + $options['tokenize'] = array( + 'default' => FALSE, + 'bool' => TRUE, + ); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['content'] = array( @@ -31,7 +46,7 @@ class views_handler_area_text extends views_handler_area { '#wysiwyg' => FALSE, ); - // @TODO: Refactor token handling into a base class. + // @todo Refactor token handling into a base class. $form['tokenize'] = array( '#type' => 'checkbox', '#title' => t('Use replacement tokens from the first row'), @@ -44,14 +59,17 @@ class views_handler_area_text extends views_handler_area { $options[t('Fields')]["[$field]"] = $handler->ui_name(); } - $count = 0; // This lets us prepare the key as we want it printed. + $count = 0; + // This lets us prepare the key as we want it printed. foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { $options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name())); $options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name())); } if (!empty($options)) { - $output = '

' . t('The following tokens are available. If you would like to have the characters \'[\' and \']\' please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.' . '

'); + $output = '

' + . t("The following tokens are available. If you would like to have the characters '[' and ']' please use the html entity codes '%5B' or '%5D' or they will get replaced with empty space.") + . '

'; foreach (array_keys($options) as $type) { if (!empty($options[$type])) { $items = array(); @@ -61,7 +79,7 @@ class views_handler_area_text extends views_handler_area { $output .= theme('item_list', array( 'items' => $items, - 'type' => $type + 'type' => $type, )); } } @@ -82,13 +100,19 @@ class views_handler_area_text extends views_handler_area { } } - function options_submit(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { $form_state['values']['options']['format'] = $form_state['values']['options']['content']['format']; $form_state['values']['options']['content'] = $form_state['values']['options']['content']['value']; parent::options_submit($form, $form_state); } - function render($empty = FALSE) { + /** + * {@inheritdoc} + */ + public function render($empty = FALSE) { $format = isset($this->options['format']) ? $this->options['format'] : filter_default_format(); if (!$empty || !empty($this->options['empty'])) { return $this->render_textarea($this->options['content'], $format); @@ -99,7 +123,7 @@ class views_handler_area_text extends views_handler_area { /** * Render a text area, using the proper format. */ - function render_textarea($value, $format) { + public function render_textarea($value, $format) { if ($value) { if ($this->options['tokenize']) { $value = $this->view->style_plugin->tokenize_value($value, 0); @@ -107,4 +131,5 @@ class views_handler_area_text extends views_handler_area { return check_markup($value, $format, '', FALSE); } } + } diff --git a/sites/all/modules/views/handlers/views_handler_area_text_custom.inc b/sites/all/modules/views/handlers/views_handler_area_text_custom.inc index 3627f0c..89577bc 100644 --- a/sites/all/modules/views/handlers/views_handler_area_text_custom.inc +++ b/sites/all/modules/views/handlers/views_handler_area_text_custom.inc @@ -12,13 +12,19 @@ */ class views_handler_area_text_custom extends views_handler_area_text { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); unset($options['format']); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // Alter the form element, to be a regular text area. @@ -26,14 +32,20 @@ class views_handler_area_text_custom extends views_handler_area_text { unset($form['content']['#format']); unset($form['content']['#wysiwyg']); - // @TODO: Use the token refactored base class. + // @todo Use the token refactored base class. } - // Empty, so we don't inherit options_submit from the parent. - function options_submit(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { + // Empty, so we don't inherit options_submit from the parent. } - function render($empty = FALSE) { + /** + * {@inheritdoc} + */ + public function render($empty = FALSE) { if (!$empty || !empty($this->options['empty'])) { return $this->render_textarea_custom($this->options['content']); } @@ -43,8 +55,14 @@ class views_handler_area_text_custom extends views_handler_area_text { /** * Render a text area with filter_xss_admin. + * + * @param string $value + * The text area string to process. + * + * @return string + * The string after it has been sanitized, optionally tokenized too. */ - function render_textarea_custom($value) { + public function render_textarea_custom($value) { if ($value) { if ($this->options['tokenize']) { $value = $this->view->style_plugin->tokenize_value($value, 0); diff --git a/sites/all/modules/views/handlers/views_handler_area_view.inc b/sites/all/modules/views/handlers/views_handler_area_view.inc index 3b72bf6..2e93135 100644 --- a/sites/all/modules/views/handlers/views_handler_area_view.inc +++ b/sites/all/modules/views/handlers/views_handler_area_view.inc @@ -12,7 +12,10 @@ */ class views_handler_area_view extends views_handler_area { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['view_to_insert'] = array('default' => ''); @@ -21,10 +24,9 @@ class views_handler_area_view extends views_handler_area { } /** - * Default options form that provides the label widget that all fields - * should have. + * Default options form; provides the label widget all fields should have. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $view_display = $this->view->name . ':' . $this->view->current_display; @@ -48,9 +50,9 @@ class views_handler_area_view extends views_handler_area { } /** - * Render the area + * Render the area. */ - function render($empty = FALSE) { + public function render($empty = FALSE) { if ($view = $this->loadView()) { if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) { return $view->preview(NULL, $this->view->args); diff --git a/sites/all/modules/views/handlers/views_handler_argument.inc b/sites/all/modules/views/handlers/views_handler_argument.inc index 86c4a0d..ced42a1 100644 --- a/sites/all/modules/views/handlers/views_handler_argument.inc +++ b/sites/all/modules/views/handlers/views_handler_argument.inc @@ -2,7 +2,7 @@ /** * @file - * @todo. + * Definition of views_handler_argument. */ /** @@ -14,50 +14,63 @@ /** * Base class for arguments. * - * The basic argument works for very simple arguments such as nid and uid + * The basic argument works for very simple arguments such as nid and uid. * * Definition terms for this handler: * - name field: The field to use for the name to use in the summary, which is - * the displayed output. For example, for the node: nid argument, - * the argument itself is the nid, but node.title is displayed. + * the displayed output. For example, for the node: nid argument, the argument + * itself is the nid, but node.title is displayed. * - name table: The table to use for the name, should it not be in the same - * table as the argument. + * table as the argument. * - empty field name: For arguments that can have no value, such as taxonomy - * which can have "no term", this is the string which - * will be displayed for this lack of value. Be sure to use - * t(). + * which can have "no term", this is the string which will be displayed for + * this lack of value. Be sure to use t(). * - validate type: A little used string to allow an argument to restrict - * which validator is available to just one. Use the - * validator ID. This probably should not be used at all, - * and may disappear or change. + * which validator is available to just one. Use the validator ID. This + * probably should not be used at all, and may disappear or change. * - numeric: If set to TRUE this field is numeric and will use %d instead of - * %s in queries. + * %s in queries. * * @ingroup views_argument_handlers */ class views_handler_argument extends views_handler { - var $validator = NULL; - var $argument = NULL; - var $value = NULL; /** - * The table to use for the name, should it not be in the same table as the argument. + * @var object + */ + public $validator = NULL; + + /** + * @var mixed + */ + public $argument = NULL; + + /** + * @var mixed + */ + public $value = NULL; + + /** + * The table to use for the name, if not the same table as the argument. + * * @var string */ - var $name_table; + public $name_table; /** - * The field to use for the name to use in the summary, which is - * the displayed output. For example, for the node: nid argument, - * the argument itself is the nid, but node.title is displayed. + * The field to use for the name to use in the summary. + * + * Used as the displayed output. For example, for the node: nid argument, the + * argument itself is the nid, but node.title is displayed. + * * @var string */ - var $name_field; + public $name_field; /** - * Constructor + * {@inheritdoc} */ - function construct() { + public function construct() { parent::construct(); if (!empty($this->definition['name field'])) { @@ -68,7 +81,10 @@ class views_handler_argument extends views_handler { } } - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); // Compatibility: The new UI changed several settings. @@ -132,31 +148,43 @@ class views_handler_argument extends views_handler { /** * Give an argument the opportunity to modify the breadcrumb, if it wants. - * This only gets called on displays where a breadcrumb is actually used. + * + * Only gets called on displays where a breadcrumb is actually used. * * The breadcrumb will be in the form of an array, with the keys being * the path and the value being the already sanitized title of the path. */ - function set_breadcrumb(&$breadcrumb) { } + public function set_breadcrumb(&$breadcrumb) { + } /** - * Determine if the argument can generate a breadcrumb + * Determine if the argument can generate a breadcrumb. * - * @return TRUE/FALSE + * @return bool + * Indicates whether the argument can generate a breadcrumb. */ - function uses_breadcrumb() { + public function uses_breadcrumb() { $info = $this->default_actions($this->options['default_action']); return !empty($info['breadcrumb']); } - function is_exception($arg = NULL) { + /** + * {@inheritdoc} + */ + public function is_exception($arg = NULL) { if (!isset($arg)) { $arg = isset($this->argument) ? $this->argument : NULL; } - return !empty($this->options['exception']['value']) && $this->options['exception']['value'] === $arg; + return !empty($this->options['exception']['value']) && ($this->options['exception']['value'] === $arg); } - function exception_title() { + /** + * Work out which title to use. + * + * @return string + * The title string to use. + */ + public function exception_title() { // If title overriding is off for the exception, return the normal title. if (empty($this->options['exception']['title_enable'])) { return $this->get_title(); @@ -167,15 +195,19 @@ class views_handler_argument extends views_handler { /** * Determine if the argument needs a style plugin. * - * @return TRUE/FALSE + * @return bool + * the argument needs a plugin style. */ - function needs_style_plugin() { + public function needs_style_plugin() { $info = $this->default_actions($this->options['default_action']); $validate_info = $this->default_actions($this->options['validate']['fail']); return !empty($info['style plugin']) || !empty($validate_info['style plugin']); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['default_action'] = array('default' => 'ignore'); @@ -213,7 +245,10 @@ class views_handler_argument extends views_handler { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $argument_text = $this->view->display_handler->get_argument_text(); @@ -380,8 +415,9 @@ class views_handler_argument extends views_handler { '#prefix' => '
', '#suffix' => '
', '#type' => 'item', - // Even if the plugin has no options add the key to the form_state. - '#input' => TRUE, // trick it into checking input to make #process run + // Even if the plugin has no options, add the key to the + // form_state. Trick it into checking input to make #process run. + '#input' => TRUE, '#dependency' => array( 'edit-options-specify-validation' => array('1'), 'edit-options-validate-type' => array($id), @@ -411,7 +447,10 @@ class views_handler_argument extends views_handler { ); } - function options_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { if (empty($form_state['values']['options'])) { return; } @@ -440,7 +479,10 @@ class views_handler_argument extends views_handler { } - function options_submit(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { if (empty($form_state['values']['options'])) { return; } @@ -451,7 +493,8 @@ class views_handler_argument extends views_handler { if ($plugin) { $options = &$form_state['values']['options']['argument_default'][$default_id]; $plugin->options_submit($form['argument_default'][$default_id], $form_state, $options); - // Copy the now submitted options to their final resting place so they get saved. + // Copy the now submitted options to their final resting place so they + // get saved. $form_state['values']['options']['default_argument_options'] = $options; } @@ -462,7 +505,8 @@ class views_handler_argument extends views_handler { if ($plugin) { $options = &$form_state['values']['options']['summary']['options'][$summary_id]; $plugin->options_submit($form['summary']['options'][$summary_id], $form_state, $options); - // Copy the now submitted options to their final resting place so they get saved. + // Copy the now submitted options to their final resting place so they + // get saved. $form_state['values']['options']['summary_options'] = $options; } } @@ -472,7 +516,8 @@ class views_handler_argument extends views_handler { if ($plugin) { $options = &$form_state['values']['options']['validate']['options'][$validate_id]; $plugin->options_submit($form['validate']['options'][$validate_id], $form_state, $options); - // Copy the now submitted options to their final resting place so they get saved. + // Copy the now submitted options to their final resting place so they + // get saved. $form_state['values']['options']['validate_options'] = $options; } @@ -484,47 +529,53 @@ class views_handler_argument extends views_handler { } /** - * Provide a list of default behaviors for this argument if the argument - * is not present. + * List of default behaviors for this argument if the argument is not present. * * Override this method to provide additional (or fewer) default behaviors. */ - function default_actions($which = NULL) { + public function default_actions($which = NULL) { $defaults = array( 'ignore' => array( 'title' => t('Display all results for the specified field'), 'method' => 'default_ignore', - 'breadcrumb' => TRUE, // generate a breadcrumb to here + // Generate a breadcrumb to here. + 'breadcrumb' => TRUE, ), 'default' => array( 'title' => t('Provide default value'), 'method' => 'default_default', 'form method' => 'default_argument_form', 'has default argument' => TRUE, - 'default only' => TRUE, // this can only be used for missing argument, not validation failure - 'breadcrumb' => TRUE, // generate a breadcrumb to here + // This can only be used for missing argument, not validation failure. + 'default only' => TRUE, + // Generate a breadcrumb to here. + 'breadcrumb' => TRUE, ), 'not found' => array( 'title' => t('Hide view'), 'method' => 'default_not_found', - 'hard fail' => TRUE, // This is a hard fail condition + // This is a hard fail condition. + 'hard fail' => TRUE, ), 'summary' => array( 'title' => t('Display a summary'), 'method' => 'default_summary', 'form method' => 'default_summary_form', 'style plugin' => TRUE, - 'breadcrumb' => TRUE, // generate a breadcrumb to here + // Generate a breadcrumb to here. + 'breadcrumb' => TRUE, ), 'empty' => array( 'title' => t('Display contents of "No results found"'), 'method' => 'default_empty', - 'breadcrumb' => TRUE, // generate a breadcrumb to here + // Generate a breadcrumb to here. + 'breadcrumb' => TRUE, ), 'access denied' => array( 'title' => t('Display "Access Denied"'), 'method' => 'default_access_denied', - 'breadcrumb' => FALSE, // generate a breadcrumb to here + // Generate a breadcrumb to here. + 'breadcrumb' => FALSE, ), ); @@ -543,10 +594,11 @@ class views_handler_argument extends views_handler { } /** - * Provide a form for selecting the default argument when the - * default action is set to provide default argument. + * Provide a form for selecting the default argument. + * + * Used when the default action is set to provide default argument. */ - function default_argument_form(&$form, &$form_state) { + public function default_argument_form(&$form, &$form_state) { $plugins = views_fetch_plugin_data('argument default'); $options = array(); @@ -554,7 +606,7 @@ class views_handler_argument extends views_handler { '#type' => 'checkbox', '#title' => t('Skip default argument for view URL'), '#default_value' => $this->options['default_argument_skip_url'], - '#description' => t('Select whether to include this default argument when constructing the URL for this view. Skipping default arguments is useful e.g. in the case of feeds.') + '#description' => t('Select whether to include this default argument when constructing the URL for this view. Skipping default arguments is useful e.g. in the case of feeds.'), ); $form['default_argument_type'] = array( @@ -564,8 +616,11 @@ class views_handler_argument extends views_handler { '#id' => 'edit-options-default-argument-type', '#title' => t('Type'), '#default_value' => $this->options['default_argument_type'], - - '#dependency' => array('radio:options[default_action]' => array('default')), + '#dependency' => array( + 'radio:options[default_action]' => array( + 'default', + ), + ), // Views custom key, moves this element to the appropriate container // under the radio button. '#argument_option' => 'default', @@ -588,7 +643,7 @@ class views_handler_argument extends views_handler { '#input' => TRUE, '#dependency' => array( 'radio:options[default_action]' => array('default'), - 'edit-options-default-argument-type' => array($id) + 'edit-options-default-argument-type' => array($id), ), '#dependency_count' => 2, ); @@ -603,10 +658,11 @@ class views_handler_argument extends views_handler { } /** - * Provide a form for selecting further summary options when the - * default action is set to display one. + * Form for selecting further summary options. + * + * Only used when the default action is set to display one. */ - function default_summary_form(&$form, &$form_state) { + public function default_summary_form(&$form, &$form_state) { $style_plugins = views_fetch_plugin_data('style'); $summary_plugins = array(); $format_options = array(); @@ -635,7 +691,7 @@ class views_handler_argument extends views_handler { '#default_value' => $this->options['summary']['number_of_records'], '#options' => array( 0 => $this->get_sort_name(), - 1 => t('Number of records') + 1 => t('Number of records'), ), '#dependency' => array('radio:options[default_action]' => array('summary')), ); @@ -659,7 +715,8 @@ class views_handler_argument extends views_handler { '#suffix' => '
', '#id' => 'edit-options-summary-options-' . $id, '#type' => 'item', - '#input' => TRUE, // trick it into checking input to make #process run + // Trick it into checking input to make #process run. + '#input' => TRUE, '#dependency' => array( 'radio:options[default_action]' => array('summary'), 'radio:options[summary][format]' => array($id), @@ -677,11 +734,11 @@ class views_handler_argument extends views_handler { * * Override this method only with extreme care. * - * @return + * @return bool * A boolean value; if TRUE, continue building this view. If FALSE, * building the view will be aborted here. */ - function default_action($info = NULL) { + public function default_action($info = NULL) { if (!isset($info)) { $info = $this->default_actions($this->options['default_action']); } @@ -699,29 +756,30 @@ class views_handler_argument extends views_handler { } /** - * How to act if validation failes + * How to act if validation fails. */ - function validate_fail() { + public function validate_fail() { $info = $this->default_actions($this->options['validate']['fail']); return $this->default_action($info); } + /** * Default action: ignore. * - * If an argument was expected and was not given, in this case, simply - * ignore the argument entirely. + * If an argument was expected and was not given, in this case, simply ignore + * the argument entirely. */ - function default_ignore() { + public function default_ignore() { return TRUE; } /** * Default action: not found. * - * If an argument was expected and was not given, in this case, report - * the view as 'not found' or hide it. + * If an argument was expected and was not given, in this case, report the + * view as 'not found' or hide it. */ - function default_not_found() { + public function default_not_found() { // Set a failure condition and let the display manager handle it. $this->view->build_info['fail'] = TRUE; return FALSE; @@ -730,21 +788,21 @@ class views_handler_argument extends views_handler { /** * Default action: access denied. * - * If an argument was expected and was not given, in this case, report - * the view as 'access denied'. + * If an argument was expected and was not given, in this case, report the + * view as 'access denied'. */ - function default_access_denied() { + public function default_access_denied() { $this->view->build_info['denied'] = TRUE; return FALSE; } /** - * Default action: empty + * Default action: empty. * - * If an argument was expected and was not given, in this case, display - * the view's empty text + * If an argument was expected and was not given, in this case, display the + * view's empty text. */ - function default_empty() { + public function default_empty() { // We return with no query; this will force the empty text. $this->view->built = TRUE; $this->view->executed = TRUE; @@ -753,17 +811,20 @@ class views_handler_argument extends views_handler { } /** - * This just returns true. The view argument builder will know where - * to find the argument from. + * This just returns true. + * + * The view argument builder will know where to find the argument from. + * + * @todo Why is this needed? */ - function default_default() { + public function default_default() { return TRUE; } /** * Determine if the argument is set to provide a default argument. */ - function has_default_argument() { + public function has_default_argument() { $info = $this->default_actions($this->options['default_action']); return !empty($info['has default argument']); } @@ -771,7 +832,7 @@ class views_handler_argument extends views_handler { /** * Get a default argument, if available. */ - function get_default_argument() { + public function get_default_argument() { $plugin = $this->get_plugin('argument default'); if ($plugin) { return $plugin->get_argument(); @@ -784,7 +845,7 @@ class views_handler_argument extends views_handler { * For example, the validation plugin may want to alter an argument for use in * the URL. */ - function process_summary_arguments(&$args) { + public function process_summary_arguments(&$args) { if ($this->options['validate']['type'] != 'none') { if (isset($this->validator) || $this->validator = $this->get_plugin('argument validator')) { $this->validator->process_summary_arguments($args); @@ -795,20 +856,19 @@ class views_handler_argument extends views_handler { /** * Default action: summary. * - * If an argument was expected and was not given, in this case, display - * a summary query. + * If an argument was expected and was not given, in this case, display a + * summary query. */ - function default_summary() { + public function default_summary() { $this->view->build_info['summary'] = TRUE; $this->view->build_info['summary_level'] = $this->options['id']; - // Change the display style to the summary style for this - // argument. + // Change the display style to the summary style for this argument. $this->view->plugin_name = $this->options['summary']['format']; $this->view->style_options = $this->options['summary_options']; - // Clear out the normal primary field and whatever else may have - // been added and let the summary do the work. + // Clear out the normal primary field and whatever else may have been added + // and let the summary do the work. $this->query->clear_fields(); $this->summary_query(); @@ -826,14 +886,14 @@ class views_handler_argument extends views_handler { * * This must: * - add_groupby: group on this field in order to create summaries. - * - add_field: add a 'num_nodes' field for the count. Usually it will - * be a count on $view->base_field + * - add_field: add a 'num_nodes' field for the count. Usually it will be a + * count on $view->base_field * - set_count_field: Reset the count field so we get the right paging. * - * @return + * @return string * The alias used to get the number of records (count) for this entry. */ - function summary_query() { + public function summary_query() { $this->ensure_my_table(); // Add the field. $this->base_alias = $this->query->add_field($this->table_alias, $this->real_field); @@ -844,15 +904,15 @@ class views_handler_argument extends views_handler { /** * Add the name field, which is the field displayed in summary queries. + * * This is often used when the argument is numeric. */ - function summary_name_field() { - // Add the 'name' field. For example, if this is a uid argument, the - // name field would be 'name' (i.e, the username). - + public function summary_name_field() { + // Add the 'name' field. For example, if this is a uid argument, the name + // field would be 'name' (i.e, the username). if (isset($this->name_table)) { - // if the alias is different then we're probably added, not ensured, - // so look up the join and add it instead. + // If the alias is different then we're probably added, not ensured, so + // look up the join and add it instead. if ($this->table_alias != $this->name_table) { $j = views_get_table_join($this->name_table, $this->table); if ($j) { @@ -878,15 +938,21 @@ class views_handler_argument extends views_handler { } /** - * Some basic summary behavior that doesn't need to be repeated as much as - * code that goes into summary_query() + * Some basic summary behavior. + * + * This doesn't need to be repeated as much as code that goes into + * summary_query(). */ - function summary_basics($count_field = TRUE) { - // Add the number of nodes counter + public function summary_basics($count_field = TRUE) { + // Add the number of nodes counter. $distinct = ($this->view->display_handler->get_option('distinct') && empty($this->query->no_distinct)); - $count_alias = $this->query->add_field($this->query->base_table, $this->query->base_field, 'num_records', - array('count' => TRUE, 'distinct' => $distinct)); + $count_alias = $this->query->add_field($this->query->base_table, + $this->query->base_field, 'num_records', + array( + 'count' => TRUE, + 'distinct' => $distinct, + )); $this->query->add_groupby($this->name_alias); if ($count_field) { @@ -897,36 +963,44 @@ class views_handler_argument extends views_handler { } /** - * Sorts the summary based upon the user's selection. The base variant of - * this is usually adequte. + * Sorts the summary based upon the user's selection. * - * @param $order + * The base variant of this is usually adequte. + * + * @param string $order * The order selected in the UI. + * @param string $by + * Optional alias for this field. */ - function summary_sort($order, $by = NULL) { + public function summary_sort($order, $by = NULL) { $this->query->add_orderby(NULL, NULL, $order, (!empty($by) ? $by : $this->name_alias)); } /** - * Provide the argument to use to link from the summary to the next level; - * this will be called once per row of a summary, and used as part of + * Provide the argument to use to link from the summary to the next level. + * + * This will be called once per row of a summary, and used as part of * $view->get_url(). * - * @param $data + * @param object $data * The query results for the row. */ - function summary_argument($data) { + public function summary_argument($data) { return $data->{$this->base_alias}; } /** - * Provides the name to use for the summary. By default this is just - * the name field. + * Provides the name to use for the summary. * - * @param $data + * By default this is just the name field. + * + * @param object $data * The query results for the row. + * + * @return string + * The summary. */ - function summary_name($data) { + public function summary_name($data) { $value = $data->{$this->name_alias}; if (empty($value) && !empty($this->definition['empty field name'])) { $value = $this->definition['empty field name']; @@ -938,8 +1012,11 @@ class views_handler_argument extends views_handler { * Set up the query for this argument. * * The argument sent may be found at $this->argument. + * + * @param bool $group_by + * Whether the query uses a group-by. */ - function query($group_by = FALSE) { + public function query($group_by = FALSE) { $this->ensure_my_table(); $this->query->add_where(0, "$this->table_alias.$this->real_field", $this->argument); } @@ -949,15 +1026,17 @@ class views_handler_argument extends views_handler { * * This usually needs to be overridden to provide a proper title. */ - function title() { + public function title() { return check_plain($this->argument); } /** - * Called by the view object to get the title. This may be set by a - * validator so we don't necessarily call through to title(). + * Called by the view object to get the title. + * + * This may be set by a validator so we don't necessarily call through to + * title(). */ - function get_title() { + public function get_title() { if (isset($this->validated_title)) { return $this->validated_title; } @@ -969,7 +1048,7 @@ class views_handler_argument extends views_handler { /** * Validate that this argument works. By default, all arguments are valid. */ - function validate_arg($arg) { + public function validate_arg($arg) { // By using % in URLs, arguments could be validated twice; this eases // that pain. if (isset($this->argument_validated)) { @@ -989,7 +1068,7 @@ class views_handler_argument extends views_handler { return $this->argument_validated = $plugin->validate_argument($arg); } - // If the plugin isn't found, fall back to the basic validation path: + // If the plugin isn't found, fall back to the basic validation path. return $this->argument_validated = $this->validate_argument_basic($arg); } @@ -997,10 +1076,10 @@ class views_handler_argument extends views_handler { * Called by the menu system to validate an argument. * * This checks to see if this is a 'soft fail', which means that if the - * argument fails to validate, but there is an action to take anyway, - * then validation cannot actually fail. + * argument fails to validate, but there is an action to take anyway, then + * validation cannot actually fail. */ - function validate_argument($arg) { + public function validate_argument($arg) { $validate_info = $this->default_actions($this->options['validate']['fail']); if (empty($validate_info['hard fail'])) { return TRUE; @@ -1008,8 +1087,8 @@ class views_handler_argument extends views_handler { $rc = $this->validate_arg($arg); - // If the validator has changed the validate fail condition to a - // soft fail, deal with that: + // If the validator has changed the validate fail condition to a soft fail, + // deal with that. $validate_info = $this->default_actions($this->options['validate']['fail']); if (empty($validate_info['hard fail'])) { return TRUE; @@ -1021,11 +1100,14 @@ class views_handler_argument extends views_handler { /** * Provide a basic argument validation. * - * This can be overridden for more complex types; the basic - * validator only checks to see if the argument is not NULL - * or is numeric if the definition says it's numeric. + * This can be overridden for more complex types; the basic validator only + * checks to see if the argument is not NULL or is numeric if the definition + * says it's numeric. + * + * @return bool + * Whether or not the argument validates. */ - function validate_argument_basic($arg) { + public function validate_argument_basic($arg) { if (!isset($arg) || $arg === '') { return FALSE; } @@ -1038,19 +1120,23 @@ class views_handler_argument extends views_handler { } /** - * Set the input for this argument + * Set the input for this argument. * - * @return TRUE if it successfully validates; FALSE if it does not. + * @return bool + * TRUE if it successfully validates; FALSE if it does not. */ - function set_argument($arg) { + public function set_argument($arg) { $this->argument = $arg; return $this->validate_arg($arg); } /** * Get the value of this argument. + * + * @return string + * The value. */ - function get_value() { + public function get_value() { // If we already processed this argument, we're done. if (isset($this->argument)) { return $this->argument; @@ -1089,8 +1175,11 @@ class views_handler_argument extends views_handler { * * Arguments can have styles for the summary view. This special export * handler makes sure this works properly. + * + * @return string + * The export summary. */ - function export_summary($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_summary($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; $name = $this->options['summary'][$option]; $options = $this->options['summary_options']; @@ -1113,8 +1202,11 @@ class views_handler_argument extends views_handler { * * Arguments use validation plugins. This special export handler makes sure * this works properly. + * + * @return string + * The validation response. */ - function export_validation($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_validation($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; $name = $this->options['validate'][$option]; $options = $this->options['validate_options']; @@ -1137,8 +1229,11 @@ class views_handler_argument extends views_handler { * * Since style and validation plugins have their own export handlers, this * one is currently only used for default argument plugins. + * + * @return string + * Export string. */ - function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; if ($option == 'default_argument_type') { $type = 'argument default'; @@ -1162,28 +1257,30 @@ class views_handler_argument extends views_handler { /** * Get the display or row plugin, if it exists. */ - function get_plugin($type = 'argument default', $name = NULL) { + public function get_plugin($type = 'argument default', $name = NULL) { $options = array(); switch ($type) { case 'argument default': $plugin_name = $this->options['default_argument_type']; $options_name = 'default_argument_options'; break; + case 'argument validator': $plugin_name = $this->options['validate']['type']; $options_name = 'validate_options'; break; + case 'style': $plugin_name = $this->options['summary']['format']; $options_name = 'summary_options'; + break; } if (!$name) { $name = $plugin_name; } - // we only fetch the options if we're fetching the plugin actually - // in use. + // We only fetch the options if we're fetching the plugin actually in use. if ($name == $plugin_name) { $options = $this->options[$options_name]; } @@ -1206,10 +1303,14 @@ class views_handler_argument extends views_handler { * * Subclasses should override this to specify what the default sort order of * their argument is (e.g. alphabetical, numeric, date). + * + * @return string + * The label for the sorter. */ - function get_sort_name() { + public function get_sort_name() { return t('Default sort', array(), array('context' => 'Sort order')); } + } /** @@ -1218,22 +1319,44 @@ class views_handler_argument extends views_handler { * @ingroup views_argument_handlers */ class views_handler_argument_broken extends views_handler_argument { - function ui_name($short = FALSE) { + + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return t('Broken/missing handler'); } - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function ensure_my_table() { + // No table to ensure! + } + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { + // No query to run. + } + + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['markup'] = array( '#markup' => '
' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '
', ); } /** - * Determine if the handler is considered 'broken' + * {@inheritdoc} */ - function broken() { return TRUE; } + public function broken() { + return TRUE; + } + } /** diff --git a/sites/all/modules/views/handlers/views_handler_argument_date.inc b/sites/all/modules/views/handlers/views_handler_argument_date.inc index 6803c36..5501e00 100644 --- a/sites/all/modules/views/handlers/views_handler_argument_date.inc +++ b/sites/all/modules/views/handlers/views_handler_argument_date.inc @@ -10,41 +10,54 @@ * * Adds an option to set a default argument based on the current date. * - * @param $arg_format - * The format string to use on the current time when - * creating a default date argument. + * @param string $arg_format + * The format string to use on the current time when creating a default date + * argument. * * Definitions terms: * - many to one: If true, the "many to one" helper will be used. * - invalid input: A string to give to the user for obviously invalid input. - * This is deprecated in favor of argument validators. + * This is deprecated in favor of argument validators. * * @see views_many_to_one_helper() * * @ingroup views_argument_handlers */ class views_handler_argument_date extends views_handler_argument_formula { - var $option_name = 'default_argument_date'; - var $arg_format = 'Y-m-d'; + + /** + * @var string + */ + public $option_name = 'default_argument_date'; + + /** + * @var string + */ + public $arg_format = 'Y-m-d'; /** * Add an option to set the default value to the current date. */ - function default_argument_form(&$form, &$form_state) { + public function default_argument_form(&$form, &$form_state) { parent::default_argument_form($form, $form_state); $form['default_argument_type']['#options'] += array('date' => t('Current date')); $form['default_argument_type']['#options'] += array('node_created' => t("Current node's creation time")); - $form['default_argument_type']['#options'] += array('node_changed' => t("Current node's update time")); } + $form['default_argument_type']['#options'] += array('node_changed' => t("Current node's update time")); + } /** - * Set the empty argument value to the current date, - * formatted appropriately for this argument. + * Set the empty argument value to the current date. + * + * Formatted appropriately for this argument. + * + * @return string + * The default argument. */ - function get_default_argument($raw = FALSE) { + public function get_default_argument($raw = FALSE) { if (!$raw && $this->options['default_argument_type'] == 'date') { return date($this->arg_format, REQUEST_TIME); } - else if (!$raw && in_array($this->options['default_argument_type'], array('node_created', 'node_changed'))) { + elseif (!$raw && in_array($this->options['default_argument_type'], array('node_created', 'node_changed'))) { foreach (range(1, 3) as $i) { $node = menu_get_object('node', $i); if (!empty($node)) { @@ -71,11 +84,12 @@ class views_handler_argument_date extends views_handler_argument_formula { } /** - * The date handler provides some default argument types, which aren't argument default plugins, - * so addapt the export mechanism. + * Adapt the export mechanism. + * + * The date handler provides some default argument types, which aren't + * argument default plugins. */ - function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { - + public function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { // Only use a special behaviour for the special argument types, else just // use the default behaviour. if ($option == 'default_argument_type') { @@ -94,8 +108,11 @@ class views_handler_argument_date extends views_handler_argument_formula { return parent::export_plugin($indent, $prefix, $storage, $option, $definition, $parents); } - - function get_sort_name() { + /** + * {@inheritdoc} + */ + public function get_sort_name() { return t('Date', array(), array('context' => 'Sort order')); } + } diff --git a/sites/all/modules/views/handlers/views_handler_argument_formula.inc b/sites/all/modules/views/handlers/views_handler_argument_formula.inc index 76f5991..56ae976 100644 --- a/sites/all/modules/views/handlers/views_handler_argument_formula.inc +++ b/sites/all/modules/views/handlers/views_handler_argument_formula.inc @@ -16,11 +16,16 @@ * @ingroup views_argument_handlers */ class views_handler_argument_formula extends views_handler_argument { - var $formula = NULL; + /** - * Constructor + * */ - function construct() { + public $formula = NULL; + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); if (!empty($this->definition['formula'])) { @@ -28,14 +33,17 @@ class views_handler_argument_formula extends views_handler_argument { } } - function get_formula() { + /** + * + */ + public function get_formula() { return str_replace('***table***', $this->table_alias, $this->formula); } /** * Build the summary query based on a formula */ - function summary_query() { + public function summary_query() { $this->ensure_my_table(); // Now that our table is secure, get our formula. $formula = $this->get_formula(); @@ -50,14 +58,15 @@ class views_handler_argument_formula extends views_handler_argument { /** * Build the query based upon the formula */ - function query($group_by = FALSE) { + public function query($group_by = FALSE) { $this->ensure_my_table(); // Now that our table is secure, get our formula. $placeholder = $this->placeholder(); - $formula = $this->get_formula() .' = ' . $placeholder; + $formula = $this->get_formula() . ' = ' . $placeholder; $placeholders = array( $placeholder => $this->argument, ); $this->query->add_where(0, $formula, $placeholders, 'formula'); } + } diff --git a/sites/all/modules/views/handlers/views_handler_argument_group_by_numeric.inc b/sites/all/modules/views/handlers/views_handler_argument_group_by_numeric.inc index aa522ea..01010b5 100644 --- a/sites/all/modules/views/handlers/views_handler_argument_group_by_numeric.inc +++ b/sites/all/modules/views/handlers/views_handler_argument_group_by_numeric.inc @@ -10,8 +10,12 @@ * * @ingroup views_argument_handlers */ -class views_handler_argument_group_by_numeric extends views_handler_argument { - function query($group_by = FALSE) { +class views_handler_argument_group_by_numeric extends views_handler_argument { + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { $this->ensure_my_table(); $field = $this->get_field(); $placeholder = $this->placeholder(); @@ -19,11 +23,18 @@ class views_handler_argument_group_by_numeric extends views_handler_argument { $this->query->add_having_expression(0, "$field = $placeholder", array($placeholder => $this->argument)); } - function ui_name($short = FALSE) { + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return $this->get_field(parent::ui_name($short)); } - function get_sort_name() { + /** + * {@inheritdoc} + */ + public function get_sort_name() { return t('Numerical', array(), array('context' => 'Sort order')); } + } diff --git a/sites/all/modules/views/handlers/views_handler_argument_many_to_one.inc b/sites/all/modules/views/handlers/views_handler_argument_many_to_one.inc index 3446760..ce581f7 100644 --- a/sites/all/modules/views/handlers/views_handler_argument_many_to_one.inc +++ b/sites/all/modules/views/handlers/views_handler_argument_many_to_one.inc @@ -6,29 +6,39 @@ */ /** - * An argument handler for use in fields that have a many to one relationship - * with the table(s) to the left. This adds a bunch of options that are - * reasonably common with this type of relationship. + * Argument handler for fields that have many-to-one table relationships. + * + * (i.e. with the table(s) to the left.) + * This adds a bunch of options that are reasonably common with this type of + * relationship. + * * Definition terms: * - numeric: If true, the field will be considered numeric. Probably should * always be set TRUE as views_handler_argument_string has many to one * capabilities. - * - zero is null: If true, a 0 will be handled as empty, so for example - * a default argument can be provided or a summary can be shown. + * - zero is null: If true, a 0 will be handled as empty, so for example a + * default argument can be provided or a summary can be shown. * * @ingroup views_argument_handlers */ class views_handler_argument_many_to_one extends views_handler_argument { - function init(&$view, &$options) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); $this->helper = new views_many_to_one_helper($this); - // Ensure defaults for these, during summaries and stuff: + // Ensure defaults for these, during summaries and stuff. $this->operator = 'or'; $this->value = array(); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); if (!empty($this->definition['numeric'])) { @@ -49,7 +59,10 @@ class views_handler_argument_many_to_one extends views_handler_argument { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // allow + for or, , for and @@ -85,11 +98,14 @@ class views_handler_argument_many_to_one extends views_handler_argument { * Override ensure_my_table so we can control how this joins in. * The operator actually has influence over joining. */ - function ensure_my_table() { + public function ensure_my_table() { $this->helper->ensure_my_table(); } - function query($group_by = FALSE) { + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { $empty = FALSE; if (isset($this->definition['zero is null']) && $this->definition['zero is null']) { if (empty($this->argument)) { @@ -118,7 +134,10 @@ class views_handler_argument_many_to_one extends views_handler_argument { $this->helper->add_filter(); } - function title() { + /** + * {@inheritdoc} + */ + public function title() { if (!$this->argument) { return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized'); } @@ -144,7 +163,10 @@ class views_handler_argument_many_to_one extends views_handler_argument { return implode($this->operator == 'or' ? ' + ' : ', ', $this->title_query()); } - function summary_query() { + /** + * {@inheritdoc} + */ + public function summary_query() { $field = $this->table . '.' . $this->field; $join = $this->get_join(); @@ -167,7 +189,10 @@ class views_handler_argument_many_to_one extends views_handler_argument { return $this->summary_basics(); } - function summary_argument($data) { + /** + * {@inheritdoc} + */ + public function summary_argument($data) { $value = $data->{$this->base_alias}; if (empty($value)) { $value = 0; @@ -179,7 +204,8 @@ class views_handler_argument_many_to_one extends views_handler_argument { /** * Override for specific title lookups. */ - function title_query() { + public function title_query() { return $this->value; } + } diff --git a/sites/all/modules/views/handlers/views_handler_argument_null.inc b/sites/all/modules/views/handlers/views_handler_argument_null.inc index 5b42728..afe0c60 100644 --- a/sites/all/modules/views/handlers/views_handler_argument_null.inc +++ b/sites/all/modules/views/handlers/views_handler_argument_null.inc @@ -11,7 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_null extends views_handler_argument { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['must_not_be'] = array('default' => FALSE, 'bool' => TRUE); return $options; @@ -21,7 +25,7 @@ class views_handler_argument_null extends views_handler_argument { * Override options_form() so that only the relevant options * are displayed to the user. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['must_not_be'] = array( '#type' => 'checkbox', @@ -38,9 +42,9 @@ class views_handler_argument_null extends views_handler_argument { * Override default_actions() to remove actions that don't * make sense for a null argument. */ - function default_actions($which = NULL) { + public function default_actions($which = NULL) { if ($which) { - if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) { + if (in_array($which, array('ignore', 'not found', 'empty', 'default', 'access denied'))) { return parent::default_actions($which); } return; @@ -51,7 +55,10 @@ class views_handler_argument_null extends views_handler_argument { return $actions; } - function validate_argument_basic($arg) { + /** + * {@inheritdoc} + */ + public function validate_argument_basic($arg) { if (!empty($this->options['must_not_be'])) { return !isset($arg); } @@ -63,5 +70,7 @@ class views_handler_argument_null extends views_handler_argument { * Override the behavior of query() to prevent the query * from being changed in any way. */ - function query($group_by = FALSE) {} + public function query($group_by = FALSE) { + } + } diff --git a/sites/all/modules/views/handlers/views_handler_argument_numeric.inc b/sites/all/modules/views/handlers/views_handler_argument_numeric.inc index 8f36b21..c0e2e2b 100644 --- a/sites/all/modules/views/handlers/views_handler_argument_numeric.inc +++ b/sites/all/modules/views/handlers/views_handler_argument_numeric.inc @@ -6,25 +6,30 @@ */ /** - * Basic argument handler for arguments that are numeric. Incorporates - * break_phrase. + * Basic argument handler for arguments that are numeric. + * + * Incorporates break_phrase. * * @ingroup views_argument_handlers */ class views_handler_argument_numeric extends views_handler_argument { + /** * The operator used for the query: or|and. * @var string */ - var $operator; + public $operator; /** * The actual value which is used for querying. * @var array */ - var $value; + public $value; - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE); @@ -33,7 +38,10 @@ class views_handler_argument_numeric extends views_handler_argument { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // allow + for or, , for and @@ -54,7 +62,10 @@ class views_handler_argument_numeric extends views_handler_argument { ); } - function title() { + /** + * {@inheritdoc} + */ + public function title() { if (!$this->argument) { return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized'); } @@ -80,14 +91,18 @@ class views_handler_argument_numeric extends views_handler_argument { /** * Override for specific title lookups. + * * @return array * Returns all titles, if it's just one title it's an array with one entry. */ - function title_query() { + public function title_query() { return $this->value; } - function query($group_by = FALSE) { + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { $this->ensure_my_table(); if (!empty($this->options['break_phrase'])) { @@ -110,7 +125,11 @@ class views_handler_argument_numeric extends views_handler_argument { } } - function get_sort_name() { + /** + * {@inheritdoc} + */ + public function get_sort_name() { return t('Numerical', array(), array('context' => 'Sort order')); } + } diff --git a/sites/all/modules/views/handlers/views_handler_argument_string.inc b/sites/all/modules/views/handlers/views_handler_argument_string.inc index dbb98fe..86000c6 100644 --- a/sites/all/modules/views/handlers/views_handler_argument_string.inc +++ b/sites/all/modules/views/handlers/views_handler_argument_string.inc @@ -6,24 +6,30 @@ */ /** - * Basic argument handler to implement string arguments that may have length - * limits. + * Argument handler to implement string arguments that may have length limits. * * @ingroup views_argument_handlers */ class views_handler_argument_string extends views_handler_argument { - function init(&$view, &$options) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); if (!empty($this->definition['many to one'])) { $this->helper = new views_many_to_one_helper($this); - // Ensure defaults for these, during summaries and stuff: + // Ensure defaults for these, during summaries and stuff. $this->operator = 'or'; $this->value = array(); } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['glossary'] = array('default' => FALSE, 'bool' => TRUE); @@ -32,6 +38,7 @@ class views_handler_argument_string extends views_handler_argument { $options['path_case'] = array('default' => 'none'); $options['transform_dash'] = array('default' => FALSE, 'bool' => TRUE); $options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE); + $options['not'] = array('default' => FALSE, 'bool' => TRUE); if (!empty($this->definition['many to one'])) { $options['add_table'] = array('default' => FALSE, 'bool' => TRUE); @@ -41,7 +48,10 @@ class views_handler_argument_string extends views_handler_argument { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['glossary'] = array( @@ -123,12 +133,19 @@ class views_handler_argument_string extends views_handler_argument { '#default_value' => !empty($this->options['break_phrase']), '#fieldset' => 'more', ); + $form['not'] = array( + '#type' => 'checkbox', + '#title' => t('Exclude'), + '#description' => t('If selected, the numbers entered for the filter will be excluded rather than limiting the view.'), + '#default_value' => !empty($this->options['not']), + '#fieldset' => 'more', + ); } /** - * Build the summary query based on a string + * Build the summary query based on a string. */ - function summary_query() { + public function summary_query() { if (empty($this->definition['many to one'])) { $this->ensure_my_table(); } @@ -157,14 +174,14 @@ class views_handler_argument_string extends views_handler_argument { * * $this->ensure_my_table() MUST have been called prior to this. */ - function get_formula() { + public function get_formula() { return "SUBSTRING($this->table_alias.$this->real_field, 1, " . intval($this->options['limit']) . ")"; } /** * Build the query based upon the formula */ - function query($group_by = FALSE) { + public function query($group_by = FALSE) { $argument = $this->argument; if (!empty($this->options['transform_dash'])) { $argument = strtr($argument, '-', ' '); @@ -198,21 +215,19 @@ class views_handler_argument_string extends views_handler_argument { } if (count($this->value) > 1) { - $operator = 'IN'; + $operator = empty($this->options['not']) ? 'IN' : 'NOT IN'; $argument = $this->value; } else { - $operator = '='; + $operator = empty($this->options['not']) ? '=' : '!='; } if ($formula) { $placeholder = $this->placeholder(); - if ($operator == 'IN') { - $field .= " IN($placeholder)"; - } - else { - $field .= ' = ' . $placeholder; + if (count($this->value) > 1) { + $placeholder = "($placeholder)"; } + $field .= " $operator $placeholder"; $placeholders = array( $placeholder => $argument, ); @@ -223,7 +238,10 @@ class views_handler_argument_string extends views_handler_argument { } } - function summary_argument($data) { + /** + * {@inheritdoc} + */ + public function summary_argument($data) { $value = $this->case_transform($data->{$this->base_alias}, $this->options['path_case']); if (!empty($this->options['transform_dash'])) { $value = strtr($value, ' ', '-'); @@ -231,11 +249,17 @@ class views_handler_argument_string extends views_handler_argument { return $value; } - function get_sort_name() { + /** + * {@inheritdoc} + */ + public function get_sort_name() { return t('Alphabetical', array(), array('context' => 'Sort order')); } - function title() { + /** + * {@inheritdoc} + */ + public function title() { $this->argument = $this->case_transform($this->argument, $this->options['case']); if (!empty($this->options['transform_dash'])) { $this->argument = strtr($this->argument, '-', ' '); @@ -263,11 +287,14 @@ class views_handler_argument_string extends views_handler_argument { /** * Override for specific title lookups. */ - function title_query() { + public function title_query() { return drupal_map_assoc($this->value, 'check_plain'); } - function summary_name($data) { + /** + * {@inheritdoc} + */ + public function summary_name($data) { return $this->case_transform(parent::summary_name($data), $this->options['case']); } diff --git a/sites/all/modules/views/handlers/views_handler_field.inc b/sites/all/modules/views/handlers/views_handler_field.inc index 65210d9..4b690dc 100644 --- a/sites/all/modules/views/handlers/views_handler_field.inc +++ b/sites/all/modules/views/handlers/views_handler_field.inc @@ -2,25 +2,26 @@ /** * @file - * @todo. + * Definition of views_handler_field. */ /** * @defgroup views_field_handlers Views field handlers * @{ * Handlers to tell Views how to build and display fields. - * */ /** * Indicator of the render_text() method for rendering a single item. - * (If no render_item() is present). + * + * If no render_item() is present. */ define('VIEWS_HANDLER_RENDER_TEXT_PHASE_SINGLE_ITEM', 0); /** * Indicator of the render_text() method for rendering the whole element. - * (if no render_item() method is available). + * + * if no render_item() method is available. */ define('VIEWS_HANDLER_RENDER_TEXT_PHASE_COMPLETELY', 1); @@ -34,17 +35,29 @@ define('VIEWS_HANDLER_RENDER_TEXT_PHASE_EMPTY', 2); * * Definition terms: * - additional fields: An array of fields that should be added to the query - * for some purpose. The array is in the form of: - * array('identifier' => array('table' => tablename, - * 'field' => fieldname); as many fields as are necessary - * may be in this array. + * for some purpose. The array is in the form of: + * array( + * 'identifier' => array( + * 'table' => tablename, + * 'field' => fieldname, + * ) + * ); + * with as many fields as are necessary may be in this array. * - click sortable: If TRUE, this field may be click sorted. * * @ingroup views_field_handlers */ class views_handler_field extends views_handler { - var $field_alias = 'unknown'; - var $aliases = array(); + + /** + * + */ + public $field_alias = 'unknown'; + + /** + * + */ + public $aliases = array(); /** * The field value prior to any rewriting. @@ -55,15 +68,15 @@ class views_handler_field extends views_handler { /** * @var array - * Stores additional fields which get's added to the query. + * Stores additional fields which get added to the query. * The generated aliases are stored in $aliases. */ - var $additional_fields = array(); + public $additional_fields = array(); /** * Construct a new field handler. */ - function construct() { + public function construct() { parent::construct(); $this->additional_fields = array(); @@ -79,21 +92,24 @@ class views_handler_field extends views_handler { /** * Determine if this field can allow advanced rendering. * - * Fields can set this to FALSE if they do not wish to allow - * token based rewriting or link-making. + * Fields can set this to FALSE if they do not wish to allow token based + * rewriting or link-making. */ - function allow_advanced_render() { + public function allow_advanced_render() { return TRUE; } - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); } /** * Called to add the field to a query. */ - function query() { + public function query() { $this->ensure_my_table(); // Add the field. $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); @@ -105,16 +121,15 @@ class views_handler_field extends views_handler { /** * Add 'additional' fields to the query. * - * @param $fields - * An array of fields. The key is an identifier used to later find the - * field alias used. The value is either a string in which case it's - * assumed to be a field on this handler's table; or it's an array in the - * form of - * @code array('table' => $tablename, 'field' => $fieldname) @endcode + * @param array $fields + * An array of fields. The key is an identifier used to later find the field + * alias used. The value is either a string in which case it's assumed to be + * a field on this handler's table; or it's an array in the form of + * @code array('table' => $tablename, 'field' => $fieldname) @endcode */ - function add_additional_fields($fields = NULL) { + public function add_additional_fields($fields = NULL) { if (!isset($fields)) { - // notice check + // Notice check. if (empty($this->additional_fields)) { return; } @@ -139,7 +154,12 @@ class views_handler_field extends views_handler { } if (empty($table_alias)) { - debug(t('Handler @handler tried to add additional_field @identifier but @table could not be added!', array('@handler' => $this->definition['handler'], '@identifier' => $identifier, '@table' => $info['table']))); + $t_args = array( + '@handler' => $this->definition['handler'], + '@identifier' => $identifier, + '@table' => $info['table'], + ); + debug(t('Handler @handler tried to add additional_field @identifier but @table could not be added!', $t_args)); $this->aliases[$identifier] = 'broken'; continue; } @@ -162,7 +182,7 @@ class views_handler_field extends views_handler { /** * Called to determine what to tell the clicksorter. */ - function click_sort($order) { + public function click_sort($order) { if (isset($this->field_alias)) { // Since fields should always have themselves already added, just // add a sort on the field. @@ -174,14 +194,14 @@ class views_handler_field extends views_handler { /** * Determine if this field is click sortable. */ - function click_sortable() { + public function click_sortable() { return !empty($this->definition['click sortable']); } /** * Get this field's label. */ - function label() { + public function label() { if (!isset($this->options['label'])) { return ''; } @@ -191,7 +211,7 @@ class views_handler_field extends views_handler { /** * Return an HTML element based upon the field's element type. */ - function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) { + public function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) { if ($none_supported) { if ($this->options['element_type'] === '0') { return ''; @@ -219,7 +239,7 @@ class views_handler_field extends views_handler { /** * Return an HTML element for the label based upon the field's element type. */ - function element_label_type($none_supported = FALSE, $default_empty = FALSE) { + public function element_label_type($none_supported = FALSE, $default_empty = FALSE) { if ($none_supported) { if ($this->options['element_label_type'] === '0') { return ''; @@ -239,7 +259,7 @@ class views_handler_field extends views_handler { /** * Return an HTML element for the wrapper based upon the field's element type. */ - function element_wrapper_type($none_supported = FALSE, $default_empty = FALSE) { + public function element_wrapper_type($none_supported = FALSE, $default_empty = FALSE) { if ($none_supported) { if ($this->options['element_wrapper_type'] === '0') { return 0; @@ -259,11 +279,10 @@ class views_handler_field extends views_handler { /** * Provide a list of elements valid for field HTML. * - * This function can be overridden by fields that want more or fewer - * elements available, though this seems like it would be an incredibly - * rare occurence. + * This function can be overridden by fields that want more or fewer elements + * available, though this seems like it would be an incredibly rare occurence. */ - function get_elements() { + public function get_elements() { static $elements = NULL; if (!isset($elements)) { $elements = variable_get('views_field_rewrite_elements', array( @@ -289,7 +308,7 @@ class views_handler_field extends views_handler { /** * Return the class of the field. */ - function element_classes($row_index = NULL) { + public function element_classes($row_index = NULL) { $classes = explode(' ', $this->options['element_class']); foreach ($classes as &$class) { $class = $this->tokenize_value($class, $row_index); @@ -304,15 +323,14 @@ class views_handler_field extends views_handler { * This function actually figures out which field was last and uses its * tokens so they will all be available. */ - function tokenize_value($value, $row_index = NULL) { + public function tokenize_value($value, $row_index = NULL) { if (strpos($value, '[') !== FALSE || strpos($value, '!') !== FALSE || strpos($value, '%') !== FALSE) { $fake_item = array( 'alter_text' => TRUE, 'text' => $value, ); - // Use isset() because empty() will trigger on 0 and 0 is - // the first row. + // Use isset() because empty() will trigger on 0 and 0 is the first row. if (isset($row_index) && isset($this->view->style_plugin->render_tokens[$row_index])) { $tokens = $this->view->style_plugin->render_tokens[$row_index]; } @@ -339,7 +357,7 @@ class views_handler_field extends views_handler { /** * Return the class of the field's label. */ - function element_label_classes($row_index = NULL) { + public function element_label_classes($row_index = NULL) { $classes = explode(' ', $this->options['element_label_class']); foreach ($classes as &$class) { $class = $this->tokenize_value($class, $row_index); @@ -351,7 +369,7 @@ class views_handler_field extends views_handler { /** * Return the class of the field's wrapper. */ - function element_wrapper_classes($row_index = NULL) { + public function element_wrapper_classes($row_index = NULL) { $classes = explode(' ', $this->options['element_wrapper_class']); foreach ($classes as &$class) { $class = $this->tokenize_value($class, $row_index); @@ -366,12 +384,12 @@ class views_handler_field extends views_handler { * This api exists so that other modules can easy set the values of the field * without having the need to change the render method as well. * - * @param $values + * @param object $values * An object containing all retrieved values. - * @param $field + * @param string $field * Optional name of the field where the value is stored. */ - function get_value($values, $field = NULL) { + public function get_value($values, $field = NULL) { $alias = isset($field) ? $this->aliases[$field] : $this->field_alias; if (isset($values->{$alias})) { return $values->{$alias}; @@ -383,13 +401,16 @@ class views_handler_field extends views_handler { * by in the style settings. * * @return bool - * TRUE if this field handler is groupable, otherwise FALSE. + * TRUE if this field handler is groupable, otherwise FALSE. */ - function use_string_group_by() { + public function use_string_group_by() { return TRUE; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['label'] = array('default' => $this->definition['title'], 'translatable' => TRUE); @@ -403,6 +424,7 @@ class views_handler_field extends views_handler { 'absolute' => array('default' => FALSE, 'bool' => TRUE), 'external' => array('default' => FALSE, 'bool' => TRUE), 'replace_spaces' => array('default' => FALSE, 'bool' => TRUE), + 'unwanted_characters' => array('default' => ''), 'path_case' => array('default' => 'none', 'translatable' => FALSE), 'trim_whitespace' => array('default' => FALSE, 'bool' => TRUE), 'alt' => array('default' => '', 'translatable' => TRUE), @@ -447,10 +469,19 @@ class views_handler_field extends views_handler { /** * Performs some cleanup tasks on the options array before saving it. */ - function options_submit(&$form, &$form_state) { + public function options_submit(&$form, &$form_state) { $options = &$form_state['values']['options']; - $types = array('element_type', 'element_label_type', 'element_wrapper_type'); - $classes = array_combine(array('element_class', 'element_label_class', 'element_wrapper_class'), $types); + $types = array( + 'element_type', + 'element_label_type', + 'element_wrapper_type', + ); + $base_types = array( + 'element_class', + 'element_label_class', + 'element_wrapper_class', + ); + $classes = array_combine($base_types, $types); foreach ($types as $type) { if (!$options[$type . '_enable']) { @@ -471,10 +502,9 @@ class views_handler_field extends views_handler { } /** - * Default options form that provides the label widget that all fields - * should have. + * Default options form provides the label widget that all fields should have. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $label = $this->label(); @@ -581,7 +611,7 @@ class views_handler_field extends views_handler { '#type' => 'checkbox', '#title' => t('Create a CSS class'), '#dependency' => array( - 'edit-options-element-label-type-enable' => array(1) + 'edit-options-element-label-type-enable' => array(1), ), '#default_value' => !empty($this->options['element_label_class']) || (string) $this->options['element_label_class'] == '0', '#fieldset' => 'style_settings', @@ -703,7 +733,7 @@ class views_handler_field extends views_handler { '#title' => t('Replace spaces with dashes'), '#default_value' => $this->options['alter']['replace_spaces'], '#dependency' => array( - 'edit-options-alter-make-link' => array(1) + 'edit-options-alter-make-link' => array(1), ), ); $form['alter']['external'] = array( @@ -715,6 +745,16 @@ class views_handler_field extends views_handler { 'edit-options-alter-make-link' => array(1), ), ); + $form['alter']['unwanted_characters'] = array( + '#type' => 'textfield', + '#title' => t('Remove unwanted characters'), + '#description' => t('Space-separated list of characters to remove from the URL path'), + '#default_value' => $this->options['alter']['unwanted_characters'], + '#dependency' => array( + 'edit-options-alter-make-link' => array(1) + ), + '#maxlength' => 255, + ); $form['alter']['path_case'] = array( '#type' => 'select', '#title' => t('Transform the case'), @@ -722,7 +762,7 @@ class views_handler_field extends views_handler { '#dependency' => array( 'edit-options-alter-make-link' => array(1), ), - '#options' => array( + '#options' => array( 'none' => t('No transform'), 'upper' => t('Upper case'), 'lower' => t('Lower case'), @@ -753,7 +793,7 @@ class views_handler_field extends views_handler { '#title' => t('Rel Text'), '#type' => 'textfield', '#default_value' => $this->options['alter']['rel'], - '#description' => t('Include Rel attribute for use in lightbox2 or other javascript utility.'), + '#description' => t('Include Rel attribute for use in lightbox2 or other JavaScript utility.'), '#dependency' => array( 'edit-options-alter-make-link' => array(1), ), @@ -796,7 +836,8 @@ class views_handler_field extends views_handler { break; } } - $count = 0; // This lets us prepare the key as we want it printed. + // This lets us prepare the key as we want it printed. + $count = 0; foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { $options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name())); $options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name())); @@ -819,15 +860,15 @@ If you would like to have the characters \'[\' and \']\' please use the html ent $output .= theme('item_list', array( 'items' => $items, - 'type' => $type + 'type' => $type, )); } } } // This construct uses 'hidden' and not markup because process doesn't - // run. It also has an extra div because the dependency wants to hide - // the parent in situations like this, so we need a second div to - // make this work. + // run. It also has an extra div because the dependency wants to hide the + // parent in situations like this, so we need a second div to make this + // work. $form['alter']['help'] = array( '#type' => 'fieldset', '#title' => t('Replacement patterns'), @@ -997,28 +1038,29 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Provide extra data to the administration form */ - function admin_summary() { + public function admin_summary() { return $this->label(); } /** * Run before any fields are rendered. * - * This gives the handlers some time to set up before any handler has - * been rendered. + * This gives the handlers some time to set up before any handler has been + * rendered. * - * @param $values + * @param array $values * An array of all objects returned from the query. */ - function pre_render(&$values) { } + public function pre_render(&$values) { + } /** * Render the field. * - * @param $values + * @param array $values * The values retrieved from the database. */ - function render($values) { + public function render($values) { $value = $this->get_value($values); return $this->sanitize_value($value); } @@ -1029,7 +1071,7 @@ If you would like to have the characters \'[\' and \']\' please use the html ent * This renders a field normally, then decides if render-as-link and * text-replacement rendering is necessary. */ - function advanced_render($values) { + public function advanced_render($values) { if ($this->allow_advanced_render() && method_exists($this, 'render_item')) { $raw_items = $this->get_items($values); // If there are no items, set the original value to NULL. @@ -1094,7 +1136,7 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Checks if a field value is empty. * - * @param $value + * @param mixed $value * The field value. * @param bool $empty_zero * Whether or not this field is configured to consider 0 as empty. @@ -1102,9 +1144,9 @@ If you would like to have the characters \'[\' and \']\' please use the html ent * Whether or not to use empty() to check the value. * * @return bool - * TRUE if the value is considered empty, FALSE otherwise. + * TRUE if the value is considered empty, FALSE otherwise. */ - function is_value_empty($value, $empty_zero, $no_skip_empty = TRUE) { + public function is_value_empty($value, $empty_zero, $no_skip_empty = TRUE) { if (!isset($value)) { $empty = TRUE; } @@ -1124,7 +1166,7 @@ If you would like to have the characters \'[\' and \']\' please use the html ent * This is separated out as some fields may render lists, and this allows * each item to be handled individually. */ - function render_text($alter) { + public function render_text($alter) { $value = $this->last_render; if (!empty($alter['alter_text']) && $alter['text'] !== '') { @@ -1139,9 +1181,10 @@ If you would like to have the characters \'[\' and \']\' please use the html ent // Check if there should be no further rewrite for empty values. $no_rewrite_for_empty = $this->options['hide_alter_empty'] && $this->is_value_empty($this->original_value, $this->options['empty_zero']); - // Check whether the value is empty and return nothing, so the field isn't rendered. - // First check whether the field should be hidden if the value(hide_alter_empty = TRUE) /the rewrite is empty (hide_alter_empty = FALSE). - // For numeric values you can specify whether "0"/0 should be empty. + // Check whether the value is empty and return nothing, so the field isn't + // rendered. First check whether the field should be hidden if the + // value(hide_alter_empty = TRUE) /the rewrite is empty (hide_alter_empty = + // FALSE). For numeric values you can specify whether "0"/0 should be empty. if ((($this->options['hide_empty'] && empty($value)) || ($alter['phase'] != VIEWS_HANDLER_RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty)) && $this->is_value_empty($value, $this->options['empty_zero'], FALSE)) { @@ -1169,7 +1212,8 @@ If you would like to have the characters \'[\' and \']\' please use the html ent $more_link_path = $this->options['alter']['more_link_path']; $more_link_path = strip_tags(decode_entities(strtr($more_link_path, $tokens))); - // Take sure that paths which was runned through url() does work as well. + // Take sure that paths which was runned through url() does work as + // well. $base_path = base_path(); // Checks whether the path starts with the base_path. if (strpos($more_link_path, $base_path) === 0) { @@ -1189,7 +1233,7 @@ If you would like to have the characters \'[\' and \']\' please use the html ent if (!empty($alter['make_link']) && !empty($alter['path'])) { if (!isset($tokens)) { - $tokens = $this->get_render_tokens($alter); + $tokens = $this->get_render_tokens($alter); } $value = $this->render_as_link($alter, $value, $tokens); } @@ -1200,9 +1244,10 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Render this field as altered text, from a fieldset set by the user. */ - function render_altered($alter, $tokens) { - // Filter this right away as our substitutions are already sanitized. - $value = filter_xss_admin($alter['text']); + public function render_altered($alter, $tokens) { + // We trust admins so we allow any tag content. This is important for + // displays such as XML where we should not mess with tags. + $value = $alter['text']; $value = strtr($value, $tokens); return $value; @@ -1211,21 +1256,20 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Trim the field down to the specified length. */ - function render_trim_text($alter, $value) { + public function render_trim_text($alter, $value) { if (!empty($alter['strip_tags'])) { // NOTE: It's possible that some external fields might override the - // element type so if someone from, say, CCK runs into a bug here, - // this may be why =) + // element type so if someone from, say, CCK runs into a bug here, this + // may be why =) $this->definition['element type'] = 'span'; } return views_trim_text($alter, $value); } /** - * Render this field as a link, with the info from a fieldset set by - * the user. + * Render this field as a link, with info from a fieldset set by the user. */ - function render_as_link($alter, $text, $tokens) { + public function render_as_link($alter, $text, $tokens) { $value = ''; if (!empty($alter['prefix'])) { @@ -1243,9 +1287,9 @@ If you would like to have the characters \'[\' and \']\' please use the html ent // strip_tags() removes , so check whether its different to front. if ($path != '') { - // Use strip tags as there should never be HTML in the path. - // However, we need to preserve special characters like " that - // were removed by check_plain(). + // Use strip tags as there should never be HTML in the path. However, we + // need to preserve special characters like " that were removed by + // check_plain(). $path = strip_tags(decode_entities(strtr($path, $tokens))); if (!empty($alter['path_case']) && $alter['path_case'] != 'none') { @@ -1255,6 +1299,12 @@ If you would like to have the characters \'[\' and \']\' please use the html ent if (!empty($alter['replace_spaces'])) { $path = str_replace(' ', '-', $path); } + + if (!empty($alter['unwanted_characters'])) { + foreach (explode(' ', $alter['unwanted_characters']) as $unwanted) { + $path = str_replace($unwanted, '', $path); + } + } } // Parse the URL and move any query and fragment parameters out of the path. @@ -1266,16 +1316,16 @@ If you would like to have the characters \'[\' and \']\' please use the html ent } // If the path is empty do not build a link around the given text and return - // it as is. - // http://www.example.com URLs will not have a $url['path'], so check host as well. + // it as is. http://www.example.com URLs will not have a $url['path'], so + // check host as well. if (empty($url['path']) && empty($url['host']) && empty($url['fragment'])) { return $text; } // If no scheme is provided in the $path, assign the default 'http://'. - // This allows a url of 'www.example.com' to be converted to 'http://www.example.com'. - // Only do this on for external URLs. - if ($alter['external']){ + // This allows a url of 'www.example.com' to be converted to + // 'http://www.example.com'. Only do this on for external URLs. + if ($alter['external']) { if (!isset($url['scheme'])) { // There is no scheme, add the default 'http://' to the $path. $path = "http://$path"; @@ -1320,13 +1370,14 @@ If you would like to have the characters \'[\' and \']\' please use the html ent $options['attributes']['rel'] = $rel; } - $target = check_plain(trim(strtr($alter['target'],$tokens))); + $target = check_plain(trim(strtr($alter['target'], $tokens))); if (!empty($target)) { $options['attributes']['target'] = $target; } - // Allow the addition of arbitrary attributes to links. Additional attributes - // currently can only be altered in preprocessors and not within the UI. + // Allow the addition of arbitrary attributes to links. Additional + // attributes currently can only be altered in preprocessors and not within + // the UI. if (isset($alter['link_attributes']) && is_array($alter['link_attributes'])) { foreach ($alter['link_attributes'] as $key => $attribute) { if (!isset($options['attributes'][$key])) { @@ -1375,11 +1426,10 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Get the 'render' tokens to use for advanced rendering. * - * This runs through all of the fields and arguments that - * are available and gets their values. This will then be - * used in one giant str_replace(). + * This runs through all of the fields and arguments that are available and + * gets their values. This will then be used in one giant str_replace(). */ - function get_render_tokens($item) { + public function get_render_tokens($item) { $tokens = array(); if (!empty($this->view->build_info['substitutions'])) { $tokens = $this->view->build_info['substitutions']; @@ -1391,9 +1441,9 @@ If you would like to have the characters \'[\' and \']\' please use the html ent $tokens[$token] = ''; } - // Use strip tags as there should never be HTML in the path. - // However, we need to preserve special characters like " that - // were removed by check_plain(). + // Use strip tags as there should never be HTML in the path. However, we + // need to preserve special characters like " that were removed by + // check_plain(). $tokens['!' . $count] = isset($this->view->args[$count - 1]) ? strip_tags(decode_entities($this->view->args[$count - 1])) : ''; } @@ -1450,27 +1500,28 @@ If you would like to have the characters \'[\' and \']\' please use the html ent * '%bar_b_c' => 'value' * ); * - * @param $array + * @param array $array * An array of values. - * - * @param $parent_keys + * @param array $parent_keys * An array of parent keys. This will represent the array depth. * - * @return - * An array of available tokens, with nested keys representative of the array structure. + * @return array + * An array of available tokens, with nested keys representative of the + * array structure. */ - function get_token_values_recursive(array $array, array $parent_keys = array()) { + public function get_token_values_recursive(array $array, array $parent_keys = array()) { $tokens = array(); foreach ($array as $param => $val) { if (is_array($val)) { - // Copy parent_keys array, so we don't afect other elements of this iteration. - $child_parent_keys = $parent_keys; - $child_parent_keys[] = $param; - // Get the child tokens. - $child_tokens = $this->get_token_values_recursive($val, $child_parent_keys); - // Add them to the current tokens array. - $tokens += $child_tokens; + // Copy parent_keys array, so we don't afect other elements of this + // iteration. + $child_parent_keys = $parent_keys; + $child_parent_keys[] = $param; + // Get the child tokens. + $child_tokens = $this->get_token_values_recursive($val, $child_parent_keys); + // Add them to the current tokens array. + $tokens += $child_tokens; } else { // Create a token key based on array element structure. @@ -1485,50 +1536,57 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Add any special tokens this field might use for itself. * - * This method is intended to be overridden by items that generate - * fields as a list. For example, the field that displays all terms - * on a node might have tokens for the tid and the term. + * This method is intended to be overridden by items that generate fields as a + * list. For example, the field that displays all terms on a node might have + * tokens for the tid and the term. * - * By convention, tokens should follow the format of [token-subtoken] - * where token is the field ID and subtoken is the field. If the - * field ID is terms, then the tokens might be [terms-tid] and [terms-name]. + * By convention, tokens should follow the format of [token-subtoken] where + * token is the field ID and subtoken is the field. If the field ID is terms, + * then the tokens might be [terms-tid] and [terms-name]. */ - function add_self_tokens(&$tokens, $item) { } + public function add_self_tokens(&$tokens, $item) { + } /** * Document any special tokens this field might use for itself. * * @see add_self_tokens() */ - function document_self_tokens(&$tokens) { } + public function document_self_tokens(&$tokens) { + } /** - * Call out to the theme() function, which probably just calls render() but - * allows sites to override output fairly easily. + * Call out to the theme() function. + * + * It probably just calls render() but allows sites to override output fairly + * easily. */ - function theme($values) { + public function theme($values) { return theme($this->theme_functions(), array( 'view' => $this->view, 'field' => $this, - 'row' => $values + 'row' => $values, )); } - function theme_functions() { + /** + * Build a list of suitable theme functions for this view. + */ + public function theme_functions() { $themes = array(); $hook = 'views_view_field'; $display = $this->view->display[$this->view->current_display]; if (!empty($display)) { - $themes[] = $hook . '__' . $this->view->name . '__' . $display->id . '__' . $this->options['id']; - $themes[] = $hook . '__' . $this->view->name . '__' . $display->id; + $themes[] = $hook . '__' . $this->view->name . '__' . $display->id . '__' . $this->options['id']; + $themes[] = $hook . '__' . $this->view->name . '__' . $display->id; $themes[] = $hook . '__' . $display->id . '__' . $this->options['id']; $themes[] = $hook . '__' . $display->id; if ($display->id != $display->display_plugin) { - $themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin . '__' . $this->options['id']; - $themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin; + $themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin . '__' . $this->options['id']; + $themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin; $themes[] = $hook . '__' . $display->display_plugin . '__' . $this->options['id']; $themes[] = $hook . '__' . $display->display_plugin; } @@ -1541,9 +1599,13 @@ If you would like to have the characters \'[\' and \']\' please use the html ent return $themes; } - function ui_name($short = FALSE) { + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return $this->get_field(parent::ui_name($short)); } + } /** @@ -1552,22 +1614,44 @@ If you would like to have the characters \'[\' and \']\' please use the html ent * @ingroup views_field_handlers */ class views_handler_field_broken extends views_handler_field { - function ui_name($short = FALSE) { + + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return t('Broken/missing handler'); } - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function ensure_my_table() { + // No table to ensure! + } + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { + // No query to run. + } + + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['markup'] = array( '#markup' => '
' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '
', ); } /** - * Determine if the handler is considered 'broken' + * {@inheritdoc} */ - function broken() { return TRUE; } + public function broken() { + return TRUE; + } + } /** @@ -1576,7 +1660,11 @@ class views_handler_field_broken extends views_handler_field { * @ingroup views_field_handlers */ class views_handler_field_file_size extends views_handler_field { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['file_size_display'] = array('default' => 'formatted'); @@ -1584,7 +1672,10 @@ class views_handler_field_file_size extends views_handler_field { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['file_size_display'] = array( '#title' => t('File size display'), @@ -1596,7 +1687,10 @@ class views_handler_field_file_size extends views_handler_field { ); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); if ($value) { switch ($this->options['file_size_display']) { @@ -1611,6 +1705,7 @@ class views_handler_field_file_size extends views_handler_field { return ''; } } + } /** @@ -1619,10 +1714,15 @@ class views_handler_field_file_size extends views_handler_field { * @ingroup views_field_handlers */ class views_handler_field_xss extends views_handler_field { - function render($values) { + + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->sanitize_value($value, 'xss'); } + } /** diff --git a/sites/all/modules/views/handlers/views_handler_field_boolean.inc b/sites/all/modules/views/handlers/views_handler_field_boolean.inc index 8acfb32..cfa1605 100644 --- a/sites/all/modules/views/handlers/views_handler_field_boolean.inc +++ b/sites/all/modules/views/handlers/views_handler_field_boolean.inc @@ -11,18 +11,22 @@ * Allows for display of true/false, yes/no, on/off, enabled/disabled. * * Definition terms: - * - output formats: An array where the first entry is displayed on boolean true - * and the second is displayed on boolean false. An example for sticky is: - * @code - * 'output formats' => array( - * 'sticky' => array(t('Sticky'), ''), - * ), - * @endcode + * - output formats: An array where the first entry is displayed on boolean true + * and the second is displayed on boolean false. An example for sticky is: + * @code + * 'output formats' => array( + * 'sticky' => array(t('Sticky'), ''), + * ), + * @endcode * * @ingroup views_field_handlers */ class views_handler_field_boolean extends views_handler_field { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['type'] = array('default' => 'yes-no'); $options['type_custom_true'] = array('default' => '', 'translatable' => TRUE); @@ -32,7 +36,10 @@ class views_handler_field_boolean extends views_handler_field { return $options; } - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); $default_formats = array( @@ -48,7 +55,10 @@ class views_handler_field_boolean extends views_handler_field { $this->formats = array_merge($default_formats, $output_formats, $custom_format); } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { foreach ($this->formats as $key => $item) { $options[$key] = implode('/', $item); } @@ -91,7 +101,10 @@ class views_handler_field_boolean extends views_handler_field { parent::options_form($form, $form_state); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); if (!empty($this->options['not'])) { $value = !$value; @@ -100,11 +113,12 @@ class views_handler_field_boolean extends views_handler_field { if ($this->options['type'] == 'custom') { return $value ? filter_xss_admin($this->options['type_custom_true']) : filter_xss_admin($this->options['type_custom_false']); } - else if (isset($this->formats[$this->options['type']])) { + elseif (isset($this->formats[$this->options['type']])) { return $value ? $this->formats[$this->options['type']][0] : $this->formats[$this->options['type']][1]; } else { return $value ? $this->formats['yes-no'][0] : $this->formats['yes-no'][1]; } } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc b/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc index 4386e05..f3eb66e 100644 --- a/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc +++ b/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc @@ -11,7 +11,11 @@ * @ingroup views_field_handlers */ class views_handler_field_contextual_links extends views_handler_field_links { - function pre_render(&$values) { + + /** + * {@inheritdoc} + */ + public function pre_render(&$values) { // Add a row plugin css class for the contextual link. $class = 'contextual-links-region'; if (!empty($this->view->style_plugin->options['row_class'])) { @@ -22,7 +26,10 @@ class views_handler_field_contextual_links extends views_handler_field_links { } } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['fields']['#description'] = t('Fields to be included as contextual links.'); @@ -32,7 +39,7 @@ class views_handler_field_contextual_links extends views_handler_field_links { /** * Render the contextual fields. */ - function render($values) { + public function render($values) { $links = $this->get_links(); if (!empty($links)) { $build = array( @@ -52,4 +59,5 @@ class views_handler_field_contextual_links extends views_handler_field_links { return ''; } } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_counter.inc b/sites/all/modules/views/handlers/views_handler_field_counter.inc index e4a0ebf..a970160 100644 --- a/sites/all/modules/views/handlers/views_handler_field_counter.inc +++ b/sites/all/modules/views/handlers/views_handler_field_counter.inc @@ -11,14 +11,21 @@ * @ingroup views_field_handlers */ class views_handler_field_counter extends views_handler_field { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['counter_start'] = array('default' => 1); $options['reverse'] = array('default' => FALSE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['counter_start'] = array( '#type' => 'textfield', '#title' => t('Starting value'), @@ -37,24 +44,31 @@ class views_handler_field_counter extends views_handler_field { parent::options_form($form, $form_state); } - function query() { - // do nothing -- to override the parent query. + /** + * {@inheritdoc} + */ + public function query() { + // Do nothing -- to override the parent query. } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $reverse = empty($this->options['reverse']) ? 1 : -1; - // Note: 1 is subtracted from the counter start value below because the + // Note: 1 is subtracted from the counter start value below because the // counter value is incremented by 1 at the end of this function. $counter_start = is_numeric($this->options['counter_start']) ? $this->options['counter_start'] : 0; - $count = ($reverse == -1) ? count($this->view->result) + $counter_start : $counter_start -1; + $count = ($reverse == -1) ? count($this->view->result) + $counter_start : $counter_start - 1; $pager = $this->view->query->pager; // Get the base count of the pager. if ($pager->use_pager()) { if ($reverse == -1) { $count = ($pager->total_items + $counter_start - ($pager->get_current_page() * $pager->get_items_per_page()) + $pager->get_offset()); - } else { + } + else { $count += (($pager->get_items_per_page() * $pager->get_current_page() + $pager->get_offset())) * $reverse; } } @@ -63,4 +77,5 @@ class views_handler_field_counter extends views_handler_field { return $count; } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_ctools_dropdown.inc b/sites/all/modules/views/handlers/views_handler_field_ctools_dropdown.inc index 8964f88..9fc9d2e 100644 --- a/sites/all/modules/views/handlers/views_handler_field_ctools_dropdown.inc +++ b/sites/all/modules/views/handlers/views_handler_field_ctools_dropdown.inc @@ -11,7 +11,11 @@ * @ingroup views_field_handlers */ class views_handler_field_ctools_dropdown extends views_handler_field_links { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['views_admin_css'] = array('default' => TRUE, 'bool' => TRUE); @@ -19,7 +23,10 @@ class views_handler_field_ctools_dropdown extends views_handler_field_links { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['fields']['#description'] = t('Fields to be included as ctools dropdown button.'); $form['destination']['#description'] = t('Include a "destination" parameter in the link to return the user to the original view upon completing a link action.'); @@ -35,7 +42,7 @@ class views_handler_field_ctools_dropdown extends views_handler_field_links { /** * Render the dropdown button. */ - function render($values) { + public function render($values) { static $added_admin_css; $links = $this->get_links(); @@ -46,10 +53,20 @@ class views_handler_field_ctools_dropdown extends views_handler_field_links { $added_admin_css = TRUE; } - return theme('links__ctools_dropbutton', array('links' => $links, 'attributes' => array('class' => array('links', 'inline')))); + $vars = array( + 'links' => $links, + 'attributes' => array( + 'class' => array( + 'links', + 'inline', + ), + ), + ); + return theme('links__ctools_dropbutton', $vars); } else { return ''; } } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_custom.inc b/sites/all/modules/views/handlers/views_handler_field_custom.inc index 66586de..eebf045 100644 --- a/sites/all/modules/views/handlers/views_handler_field_custom.inc +++ b/sites/all/modules/views/handlers/views_handler_field_custom.inc @@ -11,11 +11,18 @@ * @ingroup views_field_handlers */ class views_handler_field_custom extends views_handler_field { - function query() { - // do nothing -- to override the parent query. + + /** + * {@inheritdoc} + */ + public function query() { + // Do nothing -- to override the parent query. } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); // Override the alter text option to always alter the text. @@ -24,10 +31,13 @@ class views_handler_field_custom extends views_handler_field { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); - // Remove the checkbox + // Remove the checkbox. unset($form['alter']['alter_text']); unset($form['alter']['text']['#dependency']); unset($form['alter']['text']['#process']); @@ -36,10 +46,14 @@ class views_handler_field_custom extends views_handler_field { $form['#pre_render'][] = 'views_handler_field_custom_pre_render_move_text'; } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { // Return the text, so the code never thinks the value is empty. return $this->options['alter']['text']; } + } /** diff --git a/sites/all/modules/views/handlers/views_handler_field_date.inc b/sites/all/modules/views/handlers/views_handler_field_date.inc index f2c6371..cd0838b 100644 --- a/sites/all/modules/views/handlers/views_handler_field_date.inc +++ b/sites/all/modules/views/handlers/views_handler_field_date.inc @@ -8,10 +8,17 @@ /** * A handler to provide proper displays for dates. * + * This may be used on table fields that hold either UNIX timestamps or SQL + * datetime strings. + * * @ingroup views_field_handlers */ class views_handler_field_date extends views_handler_field { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['date_format'] = array('default' => 'small'); @@ -23,8 +30,10 @@ class views_handler_field_date extends views_handler_field { return $options; } - function options_form(&$form, &$form_state) { - + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $date_formats = array(); $date_types = system_get_date_types(); foreach ($date_types as $key => $value) { @@ -52,66 +61,112 @@ class views_handler_field_date extends views_handler_field { '#title' => t('Custom date format'), '#description' => t('If "Custom", see the PHP manual for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.', array('@url' => 'http://php.net/manual/function.date.php')), '#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '', - '#dependency' => array('edit-options-date-format' => array('custom', 'raw time ago', 'time ago', 'today time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span')), + '#dependency' => array( + 'edit-options-date-format' => $this->supported_date_types(), + ), ); $form['second_date_format'] = array( - '#type' => 'select', - '#title' => t('Second date format'), - '#options' => $date_formats + array( - 'custom' => t('Custom'), - ), - '#description' => t('The date format which will be used for rendering dates other than today.'), - '#default_value' => isset($this->options['second_date_format']) ? $this->options['second_date_format'] : 'small', - '#dependency' => array('edit-options-date-format' => array('today time ago')), - ); - $form['second_date_format_custom'] = array( - '#type' => 'textfield', - '#title' => t('Custom date format of second date'), - '#description' => t('If "Custom" is selected in "Second date format", see the PHP manual for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.', array('@url' => 'http://php.net/manual/function.date.php')), - '#default_value' => isset($this->options['second_date_format_custom']) ? $this->options['second_date_format_custom'] : '', - // We have to use states instead of ctools dependency because dependency - // doesn't handle multiple conditions. - '#states' => array( - 'visible' => array( - '#edit-options-date-format' => array('value' => 'today time ago'), - '#edit-options-second-date-format' => array('value' => 'custom'), - ), - ), - // We have to use ctools dependency too because states doesn't add the - // correct left margin to the element's wrapper. - '#dependency' => array( - // This condition is handled by form API's states. -// 'edit-options-date-format' => array('today time ago'), - 'edit-options-second-date-format' => array('custom'), - ), - ); + '#type' => 'select', + '#title' => t('Second date format'), + '#options' => $date_formats + array( + 'custom' => t('Custom'), + ), + '#description' => t('The date format which will be used for rendering dates other than today.'), + '#default_value' => isset($this->options['second_date_format']) ? $this->options['second_date_format'] : 'small', + '#dependency' => array( + 'edit-options-date-format' => array('today time ago'), + ), + ); + $form['second_date_format_custom'] = array( + '#type' => 'textfield', + '#title' => t('Custom date format of second date'), + '#description' => t('If "Custom" is selected in "Second date format", see the PHP manual for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.', array('@url' => 'http://php.net/manual/function.date.php')), + '#default_value' => isset($this->options['second_date_format_custom']) ? $this->options['second_date_format_custom'] : '', + // We have to use states instead of ctools dependency because dependency + // doesn't handle multiple conditions. + '#states' => array( + 'visible' => array( + '#edit-options-date-format' => array('value' => 'today time ago'), + '#edit-options-second-date-format' => array('value' => 'custom'), + ), + ), + // We have to use ctools dependency too because states doesn't add the + // correct left margin to the element's wrapper. + '#dependency' => array( + // This condition is handled by form API's states. + // 'edit-options-date-format' => array('today time ago'), + 'edit-options-second-date-format' => array('custom'), + ), + ); $form['timezone'] = array( '#type' => 'select', '#title' => t('Timezone'), '#description' => t('Timezone to be used for date output.'), - '#options' => array('' => t('- Default site/user timezone -')) + system_time_zones(FALSE), + '#options' => array( + '' => t('- Default site/user timezone -'), + ) + system_time_zones(FALSE), '#default_value' => $this->options['timezone'], - '#dependency' => array('edit-options-date-format' => array_merge(array('custom'), array_keys($date_formats))), + '#dependency' => array( + 'edit-options-date-format' => array_merge(array('custom'), array_keys($date_formats)), + ), ); parent::options_form($form, $form_state); } - function render($values) { + /** + * Provide a list of all of the supported standard date types. + * + * @return array + * The list of supported formats. + */ + private function supported_date_types() { + return array( + 'custom', + 'raw time ago', + 'time ago', + 'today time ago', + 'raw time hence', + 'time hence', + 'raw time span', + 'time span', + 'raw time span', + 'inverse time span', + 'time span', + ); + } + + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); + + if (!is_numeric($value)) { + // If the value isn't numeric, assume it's an SQL DATETIME. + $value = strtotime($value); + } + $format = $this->options['date_format']; - if (in_array($format, array('custom', 'raw time ago', 'time ago', 'today time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span'))) { + if (in_array($format, $this->supported_date_types())) { $custom_format = $this->options['custom_date_format']; } if ($value) { $timezone = !empty($this->options['timezone']) ? $this->options['timezone'] : NULL; - $time_diff = REQUEST_TIME - $value; // will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence) + // Will be positive for a datetime in the past (ago), and negative for a + // datetime in the future (hence). + $time_diff = REQUEST_TIME - $value; switch ($format) { case 'raw time ago': return format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2); + case 'time ago': - return t('%time ago', array('%time' => format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2))); + $t_args = array( + '%time' => format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2), + ); + return t('%time ago', $t_args); + case 'today time ago': $second_format = $this->options['second_date_format']; $second_custom_format = $this->options['second_date_format_custom']; @@ -127,24 +182,32 @@ class views_handler_field_date extends views_handler_field { else { return format_date($value, $this->options['second_date_format'], '', $timezone); } + case 'raw time hence': return format_interval(-$time_diff, is_numeric($custom_format) ? $custom_format : 2); + case 'time hence': return t('%time hence', array('%time' => format_interval(-$time_diff, is_numeric($custom_format) ? $custom_format : 2))); + case 'raw time span': return ($time_diff < 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2); + case 'inverse time span': return ($time_diff > 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2); + case 'time span': return t(($time_diff < 0 ? '%time hence' : '%time ago'), array('%time' => format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2))); + case 'custom': if ($custom_format == 'r') { return format_date($value, $format, $custom_format, $timezone, 'en'); } return format_date($value, $format, $custom_format, $timezone); + default: return format_date($value, $format, '', $timezone); } } } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_entity.inc b/sites/all/modules/views/handlers/views_handler_field_entity.inc index d8aaba4..f255e04 100644 --- a/sites/all/modules/views/handlers/views_handler_field_entity.inc +++ b/sites/all/modules/views/handlers/views_handler_field_entity.inc @@ -11,7 +11,7 @@ * Fields based upon this handler work with all query-backends if the tables * used by the query backend have an 'entity type' specified. In order to * make fields based upon this handler automatically available to all compatible - * query backends, the views field can be defined in the table + * query backends, the views field can be defined in the table. * @code views_entity_{ENTITY_TYPE} @endcode. * * @ingroup views_field_handlers @@ -41,13 +41,15 @@ class views_handler_field_entity extends views_handler_field { // Initialize the entity-type used. $table_data = views_fetch_data($this->table); - $this->entity_type = $table_data['table']['entity type']; + if (isset($table_data['table']['entity type'])) { + $this->entity_type = $table_data['table']['entity type']; + } } /** * Overriden to add the field for the entity id. */ - function query() { + public function query() { $this->table_alias = $base_table = $this->view->base_table; $this->base_field = $this->view->base_field; @@ -75,16 +77,16 @@ class views_handler_field_entity extends views_handler_field { /** * Load the entities for all rows that are about to be displayed. */ - function pre_render(&$values) { + public function pre_render(&$values) { if (!empty($values)) { list($this->entity_type, $this->entities) = $this->query->get_result_entities($values, !empty($this->relationship) ? $this->relationship : NULL, $this->field_alias); } } /** - * Overridden to return the entity object, or a certain property of the entity. + * Return the entity object or a certain property of the entity. */ - function get_value($values, $field = NULL) { + public function get_value($values, $field = NULL) { if (isset($this->entities[$this->view->row_index])) { $entity = $this->entities[$this->view->row_index]; // Support to get a certain part of the entity. @@ -101,4 +103,5 @@ class views_handler_field_entity extends views_handler_field { } return FALSE; } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_links.inc b/sites/all/modules/views/handlers/views_handler_field_links.inc index 15f6460..7e32550 100644 --- a/sites/all/modules/views/handlers/views_handler_field_links.inc +++ b/sites/all/modules/views/handlers/views_handler_field_links.inc @@ -13,9 +13,9 @@ class views_handler_field_links extends views_handler_field { /** - * Overrides views_handler_field::option_definition(). + * {@inheritdoc} */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); $options['fields'] = array('default' => array()); @@ -26,9 +26,9 @@ class views_handler_field_links extends views_handler_field { } /** - * Overrides views_handler_field::options_form(). + * {@inheritdoc} */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $all_fields = $this->view->display_handler->get_field_labels(); @@ -59,11 +59,12 @@ class views_handler_field_links extends views_handler_field { } /** - * Overrides views_handler_field::options_form(). + * {@inheritdoc} */ - function options_submit(&$form, &$form_state) { + public function options_submit(&$form, &$form_state) { // Remove unselected options. $form_state['values']['options']['fields'] = array_filter($form_state['values']['options']['fields']); + parent::options_submit($form, $form_state); } /** @@ -72,7 +73,7 @@ class views_handler_field_links extends views_handler_field { * @return array * The links which are used by the render function. */ - function get_links() { + public function get_links() { $links = array(); foreach ($this->options['fields'] as $field) { if (empty($this->view->field[$field]->last_render_text)) { @@ -121,7 +122,6 @@ class views_handler_field_links extends views_handler_field { } // Omit tweaks of query, fragment, and link_class. - $alt = strtr($alter['alt'], $tokens); if ($alt && $alt != $title) { // Set the title attribute only if it improves accessibility. @@ -148,8 +148,9 @@ class views_handler_field_links extends views_handler_field { } /** - * Overrides views_handler_field::query(). + * {@inheritdoc} */ - function query() { } + public function query() { + } } diff --git a/sites/all/modules/views/handlers/views_handler_field_machine_name.inc b/sites/all/modules/views/handlers/views_handler_field_machine_name.inc index 9f3587f..500102c 100644 --- a/sites/all/modules/views/handlers/views_handler_field_machine_name.inc +++ b/sites/all/modules/views/handlers/views_handler_field_machine_name.inc @@ -10,16 +10,21 @@ * @ingroup views_field_handlers * * Definition items: - * - options callback: The function to call in order to generate the value options. If omitted, the options 'Yes' and 'No' will be used. + * - options callback: The function to call in order to generate the value + * options. If omitted, the options 'Yes' and 'No' will be used. * - options arguments: An array of arguments to pass to the options callback. */ class views_handler_field_machine_name extends views_handler_field { + /** * @var array Stores the available options. */ - var $value_options; + public $value_options; - function get_value_options() { + /** + * {@inheritdoc} + */ + public function get_value_options() { if (isset($this->value_options)) { return; } @@ -37,14 +42,20 @@ class views_handler_field_machine_name extends views_handler_field { } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['machine_name'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['machine_name'] = array( @@ -55,11 +66,17 @@ class views_handler_field_machine_name extends views_handler_field { ); } - function pre_render(&$values) { + /** + * {@inheritdoc} + */ + public function pre_render(&$values) { $this->get_value_options(); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $values->{$this->field_alias}; if (!empty($this->options['machine_name']) || !isset($this->value_options[$value])) { $result = check_plain($value); @@ -70,4 +87,5 @@ class views_handler_field_machine_name extends views_handler_field { return $result; } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_markup.inc b/sites/all/modules/views/handlers/views_handler_field_markup.inc index b0f1cea..5262e01 100644 --- a/sites/all/modules/views/handlers/views_handler_field_markup.inc +++ b/sites/all/modules/views/handlers/views_handler_field_markup.inc @@ -10,17 +10,18 @@ * format field. * * - format: (REQUIRED) Either a string format id to use for this field or an - * array('field' => {$field}) where $field is the field in this table - * used to control the format such as the 'format' field in the node, - * which goes with the 'body' field. + * array('field' => {$field}) where $field is the field in this table used to + * control the format such as the 'format' field in the node, which goes with + * the 'body' field. * * @ingroup views_field_handlers */ class views_handler_field_markup extends views_handler_field { + /** - * Constructor; calls to base object constructor. + * {@inheritdoc} */ - function construct() { + public function construct() { parent::construct(); $this->format = $this->definition['format']; @@ -31,7 +32,10 @@ class views_handler_field_markup extends views_handler_field { } } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); if (is_array($this->format)) { $format = $this->get_value($values, 'format'); @@ -45,7 +49,10 @@ class views_handler_field_markup extends views_handler_field { } } - function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) { + /** + * {@inheritdoc} + */ + public function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) { if ($inline) { return 'span'; } @@ -56,4 +63,5 @@ class views_handler_field_markup extends views_handler_field { return 'div'; } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_math.inc b/sites/all/modules/views/handlers/views_handler_field_math.inc index 50a948a..f8c5def 100644 --- a/sites/all/modules/views/handlers/views_handler_field_math.inc +++ b/sites/all/modules/views/handlers/views_handler_field_math.inc @@ -15,14 +15,21 @@ * @ingroup views_field_handlers */ class views_handler_field_math extends views_handler_field_numeric { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['expression'] = array('default' => ''); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['expression'] = array( '#type' => 'textarea', '#title' => t('Expression'), @@ -30,17 +37,20 @@ class views_handler_field_math extends views_handler_field_numeric { '#default_value' => $this->options['expression'], ); - // Create a place for the help + // Create a place for the help. $form['expression_help'] = array(); parent::options_form($form, $form_state); - // Then move the existing help: + // Then move the existing help. $form['expression_help'] = $form['alter']['help']; unset($form['expression_help']['#dependency']); unset($form['alter']['help']); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { ctools_include('math-expr'); $tokens = array_map('floatval', $this->get_render_tokens(array())); $value = strtr($this->options['expression'], $tokens); @@ -80,5 +90,10 @@ class views_handler_field_math extends views_handler_field_numeric { return $this->sanitize_value($this->options['prefix'] . $value . $this->options['suffix']); } - function query() { } + /** + * {@inheritdoc} + */ + public function query() { + } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_numeric.inc b/sites/all/modules/views/handlers/views_handler_field_numeric.inc index 843f4c9..b8de0fd 100644 --- a/sites/all/modules/views/handlers/views_handler_field_numeric.inc +++ b/sites/all/modules/views/handlers/views_handler_field_numeric.inc @@ -6,16 +6,20 @@ */ /** - * Render a field as a numeric value + * Render a field as a numeric value. * * Definition terms: * - float: If true this field contains a decimal value. If unset this field - * will be assumed to be integer. + * will be assumed to be integer. * * @ingroup views_field_handlers */ class views_handler_field_numeric extends views_handler_field { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['set_precision'] = array('default' => FALSE, 'bool' => TRUE); @@ -31,7 +35,10 @@ class views_handler_field_numeric extends views_handler_field { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { if (!empty($this->definition['float'])) { $form['set_precision'] = array( '#type' => 'checkbox', @@ -105,9 +112,17 @@ class views_handler_field_numeric extends views_handler_field { parent::options_form($form, $form_state); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); + // Output nothing if the value is null. + if (is_null($value)) { + return ''; + } + // Hiding should happen before rounding or adding prefix/suffix. if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) { return ''; @@ -117,12 +132,13 @@ class views_handler_field_numeric extends views_handler_field { $value = number_format($value, $this->options['precision'], $this->options['decimal'], $this->options['separator']); } else { - $remainder = abs($value) - intval(abs($value)); + $point_position = strpos($value, '.'); + $remainder = ($point_position === FALSE) ? '' : substr($value, $point_position + 1); $value = $value > 0 ? floor($value) : ceil($value); $value = number_format($value, 0, '', $this->options['separator']); if ($remainder) { // The substr may not be locale safe. - $value .= $this->options['decimal'] . substr($remainder, 2); + $value .= $this->options['decimal'] . $remainder; } } @@ -135,4 +151,5 @@ class views_handler_field_numeric extends views_handler_field { . $this->sanitize_value($value) . $this->sanitize_value($this->options['suffix'], 'xss'); } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_prerender_list.inc b/sites/all/modules/views/handlers/views_handler_field_prerender_list.inc index 00a571a..360abb4 100644 --- a/sites/all/modules/views/handlers/views_handler_field_prerender_list.inc +++ b/sites/all/modules/views/handlers/views_handler_field_prerender_list.inc @@ -16,17 +16,22 @@ * @ingroup views_field_handlers */ class views_handler_field_prerender_list extends views_handler_field { + /** * Stores all items which are used to render the items. + * * It should be keyed first by the id of the base table, for example nid. * The second key is the id of the thing which is displayed multiple times * per row, for example the tid. * * @var array */ - var $items = array(); + public $items = array(); - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['type'] = array('default' => 'separator'); @@ -35,7 +40,10 @@ class views_handler_field_prerender_list extends views_handler_field { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['type'] = array( '#type' => 'radios', '#title' => t('Display type'), @@ -63,7 +71,7 @@ class views_handler_field_prerender_list extends views_handler_field { * yet or won't update their prerender list fields. If a render_item method * exists, this will not get used by advanced_render. */ - function render($values) { + public function render($values) { $field = $this->get_value($values); if (!empty($this->items[$field])) { if ($this->options['type'] == 'separator') { @@ -74,7 +82,7 @@ class views_handler_field_prerender_list extends views_handler_field { array( 'items' => $this->items[$field], 'title' => NULL, - 'type' => $this->options['type'] + 'type' => $this->options['type'], )); } } @@ -86,7 +94,7 @@ class views_handler_field_prerender_list extends views_handler_field { * When using advanced render, each possible item in the list is rendered * individually. Then the items are all pasted together. */ - function render_items($items) { + public function render_items($items) { if (!empty($items)) { if ($this->options['type'] == 'separator') { return implode($this->sanitize_value($this->options['separator'], 'xss_admin'), $items); @@ -96,7 +104,7 @@ class views_handler_field_prerender_list extends views_handler_field { array( 'items' => $items, 'title' => NULL, - 'type' => $this->options['type'] + 'type' => $this->options['type'], )); } } @@ -105,14 +113,18 @@ class views_handler_field_prerender_list extends views_handler_field { /** * Return an array of items for the field. * - * Items should be stored in the result array, if possible, as an array - * with 'value' as the actual displayable value of the item, plus - * any items that might be found in the 'alter' options array for - * creating links, such as 'path', 'fragment', 'query' etc, such a thing - * is to be made. Additionally, items that might be turned into tokens - * should also be in this array. + * Items should be stored in the result array, if possible, as an array with + * 'value' as the actual displayable value of the item, plus any items that + * might be found in the 'alter' options array for creating links, such as + * 'path', 'fragment', 'query' etc, such a thing is to be made. Additionally, + * items that might be turned into tokens should also be in this array. + * + * @param mixed $values + * + * @return array + * The items. */ - function get_items($values) { + public function get_items($values) { // Only the parent get_value returns a single field. $field = parent::get_value($values); if (!empty($this->items[$field])) { @@ -125,14 +137,14 @@ class views_handler_field_prerender_list extends views_handler_field { /** * Get the value that's supposed to be rendered. * - * @param $values + * @param object $values * An object containing all retrieved values. - * @param $field + * @param string $field * Optional name of the field where the value is stored. - * @param $raw + * @param bool $raw * Use the raw data and not the data defined in pre_render */ - function get_value($values, $field = NULL, $raw = FALSE) { + public function get_value($values, $field = NULL, $raw = FALSE) { if ($raw) { return parent::get_value($values, $field); } @@ -149,10 +161,14 @@ class views_handler_field_prerender_list extends views_handler_field { * * By default, advanced rendering will NOT be allowed if the class * inheriting from this does not implement a 'render_items' method. + * + * @return bool + * Whether or not the the render method exists. */ - function allow_advanced_render() { + public function allow_advanced_render() { // Note that the advanced render bits also use the presence of // this method to determine if it needs to render items as a list. return method_exists($this, 'render_item'); } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_serialized.inc b/sites/all/modules/views/handlers/views_handler_field_serialized.inc index 1579fce..d0242b7 100644 --- a/sites/all/modules/views/handlers/views_handler_field_serialized.inc +++ b/sites/all/modules/views/handlers/views_handler_field_serialized.inc @@ -12,15 +12,20 @@ */ class views_handler_field_serialized extends views_handler_field { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['format'] = array('default' => 'unserialized'); $options['key'] = array('default' => ''); return $options; } - - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['format'] = array( @@ -42,14 +47,20 @@ class views_handler_field_serialized extends views_handler_field { ); } - function options_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { // Require a key if the format is key. if ($form_state['values']['options']['format'] == 'key' && $form_state['values']['options']['key'] == '') { form_error($form['key'], t('You have to enter a key if you want to display a key of the data.')); } } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $values->{$this->field_alias}; if ($this->options['format'] == 'unserialized') { @@ -60,6 +71,7 @@ class views_handler_field_serialized extends views_handler_field { return check_plain($value[$this->options['key']]); } - return $value; + return check_plain($value); } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_time_interval.inc b/sites/all/modules/views/handlers/views_handler_field_time_interval.inc index e6063af..0968d65 100644 --- a/sites/all/modules/views/handlers/views_handler_field_time_interval.inc +++ b/sites/all/modules/views/handlers/views_handler_field_time_interval.inc @@ -11,7 +11,11 @@ * @ingroup views_field_handlers */ class views_handler_field_time_interval extends views_handler_field { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['granularity'] = array('default' => 2); @@ -19,7 +23,10 @@ class views_handler_field_time_interval extends views_handler_field { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['granularity'] = array( @@ -30,8 +37,12 @@ class views_handler_field_time_interval extends views_handler_field { ); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $values->{$this->field_alias}; return format_interval($value, isset($this->options['granularity']) ? $this->options['granularity'] : 2); } + } diff --git a/sites/all/modules/views/handlers/views_handler_field_url.inc b/sites/all/modules/views/handlers/views_handler_field_url.inc index 4a76548..7781c9a 100644 --- a/sites/all/modules/views/handlers/views_handler_field_url.inc +++ b/sites/all/modules/views/handlers/views_handler_field_url.inc @@ -6,12 +6,16 @@ */ /** - * Field handler to provide simple renderer that turns a URL into a clickable link. + * Field handler that turns a URL into a clickable link. * * @ingroup views_field_handlers */ class views_handler_field_url extends views_handler_field { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['display_as_link'] = array('default' => TRUE, 'bool' => TRUE); @@ -22,7 +26,7 @@ class views_handler_field_url extends views_handler_field { /** * Provide link to the page being visited. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['display_as_link'] = array( '#title' => t('Display as link'), '#type' => 'checkbox', @@ -31,7 +35,10 @@ class views_handler_field_url extends views_handler_field { parent::options_form($form, $form_state); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); if (!empty($this->options['display_as_link'])) { $this->options['alter']['make_link'] = TRUE; @@ -43,4 +50,5 @@ class views_handler_field_url extends views_handler_field { return $this->sanitize_value($value, 'url'); } } + } diff --git a/sites/all/modules/views/handlers/views_handler_filter.inc b/sites/all/modules/views/handlers/views_handler_filter.inc index 04b2ca9..6ffb10d 100644 --- a/sites/all/modules/views/handlers/views_handler_filter.inc +++ b/sites/all/modules/views/handlers/views_handler_filter.inc @@ -2,7 +2,7 @@ /** * @file - * @todo. + * Definitions of views_handler_filter and views_handler_filter_broken. */ /** @@ -15,15 +15,14 @@ * available as standard operators. * * Object flags: - * You can set some specific behavior by setting up the following flags on - * your custom class. - * - * - always_multiple: - * Disable the possibility to force a single value. - * - no_operator: - * Disable the possibility to use operators. - * - always_required: - * Disable the possibility to allow a exposed input to be optional. + * It's possible to set specific behavior using the following flags on the + * custom class: + * - always_multiple: + * Disable the possibility to force a single value. + * - no_operator: + * Disable the possibility to use operators. + * - always_required: + * Disable the possibility to allow a exposed input to be optional. */ /** @@ -32,39 +31,51 @@ * @ingroup views_filter_handlers */ class views_handler_filter extends views_handler { + /** - * Contains the actual value of the field,either configured in the views ui - * or entered in the exposed filters. + * Contains the actual value of the field. + * + * This will be either configured in the views UI or entered in the exposed + * filters. + * + * @var mixed */ - var $value = NULL; + public $value = NULL; /** * Contains the operator which is used on the query. + * + * @var string */ - var $operator = '='; + public $operator = '='; /** * Contains the information of the selected item in a gruped filter. + * + * @var array|null */ - var $group_info = NULL; + public $group_info = NULL; /** - * @var bool * Disable the possibility to force a single value. + * + * @var bool */ - var $always_multiple = FALSE; + public $always_multiple = FALSE; /** - * @var bool * Disable the possibility to use operators. + * + * @var bool */ - var $no_operator = FALSE; + public $no_operator = FALSE; /** - * @var bool * Disable the possibility to allow a exposed input to be optional. + * + * @var bool */ - var $always_required = FALSE; + public $always_required = FALSE; /** * Provide some extra help to get the operator/value easier to use. @@ -72,7 +83,7 @@ class views_handler_filter extends views_handler { * This likely has to be overridden by filters which are more complex * than simple operator/value. */ - function init(&$view, &$options) { + public function init(&$view, &$options) { parent::init($view, $options); $this->operator = $this->options['operator']; @@ -107,7 +118,10 @@ class views_handler_filter extends views_handler { } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['operator'] = array('default' => '='); @@ -122,13 +136,17 @@ class views_handler_filter extends views_handler { 'use_operator' => array('default' => FALSE, 'bool' => TRUE), 'operator_label' => array('default' => '', 'translatable' => TRUE), 'operator' => array('default' => ''), + 'limit_operators' => array('default' => FALSE, 'bool' => TRUE), + 'available_operators' => array('default' => array()), 'identifier' => array('default' => ''), 'required' => array('default' => FALSE, 'bool' => TRUE), 'remember' => array('default' => FALSE, 'bool' => TRUE), 'multiple' => array('default' => FALSE, 'bool' => TRUE), - 'remember_roles' => array('default' => array( - DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID, - )), + 'remember_roles' => array( + 'default' => array( + DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID, + ), + ), ), ); @@ -160,39 +178,42 @@ class views_handler_filter extends views_handler { } /** - * Display the filter on the administrative summary + * Display the filter on the administrative summary. */ - function admin_summary() { + public function admin_summary() { return check_plain((string) $this->operator) . ' ' . check_plain((string) $this->value); } /** * Determine if a filter can be exposed. */ - function can_expose() { return TRUE; } + public function can_expose() { + return TRUE; + } /** * Determine if a filter can be converted into a group. + * * Only exposed filters with operators available can be converted into groups. */ - function can_build_group() { + public function can_build_group() { return $this->is_exposed() && (count($this->operator_options()) > 0); } /** * Returns TRUE if the exposed filter works like a grouped filter. */ - function is_a_group() { + public function is_a_group() { return $this->is_exposed() && !empty($this->options['is_grouped']); } /** * Provide the basic form which calls through to subforms. - * If overridden, it is best to call through to the parent, - * or to at least make sure all of the functions in this form - * are called. + * + * If overridden, it is best to call through to the parent, or to at least + * make sure all of the functions in this form are called. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); if ($this->can_expose()) { $this->show_expose_button($form, $form_state); @@ -231,9 +252,9 @@ class views_handler_filter extends views_handler { } /** - * Simple validate handler + * Simple validate handler. */ - function options_validate(&$form, &$form_state) { + public function options_validate(&$form, &$form_state) { $this->operator_validate($form, $form_state); $this->value_validate($form, $form_state); if (!empty($this->options['exposed']) && !$this->is_a_group()) { @@ -245,16 +266,20 @@ class views_handler_filter extends views_handler { } /** - * Simple submit handler + * Simple submit handler. */ - function options_submit(&$form, &$form_state) { - unset($form_state['values']['expose_button']); // don't store this. - unset($form_state['values']['group_button']); // don't store this. + public function options_submit(&$form, &$form_state) { + // Don't store these. + unset($form_state['values']['expose_button']); + unset($form_state['values']['group_button']); + if (!$this->is_a_group()) { $this->operator_submit($form, $form_state); $this->value_submit($form, $form_state); } if (!empty($this->options['exposed'])) { + $options = &$form_state['values']['options']['expose']; + $options['available_operators'] = (!empty($options['use_operator']) && !empty($options['limit_operators'])) ? array_filter($options['available_operators']) : array(); $this->expose_submit($form, $form_state); } if ($this->is_a_group()) { @@ -265,7 +290,7 @@ class views_handler_filter extends views_handler { /** * Shortcut to display the operator form. */ - function show_operator_form(&$form, &$form_state) { + public function show_operator_form(&$form, &$form_state) { $this->operator_form($form, $form_state); $form['operator']['#prefix'] = '
'; $form['operator']['#suffix'] = '
'; @@ -274,14 +299,29 @@ class views_handler_filter extends views_handler { /** * Options form subform for setting the operator. * - * This may be overridden by child classes, and it must - * define $form['operator']; + * This may be overridden by child classes, and it must define + * $form['operator']. * * @see options_form() */ - function operator_form(&$form, &$form_state) { + public function operator_form(&$form, &$form_state) { $options = $this->operator_options(); if (!empty($options)) { + $available = $this->options['expose']['available_operators']; + if ($this->options['expose']['limit_operators'] && count($available)) { + foreach ($options as $key => $value) { + if (!isset($available[$key])) { + unset($options[$key]); + } + } + + // Make sure we have a valid default value if the current one is + // excluded. + if (!isset($options[$this->operator])) { + // Just choose the first. + $this->operator = key($options); + } + } $form['operator'] = array( '#type' => count($options) < 10 ? 'radios' : 'select', '#title' => t('Operator'), @@ -293,25 +333,31 @@ class views_handler_filter extends views_handler { /** * Provide a list of options for the default operator form. - * Should be overridden by classes that don't override operator_form + * + * Should be overridden by classes that don't override operator_form. */ - function operator_options() { return array(); } + public function operator_options() { + return array(); + } /** * Validate the operator form. */ - function operator_validate($form, &$form_state) { } + public function operator_validate($form, &$form_state) { + } /** * Perform any necessary changes to the form values prior to storage. + * * There is no need for this function to actually store the data. */ - function operator_submit($form, &$form_state) { } + public function operator_submit($form, &$form_state) { + } /** * Shortcut to display the value form. */ - function show_value_form(&$form, &$form_state) { + public function show_value_form(&$form, &$form_state) { $this->value_form($form, $form_state); if (empty($this->no_operator)) { $form['value']['#prefix'] = '
' . (isset($form['value']['#prefix']) ? $form['value']['#prefix'] : ''); @@ -322,28 +368,33 @@ class views_handler_filter extends views_handler { /** * Options form subform for setting options. * - * This should be overridden by all child classes and it must - * define $form['value'] + * This should be overridden by all child classes and it must define + * $form['value']. * * @see options_form() */ - function value_form(&$form, &$form_state) { $form['value'] = array(); } + public function value_form(&$form, &$form_state) { + $form['value'] = array(); + } /** * Validate the options form. */ - function value_validate($form, &$form_state) { } + public function value_validate($form, &$form_state) { + } /** * Perform any necessary changes to the form values prior to storage. + * * There is no need for this function to actually store the data. */ - function value_submit($form, &$form_state) { } + public function value_submit($form, &$form_state) { + } /** * Shortcut to display the exposed options form. */ - function show_build_group_form(&$form, &$form_state) { + public function show_build_group_form(&$form, &$form_state) { if (empty($this->options['is_grouped'])) { return; } @@ -366,8 +417,7 @@ class views_handler_filter extends views_handler { /** * Shortcut to display the build_group/hide button. */ - function show_build_group_button(&$form, &$form_state) { - + public function show_build_group_button(&$form, &$form_state) { $form['group_button'] = array( '#prefix' => '
', '#suffix' => '
', @@ -412,10 +462,11 @@ class views_handler_filter extends views_handler { $form['group_button']['radios']['radios']['#default_value'] = 1; } } + /** * Shortcut to display the expose/hide button. */ - function show_expose_button(&$form, &$form_state) { + public function show_expose_button(&$form, &$form_state) { $form['expose_button'] = array( '#prefix' => '
', '#suffix' => '
', @@ -423,8 +474,8 @@ class views_handler_filter extends views_handler { '#weight' => -200, ); - // Add a checkbox for JS users, which will have behavior attached to it - // so it can replace the button. + // Add a checkbox for JS users, which will have behavior attached to it so + // it can replace the button. $form['expose_button']['checkbox'] = array( '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('js-only')), @@ -466,7 +517,7 @@ class views_handler_filter extends views_handler { * * @see options_form() */ - function expose_form(&$form, &$form_state) { + public function expose_form(&$form, &$form_state) { $form['#theme'] = 'views_ui_expose_filter_form'; // #flatten will move everything from $form['expose'][$key] to $form[$key] // prior to rendering. That's why the pre_render for it needs to run first, @@ -481,6 +532,33 @@ class views_handler_filter extends views_handler { '#title' => t('Required'), '#default_value' => $this->options['expose']['required'], ); + + $operator_options = $this->operator_options(); + if (count($operator_options)) { + $form['expose']['limit_operators'] = array( + '#type' => 'checkbox', + '#title' => t('Limit operators'), + '#description' => t('When checked, the operator will be exposed to the user'), + '#default_value' => !empty($this->options['expose']['limit_operators']), + '#dependency' => array( + 'edit-options-expose-use-operator' => array(1), + ), + '#description' => t('Restrict which operators will be available to select in the exposed operator form.'), + ); + + $form['expose']['available_operators'] = array( + '#type' => 'checkboxes', + '#title' => t('Limit the exposed operators'), + '#default_value' => $this->options['expose']['available_operators'], + '#prefix' => '
', + '#suffix' => '
', + '#description' => t('Select which operators will be available to select in the exposed operator form. If none are selected, all the operators listed here will be used.'), + '#options' => $operator_options, + '#dependency' => array( + 'edit-options-expose-limit-operators' => array(1), + ), + ); + } } else { $form['expose']['required'] = array( @@ -503,7 +581,7 @@ class views_handler_filter extends views_handler { ); if (!empty($form['operator']['#type'])) { - // Increase the width of the left (operator) column. + // Increase the width of the left (operator) column. $form['operator']['#prefix'] = '
'; $form['operator']['#suffix'] = '
'; $form['value']['#prefix'] = '
'; @@ -522,7 +600,7 @@ class views_handler_filter extends views_handler { '#size' => 40, '#description' => t('This will appear before your operator select field.'), '#dependency' => array( - 'edit-options-expose-use-operator' => array(1) + 'edit-options-expose-use-operator' => array(1), ), ); $form['expose']['operator_id'] = array( @@ -532,7 +610,7 @@ class views_handler_filter extends views_handler { '#size' => 40, '#description' => t('This will appear in the URL after the ? to identify this operator.'), '#dependency' => array( - 'edit-options-expose-use-operator' => array(1) + 'edit-options-expose-use-operator' => array(1), ), '#fieldset' => 'more', ); @@ -566,7 +644,7 @@ class views_handler_filter extends views_handler { '#description' => t('Remember exposed selection only for the selected user role(s). If you select no roles, the exposed data will never be stored.'), '#default_value' => $this->options['expose']['remember_roles'], '#options' => $role_options, - '#dependency' => array( + '#dependency' => array( 'edit-options-expose-remember' => array(1), ), ); @@ -584,7 +662,7 @@ class views_handler_filter extends views_handler { /** * Validate the options form. */ - function expose_validate($form, &$form_state) { + public function expose_validate($form, &$form_state) { if (empty($form_state['values']['options']['expose']['identifier'])) { form_error($form['expose']['identifier'], t('The identifier is required if the filter is exposed.')); } @@ -599,12 +677,18 @@ class views_handler_filter extends views_handler { if (!$this->view->display_handler->is_identifier_unique($form_state['id'], $form_state['values']['options']['expose']['identifier'])) { form_error($form['expose']['identifier'], t('This identifier is used by another handler.')); } + + // Filter out roles which weren't selected, so that they aren't exported. + // This is purely cosmetic. + if (!empty($form_state['values']['options']['expose']['remember_roles'])) { + $form_state['values']['options']['expose']['remember_roles'] = array_filter($form_state['values']['options']['expose']['remember_roles']); + } } - /** + /** * Validate the build group options form. */ - function build_group_validate($form, &$form_state) { + public function build_group_validate($form, &$form_state) { if (!empty($form_state['values']['options']['group_info'])) { if (empty($form_state['values']['options']['group_info']['identifier'])) { form_error($form['group_info']['identifier'], t('The identifier is required if the filter is exposed.')); @@ -625,13 +709,15 @@ class views_handler_filter extends views_handler { if (!empty($form_state['values']['options']['group_info']['group_items'])) { foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) { if (empty($group['remove'])) { - // Check if the title is defined but value wasn't defined. if (!empty($group['title'])) { - if ((!is_array($group['value']) && trim($group['value']) == "") || - (is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) == 0)) { - form_error($form['group_info']['group_items'][$id]['value'], - t('The value is required if title for this item is defined.')); + // No value is needed for 'empty' and 'not empty' operator. + if (!in_array($group['operator'], array('empty', 'not empty'))) { + if ((!is_array($group['value']) && trim($group['value']) == "") || + (is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) == 0)) { + form_error($form['group_info']['group_items'][$id]['value'], + t('The value is required if title for this item is defined.')); + } } } @@ -640,7 +726,7 @@ class views_handler_filter extends views_handler { (is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) > 0)) { if (empty($group['title'])) { form_error($form['group_info']['group_items'][$id]['title'], - t('The title is required if value for this item is defined.')); + t('The title is required if value for this item is defined.')); } } } @@ -651,11 +737,11 @@ class views_handler_filter extends views_handler { /** * Save new group items, re-enumerates and remove groups marked to delete. */ - function build_group_submit($form, &$form_state) { + public function build_group_submit($form, &$form_state) { $groups = array(); uasort($form_state['values']['options']['group_info']['group_items'], 'drupal_sort_weight'); - // Filter out removed items. + // Filter out removed items. // Start from 1 to avoid problems with #default_value in the widget. $new_id = 1; $new_default = 'All'; @@ -684,7 +770,7 @@ class views_handler_filter extends views_handler { /** * Provide default options for exposed filters. */ - function expose_options() { + public function expose_options() { $this->options['expose'] = array( 'use_operator' => FALSE, 'operator' => $this->options['id'] . '_op', @@ -697,10 +783,10 @@ class views_handler_filter extends views_handler { ); } - /** + /** * Provide default options for exposed filters. */ - function build_group_options() { + public function build_group_options() { $this->options['group_info'] = array( 'label' => $this->definition['title'], 'description' => NULL, @@ -716,12 +802,10 @@ class views_handler_filter extends views_handler { } /** - * Build a form containing a group of operator | values to apply as a - * single filter. + * Build a form with a group of operator | values to apply as a single filter. */ - function group_form(&$form, &$form_state) { + public function group_form(&$form, &$form_state) { if (!empty($this->options['group_info']['optional']) && !$this->multiple_exposed_input()) { - $old_any = $this->options['group_info']['widget'] == 'select' ? '' : '<Any>'; $any_label = variable_get('views_exposed_filter_any_label', 'new_any') == 'old_any' ? $old_any : t('- Any -'); $groups = array('All' => $any_label); @@ -750,7 +834,7 @@ class views_handler_filter extends views_handler { $form[$value]['#multiple'] = TRUE; } unset($form[$value]['#default_value']); - if (empty($form_state['input'])) { + if (empty($form_state['input'][$value])) { $form_state['input'][$value] = $this->group_info; } } @@ -759,13 +843,12 @@ class views_handler_filter extends views_handler { } } - /** - * Render our chunk of the exposed filter form when selecting + * Render our chunk of the exposed filter form when selecting. * * You can override this if it doesn't do what you expect. */ - function exposed_form(&$form, &$form_state) { + public function exposed_form(&$form, &$form_state) { if (empty($this->options['exposed'])) { return; } @@ -775,7 +858,7 @@ class views_handler_filter extends views_handler { $operator = $this->options['expose']['operator_id']; $this->operator_form($form, $form_state); $form[$operator] = $form['operator']; - $form[$operator]['#title'] = $this->options['expose']['operator_label']; + $form[$operator]['#title'] = $this->options['expose']['operator_label']; $form[$operator]['#title_display'] = 'invisible'; $this->exposed_translate($form[$operator], 'operator'); @@ -786,7 +869,19 @@ class views_handler_filter extends views_handler { // Build the form and set the value based on the identifier. if (!empty($this->options['expose']['identifier'])) { $value = $this->options['expose']['identifier']; - $this->value_form($form, $form_state); + if ($this->operator == 'empty' || $this->operator == 'not empty') { + $boolean = new views_handler_filter_boolean_operator(); + $boolean->value = $this->value = 'All'; + $boolean->value_value = $this->value_value = ''; + $boolean->value_options = $this->value_options = array( + 1 => t('Yes'), + 0 => t('No'), + ); + $boolean->value_form($form, $form_state); + } + else { + $this->value_form($form, $form_state); + } $form[$value] = $form['value']; if (isset($form[$value]['#title']) && !empty($form[$value]['#type']) && $form[$value]['#type'] != 'checkbox') { @@ -811,18 +906,19 @@ class views_handler_filter extends views_handler { /** * Build the form to let users create the group of exposed filters. + * * This form is displayed when users click on button 'Build group' */ - function build_group_form(&$form, &$form_state) { + public function build_group_form(&$form, &$form_state) { if (empty($this->options['exposed']) || empty($this->options['is_grouped'])) { return; } $form['#theme'] = 'views_ui_build_group_filter_form'; - // #flatten will move everything from $form['group_info'][$key] to $form[$key] - // prior to rendering. That's why the pre_render for it needs to run first, - // so that when the next pre_render (the one for fieldsets) runs, it gets - // the flattened data. + // #flatten will move everything from $form['group_info'][$key] to + // $form[$key] prior to rendering. That's why the pre_render for it needs + // to run first, so that when the next pre_render (the one for fieldsets) + // runs, it gets the flattened data. array_unshift($form['#pre_render'], 'views_ui_pre_render_flatten_data'); $form['group_info']['#flatten'] = TRUE; @@ -925,7 +1021,9 @@ class views_handler_filter extends views_handler { '#default_value' => $this->options['group_info']['remember'], ); - $groups = array('All' => '- Any -'); // The string '- Any -' will not be rendered see @theme_views_ui_build_group_filter_form + // The string '- Any -' will not be rendered. + // @see theme_views_ui_build_group_filter_form() + $groups = array('All' => '- Any -'); // Provide 3 options to start when we are in a new group. if (count($this->options['group_info']['group_items']) == 0) { @@ -938,27 +1036,28 @@ class views_handler_filter extends views_handler { if (!empty($form_state['values']['options']['group_info']['group_items'][$item_id]['remove'])) { continue; } - // Each rows contains three widgets: - // a) The title, where users define how they identify a pair of operator | value - // b) The operator - // c) The value (or values) to use in the filter with the selected operator + // Each rows contains three widgets: + // a) The title, where users define how they identify a pair of operator + // | value. + // b) The operator. + // c) The value (or values) to use in the filter with the selected + // operator. // In each row, we have to display the operator form and the value from // $row acts as a fake form to render each widget in a row. $row = array(); $groups[$item_id] = ''; $this->operator_form($row, $form_state); - // Force the operator form to be a select box. Some handlers uses - // radios and they occupy a lot of space in a table row. + // Force the operator form to be a select box. Some handlers uses radios + // and they occupy a lot of space in a table row. $row['operator']['#type'] = 'select'; $row['operator']['#title'] = ''; $this->value_form($row, $form_state); - // Fix the dependencies to update value forms when operators - // changes. This is needed because forms are inside a new form and - // their ids changes. Dependencies are used when operator changes - // from to 'Between', 'Not Between', etc, and two or more widgets - // are displayed. + // Fix the dependencies to update value forms when operators changes. + // This is needed because forms are inside a new form and their IDs + // changes. Dependencies are used when operator changes from to + // 'Between', 'Not Between', etc, and two or more widgets are displayed. $without_children = TRUE; foreach (element_children($row['value']) as $children) { if (isset($row['value'][$children]['#dependency']['edit-options-operator'])) { @@ -1005,12 +1104,13 @@ class views_handler_filter extends views_handler { ), 'weight' => array( '#type' => 'weight', - '#delta' => 10, + '#delta' => count($this->options['group_info']['group_items']), '#default_value' => $default_weight++, '#attributes' => array('class' => array('weight')), ), ); } + // From all groups, let chose which is the default. $form['group_info']['default_group'] = array( '#type' => 'radios', @@ -1019,8 +1119,9 @@ class views_handler_filter extends views_handler { '#required' => TRUE, '#attributes' => array( 'class' => array('default-radios'), - ) + ), ); + // From all groups, let chose which is the default. $form['group_info']['default_group_multiple'] = array( '#type' => 'checkboxes', @@ -1028,7 +1129,7 @@ class views_handler_filter extends views_handler { '#default_value' => $this->options['group_info']['default_group_multiple'], '#attributes' => array( 'class' => array('default-checkboxes'), - ) + ), ); $form['group_info']['add_group'] = array( @@ -1056,12 +1157,10 @@ class views_handler_filter extends views_handler { } } - /** - * Make some translations to a form item to make it more suitable to - * exposing. + * Make some translations to a form item to make it more suitable to exposing. */ - function exposed_translate(&$form, $type) { + public function exposed_translate(&$form, $type) { if (!isset($form['#type'])) { return; } @@ -1083,7 +1182,8 @@ class views_handler_filter extends views_handler { $form['#size'] = NULL; } - // Cleanup in case the translated element's (radios or checkboxes) display value contains html. + // Cleanup in case the translated element's (radios or checkboxes) display + // value contains html. if ($form['#type'] == 'select') { $this->prepare_filter_select_options($form['#options']); } @@ -1099,21 +1199,19 @@ class views_handler_filter extends views_handler { } } - - /** * Sanitizes the HTML select element's options. * * The function is recursive to support optgroups. */ - function prepare_filter_select_options(&$options) { + public function prepare_filter_select_options(&$options) { foreach ($options as $value => $label) { // Recurse for optgroups. if (is_array($label)) { $this->prepare_filter_select_options($options[$value]); } // FAPI has some special value to allow hierarchy. - // @see _form_options_flatten + // @see _form_options_flatten() elseif (is_object($label)) { $this->prepare_filter_select_options($options[$value]->option); } @@ -1124,8 +1222,10 @@ class views_handler_filter extends views_handler { } /** - * Tell the renderer about our exposed form. This only needs to be - * overridden for particularly complex forms. And maybe not even then. + * Tell the renderer about our exposed form. + * + * This only needs to be overridden for particularly complex forms. And maybe + * not even then. * * @return array|null * For standard exposed filters. An array with the following keys: @@ -1136,7 +1236,7 @@ class views_handler_filter extends views_handler { * - value: The $form key of the value. Set to NULL if no value. * - label: The label to use for this piece. */ - function exposed_info() { + public function exposed_info() { if (empty($this->options['exposed'])) { return; } @@ -1157,21 +1257,21 @@ class views_handler_filter extends views_handler { ); } - /* + /** * Transform the input from a grouped filter into a standard filter. * - * When a filter is a group, find the set of operator and values - * that the choosed item represents, and inform views that a normal - * filter was submitted by telling the operator and the value selected. + * When a filter is a group, find the set of operator and values that the + * choosen item represents, and inform views that a normal filter was + * submitted by telling the operator and the value selected. * * The param $selected_group_id is only passed when the filter uses the - * checkboxes widget, and this function will be called for each item - * choosed in the checkboxes. + * checkboxes widget, and this function will be called for each item choosen + * in the checkboxes. */ - function convert_exposed_input(&$input, $selected_group_id = NULL) { + public function convert_exposed_input(&$input, $selected_group_id = NULL) { if ($this->is_a_group()) { - // If it is already defined the selected group, use it. Only valid - // when the filter uses checkboxes for widget. + // If it is already defined the selected group, use it. Only valid when + // the filter uses checkboxes for widget. if (!empty($selected_group_id)) { $selected_group = $selected_group_id; } @@ -1187,7 +1287,8 @@ class views_handler_filter extends views_handler { if (isset($selected_group) && isset($this->options['group_info']['group_items'][$selected_group])) { $input[$this->options['expose']['operator']] = $this->options['group_info']['group_items'][$selected_group]['operator']; - // Value can be optional, For example for 'empty' and 'not empty' filters. + // Value can be optional, For example for 'empty' and 'not empty' + // filters. if (!empty($this->options['group_info']['group_items'][$selected_group]['value'])) { $input[$this->options['expose']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value']; } @@ -1203,11 +1304,14 @@ class views_handler_filter extends views_handler { } /** - * Returns the options available for a grouped filter that users checkboxes - * as widget, and therefore has to be applied several times, one per - * item selected. + * Options available for a grouped filter which uses checkboxes. + * + * Note: has to be applied several times, one per item selected. + * + * @return array + * The options available for a grouped filter. */ - function group_multiple_exposed_input(&$input) { + public function group_multiple_exposed_input(&$input) { if (!empty($input[$this->options['group_info']['identifier']])) { return array_filter($input[$this->options['group_info']['identifier']]); } @@ -1215,19 +1319,23 @@ class views_handler_filter extends views_handler { } /** - * Returns TRUE if users can select multiple groups items of a - * grouped exposed filter. + * Indicate whether users can select multiple group items. + * + * @return bool + * TRUE if users can select multiple groups items of a grouped exposed + * filter. */ - function multiple_exposed_input() { + public function multiple_exposed_input() { return $this->is_a_group() && !empty($this->options['group_info']['multiple']); } /** * If set to remember exposed input in the session, store it there. - * This function is similar to store_exposed_input but modified to - * work properly when the filter is a group. + * + * This function is similar to store_exposed_input but modified to work + * properly when the filter is a group. */ - function store_group_input($input, $status) { + public function store_group_input($input, $status) { if (!$this->is_a_group() || empty($this->options['group_info']['identifier'])) { return TRUE; } @@ -1236,12 +1344,12 @@ class views_handler_filter extends views_handler { return; } - // Figure out which display id is responsible for the filters, so we - // know where to look for session stored values. + // Figure out which display id is responsible for the filters, so we know + // where to look for session stored values. $display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display; - // false means that we got a setting that means to recuse ourselves, - // so we should erase whatever happened to be there. + // False means that we got a setting that means to recuse ourselves, so we + // should erase whatever happened to be there. if ($status === FALSE && isset($_SESSION['views'][$this->view->name][$display_id])) { $session = &$_SESSION['views'][$this->view->name][$display_id]; @@ -1262,15 +1370,13 @@ class views_handler_filter extends views_handler { } /** - * Check to see if input from the exposed filters should change - * the behavior of this filter. + * Check to see if input from the exposed filters should change the behavior. */ - function accept_exposed_input($input) { + public function accept_exposed_input($input) { if (empty($this->options['exposed'])) { return TRUE; } - if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']) && isset($input[$this->options['expose']['operator_id']])) { $this->operator = $input[$this->options['expose']['operator_id']]; } @@ -1280,14 +1386,13 @@ class views_handler_filter extends views_handler { // Various ways to check for the absence of non-required input. if (empty($this->options['expose']['required'])) { - if (($this->operator == 'empty' || $this->operator == 'not empty') && $value === '') { - $value = ' '; + if ($this->operator == 'empty' || $this->operator == 'not empty') { + $value = is_array($value) ? $value['value'] : $value; + $this->operator = ($this->operator == 'empty' && empty($value)) || ($this->operator == 'not empty' && !empty($value)) ? 'not empty' : 'empty'; } - if ($this->operator != 'empty' && $this->operator != 'not empty') { - if ($value == 'All' || $value === array()) { - return FALSE; - } + if ($value == 'All' || $value === array()) { + return FALSE; } if (!empty($this->always_multiple) && $value === '') { @@ -1295,7 +1400,6 @@ class views_handler_filter extends views_handler { } } - if (isset($value)) { $this->value = $value; if (empty($this->always_multiple) && empty($this->options['expose']['multiple'])) { @@ -1310,7 +1414,10 @@ class views_handler_filter extends views_handler { return TRUE; } - function store_exposed_input($input, $status) { + /** + * Store the exposed input for processing later. + */ + public function store_exposed_input($input, $status) { if (empty($this->options['exposed']) || empty($this->options['expose']['identifier'])) { return TRUE; } @@ -1327,15 +1434,15 @@ class views_handler_filter extends views_handler { return; } - // Figure out which display id is responsible for the filters, so we - // know where to look for session stored values. + // Figure out which display id is responsible for the filters, so we know + // where to look for session stored values. $display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display; - // shortcut test. + // Shortcut test. $operator = !empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']); - // false means that we got a setting that means to recuse ourselves, - // so we should erase whatever happened to be there. + // False means that we got a setting that means to recuse ourselves, so we + // should erase whatever happened to be there. if (!$status && isset($_SESSION['views'][$this->view->name][$display_id])) { $session = &$_SESSION['views'][$this->view->name][$display_id]; if ($operator && isset($session[$this->options['expose']['operator_id']])) { @@ -1358,7 +1465,9 @@ class views_handler_filter extends views_handler { $session[$this->options['expose']['operator_id']] = $input[$this->options['expose']['operator_id']]; } - $session[$this->options['expose']['identifier']] = $input[$this->options['expose']['identifier']]; + if (isset($input[$this->options['expose']['identifier']])) { + $session[$this->options['expose']['identifier']] = $input[$this->options['expose']['identifier']]; + } } } @@ -1366,10 +1475,10 @@ class views_handler_filter extends views_handler { * Add this filter to the query. * * Due to the nature of fapi, the value and the operator have an unintended - * level of indirection. You will find them in $this->operator - * and $this->value respectively. + * level of indirection. You will find them in $this->operator and + * $this->value respectively. */ - function query() { + public function query() { $this->ensure_my_table(); $this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", $this->value, $this->operator); } @@ -1377,16 +1486,18 @@ class views_handler_filter extends views_handler { /** * Can this filter be used in OR groups? * - * Some filters have complicated where clauses that cannot be easily used - * with OR groups. Some filters must also use HAVING which also makes - * them not groupable. These filters will end up in a special group - * if OR grouping is in use. + * Some filters have complicated where clauses that cannot be easily used with + * OR groups. Some filters must also use HAVING which also makes them not + * groupable. These filters will end up in a special group if OR grouping is + * in use. * * @return bool + * Whether the filter can be used in OR groups. */ - function can_group() { - return TRUE; - } + public function can_group() { + return TRUE; + } + } @@ -1396,34 +1507,59 @@ class views_handler_filter extends views_handler { * @ingroup views_filter_handlers */ class views_handler_filter_broken extends views_handler_filter { - function ui_name($short = FALSE) { + + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return t('Broken/missing handler'); } - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function ensure_my_table() { + // No table to ensure! + } + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { + // No query to run. + } + + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['markup'] = array( '#markup' => '
' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '
', ); } /** - * Determine if the handler is considered 'broken' + * {@inheritdoc} */ - function broken() { return TRUE; } + public function broken() { + return TRUE; + } + } /** * Filter by no empty values, though allow to use "0". - * @param $var + * + * @param string $var + * The string to check. + * * @return bool + * Indicates if the argument is an empty string. */ function _views_array_filter_zero($var) { - return trim($var) != ""; + return trim($var) != ''; } - /** * @} */ diff --git a/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc b/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc index 56365e1..1b1791a 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc @@ -22,14 +22,26 @@ * @ingroup views_filter_handlers */ class views_handler_filter_boolean_operator extends views_handler_filter { - // exposed filter options - var $always_multiple = TRUE; - // Don't display empty space where the operator would be. - var $no_operator = TRUE; - // Whether to accept NULL as a false value or not - var $accept_null = FALSE; - function construct() { + /** + * Exposed filter options. + */ + public $always_multiple = TRUE; + + /** + * Don't display empty space where the operator would be. + */ + public $no_operator = TRUE; + + /** + * Whether to accept NULL as a false value or not. + */ + public $accept_null = FALSE; + + /** + * {@inheritdoc} + */ + public function construct() { $this->value_value = t('True'); if (isset($this->definition['label'])) { $this->value_value = $this->definition['label']; @@ -37,7 +49,7 @@ class views_handler_filter_boolean_operator extends views_handler_filter { if (isset($this->definition['accept null'])) { $this->accept_null = (bool) $this->definition['accept null']; } - else if (isset($this->definition['accept_null'])) { + elseif (isset($this->definition['accept_null'])) { $this->accept_null = (bool) $this->definition['accept_null']; } $this->value_options = NULL; @@ -56,7 +68,7 @@ class views_handler_filter_boolean_operator extends views_handler_filter { * dynamic for some reason, child classes should use a guard to reduce * database hits as much as possible. */ - function get_value_options() { + public function get_value_options() { if (isset($this->definition['type'])) { if ($this->definition['type'] == 'yes-no') { $this->value_options = array(1 => t('Yes'), 0 => t('No')); @@ -75,7 +87,10 @@ class views_handler_filter_boolean_operator extends views_handler_filter { } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['value']['default'] = FALSE; @@ -83,11 +98,17 @@ class views_handler_filter_boolean_operator extends views_handler_filter { return $options; } - function operator_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function operator_form(&$form, &$form_state) { $form['operator'] = array(); } - function value_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function value_form(&$form, &$form_state) { if (empty($this->value_options)) { // Initialize the array of possible values for this filter. $this->get_value_options(); @@ -122,13 +143,19 @@ class views_handler_filter_boolean_operator extends views_handler_filter { } } - function value_validate($form, &$form_state) { + /** + * {@inheritdoc} + */ + public function value_validate($form, &$form_state) { if ($form_state['values']['options']['value'] == 'All' && !empty($form_state['values']['options']['expose']['required'])) { form_set_error('value', t('You must select a value unless this is an non-required exposed filter.')); } } - function admin_summary() { + /** + * {@inheritdoc} + */ + public function admin_summary() { if ($this->is_a_group()) { return t('grouped'); } @@ -145,14 +172,20 @@ class views_handler_filter_boolean_operator extends views_handler_filter { return $this->value_options[!empty($this->value)]; } - function expose_options() { + /** + * {@inheritdoc} + */ + public function expose_options() { parent::expose_options(); $this->options['expose']['operator_id'] = ''; $this->options['expose']['label'] = $this->value_value; $this->options['expose']['required'] = TRUE; } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $field = "$this->table_alias.$this->real_field"; @@ -176,4 +209,5 @@ class views_handler_filter_boolean_operator extends views_handler_filter { } } } + } diff --git a/sites/all/modules/views/handlers/views_handler_filter_boolean_operator_string.inc b/sites/all/modules/views/handlers/views_handler_filter_boolean_operator_string.inc index 080ac50..52245a1 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_boolean_operator_string.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_boolean_operator_string.inc @@ -17,7 +17,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_boolean_operator_string extends views_handler_filter_boolean_operator { - function query() { + + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $where = "$this->table_alias.$this->real_field "; @@ -32,4 +36,5 @@ class views_handler_filter_boolean_operator_string extends views_handler_filter_ } $this->query->add_where_expression($this->options['group'], $where); } + } diff --git a/sites/all/modules/views/handlers/views_handler_filter_combine.inc b/sites/all/modules/views/handlers/views_handler_filter_combine.inc index c1afcf5..35bfb20 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_combine.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_combine.inc @@ -11,19 +11,26 @@ * @ingroup views_field_handlers */ class views_handler_filter_combine extends views_handler_filter_string { + /** * @var views_plugin_query_default */ public $query; - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['fields'] = array('default' => array()); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $this->view->init_style(); @@ -49,7 +56,10 @@ class views_handler_filter_combine extends views_handler_filter_string { } } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->view->_build('field'); $fields = array(); // Only add the fields if they have a proper field and table alias. @@ -63,7 +73,7 @@ class views_handler_filter_combine extends views_handler_filter_string { // Always add the table of the selected fields to be sure a table alias // exists. $field->ensure_my_table(); - if (!empty($field->field_alias) && !empty($field->field_alias)) { + if (!empty($field->table_alias) && !empty($field->real_field)) { $fields[] = "$field->table_alias.$field->real_field"; } } @@ -86,20 +96,28 @@ class views_handler_filter_combine extends views_handler_filter_string { } } - // By default things like op_equal uses add_where, that doesn't support - // complex expressions, so override all operators. - function op_equal($field) { + /** + * By default things like op_equal uses add_where, that doesn't support + * complex expressions, so override all operators. + */ + public function op_equal($field) { $placeholder = $this->placeholder(); $operator = $this->operator(); $this->query->add_where_expression($this->options['group'], "$field $operator $placeholder", array($placeholder => $this->value)); } - function op_contains($field) { + /** + * + */ + public function op_contains($field) { $placeholder = $this->placeholder(); $this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%')); } - function op_word($field) { + /** + * + */ + public function op_word($field) { $where = $this->operator == 'word' ? db_or() : db_and(); // Don't filter on empty strings. @@ -132,37 +150,66 @@ class views_handler_filter_combine extends views_handler_filter_string { $this->query->add_where($this->options['group'], $where); } - function op_starts($field) { + /** + * + */ + public function op_starts($field) { $placeholder = $this->placeholder(); $this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => db_like($this->value) . '%')); } - function op_not_starts($field) { + /** + * + */ + public function op_not_starts($field) { $placeholder = $this->placeholder(); $this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => db_like($this->value) . '%')); } - function op_ends($field) { + /** + * + */ + public function op_ends($field) { $placeholder = $this->placeholder(); $this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value))); } - function op_not_ends($field) { + /** + * + */ + public function op_not_ends($field) { $placeholder = $this->placeholder(); $this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value))); } - function op_not($field) { + /** + * + */ + public function op_not($field) { $placeholder = $this->placeholder(); $this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%')); } - function op_regex($field) { + /** + * + */ + public function op_regex($field) { $placeholder = $this->placeholder(); $this->query->add_where_expression($this->options['group'], "$field RLIKE $placeholder", array($placeholder => $this->value)); } - function op_empty($field) { + /** + * + */ + public function op_not_regex($field) { + $placeholder = $this->placeholder(); + $this->query->add_where_expression($this->options['group'], "$field NOT RLIKE $placeholder", array($placeholder => $this->value)); + } + + /** + * + */ + public function op_empty($field) { if ($this->operator == 'empty') { $operator = "IS NULL"; } @@ -172,4 +219,5 @@ class views_handler_filter_combine extends views_handler_filter_string { $this->query->add_where_expression($this->options['group'], "$field $operator"); } + } diff --git a/sites/all/modules/views/handlers/views_handler_filter_date.inc b/sites/all/modules/views/handlers/views_handler_filter_date.inc index 3831327..26fb1a3 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_date.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_date.inc @@ -11,19 +11,23 @@ * @ingroup views_filter_handlers */ class views_handler_filter_date extends views_handler_filter_numeric { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); - // value is already set up properly, we're just adding our new field to it. + // Value is already set up properly, we're just adding our new field to it. $options['value']['contains']['type']['default'] = 'date'; return $options; } /** - * Add a type selector to the value form + * Add a type selector to the value form. */ - function value_form(&$form, &$form_state) { + public function value_form(&$form, &$form_state) { if (empty($form_state['exposed'])) { $form['value']['type'] = array( '#type' => 'radios', @@ -38,7 +42,10 @@ class views_handler_filter_date extends views_handler_filter_numeric { parent::value_form($form, $form_state); } - function options_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { parent::options_validate($form, $form_state); if (!empty($this->options['exposed']) && empty($form_state['values']['options']['expose']['required'])) { @@ -49,7 +56,10 @@ class views_handler_filter_date extends views_handler_filter_numeric { $this->validate_valid_time($form['value'], $form_state['values']['options']['operator'], $form_state['values']['options']['value']); } - function exposed_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function exposed_validate(&$form, &$form_state) { if (empty($this->options['exposed'])) { return; } @@ -74,7 +84,7 @@ class views_handler_filter_date extends views_handler_filter_numeric { /** * Validate that the time values convert to something usable. */ - function validate_valid_time(&$form, $operator, $value) { + public function validate_valid_time(&$form, $operator, $value) { $operators = $this->operators(); if ($operators[$operator]['values'] == 1) { @@ -98,7 +108,7 @@ class views_handler_filter_date extends views_handler_filter_numeric { /** * Validate the build group options form. */ - function build_group_validate($form, &$form_state) { + public function build_group_validate($form, &$form_state) { // Special case to validate grouped date filters, this is because the // $group['value'] array contains the type of filter (date or offset) // and therefore the number of items the comparission has to be done @@ -122,8 +132,10 @@ class views_handler_filter_date extends views_handler_filter_numeric { } } - - function accept_exposed_input($input) { + /** + * {@inheritdoc} + */ + public function accept_exposed_input($input) { if (empty($this->options['exposed'])) { return TRUE; } @@ -146,36 +158,45 @@ class views_handler_filter_date extends views_handler_filter_numeric { return FALSE; } } - else { + elseif ($operators[$operator]['values'] == 2) { if ($this->value['min'] == '' || $this->value['max'] == '') { return FALSE; } } - // restore what got overwritten by the parent. + // Restore what got overwritten by the parent. $this->value['type'] = $type; return $rc; } - function op_between($field) { + /** + * + */ + public function op_between($field) { // Use the substitutions to ensure a consistent timestamp. $query_substitutions = views_views_query_substitutions($this->view); $a = intval(strtotime($this->value['min'], $query_substitutions['***CURRENT_TIME***'])); $b = intval(strtotime($this->value['max'], $query_substitutions['***CURRENT_TIME***'])); - // This is safe because we are manually scrubbing the values. - // It is necessary to do it this way because $a and $b are formulas when using an offset. + // This is safe because we are manually scrubbing the values. It is + // necessary to do it this way because $a and $b are formulas when using an + // offset. $operator = strtoupper($this->operator); $this->query->add_where_expression($this->options['group'], "$field $operator $a AND $b"); } - function op_simple($field) { + /** + * + */ + public function op_simple($field) { // Use the substitutions to ensure a consistent timestamp. $query_substitutions = views_views_query_substitutions($this->view); $value = intval(strtotime($this->value['value'], $query_substitutions['***CURRENT_TIME***'])); - // This is safe because we are manually scrubbing the value. - // It is necessary to do it this way because $value is a formula when using an offset. + // This is safe because we are manually scrubbing the value. It is + // necessary to do it this way because $value is a formula when using an + // offset. $this->query->add_where_expression($this->options['group'], "$field $this->operator $value"); } + } diff --git a/sites/all/modules/views/handlers/views_handler_filter_entity_bundle.inc b/sites/all/modules/views/handlers/views_handler_filter_entity_bundle.inc index c46cd0b..92cf8b4 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_entity_bundle.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_entity_bundle.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_filter_entity_bundle + * Definition of views_handler_filter_entity_bundle. */ /** @@ -13,6 +13,7 @@ * @ingroup views_filter_handlers */ class views_handler_filter_entity_bundle extends views_handler_filter_in_operator { + /** * Stores the entity type on which the filter filters. * @@ -20,7 +21,10 @@ class views_handler_filter_entity_bundle extends views_handler_filter_in_operato */ public $entity_type; - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); $this->get_entity_type(); @@ -32,16 +36,17 @@ class views_handler_filter_entity_bundle extends views_handler_filter_in_operato * @return string * The entity type on the filter. */ - function get_entity_type() { + public function get_entity_type() { if (!isset($this->entity_type)) { $data = views_fetch_data($this->table); if (isset($data['table']['entity type'])) { $this->entity_type = $data['table']['entity type']; } - // If the current filter is under a relationship you can't be sure that the - // entity type of the view is the entity type of the current filter - // For example a filter from a node author on a node view does have users as entity type. + // If the current filter is under a relationship you can't be sure that + // the entity type of the view is the entity type of the current filter + // For example a filter from a node author on a node view does have users + // as entity type. if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') { $relationships = $this->view->display_handler->get_option('relationships'); if (!empty($relationships[$this->options['relationship']])) { @@ -55,8 +60,10 @@ class views_handler_filter_entity_bundle extends views_handler_filter_in_operato return $this->entity_type; } - - function get_value_options() { + /** + * {@inheritdoc} + */ + public function get_value_options() { if (!isset($this->value_options)) { $info = entity_get_info($this->entity_type); $types = $info['bundles']; @@ -76,7 +83,7 @@ class views_handler_filter_entity_bundle extends views_handler_filter_in_operato * bundle, though these two need an additional join to node/vocab table * to work as required. */ - function query() { + public function query() { $this->ensure_my_table(); // Adjust the join for the comment case. @@ -119,4 +126,5 @@ class views_handler_filter_entity_bundle extends views_handler_filter_in_operato } parent::query(); } + } diff --git a/sites/all/modules/views/handlers/views_handler_filter_equality.inc b/sites/all/modules/views/handlers/views_handler_filter_equality.inc index e045c7e..76428ca 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_equality.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_equality.inc @@ -6,18 +6,21 @@ */ /** - * Simple filter to handle equal to / not equal to filters + * Simple filter to handle equal to / not equal to filters. * * @ingroup views_filter_handlers */ class views_handler_filter_equality extends views_handler_filter { - // exposed filter options - var $always_multiple = TRUE; /** - * Provide simple equality operator + * Exposed filter options. */ - function operator_options() { + public $always_multiple = TRUE; + + /** + * Provide simple equality operator. + */ + public function operator_options() { return array( '=' => t('Is equal to'), '!=' => t('Is not equal to'), @@ -25,9 +28,9 @@ class views_handler_filter_equality extends views_handler_filter { } /** - * Provide a simple textfield for equality + * Provide a simple textfield for equality. */ - function value_form(&$form, &$form_state) { + public function value_form(&$form, &$form_state) { $form['value'] = array( '#type' => 'textfield', '#title' => t('Value'), @@ -42,4 +45,5 @@ class views_handler_filter_equality extends views_handler_filter { } } } + } diff --git a/sites/all/modules/views/handlers/views_handler_filter_fields_compare.inc b/sites/all/modules/views/handlers/views_handler_filter_fields_compare.inc index fe94ce7..7f33501 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_fields_compare.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_fields_compare.inc @@ -10,17 +10,19 @@ * * @ingroup views_filter_handlers */ - class views_handler_filter_fields_compare extends views_handler_filter { - function can_expose() { + /** + * {@inheritdoc} + */ + public function can_expose() { return FALSE; } /** - * Overrides views_handler_filter#option_definition(). + * {@inheritdoc} */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); $options['left_field'] = $options['right_field'] = array('default' => ''); @@ -31,21 +33,21 @@ class views_handler_filter_fields_compare extends views_handler_filter { /** * Provide a list of all operators. */ - function fields_operator_options() { + public function fields_operator_options() { return array( '<' => t('Is less than'), '<=' => t('Is less than or equal to'), '=' => t('Is equal to'), - '<>' => t('Is not equal to'), + '<>' => t('Is not equal to'), '>=' => t('Is greater than or equal to'), - '>' => t('Is greater than') + '>' => t('Is greater than'), ); } /** * Provide a list of available fields. */ - function field_options() { + public function field_options() { $options = array(); $field_handlers = $this->view->display_handler->get_handlers('field'); @@ -59,9 +61,9 @@ class views_handler_filter_fields_compare extends views_handler_filter { } /** - * Overrides views_handler_filter#options_form(). + * {@inheritdoc} */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $field_options = $this->field_options(); @@ -93,11 +95,10 @@ class views_handler_filter_fields_compare extends views_handler_filter { } /** - * Overrides views_handler_filter#query(). - * - * Build extra condition from existing fields (from existing joins). + * {@inheritdoc} */ - function query() { + public function query() { + // Build extra condition from existing fields (from existing joins). $left = $this->options['left_field']; $right = $this->options['right_field']; @@ -120,22 +121,21 @@ class views_handler_filter_fields_compare extends views_handler_filter { $right_table_alias = $this->query->ensure_table($right_handler->table, $right_handler->relationship); // Build piece of SQL. - $snippet = - $left_table_alias . '.' . $left_handler->real_field . - ' ' . $this->options['operator'] . ' ' . - $right_table_alias . '.' . $right_handler->real_field; + $snippet = $left_table_alias . '.' . $left_handler->real_field + . ' ' . $this->options['operator'] . ' ' + . $right_table_alias . '.' . $right_handler->real_field; $this->query->add_where_expression($this->options['group'], $snippet); } /** - * Overrides views_handler_filter#admin_summary(). + * {@inheritdoc} */ - function admin_summary() { + public function admin_summary() { return check_plain( - $this->options['left_field'] . ' ' . - $this->options['operator'] . ' ' . - $this->options['right_field'] + $this->options['left_field'] . ' ' + . $this->options['operator'] . ' ' + . $this->options['right_field'] ); } diff --git a/sites/all/modules/views/handlers/views_handler_filter_group_by_numeric.inc b/sites/all/modules/views/handlers/views_handler_filter_group_by_numeric.inc index 2b265be..173228d 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_group_by_numeric.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_group_by_numeric.inc @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_group_by_numeric extends views_handler_filter_numeric { - function query() { + + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $field = $this->get_field(); @@ -20,7 +24,11 @@ class views_handler_filter_group_by_numeric extends views_handler_filter_numeric $this->{$info[$this->operator]['method']}($field); } } - function op_between($field) { + + /** + * {@inheritdoc} + */ + public function op_between($field) { $placeholder_min = $this->placeholder(); $placeholder_max = $this->placeholder(); if ($this->operator == 'between') { @@ -32,12 +40,18 @@ class views_handler_filter_group_by_numeric extends views_handler_filter_numeric } } - function op_simple($field) { + /** + * {@inheritdoc} + */ + public function op_simple($field) { $placeholder = $this->placeholder(); $this->query->add_having_expression($this->options['group'], "$field $this->operator $placeholder", array($placeholder => $this->value['value'])); } - function op_empty($field) { + /** + * {@inheritdoc} + */ + public function op_empty($field) { if ($this->operator == 'empty') { $operator = "IS NULL"; } @@ -48,9 +62,18 @@ class views_handler_filter_group_by_numeric extends views_handler_filter_numeric $this->query->add_having_expression($this->options['group'], "$field $operator"); } - function ui_name($short = FALSE) { + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return $this->get_field(parent::ui_name($short)); } - function can_group() { return FALSE; } + /** + * {@inheritdoc} + */ + public function can_group() { + return FALSE; + } + } diff --git a/sites/all/modules/views/handlers/views_handler_filter_in_operator.inc b/sites/all/modules/views/handlers/views_handler_filter_in_operator.inc index fc2700b..c20e8f0 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_in_operator.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_in_operator.inc @@ -6,24 +6,32 @@ */ /** - * Simple filter to handle matching of multiple options selectable via checkboxes + * Simple filter to handle matching of multiple options using checkboxes. * * Definition items: - * - options callback: The function to call in order to generate the value options. If omitted, the options 'Yes' and 'No' will be used. + * - options callback: The function to call in order to generate the value + * options. If omitted, the options 'Yes' and 'No' will be used. * - options arguments: An array of arguments to pass to the options callback. * * @ingroup views_filter_handlers */ class views_handler_filter_in_operator extends views_handler_filter { - var $value_form_type = 'checkboxes'; + + /** + * + */ + public $value_form_type = 'checkboxes'; /** * @var array * Stores all operations which are available on the form. */ - var $value_options = NULL; + public $value_options = NULL; - function construct() { + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->value_title = t('Options'); $this->value_options = NULL; @@ -40,7 +48,7 @@ class views_handler_filter_in_operator extends views_handler_filter { * @return * Return the stored values in $this->value_options if someone expects it. */ - function get_value_options() { + public function get_value_options() { if (isset($this->value_options)) { return; } @@ -60,22 +68,32 @@ class views_handler_filter_in_operator extends views_handler_filter { return $this->value_options; } - function expose_options() { + /** + * {@inheritdoc} + */ + public function expose_options() { parent::expose_options(); $this->options['expose']['reduce'] = FALSE; } - function expose_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function expose_form(&$form, &$form_state) { parent::expose_form($form, $form_state); $form['expose']['reduce'] = array( '#type' => 'checkbox', '#title' => t('Limit list to selected items'), '#description' => t('If checked, the only items presented to the user will be the ones selected here.'), - '#default_value' => !empty($this->options['expose']['reduce']), // safety + // Safety. + '#default_value' => !empty($this->options['expose']['reduce']), ); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['operator']['default'] = 'in'; @@ -86,11 +104,11 @@ class views_handler_filter_in_operator extends views_handler_filter { } /** - * This kind of construct makes it relatively easy for a child class - * to add or remove functionality by overriding this function and - * adding/removing items from this array. + * This kind of construct makes it relatively easy for a child class to add or + * remove functionality by overriding this function and adding/removing items + * from this array. */ - function operators() { + public function operators() { $operators = array( 'in' => array( 'title' => t('Is one of'), @@ -129,9 +147,9 @@ class views_handler_filter_in_operator extends views_handler_filter { } /** - * Build strings from the operators() for 'select' options + * Build strings from the operators() for 'select' options. */ - function operator_options($which = 'title') { + public function operator_options($which = 'title') { $options = array(); foreach ($this->operators() as $id => $info) { $options[$id] = $info[$which]; @@ -140,7 +158,10 @@ class views_handler_filter_in_operator extends views_handler_filter { return $options; } - function operator_values($values = 1) { + /** + * {@inheritdoc} + */ + public function operator_values($values = 1) { $options = array(); foreach ($this->operators() as $id => $info) { if (isset($info['values']) && $info['values'] == $values) { @@ -151,7 +172,10 @@ class views_handler_filter_in_operator extends views_handler_filter { return $options; } - function value_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function value_form(&$form, &$form_state) { $form['value'] = array(); $options = array(); @@ -172,7 +196,7 @@ class views_handler_filter_in_operator extends views_handler_filter { $identifier = $this->options['expose']['identifier']; if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator_id'])) { - // exposed and locked. + // Exposed and locked. $which = in_array($this->operator, $this->operator_values(1)) ? 'value' : 'none'; } else { @@ -229,7 +253,7 @@ class views_handler_filter_in_operator extends views_handler_filter { /** * When using exposed filters, we may be required to reduce the set. */ - function reduce_value_options($input = NULL) { + public function reduce_value_options($input = NULL) { if (!isset($input)) { $input = $this->value_options; } @@ -257,9 +281,12 @@ class views_handler_filter_in_operator extends views_handler_filter { return $options; } - function accept_exposed_input($input) { + /** + * {@inheritdoc} + */ + public function accept_exposed_input($input) { // A very special override because the All state for this type of - // filter could have a default: + // filter could have a default. if (empty($this->options['exposed'])) { return TRUE; } @@ -276,7 +303,10 @@ class views_handler_filter_in_operator extends views_handler_filter { return parent::accept_exposed_input($input); } - function value_submit($form, &$form_state) { + /** + * {@inheritdoc} + */ + public function value_submit($form, &$form_state) { // Drupal's FAPI system automatically puts '0' in for any checkbox that // was not set, and the key to the checkbox if it is set. // Unfortunately, this means that if the key to that checkbox is 0, @@ -289,7 +319,10 @@ class views_handler_filter_in_operator extends views_handler_filter { $form_state['values']['options']['value'] = $form['value']['#value']; } - function admin_summary() { + /** + * {@inheritdoc} + */ + public function admin_summary() { if ($this->is_a_group()) { return t('grouped'); } @@ -317,7 +350,7 @@ class views_handler_filter_in_operator extends views_handler_filter { if (count($this->value) == 0) { $values = t('Unknown'); } - else if (count($this->value) == 1) { + elseif (count($this->value) == 1) { // If any, use the 'single' short name of the operator instead. if (isset($info[$this->operator]['short_single'])) { $operator = check_plain($info[$this->operator]['short_single']); @@ -351,14 +384,20 @@ class views_handler_filter_in_operator extends views_handler_filter { return $operator . (($values !== '') ? ' ' . $values : ''); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $info = $this->operators(); if (!empty($info[$this->operator]['method'])) { $this->{$info[$this->operator]['method']}(); } } - function op_simple() { + /** + * {@inheritdoc} + */ + public function op_simple() { if (empty($this->value)) { return; } @@ -369,7 +408,10 @@ class views_handler_filter_in_operator extends views_handler_filter { $this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", array_values($this->value), $this->operator); } - function op_empty() { + /** + * {@inheritdoc} + */ + public function op_empty() { $this->ensure_my_table(); if ($this->operator == 'empty') { $operator = "IS NULL"; @@ -381,7 +423,10 @@ class views_handler_filter_in_operator extends views_handler_filter { $this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", NULL, $operator); } - function validate() { + /** + * {@inheritdoc} + */ + public function validate() { $this->get_value_options(); $errors = array(); @@ -396,11 +441,13 @@ class views_handler_filter_in_operator extends views_handler_filter { } if (is_array($this->value)) { if (!isset($this->value_options)) { - // Don't validate if there are none value options provided, for example for special handlers. + // Don't validate if there are none value options provided, for example + // for special handlers. return $errors; } if ($this->options['exposed'] && !$this->options['expose']['required'] && empty($this->value)) { - // Don't validate if the field is exposed and no default value is provided. + // Don't validate if the field is exposed and no default value is + // provided. return $errors; } @@ -423,4 +470,5 @@ class views_handler_filter_in_operator extends views_handler_filter { } return $errors; } + } diff --git a/sites/all/modules/views/handlers/views_handler_filter_many_to_one.inc b/sites/all/modules/views/handlers/views_handler_filter_many_to_one.inc index f384796..c14af20 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_many_to_one.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_many_to_one.inc @@ -6,8 +6,9 @@ */ /** - * Complex filter to handle filtering for many to one relationships, - * such as terms (many terms per node) or roles (many roles per user). + * Complex filter to handle filtering for many to one relationships. + * + * Examples: terms (many terms per node), roles (many roles per user). * * The construct method needs to be overridden to provide a list of options; * alternately, the value_form and admin_summary methods need to be overriden @@ -16,19 +17,31 @@ * @ingroup views_filter_handlers */ class views_handler_filter_many_to_one extends views_handler_filter_in_operator { + /** * @var views_many_to_one_helper * * Stores the Helper object which handles the many_to_one complexity. */ - var $helper = NULL; + public $helper = NULL; - function init(&$view, &$options) { + /** + * + */ + public $value_form_type = 'select'; + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); $this->helper = new views_many_to_one_helper($this); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['operator']['default'] = 'or'; @@ -45,7 +58,10 @@ class views_handler_filter_many_to_one extends views_handler_filter_in_operator return $options; } - function operators() { + /** + * {@inheritdoc} + */ + public function operators() { $operators = array( 'or' => array( 'title' => t('Is one of'), @@ -93,8 +109,10 @@ class views_handler_filter_many_to_one extends views_handler_filter_in_operator return $operators; } - var $value_form_type = 'select'; - function value_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function value_form(&$form, &$form_state) { parent::value_form($form, $form_state); if (empty($form_state['exposed'])) { @@ -106,7 +124,7 @@ class views_handler_filter_many_to_one extends views_handler_filter_in_operator * Override ensure_my_table so we can control how this joins in. * The operator actually has influence over joining. */ - function ensure_my_table() { + public function ensure_my_table() { // Defer to helper if the operator specifies it. $info = $this->operators(); if (isset($info[$this->operator]['ensure_my_table']) && $info[$this->operator]['ensure_my_table'] == 'helper') { @@ -116,10 +134,14 @@ class views_handler_filter_many_to_one extends views_handler_filter_in_operator return parent::ensure_my_table(); } - function op_helper() { + /** + * {@inheritdoc} + */ + public function op_helper() { if (empty($this->value)) { return; } $this->helper->add_filter(); } + } diff --git a/sites/all/modules/views/handlers/views_handler_filter_numeric.inc b/sites/all/modules/views/handlers/views_handler_filter_numeric.inc index 03384f6..a338374 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_numeric.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_numeric.inc @@ -11,8 +11,16 @@ * @ingroup views_filter_handlers */ class views_handler_filter_numeric extends views_handler_filter { - var $always_multiple = TRUE; - function option_definition() { + + /** + * Exposed filter options. + */ + public $always_multiple = TRUE; + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['value'] = array( @@ -26,7 +34,10 @@ class views_handler_filter_numeric extends views_handler_filter { return $options; } - function operators() { + /** + * {@inheritdoc} + */ + public function operators() { $operators = array( '<' => array( 'title' => t('Is less than'), @@ -105,6 +116,12 @@ class views_handler_filter_numeric extends views_handler_filter { 'method' => 'op_regex', 'values' => 1, ), + 'not_regular_expression' => array( + 'title' => t('Not regular expression'), + 'short' => t('not regex'), + 'method' => 'op_not_regex', + 'values' => 1, + ), ); } @@ -114,7 +131,7 @@ class views_handler_filter_numeric extends views_handler_filter { /** * Provide a list of all the numeric operators */ - function operator_options($which = 'title') { + public function operator_options($which = 'title') { $options = array(); foreach ($this->operators() as $id => $info) { $options[$id] = $info[$which]; @@ -123,7 +140,10 @@ class views_handler_filter_numeric extends views_handler_filter { return $options; } - function operator_values($values = 1) { + /** + * {@inheritdoc} + */ + public function operator_values($values = 1) { $options = array(); foreach ($this->operators() as $id => $info) { if ($info['values'] == $values) { @@ -133,10 +153,11 @@ class views_handler_filter_numeric extends views_handler_filter { return $options; } + /** * Provide a simple textfield for equality */ - function value_form(&$form, &$form_state) { + public function value_form(&$form, &$form_state) { $form['value']['#tree'] = TRUE; // We have to make some choices when creating this as an exposed @@ -144,72 +165,108 @@ class views_handler_filter_numeric extends views_handler_filter { // not rendered, we can't render dependencies; instead we only // render the form items we need. $which = 'all'; + $limit_operators = !empty($this->options['expose']['limit_operators']) && (count($this->options['expose']['available_operators']) > 0); + $use_value = FALSE; + $use_minmax = FALSE; + if (!empty($form['operator'])) { $source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator'; } if (!empty($form_state['exposed'])) { + $operator_values_with_1_values = $this->operator_values(1); + $operator_values_with_2_values = $this->operator_values(2); + if ($limit_operators) { + // If limit operators is enabled, check that at least one operator + // with two values is enabled to display the min max widgets + foreach ($operator_values_with_2_values as $operator) { + if (isset($this->options['expose']['available_operators'][$operator])) { + $use_minmax = TRUE; + break; + } + } + // the same for operators with one value + foreach ($operator_values_with_1_values as $operator) { + if (isset($this->options['expose']['available_operators'][$operator])) { + $use_value = TRUE; + break; + } + } + } + else { + $use_minmax = $use_value = TRUE; + } $identifier = $this->options['expose']['identifier']; if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator_id'])) { // exposed and locked. - $which = in_array($this->operator, $this->operator_values(2)) ? 'minmax' : 'value'; + $which = in_array($this->operator, $operator_values_with_2_values) ? 'minmax' : 'value'; } else { $source = 'edit-' . drupal_html_id($this->options['expose']['operator_id']); } } - - if ($which == 'all') { - $form['value']['value'] = array( - '#type' => 'textfield', - '#title' => empty($form_state['exposed']) ? t('Value') : '', - '#size' => 30, - '#default_value' => $this->value['value'], - '#dependency' => array($source => $this->operator_values(1)), - ); - if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['value'])) { - $form_state['input'][$identifier]['value'] = $this->value['value']; - } + else { + $use_minmax = $use_value = TRUE; } - elseif ($which == 'value') { - // When exposed we drop the value-value and just do value if - // the operator is locked. - $form['value'] = array( - '#type' => 'textfield', - '#title' => empty($form_state['exposed']) ? t('Value') : '', - '#size' => 30, - '#default_value' => $this->value['value'], - ); - if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) { - $form_state['input'][$identifier] = $this->value['value']; + + if ($use_value) { + if ($which == 'all') { + $form['value']['value'] = array( + '#type' => 'textfield', + '#title' => empty($form_state['exposed']) ? t('Value') : '', + '#size' => 30, + '#default_value' => $this->value['value'], + '#dependency' => array($source => $this->operator_values(1)), + ); + if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['value'])) { + $form_state['input'][$identifier]['value'] = $this->value['value']; + } + } + elseif ($which == 'value') { + // When exposed we drop the value-value and just do value if + // the operator is locked. + $form['value'] = array( + '#type' => 'textfield', + '#title' => empty($form_state['exposed']) ? t('Value') : '', + '#size' => 30, + '#default_value' => $this->value['value'], + ); + if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) { + $form_state['input'][$identifier] = $this->value['value']; + } } } if ($which == 'all' || $which == 'minmax') { - $form['value']['min'] = array( - '#type' => 'textfield', - '#title' => empty($form_state['exposed']) ? t('Min') : '', - '#size' => 30, - '#default_value' => $this->value['min'], - ); - $form['value']['max'] = array( - '#type' => 'textfield', - '#title' => empty($form_state['exposed']) ? t('And max') : t('And'), - '#size' => 30, - '#default_value' => $this->value['max'], - ); - if ($which == 'all') { - $dependency = array( - '#dependency' => array($source => $this->operator_values(2)), + if ($use_minmax) { + $form['value']['min'] = array( + '#type' => 'textfield', + '#title' => empty($form_state['exposed']) ? t('Min') : '', + '#size' => 30, + '#default_value' => $this->value['min'], ); - $form['value']['min'] += $dependency; - $form['value']['max'] += $dependency; + $form['value']['max'] = array( + '#type' => 'textfield', + '#title' => empty($form_state['exposed']) ? t('And max') : t('And'), + '#size' => 30, + '#default_value' => $this->value['max'], + ); + + if ($which == 'all') { + $dependency = array( + '#dependency' => array($source => $this->operator_values(2)), + ); + + $form['value']['min'] += $dependency; + $form['value']['max'] += $dependency; + } } - if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['min'])) { + + if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['min']) && $use_minmax) { $form_state['input'][$identifier]['min'] = $this->value['min']; } - if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['max'])) { + if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['max']) && $use_minmax) { $form_state['input'][$identifier]['max'] = $this->value['max']; } @@ -223,7 +280,10 @@ class views_handler_filter_numeric extends views_handler_filter { } } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $field = "$this->table_alias.$this->real_field"; @@ -233,7 +293,10 @@ class views_handler_filter_numeric extends views_handler_filter { } } - function op_between($field) { + /** + * {@inheritdoc} + */ + public function op_between($field) { if ($this->operator == 'between') { $this->query->add_where($this->options['group'], $field, array($this->value['min'], $this->value['max']), 'BETWEEN'); } @@ -242,11 +305,17 @@ class views_handler_filter_numeric extends views_handler_filter { } } - function op_simple($field) { + /** + * {@inheritdoc} + */ + public function op_simple($field) { $this->query->add_where($this->options['group'], $field, $this->value['value'], $this->operator); } - function op_empty($field) { + /** + * {@inheritdoc} + */ + public function op_empty($field) { if ($this->operator == 'empty') { $operator = "IS NULL"; } @@ -257,11 +326,24 @@ class views_handler_filter_numeric extends views_handler_filter { $this->query->add_where($this->options['group'], $field, NULL, $operator); } - function op_regex($field) { + /** + * {@inheritdoc} + */ + public function op_regex($field) { $this->query->add_where($this->options['group'], $field, $this->value['value'], 'RLIKE'); } - function admin_summary() { + /** + * {@inheritdoc} + */ + public function op_not_regex($field) { + $this->query->add_where($this->options['group'], $field, $this->value['value'], 'NOT RLIKE'); + } + + /** + * {@inheritdoc} + */ + public function admin_summary() { if ($this->is_a_group()) { return t('grouped'); } @@ -281,15 +363,15 @@ class views_handler_filter_numeric extends views_handler_filter { } /** - * Do some minor translation of the exposed input + * Do some minor translation of the exposed input. */ - function accept_exposed_input($input) { + public function accept_exposed_input($input) { if (empty($this->options['exposed'])) { return TRUE; } - // rewrite the input value so that it's in the correct format so that - // the parent gets the right data. + // Rewrite the input value so that it's in the correct format so that the + // parent gets the right data. if (!empty($this->options['expose']['identifier'])) { $value = &$input[$this->options['expose']['identifier']]; if (!is_array($value)) { @@ -311,6 +393,7 @@ class views_handler_filter_numeric extends views_handler_filter { return FALSE; } break; + case 2: if ($value['min'] === '' && $value['max'] === '') { return FALSE; @@ -322,4 +405,5 @@ class views_handler_filter_numeric extends views_handler_filter { return $rc; } + } diff --git a/sites/all/modules/views/handlers/views_handler_filter_string.inc b/sites/all/modules/views/handlers/views_handler_filter_string.inc index c50eff4..85e3814 100644 --- a/sites/all/modules/views/handlers/views_handler_filter_string.inc +++ b/sites/all/modules/views/handlers/views_handler_filter_string.inc @@ -12,10 +12,16 @@ * @ingroup views_filter_handlers */ class views_handler_filter_string extends views_handler_filter { - // exposed filter options - var $always_multiple = TRUE; - function option_definition() { + /** + * Exposed filter options. + */ + public $always_multiple = TRUE; + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['expose']['contains']['required'] = array('default' => FALSE, 'bool' => TRUE); @@ -24,11 +30,11 @@ class views_handler_filter_string extends views_handler_filter { } /** - * This kind of construct makes it relatively easy for a child class - * to add or remove functionality by overriding this function and - * adding/removing items from this array. + * This kind of construct makes it relatively easy for a child class to add or + * remove functionality by overriding this function and adding/removing items + * from this array. */ - function operators() { + public function operators() { $operators = array( '=' => array( 'title' => t('Is equal to'), @@ -103,7 +109,7 @@ class views_handler_filter_string extends views_handler_filter { 'values' => 1, ), ); - // if the definition allows for the empty operator, add it. + // If the definition allows for the empty operator, add it. if (!empty($this->definition['allow empty'])) { $operators += array( 'empty' => array( @@ -129,6 +135,12 @@ class views_handler_filter_string extends views_handler_filter { 'method' => 'op_regex', 'values' => 1, ), + 'not_regular_expression' => array( + 'title' => t('Not regular expression'), + 'short' => t('not regex'), + 'method' => 'op_not_regex', + 'values' => 1, + ), ); } @@ -136,9 +148,9 @@ class views_handler_filter_string extends views_handler_filter { } /** - * Build strings from the operators() for 'select' options + * Build strings from the operators() for 'select' options. */ - function operator_options($which = 'title') { + public function operator_options($which = 'title') { $options = array(); foreach ($this->operators() as $id => $info) { $options[$id] = $info[$which]; @@ -147,7 +159,10 @@ class views_handler_filter_string extends views_handler_filter { return $options; } - function admin_summary() { + /** + * {@inheritdoc} + */ + public function admin_summary() { if ($this->is_a_group()) { return t('grouped'); } @@ -157,7 +172,7 @@ class views_handler_filter_string extends views_handler_filter { $options = $this->operator_options('short'); $output = ''; - if(!empty($options[$this->operator])) { + if (!empty($options[$this->operator])) { $output = check_plain($options[$this->operator]); } if (in_array($this->operator, $this->operator_values(1))) { @@ -166,7 +181,10 @@ class views_handler_filter_string extends views_handler_filter { return $output; } - function operator_values($values = 1) { + /** + * {@inheritdoc} + */ + public function operator_values($values = 1) { $options = array(); foreach ($this->operators() as $id => $info) { if (isset($info['values']) && $info['values'] == $values) { @@ -178,13 +196,12 @@ class views_handler_filter_string extends views_handler_filter { } /** - * Provide a simple textfield for equality + * Provide a simple textfield for equality. */ - function value_form(&$form, &$form_state) { - // We have to make some choices when creating this as an exposed - // filter form. For example, if the operator is locked and thus - // not rendered, we can't render dependencies; instead we only - // render the form items we need. + public function value_form(&$form, &$form_state) { + // We have to make some choices when creating this as an exposed filter + // form. For example, if the operator is locked and thus not rendered, we + // can't render dependencies; instead we only render the form items we need. $which = 'all'; if (!empty($form['operator'])) { $source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator'; @@ -223,23 +240,26 @@ class views_handler_filter_string extends views_handler_filter { // Ensure there is something in the 'value'. $form['value'] = array( '#type' => 'value', - '#value' => NULL + '#value' => NULL, ); } } - function operator() { + /** + * {@inheritdoc} + */ + public function operator() { return $this->operator == '=' ? 'LIKE' : 'NOT LIKE'; } /** * Add this filter to the query. * - * Due to the nature of fapi, the value and the operator have an unintended - * level of indirection. You will find them in $this->operator - * and $this->value respectively. + * Due to the nature of FAPI, the value and the operator have an unintended + * level of indirection. You will find them in $this->operator and + * $this->value respectively. */ - function query() { + public function query() { $this->ensure_my_table(); $field = "$this->table_alias.$this->real_field"; @@ -249,15 +269,26 @@ class views_handler_filter_string extends views_handler_filter { } } - function op_equal($field) { + /** + * {@inheritdoc} + */ + public function op_equal($field) { $this->query->add_where($this->options['group'], $field, $this->value, $this->operator()); } - function op_contains($field) { - $this->query->add_where($this->options['group'], $field, '%' . db_like($this->value) . '%', 'LIKE'); + /** + * {@inheritdoc} + */ + public function op_contains($field) { + if (!empty($this->value)) { + $this->query->add_where($this->options['group'], $field, '%' . db_like($this->value) . '%', 'LIKE'); + } } - function op_word($field) { + /** + * {@inheritdoc} + */ + public function op_word($field) { $where = $this->operator == 'word' ? db_or() : db_and(); // Don't filter on empty strings. @@ -267,11 +298,11 @@ class views_handler_filter_string extends views_handler_filter { preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->value, $matches, PREG_SET_ORDER); foreach ($matches as $match) { - $phrase = false; + $phrase = FALSE; // Strip off phrase quotes if ($match[2]{0} == '"') { $match[2] = substr($match[2], 1, -1); - $phrase = true; + $phrase = TRUE; } $words = trim($match[2], ',?!();:-'); $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY); @@ -285,46 +316,80 @@ class views_handler_filter_string extends views_handler_filter { return; } - // previously this was a call_user_func_array but that's unnecessary - // as views will unpack an array that is a single arg. + // Previously this was a call_user_func_array but that's unnecessary as + // Views will unpack an array that is a single arg. $this->query->add_where($this->options['group'], $where); } - function op_starts($field) { + /** + * {@inheritdoc} + */ + public function op_starts($field) { $this->query->add_where($this->options['group'], $field, db_like($this->value) . '%', 'LIKE'); } - function op_not_starts($field) { + /** + * {@inheritdoc} + */ + public function op_not_starts($field) { $this->query->add_where($this->options['group'], $field, db_like($this->value) . '%', 'NOT LIKE'); } - function op_ends($field) { + /** + * {@inheritdoc} + */ + public function op_ends($field) { $this->query->add_where($this->options['group'], $field, '%' . db_like($this->value), 'LIKE'); } - function op_not_ends($field) { + /** + * {@inheritdoc} + */ + public function op_not_ends($field) { $this->query->add_where($this->options['group'], $field, '%' . db_like($this->value), 'NOT LIKE'); } - function op_not($field) { + /** + * {@inheritdoc} + */ + public function op_not($field) { $this->query->add_where($this->options['group'], $field, '%' . db_like($this->value) . '%', 'NOT LIKE'); } - function op_shorter($field) { + /** + * {@inheritdoc} + */ + public function op_shorter($field) { $placeholder = $this->placeholder(); $this->query->add_where_expression($this->options['group'], "LENGTH($field) < $placeholder", array($placeholder => $this->value)); } - function op_longer($field) { + /** + * {@inheritdoc} + */ + public function op_longer($field) { $placeholder = $this->placeholder(); $this->query->add_where_expression($this->options['group'], "LENGTH($field) > $placeholder", array($placeholder => $this->value)); } - function op_regex($field) { + /** + * {@inheritdoc} + */ + public function op_regex($field) { $this->query->add_where($this->options['group'], $field, $this->value, 'RLIKE'); } - function op_empty($field) { + /** + * {@inheritdoc} + */ + public function op_not_regex($field) { + $this->query->add_where($this->options['group'], $field, $this->value, 'NOT RLIKE'); + } + + /** + * {@inheritdoc} + */ + public function op_empty($field) { if ($this->operator == 'empty') { $operator = "IS NULL"; } diff --git a/sites/all/modules/views/handlers/views_handler_relationship.inc b/sites/all/modules/views/handlers/views_handler_relationship.inc index 695082b..d20217c 100644 --- a/sites/all/modules/views/handlers/views_handler_relationship.inc +++ b/sites/all/modules/views/handlers/views_handler_relationship.inc @@ -2,7 +2,7 @@ /** * @file - * Views' relationship handlers. + * Definition of views_handler_relationship. */ /** @@ -12,12 +12,11 @@ */ /** - * Simple relationship handler that allows a new version of the primary table - * to be linked in. + * Relationship handler, allows a new version of the primary table to be linked. * - * The base relationship handler can only handle a single join. Some relationships - * are more complex and might require chains of joins; for those, you must - * utilize a custom relationship handler. + * The base relationship handler can only handle a single join. Some + * relationships are more complex and might require chains of joins; for those, + * you must use a custom relationship handler. * * Definition items: * - base: The new base table this relationship will be adding. This does not @@ -36,18 +35,18 @@ * @ingroup views_relationship_handlers */ class views_handler_relationship extends views_handler { + /** - * Init handler to let relationships live on tables other than - * the table they operate on. + * Let relationships live on tables other than the table they operate on. */ - function init(&$view, &$options) { + public function init(&$view, &$options) { parent::init($view, $options); if (isset($this->definition['relationship table'])) { $this->table = $this->definition['relationship table']; } if (isset($this->definition['relationship field'])) { - // Set both real_field and field so custom handler - // can rely on the old field value. + // Set both real_field and field so custom handler can rely on the old + // field value. $this->real_field = $this->field = $this->definition['relationship field']; } } @@ -55,18 +54,22 @@ class views_handler_relationship extends views_handler { /** * Get this field's label. */ - function label() { + public function label() { if (!isset($this->options['label'])) { return $this->ui_name(); } return $this->options['label']; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); - // Relationships definitions should define a default label, but if they aren't get another default value. + // Relationships definitions should define a default label, but if they + // aren't get another default value. if (!empty($this->definition['label'])) { $label = $this->definition['label']; } @@ -81,10 +84,9 @@ class views_handler_relationship extends views_handler { } /** - * Default options form that provides the label widget that all fields - * should have. + * Provide the label widget that all fields should have. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['label'] = array( '#type' => 'textfield', @@ -105,7 +107,7 @@ class views_handler_relationship extends views_handler { /** * Called to implement a relationship in a query. */ - function query() { + public function query() { // Figure out what base table this relationship brings to the party. $table_data = views_fetch_data($this->definition['base']); $base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field']; @@ -126,7 +128,7 @@ class views_handler_relationship extends views_handler { } if (!empty($def['join_handler']) && class_exists($def['join_handler'])) { - $join = new $def['join_handler']; + $join = new $def['join_handler'](); } else { $join = new views_join(); @@ -137,7 +139,7 @@ class views_handler_relationship extends views_handler { $join->construct(); $join->adjusted = TRUE; - // use a short alias for this: + // Use a short alias for this. $alias = $def['table'] . '_' . $this->table; $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship); @@ -152,9 +154,10 @@ class views_handler_relationship extends views_handler { /** * You can't groupby a relationship. */ - function use_group_by() { + public function use_group_by() { return FALSE; } + } /** @@ -163,22 +166,44 @@ class views_handler_relationship extends views_handler { * @ingroup views_relationship_handlers */ class views_handler_relationship_broken extends views_handler_relationship { - function ui_name($short = FALSE) { + + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return t('Broken/missing handler'); } - function ensure_my_table() { /* No table to ensure! */ } - function query() { /* No query to run */ } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function ensure_my_table() { + // No table to ensure! + } + + /** + * {@inheritdoc} + */ + public function query() { + // No query to run. + } + + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['markup'] = array( '#markup' => '
' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '
', ); } /** - * Determine if the handler is considered 'broken' + * {@inheritdoc} */ - function broken() { return TRUE; } + public function broken() { + return TRUE; + } + } /** diff --git a/sites/all/modules/views/handlers/views_handler_relationship_groupwise_max.inc b/sites/all/modules/views/handlers/views_handler_relationship_groupwise_max.inc index 23198c6..10f6971 100644 --- a/sites/all/modules/views/handlers/views_handler_relationship_groupwise_max.inc +++ b/sites/all/modules/views/handlers/views_handler_relationship_groupwise_max.inc @@ -2,11 +2,12 @@ /** * @file - * Relationship for groupwise maximum handler. + * Definition of views_handler_relationship_groupwise_max. */ /** * Relationship handler that allows a groupwise maximum of the linked in table. + * * For a definition, see: * http://dev.mysql.com/doc/refman/5.0/en/example-maximum-column-group-row.html * In lay terms, instead of joining to get all matching records in the linked @@ -58,7 +59,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi /** * Defines default values for options. */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); $options['subquery_sort'] = array('default' => NULL); @@ -72,10 +73,11 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi } /** - * Extends the relationship's basic options, allowing the user to pick - * a sort and an order for it. + * Extends the relationship's basic options. + * + * Allows the user to pick a sort and an order for it. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // Get the sorts that apply to our base. @@ -92,7 +94,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi '#default_value' => !empty($this->options['subquery_sort']) ? $this->options['subquery_sort'] : $this->definition['base'] . '.' . $base_table_data['table']['base']['field'], '#options' => $sort_options, '#description' => theme('advanced_help_topic', array('module' => 'views', 'topic' => 'relationship-representative')) . - t("The sort criteria is applied to the data brought in by the relationship to determine how a representative item is obtained for each row. For example, to show the most recent node for each user, pick 'Content: Updated date'."), + t("The sort criteria is applied to the data brought in by the relationship to determine how a representative item is obtained for each row. For example, to show the most recent node for each user, pick 'Content: Updated date'."), ); $form['subquery_order'] = array( @@ -110,8 +112,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi '#default_value' => $this->options['subquery_namespace'], ); - - // WIP: This stuff doens't work yet: namespacing issues. + // WIP: This stuff doesn't work yet: namespacing issues. // A list of suitable views to pick one as the subview. $views = array('' => ''); $all_views = views_get_all_views(); @@ -120,7 +121,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi // - base must the base that our relationship joins towards // - must have fields. if ($view->base_table == $this->definition['base'] && !empty($view->display['default']->display_options['fields'])) { - // TODO: check the field is the correct sort? + // @todo check the field is the correct sort? // or let users hang themselves at this stage and check later? if ($view->type == 'Default') { $views[t('Default Views')][$view->name] = $view->name; @@ -152,10 +153,11 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi * * We use this to obtain our subquery SQL. */ - function get_temporary_view() { + public function get_temporary_view() { views_include('view'); $view = new view(); - $view->vid = 'new'; // @todo: what's this? + // @todo What's this? + $view->vid = 'new'; $view->base_table = $this->definition['base']; $view->add_display('default'); return $view; @@ -164,7 +166,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi /** * When the form is submitted, take sure to clear the subquery string cache. */ - function options_form_submit(&$form, &$form_state) { + public function options_form_submit(&$form, &$form_state) { $cid = 'views_relationship_groupwise_max:' . $this->view->name . ':' . $this->view->current_display . ':' . $this->options['id']; cache_clear_all($cid, 'cache_views_data'); } @@ -175,18 +177,19 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi * generate the subquery when the options are saved, rather than when the view * is run. This saves considerable time. * - * @param $options - * An array of options: - * - subquery_sort: the id of a views sort. - * - subquery_order: either ASC or DESC. - * @return + * @param array $options + * An array of options that contains the following items: + * - subquery_sort: the id of a views sort. + * - subquery_order: either ASC or DESC. + * + * @return string * The subquery SQL string, ready for use in the main query. */ - function left_query($options) { + public function left_query($options) { // Either load another view, or create one on the fly. if ($options['subquery_view']) { $temp_view = views_get_view($options['subquery_view']); - // Remove all fields from default display + // Remove all fields from default display. unset($temp_view->display['default']->display_options['fields']); } else { @@ -195,18 +198,14 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi $temp_view = $this->get_temporary_view(); // Add the sort from the options to the default display. - // This is broken, in that the sort order field also gets added as a - // select field. See http://drupal.org/node/844910. - // We work around this further down. - $sort = $options['subquery_sort']; - list($sort_table, $sort_field) = explode('.', $sort); + list($sort_table, $sort_field) = explode('.', $options['subquery_sort']); $sort_options = array('order' => $options['subquery_order']); $temp_view->add_item('default', 'sort', $sort_table, $sort_field, $sort_options); } // Get the namespace string. - $temp_view->namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : '_INNER'; - $this->subquery_namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : 'INNER'; + $temp_view->namespace = (!empty($options['subquery_namespace'])) ? '_' . $options['subquery_namespace'] : '_INNER'; + $this->subquery_namespace = (!empty($options['subquery_namespace'])) ? '_' . $options['subquery_namespace'] : 'INNER'; // The value we add here does nothing, but doing this adds the right tables // and puts in a WHERE clause with a placeholder we can grab later. @@ -217,14 +216,16 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi $base_field = $views_data['table']['base']['field']; $temp_view->add_item('default', 'field', $this->definition['base'], $this->definition['field']); - // Add the correct argument for our relationship's base - // ie the 'how to get back to base' argument. - // The relationship definition tells us which one to use. + // Add the correct argument for our relationship's base ie the "how to get + // back to base" argument; the relationship definition defines which one to + // use. $temp_view->add_item( 'default', 'argument', - $this->definition['argument table'], // eg 'term_node', - $this->definition['argument field'] // eg 'tid' + // For example, 'term_node', + $this->definition['argument table'], + // For example, 'tid'. + $this->definition['argument field'] ); // Build the view. The creates the query object and produces the query @@ -235,7 +236,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi // somewhat so we can get the SQL query from it. $subquery = $temp_view->build_info['query']; - // Workaround until http://drupal.org/node/844910 is fixed: + // Workaround until http://drupal.org/node/844910 is fixed. // Remove all fields from the SELECT except the base id. $fields =& $subquery->getFields(); foreach (array_keys($fields) as $field_name) { @@ -245,8 +246,8 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi } } - // Make every alias in the subquery safe within the outer query by - // appending a namespace to it, '_inner' by default. + // Make every alias in the subquery safe within the outer query by appending + // a namespace to it, '_inner' by default. $tables =& $subquery->getTables(); foreach (array_keys($tables) as $table_name) { $tables[$table_name]['alias'] .= $this->subquery_namespace; @@ -264,32 +265,49 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi $where =& $subquery->conditions(); $this->alter_subquery_condition($subquery, $where); // Not sure why, but our sort order clause doesn't have a table. - // TODO: the call to add_item() above to add the sort handler is probably + // @todo The call to add_item() above to add the sort handler is probably // wrong -- needs attention from someone who understands it. - // In the meantime, this works, but with a leap of faith... + // In the meantime, this works, but with a leap of faith. $orders =& $subquery->getOrderBy(); + $orders_tmp = array(); foreach ($orders as $order_key => $order) { - // But if we're using a whole view, we don't know what we have! - if ($options['subquery_view']) { - list($sort_table, $sort_field) = explode('.', $order_key); - } - $orders[$sort_table . $this->subquery_namespace . '.' . $sort_field] = $order; - unset($orders[$order_key]); + // Until http://drupal.org/node/844910 is fixed, $order_key is a field + // alias from SELECT. De-alias it using the View object. + $sort_table = $temp_view->query->fields[$order_key]['table']; + $sort_field = $temp_view->query->fields[$order_key]['field']; + $orders_tmp[$sort_table . $this->subquery_namespace . '.' . $sort_field] = $order; } + $orders = $orders_tmp; // The query we get doesn't include the LIMIT, so add it here. $subquery->range(0, 1); + // Clone the query object to force recompilation of the underlying where and + // having objects on the next step. + $subquery = clone $subquery; + + // Add in Views Query Substitutions such as ***CURRENT_TIME***. + views_query_views_alter($subquery); // Extract the SQL the temporary view built. $subquery_sql = $subquery->__toString(); - // Replace the placeholder with the outer, correlated field. - // Eg, change the placeholder ':users_uid' into the outer field 'users.uid'. - // We have to work directly with the SQL, because putting a name of a field - // into a SelectQuery that it does not recognize (because it's outer) just - // makes it treat it as a string. - $outer_placeholder = ':' . str_replace('.', '_', $this->definition['outer field']); - $subquery_sql = str_replace($outer_placeholder, $this->definition['outer field'], $subquery_sql); + // Replace subquery argument placeholders. + $quoted = $subquery->getArguments(); + $connection = Database::getConnection(); + foreach ($quoted as $key => $val) { + if (is_array($val)) { + $quoted[$key] = implode(', ', array_map(array($connection, 'quote'), $val)); + } + // If the correlated placeholder has been located, replace it with the + // outer field name. + elseif ($val === '**CORRELATED**') { + $quoted[$key] = $this->definition['outer field']; + } + else { + $quoted[$key] = $connection->quote($val); + } + } + $subquery_sql = strtr($subquery_sql, $quoted); return $subquery_sql; } @@ -301,7 +319,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi * * (Though why is the condition we get in a simple query 3 levels deep???) */ - function alter_subquery_condition(QueryAlterableInterface $query, &$conditions) { + public function alter_subquery_condition(QueryAlterableInterface $query, &$conditions) { foreach ($conditions as $condition_id => &$condition) { // Skip the #conjunction element. if (is_numeric($condition_id)) { @@ -321,7 +339,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi * * Turns 'foo.bar' into 'foo_NAMESPACE.bar'. */ - function condition_namespace($string) { + public function condition_namespace($string) { return str_replace('.', $this->subquery_namespace . '.', $string); } @@ -330,7 +348,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi * This is mostly a copy of our parent's query() except for this bit with * the join class. */ - function query() { + public function query() { // Figure out what base table this relationship brings to the party. $table_data = views_fetch_data($this->definition['base']); $base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field']; @@ -374,9 +392,10 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi $join->construct(); $join->adjusted = TRUE; - // use a short alias for this: + // Use a short alias for this. $alias = $def['table'] . '_' . $this->table; $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship); } + } diff --git a/sites/all/modules/views/handlers/views_handler_sort.inc b/sites/all/modules/views/handlers/views_handler_sort.inc index 99574e4..1b17e79 100644 --- a/sites/all/modules/views/handlers/views_handler_sort.inc +++ b/sites/all/modules/views/handlers/views_handler_sort.inc @@ -2,7 +2,7 @@ /** * @file - * @todo. + * Definition of views_handler_sort. */ /** @@ -21,18 +21,23 @@ class views_handler_sort extends views_handler { /** * Determine if a sort can be exposed. */ - function can_expose() { return TRUE; } + public function can_expose() { + return TRUE; + } /** * Called to add the sort to a query. */ - function query() { + public function query() { $this->ensure_my_table(); // Add the field. $this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['order'] = array('default' => 'ASC'); @@ -48,7 +53,7 @@ class views_handler_sort extends views_handler { /** * Display whether or not the sort order is ascending or descending */ - function admin_summary() { + public function admin_summary() { if (!empty($this->options['exposed'])) { return t('Exposed'); } @@ -57,18 +62,17 @@ class views_handler_sort extends views_handler { case 'asc': default: return t('asc'); - break; + case 'DESC'; case 'desc'; return t('desc'); - break; } } /** * Basic options for all sort criteria */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); if ($this->can_expose()) { $this->show_expose_button($form, $form_state); @@ -84,11 +88,11 @@ class views_handler_sort extends views_handler { /** * Shortcut to display the expose/hide button. */ - function show_expose_button(&$form, &$form_state) { + public function show_expose_button(&$form, &$form_state) { $form['expose_button'] = array( '#prefix' => '
', '#suffix' => '
', - // Should always come first + // Should always come first. '#weight' => -1000, ); @@ -131,9 +135,9 @@ class views_handler_sort extends views_handler { } /** - * Simple validate handler + * Simple validate handler. */ - function options_validate(&$form, &$form_state) { + public function options_validate(&$form, &$form_state) { $this->sort_validate($form, $form_state); if (!empty($this->options['exposed'])) { $this->expose_validate($form, $form_state); @@ -142,10 +146,12 @@ class views_handler_sort extends views_handler { } /** - * Simple submit handler + * Simple submit handler. */ - function options_submit(&$form, &$form_state) { - unset($form_state['values']['expose_button']); // don't store this. + public function options_submit(&$form, &$form_state) { + // Don't store this. + unset($form_state['values']['expose_button']); + $this->sort_submit($form, $form_state); if (!empty($this->options['exposed'])) { $this->expose_submit($form, $form_state); @@ -155,7 +161,7 @@ class views_handler_sort extends views_handler { /** * Shortcut to display the value form. */ - function show_sort_form(&$form, &$form_state) { + public function show_sort_form(&$form, &$form_state) { $options = $this->sort_options(); if (!empty($options)) { $form['order'] = array( @@ -166,22 +172,34 @@ class views_handler_sort extends views_handler { } } - function sort_validate(&$form, &$form_state) { } + /** + * {@inheritdoc} + */ + public function sort_validate(&$form, &$form_state) { + } - function sort_submit(&$form, &$form_state) { } + /** + * {@inheritdoc} + */ + public function sort_submit(&$form, &$form_state) { + } /** * Provide a list of options for the default sort form. - * Should be overridden by classes that don't override sort_form + * + * Should be overridden by classes that don't override sort_form. */ - function sort_options() { + public function sort_options() { return array( 'ASC' => t('Sort ascending'), 'DESC' => t('Sort descending'), ); } - function expose_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function expose_form(&$form, &$form_state) { // #flatten will move everything from $form['expose'][$key] to $form[$key] // prior to rendering. That's why the pre_render for it needs to run first, // so that when the next pre_render (the one for fieldsets) runs, it gets @@ -196,18 +214,19 @@ class views_handler_sort extends views_handler { '#required' => TRUE, '#size' => 40, '#weight' => -1, - ); + ); } /** * Provide default options for exposed sorts. */ - function expose_options() { + public function expose_options() { $this->options['expose'] = array( 'order' => $this->options['order'], 'label' => $this->definition['title'], ); } + } /** @@ -216,22 +235,44 @@ class views_handler_sort extends views_handler { * @ingroup views_sort_handlers */ class views_handler_sort_broken extends views_handler_sort { - function ui_name($short = FALSE) { + + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return t('Broken/missing handler'); } - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function ensure_my_table() { + // No table to ensure! + } + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { + // No query to run. + } + + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['markup'] = array( '#markup' => '
' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '
', ); } /** - * Determine if the handler is considered 'broken' + * Determine if the handler is considered 'broken'. */ - function broken() { return TRUE; } + public function broken() { + return TRUE; + } + } diff --git a/sites/all/modules/views/handlers/views_handler_sort_date.inc b/sites/all/modules/views/handlers/views_handler_sort_date.inc index b37cc41..08ad609 100644 --- a/sites/all/modules/views/handlers/views_handler_sort_date.inc +++ b/sites/all/modules/views/handlers/views_handler_sort_date.inc @@ -14,7 +14,11 @@ * @ingroup views_sort_handlers */ class views_handler_sort_date extends views_handler_sort { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['granularity'] = array('default' => 'second'); @@ -22,7 +26,10 @@ class views_handler_sort_date extends views_handler_sort { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['granularity'] = array( @@ -42,27 +49,32 @@ class views_handler_sort_date extends views_handler_sort { } /** - * Called to add the sort to a query. + * {@inheritdoc} */ - function query() { + public function query() { $this->ensure_my_table(); switch ($this->options['granularity']) { case 'second': default: $this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']); return; + case 'minute': $formula = views_date_sql_format('YmdHi', "$this->table_alias.$this->real_field"); break; + case 'hour': $formula = views_date_sql_format('YmdH', "$this->table_alias.$this->real_field"); break; + case 'day': $formula = views_date_sql_format('Ymd', "$this->table_alias.$this->real_field"); break; + case 'month': $formula = views_date_sql_format('Ym', "$this->table_alias.$this->real_field"); break; + case 'year': $formula = views_date_sql_format('Y', "$this->table_alias.$this->real_field"); break; @@ -71,4 +83,5 @@ class views_handler_sort_date extends views_handler_sort { // Add the field. $this->query->add_orderby(NULL, $formula, $this->options['order'], $this->table_alias . '_' . $this->field . '_' . $this->options['granularity']); } + } diff --git a/sites/all/modules/views/handlers/views_handler_sort_group_by_numeric.inc b/sites/all/modules/views/handlers/views_handler_sort_group_by_numeric.inc index 4a521c1..42696bd 100644 --- a/sites/all/modules/views/handlers/views_handler_sort_group_by_numeric.inc +++ b/sites/all/modules/views/handlers/views_handler_sort_group_by_numeric.inc @@ -11,7 +11,11 @@ * @ingroup views_sort_handlers */ class views_handler_sort_group_by_numeric extends views_handler_sort { - function init(&$view, &$options) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); // Initialize the original handler. @@ -20,9 +24,9 @@ class views_handler_sort_group_by_numeric extends views_handler_sort { } /** - * Called to add the field to a query. + * {@inheritdoc} */ - function query() { + public function query() { $this->ensure_my_table(); $params = array( @@ -32,7 +36,11 @@ class views_handler_sort_group_by_numeric extends views_handler_sort { $this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order'], NULL, $params); } - function ui_name($short = FALSE) { + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return $this->get_field(parent::ui_name($short)); } + } diff --git a/sites/all/modules/views/handlers/views_handler_sort_menu_hierarchy.inc b/sites/all/modules/views/handlers/views_handler_sort_menu_hierarchy.inc index dacb1fe..edaa1a8 100644 --- a/sites/all/modules/views/handlers/views_handler_sort_menu_hierarchy.inc +++ b/sites/all/modules/views/handlers/views_handler_sort_menu_hierarchy.inc @@ -17,13 +17,20 @@ * @ingroup views_sort_handlers */ class views_handler_sort_menu_hierarchy extends views_handler_sort { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['sort_within_level'] = array('default' => FALSE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['sort_within_level'] = array( '#type' => 'checkbox', @@ -33,7 +40,10 @@ class views_handler_sort_menu_hierarchy extends views_handler_sort { ); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $max_depth = isset($this->definition['max depth']) ? $this->definition['max depth'] : MENU_MAX_DEPTH; for ($i = 1; $i <= $max_depth; ++$i) { @@ -51,4 +61,5 @@ class views_handler_sort_menu_hierarchy extends views_handler_sort { $this->query->add_orderby($this->table_alias, $this->field . $i, $this->options['order']); } } + } diff --git a/sites/all/modules/views/handlers/views_handler_sort_random.inc b/sites/all/modules/views/handlers/views_handler_sort_random.inc index eaaaf79..5bf9bfa 100644 --- a/sites/all/modules/views/handlers/views_handler_sort_random.inc +++ b/sites/all/modules/views/handlers/views_handler_sort_random.inc @@ -11,12 +11,20 @@ * @ingroup views_sort_handlers */ class views_handler_sort_random extends views_handler_sort { - function query() { + + /** + * {@inheritdoc} + */ + public function query() { $this->query->add_orderby('rand'); } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['order']['#access'] = FALSE; } + } diff --git a/sites/all/modules/views/help/about.html b/sites/all/modules/views/help/about.html index 8ba77f8..b03d1fc 100644 --- a/sites/all/modules/views/help/about.html +++ b/sites/all/modules/views/help/about.html @@ -19,9 +19,9 @@ The "building block" design of the views system provides power and flexibility,
  • Header, which allow you to add by default one or more text area above the views output.
  • -
  • Footer, which allow you to add by default one or more text area beneath the views output.
  • +
  • Footer, which allow you to add by default one or more text area beneath the views output.
  • -
  • The Emtpy Text content will be displayed, when you choose in the Arguments Section "Action to take if argument is not present" the option "Display empty text".
  • +
  • The Emtpy Text content will be displayed, when you choose in the Arguments Section "Action to take if argument is not present" the option "Display empty text".
  • diff --git a/sites/all/modules/views/help/alter-exposed-filter.html b/sites/all/modules/views/help/alter-exposed-filter.html index 454994f..ff3e9b6 100644 --- a/sites/all/modules/views/help/alter-exposed-filter.html +++ b/sites/all/modules/views/help/alter-exposed-filter.html @@ -4,8 +4,9 @@ As a consequence, it *always* thinks the value was submitted, even if it was not
     <?php
    -if (empty($form_state['view']->exposed_input[$identifier])) .
    -		{ $form_state['input'][$identifier] = $default_value; }
    +if (empty($form_state['view']->exposed_input[$identifier])) {
    +  $form_state['input'][$identifier] = $default_value;
    +}
     ?>
     
    @@ -18,10 +19,10 @@ To do this, I used the following function, where geoip_redirect_get_tid() loads
     <?php
     function MODULENAME_form_views_exposed_form_alter(&$form, $form_state) {
    -  if(strpos($form['#id'], 'volunteer-directory') !== FALSE) {
    +  if (strpos($form['#id'], 'volunteer-directory') !== FALSE) {
         $city_tid = geoip_redirect_get_tid();
    -    if(is_numeric($city_tid) && $city_tid != 7660) {
    -      if (empty($form_state['view']->exposed_input['tid']))  {
    +    if (is_numeric($city_tid) && $city_tid != 7660) {
    +      if (empty($form_state['view']->exposed_input['tid'])) {
             $form_state['input']['tid'] = $city_tid;
           }
         }
    diff --git a/sites/all/modules/views/help/api-example.html b/sites/all/modules/views/help/api-example.html
    index 682fe87..819d65f 100644
    --- a/sites/all/modules/views/help/api-example.html
    +++ b/sites/all/modules/views/help/api-example.html
    @@ -40,7 +40,7 @@ Below is the contents of a simple node_example.views.inc file that allows you to
      * @endcode
      */
     
    -function node_example_views_data()  {
    +function node_example_views_data() {
       // Basic table information.
     
       // ----------------------------------------------------------------
    diff --git a/sites/all/modules/views/help/api-tables.html b/sites/all/modules/views/help/api-tables.html
    index cafbbab..c80d29a 100644
    --- a/sites/all/modules/views/help/api-tables.html
    +++ b/sites/all/modules/views/help/api-tables.html
    @@ -169,8 +169,10 @@ Each field is described in the view data with an array, keyed to the database na
     
     
     $data['node']['nid'] = array(
    +  // The item it appears as on the UI,
       'title' => t('Nid'),
    -  'help' => t('The node ID of the node.'), // The help that appears on the UI,
    +  // The help that appears on the UI,
    +  'help' => t('The node ID of the node.'),
       // Information for displaying the nid
       'field' => array(
         'handler' => 'views_handler_field_node',
    @@ -179,7 +181,8 @@ $data['node']['nid'] = array(
       // Information for accepting a nid as an argument
       'argument' => array(
         'handler' => 'views_handler_argument_node_nid',
    -    'name field' => 'title', // the field to display in the summary.
    +    // The field to display in the summary.
    +    'name field' => 'title',
         'numeric' => TRUE,
         'validate type' => 'nid',
       ),
    diff --git a/sites/all/modules/views/help/api-upgrading.html b/sites/all/modules/views/help/api-upgrading.html
    index 158f809..2ff6bb4 100644
    --- a/sites/all/modules/views/help/api-upgrading.html
    +++ b/sites/all/modules/views/help/api-upgrading.html
    @@ -113,9 +113,9 @@ The views_handler class got two new functions:
     /**
      * Get the value that's supposed to be rendered.
      *
    - * @param $values
    + * @param object $values
      *   An object containing all retrieved values.
    - * @param $field
    + * @param string $field
      *   Optional name of the field where the value is stored.
      */
     function get_value($values, $field = NULL) {
    @@ -128,9 +128,9 @@ function get_value($values, $field = NULL) {
     /**
      * Sanitize the value for output.
      *
    - * @param $value
    + * @param string $value
      *   The value being rendered.
    - * @param $type
    + * @param string $type
      *   The type of sanitization needed. If not provided, check_plain() is used.
      */
     function sanitize_value($value, $type = NULL) {
    @@ -138,9 +138,11 @@ function sanitize_value($value, $type = NULL) {
         case 'xss':
           $value = filter_xss($value);
           break;
    +
         case 'url':
           $value = check_url($value);
           break;
    +
         default:
           $value = check_plain($value);
           break;
    diff --git a/sites/all/modules/views/help/embed.html b/sites/all/modules/views/help/embed.html
    index e39fbf5..156b1dc 100644
    --- a/sites/all/modules/views/help/embed.html
    +++ b/sites/all/modules/views/help/embed.html
    @@ -10,9 +10,9 @@ easiest way is to use the function views_embed_view():
      * solution and doesn't really offer a lot of options, but breaking the function
      * apart is pretty easy, and this provides a worthwhile guide to doing so.
      *
    - * @param $name
    + * @param string $name
      *   The name of the view to embed.
    - * @param $display_id
    + * @param string $display_id
      *   The display id to embed. If unsure, use 'default', as it will always be
      *   valid. But things like 'page' or 'block' should work here.
      * @param ...
    diff --git a/sites/all/modules/views/help/ui-crashes.html b/sites/all/modules/views/help/ui-crashes.html
    index 4e8a389..6c20794 100644
    --- a/sites/all/modules/views/help/ui-crashes.html
    +++ b/sites/all/modules/views/help/ui-crashes.html
    @@ -1,10 +1,10 @@
     

    Troubleshooting UI crashes

    -There are a number of reasons why the Views UI may crash; the most common state or result of a crash is either a white screen (everyone's favorite WSOD), or a screen of what looks like garbage text. This is generally a javascript crash of some fashion. +There are a number of reasons why the Views UI may crash; the most common state or result of a crash is either a white screen (everyone's favorite WSOD), or a screen of what looks like garbage text. This is generally JavaScript crash of some fashion. To get the most timely and accurate help in the issue queue, please try to gather this information: -Check your javascript console. In Firefox, you can hit ctrl-shift-j or use firebug. Copy this information into the issue, or attach it as a text file. Really - this is the single biggest thing you can do to help figure out where the crash is coming from. +Check your JavaScript console. In Firefox, you can hit ctrl-shift-j or use firebug. Copy this information into the issue, or attach it as a text file. Really - this is the single biggest thing you can do to help figure out where the crash is coming from.

    JSON prepends data with jQuery, causing editing and preview problems.

    @@ -13,7 +13,7 @@ This section originally stems from this Some modules may add PHP improperly, disrupting normal jQuery operation. Errors may look like -{ "default": "default" } +{ "default": "default" } This can also be a server configuration issue. In one case, this was solved by commenting out diff --git a/sites/all/modules/views/includes/admin.inc b/sites/all/modules/views/includes/admin.inc index 6098b23..810c70f 100644 --- a/sites/all/modules/views/includes/admin.inc +++ b/sites/all/modules/views/includes/admin.inc @@ -8,10 +8,11 @@ /** * Create an array of Views admin CSS for adding or attaching. * - * This returns an array of arrays. Each array represents a single - * file. The array format is: - * - file: The fully qualified name of the file to send to drupal_add_css - * - options: An array of options to pass to drupal_add_css. + * @return array + * An array of arrays. Each array represents a single file. The array format + * is: + * - file: The fully qualified name of the file to send to drupal_add_css + * - options: An array of options to pass to drupal_add_css. */ function views_ui_get_admin_css() { $module_path = drupal_get_path('module', 'views_ui'); @@ -21,27 +22,28 @@ function views_ui_get_admin_css() { $list[$module_path . '/css/ie/views-admin.ie7.css'] = array( 'browsers' => array( 'IE' => 'lte IE 7', - '!IE' => FALSE + '!IE' => FALSE, ), 'preprocess' => FALSE, ); $list[$module_path . '/css/views-admin.theme.css'] = array(); - // Add in any theme specific CSS files we have + // Add in any theme specific CSS files we have. $themes = list_themes(); $theme_key = $GLOBALS['theme']; while ($theme_key) { // Try to find the admin css file for non-core themes. if (!in_array($theme_key, array('garland', 'seven', 'bartik'))) { $theme_path = drupal_get_path('theme', $theme_key); - // First search in the css directory, then in the root folder of the theme. + // First search in the css directory, then in the root folder of the + // theme. if (file_exists($theme_path . "/css/views-admin.$theme_key.css")) { $list[$theme_path . "/css/views-admin.$theme_key.css"] = array( 'group' => CSS_THEME, ); } - else if (file_exists($theme_path . "/views-admin.$theme_key.css")) { + elseif (file_exists($theme_path . "/views-admin.$theme_key.css")) { $list[$theme_path . "/views-admin.$theme_key.css"] = array( 'group' => CSS_THEME, ); @@ -54,7 +56,7 @@ function views_ui_get_admin_css() { } $theme_key = isset($themes[$theme_key]->base_theme) ? $themes[$theme_key]->base_theme : ''; } - // Views contains style overrides for the following modules + // Views contains style overrides for the following modules. $module_list = array('contextual', 'advanced_help', 'ctools'); foreach ($module_list as $module) { if (module_exists($module)) { @@ -62,7 +64,6 @@ function views_ui_get_admin_css() { } } - return $list; } @@ -76,11 +77,12 @@ function views_ui_add_admin_css() { } /** - * Check to see if the advanced help module is installed, and if not put up - * a message. + * Check to see if the advanced help module is installed. * - * Only call this function if the user is already in a position for this to - * be useful. + * If not display a message. + * + * Only call this function if the user is already in a position for this to be + * useful. */ function views_ui_check_advanced_help() { if (!variable_get('views_ui_show_advanced_help_warning', TRUE)) { @@ -91,10 +93,18 @@ function views_ui_check_advanced_help() { $filename = db_query_range("SELECT filename FROM {system} WHERE type = 'module' AND name = 'advanced_help'", 0, 1) ->fetchField(); if ($filename && file_exists($filename)) { - drupal_set_message(t('If you enable the advanced help module, Views will provide more and better help. You can disable this message at the Views settings page.', array('@modules' => url('admin/modules'),'@hide' => url('admin/structure/views/settings')))); + drupal_set_message(t('If you enable the advanced help module, Views will provide more and better help. You can disable this message at the Views settings page.', + array( + '@modules' => url('admin/modules'), + '@hide' => url('admin/structure/views/settings'), + ))); } else { - drupal_set_message(t('If you install the advanced help module from !href, Views will provide more and better help. You can disable this message at the Views settings page.', array('!href' => l('http://drupal.org/project/advanced_help', 'http://drupal.org/project/advanced_help'), '@hide' => url('admin/structure/views/settings')))); + drupal_set_message(t('If you install the advanced help module from !href, Views will provide more and better help. You can disable this message at the Views settings page.', + array( + '!href' => l('http://drupal.org/project/advanced_help', 'http://drupal.org/project/advanced_help'), + '@hide' => url('admin/structure/views/settings'), + ))); } } } @@ -133,10 +143,10 @@ function views_ui_preview($view, $display_id, $args = array()) { $view->live_preview = TRUE; $view->views_ui_context = TRUE; - // AJAX happens via $_POST but everything expects exposed data to - // be in GET. Copy stuff but remove ajax-framework specific keys. - // If we're clicking on links in a preview, though, we could actually - // still have some in $_GET, so we use $_REQUEST to ensure we get it all. + // AJAX happens via $_POST but everything expects exposed data to be in + // GET. Copy stuff but remove ajax-framework specific keys. If we're + // clicking on links in a preview, though, we could actually still have + // some in $_GET, so we use $_REQUEST to ensure we get it all. $exposed_input = $_REQUEST; foreach (array('view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', 'ajax_html_ids', 'ajax_page_state', 'form_id', 'form_build_id', 'form_token') as $key) { if (isset($exposed_input[$key])) { @@ -146,14 +156,13 @@ function views_ui_preview($view, $display_id, $args = array()) { $view->set_exposed_input($exposed_input); - if (!$view->set_display($display_id)) { return t('Invalid display id @display', array('@display' => $display_id)); } $view->set_arguments($args); - // Store the current view URL for later use: + // Store the current view URL for later use. if ($view->display_handler->get_option('path')) { $path = $view->get_url(); } @@ -187,7 +196,7 @@ function views_ui_preview($view, $display_id, $args = array()) { if (!empty($view->build_info['query'])) { if ($show_query) { $query = $view->build_info['query']; - // Only the sql default class has a method getArguments. + // Only the SQL default class has a method getArguments. $quoted = array(); if (get_class($view->query) == 'views_plugin_query_default') { @@ -401,8 +410,8 @@ function views_ui_add_form($form, &$form_state) { * Helper form element validator: integer. * * The problem with this is that the function is private so it's not guaranteed - * that it might not be renamed/changed. In the future field.module or something else - * should provide a public validate function. + * that it might not be renamed/changed. In the future field.module or something + * else should provide a public validate function. * * @see _element_validate_integer_positive() */ @@ -414,7 +423,7 @@ function views_element_validate_integer($element, &$form_state) { } /** - * Gets the current value of a #select element, from within a form constructor function. + * Gets the current value of a #select element, from within a form constructor. * * This function is intended for use in highly dynamic forms (in particular the * add view wizard) which are rebuilt in different ways depending on which @@ -434,9 +443,9 @@ function views_element_validate_integer($element, &$form_state) { * the results of this function for any other purpose besides deciding how to * build the next version of the form. * - * @param $form_state - * The standard associative array containing the current state of the form. - * @param $parents + * @param array $form_state + * The standard associative array containing the current state of the form. + * @param array $parents * An array of parent keys that point to the part of the submitted form * values that are expected to contain the element's value (in the case where * this form element was actually submitted). In a simple case (assuming @@ -444,14 +453,14 @@ function views_element_validate_integer($element, &$form_state) { * $form['wrapper']['select'], so that the submitted form values would * normally be found in $form_state['values']['wrapper']['select'], you would * pass array('wrapper', 'select') for this parameter. - * @param $default_value + * @param mixed $default_value * The default value to return if the #select element does not currently have * a proper value set based on the submitted input. - * @param $element + * @param array $element * An array representing the current version of the #select element within * the form. * - * @return + * @return array * The current value of the #select element. A common use for this is to feed * it back into $element['#default_value'] so that the form will be rendered * with the correct value selected. @@ -508,16 +517,16 @@ function views_ui_get_selected($form_state, $parents, $default_value, $element) * mean that the non-JavaScript fallback button does not appear in the correct * place in the form. * - * @param $wrapping_element + * @param array $wrapping_element * The element whose child will server as the AJAX trigger. For example, if * $form['some_wrapper']['triggering_element'] represents the element which * will trigger the AJAX behavior, you would pass $form['some_wrapper'] for * this parameter. - * @param $trigger_key + * @param string $trigger_key * The key within the wrapping element that identifies which of its children * serves as the AJAX trigger. In the above example, you would pass * 'triggering_element' for this parameter. - * @param $refresh_parents + * @param array $refresh_parents * An array of parent keys that point to the part of the form that will be * refreshed by AJAX. For example, if triggering the AJAX behavior should * cause $form['dynamic_content']['section'] to be refreshed, you would pass @@ -581,7 +590,7 @@ function views_ui_add_ajax_trigger(&$wrapping_element, $trigger_key, $refresh_pa $wrapping_element[$button_key]['#value'] = t('Update "@title" choice (@number)', array( '@title' => $button_title, '@number' => ++$seen_buttons[$button_title], - )); + )); } // Attach custom data to the triggering element and submit button, so we can @@ -600,7 +609,7 @@ function views_ui_add_ajax_trigger(&$wrapping_element, $trigger_key, $refresh_pa } /** - * Processes a non-JavaScript fallback submit button to limit its validation errors. + * Processes a non-JS fallback submit button to limit its validation errors. */ function views_ui_add_limited_validation($element, &$form_state) { // Retrieve the AJAX triggering element so we can determine its parents. (We @@ -634,11 +643,11 @@ function views_ui_add_limited_validation($element, &$form_state) { } /** - * After-build function that adds a wrapper to a form region (for AJAX refreshes). + * After-build function that adds a wrapper to a form region (AJAX refreshes). * * This function inserts a wrapper around the region of the form that needs to - * be refreshed by AJAX, based on information stored in the corresponding - * submit button form element. + * be refreshed by AJAX, based on information stored in the corresponding submit + * button form element. */ function views_ui_add_ajax_wrapper($element, &$form_state) { // Don't add the wrapper
    if the same one was already inserted on this @@ -682,7 +691,7 @@ function views_ui_ajax_update_form($form, $form_state) { } /** - * Non-Javascript fallback for updating the add view form. + * Non-JavaScript fallback for updating the add view form. */ function views_ui_nojs_submit($form, &$form_state) { $form_state['rebuild'] = TRUE; @@ -721,7 +730,8 @@ function views_ui_add_form_save_submit($form, &$form_state) { if ($display->handler->has_path()) { $one_path = $display->handler->get_option('path'); if (strpos($one_path, '%') === FALSE) { - $form_state['redirect'] = $one_path; // PATH TO THE VIEW IF IT HAS ONE + $form_state['redirect'] = $one_path; + // PATH TO THE VIEW IF IT HAS ONE. return; } } @@ -811,7 +821,7 @@ function views_ui_taxonomy_autocomplete_validate($element, &$form_state) { /** * Theme function; returns basic administrative information about a view. * - * TODO: template + preprocess + * TODO: template + preprocess. */ function theme_views_ui_view_info($variables) { $view = $variables['view']; @@ -832,13 +842,14 @@ function theme_views_ui_view_info($variables) { case t('Overridden'): $type = t('Database overriding code'); + break; } $output = ''; $output .= '
    ' . check_plain($title) . "
    \n"; $output .= '
    ' . $displays . "
    \n"; $output .= '
    ' . $type . "
    \n"; - $output .= '
    ' . t('Type') . ': ' . check_plain($variables['base']). "
    \n"; + $output .= '
    ' . t('Type') . ': ' . check_plain($variables['base']) . "
    \n"; return $output; } @@ -876,7 +887,7 @@ function views_ui_break_lock_confirm_submit(&$form, &$form_state) { } /** - * Helper function to return the used display_id for the edit page + * Helper function to return the used display_id for the edit page. * * This function handles access to the display. */ @@ -927,6 +938,9 @@ function views_ui_edit_page($view, $display_id = NULL) { return $build; } +/** + * + */ function views_ui_build_preview($view, $display_id, $render = TRUE) { if (isset($_POST['ajax_html_ids'])) { unset($_POST['ajax_html_ids']); @@ -1000,7 +1014,7 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { $form['#attached']['library'][] = array('system', 'ui.dialog'); $form['#attached']['library'][] = array('system', 'drupal.ajax'); $form['#attached']['library'][] = array('system', 'jquery.form'); - // TODO: This should be getting added to the page when an ajax popup calls + // @todo This should be getting added to the page when an ajax popup calls // for it, instead of having to add it manually here. $form['#attached']['js'][] = 'misc/tabledrag.js'; @@ -1009,12 +1023,16 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { $form['#attached']['js'][] = $module_path . '/js/views-admin.js'; $form['#attached']['js'][] = array( - 'data' => array('views' => array('ajax' => array( - 'id' => '#views-ajax-body', - 'title' => '#views-ajax-title', - 'popup' => '#views-ajax-popup', - 'defaultForm' => views_ui_get_default_ajax_message(), - ))), + 'data' => array( + 'views' => array( + 'ajax' => array( + 'id' => '#views-ajax-body', + 'title' => '#views-ajax-title', + 'popup' => '#views-ajax-popup', + 'defaultForm' => views_ui_get_default_ajax_message(), + ), + ), + ), 'type' => 'setting', ); @@ -1030,7 +1048,9 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { if (isset($view->locked) && is_object($view->locked)) { $form['locked'] = array( '#theme_wrappers' => array('container'), - '#attributes' => array('class' => array('view-locked', 'messages', 'warning')), + '#attributes' => array( + 'class' => array('view-locked', 'messages', 'warning'), + ), '#markup' => t('This view is being edited by user !user, and is therefore locked from editing by others. This lock is !age old. Click here to break this lock.', array('!user' => theme('username', array('account' => user_load($view->locked->uid))), '!age' => format_interval(REQUEST_TIME - $view->locked->updated), '!break' => url('admin/structure/views/view/' . $view->name . '/break-lock'))), ); } @@ -1043,7 +1063,9 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { $form['changed'] = array( '#theme_wrappers' => array('container'), - '#attributes' => array('class' => array('view-changed', 'messages', 'warning')), + '#attributes' => array( + 'class' => array('view-changed', 'messages', 'warning'), + ), '#markup' => $message, ); if (empty($view->changed)) { @@ -1072,7 +1094,7 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { $form['actions']['save'] = array( '#type' => 'submit', '#value' => t('Save'), - // Taken from the "old" UI. @TODO: Review and rename. + // Taken from the "old" UI. @todo: Review and rename. '#validate' => array('views_ui_edit_view_form_validate'), '#submit' => array('views_ui_edit_view_form_submit'), ); @@ -1083,7 +1105,8 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { ); $form['displays'] = array( - '#prefix' => '

    ' . t('Displays') . '

    ' . "\n" . '
    ', + '#prefix' => '

    ' . t('Displays') . "

    \n" + . '
    ', '#suffix' => '
    ', ); @@ -1093,8 +1116,8 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { if ($display_id) { $form_state['display_id'] = $display_id; - // The part of the page where editing will take place. - // This element is the ctools collapsible-div container for the display edit elements. + // The part of the page where editing will take place. This element is the + // CTools collapsible-div container for the display edit elements. $form['displays']['settings'] = array( '#theme_wrappers' => array('container'), '#attributes' => array( @@ -1107,7 +1130,8 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { '#id' => 'edit-display-settings', ); $display_title = views_ui_get_display_label($view, $display_id, FALSE); - // Add a handle for the ctools collapsible-div. The handle is the title of the display + // Add a handle for the ctools collapsible-div. The handle is the title of + // the display. $form['displays']['settings']['tab_title']['#markup'] = '

    ' . t('@display_title details', array('@display_title' => ucwords($display_title))) . '

    '; // Add a text that the display is disabled. if (!empty($view->display[$display_id]->handler)) { @@ -1116,8 +1140,8 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { $form['displays']['settings']['disabled']['#markup'] = t('This display is disabled.'); } } - // The ctools collapsible-div content - $form['displays']['settings']['settings_content']= array( + // The ctools collapsible-div content. + $form['displays']['settings']['settings_content'] = array( '#theme_wrappers' => array('container'), '#id' => 'edit-display-settings-content', '#attributes' => array( @@ -1126,7 +1150,7 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { ), ), ); - // Add the edit display content + // Add the edit display content. $form['displays']['settings']['settings_content']['tab_content'] = views_ui_get_display_tab($view, $display_id); $form['displays']['settings']['settings_content']['tab_content']['#theme_wrappers'] = array('container'); $form['displays']['settings']['settings_content']['tab_content']['#attributes'] = array('class' => array('views-display-tab')); @@ -1172,7 +1196,7 @@ function views_ui_preview_form($form, &$form_state, $view, $display_id = 'defaul $form_state['no_cache'] = TRUE; $form_state['view'] = $view; - $form['#attributes'] = array('class' => array('clearfix',)); + $form['#attributes'] = array('class' => array('clearfix')); // Add a checkbox controlling whether or not this display auto-previews. $form['live_preview'] = array( @@ -1182,16 +1206,16 @@ function views_ui_preview_form($form, &$form_state, $view, $display_id = 'defaul '#default_value' => variable_get('views_ui_always_live_preview', TRUE), ); - // Add the arguments textfield + // Add the arguments textfield. $form['view_args'] = array( '#type' => 'textfield', '#title' => t('Preview with contextual filters:'), '#description' => t('Separate contextual filter values with a "/". For example, %example.', array('%example' => '40/12/10')), '#id' => 'preview-args', -// '#attributes' => array('class' => array('ctools-auto-submit')), + // '#attributes' => array('class' => array('ctools-auto-submit')), ); - // Add the preview button + // Add the preview button. $form['button'] = array( '#type' => 'submit', '#value' => t('Update preview'), @@ -1211,10 +1235,10 @@ function views_ui_preview_form($form, &$form_state, $view, $display_id = 'defaul // Make ENTER in arguments textfield (and other controls) submit the form // as this button, not the Save button. // @todo This only works for JS users. To make this work for nojs users, - // we may need to split Preview into a separate form. + // we may need to split Preview into a separate form. '#process' => array_merge(array('views_ui_default_button'), element_info_property('submit', '#process', array())), ); - $form['#action'] = url('admin/structure/views/view/' . $view->name .'/preview/' . $display_id); + $form['#action'] = url('admin/structure/views/view/' . $view->name . '/preview/' . $display_id); return $form; } @@ -1227,15 +1251,15 @@ function views_ui_render_display_top($view, $display_id) { $element['#attributes']['class'] = array('views-display-top', 'clearfix'); $element['#attributes']['id'] = array('views-display-top'); - // Extra actions for the display + // Extra actions for the display. $element['extra_actions'] = array( '#theme' => 'links__ctools_dropbutton', '#attributes' => array( - 'id' => 'views-display-extra-actions', - 'class' => array( - 'horizontal', 'right', 'links', 'actions', - ), + 'id' => 'views-display-extra-actions', + 'class' => array( + 'horizontal', 'right', 'links', 'actions', ), + ), '#links' => array( 'edit-details' => array( 'title' => t('edit view name/description'), @@ -1310,6 +1334,9 @@ function views_ui_render_display_top($view, $display_id) { return $element; } +/** + * + */ function views_ui_get_default_ajax_message() { return '
    ' . t("Click on an item to edit that item's details.") . '
    '; } @@ -1372,11 +1399,11 @@ function views_ui_edit_form_submit_delete_display($form, &$form_state) { * Submit handler to add a restore a removed display to a view. */ function views_ui_edit_form_submit_undo_delete_display($form, &$form_state) { - // Create the new display + // Create the new display. $id = $form_state['display_id']; $form_state['view']->display[$id]->deleted = FALSE; - // Store in cache + // Store in cache. views_ui_cache_set($form_state['view']); // Redirect to the top-level edit page. @@ -1388,10 +1415,10 @@ function views_ui_edit_form_submit_undo_delete_display($form, &$form_state) { */ function views_ui_edit_form_submit_enable_display($form, &$form_state) { $id = $form_state['display_id']; - // set_option doesn't work because this would might affect upper displays + // set_option doesn't work because this would might affect upper displays. $form_state['view']->display[$id]->handler->set_option('enabled', TRUE); - // Store in cache + // Store in cache. views_ui_cache_set($form_state['view']); // Redirect to the top-level edit page. @@ -1405,7 +1432,7 @@ function views_ui_edit_form_submit_disable_display($form, &$form_state) { $id = $form_state['display_id']; $form_state['view']->display[$id]->handler->set_option('enabled', FALSE); - // Store in cache + // Store in cache. views_ui_cache_set($form_state['view']); // Redirect to the top-level edit page. @@ -1459,10 +1486,10 @@ function views_ui_edit_form_submit_delay_destination($form, &$form_state) { * * @param view $view * The view which will be edited. - * @param $display_id + * @param string $display_id * The display_id which is edited on the current request. */ -function views_ui_edit_page_display_tabs($view, $display_id = NULL) { +function views_ui_edit_page_display_tabs(view $view, $display_id = NULL) { $tabs = array(); // Create a tab for each display. @@ -1483,7 +1510,8 @@ function views_ui_edit_page_display_tabs($view, $display_id = NULL) { } } - // If the default display isn't supposed to be shown, don't display its tab, unless it's the only display. + // If the default display isn't supposed to be shown, don't display its tab, + // unless it's the only display. if ((!views_ui_show_default_display($view) && $display_id != 'default') && count($tabs) > 1) { $tabs['default']['#access'] = FALSE; } @@ -1526,7 +1554,7 @@ function views_ui_get_display_tab($view, $display_id) { // page. if (empty($display->handler)) { $title = isset($display->display_title) ? $display->display_title : t('Invalid'); - // @TODO: Improved UX for the case where a plugin is missing. + // @todo: Improved UX for the case where a plugin is missing. $build['#markup'] = t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", array('@display' => $display->id, '@plugin' => $display->display_plugin)); } // Build the content of the edit page. @@ -1542,8 +1570,10 @@ function views_ui_get_display_tab($view, $display_id) { /** * Helper function to get the display details section of the edit UI. * - * @param $view - * @param $display + * @param view $view + * The full view object. + * @param object $display + * The display object to work with. * * @return array * A renderable page build array. @@ -1552,35 +1582,40 @@ function views_ui_get_display_tab_details($view, $display) { $display_title = views_ui_get_display_label($view, $display->id, FALSE); $build = array( '#theme_wrappers' => array('container'), - '#attributes' => array('id' => 'edit-display-settings-details',), + '#attributes' => array('id' => 'edit-display-settings-details'), ); $plugin = views_fetch_plugin_data('display', $view->display[$display->id]->display_plugin); - // The following is for display purposes only. We need to determine if there is more than one button and wrap - // the buttons in a .ctools-dropbutton class if more than one is present. Otherwise, we'll just wrap the - // actions in the .ctools-button class. - $isDisplayDeleted = !empty($display->deleted); - $isDeletable = empty($plugin['no remove']); + // The following is for display purposes only. We need to determine if there + // is more than one button and wrap the buttons in a .ctools-dropbutton class + // if more than one is present. Otherwise, we'll just wrap the actions in the + // .ctools-button class. + $is_display_deleted = !empty($display->deleted); + $is_deletable = empty($plugin['no remove']); // The master display cannot be cloned. - $isDefault = $display->id == 'default'; + $is_default = $display->id == 'default'; // @todo: Figure out why get_option doesn't work here. - $isEnabled = $display->handler->get_option('enabled'); + $is_enabled = $display->handler->get_option('enabled'); - if (!$isDisplayDeleted && $isDeletable && !$isDefault) { - $prefix = '
      '; + if (!$is_display_deleted && $is_deletable && !$is_default) { + $prefix = '
        '; $suffix = '
      '; - $itemElement = 'li'; + $item_element = 'li'; } else { $prefix = '
        '; $suffix = '
      '; - $itemElement = 'li'; + $item_element = 'li'; } if ($display->id != 'default') { $build['top']['#theme_wrappers'] = array('container'); $build['top']['#attributes']['id'] = 'edit-display-settings-top'; - $build['top']['#attributes']['class'] = array('views-ui-display-tab-actions', 'views-ui-display-tab-bucket', 'clearfix'); + $build['top']['#attributes']['class'] = array( + 'views-ui-display-tab-actions', + 'views-ui-display-tab-bucket', + 'clearfix', + ); // The Delete, Duplicate and Undo Delete buttons. $build['top']['actions'] = array( @@ -1588,15 +1623,18 @@ function views_ui_get_display_tab_details($view, $display) { '#suffix' => $suffix, ); - if (!$isDisplayDeleted) { - if (!$isEnabled) { + if (!$is_display_deleted) { + if (!$is_enabled) { $build['top']['actions']['enable'] = array( '#type' => 'submit', '#value' => t('enable @display_title', array('@display_title' => $display_title)), '#limit_validation_errors' => array(), - '#submit' => array('views_ui_edit_form_submit_enable_display', 'views_ui_edit_form_submit_delay_destination'), - '#prefix' => '<' . $itemElement . ' class="enable">', - "#suffix" => '', + '#submit' => array( + 'views_ui_edit_form_submit_enable_display', + 'views_ui_edit_form_submit_delay_destination', + ), + '#prefix' => '<' . $item_element . ' class="enable">', + "#suffix" => '', ); } // Add a link to view the page. @@ -1606,41 +1644,52 @@ function views_ui_get_display_tab_details($view, $display) { $build['top']['actions']['path'] = array( '#type' => 'link', '#title' => t('view @display', array('@display' => $display->display_title)), - '#options' => array('alt' => array(t("Go to the real page for this display"))), + '#options' => array( + 'alt' => array(t('Go to the real page for this display')), + ), '#href' => $path, - '#prefix' => '<' . $itemElement . ' class="view">', - "#suffix" => '', + '#prefix' => '<' . $item_element . ' class="view">', + "#suffix" => '', ); } } - if (!$isDefault) { + if (!$is_default) { $build['top']['actions']['duplicate'] = array( '#type' => 'submit', '#value' => t('clone @display_title', array('@display_title' => $display_title)), '#limit_validation_errors' => array(), - '#submit' => array('views_ui_edit_form_submit_duplicate_display', 'views_ui_edit_form_submit_delay_destination'), - '#prefix' => '<' . $itemElement . ' class="duplicate">', - "#suffix" => '', + '#submit' => array( + 'views_ui_edit_form_submit_duplicate_display', + 'views_ui_edit_form_submit_delay_destination', + ), + '#prefix' => '<' . $item_element . ' class="duplicate">', + "#suffix" => '', ); } - if ($isDeletable) { + if ($is_deletable) { $build['top']['actions']['delete'] = array( '#type' => 'submit', '#value' => t('delete @display_title', array('@display_title' => $display_title)), '#limit_validation_errors' => array(), - '#submit' => array('views_ui_edit_form_submit_delete_display', 'views_ui_edit_form_submit_delay_destination'), - '#prefix' => '<' . $itemElement . ' class="delete">', - "#suffix" => '', + '#submit' => array( + 'views_ui_edit_form_submit_delete_display', + 'views_ui_edit_form_submit_delay_destination', + ), + '#prefix' => '<' . $item_element . ' class="delete">', + "#suffix" => '', ); } - if ($isEnabled) { + if ($is_enabled) { $build['top']['actions']['disable'] = array( '#type' => 'submit', '#value' => t('disable @display_title', array('@display_title' => $display_title)), '#limit_validation_errors' => array(), - '#submit' => array('views_ui_edit_form_submit_disable_display', 'views_ui_edit_form_submit_delay_destination'), - '#prefix' => '<' . $itemElement . ' class="disable">', - "#suffix" => '', + '#submit' => array( + 'views_ui_edit_form_submit_disable_display', + 'views_ui_edit_form_submit_delay_destination', + ), + '#prefix' => '<' . $item_element . ' class="disable">', + "#suffix" => '', ); } } @@ -1649,9 +1698,12 @@ function views_ui_get_display_tab_details($view, $display) { '#type' => 'submit', '#value' => t('undo delete of @display_title', array('@display_title' => $display_title)), '#limit_validation_errors' => array(), - '#submit' => array('views_ui_edit_form_submit_undo_delete_display', 'views_ui_edit_form_submit_delay_destination'), - '#prefix' => '<' . $itemElement . ' class="undo-delete">', - "#suffix" => '', + '#submit' => array( + 'views_ui_edit_form_submit_undo_delete_display', + 'views_ui_edit_form_submit_delay_destination', + ), + '#prefix' => '<' . $item_element . ' class="undo-delete">', + "#suffix" => '', ); } @@ -1665,22 +1717,37 @@ function views_ui_get_display_tab_details($view, $display) { $build['columns'] = array(); $build['columns']['#theme_wrappers'] = array('container'); - $build['columns']['#attributes'] = array('id' => 'edit-display-settings-main', 'class' => array('clearfix', 'views-display-columns'),); + $build['columns']['#attributes'] = array( + 'id' => 'edit-display-settings-main', + 'class' => array('clearfix', 'views-display-columns'), + ); $build['columns']['first']['#theme_wrappers'] = array('container'); - $build['columns']['first']['#attributes'] = array('class' => array('views-display-column', 'first')); + $build['columns']['first']['#attributes'] = array( + 'class' => array('views-display-column', 'first'), + ); $build['columns']['second']['#theme_wrappers'] = array('container'); - $build['columns']['second']['#attributes'] = array('class' => array('views-display-column', 'second')); + $build['columns']['second']['#attributes'] = array( + 'class' => array('views-display-column', 'second'), + ); $build['columns']['second']['settings'] = array(); $build['columns']['second']['header'] = array(); $build['columns']['second']['footer'] = array(); $build['columns']['second']['pager'] = array(); - // The third column buckets are wrapped in a CTools collapsible div + // The third column buckets are wrapped in a CTools collapsible div. $build['columns']['third']['#theme_wrappers'] = array('container'); - $build['columns']['third']['#attributes'] = array('class' => array('views-display-column', 'third', 'ctools-collapsible-container', 'ctools-collapsible-remember')); + $build['columns']['third']['#attributes'] = array( + 'class' => array( + 'views-display-column', + 'third', + 'ctools-collapsible-container', + 'ctools-collapsible-remember', + ), + ); + // Specify an id that won't change after AJAX requests, so ctools can keep // track of the user's preferred collapsible state. Use the same id across // different displays of the same view, so changing displays doesn't @@ -1690,9 +1757,11 @@ function views_ui_get_display_tab_details($view, $display) { if (!variable_get('views_ui_show_advanced_column', FALSE)) { $build['columns']['third']['#attributes']['class'][] = 'ctools-collapsed'; } - $build['columns']['third']['advanced'] = array('#markup' => '

      ' . t('Advanced') . '

      ',); + $build['columns']['third']['advanced'] = array('#markup' => '

      ' . t('Advanced') . '

      '); $build['columns']['third']['collapse']['#theme_wrappers'] = array('container'); - $build['columns']['third']['collapse']['#attributes'] = array('class' => array('ctools-collapsible-content',),); + $build['columns']['third']['collapse']['#attributes'] = array( + 'class' => array('ctools-collapsible-content'), + ); // Each option (e.g. title, access, display as grid/table/list) fits into one // of several "buckets," or boxes (Format, Fields, Sort, and so on). @@ -1721,7 +1790,7 @@ function views_ui_get_display_tab_details($view, $display) { } if (isset($bucket['build']) && is_array($bucket['build'])) { // The third column is a CTools collapsible div, so - // the structure of the form is a little different for this column + // the structure of the form is a little different for this column. if ($column === 'third') { $build['columns'][$column]['collapse'][$id] = $bucket['build']; $build['columns'][$column]['collapse'][$id]['#theme_wrappers'][] = 'views_ui_display_tab_bucket'; @@ -1789,12 +1858,15 @@ function views_ui_edit_form_get_build_from_option($id, $option, $view, $display) return $option_build; } +/** + * + */ function template_preprocess_views_ui_display_tab_setting(&$variables) { static $zebra = 0; $variables['zebra'] = ($zebra % 2 === 0 ? 'odd' : 'even'); $zebra++; - // Put the main link to the left side + // Put the main link to the left side. array_unshift($variables['settings_links'], $variables['link']); $variables['settings_links'] = implode(' | ', $variables['settings_links']); @@ -1815,6 +1887,9 @@ function template_preprocess_views_ui_display_tab_setting(&$variables) { } } +/** + * + */ function template_preprocess_views_ui_display_tab_bucket(&$variables) { $element = $variables['element']; @@ -1835,6 +1910,9 @@ function template_preprocess_views_ui_display_tab_bucket(&$variables) { $variables['actions'] = !empty($element['#actions']) ? $element['#actions'] : ''; } +/** + * + */ function template_preprocess_views_ui_display_tab_column(&$variables) { $element = $variables['element']; @@ -2016,7 +2094,8 @@ function views_ui_import_validate($form, &$form_state) { elseif (version_compare($view->api_version, views_api_version(), '>')) { form_error($form['view'], t('That view is created for the version @import_version of views, but you only have @api_version', array( '@import_version' => $view->api_version, - '@api_version' => views_api_version()))); + '@api_version' => views_api_version(), + ))); } // View name must be alphanumeric or underscores, no other punctuation. @@ -2049,23 +2128,30 @@ function views_ui_import_validate($form, &$form_state) { // Bypass the validation of view pluigns/handlers if option is checked. if (!$form_state['values']['bypass_validation']) { - // Make sure that all plugins and handlers needed by this view actually exist. + // Make sure that all plugins and handlers needed by this view actually + // exist. foreach ($view->display as $id => $display) { if (empty($display->handler) || !empty($display->handler->broken)) { - drupal_set_message(t('Display plugin @plugin is not available.', array('@plugin' => $display->display_plugin)), 'error'); + drupal_set_message(t('Display plugin @plugin is not available.', array( + '@plugin' => $display->display_plugin, + )), 'error'); $broken = TRUE; continue; } $plugin = views_get_plugin('style', $display->handler->get_option('style_plugin')); if (!$plugin) { - drupal_set_message(t('Style plugin @plugin is not available.', array('@plugin' => $display->handler->get_option('style_plugin'))), 'error'); + drupal_set_message(t('Style plugin @plugin is not available.', array( + '@plugin' => $display->handler->get_option('style_plugin'), + )), 'error'); $broken = TRUE; } elseif ($plugin->uses_row_plugin()) { $plugin = views_get_plugin('row', $display->handler->get_option('row_plugin')); if (!$plugin) { - drupal_set_message(t('Row plugin @plugin is not available.', array('@plugin' => $display->handler->get_option('row_plugin'))), 'error'); + drupal_set_message(t('Row plugin @plugin is not available.', array( + '@plugin' => $display->handler->get_option('row_plugin'), + )), 'error'); $broken = TRUE; } } @@ -2076,10 +2162,10 @@ function views_ui_import_validate($form, &$form_state) { foreach ($handlers as $id => $handler) { if ($handler->broken()) { drupal_set_message(t('@type handler @table.@field is not available.', array( - '@type' => $info['stitle'], - '@table' => $handler->table, - '@field' => $handler->field, - )), 'error'); + '@type' => $info['stitle'], + '@table' => $handler->table, + '@field' => $handler->field, + )), 'error'); $broken = TRUE; } } @@ -2135,7 +2221,8 @@ function views_ui_edit_view_form_submit($form, &$form_state) { foreach ($form_state['view']->display as $id => $display) { if (!empty($display->new_id)) { $form_state['view']->display[$id]->id = $display->new_id; - // Redirect the user to the renamed display to be sure that the page itself exists and doesn't throw errors. + // Redirect the user to the renamed display to be sure that the page + // itself exists and doesn't throw errors. $form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->name . '/edit/' . $display->new_id; } } @@ -2143,7 +2230,8 @@ function views_ui_edit_view_form_submit($form, &$form_state) { // Direct the user to the right url, if the path of the display has changed. if (!empty($_GET['destination'])) { $destination = $_GET['destination']; - // Find out the first display which has a changed path and redirect to this url. + // Find out the first display which has a changed path and redirect to this + // URL. $old_view = views_get_view($form_state['view']->name); foreach ($old_view->display as $id => $display) { // Only check for displays with a path. @@ -2179,9 +2267,12 @@ function views_ui_edit_view_form_cancel($form, &$form_state) { } } +/** + * + */ function views_ui_edit_view_form_delete($form, &$form_state) { unset($_REQUEST['destination']); - // Redirect to the delete confirm page + // Redirect to the delete confirm page. $form_state['redirect'] = array('admin/structure/views/view/' . $form_state['view']->name . '/delete', array('query' => drupal_get_destination() + array('cancel' => 'admin/structure/views/view/' . $form_state['view']->name . '/edit'))); } @@ -2212,9 +2303,10 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { case 'filter': $rearrange_url = "admin/structure/views/nojs/rearrange-$type/$view->name/$display->id/$type"; $rearrange_text = t('And/Or, Rearrange'); - // TODO: Add another class to have another symbol for filter rearrange. + // @todo Add another class to have another symbol for filter rearrange. $class = 'icon compact rearrange'; break; + case 'field': // Fetch the style plugin info so we know whether to list fields or not. $style_plugin = $display->handler->get_plugin(); @@ -2240,7 +2332,7 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { $actions['add'] = array( 'title' => t('Add'), 'href' => "admin/structure/views/nojs/add-item/$view->name/$display->id/$type", - 'attributes'=> array('class' => array('icon compact add', 'views-ajax-link'), 'title' => t('Add'), 'id' => 'views-add-' . $type), + 'attributes' => array('class' => array('icon compact add', 'views-ajax-link'), 'title' => t('Add'), 'id' => 'views-add-' . $type), 'html' => TRUE, ); if ($count_handlers > 0) { @@ -2252,12 +2344,12 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { ); } - // Render the array of links + // Render the array of links. $build['#actions'] = theme('links__ctools_dropbutton', array( 'links' => $actions, 'attributes' => array( - 'class' => array('inline', 'links', 'actions', 'horizontal', 'right') + 'class' => array('inline', 'links', 'actions', 'horizontal', 'right'), ), 'class' => array('views-ui-settings-bucket-operations'), ) @@ -2279,7 +2371,7 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { static $relationships = NULL; if (!isset($relationships)) { - // Get relationship labels + // Get relationship labels. $relationships = array(); // @todo: get_handlers() $handlers = $display->handler->get_option('relationships'); @@ -2291,7 +2383,7 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { } } - // Filters can now be grouped so we do a little bit extra: + // Filters can now be grouped so we do a little bit extra. $groups = array(); $grouping = FALSE; if ($type == 'filter') { @@ -2334,16 +2426,16 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { $build['fields'][$id]['#link'] = l($link_text, "admin/structure/views/nojs/config-item/$view->name/$display->id/$type/$id", array('attributes' => $link_attributes, 'html' => TRUE)); $build['fields'][$id]['#class'][] = drupal_clean_css_identifier($display->id . '-' . $type . '-' . $id); if (!empty($view->changed_sections[$display->id . '-' . $type . '-' . $id])) { - // @TODO: #changed is no longer being used? + // @todo: #changed is no longer being used? $build['fields'][$id]['#changed'] = TRUE; } if ($display->handler->use_group_by() && $handler->use_group_by()) { - $build['fields'][$id]['#settings_links'][] = l('' . t('Aggregation settings') . '', "admin/structure/views/nojs/config-item-group/$view->name/$display->id/$type/$id", array('attributes' => array('class' => 'views-button-configure views-ajax-link', 'title' => t('Aggregation settings')), 'html' => true)); + $build['fields'][$id]['#settings_links'][] = l('' . t('Aggregation settings') . '', "admin/structure/views/nojs/config-item-group/$view->name/$display->id/$type/$id", array('attributes' => array('class' => 'views-button-configure views-ajax-link', 'title' => t('Aggregation settings')), 'html' => TRUE)); } if ($handler->has_extra_options()) { - $build['fields'][$id]['#settings_links'][] = l('' . t('Settings') . '', "admin/structure/views/nojs/config-item-extra/$view->name/$display->id/$type/$id", array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => t('Settings')), 'html' => true)); + $build['fields'][$id]['#settings_links'][] = l('' . t('Settings') . '', "admin/structure/views/nojs/config-item-extra/$view->name/$display->id/$type/$id", array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => t('Settings')), 'html' => TRUE)); } if ($grouping) { @@ -2357,7 +2449,8 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { } } - // If using grouping, re-order fields so that they show up properly in the list. + // If using grouping, re-order fields so that they show up properly in the + // list. if ($type == 'filter' && $grouping) { $store = $build['fields']; $build['fields'] = array(); @@ -2405,7 +2498,9 @@ function views_ui_regenerate_tab(&$view, &$output, $display_id) { } /** - * Recursively adds microweights to a render array, similar to what form_builder() does for forms. + * Recursively adds microweights to a render array. + * + * Similar to what form_builder() does for forms. * * @todo Submit a core patch to fix drupal_render() to do this, so that all * render arrays automatically preserve array insertion order, as forms do. @@ -2414,7 +2509,7 @@ function views_ui_add_microweights(&$build) { $count = 0; foreach (element_children($build) as $key) { if (!isset($build[$key]['#weight'])) { - $build[$key]['#weight'] = $count/1000; + $build[$key]['#weight'] = $count / 1000; } views_ui_add_microweights($build[$key]); $count++; @@ -2499,8 +2594,8 @@ function views_ui_standard_form_buttons(&$form, &$form_state, $form_id, $name = ); } - // Compatibility, to be removed later: // TODO: When is "later"? - // We used to set these items on the form, but now we want them on the $form_state: + // Compatibility, to be removed later: // @todo When is "later"? We used to + // set these items on the form, but now we want them on the $form_state. if (isset($form['#title'])) { $form_state['title'] = $form['#title']; } @@ -2535,11 +2630,10 @@ function views_ui_standard_form_buttons(&$form, &$form_state, $form_id, $name = function views_ui_standard_submit($form, &$form_state) { // Determine whether the values the user entered are intended to apply to // the current display or the default display. - list($was_defaulted, $is_defaulted, $revert) = views_ui_standard_override_values($form, $form_state); // Mark the changed section of the view as changed. - // TODO: Document why we are doing this, and see if we still need it. + // @todo Document why we are doing this, and see if we still need it. if (!empty($form['#section'])) { $form_state['view']->changed_sections[$form['#section']] = TRUE; } @@ -2551,7 +2645,8 @@ function views_ui_standard_submit($form, &$form_state) { $display = &$form_state['view']->display[$form_state['display_id']]; $display->handler->options_override($form, $form_state); - // Don't execute the normal submit handling but still store the changed view into cache. + // Don't execute the normal submit handling but still store the changed + // view into cache. views_ui_cache_set($form_state['view']); return; } @@ -2590,8 +2685,9 @@ function views_ui_standard_submit($form, &$form_state) { function views_ui_standard_override_values($form, $form_state) { // Make sure the dropdown exists in the first place. if (isset($form_state['values']['override']['dropdown'])) { - // #default_value is used to determine whether it was the default value or not. - // So the available options are: $display, 'default' and 'default_revert', not 'defaults'. + // #default_value is used to determine whether it was the default value or + // not. So the available options are: $display, 'default' and + // 'default_revert', not 'defaults'. $was_defaulted = ($form['override']['dropdown']['#default_value'] === 'defaults'); $is_defaulted = ($form_state['values']['override']['dropdown'] === 'default'); $revert = ($form_state['values']['override']['dropdown'] === 'default_revert'); @@ -2613,7 +2709,7 @@ function views_ui_standard_override_values($form, $form_state) { } /** - * Submit handler for cancel button + * Submit handler for cancel button. */ function views_ui_standard_cancel($form, &$form_state) { if (!empty($form_state['view']->changed) && isset($form_state['view']->form_cache)) { @@ -2625,9 +2721,10 @@ function views_ui_standard_cancel($form, &$form_state) { } /** - * Add a dropdown for a given section. + * + * Allows the user to change whether this info is stored on the default display + * or on the current display. */ function views_ui_standard_display_dropdown(&$form, &$form_state, $section) { $view = &$form_state['view']; @@ -2636,7 +2733,7 @@ function views_ui_standard_display_dropdown(&$form, &$form_state, $section) { $current_display = $view->display[$display_id]; // Add the "2 of 3" progress indicator. - // @TODO: Move this to a separate function if it's needed on any forms that + // @todo: Move this to a separate function if it's needed on any forms that // don't have the display dropdown. if ($form_progress = views_ui_get_form_progress($view)) { $form['progress']['#markup'] = '
      ' . t('@current of @total', array('@current' => $form_progress['current'], '@total' => $form_progress['total'])) . '
      '; @@ -2674,7 +2771,8 @@ function views_ui_standard_display_dropdown(&$form, &$form_state, $section) { ); $form['override']['dropdown'] = array( '#type' => 'select', - '#title' => t('For'), // @TODO: Translators may need more context than this. + '#title' => t('For'), + // @todo: Translators may need more context than this. '#options' => $display_dropdown, ); if ($current_display->handler->is_defaulted($section)) { @@ -2689,7 +2787,7 @@ function views_ui_standard_display_dropdown(&$form, &$form_state, $section) { /** * Get the user's current progress through the form stack. * - * @param $view + * @param view $view * The current view. * * @return @@ -2721,7 +2819,6 @@ function views_ui_get_form_progress($view) { // -------------------------------------------------------------------------- // Various subforms for editing the pieces of a view. - function views_ui_ajax_forms($key = NULL) { $forms = array( 'display' => array( @@ -2809,7 +2906,7 @@ function views_ui_build_identifier($key, $view, $display_id, $args) { */ function views_ui_build_form_state($js, $key, &$view, $display_id, $args) { $form = views_ui_ajax_forms($key); - // Build up form state + // Build up form state. $form_state = array( 'form_key' => $key, 'form_id' => $form['form_id'], @@ -2890,6 +2987,10 @@ function views_ui_add_form_to_stack($key, &$view, $display_id, $args, $top = FAL * together. */ function views_ui_ajax_form($js, $key, $view, $display_id = '') { + $args = func_get_args(); + // Remove the known args. + array_splice($args, 0, 4); + // Reset the cache of IDs. Drupal rather aggressively prevents id duplication // but this causes it to remember IDs that are no longer even being used. if (isset($_POST['ajax_html_ids'])) { @@ -2902,9 +3003,6 @@ function views_ui_ajax_form($js, $key, $view, $display_id = '') { } views_include('ajax'); - $args = func_get_args(); - // Remove the known args - array_splice($args, 0, 4); $form_state = views_ui_build_form_state($js, $key, $view, $display_id, $args); // check to see if this is the top form of the stack. If it is, pop @@ -2915,9 +3013,9 @@ function views_ui_ajax_form($js, $key, $view, $display_id = '') { // Retrieve the first form from the stack without changing the integer keys, // as they're being used for the "2 of 3" progress indicator. reset($view->stack); - list($key, $top) = each($view->stack); + $key = key($view->stack); + $top = current($view->stack); unset($view->stack[$key]); - if (array_shift($top) != $identifier) { $view->stack = array(); } @@ -2933,8 +3031,9 @@ function views_ui_ajax_form($js, $key, $view, $display_id = '') { // With the below logic, we may end up rendering a form twice (or two forms // each sharing the same element ids), potentially resulting in // drupal_add_js() being called twice to add the same setting. drupal_get_js() - // is ok with that, but until ajax_render() is (http://drupal.org/node/208611), - // reset the drupal_add_js() static before rendering the second time. + // is ok with that, but until ajax_render() is, reset the drupal_add_js() + // static before rendering the second time. + // @see http://drupal.org/node/208611 $drupal_add_js_original = drupal_add_js(); $drupal_add_js = &drupal_static('drupal_add_js'); $output = views_ajax_form_wrapper($form_state['form_id'], $form_state); @@ -2946,6 +3045,11 @@ function views_ui_ajax_form($js, $key, $view, $display_id = '') { $stack = $view->stack; $top = array_shift($stack); $top[0] = $js; + + // Change view into a reference. + $stepview = $top[2]; + $top[2] = &$stepview; + $form_state = call_user_func_array('views_ui_build_form_state', $top); $form_state['input'] = array(); $form_state['url'] = url(views_ui_build_form_url($form_state)); @@ -2955,7 +3059,8 @@ function views_ui_ajax_form($js, $key, $view, $display_id = '') { $output = views_ajax_form_wrapper($form_state['form_id'], $form_state); } elseif (!$js) { - // if nothing on the stack, non-js forms just go back to the main view editor. + // If nothing on the stack, non-js forms just go back to the main view + // editor. return drupal_goto("admin/structure/views/view/$view->name/edit"); } else { @@ -2981,16 +3086,16 @@ function views_ui_ajax_form($js, $key, $view, $display_id = '') { * Submit handler to add a restore a removed display to a view. */ function views_ui_remove_display_form_restore($form, &$form_state) { - // Create the new display + // Create the new display. $id = $form_state['display_id']; $form_state['view']->display[$id]->deleted = FALSE; - // Store in cache + // Store in cache. views_ui_cache_set($form_state['view']); } /** - * Form constructor callback to display analysis information on a view + * Form constructor callback to display analysis information on a view. */ function views_ui_analyze_view_form($form, &$form_state) { $view = &$form_state['view']; @@ -3014,14 +3119,14 @@ function views_ui_analyze_view_form($form, &$form_state) { } /** - * Submit handler for views_ui_analyze_view_form + * Submit handler for views_ui_analyze_view_form. */ function views_ui_analyze_view_form_submit($form, &$form_state) { $form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->name . '/edit'; } /** - * Form constructor callback to reorder displays on a view + * Form constructor callback to reorder displays on a view. */ function views_ui_reorder_displays_form($form, &$form_state) { $view = &$form_state['view']; @@ -3066,7 +3171,7 @@ function views_ui_reorder_displays_form($form, &$form_state) { $form['#title'] = t('Displays Reorder'); $form['#section'] = 'reorder'; - // Add javascript settings that will be added via $.extend for tabledragging + // Add JavaScript settings that will be added via $.extend for tabledragging. $form['#js']['tableDrag']['reorder-displays']['weight'][0] = array( 'target' => 'weight', 'source' => NULL, @@ -3084,7 +3189,7 @@ function views_ui_reorder_displays_form($form, &$form_state) { } /** - * Display position sorting function + * Display position sorting function. */ function _views_position_sort($display1, $display2) { if ($display1->position != $display2->position) { @@ -3095,10 +3200,10 @@ function _views_position_sort($display1, $display2) { } /** - * Submit handler for rearranging display form + * Submit handler for rearranging display form. */ function views_ui_reorder_displays_form_submit($form, &$form_state) { - foreach($form_state['input'] as $display => $info) { + foreach ($form_state['input'] as $display => $info) { // add each value that is a field with a weight to our list, but only if // it has had its 'removed' checkbox checked. if (is_array($info) && isset($info['weight']) && empty($info['removed'])) { @@ -3106,19 +3211,19 @@ function views_ui_reorder_displays_form_submit($form, &$form_state) { } } - // Sort the order array + // Sort the order array. asort($order); - // Fixing up positions + // Fixing up positions. $position = 2; - foreach(array_keys($order) as $display) { + foreach (array_keys($order) as $display) { $order[$display] = $position++; } - // Setting up position and removing deleted displays + // Setting up position and removing deleted displays. $displays = $form_state['view']->display; - foreach($displays as $display_id => $display) { + foreach ($displays as $display_id => $display) { // Don't touch the default !!! if ($display_id === 'default') { continue; @@ -3131,16 +3236,16 @@ function views_ui_reorder_displays_form_submit($form, &$form_state) { } } - // Sorting back the display array as the position is not enough + // Sorting back the display array as the position is not enough. uasort($form_state['view']->display, '_views_position_sort'); - // Store in cache + // Store in cache. views_ui_cache_set($form_state['view']); $form_state['redirect'] = array('admin/structure/views/view/' . $form_state['view']->name . '/edit', array('fragment' => 'views-tab-default')); } /** - * Turn the reorder form into a proper table + * Turn the reorder form into a proper table. */ function theme_views_ui_reorder_displays_form($vars) { $form = $vars['form']; @@ -3187,10 +3292,11 @@ function theme_views_ui_reorder_displays_form($vars) { $output = drupal_render($form['override']); $output .= '
      '; $output .= theme('table', - array('header' => $header, - 'rows' => $rows, - 'attributes' => array('id' => 'reorder-displays'), - )); + array( + 'header' => $header, + 'rows' => $rows, + 'attributes' => array('id' => 'reorder-displays'), + )); $output .= '
      '; $output .= drupal_render_children($form); @@ -3251,7 +3357,7 @@ function views_ui_edit_details_form_submit($form, &$form_state) { } /** - * Form constructor callback to edit display of a view + * Form constructor callback to edit display of a view. */ function views_ui_edit_display_form($form, &$form_state) { $view = &$form_state['view']; @@ -3291,7 +3397,7 @@ function views_ui_edit_display_form($form, &$form_state) { } /** - * Validate handler for views_ui_edit_display_form + * Validate handler for views_ui_edit_display_form. */ function views_ui_edit_display_form_validate($form, &$form_state) { $display = &$form_state['view']->display[$form_state['display_id']]; @@ -3303,7 +3409,7 @@ function views_ui_edit_display_form_validate($form, &$form_state) { } /** - * Submit handler for views_ui_edit_display_form + * Submit handler for views_ui_edit_display_form. */ function views_ui_edit_display_form_submit($form, &$form_state) { $display = &$form_state['view']->display[$form_state['display_id']]; @@ -3313,9 +3419,9 @@ function views_ui_edit_display_form_submit($form, &$form_state) { } /** - * Override handler for views_ui_edit_display_form + * Override handler for views_ui_edit_display_form. * - * @TODO: Not currently used. Remove unless we implement an override toggle. + * @todo: Not currently used. Remove unless we implement an override toggle. */ function views_ui_edit_display_form_override($form, &$form_state) { $display = &$form_state['view']->display[$form_state['display_id']]; @@ -3363,13 +3469,13 @@ function views_ui_config_type_form($form, &$form_state) { } /** - * Submit handler for type configuration form + * Submit handler for type configuration form. */ function views_ui_config_type_form_submit($form, &$form_state) { $types = views_object_types(); $display = &$form_state['view']->display[$form_state['display_id']]; - // Store in cache + // Store in cache. views_ui_cache_set($form_state['view']); } @@ -3396,7 +3502,7 @@ function views_ui_rearrange_form($form, &$form_state) { $count = 0; - // Get relationship labels + // Get relationship labels. $relationships = array(); foreach ($display->handler->get_handlers('relationship') as $id => $handler) { $relationships[$id] = $handler->label(); @@ -3409,7 +3515,7 @@ function views_ui_rearrange_form($form, &$form_state) { } } - // Filters can now be grouped so we do a little bit extra: + // Filters can now be grouped so we do a little bit extra. $groups = array(); $grouping = FALSE; if ($type == 'filter') { @@ -3448,7 +3554,7 @@ function views_ui_rearrange_form($form, &$form_state) { ); } - // Add javascript settings that will be added via $.extend for tabledragging + // Add JavaScript settings that will be added via $.extend for tabledragging. $form['#js']['tableDrag']['arrange']['weight'][0] = array( 'target' => 'weight', 'source' => NULL, @@ -3468,7 +3574,7 @@ function views_ui_rearrange_form($form, &$form_state) { } /** - * Turn the rearrange form into a proper table + * Turn the rearrange form into a proper table. */ function theme_views_ui_rearrange_form($variables) { $form = $variables['form']; @@ -3524,7 +3630,7 @@ function theme_views_ui_expose_filter_form($variables) { $output .= '
    '; } - // Only output the right column markup if there's a left column to begin with + // Only output the right column markup if there's a left column to begin with. if (!empty($form['operator']['#type'])) { $output .= '
    '; $output .= drupal_render_children($form); @@ -3539,7 +3645,7 @@ function theme_views_ui_expose_filter_form($variables) { return $output; } - /** +/** * Theme the build group filter form. */ function theme_views_ui_build_group_filter_form($variables) { @@ -3567,7 +3673,6 @@ function theme_views_ui_build_group_filter_form($variables) { $output .= drupal_render($form['description']); $output .= '
    '; - $header = array( t('Default'), t('Weight'), @@ -3581,7 +3686,8 @@ function theme_views_ui_build_group_filter_form($variables) { $form['default_group_multiple'] = form_process_checkboxes($form['default_group_multiple']); $form['default_group']['All']['#title'] = ''; - drupal_render($form['default_group_multiple']['All']); // Don't render + drupal_render($form['default_group_multiple']['All']); + // Don't render. $rows[] = array( drupal_render($form['default_group']['All']), '', @@ -3600,7 +3706,7 @@ function theme_views_ui_build_group_filter_form($variables) { 'title' => drupal_render($form['group_items'][$group_id]['title']), 'operator' => drupal_render($form['group_items'][$group_id]['operator']), 'value' => drupal_render($form['group_items'][$group_id]['value']), - 'remove' => drupal_render($form['group_items'][$group_id]['remove']) . l('' . t('Remove') . '', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $group_id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => true)), + 'remove' => drupal_render($form['group_items'][$group_id]['remove']) . l('' . t('Remove') . '', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $group_id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => TRUE)), ); $rows[] = array('data' => $data, 'id' => 'views-row-' . $group_id, 'class' => array('draggable')); } @@ -3612,7 +3718,7 @@ function theme_views_ui_build_group_filter_form($variables) { /** - * Submit handler for rearranging form + * Submit handler for rearranging form. */ function views_ui_rearrange_form_submit($form, &$form_state) { $types = views_object_types(); @@ -3621,7 +3727,7 @@ function views_ui_rearrange_form_submit($form, &$form_state) { $old_fields = $display->handler->get_option($types[$form_state['type']]['plural']); $new_fields = $order = array(); - // Make an array with the weights + // Make an array with the weights. foreach ($form_state['values'] as $field => $info) { // add each value that is a field with a weight to our list, but only if // it has had its 'removed' checkbox checked. @@ -3630,7 +3736,7 @@ function views_ui_rearrange_form_submit($form, &$form_state) { } } - // Sort the array + // Sort the array. asort($order); // Create a new list of fields in the new order. @@ -3639,7 +3745,7 @@ function views_ui_rearrange_form_submit($form, &$form_state) { } $display->handler->set_option($types[$form_state['type']]['plural'], $new_fields); - // Store in cache + // Store in cache. views_ui_cache_set($form_state['view']); } @@ -3675,7 +3781,7 @@ function views_ui_rearrange_filter_form($form, &$form_state) { } $count = 0; - // Get relationship labels + // Get relationship labels. $relationships = array(); foreach ($display->handler->get_handlers('relationship') as $id => $handler) { $relationships[$id] = $handler->label(); @@ -3698,7 +3804,7 @@ function views_ui_rearrange_filter_form($form, &$form_state) { $form['filter_groups']['#tree'] = TRUE; $form['filter_groups']['operator'] = array( '#type' => 'select', - '#options' => array ( + '#options' => array( 'AND' => t('And'), 'OR' => t('Or'), ), @@ -3727,7 +3833,8 @@ function views_ui_rearrange_filter_form($form, &$form_state) { ), ); - $form['remove_groups'][$id] = array(); // to prevent a notice + $form['remove_groups'][$id] = array(); + // to prevent a notice. if ($id != 1) { $form['remove_groups'][$id] = array( '#type' => 'submit', @@ -3759,9 +3866,8 @@ function views_ui_rearrange_filter_form($form, &$form_state) { $field['group'] = 'ungroupable'; } - // If not grouping and the handler is set ungroupable, move it back to - // the default group to prevent weird errors from having it be in its - // own group: + // If not grouping and the handler is set ungroupable, move it back to the + // default group to prevent weird errors from having it be in its own group. if (!$grouping && $field['group'] == 'ungroupable') { $field['group'] = 1; } @@ -3821,7 +3927,7 @@ function views_ui_rearrange_filter_form($form, &$form_state) { } /** - * Turn the rearrange form into a proper table + * Turn the rearrange form into a proper table. */ function theme_views_ui_rearrange_filter_form(&$vars) { $form = $vars['form']; @@ -3867,7 +3973,7 @@ function theme_views_ui_rearrange_filter_form(&$vars) { $form['filters'][$id]['group']['#attributes']['class'] = array('views-group-select views-group-select-' . $group_id); $row[] = drupal_render($form['filters'][$id]['group']); $form['filters'][$id]['removed']['#attributes']['class'][] = 'js-hide'; - $row[] = drupal_render($form['filters'][$id]['removed']) . l('' . t('Remove') . '', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => true)); + $row[] = drupal_render($form['filters'][$id]['removed']) . l('' . t('Remove') . '', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => TRUE)); $row = array('data' => $row, 'class' => array('draggable'), 'id' => 'views-row-' . $id); if ($group_id !== 'ungroupable') { @@ -3914,7 +4020,7 @@ function theme_views_ui_rearrange_filter_form(&$vars) { } /** - * Submit handler for rearranging form + * Submit handler for rearranging form. */ function views_ui_rearrange_filter_form_submit($form, &$form_state) { $types = views_object_types(); @@ -3933,7 +4039,7 @@ function views_ui_rearrange_filter_form_submit($form, &$form_state) { // Whatever button was clicked, re-calculate field information. $new_fields = $order = array(); - // Make an array with the weights + // Make an array with the weights. foreach ($form_state['values']['filters'] as $field => $info) { // add each value that is a field with a weight to our list, but only if // it has had its 'removed' checkbox checked. @@ -3949,7 +4055,7 @@ function views_ui_rearrange_filter_form_submit($form, &$form_state) { } } - // Sort the array + // Sort the array. asort($order); // Create a new list of fields in the new order. @@ -3961,7 +4067,7 @@ function views_ui_rearrange_filter_form_submit($form, &$form_state) { // either adding or removing a group, not actually updating the filters. if (!empty($form_state['clicked_button']['#group'])) { if ($form_state['clicked_button']['#group'] == 'add') { - // Add a new group + // Add a new group. $groups['groups'][] = 'AND'; } else { @@ -4053,11 +4159,11 @@ function views_ui_add_item_form($form, &$form_state) { $form['#title'] = t('Add @type', array('@type' => $ltitle)); $form['#section'] = $display_id . 'add-item'; - // Add the display override dropdown. views_ui_standard_display_dropdown($form, $form_state, $section); - // Figure out all the base tables allowed based upon what the relationships provide. + // Figure out all the base tables allowed based upon what the relationships + // provide. $base_tables = $view->get_base_tables(); $options = views_fetch_fields(array_keys($base_tables), $type, $display->handler->use_group_by()); @@ -4134,10 +4240,10 @@ function views_ui_add_item_form($form, &$form_state) { } else { $form['options']['markup'] = array( - '#markup' => '
    ' . t('There are no @types available to add.', array('@types' => $ltitle)) . '
    ', + '#markup' => '
    ' . t('There are no @types available to add.', array('@types' => $ltitle)) . '
    ', ); } - // Add a div to show the selected items + // Add a div to show the selected items. $form['selected'] = array( '#type' => 'item', '#markup' => '
    ', @@ -4183,7 +4289,8 @@ function views_ui_add_item_form_submit($form, &$form_state) { } if (!empty($form_state['values']['name']) && is_array($form_state['values']['name'])) { - // Loop through each of the items that were checked and add them to the view. + // Loop through each of the items that were checked and add them to the + // view. foreach (array_keys(array_filter($form_state['values']['name'])) as $field) { list($table, $field) = explode('.', $field, 2); @@ -4192,9 +4299,10 @@ function views_ui_add_item_form_submit($form, &$form_state) { } $id = $form_state['view']->add_item($form_state['display_id'], $type, $table, $field); - // check to see if we have group by settings + // Check to see if we have group by settings. $key = $type; - // Footer,header and empty text have a different internal handler type(area). + // Footer,header and empty text have a different internal handler type + // (area). if (isset($types[$type]['type'])) { $key = $types[$type]['type']; } @@ -4203,11 +4311,12 @@ function views_ui_add_item_form_submit($form, &$form_state) { views_ui_add_form_to_stack('config-item-group', $form_state['view'], $form_state['display_id'], array($type, $id)); } - // check to see if this type has settings, if so add the settings form first + // Check to see if this type has settings, if so add the settings form + // first. if ($handler && $handler->has_extra_options()) { views_ui_add_form_to_stack('config-item-extra', $form_state['view'], $form_state['display_id'], array($type, $id)); } - // Then add the form to the stack + // Then add the form to the stack. views_ui_add_form_to_stack('config-item', $form_state['view'], $form_state['display_id'], array($type, $id)); } } @@ -4216,19 +4325,19 @@ function views_ui_add_item_form_submit($form, &$form_state) { unset($form_state['view']->form_cache); } - // Store in cache + // Store in cache. views_ui_cache_set($form_state['view']); } /** - * Override handler for views_ui_edit_display_form + * Override handler for views_ui_edit_display_form. */ function views_ui_config_item_form_build_group($form, &$form_state) { $item = &$form_state['handler']->options; // flip. If the filter was a group, set back to a standard filter. $item['is_grouped'] = empty($item['is_grouped']); - // If necessary, set new defaults: + // If necessary, set new defaults. if ($item['is_grouped']) { $form_state['handler']->build_group_options(); } @@ -4302,13 +4411,13 @@ function views_ui_config_item_form($form, &$form_state) { $relationship_options = array(); foreach ($relationships as $relationship) { - // relationships can't link back to self. But also, due to ordering, + // Relationships can't link back to self. But also, due to ordering, // relationships can only link to prior relationships. if ($type == 'relationship' && $id == $relationship['id']) { break; } $relationship_handler = views_get_handler($relationship['table'], $relationship['field'], 'relationship'); - // ignore invalid/broken relationships. + // Ignore invalid/broken relationships. if (empty($relationship_handler)) { continue; } @@ -4432,7 +4541,6 @@ function views_ui_config_item_form_submit_temporary($form, &$form_state) { $handler = views_get_handler($item['table'], $item['field'], $handler_type, $override); $handler->init($form_state['view'], $item); - // Add the incoming options to existing options because items using // the extra form may not have everything in the form here. $options = $form_state['values']['options'] + $form_state['handler']->options; @@ -4441,17 +4549,17 @@ function views_ui_config_item_form_submit_temporary($form, &$form_state) { // extra stuff on the form is not sent through. $handler->unpack_options($handler->options, $options, NULL, FALSE); - // Store the item back on the view + // Store the item back on the view. $form_state['view']->temporary_options[$type][$form_state['id']] = $handler->options; - // @todo: Figure out whether views_ui_ajax_form is perhaps the better place to fix the issue. - // views_ui_ajax_form() drops the current form from the stack, even if it's an #ajax. - // So add the item back to the top of the stack. + // @todo: Figure out whether views_ui_ajax_form is perhaps the better place + // to fix the issue. views_ui_ajax_form() drops the current form from the + // stack, even if it's an #ajax. So add the item back to the top of the stack. views_ui_add_form_to_stack($form_state['form_key'], $form_state['view'], $form_state['display_id'], array($type, $item['id']), TRUE); $form_state['rerender'] = TRUE; $form_state['rebuild'] = TRUE; - // Write to cache + // Write to cache. views_ui_cache_set($form_state['view']); } @@ -4487,7 +4595,6 @@ function views_ui_config_item_form_submit($form, &$form_state) { $handler = views_get_handler($item['table'], $item['field'], $handler_type, $override); $handler->init($form_state['view'], $item); - // Add the incoming options to existing options because items using // the extra form may not have everything in the form here. $options = $form_state['values']['options'] + $form_state['handler']->options; @@ -4496,7 +4603,7 @@ function views_ui_config_item_form_submit($form, &$form_state) { // extra stuff on the form is not sent through. $handler->unpack_options($handler->options, $options, NULL, FALSE); - // Store the item back on the view + // Store the item back on the view. $form_state['view']->set_item($form_state['display_id'], $form_state['type'], $form_state['id'], $handler->options); // Ensure any temporary options are removed. @@ -4504,7 +4611,7 @@ function views_ui_config_item_form_submit($form, &$form_state) { unset($form_state['view']->temporary_options[$type][$form_state['id']]); } - // Write to cache + // Write to cache. views_ui_cache_set($form_state['view']); } @@ -4565,18 +4672,18 @@ function views_ui_config_item_group_form_submit($form, &$form_state) { $handler->groupby_form_submit($form, $form_state); - // Store the item back on the view + // Store the item back on the view. $form_state['view']->set_item($form_state['display_id'], $form_state['type'], $form_state['id'], $item); - // Write to cache + // Write to cache. views_ui_cache_set($form_state['view']); } /** - * Submit handler for removing an item from a view + * Submit handler for removing an item from a view. */ function views_ui_config_item_form_remove($form, &$form_state) { - // Store the item back on the view + // Store the item back on the view. list($was_defaulted, $is_defaulted) = views_ui_standard_override_values($form, $form_state); // If the display selection was changed toggle the override value. if ($was_defaulted != $is_defaulted) { @@ -4585,19 +4692,19 @@ function views_ui_config_item_form_remove($form, &$form_state) { } $form_state['view']->set_item($form_state['display_id'], $form_state['type'], $form_state['id'], NULL); - // Write to cache + // Write to cache. views_ui_cache_set($form_state['view']); } /** - * Override handler for views_ui_edit_display_form + * Override handler for views_ui_edit_display_form. */ function views_ui_config_item_form_expose($form, &$form_state) { $item = &$form_state['handler']->options; - // flip + // flip. $item['exposed'] = empty($item['exposed']); - // If necessary, set new defaults: + // If necessary, set new defaults. if ($item['exposed']) { $form_state['handler']->expose_options(); } @@ -4676,10 +4783,10 @@ function views_ui_config_item_extra_form_submit($form, &$form_state) { $item[$key] = $value; } - // Store the item back on the view + // Store the item back on the view. $form_state['view']->set_item($form_state['display_id'], $form_state['type'], $form_state['id'], $item); - // Write to cache + // Write to cache. views_ui_cache_set($form_state['view']); } @@ -4746,10 +4853,10 @@ function views_ui_config_style_form_submit($form, &$form_state) { // Store the data we're given. $item['style_options'] = $form_state['values']['style_options']; - // Store the item back on the view + // Store the item back on the view. $form_state['view']->set_item($form_state['display_id'], $form_state['type'], $form_state['id'], $item); - // Write to cache + // Write to cache. views_ui_cache_set($form_state['view']); } @@ -4824,7 +4931,7 @@ function views_ui_admin_settings_basic() { '#title' => t('Custom admin theme for the Views UI'), '#options' => array('_default' => t('- Use default -')) + $options, '#default_value' => variable_get('views_ui_custom_theme', '_default'), - '#description' => t('In some cases you might want to select a different admin theme for the Views UI.') + '#description' => t('In some cases you might want to select a different admin theme for the Views UI.'), ); $form['basic']['views_exposed_filter_any_label'] = array( @@ -4845,12 +4952,11 @@ function views_ui_admin_settings_basic() { '#default_value' => variable_get('views_ui_always_live_preview', TRUE), ); -// $form['live_preview']['views_ui_always_live_preview_button'] = array( -// '#type' => 'checkbox', -// '#title' => t('Always show the preview button, even when the automatically update option is checked'), -// '#default_value' => variable_get('views_ui_always_live_preview_button', FALSE), -// ); - + // $form['live_preview']['views_ui_always_live_preview_button'] = array( + // '#type' => 'checkbox', + // '#title' => t('Always show the preview button, even when the automatically update option is checked'), + // '#default_value' => variable_get('views_ui_always_live_preview_button', FALSE), + // ); $form['live_preview']['views_ui_show_preview_information'] = array( '#type' => 'checkbox', '#title' => t('Show information and statistics about the view during live preview'), @@ -4891,8 +4997,7 @@ function views_ui_admin_settings_basic() { '#dependency' => array('edit-views-ui-show-preview-information' => array(TRUE)), ); -// $form['live_preview']['views_ui_show_performance_statistics_where'] = array( - + // $form['live_preview']['views_ui_show_performance_statistics_where'] = array( return system_settings_form($form); } @@ -4937,7 +5042,7 @@ function views_ui_admin_settings_advanced() { $form['debug']['views_no_javascript'] = array( '#type' => 'checkbox', '#title' => t('Disable JavaScript with Views'), - '#description' => t("If you are having problems with the JavaScript, you can disable it here. The Views UI should degrade and still be usable without javascript; it's just not as good."), + '#description' => t("If you are having problems with the JavaScript, you can disable it here. The Views UI should degrade and still be usable without JavaScript; it's just not as good."), '#default_value' => variable_get('views_no_javascript', FALSE), ); @@ -4953,7 +5058,7 @@ function views_ui_admin_settings_advanced() { '#title' => t('Localization'), ); - $form['locale']['views_localization_plugin'] = array( + $form['locale']['views_localization_plugin'] = array( '#type' => 'radios', '#title' => t('Translation method'), '#options' => views_fetch_plugin_names('localization', NULL, array()), @@ -4994,7 +5099,7 @@ function views_ui_admin_settings_advanced() { '#default_value' => views_get_enabled_display_extenders(), '#options' => $options, '#type' => 'checkboxes', - '#description' => t('Select extensions of the views interface.') + '#description' => t('Select extensions of the views interface.'), ); } @@ -5021,7 +5126,7 @@ function views_ui_config_item_form_rescan($form, &$form_state) { // function uses an internal cache (which was initialized before we // called drupal_theme_rebuild()) so it won't reflect the // current state of our theme registry. The only way to clear that cache - // is to re-initialize the theme system: + // is to re-initialize the theme system. unset($GLOBALS['theme']); drupal_theme_initialize(); @@ -5030,7 +5135,7 @@ function views_ui_config_item_form_rescan($form, &$form_state) { } /** - * Override handler for views_ui_edit_display_form + * Override handler for views_ui_edit_display_form. */ function views_ui_edit_display_form_change_theme($form, &$form_state) { // This is just a temporary variable. @@ -5042,11 +5147,11 @@ function views_ui_edit_display_form_change_theme($form, &$form_state) { } /** - * Page callback for views tag autocomplete + * Page callback for views tag autocomplete. */ function views_ui_autocomplete_tag($string = '') { $matches = array(); - // get matches from default views: + // Get matches from default views. views_include('view'); $views = views_get_all_views(); foreach ($views as $view) { @@ -5062,8 +5167,7 @@ function views_ui_autocomplete_tag($string = '') { } // ------------------------------------------------------------------ -// Get information from the Views data - +// Get information from the Views data. function _views_weight_sort($a, $b) { if ($a['weight'] != $b['weight']) { return $a['weight'] < $b['weight'] ? -1 : 1; @@ -5076,7 +5180,7 @@ function _views_weight_sort($a, $b) { } /** - * Fetch a list of all base tables available + * Fetch a list of all base tables available. * * @return * A keyed array of in the form of 'base_table' => 'Description'. @@ -5103,6 +5207,9 @@ function views_fetch_base_tables() { return $base_tables; } +/** + * + */ function _views_sort_types($a, $b) { $a_group = drupal_strtolower($a['group']); $b_group = drupal_strtolower($b['group']); @@ -5136,7 +5243,6 @@ function views_fetch_fields($base, $type, $grouping = FALSE) { static $fields = array(); if (empty($fields)) { $data = views_fetch_data(); - $start = microtime(TRUE); // This constructs this ginormous multi dimensional array to // collect the important data about fields. In the end, // the structure looks a bit like this (using nid as an example) @@ -5146,13 +5252,18 @@ function views_fetch_fields($base, $type, $grouping = FALSE) { // can appear in different places in the actual data structure so that // the data doesn't have to be repeated a lot. This essentially lets // each field have a cheap kind of inheritance. - + $components = array('title', 'group', 'help', 'base', 'aliases'); + $components_errors = array(); + // Fixed number of calls to t() to produce error components. + foreach ($components as $string) { + $components_errors[$string] = t("Error: missing @component", array('@component' => $string)); + } foreach ($data as $table => $table_data) { $bases = array(); $strings = array(); $skip_bases = array(); foreach ($table_data as $field => $info) { - // Collect table data from this table + // Collect table data from this table. if ($field == 'table') { // calculate what tables this table can join to. if (!empty($info['join'])) { @@ -5181,22 +5292,22 @@ function views_fetch_fields($base, $type, $grouping = FALSE) { if (isset($info[$key]['moved to'])) { continue; } - foreach (array('title', 'group', 'help', 'base', 'aliases') as $string) { - // First, try the lowest possible level + foreach ($components as $string) { + // First, try the lowest possible level. if (!empty($info[$key][$string])) { $strings[$field][$key][$string] = $info[$key][$string]; } - // Then try the field level + // Then try the field level. elseif (!empty($info[$string])) { $strings[$field][$key][$string] = $info[$string]; } - // Finally, try the table level + // Finally, try the table level. elseif (!empty($table_data['table'][$string])) { $strings[$field][$key][$string] = $table_data['table'][$string]; } else { - if ($string != 'base' && $string != 'base') { - $strings[$field][$key][$string] = t("Error: missing @component", array('@component' => $string)); + if ($string != 'base') { + $strings[$field][$key][$string] = $components_errors[$string]; } } } @@ -5213,12 +5324,10 @@ function views_fetch_fields($base, $type, $grouping = FALSE) { } } } -// vsm('Views UI data build time: ' . (views_microtime() - $start) * 1000 . ' ms'); } - // If we have an array of base tables available, go through them - // all and add them together. Duplicate keys will be lost and that's - // Just Fine. + // If we have an array of base tables available, go through them all and add + // them together. Duplicate keys will be lost and that's Just Fine. if (is_array($base)) { $strings = array(); foreach ($base as $base_table) { @@ -5239,7 +5348,7 @@ function views_fetch_fields($base, $type, $grouping = FALSE) { /** - * Theme the form for the table style plugin + * Theme the form for the table style plugin. */ function theme_views_ui_style_plugin_table($variables) { $form = $variables['form']; @@ -5326,6 +5435,9 @@ function views_ui_get_display_label($view, $display_id, $check_changed = TRUE) { return $title; } +/** + * + */ function views_ui_add_template_page() { $templates = views_get_all_templates(); @@ -5353,7 +5465,9 @@ function views_ui_add_template_page() { } /** - * #process callback for a button; determines if a button is the form's triggering element. + * #process callback for a button. + * + * Determines if a button is the form's triggering element. * * The Form API has logic to determine the form's triggering element based on * the data in $_POST. However, it only checks buttons based on a single #value @@ -5376,7 +5490,9 @@ function views_ui_form_button_was_clicked($element, &$form_state) { } /** - * #process callback for a button; makes implicit form submissions trigger as this button. + * #process callback for a button. + * + * Makes implicit form submissions trigger as this button. * * @see Drupal.behaviors.viewsImplicitFormSubmission */ diff --git a/sites/all/modules/views/includes/ajax.inc b/sites/all/modules/views/includes/ajax.inc index 90e4ca9..37eee9c 100644 --- a/sites/all/modules/views/includes/ajax.inc +++ b/sites/all/modules/views/includes/ajax.inc @@ -18,14 +18,15 @@ function views_ajax() { if (isset($_REQUEST['view_name']) && isset($_REQUEST['view_display_id'])) { $name = $_REQUEST['view_name']; $display_id = $_REQUEST['view_display_id']; - $args = isset($_REQUEST['view_args']) && $_REQUEST['view_args'] !== '' ? explode('/', $_REQUEST['view_args']) : array(); - $path = isset($_REQUEST['view_path']) ? rawurldecode($_REQUEST['view_path']) : NULL; + $args = isset($_REQUEST['view_args']) && $_REQUEST['view_args'] !== '' ? explode('/', htmlspecialchars_decode($_REQUEST['view_args'], ENT_QUOTES)) : array(); + $path = isset($_REQUEST['view_path']) ? htmlspecialchars_decode($_REQUEST['view_path'], ENT_QUOTES) : NULL; $dom_id = isset($_REQUEST['view_dom_id']) ? preg_replace('/[^a-zA-Z0-9_-]+/', '-', $_REQUEST['view_dom_id']) : NULL; $pager_element = isset($_REQUEST['pager_element']) ? intval($_REQUEST['pager_element']) : NULL; $commands = array(); - // Remove all of this stuff from $_GET so it doesn't end up in pagers and tablesort URLs. + // Remove all of this stuff from $_GET so it doesn't end up in pagers and + // tablesort URLs. foreach (array('view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', 'ajax_html_ids', 'ajax_page_state') as $key) { if (isset($_GET[$key])) { unset($_GET[$key]); @@ -46,11 +47,11 @@ function views_ajax() { $_GET['q'] = $path; } - // If page parameter is in the $_POST exclude it from $_GET, - // otherwise support views_ajax requests using $_GET. + // If page parameter is in the $_POST exclude it from $_GET, otherwise + // support views_ajax requests using $_GET. $exclude = isset($_POST['page']) ? array('page') : array(); - // Add all $_POST data to $_GET as many things, - // such as tablesorts, exposed filters and paging assume $_GET. + // Add all $_POST data to $_GET as many things, such as tablesorts, + // exposed filters and paging assume $_GET. $_GET = $_POST + drupal_get_query_parameters($_GET, $exclude); // Overwrite the destination. @@ -71,7 +72,8 @@ function views_ajax() { // Reuse the same DOM id so it matches that in Drupal.settings. $view->dom_id = $dom_id; - $commands[] = ajax_command_replace('.view-dom-id-' . $dom_id, $view->preview($display_id, $args)); + // Always return HTML with the same DOM ID that was sent by the browser. + $commands[] = ajax_command_replace('.view-dom-id-' . $dom_id, preg_replace('/view-dom-id-[a-zA-Z0-9_-]+/', 'view-dom-id-' . $view->dom_id, $view->preview($display_id, $args), 1)); } drupal_alter('views_ajax_data', $commands, $view); return array('#type' => 'ajax', '#commands' => $commands); @@ -81,14 +83,14 @@ function views_ajax() { /** * Creates a Drupal AJAX 'viewsSetForm' command. * - * @param $output + * @param string $output * The form to display in the modal. - * @param $title + * @param string $title * The title. - * @param $url + * @param string $url * An optional URL. * - * @return + * @return array * An array suitable for use with the ajax_render() function. */ function views_ajax_command_set_form($output, $title, $url = NULL) { @@ -106,7 +108,7 @@ function views_ajax_command_set_form($output, $title, $url = NULL) { /** * Creates a Drupal AJAX 'viewsDismissForm' command. * - * @return + * @return array * An array suitable for use with the ajax_render() function. */ function views_ajax_command_dismiss_form() { @@ -119,8 +121,8 @@ function views_ajax_command_dismiss_form() { /** * Creates a Drupal AJAX 'viewsHilite' command. * - * @param $selector - * The selector to highlight + * @param string $selector + * The selector to highlight. * * @return * An array suitable for use with the ajax_render() function. @@ -135,14 +137,14 @@ function views_ajax_command_hilite($selector) { /** * Creates a Drupal AJAX 'addTab' command. * - * @param $id + * @param string $id * The DOM ID. - * @param $title + * @param string $title * The title. - * @param $body + * @param string $body * The body. * - * @return + * @return array * An array suitable for use with the ajax_render() function. */ function views_ajax_command_add_tab($id, $title, $body) { @@ -158,7 +160,7 @@ function views_ajax_command_add_tab($id, $title, $body) { /** * Scroll to top of the current view. * - * @return + * @return array * An array suitable for use with the ajax_render() function. */ function views_ajax_command_scroll_top($selector) { @@ -175,7 +177,7 @@ function views_ajax_command_scroll_top($selector) { * @param bool $changed * Whether of not the view has changed. * - * @return + * @return array * An array suitable for use with the ajax_render() function. */ function views_ajax_command_show_buttons($changed) { @@ -189,7 +191,7 @@ function views_ajax_command_show_buttons($changed) { /** * Trigger the Views live preview. * - * @return + * @return array * An array suitable for use with the ajax_render() function. */ function views_ajax_command_trigger_preview() { @@ -202,7 +204,7 @@ function views_ajax_command_trigger_preview() { /** * Replace the page title. * - * @return + * @return array * An array suitable for use with the ajax_render() function. */ function views_ajax_command_replace_title($title) { @@ -216,6 +218,12 @@ function views_ajax_command_replace_title($title) { /** * Return an AJAX error. + * + * @param string $message + * The message to display. + * + * @return array + * An array suitable for use with the ajax_render() function. */ function views_ajax_error($message) { $commands = array(); @@ -225,6 +233,7 @@ function views_ajax_error($message) { /** * Wrapper around drupal_build_form to handle some AJAX stuff automatically. + * * This makes some assumptions about the client. */ function views_ajax_form_wrapper($form_id, &$form_state) { @@ -243,15 +252,15 @@ function views_ajax_form_wrapper($form_id, &$form_state) { $form = drupal_build_form($form_id, $form_state); $output = drupal_render($form); - // These forms have the title built in, so set the title here: + // These forms have the title built in, so set the title here. if (empty($form_state['ajax']) && !empty($form_state['title'])) { drupal_set_title($form_state['title']); drupal_add_css(drupal_get_path('module', 'views_ui') . '/css/views-admin.css'); } if (!empty($form_state['ajax']) && (empty($form_state['executed']) || !empty($form_state['rerender']))) { - // If the form didn't execute and we're using ajax, build up a - // Ajax command list to execute. + // If the form didn't execute and we're using ajax, build up a AJAX command + // list to execute. $commands = array(); $display = ''; @@ -279,7 +288,7 @@ function views_ajax_form_wrapper($form_id, &$form_state) { return $commands; } - // These forms have the title built in, so set the title here: + // These forms have the title built in, so set the title here. if (empty($form_state['ajax']) && !empty($form_state['title'])) { drupal_set_title($form_state['title']); } @@ -289,13 +298,14 @@ function views_ajax_form_wrapper($form_id, &$form_state) { /** - * Page callback for views user autocomplete + * Page callback for views user autocomplete. */ function views_ajax_autocomplete_user($string = '') { - // The user enters a comma-separated list of user name. We only autocomplete the last name. + // The user enters a comma-separated list of user name. We only autocomplete + // the last name. $array = drupal_explode_tags($string); - // Fetch last name + // Fetch last name. $last_string = trim(array_pop($array)); $matches = array(); if ($last_string != '') { @@ -328,16 +338,16 @@ function views_ajax_autocomplete_user($string = '') { /** * Page callback for views taxonomy autocomplete. * - * @param $vid + * @param int $vid * The vocabulary id of the tags which should be returned. - * - * @param $tags_typed + * @param string $tags_typed * The typed string of the user. * * @see taxonomy_autocomplete() */ function views_ajax_autocomplete_taxonomy($vid, $tags_typed = '') { - // The user enters a comma-separated list of tags. We only autocomplete the last tag. + // The user enters a comma-separated list of tags. We only autocomplete the + // last tag. $tags_typed = drupal_explode_tags($tags_typed); $tag_last = drupal_strtolower(array_pop($tags_typed)); diff --git a/sites/all/modules/views/includes/analyze.inc b/sites/all/modules/views/includes/analyze.inc index 68ee334..5dd58de 100644 --- a/sites/all/modules/views/includes/analyze.inc +++ b/sites/all/modules/views/includes/analyze.inc @@ -16,8 +16,8 @@ * Analyze a review and return the results. * * @return - * An array of analyze results organized into arrays keyed by 'ok', - * 'warning' and 'error'. + * An array of analyze results organized into arrays keyed by 'ok', 'warning' + * and 'error'. */ function views_analyze_view(&$view) { $view->init_display(); @@ -79,12 +79,12 @@ function views_analyze_format_result($view, $messages) { * that may be broken unless the user knows what he or she is doing, * and 'error' for items that are definitely broken are much more useful. * - * @param $messages + * @param string $message * The message to report. - * @param $type + * @param string $type * The type of message. This should be "ok", "warning" or "error". Other - * values can be used but how they are treated by the output routine - * is undefined. + * values can be used but how they are treated by the output routine is + * undefined. */ function views_ui_analysis($message, $type = 'error') { return array('message' => $message, 'type' => $type); @@ -99,7 +99,7 @@ function views_ui_analysis($message, $type = 'error') { */ function views_ui_views_analyze($view) { $ret = array(); - // Check for something other than the default display: + // Check for something other than the default display. if (count($view->display) < 2) { $ret[] = views_ui_analysis(t('This view has only a default display and therefore will not be placed anywhere on your site; perhaps you want to add a page or a block display.'), 'warning'); } diff --git a/sites/all/modules/views/includes/base.inc b/sites/all/modules/views/includes/base.inc index 2d2ceb5..b2c8622 100644 --- a/sites/all/modules/views/includes/base.inc +++ b/sites/all/modules/views/includes/base.inc @@ -2,34 +2,36 @@ /** * @file - * Provides the basic object definitions used by plugins and handlers. + * Definition of views_object. */ /** - * Basic definition for many views objects. + * Provides the basic object definitions used by plugins and handlers. */ class views_object { + /** * Except for displays, options for the object will be held here. */ - var $options = array(); + public $options = array(); /** * The top object of a view. * * @var view */ - var $view = NULL; + public $view = NULL; /** - * Handler's definition + * Handler's definition. * * @var array */ - var $definition; + public $definition; /** * Information about options for all kinds of purposes will be held here. + * * @code * 'option_name' => array( * - 'default' => default value, @@ -52,35 +54,69 @@ class views_object { * @see views_object::export_option_always() * @see views_object::unpack_translatable() */ - function option_definition() { return array(); } + public function option_definition() { + return array(); + } /** - * Views handlers use a special construct function so that we can more - * easily construct them with variable arguments. + * Collect this handler's option definition and alter them, ready for use. + * + * @return array + * Returns the options of this handler/plugin after allowing for alters. + * + * @see hook_views_plugin_option_definition_alter() + * @see hook_views_handler_option_definition_alter() */ - function construct() { $this->set_default_options(); } + function altered_option_definition() { + $definition = $this->option_definition(); + if (!empty($this->is_plugin)) { + // Trigger hook_views_plugin_option_definition_alter(). + drupal_alter('views_plugin_option_definition', $definition, $this); + } + else { + // Trigger hook_views_handler_option_definition_alter(). + drupal_alter('views_handler_option_definition', $definition, $this); + } + return $definition; + } /** - * Set default options on this object. Called by the constructor in a - * complex chain to deal with backward compatibility. + * Views handlers use a special construct function. + * + * Allows it to more easily construct them with variable arguments. + */ + public function construct() { + $this->set_default_options(); + } + + /** + * Set default options on this object. + * + * Called by the constructor in a complex chain to deal with backward + * compatibility. * * @deprecated since views2 */ - function options(&$options) { } + public function options(&$options) { + } /** * Set default options. - * For backward compatibility, it sends the options array; this is a - * feature that will likely disappear at some point. + * + * For backward compatibility, it sends the options array; this is a feature + * that will likely disappear at some point. */ - function set_default_options() { - $this->_set_option_defaults($this->options, $this->option_definition()); + public function set_default_options() { + $this->_set_option_defaults($this->options, $this->altered_option_definition()); // Retained for complex defaults plus backward compatibility. $this->options($this->options); } - function _set_option_defaults(&$storage, $options, $level = 0) { + /** + * + */ + public function _set_option_defaults(&$storage, $options, $level = 0) { foreach ($options as $option => $definition) { if (isset($definition['contains']) && is_array($definition['contains'])) { $storage[$option] = array(); @@ -96,28 +132,28 @@ class views_object { } /** - * Unpack options over our existing defaults, drilling down into arrays - * so that defaults don't get totally blown away. + * Unpack options over our existing defaults, drilling down into arrays so + * that defaults don't get totally blown away. */ - function unpack_options(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE, $localization_keys = array()) { + public function unpack_options(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE, $localization_keys = array()) { if ($check && !is_array($options)) { return; } if (!isset($definition)) { - $definition = $this->option_definition(); + $definition = $this->altered_option_definition(); } if (!empty($this->view)) { // Ensure we have a localization plugin. $this->view->init_localization(); - // Set up default localization keys. Handlers and such set this for us + // Set up default localization keys. Handlers and such set this for us. if (empty($localization_keys) && isset($this->localization_keys)) { $localization_keys = $this->localization_keys; } // but plugins don't because there isn't a common init() these days. - else if (!empty($this->is_plugin) && empty($localization_keys)) { + elseif (!empty($this->is_plugin) && empty($localization_keys)) { if ($this->plugin_type != 'display') { $localization_keys = array($this->view->current_display); $localization_keys[] = $this->plugin_type; @@ -146,9 +182,9 @@ class views_object { $this->unpack_options($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : array(), $all, FALSE, array_merge($localization_keys, array($key))); } - // Don't localize strings during editing. When editing, we need to work with - // the original data, not the translated version. - else if (empty($this->view->editing) && !empty($definition[$key]['translatable']) && !empty($value) || !empty($definition['contains'][$key]['translatable']) && !empty($value)) { + // Don't localize strings during editing. When editing, we need to work + // with the original data, not the translated version. + elseif (empty($this->view->editing) && !empty($definition[$key]['translatable']) && !empty($value) || !empty($definition['contains'][$key]['translatable']) && !empty($value)) { if (!empty($this->view) && $this->view->is_translatable()) { // Allow other modules to make changes to the string before it's // sent for translation. @@ -170,7 +206,7 @@ class views_object { $storage[$key] = t($value); } } - else if ($all || !empty($definition[$key])) { + elseif ($all || !empty($definition[$key])) { $storage[$key] = $value; } } @@ -179,14 +215,17 @@ class views_object { /** * Let the handler know what its full definition is. */ - function set_definition($definition) { + public function set_definition($definition) { $this->definition = $definition; if (isset($definition['field'])) { $this->real_field = $definition['field']; } } - function destroy() { + /** + * Destructor. + */ + public function destroy() { if (isset($this->view)) { unset($this->view); } @@ -200,16 +239,22 @@ class views_object { } } - function export_options($indent, $prefix) { + /** + * + */ + public function export_options($indent, $prefix) { $output = ''; - foreach ($this->option_definition() as $option => $definition) { + foreach ($this->altered_option_definition() as $option => $definition) { $output .= $this->export_option($indent, $prefix, $this->options, $option, $definition, array()); } return $output; } - function export_option($indent, $prefix, $storage, $option, $definition, $parents) { + /** + * + */ + public function export_option($indent, $prefix, $storage, $option, $definition, $parents) { // Do not export options for which we have no settings. if (!isset($storage[$option])) { return; @@ -220,7 +265,7 @@ class views_object { return; } - // Special handling for some items + // Special handling for some items. if (method_exists($this, $definition['export'])) { return $this->{$definition['export']}($indent, $prefix, $storage, $option, $definition, $parents); } @@ -262,7 +307,7 @@ class views_object { /** * Always exports the option, regardless of the default value. */ - function export_option_always($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_option_always($indent, $prefix, $storage, $option, $definition, $parents) { // If there is no default, the option will always be exported. unset($definition['default']); // Unset our export method to prevent recursion. @@ -273,8 +318,8 @@ class views_object { /** * Unpacks each handler to store translatable texts. */ - function unpack_translatables(&$translatable, $parents = array()) { - foreach ($this->option_definition() as $option => $definition) { + public function unpack_translatables(&$translatable, $parents = array()) { + foreach ($this->altered_option_definition() as $option => $definition) { $this->unpack_translatable($translatable, $this->options, $option, $definition, $parents, array()); } } @@ -284,21 +329,21 @@ class views_object { * * This function run's through all suboptions recursive. * - * @param $translatable + * @param array $translatable * Stores all available translatable items. - * @param $storage - * @param $option - * @param $definition - * @param $parents - * @param $keys + * @param array $storage + * @param string $option + * @param string $definition + * @param array $parents + * @param array $keys */ - function unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array()) { + public function unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array()) { // Do not export options for which we have no settings. if (!isset($storage[$option])) { return; } - // Special handling for some items + // Special handling for some items. if (isset($definition['unpack_translatable']) && method_exists($this, $definition['unpack_translatable'])) { return $this->{$definition['unpack_translatable']}($translatable, $storage, $option, $definition, $parents, $keys); } @@ -328,8 +373,8 @@ class views_object { if (is_array($value)) { $this->unpack_translatable($translatable, $options, $key, $definition, $parents, $translation_keys); } - else if (!empty($definition[$key]['translatable']) && !empty($value)) { - // Build source data and add to the array + elseif (!empty($definition[$key]['translatable']) && !empty($value)) { + // Build source data and add to the array. $format = NULL; if (isset($definition['format_key']) && isset($options[$definition['format_key']])) { $format = $options[$definition['format_key']]; @@ -342,9 +387,9 @@ class views_object { } } } - else if (!empty($definition['translatable']) && !empty($options)) { + elseif (!empty($definition['translatable']) && !empty($options)) { $value = $options; - // Build source data and add to the array + // Build source data and add to the array. $format = NULL; if (isset($definition['format_key']) && isset($storage[$definition['format_key']])) { $format = $storage[$definition['format_key']]; @@ -356,4 +401,5 @@ class views_object { ); } } + } diff --git a/sites/all/modules/views/includes/cache.inc b/sites/all/modules/views/includes/cache.inc index b836db4..6ef36df 100644 --- a/sites/all/modules/views/includes/cache.inc +++ b/sites/all/modules/views/includes/cache.inc @@ -6,11 +6,13 @@ */ /** - * Fetch Views' data from the cache + * Fetch Views' data from the cache. * - * @param $move - * Under certain circumstances it makes sense to not get the moved table, but the old one. - * One example is views_get_handler. + * @param string $table + * @param bool $move + * Under certain circumstances it makes sense to not get the moved table, but + * the old one. One example is views_get_handler. + * @param bool $reset */ function _views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) { $cache = &drupal_static(__FUNCTION__ . '_cache'); @@ -100,7 +102,8 @@ function _views_fetch_data_build() { } /** - * Links tables having an 'entity type' specified to the respective generic entity-type tables. + * Links tables having an 'entity type' specified to the respective generic + * entity-type tables. */ function _views_data_process_entity_types(&$data) { foreach ($data as $table_name => $table_info) { @@ -151,7 +154,7 @@ function _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE) return $cache; } elseif (!$plugin) { - // Not in the if above so the else below won't run + // Not in the if above so the else below won't run. if (isset($cache[$type])) { return $cache[$type]; } @@ -169,12 +172,13 @@ function _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE) * * This is just a convenience wrapper around cache_set(). * - * @param $cid + * @param string $cid * The cache ID of the data to store. - * @param $data - * The data to store in the cache. Complex data types will be automatically serialized before insertion. - * Strings will be stored as plain text and not serialized. - * @param $use_language + * @param mixed $data + * The data to store in the cache. Complex data types will be automatically + * serialized before insertion. Strings will be stored as plain text and not + * serialized. + * @param bool $use_language * If TRUE, the data will be cached specific to the currently active language. */ function views_cache_set($cid, $data, $use_language = FALSE) { @@ -198,7 +202,8 @@ function views_cache_set($cid, $data, $use_language = FALSE) { * @param int $cid * The cache ID of the data to retrieve. * @param bool $use_language - * If TRUE, the data will be requested specific to the currently active language. + * If TRUE, the data will be requested specific to the currently active + * language. * * @return stdClass|bool * The cache or FALSE on failure. diff --git a/sites/all/modules/views/includes/handlers.inc b/sites/all/modules/views/includes/handlers.inc index c8fd3b0..8c2f8ec 100644 --- a/sites/all/modules/views/includes/handlers.inc +++ b/sites/all/modules/views/includes/handlers.inc @@ -6,13 +6,13 @@ */ /** - * Instantiate and construct a new handler + * Instantiate and construct a new handler. */ function _views_create_handler($definition, $type = 'handler', $handler_type = NULL) { -// debug('Instantiating handler ' . $definition['handler']); + // debug('Instantiating handler ' . $definition['handler']); if (empty($definition['handler'])) { vpr('_views_create_handler - type: @type - failed: handler has not been provided.', - array('@type' => isset($handler_type) ? ( $type . '(handler type: ' . $handler_type . ')' ) : $type) + array('@type' => isset($handler_type) ? ($type . '(handler type: ' . $handler_type . ')') : $type) ); return; } @@ -24,8 +24,8 @@ function _views_create_handler($definition, $type = 'handler', $handler_type = N '_views_create_handler - loading override handler @type failed: class @override_handler could not be loaded. ' . 'Verify the class file has been registered in the corresponding .info-file (files[]).', array( - '@type' => isset($handler_type) ? ( $type . '(handler type: ' . $handler_type . ')' ) : $type, - '@override_handler' => $definition['override handler'] + '@type' => isset($handler_type) ? ($type . '(handler type: ' . $handler_type . ')') : $type, + '@override_handler' => $definition['override handler'], ) ); return; @@ -36,19 +36,19 @@ function _views_create_handler($definition, $type = 'handler', $handler_type = N '_views_create_handler - loading handler @type failed: class @handler could not be loaded. ' . 'Verify the class file has been registered in the corresponding .info-file (files[]).', array( - '@type' => isset($handler_type) ? ( $type . '(handler type: ' . $handler_type . ')' ) : $type, - '@handler' => $definition['handler'] + '@type' => isset($handler_type) ? ($type . '(handler type: ' . $handler_type . ')') : $type, + '@handler' => $definition['handler'], ) ); return; } - if (!empty($definition['override handler'])) { - $handler = new $definition['override handler']; - } - else { - $handler = new $definition['handler']; - } + if (!empty($definition['override handler'])) { + $handler = new $definition['override handler']; + } + else { + $handler = new $definition['handler']; + } $handler->set_definition($definition); if ($type == 'handler') { @@ -73,11 +73,11 @@ function _views_create_handler($definition, $type = 'handler', $handler_type = N function _views_prepare_handler($definition, $data, $field, $type) { foreach (array('group', 'title', 'title short', 'help', 'real field') as $key) { if (!isset($definition[$key])) { - // First check the field level + // First check the field level. if (!empty($data[$field][$key])) { $definition[$key] = $data[$field][$key]; } - // Then if that doesn't work, check the table level + // Then if that doesn't work, check the table level. elseif (!empty($data['table'][$key])) { $definition[$key] = $data['table'][$key]; } @@ -88,7 +88,7 @@ function _views_prepare_handler($definition, $data, $field, $type) { } /** - * Fetch a handler to join one table to a primary table from the data cache + * Fetch a handler to join one table to a primary table from the data cache. */ function views_get_table_join($table, $base_table) { $data = views_fetch_data($table); @@ -101,7 +101,7 @@ function views_get_table_join($table, $base_table) { $handler = new views_join(); } - // Fill in some easy defaults + // Fill in some easy defaults. $handler->definition = $h; if (empty($handler->definition['table'])) { $handler->definition['table'] = $table; @@ -121,7 +121,7 @@ function views_get_table_join($table, $base_table) { return $handler; } - // DEBUG -- identify missing handlers + // DEBUG -- identify missing handlers. vpr("Missing join: @table @base_table", array('@table' => $table, '@base_table' => $base_table)); } @@ -147,29 +147,30 @@ function views_get_table_join($table, $base_table) { * field/handler is or does. * - access callback: If this field should have access control, this could * be a function to use. 'user_access' is a common - * function to use here. If not specified, no access + * public function to use here. If not specified, no access * control is provided. * - access arguments: An array of arguments for the access callback. */ class views_handler extends views_object { + /** * The top object of a view. * * @var view */ - var $view = NULL; + public $view = NULL; /** - * Where the $query object will reside: + * Where the $query object will reside:. * * @var views_plugin_query */ - var $query = NULL; + public $query = NULL; /** * The type of the handler, for example filter/footer/field. */ - var $handler_type = NULL; + public $handler_type = NULL; /** * The alias of the table of this handler which is used in the query. @@ -180,28 +181,28 @@ class views_handler extends views_object { * The actual field in the database table, maybe different * on other kind of query plugins/special handlers. */ - var $real_field; + public $real_field; /** * The relationship used for this field. */ - var $relationship = NULL; + public $relationship = NULL; /** - * init the handler with necessary data. - * @param $view + * Init the handler with necessary data. + * + * @param view $view * The $view object this handler is attached to. - * @param $options + * @param array $options * The item from the database; the actual contents of this will vary * based upon the type of handler. */ - function init(&$view, &$options) { + public function init(&$view, &$options) { $this->view = &$view; $display_id = $this->view->current_display; // Check to see if this handler type is defaulted. Note that // we have to do a lookup because the type is singular but the // option is stored as the plural. - // If the 'moved to' keyword moved our handler, let's fix that now. if (isset($this->actual_table)) { $options['table'] = $this->actual_table; @@ -224,7 +225,7 @@ class views_handler extends views_object { $display_id, $this->handler_type, $options['table'], - $options['id'] + $options['id'], ); $this->unpack_options($this->options, $options); @@ -252,7 +253,10 @@ class views_handler extends views_object { $this->query = &$view->query; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['id'] = array('default' => ''); @@ -268,12 +272,15 @@ class views_handler extends views_object { /** * Return a string representing this handler's name in the UI. */ - function ui_name($short = FALSE) { + public function ui_name($short = FALSE) { if (!empty($this->options['ui_name'])) { $title = check_plain($this->options['ui_name']); return $title; } $title = ($short && isset($this->definition['title short'])) ? $this->definition['title short'] : $this->definition['title']; + if (empty($this->definition['group'])) { + return $title; + } return t('!group: !title', array('!group' => $this->definition['group'], '!title' => $title)); } @@ -284,7 +291,7 @@ class views_handler extends views_object { * non-standard fields. Because this takes an argument, fields * overriding this can just call return parent::get_field($formula) */ - function get_field($field = NULL) { + public function get_field($field = NULL) { if (!isset($field)) { if (!empty($this->formula)) { $field = $this->get_formula(); @@ -294,7 +301,8 @@ class views_handler extends views_object { } } - // If grouping, check to see if the aggregation method needs to modify the field. + // If grouping, check to see if the aggregation method needs to modify the + // field. if ($this->view->display_handler->use_group_by()) { $this->view->init_query(); if ($this->query) { @@ -311,25 +319,28 @@ class views_handler extends views_object { /** * Sanitize the value for output. * - * @param $value + * @param string $value * The value being rendered. - * @param $type + * @param string $type * The type of sanitization needed. If not provided, check_plain() is used. * * @return string * Returns the safe value. */ - function sanitize_value($value, $type = NULL) { + public function sanitize_value($value, $type = NULL) { switch ($type) { case 'xss': $value = filter_xss($value); break; + case 'xss_admin': $value = filter_xss_admin($value); break; + case 'url': $value = check_url($value); break; + default: $value = check_plain($value); break; @@ -340,9 +351,9 @@ class views_handler extends views_object { /** * Transform a string by a certain method. * - * @param $string + * @param string $string * The input you want to transform. - * @param $option + * @param array $option * How do you want to transform it, possible values: * - upper: Uppercase the string. * - lower: lowercase the string. @@ -352,7 +363,7 @@ class views_handler extends views_object { * @return string * The transformed string. */ - function case_transform($string, $option) { + public function case_transform($string, $option) { global $multibyte; switch ($option) { @@ -360,10 +371,13 @@ class views_handler extends views_object { return $string; case 'upper': return drupal_strtoupper($string); + case 'lower': return drupal_strtolower($string); + case 'ucfirst': return drupal_strtoupper(drupal_substr($string, 0, 1)) . drupal_substr($string, 1); + case 'ucwords': if ($multibyte == UNICODE_MULTIBYTE) { return mb_convert_case($string, MB_CASE_TITLE); @@ -377,12 +391,13 @@ class views_handler extends views_object { /** * Validate the options form. */ - function options_validate(&$form, &$form_state) { } + public function options_validate(&$form, &$form_state) { + } /** * Build the options form. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { // Some form elements belong in a fieldset for presentation, but can't // be moved into one because of the form_state['values'] hierarchy. Those // elements can add a #fieldset => 'fieldset_name' property, and they'll @@ -406,26 +421,30 @@ class views_handler extends views_object { '#collapsed' => TRUE, '#weight' => 150, ); + // Allow to alter the default values brought into the form. - drupal_alter('views_handler_options', $this->options, $view); + // Triggers hook_views_handler_options_alter(). + drupal_alter('views_handler_options', $this->options, $this); } /** * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { } + public function options_submit(&$form, &$form_state) { + } /** * Provides the handler some groupby. */ - function use_group_by() { + public function use_group_by() { return TRUE; } + /** * Provide a form for aggregation settings. */ - function groupby_form(&$form, &$form_state) { + public function groupby_form(&$form, &$form_state) { $view = &$form_state['view']; $display_id = $form_state['display_id']; $types = views_object_types(); @@ -456,7 +475,7 @@ class views_handler extends views_object { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function groupby_form_submit(&$form, &$form_state) { + public function groupby_form_submit(&$form, &$form_state) { $item =& $form_state['handler']->options; $item['group_type'] = $form_state['values']['options']['group_type']; @@ -466,85 +485,102 @@ class views_handler extends views_object { * If a handler has 'extra options' it will get a little settings widget and * another form called extra_options. */ - function has_extra_options() { return FALSE; } + public function has_extra_options() { + return FALSE; + } /** * Provide defaults for the handler. */ - function extra_options(&$option) { } + public function extra_options(&$option) { + } /** * Provide a form for setting options. */ - function extra_options_form(&$form, &$form_state) { } + public function extra_options_form(&$form, &$form_state) { + } /** * Validate the options form. */ - function extra_options_validate($form, &$form_state) { } + public function extra_options_validate($form, &$form_state) { + } /** * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function extra_options_submit($form, &$form_state) { } + public function extra_options_submit($form, &$form_state) { + } /** * Determine if a handler can be exposed. */ - function can_expose() { return FALSE; } + public function can_expose() { + return FALSE; + } /** * Set new exposed option defaults when exposed setting is flipped * on. */ - function expose_options() { } + public function expose_options() { + } /** * Get information about the exposed form for the form renderer. */ - function exposed_info() { } + public function exposed_info() { + } /** - * Render our chunk of the exposed handler form when selecting + * Render our chunk of the exposed handler form when selecting. */ - function exposed_form(&$form, &$form_state) { } + public function exposed_form(&$form, &$form_state) { + } /** - * Validate the exposed handler form + * Validate the exposed handler form. */ - function exposed_validate(&$form, &$form_state) { } + public function exposed_validate(&$form, &$form_state) { + } /** - * Submit the exposed handler form + * Submit the exposed handler form. */ - function exposed_submit(&$form, &$form_state) { } + public function exposed_submit(&$form, &$form_state) { + } /** * Form for exposed handler options. */ - function expose_form(&$form, &$form_state) { } + public function expose_form(&$form, &$form_state) { + } /** * Validate the options form. */ - function expose_validate($form, &$form_state) { } + public function expose_validate($form, &$form_state) { + } /** * Perform any necessary changes to the form exposes prior to storage. * There is no need for this function to actually store the data. */ - function expose_submit($form, &$form_state) { } + public function expose_submit($form, &$form_state) { + } /** * Shortcut to display the expose/hide button. */ - function show_expose_button(&$form, &$form_state) { } + public function show_expose_button(&$form, &$form_state) { + } /** * Shortcut to display the exposed options form. */ - function show_expose_form(&$form, &$form_state) { + public function show_expose_form(&$form, &$form_state) { if (empty($this->options['exposed'])) { return; } @@ -567,9 +603,9 @@ class views_handler extends views_object { /** * Check whether current user has access to this handler. * - * @return boolean + * @return bool */ - function access() { + public function access() { if (isset($this->definition['access callback']) && function_exists($this->definition['access callback'])) { if (isset($this->definition['access arguments']) && is_array($this->definition['access arguments'])) { return call_user_func_array($this->definition['access callback'], $this->definition['access arguments']); @@ -586,7 +622,8 @@ class views_handler extends views_object { * This gives all the handlers some time to set up before any handler has * been fully run. */ - function pre_query() { } + public function pre_query() { + } /** * Run after the view is executed, before the result is cached. @@ -595,12 +632,13 @@ class views_handler extends views_object { * used so that handlers that pull up secondary data can put it in the * $values so that the raw data can be utilized externally. */ - function post_execute(&$values) { } + public function post_execute(&$values) { + } /** * Provides a unique placeholders for handlers. */ - function placeholder() { + public function placeholder() { return $this->query->placeholder($this->options['table'] . '_' . $this->options['field']); } @@ -608,7 +646,7 @@ class views_handler extends views_object { * Called just prior to query(), this lets a handler set up any relationship * it needs. */ - function set_relationship() { + public function set_relationship() { // Ensure this gets set to something. $this->relationship = NULL; @@ -638,7 +676,7 @@ class views_handler extends views_object { * Ensure the main table for this handler is in the query. This is used * a lot. */ - function ensure_my_table() { + public function ensure_my_table() { if (!isset($this->table_alias)) { if (!method_exists($this->query, 'ensure_table')) { vpr(t('Ensure my table called but query has no ensure_table method.')); @@ -650,48 +688,59 @@ class views_handler extends views_object { } /** - * Provide text for the administrative summary + * Provide text for the administrative summary. */ - function admin_summary() { } + public function admin_summary() { + } /** * Determine if the argument needs a style plugin. * - * @return TRUE/FALSE + * @return bool */ - function needs_style_plugin() { return FALSE; } + public function needs_style_plugin() { + return FALSE; + } /** * Determine if this item is 'exposed', meaning it provides form elements * to let users modify the view. * - * @return TRUE/FALSE + * @return bool */ - function is_exposed() { + public function is_exposed() { return !empty($this->options['exposed']); } /** * Returns TRUE if the exposed filter works like a grouped filter. */ - function is_a_group() { return FALSE; } + public function is_a_group() { + return FALSE; + } /** * Define if the exposed input has to be submitted multiple times. * This is TRUE when exposed filters grouped are using checkboxes as * widgets. */ - function multiple_exposed_input() { return FALSE; } + public function multiple_exposed_input() { + return FALSE; + } /** * Take input from exposed handlers and assign to this handler, if necessary. */ - function accept_exposed_input($input) { return TRUE; } + public function accept_exposed_input($input) { + return TRUE; + } /** * If set to remember exposed input in the session, store it there. */ - function store_exposed_input($input, $status) { return TRUE; } + public function store_exposed_input($input, $status) { + return TRUE; + } /** * Get the join object that should be used for this handler. @@ -700,9 +749,9 @@ class views_handler extends views_object { * getting the join if it is necessary to make some changes to it, such * as adding an 'extra'. */ - function get_join() { + public function get_join() { // get the join from this table that links back to the base table. - // Determine the primary table to seek + // Determine the primary table to seek. if (empty($this->query->relationships[$this->relationship])) { $base_table = $this->query->base_table; } @@ -724,16 +773,25 @@ class views_handler extends views_object { * * @see views_handler::options_validate() * - * @return - * Empty array if the handler is valid; an array of error strings if it is not. + * @return array + * Empty array if the handler is valid; an array of error strings if it is + * not. */ - function validate() { return array(); } + public function validate() { + return array(); + } /** - * Determine if the handler is considered 'broken', meaning it's a - * a placeholder used when a handler can't be found. + * Determine if the handler is considered 'broken'. + * + * Generally only returns TRUE if the handler can't be found. + * + * @return bool + * The handler could not be loaded. */ - function broken() { } + public function broken() { + } + } /** @@ -748,9 +806,9 @@ class views_handler extends views_object { * definition terms: * - numeric: If true, treat this field as numeric, using %d instead of %s in * queries. - * */ class views_many_to_one_helper { + /** * Contains possible existing placeholders used by the query. * @@ -758,15 +816,24 @@ class views_many_to_one_helper { */ public $placeholders = array(); - function __construct(&$handler) { + /** + * {@inheritdoc} + */ + public function __construct(&$handler) { $this->handler = &$handler; } + /** + * {@inheritdoc} + */ static function option_definition(&$options) { $options['reduce_duplicates'] = array('default' => FALSE, 'bool' => TRUE); } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['reduce_duplicates'] = array( '#type' => 'checkbox', '#title' => t('Reduce duplicates'), @@ -777,11 +844,12 @@ class views_many_to_one_helper { } /** - * Sometimes the handler might want us to use some kind of formula, so give - * it that option. If it wants us to do this, it must set $helper->formula = TRUE - * and implement handler->get_formula(); + * Provide an option to use a formula. + * + * If it wants us to do this, it must set $helper->formula = TRUE and + * implement handler->get_formula();. */ - function get_field() { + public function get_field() { if (!empty($this->formula)) { return $this->handler->get_formula(); } @@ -793,12 +861,12 @@ class views_many_to_one_helper { /** * Add a table to the query. * - * This is an advanced concept; not only does it add a new instance of the table, - * but it follows the relationship path all the way down to the relationship - * link point and adds *that* as a new relationship and then adds the table to - * the relationship, if necessary. + * This is an advanced concept; not only does it add a new instance of the + * table, but it follows the relationship path all the way down to the + * relationship link point and adds *that* as a new relationship and then adds + * the table to the relationship, if necessary. */ - function add_table($join = NULL, $alias = NULL) { + public function add_table($join = NULL, $alias = NULL) { // This is used for lookups in the many_to_one table. $field = $this->handler->relationship . '_' . $this->handler->table . '.' . $this->handler->field; @@ -806,11 +874,11 @@ class views_many_to_one_helper { $join = $this->get_join(); } - // See if there's a chain between us and the base relationship. If so, we need - // to create a new relationship to use. + // See if there's a chain between us and the base relationship. If so, we + // need to create a new relationship to use. $relationship = $this->handler->relationship; - // Determine the primary table to seek + // Determine the primary table to seek. if (empty($this->handler->query->relationships[$relationship])) { $base_table = $this->handler->query->base_table; } @@ -821,7 +889,7 @@ class views_many_to_one_helper { // Cycle through the joins. This isn't as error-safe as the normal // ensure_path logic. Perhaps it should be. $r_join = clone $join; - while ($r_join->left_table != $base_table) { + while (!empty($r_join) && $r_join->left_table != $base_table) { $r_join = views_get_table_join($r_join->left_table, $base_table); } // If we found that there are tables in between, add the relationship. @@ -844,19 +912,24 @@ class views_many_to_one_helper { return $alias; } - function get_join() { + /** + * {@inheritdoc} + */ + public function get_join() { return $this->handler->get_join(); } /** - * Provide the proper join for summary queries. This is important in part because - * it will cooperate with other arguments if possible. + * Provide the proper join for summary queries. + * + * This is important in part because it will cooperate with other arguments if + * possible. */ - function summary_join() { + public function summary_join() { $field = $this->handler->relationship . '_' . $this->handler->table . '.' . $this->handler->field; $join = $this->get_join(); - // shortcuts + // Shortcuts. $options = $this->handler->options; $view = &$this->handler->view; $query = &$this->handler->query; @@ -887,16 +960,17 @@ class views_many_to_one_helper { /** * Override ensure_my_table so we can control how this joins in. + * * The operator actually has influence over joining. */ - function ensure_my_table() { + public function ensure_my_table() { if (!isset($this->handler->table_alias)) { // Case 1: Operator is an 'or' and we're not reducing duplicates. - // We hence get the absolute simplest: + // We hence get the absolute simplest. $field = $this->handler->relationship . '_' . $this->handler->table . '.' . $this->handler->field; if ($this->handler->operator == 'or' && empty($this->handler->options['reduce_duplicates'])) { if (empty($this->handler->options['add_table']) && empty($this->handler->view->many_to_one_tables[$field])) { - // query optimization, INNER joins are slightly faster, so use them + // Query optimization, INNER joins are slightly faster, so use them // when we know we can. $join = $this->get_join(); if (isset($join)) { @@ -927,57 +1001,45 @@ class views_many_to_one_helper { return $this->handler->table_alias; } - // Case 2: it's an 'and' or an 'or'. + // Case 2: it's anything but an 'or'. // We do one join per selected value. - if ($this->handler->operator != 'not') { - // Clone the join for each table: - $this->handler->table_aliases = array(); - foreach ($this->handler->value as $value) { - $join = $this->get_join(); - if ($this->handler->operator == 'and') { - $join->type = 'INNER'; - } - $join->extra = array( - array( - 'field' => $this->handler->real_field, - 'value' => $value, - 'numeric' => !empty($this->handler->definition['numeric']), - ), - ); - // The table alias needs to be unique to this value across the - // multiple times the filter or argument is called by the view. - if (!isset($this->handler->view->many_to_one_aliases[$field][$value])) { - if (!isset($this->handler->view->many_to_one_count[$this->handler->table])) { - $this->handler->view->many_to_one_count[$this->handler->table] = 0; - } - $this->handler->view->many_to_one_aliases[$field][$value] = $this->handler->table . '_value_' . ($this->handler->view->many_to_one_count[$this->handler->table]++); + // Clone the join for each table: + $this->handler->table_aliases = array(); + $values = $this->handler->operator === 'not' ? array($this->handler->value) : $this->handler->value; + foreach ($values as $value) { + $join = $this->get_join(); + if ($this->handler->operator == 'and') { + $join->type = 'INNER'; + } + if (empty($join->extra)) { + $join->extra = array(); + } + $join->extra[] = array( + 'field' => $this->handler->real_field, + 'value' => $value, + 'numeric' => !empty($this->handler->definition['numeric']), + ); + if (($this->handler->is_a_group() && is_array($value)) || $this->handler->operator === 'not') { + $value = serialize($value); + } + // The table alias needs to be unique to this value across the + // multiple times the filter or argument is called by the view. + if (!isset($this->handler->view->many_to_one_aliases[$field][$value])) { + if (!isset($this->handler->view->many_to_one_count[$this->handler->table])) { + $this->handler->view->many_to_one_count[$this->handler->table] = 0; } - $alias = $this->handler->table_aliases[$value] = $this->add_table($join, $this->handler->view->many_to_one_aliases[$field][$value]); - + $this->handler->view->many_to_one_aliases[$field][$value] = $this->handler->table . '_value_' . ($this->handler->view->many_to_one_count[$this->handler->table]++); + $alias = $this->handler->table_aliases[$value] = $this->add_table($join, + $this->handler->view->many_to_one_aliases[$field][$value]); // and set table_alias to the first of these. if (empty($this->handler->table_alias)) { $this->handler->table_alias = $alias; } } - } - // Case 3: it's a 'not'. - // We just do one join. We'll add a where clause during - // the query phase to ensure that $table.$field IS NULL. - else { - $join = $this->get_join(); - $join->type = 'LEFT'; - $join->extra = array(); - $join->extra_type = 'OR'; - foreach ($this->handler->value as $value) { - $join->extra[] = array( - 'field' => $this->handler->real_field, - 'value' => $value, - 'numeric' => !empty($this->handler->definition['numeric']), - ); + else { + $this->handler->table_aliases[$value] = $this->handler->view->many_to_one_aliases[$field][$value]; } - - $this->handler->table_alias = $this->add_table($join); } } return $this->handler->table_alias; @@ -986,17 +1048,20 @@ class views_many_to_one_helper { /** * Provides a unique placeholders for handlers. */ - function placeholder() { + public function placeholder() { return $this->handler->query->placeholder($this->handler->options['table'] . '_' . $this->handler->options['field']); } - function add_filter() { + /** + * + */ + public function add_filter() { if (empty($this->handler->value)) { return; } $this->handler->ensure_my_table(); - // Shorten some variables: + // Shorten some variables. $field = $this->get_field(); $options = $this->handler->options; $operator = $this->handler->operator; @@ -1006,21 +1071,21 @@ class views_many_to_one_helper { $options['group'] = 0; } - // add_condition determines whether a single expression is enough(FALSE) or the - // conditions should be added via an db_or()/db_and() (TRUE). + // Determine whether a single expression is enough(FALSE) or the conditions + // should be added via an db_or()/db_and() (TRUE). $add_condition = TRUE; - if ($operator == 'not') { - $value = NULL; - $operator = 'IS NULL'; - $add_condition = FALSE; - } - elseif ($operator == 'or' && empty($options['reduce_duplicates'])) { + if ($operator == 'or' && empty($options['reduce_duplicates'])) { if (count($value) > 1) { $operator = 'IN'; } else { $value = is_array($value) ? array_pop($value) : $value; - $operator = '='; + if (is_array($value) && count($value) > 1) { + $operator = 'IN'; + } + else { + $operator = '='; + } } $add_condition = FALSE; } @@ -1048,25 +1113,28 @@ class views_many_to_one_helper { $field = $this->handler->real_field; $clause = $operator == 'or' ? db_or() : db_and(); foreach ($this->handler->table_aliases as $value => $alias) { + if ($operator == 'not') { + $value = NULL; + } $clause->condition("$alias.$field", $value); } - // implode on either AND or OR. + // Implode on either AND or OR. $this->handler->query->add_where($options['group'], $clause); } } + } /** * Break x,y,z and x+y+z into an array. Works for strings. * - * @param $str + * @param string $str * The string to parse. - * @param $object - * The object to use as a base. If not specified one will - * be created. + * @param object $object + * The object to use as a base. If not specified one will be created. * - * @return $object + * @return object * An object containing * - operator: Either 'and' or 'or' * - value: An array of numeric values. @@ -1076,7 +1144,7 @@ function views_break_phrase_string($str, &$handler = NULL) { $handler = new stdClass(); } - // Set up defaults: + // Set up defaults. if (!isset($handler->value)) { $handler->value = array(); } @@ -1121,11 +1189,10 @@ function views_break_phrase_string($str, &$handler = NULL) { /** * Break x,y,z and x+y+z into an array. Numeric only. * - * @param $str + * @param string $str * The string to parse. - * @param $handler - * The handler object to use as a base. If not specified one will - * be created. + * @param object $handler + * The handler object to use as a base. If not specified one will be created. * * @return $handler * The new handler object. @@ -1135,8 +1202,7 @@ function views_break_phrase($str, &$handler = NULL) { $handler = new stdClass(); } - // Set up defaults: - + // Set up defaults. if (!isset($handler->value)) { $handler->value = array(); } @@ -1174,8 +1240,7 @@ function views_break_phrase($str, &$handler = NULL) { } // -------------------------------------------------------------------------- -// Date helper functions - +// Date helper functions. /** * Figure out what timezone we're in; needed for some date manipulations. */ @@ -1188,7 +1253,7 @@ function views_get_timezone() { $timezone = variable_get('date_default_timezone', 0); } - // set up the database timezone + // Set up the database timezone. $db_type = Database::getConnection()->databaseType(); if (in_array($db_type, array('mysql', 'pgsql'))) { $offset = '+00:00'; @@ -1201,7 +1266,7 @@ function views_get_timezone() { db_query("SET @@session.time_zone = '$offset'"); } - $already_set = true; + $already_set = TRUE; } } @@ -1211,15 +1276,16 @@ function views_get_timezone() { /** * Helper function to create cross-database SQL dates. * - * @param $field + * @param string $field * The real table and field name, like 'tablename.fieldname'. - * @param $field_type + * @param string $field_type * The type of date field, 'int' or 'datetime'. - * @param $set_offset + * @param string $set_offset * The name of a field that holds the timezone offset or a fixed timezone * offset value. If not provided, the normal Drupal timezone handling * will be used, i.e. $set_offset = 0 will make no timezone adjustment. - * @return + * + * @return string * An appropriate SQL string for the db type and field type. */ function views_date_sql_field($field, $field_type = 'int', $set_offset = NULL) { @@ -1237,6 +1303,7 @@ function views_date_sql_field($field, $field_type = 'int', $set_offset = NULL) { case 'int': $field = "DATE_ADD('19700101', INTERVAL $field SECOND)"; break; + case 'datetime': break; } @@ -1244,11 +1311,13 @@ function views_date_sql_field($field, $field_type = 'int', $set_offset = NULL) { $field = "($field + INTERVAL $offset_seconds SECOND)"; } return $field; + case 'pgsql': switch ($field_type) { case 'int': $field = "TO_TIMESTAMP($field)"; break; + case 'datetime': break; } @@ -1256,6 +1325,7 @@ function views_date_sql_field($field, $field_type = 'int', $set_offset = NULL) { $field = "($field + INTERVAL '$offset_seconds SECONDS')"; } return $field; + case 'sqlite': if (!empty($offset)) { $field = "($field + '$offset_seconds')"; @@ -1267,17 +1337,18 @@ function views_date_sql_field($field, $field_type = 'int', $set_offset = NULL) { /** * Helper function to create cross-database SQL date formatting. * - * @param $format + * @param string $format * A format string for the result, like 'Y-m-d H:i:s'. - * @param $field + * @param string $field * The real table and field name, like 'tablename.fieldname'. - * @param $field_type + * @param string $field_type * The type of date field, 'int' or 'datetime'. - * @param $set_offset + * @param string $set_offset * The name of a field that holds the timezone offset or a fixed timezone - * offset value. If not provided, the normal Drupal timezone handling - * will be used, i.e. $set_offset = 0 will make no timezone adjustment. - * @return + * offset value. If not provided, the normal Drupal timezone handling will be + * used, i.e. $set_offset = 0 will make no timezone adjustment. + * + * @return string * An appropriate SQL string for the db type and field type. */ function views_date_sql_format($format, $field, $field_type = 'int', $set_offset = NULL) { @@ -1302,48 +1373,69 @@ function views_date_sql_format($format, $field, $field_type = 'int', $set_offset 'i' => '%i', 's' => '%s', 'A' => '%p', - ); + ); $format = strtr($format, $replace); return "DATE_FORMAT($field, '$format')"; + case 'pgsql': $replace = array( 'Y' => 'YYYY', 'y' => 'YY', 'M' => 'Mon', 'm' => 'MM', - 'n' => 'MM', // no format for Numeric representation of a month, without leading zeros + // No format for Numeric representation of a month, without leading + // zeros. + 'n' => 'MM', 'F' => 'Month', 'D' => 'Dy', 'd' => 'DD', 'l' => 'Day', - 'j' => 'DD', // no format for Day of the month without leading zeros + // No format for Day of the month without leading zeros. + 'j' => 'DD', 'W' => 'WW', 'H' => 'HH24', 'h' => 'HH12', 'i' => 'MI', 's' => 'SS', 'A' => 'AM', - ); + ); $format = strtr($format, $replace); return "TO_CHAR($field, '$format')"; + case 'sqlite': $replace = array( - 'Y' => '%Y', // 4 digit year number - 'y' => '%Y', // no format for 2 digit year number - 'M' => '%m', // no format for 3 letter month name - 'm' => '%m', // month number with leading zeros - 'n' => '%m', // no format for month number without leading zeros - 'F' => '%m', // no format for full month name - 'D' => '%d', // no format for 3 letter day name - 'd' => '%d', // day of month number with leading zeros - 'l' => '%d', // no format for full day name - 'j' => '%d', // no format for day of month number without leading zeros - 'W' => '%W', // ISO week number - 'H' => '%H', // 24 hour hour with leading zeros - 'h' => '%H', // no format for 12 hour hour with leading zeros - 'i' => '%M', // minutes with leading zeros - 's' => '%S', // seconds with leading zeros - 'A' => '', // no format for AM/PM + // 4 digit year number. + 'Y' => '%Y', + // No format for 2 digit year number. + 'y' => '%Y', + // No format for 3 letter month name. + 'M' => '%m', + // Month number with leading zeros. + 'm' => '%m', + // No format for month number without leading zeros. + 'n' => '%m', + // No format for full month name. + 'F' => '%m', + // No format for 3 letter day name. + 'D' => '%d', + // Day of month number with leading zeros. + 'd' => '%d', + // No format for full day name. + 'l' => '%d', + // No format for day of month number without leading zeros. + 'j' => '%d', + // ISO week number. + 'W' => '%W', + // 24 hour hour with leading zeros. + 'H' => '%H', + // No format for 12 hour hour with leading zeros. + 'h' => '%H', + // Minutes with leading zeros. + 'i' => '%M', + // Seconds with leading zeros. + 's' => '%S', + // No format for AM/PM. + 'A' => '', ); $format = strtr($format, $replace); return "strftime('$format', $field, 'unixepoch')"; @@ -1353,17 +1445,18 @@ function views_date_sql_format($format, $field, $field_type = 'int', $set_offset /** * Helper function to create cross-database SQL date extraction. * - * @param $extract_type + * @param string $extract_type * The type of value to extract from the date, like 'MONTH'. - * @param $field + * @param string $field * The real table and field name, like 'tablename.fieldname'. - * @param $field_type + * @param string $field_type * The type of date field, 'int' or 'datetime'. - * @param $set_offset + * @param string $set_offset * The name of a field that holds the timezone offset or a fixed timezone * offset value. If not provided, the normal Drupal timezone handling * will be used, i.e. $set_offset = 0 will make no timezone adjustment. - * @return + * + * @return string * An appropriate SQL string for the db type and field type. */ function views_date_sql_extract($extract_type, $field, $field_type = 'int', $set_offset = NULL) { @@ -1371,46 +1464,58 @@ function views_date_sql_extract($extract_type, $field, $field_type = 'int', $set $field = views_date_sql_field($field, $field_type, $set_offset); // Note there is no space after FROM to avoid db_rewrite problems - // see http://drupal.org/node/79904. + // @see http://drupal.org/node/79904. switch ($extract_type) { - case('DATE'): - return $field; - case('YEAR'): - return "EXTRACT(YEAR FROM($field))"; - case('MONTH'): - return "EXTRACT(MONTH FROM($field))"; - case('DAY'): - return "EXTRACT(DAY FROM($field))"; - case('HOUR'): - return "EXTRACT(HOUR FROM($field))"; - case('MINUTE'): - return "EXTRACT(MINUTE FROM($field))"; - case('SECOND'): - return "EXTRACT(SECOND FROM($field))"; - case('WEEK'): // ISO week number for date - switch ($db_type) { - case('mysql'): - // WEEK using arg 3 in mysql should return the same value as postgres EXTRACT - return "WEEK($field, 3)"; - case('pgsql'): - return "EXTRACT(WEEK FROM($field))"; - } - case('DOW'): - switch ($db_type) { - case('mysql'): - // mysql returns 1 for Sunday through 7 for Saturday - // php date functions and postgres use 0 for Sunday and 6 for Saturday - return "INTEGER(DAYOFWEEK($field) - 1)"; - case('pgsql'): - return "EXTRACT(DOW FROM($field))"; - } - case('DOY'): - switch ($db_type) { - case('mysql'): - return "DAYOFYEAR($field)"; - case('pgsql'): - return "EXTRACT(DOY FROM($field))"; - } + case('DATE'): + return $field; + + case('YEAR'): + return "EXTRACT(YEAR FROM($field))"; + + case('MONTH'): + return "EXTRACT(MONTH FROM($field))"; + + case('DAY'): + return "EXTRACT(DAY FROM($field))"; + + case('HOUR'): + return "EXTRACT(HOUR FROM($field))"; + + case('MINUTE'): + return "EXTRACT(MINUTE FROM($field))"; + + case('SECOND'): + return "EXTRACT(SECOND FROM($field))"; + + case('WEEK'): + // ISO week number for date. + switch ($db_type) { + case('mysql'): + // WEEK using arg 3 in mysql should return the same value as postgres + // EXTRACT. + return "WEEK($field, 3)"; + + case('pgsql'): + return "EXTRACT(WEEK FROM($field))"; + } + case('DOW'): + switch ($db_type) { + // MySQL returns 1 for Sunday through 7 for Saturday. + case('mysql'): + return "INTEGER(DAYOFWEEK($field) - 1)"; + + // PHP date functions and postgres use 0 for Sunday and 6 for Saturday. + case('pgsql'): + return "EXTRACT(DOW FROM($field))"; + } + case('DOY'): + switch ($db_type) { + case('mysql'): + return "DAYOFYEAR($field)"; + + case('pgsql'): + return "EXTRACT(DOY FROM($field))"; + } } } @@ -1430,11 +1535,11 @@ function views_date_sql_extract($extract_type, $field, $field_type = 'int', $set * // PHP 4 doesn't call constructors of the base class automatically from a * // constructor of a derived class. It is your responsibility to propagate * // the call to constructors upstream where appropriate. - * function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') { + * public function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') { * parent::construct($table, $left_table, $left_field, $field, $extra, $type); * } * - * function build_join($select_query, $table, $view_query) { + * public function build_join($select_query, $table, $view_query) { * $this->extra = 'foo.bar = baz.boing'; * parent::build_join($select_query, $table, $view_query); * } @@ -1451,7 +1556,7 @@ function views_date_sql_extract($extract_type, $field, $field_type = 'int', $set * * Extensions of this class can be used to create more interesting joins. * - * join definition + * 'join' definition: * - table: table to join (right table) * - field: field to join on (right field) * - left_table: The table we join to @@ -1464,25 +1569,27 @@ function views_date_sql_extract($extract_type, $field, $field_type = 'int', $set * alias. If you use realtime joins, it works better. * - - field: Field or formula * in formulas we can reference the right table by using %alias - * @see SelectQueryInterface::addJoin() - * - - operator: defaults to = - * - - value: Must be set. If an array, operator will be defaulted to IN. - * - - numeric: If true, the value will not be surrounded in quotes. - * - - extra type: How all the extras will be combined. Either AND or OR. Defaults to AND. + * + * @see SelectQueryInterface::addJoin() + * - operator: Defaults to =. + * - value: Must be set. If an array, operator will be defaulted to IN. + * - numeric: If true, the value will not be surrounded in quotes. + * - extra type: How all the extras will be combined. Either AND or OR. + * Defaults to AND. */ class views_join { - var $table = NULL; - var $left_table = NULL; - var $left_field = NULL; - var $field = NULL; - var $extra = NULL; - var $type = NULL; - var $definition = array(); + public $table = NULL; + public $left_table = NULL; + public $left_field = NULL; + public $field = NULL; + public $extra = NULL; + public $type = NULL; + public $definition = array(); /** * Construct the views_join object. */ - function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') { + public function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') { $this->extra_type = 'AND'; if (!empty($table)) { $this->table = $table; @@ -1493,8 +1600,8 @@ class views_join { $this->type = strtoupper($type); } elseif (!empty($this->definition)) { - // if no arguments, construct from definition. - // These four must exist or it will throw notices. + // If no arguments, construct from definition. These four must exist or + // it will throw notices. $this->table = $this->definition['table']; $this->left_table = $this->definition['left_table']; $this->left_field = $this->definition['left_field']; @@ -1515,14 +1622,14 @@ class views_join { * * When possible, try to use table alias instead of table names. * - * @param $select_query - * An implementation of SelectQueryInterface. - * @param $table + * @param SelectQueryInterface $select_query + * An Implements SelectQueryInterface. + * @param string $table * The base table to join. - * @param $view_query - * The source query, implementation of views_plugin_query. + * @param views_plugin_query $view_query + * The source query, Implements views_plugin_query. */ - function build_join($select_query, $table, $view_query) { + public function build_join($select_query, $table, $view_query) { if (empty($this->definition['table formula'])) { $right_table = $this->table; } @@ -1535,7 +1642,8 @@ class views_join { $left_field = "$left[alias].$this->left_field"; } else { - // This can be used if left_field is a formula or something. It should be used only *very* rarely. + // This can be used if left_field is a formula or something. It should be + // used only *very* rarely. $left_field = $this->left_field; } @@ -1554,8 +1662,8 @@ class views_join { foreach ($this->extra as $info) { if (is_array($info)) { $extra = ''; - // Figure out the table name. Remember, only use aliases provided - // if at all possible. + // Figure out the table name. Remember, only use aliases provided if + // at all possible. $join_table = ''; if (!array_key_exists('table', $info)) { $join_table = $table['alias'] . '.'; @@ -1572,7 +1680,7 @@ class views_join { } // Convert a single-valued array of values to the single-value case, - // and transform from IN() notation to = notation + // and transform from IN() notation to = notation. if (is_array($info['value']) && count($info['value']) == 1) { if (empty($info['operator'])) { $operator = '='; @@ -1584,15 +1692,18 @@ class views_join { } if (is_array($info['value'])) { + $value_placeholders = array(); + // With an array of values, we need multiple placeholders and the // 'IN' operator is implicit. foreach ($info['value'] as $value) { $placeholder_i = $view_query->placeholder('views_join_condition_'); + $value_placeholders[] = $placeholder_i; $arguments[$placeholder_i] = $value; } $operator = !empty($info['operator']) ? $info['operator'] : 'IN'; - $placeholder = '( ' . implode(', ', array_keys($arguments)) . ' )'; + $placeholder = '( ' . implode(', ', $value_placeholders) . ' )'; } else { // With a single value, the '=' operator is implicit. @@ -1609,7 +1720,7 @@ class views_join { if ($extras) { if (count($extras) == 1) { - $condition .= ' AND ' . array_shift($extras); + $condition .= ' AND (' . array_shift($extras) . ')'; } else { $condition .= ' AND (' . implode(' ' . $this->extra_type . ' ', $extras) . ')'; @@ -1623,15 +1734,20 @@ class views_join { /** * Join handler for relationships that join with a subquery as the left field. - * eg: + * + * For example: * LEFT JOIN node node_term_data ON ([YOUR SUBQUERY HERE]) = node_term_data.nid * - * join definition - * same as views_join class above, except: + * 'join' definition: + * Same as views_join class above, except: * - left_query: The subquery to use in the left side of the join clause. */ class views_join_subquery extends views_join { - function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') { + + /** + * {@inheritdoc} + */ + public function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') { parent::construct($table, $left_table, $left_field, $field, $extra, $type); $this->left_query = $this->definition['left_query']; } @@ -1639,16 +1755,14 @@ class views_join_subquery extends views_join { /** * Build the SQL for the join this object represents. * - * @param $select_query - * An implementation of SelectQueryInterface. - * @param $table + * @param object $select_query + * An Implements SelectQueryInterface. + * @param string $table * The base table to join. - * @param $view_query - * The source query, implementation of views_plugin_query. - * @return - * + * @param array $view_query + * The source query, Implements views_plugin_query. */ - function build_join($select_query, $table, $view_query) { + public function build_join($select_query, $table, $view_query) { if (empty($this->definition['table formula'])) { $right_table = "{" . $this->table . "}"; } @@ -1662,7 +1776,8 @@ class views_join_subquery extends views_join { // Tack on the extra. // This is just copied verbatim from the parent class, which itself has a - // bug: http://drupal.org/node/1118100 + // bug. + // @see http://drupal.org/node/1118100 if (isset($this->extra)) { // If extra has been provided as string instead of an array, convert it // to an array. @@ -1674,8 +1789,8 @@ class views_join_subquery extends views_join { foreach ($this->extra as $info) { if (is_array($info)) { $extra = ''; - // Figure out the table name. Remember, only use aliases provided - // if at all possible. + // Figure out the table name. Remember, only use aliases provided if + // at all possible. $join_table = ''; if (!array_key_exists('table', $info)) { $join_table = $table['alias'] . '.'; @@ -1708,7 +1823,7 @@ class views_join_subquery extends views_join { if ($extras) { if (count($extras) == 1) { - $condition .= ' AND ' . array_shift($extras); + $condition .= ' AND (' . array_shift($extras) . ')'; } else { $condition .= ' AND (' . implode(' ' . $this->extra_type . ' ', $extras) . ')'; diff --git a/sites/all/modules/views/includes/plugins.inc b/sites/all/modules/views/includes/plugins.inc index 4b68982..8308e01 100644 --- a/sites/all/modules/views/includes/plugins.inc +++ b/sites/all/modules/views/includes/plugins.inc @@ -5,7 +5,7 @@ * Built in plugins for Views output handling. */ -// @todo: Remove this once update.php can use the registry +// @todo Remove this once update.php can use the registry. views_include('base'); /** @@ -101,7 +101,7 @@ function views_views_plugins() { 'title' => t('Empty display extender'), 'help' => t('Default settings for this view.'), 'handler' => 'views_plugin_display_extender', - // You can force the plugin to be enabled + // You can force the plugin to be enabled. 'enabled' => FALSE, 'no ui' => TRUE, ), @@ -160,7 +160,8 @@ function views_views_plugins() { 'help' => t('Displays the default summary as a list.'), 'handler' => 'views_plugin_style_summary', 'theme' => 'views_view_summary', - 'type' => 'summary', // only shows up as a summary style + 'type' => 'summary', + // only shows up as a summary style. 'uses options' => TRUE, 'help topic' => 'style-summary', ), @@ -169,7 +170,8 @@ function views_views_plugins() { 'help' => t('Displays the summary unformatted, with option for one after another or inline.'), 'handler' => 'views_plugin_style_summary_unformatted', 'theme' => 'views_view_summary_unformatted', - 'type' => 'summary', // only shows up as a summary style + 'type' => 'summary', + // only shows up as a summary style. 'uses options' => TRUE, 'help topic' => 'style-summary-unformatted', ), @@ -266,7 +268,7 @@ function views_views_plugins() { 'views_query' => array( 'title' => t('SQL Query'), 'help' => t('Query will be generated and run using the Drupal database API.'), - 'handler' => 'views_plugin_query_default' + 'handler' => 'views_plugin_query_default', ), ), 'cache' => array( @@ -356,7 +358,7 @@ function views_views_plugins() { 'handler' => 'views_plugin_localization', 'parent' => '', ), - 'none' => array( + 'none' => array( 'title' => t('None'), 'help' => t('Do not pass admin strings for translation.'), 'handler' => 'views_plugin_localization_none', @@ -381,7 +383,8 @@ function views_views_plugins() { 'help' => t('Puts all of the results into a select box and allows the user to go to a different page based upon the results.'), 'handler' => 'views_plugin_style_summary_jump_menu', 'theme' => 'views_view_summary_jump_menu', - 'type' => 'summary', // only shows up as a summary style + 'type' => 'summary', + // only shows up as a summary style. 'uses options' => TRUE, 'help topic' => 'style-summary-jump-menu', ); @@ -417,7 +420,7 @@ function views_discover_plugins() { } $module_dir = isset($result['module']) ? $result['module'] : $module; - // Setup automatic path/file finding for theme registration + // Setup automatic path/file finding for theme registration. if ($module_dir == 'views') { $theme_path = drupal_get_path('module', $module_dir) . '/theme'; $theme_file = 'theme.inc'; @@ -452,7 +455,7 @@ function views_discover_plugins() { // Set the internal name to be able to read it out later. $def['name'] = $plugin; - // merge the new data in + // merge the new data in. $cache[$type][$plugin] = $def; } } @@ -467,29 +470,30 @@ function views_discover_plugins() { * Abstract base class to provide interface common to all plugins. */ class views_plugin extends views_object { + /** * The top object of a view. * * @var view */ - var $view = NULL; + public $view = NULL; /** * The current used views display. * * @var views_display */ - var $display = NULL; + public $display = NULL; /** * The plugin type of this plugin, for example style or query. */ - var $plugin_type = NULL; + public $plugin_type = NULL; /** * The plugin name of this plugin, for example table or full. */ - var $plugin_name = NULL; + public $plugin_name = NULL; /** * Init will be called after construct, when the plugin is attached to a @@ -499,7 +503,7 @@ class views_plugin extends views_object { /** * Provide a form to edit options for this plugin. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { // Some form elements belong in a fieldset for presentation, but can't // be moved into one because of the form_state['values'] hierarchy. Those // elements can add a #fieldset => 'fieldset_name' property, and they'll @@ -510,22 +514,25 @@ class views_plugin extends views_object { /** * Validate the options form. */ - function options_validate(&$form, &$form_state) { } + public function options_validate(&$form, &$form_state) { + } /** * Handle any special handling on the validate form. */ - function options_submit(&$form, &$form_state) { } + public function options_submit(&$form, &$form_state) { + } /** * Add anything to the query that we might need to. */ - function query() { } + public function query() { + } /** * Provide a full list of possible theme templates used by this style. */ - function theme_functions() { + public function theme_functions() { if (empty($this->definition['theme'])) { $this->definition['theme'] = 'views_view'; } @@ -533,9 +540,9 @@ class views_plugin extends views_object { } /** - * Provide a list of additional theme functions for the theme information page + * Provide a list of additional theme functions for the theme info page. */ - function additional_theme_functions() { + public function additional_theme_functions() { $funcs = array(); if (!empty($this->definition['additional themes'])) { foreach ($this->definition['additional themes'] as $theme => $type) { @@ -548,16 +555,18 @@ class views_plugin extends views_object { /** * Validate that the plugin is correct and can be saved. * - * @return + * @return array * An array of error strings to tell the user what is wrong with this * plugin. */ - function validate() { return array(); } + public function validate() { + return array(); + } /** * Returns the summary of the settings in the display. */ - function summary_title() { + public function summary_title() { return t('Settings'); } /** @@ -565,12 +574,13 @@ class views_plugin extends views_object { * * This appears on the ui beside each plugin and beside the settings link. */ - function plugin_title() { + public function plugin_title() { if (isset($this->definition['short title'])) { return check_plain($this->definition['short title']); } return check_plain($this->definition['title']); } + } /** diff --git a/sites/all/modules/views/includes/view.inc b/sites/all/modules/views/includes/view.inc index 5771ef3..4f26650 100644 --- a/sites/all/modules/views/includes/view.inc +++ b/sites/all/modules/views/includes/view.inc @@ -2,10 +2,6 @@ /** * @file - * Provides the view object type and associated methods. - */ - -/** * @defgroup views_objects Objects that represent a View or part of a view * @{ * These objects are the core of Views do the bulk of the direction and @@ -13,34 +9,48 @@ */ /** - * An object to contain all of the data to generate a view, plus the member - * functions to build the view query, execute the query and render the output. + * An object to contain all of the data to generate a view. + * + * Also includes the member functions to build the view query, execute the + * query and render the output. */ class view extends views_db_object { - var $db_table = 'views_view'; - var $base_table = 'node'; - var $base_field = 'nid'; + + /** + * + */ + public $db_table = 'views_view'; + + /** + * + */ + public $base_table = 'node'; + + /** + * + */ + public $base_field = 'nid'; /** * The name of the view. * * @var string */ - var $name = ""; + public $name = ""; /** * The id of the view, which is used only for views in the database. * * @var number */ - var $vid; + public $vid; /** * The description of the view, which is used only in the interface. * * @var string */ - var $description; + public $description; /** * The "tags" of a view. @@ -49,20 +59,21 @@ class view extends views_db_object { * * @var string */ - var $tag; + public $tag; /** * The human readable name of the view. * * @var string */ - var $human_name; + public $human_name; /** * The core version the view was created for. + * * @var int */ - var $core; + public $core; /** * The views-api version this view was created by. @@ -71,26 +82,47 @@ class view extends views_db_object { * * @var string */ - var $api_version; + public $api_version; /** * Is the view disabled. * - * This value is used for exported view, to provide some default views which aren't enabled. + * This value is used for exported view, to provide some default views which + * aren't enabled. * * @var bool */ - var $disabled; + public $disabled; - // State variables - var $built = FALSE; - var $executed = FALSE; - var $editing = FALSE; + /** + * State variable. + */ + public $built = FALSE; - var $args = array(); - var $build_info = array(); + /** + * State variable. + */ + public $executed = FALSE; - var $use_ajax = FALSE; + /** + * State variable. + */ + public $editing = FALSE; + + /** + * + */ + public $args = array(); + + /** + * + */ + public $build_info = array(); + + /** + * + */ + public $use_ajax = FALSE; /** * Where the results of a query will go. @@ -99,107 +131,107 @@ class view extends views_db_object { * * @var array */ - var $result = array(); + public $result = array(); // May be used to override the current pager info. - var $current_page = NULL; - var $items_per_page = NULL; - var $offset = NULL; - var $total_rows = NULL; + public $current_page = NULL; + public $items_per_page = NULL; + public $offset = NULL; + public $total_rows = NULL; - // Places to put attached renderings: - var $attachment_before = ''; - var $attachment_after = ''; + // Places to put attached renderings. + public $attachment_before = ''; + public $attachment_after = ''; - // Exposed widget input - var $exposed_data = array(); - var $exposed_input = array(); + // Exposed widget input. + public $exposed_data = array(); + public $exposed_input = array(); // Exposed widget input directly from the $form_state['values']. - var $exposed_raw_input = array(); + public $exposed_raw_input = array(); // Used to store views that were previously running if we recurse. - var $old_view = array(); + public $old_view = array(); // To avoid recursion in views embedded into areas. - var $parent_views = array(); + public $parent_views = array(); // Is the current stored view runned as an attachment to another view. - var $is_attachment = NULL; + public $is_attachment = NULL; // Stores the next steps of form items to handle. // It's an array of stack items, which contain the form id, the type of form, // the view, the display and some additional arguments. // @see views_ui_add_form_to_stack() // var $stack; - /** * Identifier of the current display. * * @var string */ - var $current_display; + public $current_display; /** - * Where the $query object will reside: + * Where the $query object will reside:. * * @var views_plugin_query */ - var $query = NULL; + public $query = NULL; - /** + /** * The current used display plugin. * * @var views_plugin_display */ - var $display_handler; + public $display_handler; /** * Stores all display handlers of this view. * * @var array[views_display] */ - var $display; + public $display; /** * The current used style plugin. * * @var views_plugin_style */ - var $style_plugin; + public $style_plugin; /** * Stored the changed options of the style plugin. * * @deprecated Better use $view->style_plugin->options + * * @var array */ - var $style_options; + public $style_options; /** * Stores the current active row while rendering. * * @var int */ - var $row_index; + public $row_index; - /** + /** * Allow to override the url of the current view. * * @var string */ - var $override_url = NULL; + public $override_url = NULL; /** * Allow to override the path used for generated urls. * * @var string */ - var $override_path = NULL; + public $override_path = NULL; /** * Allow to override the used database which is used for this query. */ - var $base_database = NULL; + public $base_database = NULL; /** * Here comes a list of the possible handler which are active on this view. @@ -207,58 +239,67 @@ class view extends views_db_object { /** * Stores the field handlers which are initialized on this view. + * * @var array[views_handler_field] */ - var $field; + public $field; /** * Stores the argument handlers which are initialized on this view. + * * @var array[views_handler_argument] */ - var $argument; + public $argument; /** * Stores the sort handlers which are initialized on this view. + * * @var array[views_handler_sort] */ - var $sort; + public $sort; /** * Stores the filter handlers which are initialized on this view. + * * @var array[views_handler_filter] */ - var $filter; + public $filter; /** * Stores the relationship handlers which are initialized on this view. + * * @var array[views_handler_relationship] */ - var $relationship; + public $relationship; /** * Stores the area handlers for the header which are initialized on this view. + * * @var array[views_handler_area] */ - var $header; + public $header; /** * Stores the area handlers for the footer which are initialized on this view. + * * @var array[views_handler_area] */ - var $footer; + public $footer; /** - * Stores the area handlers for the empty text which are initialized on this view. + * The area handlers for the empty text which are initialized on this view. + * * @var array[views_handler_area] */ - var $empty; + public $empty; /** - * Constructor + * Standard PHP constructor. */ - function __construct() { + public function __construct() { parent::init(); - // Make sure all of our sub objects are arrays. + + // Make sure all of the sub objects are arrays. foreach ($this->db_objects() as $object) { $this->$object = array(); } @@ -267,22 +308,21 @@ class view extends views_db_object { /** * Perform automatic updates when loading or importing a view. * - * Over time, some things about Views or Drupal data has changed. - * this attempts to do some automatic updates that must happen - * to ensure older views will at least try to work. + * Over time, some things about Views or Drupal data has changed. this + * attempts to do some automatic updates that must happen to ensure older + * views will at least try to work. */ - function update() { + public function update() { // When views are converted automatically the base_table should be renamed // to have a working query. $this->base_table = views_move_table($this->base_table); } - /** * Returns a list of the sub-object types used by this view. These types are * stored on the display, and are used in the build process. */ - function display_objects() { + public function display_objects() { return array('argument', 'field', 'sort', 'filter', 'relationship', 'header', 'footer', 'empty'); } @@ -298,27 +338,26 @@ class view extends views_db_object { * Set the arguments that come to this view. Usually from the URL * but possibly from elsewhere. */ - function set_arguments($args) { + public function set_arguments($args) { $this->args = $args; } /** * Change/Set the current page for the pager. */ - function set_current_page($page) { + public function set_current_page($page) { $this->current_page = $page; // If the pager is already initialized, pass it through to the pager. if (!empty($this->query->pager)) { return $this->query->pager->set_current_page($page); } - } /** * Get the current page from the pager. */ - function get_current_page() { + public function get_current_page() { // If the pager is already initialized, pass it through to the pager. if (!empty($this->query->pager)) { return $this->query->pager->get_current_page(); @@ -332,7 +371,7 @@ class view extends views_db_object { /** * Get the items per page from the pager. */ - function get_items_per_page() { + public function get_items_per_page() { // If the pager is already initialized, pass it through to the pager. if (!empty($this->query->pager)) { return $this->query->pager->get_items_per_page(); @@ -346,7 +385,7 @@ class view extends views_db_object { /** * Set the items per page on the pager. */ - function set_items_per_page($items_per_page) { + public function set_items_per_page($items_per_page) { $this->items_per_page = $items_per_page; // If the pager is already initialized, pass it through to the pager. @@ -358,7 +397,7 @@ class view extends views_db_object { /** * Get the pager offset from the pager. */ - function get_offset() { + public function get_offset() { // If the pager is already initialized, pass it through to the pager. if (!empty($this->query->pager)) { return $this->query->pager->get_offset(); @@ -372,7 +411,7 @@ class view extends views_db_object { /** * Set the offset on the pager. */ - function set_offset($offset) { + public function set_offset($offset) { $this->offset = $offset; // If the pager is already initialized, pass it through to the pager. @@ -384,7 +423,7 @@ class view extends views_db_object { /** * Determine if the pager actually uses a pager. */ - function use_pager() { + public function use_pager() { if (!empty($this->query->pager)) { return $this->query->pager->use_pager(); } @@ -395,7 +434,7 @@ class view extends views_db_object { * tablesorting and exposed filters will be fetched via an AJAX call * rather than a page refresh. */ - function set_use_ajax($use_ajax) { + public function set_use_ajax($use_ajax) { $this->use_ajax = $use_ajax; } @@ -403,14 +442,14 @@ class view extends views_db_object { * Set the exposed filters input to an array. If unset they will be taken * from $_GET when the time comes. */ - function set_exposed_input($filters) { + public function set_exposed_input($filters) { $this->exposed_input = $filters; } /** * Figure out what the exposed input for this view is. */ - function get_exposed_input() { + public function get_exposed_input() { if (empty($this->exposed_input)) { $this->exposed_input = array(); @@ -439,13 +478,13 @@ class view extends views_db_object { /** * Set the display for this view and initialize the display handler. */ - function init_display($reset = FALSE) { + public function init_display($reset = FALSE) { // The default display is always the first one in the list. if (isset($this->current_display)) { return TRUE; } - // Instantiate all displays + // Instantiate all displays. foreach (array_keys($this->display) as $id) { // Correct for shallow cloning // Often we'll have a cloned view so we don't mess up each other's @@ -481,10 +520,10 @@ class view extends views_db_object { /** * Get the first display that is accessible to the user. * - * @param $displays + * @param string|array $displays * Either a single display id or an array of display ids. */ - function choose_display($displays) { + public function choose_display($displays) { if (!is_array($displays)) { return $displays; } @@ -503,10 +542,10 @@ class view extends views_db_object { /** * Set the display as current. * - * @param $display_id + * @param string $display_id * The id of the display to mark as current. */ - function set_display($display_id = NULL) { + public function set_display($display_id = NULL) { // If we have not already initialized the display, do so. But be careful. if (empty($this->current_display)) { $this->init_display(); @@ -542,7 +581,7 @@ class view extends views_db_object { return FALSE; } - // Set a shortcut + // Set a shortcut. $this->display_handler = &$this->display[$display_id]->handler; return TRUE; @@ -554,7 +593,7 @@ class view extends views_db_object { * Note that arguments may have changed which style plugin we use, so * check the view object first, then ask the display handler. */ - function init_style() { + public function init_style() { if (isset($this->style_plugin)) { return is_object($this->style_plugin); } @@ -570,7 +609,7 @@ class view extends views_db_object { return FALSE; } - // init the new style handler with data. + // Init the new style handler with data.. $this->style_plugin->init($this, $this->display[$this->current_display], $this->style_options); return TRUE; } @@ -581,7 +620,7 @@ class view extends views_db_object { * This will try to add relationships automatically if it can, and will * remove the handlers if it cannot. */ - function fix_missing_relationships() { + public function fix_missing_relationships() { if (isset($this->relationships_fixed)) { return; } @@ -665,7 +704,7 @@ class view extends views_db_object { /** * Acquire and attach all of the handlers. */ - function init_handlers() { + public function init_handlers() { if (empty($this->inited)) { $this->fix_missing_relationships(); foreach (views_object_types() as $key => $info) { @@ -676,12 +715,12 @@ class view extends views_db_object { } /** - * Initialize the pager + * Initialize the pager. * * Like style initialization, pager initialization is held until late * to allow for overrides. */ - function init_pager() { + public function init_pager() { if (empty($this->query->pager)) { // If the query doesn't exist, initialize it. if (empty($this->query)) { @@ -709,7 +748,7 @@ class view extends views_db_object { * Create a list of base tables eligible for this view. Used primarily * for the UI. Display must be already initialized. */ - function get_base_tables() { + public function get_base_tables() { $base_tables = array( $this->base_table => TRUE, '#global' => TRUE, @@ -724,7 +763,7 @@ class view extends views_db_object { /** * Run the pre_query() on all active handlers. */ - function _pre_query() { + public function _pre_query() { foreach (views_object_types() as $key => $info) { $handlers = &$this->$key; $position = 0; @@ -739,7 +778,7 @@ class view extends views_db_object { /** * Run the post_execute() on all active handlers. */ - function _post_execute() { + public function _post_execute() { foreach (views_object_types() as $key => $info) { $handlers = &$this->$key; foreach ($handlers as $id => $handler) { @@ -751,12 +790,12 @@ class view extends views_db_object { /** * Attach all of the handlers for each type. * - * @param $key - * One of 'argument', 'field', 'sort', 'filter', 'relationship' - * @param $info + * @param string $key + * One of 'argument', 'field', 'sort', 'filter', 'relationship'. + * @param array $info * The $info from views_object_types for this object. */ - function _init_handler($key, $info) { + public function _init_handler($key, $info) { // Load the requested items from the display onto the object. $this->$key = &$this->display_handler->get_handlers($key); @@ -774,7 +813,7 @@ class view extends views_db_object { /** * Build all the arguments. */ - function _build_arguments() { + public function _build_arguments() { // Initially, we want to build sorts and fields. This can change, though, // if we get a summary view. if (empty($this->argument)) { @@ -804,7 +843,11 @@ class view extends views_db_object { $argument->set_relationship(); - $arg = isset($this->args[$position]) ? $this->args[$position] : NULL; + $arg = NULL; + if (isset($this->args[$position]) && $this->args[$position] !== '') { + $arg = $this->args[$position]; + } + $argument->position = $position; if (isset($arg) || $argument->has_default_argument()) { @@ -816,7 +859,8 @@ class view extends views_db_object { } } - // Set the argument, which will also validate that the argument can be set. + // Set the argument, which will also validate that the argument can be + // set. if (!$argument->set_argument($arg)) { $status = $argument->validate_fail($arg); break; @@ -830,7 +874,7 @@ class view extends views_db_object { $argument->query($this->display_handler->use_group_by()); } - // Add this argument's substitution + // Add this argument's substitution. $substitutions['%' . ($position + 1)] = $arg_title; $substitutions['!' . ($position + 1)] = strip_tags(decode_entities($arg)); @@ -852,7 +896,7 @@ class view extends views_db_object { // Allow the argument to muck with this breadcrumb. $argument->set_breadcrumb($this->build_info['breadcrumb']); - // Test to see if we should use this argument's title + // Test to see if we should use this argument's title. if (!empty($argument->options['title_enable']) && !empty($argument->options['title'])) { $title = $argument->options['title']; } @@ -865,7 +909,7 @@ class view extends views_db_object { break; } - // Be safe with references and loops: + // Be safe with references and loops. unset($argument); } @@ -883,7 +927,7 @@ class view extends views_db_object { /** * Do some common building initialization. */ - function init_query() { + public function init_query() { if (!empty($this->query)) { $class = get_class($this->query); if ($class && $class != 'stdClass') { @@ -917,7 +961,7 @@ class view extends views_db_object { /** * Build the query for the view. */ - function build($display_id = NULL) { + public function build($display_id = NULL) { if (!empty($this->built)) { return; } @@ -936,7 +980,6 @@ class view extends views_db_object { // Attempt to load from cache. // @todo Load a build_info from cache. - $start = microtime(TRUE); // If that fails, let's build! $this->build_info = array( @@ -950,8 +993,7 @@ class view extends views_db_object { // Call a module hook and see if it wants to present us with a // pre-built query or instruct us not to build the query for // some reason. - // @todo: Implement this. Use the same mechanism Panels uses. - + // @todo Implement this. Use the same mechanism Panels uses. // Run through our handlers and ensure they have necessary information. $this->init_handlers(); @@ -971,7 +1013,8 @@ class view extends views_db_object { $exposed_errors = count($errors_after) > count($errors_before); if ($exposed_errors || !empty($this->build_info['abort'])) { $this->built = TRUE; - // Don't execute the query, but rendering will still be executed to display the empty text. + // Don't execute the query, but rendering will still be executed to + // display the empty text. $this->executed = TRUE; return empty($this->build_info['fail']); } @@ -985,7 +1028,7 @@ class view extends views_db_object { $filter_groups = $this->display_handler->get_option('filter_groups'); if ($filter_groups) { $this->query->set_group_operator($filter_groups['operator']); - foreach($filter_groups['groups'] as $id => $operator) { + foreach ($filter_groups['groups'] as $id => $operator) { $this->query->set_where_group($operator, $id); } } @@ -1030,13 +1073,13 @@ class view extends views_db_object { $this->_build('footer'); $this->_build('empty'); - // Allow display handler to affect the query: + // Allow display handler to affect the query. $this->display_handler->query($this->display_handler->use_group_by()); - // Allow style handler to affect the query: + // Allow style handler to affect the query. $this->style_plugin->query($this->display_handler->use_group_by()); - // Allow exposed form to affect the query: + // Allow exposed form to affect the query. if (isset($exposed_form)) { $exposed_form->query(); } @@ -1057,7 +1100,7 @@ class view extends views_db_object { $this->built = TRUE; $this->build_time = microtime(TRUE) - $start; - // Attach displays + // Attach displays. $this->attach_displays(); // Let modules modify the view just after building it. @@ -1076,7 +1119,7 @@ class view extends views_db_object { * The type of handlers (filter etc.) which should be iterated over to * build the relationship and query information. */ - function _build($key) { + public function _build($key) { $handlers = &$this->$key; foreach ($handlers as $id => $data) { @@ -1097,7 +1140,7 @@ class view extends views_db_object { } } $rc = $handlers[$id]->accept_exposed_input($this->exposed_data); - $handlers[$id]->store_exposed_input($this->exposed_data, $rc); + $handlers[$id]->store_exposed_input($this->exposed_input, $rc); if (!$rc) { continue; } @@ -1119,7 +1162,7 @@ class view extends views_db_object { * Return whether the executing was successful, for example an argument * could stop the process. */ - function execute($display_id = NULL) { + public function execute($display_id = NULL) { if (empty($this->built)) { if (!$this->build($display_id)) { return FALSE; @@ -1130,7 +1173,8 @@ class view extends views_db_object { return TRUE; } - // Don't allow to use deactivated displays, but display them on the live preview. + // Don't allow to use deactivated displays, but display them on the live + // preview. if (!$this->display[$this->current_display]->handler->get_option('enabled') && empty($this->live_preview)) { $this->build_info['fail'] = TRUE; return FALSE; @@ -1150,7 +1194,7 @@ class view extends views_db_object { $cache = $this->display_handler->get_plugin('cache'); } if ($cache && $cache->cache_get('results')) { - if($this->query->pager->use_pager() || !empty($this->get_total_rows)) { + if ($this->query->pager->use_pager() || !empty($this->get_total_rows)) { $this->query->pager->total_items = $this->total_rows; $this->query->pager->update_page_info(); } @@ -1185,17 +1229,18 @@ class view extends views_db_object { * @param string $display_id * The machine name of the display, which should be rendered. * - * @return (string|NULL) - * Return the output of the rendered view or NULL if something failed in the process. + * @return string|NULL + * Return the output of the rendered view or NULL if something failed in the + * process. */ - function render($display_id = NULL) { + public function render($display_id = NULL) { $this->execute($display_id); // Check to see if the build failed. if (!empty($this->build_info['fail'])) { return; } - if (!empty($this->view->build_info['denied'])) { + if (!empty($this->build_info['denied'])) { return; } @@ -1300,21 +1345,20 @@ class view extends views_db_object { } /** - * Render a specific field via the field ID and the row # + * Render a specific field via the field ID and the row #. * * Note: You might want to use views_plugin_style::render_fields as it * caches the output for you. * * @param string $field * The id of the field to be rendered. - * * @param int $row * The row number in the $view->result which is used for the rendering. * * @return string * The rendered output of the field. */ - function render_field($field, $row) { + public function render_field($field, $row) { if (isset($this->field[$field]) && isset($this->result[$row])) { return $this->field[$field]->advanced_render($this->result[$row]); } @@ -1332,7 +1376,7 @@ class view extends views_db_object { * * If you simply want to view the display, use view::preview() instead. */ - function execute_display($display_id = NULL, $args = array()) { + public function execute_display($display_id = NULL, $args = array()) { if (empty($this->current_display) || $this->current_display != $this->choose_display($display_id)) { if (!$this->set_display($display_id)) { return FALSE; @@ -1341,7 +1385,7 @@ class view extends views_db_object { $this->pre_execute($args); - // Execute the view + // Execute the view. $output = $this->display_handler->execute(); $this->post_execute(); @@ -1355,7 +1399,7 @@ class view extends views_db_object { * Can also be called when views are embedded, as this guarantees * normalized output. */ - function preview($display_id = NULL, $args = array()) { + public function preview($display_id = NULL, $args = array()) { if (empty($this->current_display) || ((!empty($display_id)) && $this->current_display != $display_id)) { if (!$this->set_display($display_id)) { return FALSE; @@ -1375,7 +1419,7 @@ class view extends views_db_object { * Run attachments and let the display do what it needs to do prior * to running. */ - function pre_execute($args = array()) { + public function pre_execute($args = array()) { $this->old_view[] = views_get_current_view(); views_set_current_view($this); $display_id = $this->current_display; @@ -1386,7 +1430,8 @@ class view extends views_db_object { $this->set_arguments($args); } - // Let modules modify the view just prior to executing it. + // Trigger hook_views_pre_view(). Allow other modules to modify the view + // just prior to executing the preview. foreach (module_implements('views_pre_view') as $module) { $function = $module . '_views_pre_view'; $function($this, $display_id, $this->args); @@ -1395,17 +1440,16 @@ class view extends views_db_object { // Allow hook_views_pre_view() to set the dom_id, then ensure it is set. $this->dom_id = !empty($this->dom_id) ? $this->dom_id : md5($this->name . REQUEST_TIME . rand()); - // Allow the display handler to set up for execution + // Allow the display handler to set up for execution. $this->display_handler->pre_execute(); } /** * Unset the current view, mostly. */ - function post_execute() { + public function post_execute() { // unset current view so we can be properly destructed later on. // Return the previous value in case we're an attachment. - if ($this->old_view) { $old_view = array_pop($this->old_view); } @@ -1416,7 +1460,7 @@ class view extends views_db_object { /** * Run attachment displays for the view. */ - function attach_displays() { + public function attach_displays() { if (!empty($this->is_attachment)) { return; } @@ -1436,22 +1480,21 @@ class view extends views_db_object { } /** - * Called to get hook_menu() information from the view and the named display handler. + * Called to get hook_menu() info from the view and the named display handler. * - * @param $display_id + * @param string $display_id * A display id. - * @param $callbacks + * @param array $callbacks * A menu callback array passed from views_menu_alter(). */ - function execute_hook_menu($display_id = NULL, &$callbacks = array()) { + public function execute_hook_menu($display_id = NULL, &$callbacks = array()) { // Prepare the view with the information we have. - // This was probably already called, but it's good to be safe. if (!$this->set_display($display_id)) { return FALSE; } - // Execute the view + // Execute the view. if (isset($this->display_handler)) { return $this->display_handler->execute_hook_menu($callbacks); } @@ -1461,25 +1504,25 @@ class view extends views_db_object { * Called to get hook_block information from the view and the * named display handler. */ - function execute_hook_block_list($display_id = NULL) { + public function execute_hook_block_list($display_id = NULL) { // Prepare the view with the information we have. - // This was probably already called, but it's good to be safe. if (!$this->set_display($display_id)) { return FALSE; } - // Execute the view + // Execute the view. if (isset($this->display_handler)) { return $this->display_handler->execute_hook_block_list(); } } /** - * Determine if the given user has access to the view. Note that - * this sets the display handler if it hasn't been. + * Determine if the given user has access to the view. + * + * Note that this sets the display handler if it hasn't been. */ - function access($displays = NULL, $account = NULL) { + public function access($displays = NULL, $account = NULL) { // No one should have access to disabled views. if (!empty($this->disabled)) { return FALSE; @@ -1493,9 +1536,8 @@ class view extends views_db_object { $account = $GLOBALS['user']; } - // We can't use choose_display() here because that function - // calls this one. - $displays = (array)$displays; + // We can't use choose_display() here because that function calls this one. + $displays = (array) $displays; foreach ($displays as $display_id) { if (!empty($this->display[$display_id]->handler)) { if ($this->display[$display_id]->handler->access($account)) { @@ -1508,10 +1550,11 @@ class view extends views_db_object { } /** - * Get the view's current title. This can change depending upon how it - * was built. + * Get the view's current title. + * + * This can change depending upon how it was built. */ - function get_title() { + public function get_title() { if (empty($this->display_handler)) { if (!$this->set_display('default')) { return FALSE; @@ -1536,19 +1579,20 @@ class view extends views_db_object { /** * Override the view's current title. * - * The tokens in the title get's replaced before rendering. + * The tokens in the title get replaced before rendering. */ - function set_title($title) { - $this->build_info['title'] = $title; - return TRUE; - } + public function set_title($title) { + $this->build_info['title'] = $title; + return TRUE; + } /** * Return the human readable name for a view. * - * When a certain view doesn't have a human readable name return the machine readable name. + * When a certain view doesn't have a human readable name return the machine + * readable name. */ - function get_human_name() { + public function get_human_name() { if (!empty($this->human_name)) { $human_name = $this->human_name; } @@ -1561,7 +1605,7 @@ class view extends views_db_object { /** * Force the view to build a title. */ - function build_title() { + public function build_title() { $this->init_display(); if (empty($this->built)) { @@ -1578,7 +1622,7 @@ class view extends views_db_object { * * This URL will be adjusted for arguments. */ - function get_url($args = NULL, $path = NULL) { + public function get_url($args = NULL, $path = NULL) { if (!empty($this->override_url)) { return $this->override_url; } @@ -1600,7 +1644,7 @@ class view extends views_db_object { } } } - // Don't bother working if there's nothing to do: + // Don't bother working if there's nothing to do. if (empty($path) || (empty($args) && strpos($path, '%') === FALSE)) { return $path; } @@ -1619,7 +1663,8 @@ class view extends views_db_object { $pieces[] = $this->argument[$id]->options['exception']['value']; } else { - $pieces[] = '*'; // gotta put something if there just isn't one. + $pieces[] = '*'; + // @todo Gotta put something if there just isn't one. } } @@ -1642,7 +1687,7 @@ class view extends views_db_object { /** * Get the base path used for this view. */ - function get_path() { + public function get_path() { if (!empty($this->override_path)) { return $this->override_path; } @@ -1658,10 +1703,10 @@ class view extends views_db_object { /** * Get the breadcrumb used for this view. * - * @param $set + * @param bool $set * If true, use drupal_set_breadcrumb() to install the breadcrumb. */ - function get_breadcrumb($set = FALSE) { + public function get_breadcrumb($set = FALSE) { // Now that we've built the view, extract the breadcrumb. $base = TRUE; $breadcrumb = array(); @@ -1690,30 +1735,29 @@ class view extends views_db_object { } /** - * Is this view cacheable? + * Is this view cacheable?. */ - function is_cacheable() { + public function is_cacheable() { return $this->is_cacheable; } /** * Set up query capturing. * - * db_query() stores the queries that it runs in global $queries, - * bit only if dev_query is set to true. In this case, we want - * to temporarily override that setting if it's not and we - * can do that without forcing a db rewrite by just manipulating - * $conf. This is kind of evil but it works. + * Db_query() stores the queries that it runs in global $queries, bit only if + * dev_query is set to true. In this case, we want to temporarily override + * that setting if it's not and we can do that without forcing a db rewrite by + * just manipulating $conf. This is kind of evil but it works. */ - function start_query_capture() { + public function start_query_capture() { global $conf, $queries; if (empty($conf['dev_query'])) { $this->fix_dev_query = TRUE; $conf['dev_query'] = TRUE; } - // Record the last query key used; anything already run isn't - // a query that we are interested in. + // Record the last query key used; anything already run isn't a query that + // we are interested in. $this->last_query_key = NULL; if (!empty($queries)) { @@ -1727,19 +1771,19 @@ class view extends views_db_object { * * @see view::start_query_capture() */ - function end_query_capture() { + public function end_query_capture() { global $conf, $queries; if (!empty($this->fix_dev_query)) { $conf['dev_query'] = FALSE; } - // make a copy of the array so we can manipulate it with array_splice. + // Make a copy of the array so we can manipulate it with array_splice. $temp = $queries; // Scroll through the queries until we get to our last query key. // Unset anything in our temp array. if (isset($this->last_query_key)) { - while (list($id, $query) = each($queries)) { + foreach ($queries as $id => $query) { if ($id == $this->last_query_key) { break; } @@ -1754,9 +1798,9 @@ class view extends views_db_object { /** * Static factory method to load a list of views based upon a $where clause. * - * Although this method could be implemented to simply iterate over views::load(), - * that would be very slow. Buiding the views externally from unified queries is - * much faster. + * Although this method could be implemented to simply iterate over + * views::load(), that would be very slow. Buiding the views externally from + * unified queries is much faster. */ static function load_views() { $result = db_query("SELECT DISTINCT v.* FROM {views_view} v"); @@ -1764,7 +1808,7 @@ class view extends views_db_object { // Load all the views. foreach ($result as $data) { - $view = new view; + $view = new view(); $view->load_row($data); $view->loaded = TRUE; $view->type = t('Normal'); @@ -1777,7 +1821,7 @@ class view extends views_db_object { return array(); } - // Now load all the subtables: + // Now load all the subtables. foreach (view::db_objects() as $key) { $object_name = "views_$key"; $result = db_query("SELECT * FROM {{$object_name}} WHERE vid IN (:vids) ORDER BY vid, position", @@ -1787,8 +1831,8 @@ class view extends views_db_object { $object = new $object_name(FALSE); $object->load_row($data); - // Because it can get complicated with this much indirection, - // make a shortcut reference. + // Because it can get complicated with this much indirection, make a + // shortcut reference. $location = &$views[$names[$object->vid]]->$key; // If we have a basic id field, load the item onto the view based on @@ -1805,14 +1849,17 @@ class view extends views_db_object { } /** - * Save the view to the database. If the view does not already exist, - * A vid will be assigned to the view and also returned from this function. + * Save the view to the database. + * + * If the view does not already exist a vid will be assigned to the view and + * also returned from this function. */ - function save() { + public function save() { if ($this->vid == 'new') { $this->vid = NULL; } - // If there is no vid, check if a view with this machine name already exists. + // If there is no vid, check if a view with this machine name already + // exists. elseif (empty($this->vid)) { $vid = db_query("SELECT vid from {views_view} WHERE name = :name", array(':name' => $this->name))->fetchField(); $this->vid = $vid ? $vid : NULL; @@ -1826,7 +1873,7 @@ class view extends views_db_object { try { // If we have no vid or our vid is a string, this is a new view. if (!empty($this->vid)) { - // remove existing table entries + // remove existing table entries. foreach ($this->db_objects() as $key) { db_delete('views_' . $key) ->condition('vid', $this->vid) @@ -1849,18 +1896,20 @@ class view extends views_db_object { $this->save_locale_strings(); - // Clear caches. - views_invalidate_cache(); + // Clear the relevant caches. + cache_clear_all('views_block_items:', 'cache_views', TRUE); + views_invalidate_cache('ctools_export:views_view:' . $this->name); // Notify modules that this view has been saved. module_invoke_all('views_view_save', $this); } /** - * Save a row to the database for the given key, which is one of the - * keys from view::db_objects() + * Save a row to the database for the given key. + * + * i.e. one of the keys from view::db_objects(). */ - function _save_rows($key) { + public function _save_rows($key) { $count = 0; foreach ($this->$key as $position => $object) { $object->position = ++$count; @@ -1872,7 +1921,7 @@ class view extends views_db_object { /** * Delete the view from the database. */ - function delete($clear = TRUE) { + public function delete($clear = TRUE) { if (empty($this->vid)) { return; } @@ -1882,7 +1931,7 @@ class view extends views_db_object { ->execute(); // Delete from all of our subtables as well. foreach ($this->db_objects() as $key) { - db_delete('views_'. $key) + db_delete('views_' . $key) ->condition('vid', $this->vid) ->execute(); } @@ -1891,7 +1940,8 @@ class view extends views_db_object { if ($clear) { // Clear caches. - views_invalidate_cache(); + cache_clear_all('views_block_items:', 'cache_views', TRUE); + views_invalidate_cache('ctools_export:views_view:' . $this->name); } // Notify modules that this view has been deleted. @@ -1901,12 +1951,12 @@ class view extends views_db_object { /** * Export a view as PHP code. */ - function export($indent = '') { + public function export($indent = '') { $this->init_display(); $this->init_query(); $output = ''; $output .= $this->export_row('view', $indent); - // Set the API version + // Set the API version. $output .= $indent . '$view->api_version = \'' . views_api_version() . "';\n"; $output .= $indent . '$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */' . "\n"; @@ -1914,9 +1964,9 @@ class view extends views_db_object { $output .= "\n" . $indent . "/* Display: $display->display_title */\n"; $output .= $indent . '$handler = $view->new_display(' . ctools_var_export($display->display_plugin, $indent) . ', ' . ctools_var_export($display->display_title, $indent) . ', \'' . $id . "');\n"; if (empty($display->handler)) { - // @todo -- probably need a method of exporting broken displays as - // they may simply be broken because a module is not installed. That - // does not invalidate the display. + // @todo Probably need a method of exporting broken displays as they + // may simply be broken because a module is not installed. That does + // not invalidate the display. continue; } @@ -1936,12 +1986,11 @@ class view extends views_db_object { } /** - * Make a copy of this view that has been sanitized of all database IDs - * and handlers and other stuff. + * Make a copy of this view with IDs, handlers sanitized * * I'd call this clone() but it's reserved. */ - function copy() { + public function copy() { $code = $this->export(); eval($code); return $view; @@ -1950,21 +1999,20 @@ class view extends views_db_object { /** * Safely clone a view. * - * Because views are complicated objects within objects, and PHP loves to - * do references to everything, if a View is not properly and safely - * cloned it will still have references to the original view, and can - * actually cause the original view to point to objects in the cloned - * view. This gets ugly fast. + * Because views are complicated objects within objects, and PHP loves to do + * references to everything, if a View is not properly and safely cloned it + * will still have references to the original view, and can actually cause the + * original view to point to objects in the cloned view. This gets ugly fast. * * This will completely wipe a view clean so it can be considered fresh. * * @return view * The cloned view. */ - function clone_view() { + public function clone_view() { $clone = clone $this; - $keys = array('current_display', 'display_handler', 'build_info', 'built', 'executed', 'attachment_before', 'attachment_after', 'field', 'argument', 'filter', 'sort', 'relationship', 'header', 'footer', 'empty', 'query', 'inited', 'style_plugin', 'plugin_name', 'exposed_data', 'exposed_input', 'exposed_widgets', 'many_to_one_tables', 'feed_icon'); + $keys = array('current_display', 'display_handler', 'build_info', 'built', 'executed', 'attachment_before', 'attachment_after', 'field', 'argument', 'filter', 'sort', 'relationship', 'header', 'footer', 'empty', 'query', 'inited', 'style_plugin', 'plugin_name', 'exposed_data', 'exposed_input', 'exposed_widgets', 'many_to_one_aliases', 'many_to_one_tables', 'feed_icon'); foreach ($keys as $key) { if (isset($clone->{$key})) { unset($clone->{$key}); @@ -1976,8 +2024,8 @@ class view extends views_db_object { $clone->attachment_after = ''; $clone->result = array(); - // shallow cloning means that all the display objects - // *were not cloned*. We must clone them ourselves. + // Shallow cloning means that all the display objects *were not cloned*. We + // must clone them ourselves. $displays = array(); foreach ($clone->display as $id => $display) { $displays[$id] = clone $display; @@ -1991,10 +2039,9 @@ class view extends views_db_object { } /** - * Unset references so that a $view object may be properly garbage - * collected. + * Unset references so that a $view object may be properly garbage collected. */ - function destroy() { + public function destroy() { foreach (array_keys($this->display) as $display_id) { if (isset($this->display[$display_id]->handler) && is_object($this->display[$display_id]->handler)) { $this->display[$display_id]->handler->destroy(); @@ -2055,10 +2102,10 @@ class view extends views_db_object { /** * Make sure the view is completely valid. * - * @return + * @return bool * TRUE if the view is valid; an array of error strings if it is not. */ - function validate() { + public function validate() { $this->init_display(); $errors = array(); @@ -2087,7 +2134,7 @@ class view extends views_db_object { /** * Find and initialize the localization plugin. */ - function init_localization() { + public function init_localization() { // If the translate attribute isn't set, init the localization plugin. if (!isset($this->localization_plugin->translate)) { $this->localization_plugin = views_get_plugin('localization', views_get_localization_plugin()); @@ -2111,7 +2158,7 @@ class view extends views_db_object { /** * Determine whether a view supports admin string translation. */ - function is_translatable() { + public function is_translatable() { // Use translation no matter what type of view. if (variable_get('views_localize_all', FALSE)) { return TRUE; @@ -2124,31 +2171,31 @@ class view extends views_db_object { /** * Send strings for localization. */ - function save_locale_strings() { + public function save_locale_strings() { $this->process_locale_strings('save'); } /** * Delete localized strings. */ - function delete_locale_strings() { + public function delete_locale_strings() { $this->process_locale_strings('delete'); } /** * Export localized strings. */ - function export_locale_strings() { + public function export_locale_strings() { $this->process_locale_strings('export'); } /** * Process strings for localization, deletion or export to code. */ - function process_locale_strings($op) { + public function process_locale_strings($op) { // Ensure this view supports translation, we have a display, and we // have a localization plugin. - // @fixme Export does not init every handler. + // @todo Export does not init every handler. if (($this->is_translatable() || $op == 'export') && $this->init_display() && $this->init_localization()) { $this->localization_plugin->process_locale_strings($op); } @@ -2160,17 +2207,18 @@ class view extends views_db_object { * Base class for views' database objects. */ class views_db_object { + public $db_table; /** * Initialize this object, setting values from schema defaults. * - * @param $init + * @param array|bool $init * If an array, this is a set of values from db_fetch_object to * load. Otherwse, if TRUE values will be filled in from schema * defaults. */ - function init($init = TRUE) { + public function init($init = TRUE) { if (is_array($init)) { return $this->load_row($init); } @@ -2207,16 +2255,16 @@ class views_db_object { /** * Write the row to the database. * - * @param $update + * @param bool $update * If true this will be an UPDATE query. Otherwise it will be an INSERT. */ - function save_row($update = NULL) { + public function save_row($update = NULL) { $fields = $defs = $values = $serials = array(); $schema = drupal_get_schema($this->db_table); // Go through our schema and build correlations. foreach ($schema['fields'] as $field => $info) { - // special case -- skip serial types if we are updating. + // Special case - skip serial types if we are updating. if ($info['type'] == 'serial') { $serials[] = $field; continue; @@ -2238,8 +2286,7 @@ class views_db_object { ->execute(); if ($serials && !$update) { - // get last insert ids and fill them in. - // Well, one ID. + // Get last insert ids and fill them in. Well, one ID. foreach ($serials as $field) { $this->$field = $return; } @@ -2249,15 +2296,14 @@ class views_db_object { /** * Load the object with a row from the database. * - * This method is separate from the constructor in order to give us - * more flexibility in terms of how the view object is built in different - * contexts. + * This method is separate from the constructor in order to give us more + * flexibility in terms of how the view object is built in different contexts. * - * @param $data + * @param object $data * An object from db_fetch_object. It should contain all of the fields * that are in the schema. */ - function load_row($data) { + public function load_row($data) { $schema = drupal_get_schema($this->db_table); // Go through our schema and build correlations. @@ -2267,14 +2313,16 @@ class views_db_object { } /** - * Export a loaded row, such as an argument, field or the view itself to PHP code. + * Export a loaded row. * - * @param $identifier + * Might be an argument, field or the view itself to PHP code. + * + * @param string $identifier * The variable to assign the PHP code for this object to. - * @param $indent + * @param int $indent * An optional indentation for prettifying nested code. */ - function export_row($identifier = NULL, $indent = '') { + public function export_row($identifier = NULL, $indent = '') { ctools_include('export'); if (!$identifier) { @@ -2296,7 +2344,7 @@ class views_db_object { $this->$field = ''; } - // serialized defaults must be set as serialized. + // Serialized defaults must be set as serialized. if (isset($info['serialize'])) { $this->$field = unserialize($this->$field); } @@ -2319,17 +2367,18 @@ class views_db_object { /** * Add a new display handler to the view, automatically creating an id. * - * @param $type + * @param string $type * The plugin type from the views plugin data. Defaults to 'page'. - * @param $title + * @param string $title * The title of the display; optional, may be filled in from default. - * @param $id + * @param int $id * The id to use. - * @return - * The key to the display in $view->display, so that the new display - * can be easily located. + * + * @return string + * The key to the display in $view->display, so that the new display can be + * easily located. */ - function add_display($type = 'page', $title = NULL, $id = NULL) { + public function add_display($type = 'page', $title = NULL, $id = NULL) { if (empty($type)) { return FALSE; } @@ -2339,7 +2388,6 @@ class views_db_object { $plugin['title'] = t('Broken'); } - if (empty($id)) { $id = $this->generate_display_id($type); if ($id !== 'default') { @@ -2360,8 +2408,8 @@ class views_db_object { } } - // Create the new display object - $display = new views_display; + // Create the new display object. + $display = new views_display(); $display->options($type, $id, $title); // Add the new display object to the view. @@ -2372,10 +2420,10 @@ class views_db_object { /** * Generate a display id of a certain plugin type. * - * @param $type + * @param string $type * Which plugin should be used for the new display id. */ - function generate_display_id($type) { + public function generate_display_id($type) { // 'default' is singular and is unique, so just go with 'default' // for it. For all others, start counting. if ($type == 'default') { @@ -2385,8 +2433,8 @@ class views_db_object { $id = $type . '_1'; $count = 1; - // Loop through IDs based upon our style plugin name until - // we find one that is unused. + // Loop through IDs based upon our style plugin name until we find one that + // is unused. while (!empty($this->display[$id])) { $id = $type . '_' . ++$count; } @@ -2399,12 +2447,12 @@ class views_db_object { * * These items are typically fields, filters, sort criteria, or arguments. * - * @param $requested_id + * @param int $requested_id * The requested ID for the item. - * @param $existing_items + * @param array $existing_items * An array of existing items, keyed by their IDs. * - * @return + * @return string * A unique ID. This will be equal to $requested_id if no item with that ID * already exists. Otherwise, it will be appended with an integer to make * it unique, e.g. "{$requested_id}_1", "{$requested_id}_2", etc. @@ -2420,22 +2468,24 @@ class views_db_object { /** * Create a new display and a display handler for it. - * @param $type + * + * @param string $type * The plugin type from the views plugin data. Defaults to 'page'. - * @param $title + * @param string $title * The title of the display; optional, may be filled in from default. - * @param $id + * @param int $id * The id to use. + * * @return views_plugin_display * A reference to the new handler object. */ - function &new_display($type = 'page', $title = NULL, $id = NULL) { + public function &new_display($type = 'page', $title = NULL, $id = NULL) { $id = $this->add_display($type, $title, $id); - // Create a handler + // Create a handler. $this->display[$id]->handler = views_get_plugin('display', $this->display[$id]->display_plugin); if (empty($this->display[$id]->handler)) { - // provide a 'default' handler as an emergency. This won't work well but + // Provide a 'default' handler as an emergency. This won't work well but // it will keep things from crashing. $this->display[$id]->handler = views_get_plugin('display', 'default'); } @@ -2443,7 +2493,7 @@ class views_db_object { if (!empty($this->display[$id]->handler)) { // Initialize the new display handler with data. $this->display[$id]->handler->init($this, $this->display[$id]); - // If this is NOT the default display handler, let it know which is + // If this is NOT the default display handler, let it know which is. if ($id != 'default') { $this->display[$id]->handler->default_display = &$this->display['default']->handler; } @@ -2457,7 +2507,7 @@ class views_db_object { * * These items may be fields, filters, sort criteria, or arguments. */ - function add_item($display_id, $type, $table, $field, $options = array(), $id = NULL) { + public function add_item($display_id, $type, $table, $field, $options = array(), $id = NULL) { $types = views_object_types(); $this->set_display($display_id); @@ -2491,7 +2541,7 @@ class views_db_object { /** * Get an array of items for the current display. */ - function get_items($type, $display_id = NULL) { + public function get_items($type, $display_id = NULL) { $this->set_display($display_id); if (!isset($display_id)) { @@ -2504,34 +2554,32 @@ class views_db_object { } /** - * Get the configuration of an item (field/sort/filter/etc) on a given - * display. + * Get the config of an item (field/sort/filter/etc) on a given display. */ - function get_item($display_id, $type, $id) { + public function get_item($display_id, $type, $id) { // Get info about the types so we can get the right data. $types = views_object_types(); - // Initialize the display + // Initialize the display. $this->set_display($display_id); - // Get the existing configuration + // Get the existing configuration. $fields = $this->display[$display_id]->handler->get_option($types[$type]['plural']); return isset($fields[$id]) ? $fields[$id] : NULL; } /** - * Set the configuration of an item (field/sort/filter/etc) on a given - * display. + * Set the config of an item (field/sort/filter/etc) on a given display. * * Pass in NULL for the $item to remove an item. */ - function set_item($display_id, $type, $id, $item) { + public function set_item($display_id, $type, $id, $item) { // Get info about the types so we can get the right data. $types = views_object_types(); - // Initialize the display + // Initialize the display. $this->set_display($display_id); - // Get the existing configuration + // Get the existing configuration. $fields = $this->display[$display_id]->handler->get_option($types[$type]['plural']); if (isset($item)) { $fields[$id] = $item; @@ -2547,15 +2595,15 @@ class views_db_object { /** * Set an option on an item. * - * Use this only if you have just 1 or 2 options to set; if you have - * many, consider getting the item, adding the options and doing - * set_item yourself. + * Use this only if you have just 1 or 2 options to set; if you have many, + * consider getting the item, adding the options and doing set_item yourself. */ - function set_item_option($display_id, $type, $id, $option, $value) { + public function set_item_option($display_id, $type, $id, $option, $value) { $item = $this->get_item($display_id, $type, $id); $item[$option] = $value; $this->set_item($display_id, $type, $id, $item); } + } /** @@ -2565,47 +2613,55 @@ class views_db_object { * to the behavior of the display at all. */ class views_display extends views_db_object { + /** * The display handler itself, which has all the methods. * * @var views_plugin_display */ - var $handler; + public $handler; /** * Stores all options of the display, like fields, filters etc. * * @var array */ - var $display_options; + public $display_options; - var $db_table = 'views_display'; - function __construct($init = TRUE) { + public $db_table = 'views_display'; + public function __construct($init = TRUE) { parent::init($init); } - function options($type, $id, $title) { + /** + * {@inheritdoc} + */ + public function options($type, $id, $title) { $this->display_plugin = $type; $this->id = $id; $this->display_title = $title; } + } /** - * Provide a list of views object types used in a view, with some information - * about them. + * Provide a list of object types used in a view, with some info about them. */ function views_object_types() { static $retval = NULL; - // statically cache this so t() doesn't run a bajillion times. + // Statically cache this so t() doesn't run a bajillion times. if (!isset($retval)) { $retval = array( 'field' => array( - 'title' => t('Fields'), // title - 'ltitle' => t('fields'), // lowercase title for mid-sentence - 'stitle' => t('Field'), // singular title - 'lstitle' => t('field'), // singular lowercase title for mid sentence + // Title. + 'title' => t('Fields'), + // Lowercase title for mid-sentence. + 'ltitle' => t('fields'), + // Singular title. + 'stitle' => t('Field'), + // Lingular lowercase title for mid sentence. + 'lstitle' => t('field'), 'plural' => 'fields', ), 'argument' => array( diff --git a/sites/all/modules/views/js/ajax.js b/sites/all/modules/views/js/ajax.js index 5c68854..105465e 100644 --- a/sites/all/modules/views/js/ajax.js +++ b/sites/all/modules/views/js/ajax.js @@ -25,7 +25,13 @@ }); $('form', ajax_body).once('views-ajax-submit-processed').each(function() { - var element_settings = { 'url': response.url, 'event': 'submit', 'progress': { 'type': 'throbber' } }; + var element_settings = { + 'url': response.url, + 'event': 'submit', + 'progress': { + 'type': 'throbber' + } + }; var $form = $(this); var id = $form.attr('id'); Drupal.ajax[id] = new Drupal.ajax(id, this, element_settings); @@ -90,7 +96,7 @@ }; /** - * Get rid of irritating tabledrag messages + * Get rid of irritating tabledrag messages. */ Drupal.theme.tableDragChangedWarning = function () { return []; @@ -143,7 +149,9 @@ var base_element_settings = { 'event': 'click', - 'progress': { 'type': 'throbber' } + 'progress': { + 'type': 'throbber' + } }; // Bind AJAX behaviors to all items showing the class. $('a.views-ajax-link', context).once('views-ajax-processed').each(function () { @@ -158,23 +166,23 @@ $('div#views-live-preview a') .once('views-ajax-processed').each(function () { - // We don't bind to links without a URL. - if (!$(this).attr('href')) { - return true; - } + // We don't bind to links without a URL. + if (!$(this).attr('href')) { + return true; + } - var element_settings = base_element_settings; - // Set the URL to go to the anchor. - element_settings.url = $(this).attr('href'); - if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') { - return true; - } + var element_settings = base_element_settings; + // Set the URL to go to the anchor. + element_settings.url = $(this).attr('href'); + if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') { + return true; + } - element_settings.wrapper = 'views-live-preview'; - element_settings.method = 'html'; - var base = $(this).attr('id'); - Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); - }); + element_settings.wrapper = 'views-live-preview'; + element_settings.method = 'html'; + var base = $(this).attr('id'); + Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); + }); // Within a live preview, make exposed widget form buttons re-trigger the // Preview button. @@ -182,29 +190,29 @@ // of the main Edit form. $('div#views-live-preview input[type=submit]') .once('views-ajax-processed').each(function(event) { - $(this).click(function () { - this.form.clk = this; - return true; + $(this).click(function () { + this.form.clk = this; + return true; + }); + var element_settings = base_element_settings; + // Set the URL to go to the anchor. + element_settings.url = $(this.form).attr('action'); + if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') { + return true; + } + + element_settings.wrapper = 'views-live-preview'; + element_settings.method = 'html'; + element_settings.event = 'click'; + + var base = $(this).attr('id'); + Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); }); - var element_settings = base_element_settings; - // Set the URL to go to the anchor. - element_settings.url = $(this.form).attr('action'); - if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') { - return true; - } - - element_settings.wrapper = 'views-live-preview'; - element_settings.method = 'html'; - element_settings.event = 'click'; - - var base = $(this).attr('id'); - Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); - }); if (!this.collapseReplaced && Drupal.collapseScrollIntoView) { this.collapseReplaced = true; Drupal.collapseScrollIntoView = function (node) { - for (var $parent = $(node); $parent.get(0) != document && $parent.size() != 0; $parent = $parent.parent()) { + for (var $parent = $(node); $parent.get(0) != document && $parent.length != 0; $parent = $parent.parent()) { if ($parent.css('overflow') == 'scroll' || $parent.css('overflow') == 'auto') { if (Drupal.viewsUi.resizeModal) { // If the modal is already at the max height, don't bother with diff --git a/sites/all/modules/views/js/ajax_view.js b/sites/all/modules/views/js/ajax_view.js index aa10a00..5012c33 100644 --- a/sites/all/modules/views/js/ajax_view.js +++ b/sites/all/modules/views/js/ajax_view.js @@ -4,148 +4,162 @@ */ (function ($) { -/** - * Attaches the AJAX behavior to Views exposed filter forms and key View links. - */ -Drupal.behaviors.ViewsAjaxView = {}; -Drupal.behaviors.ViewsAjaxView.attach = function() { - if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) { - $.each(Drupal.settings.views.ajaxViews, function(i, settings) { - Drupal.views.instances[i] = new Drupal.views.ajaxView(settings); - }); - } -}; - -Drupal.views = {}; -Drupal.views.instances = {}; - -/** - * Javascript object for a certain view. - */ -Drupal.views.ajaxView = function(settings) { - var selector = '.view-dom-id-' + settings.view_dom_id; - this.$view = $(selector); - - // Retrieve the path to use for views' ajax. - var ajax_path = Drupal.settings.views.ajax_path; - - // If there are multiple views this might've ended up showing up multiple times. - if (ajax_path.constructor.toString().indexOf("Array") != -1) { - ajax_path = ajax_path[0]; - } - - // Check if there are any GET parameters to send to views. - var queryString = window.location.search || ''; - if (queryString !== '') { - // Remove the question mark and Drupal path component if any. - var queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, ''); - if (queryString !== '') { - // If there is a '?' in ajax_path, clean url are on and & should be used to add parameters. - queryString = ((/\?/.test(ajax_path)) ? '&' : '?') + queryString; + /** + * Attaches the AJAX behavior to exposed filter forms and key views links. + */ + Drupal.behaviors.ViewsAjaxView = {}; + Drupal.behaviors.ViewsAjaxView.attach = function() { + if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) { + $.each(Drupal.settings.views.ajaxViews, function(i, settings) { + Drupal.views.instances[i] = new Drupal.views.ajaxView(settings); + }); } - } - - this.element_settings = { - url: ajax_path + queryString, - submit: settings, - setClick: true, - event: 'click', - selector: selector, - progress: { type: 'throbber' } }; - this.settings = settings; + Drupal.views = {}; + Drupal.views.instances = {}; - // Add the ajax to exposed forms. - this.$exposed_form = $('#views-exposed-form-'+ settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-')); - this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this)); + /** + * JavaScript object for a certain view. + */ + Drupal.views.ajaxView = function(settings) { + var selector = '.view-dom-id-' + settings.view_dom_id; + this.$view = $(selector); - // Store Drupal.ajax objects here for all pager links. - this.links = []; + // Retrieve the path to use for views' ajax. + var ajax_path = Drupal.settings.views.ajax_path; - // Add the ajax to pagers. - this.$view - // Don't attach to nested views. Doing so would attach multiple behaviors - // to a given element. - .filter(jQuery.proxy(this.filterNestedViews, this)) - .once(jQuery.proxy(this.attachPagerAjax, this)); + // If there are multiple views this might've ended up showing up multiple + // times. + if (ajax_path.constructor.toString().indexOf("Array") != -1) { + ajax_path = ajax_path[0]; + } - // Add a trigger to update this view specifically. In order to trigger a - // refresh use the following code. - // - // @code - // jQuery('.view-name').trigger('RefreshView'); - // @endcode - // Add a trigger to update this view specifically. - var self_settings = this.element_settings; - self_settings.event = 'RefreshView'; - this.refreshViewAjax = new Drupal.ajax(this.selector, this.$view, self_settings); -}; + // Check if there are any GET parameters to send to views. + var queryString = window.location.search || ''; + if (queryString !== '') { + // Remove the question mark and Drupal path component if any. + var queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, ''); + if (queryString !== '') { + // If there is a '?' in ajax_path, clean url are on and & should be + // used to add parameters. + queryString = ((/\?/.test(ajax_path)) ? '&' : '?') + queryString; + } + } -Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() { - var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form); - button = button[0]; + this.element_settings = { + url: ajax_path + queryString, + submit: settings, + setClick: true, + event: 'click', + selector: selector, + progress: { + type: 'throbber' + } + }; - this.exposedFormAjax = new Drupal.ajax($(button).attr('id'), button, this.element_settings); -}; + this.settings = settings; -Drupal.views.ajaxView.prototype.filterNestedViews= function() { - // If there is at least one parent with a view class, this view - // is nested (e.g., an attachment). Bail. - return !this.$view.parents('.view').size(); -}; + // Add the ajax to exposed forms. + this.$exposed_form = $('#views-exposed-form-' + settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-')); + this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this)); -/** - * Attach the ajax behavior to each link. - */ -Drupal.views.ajaxView.prototype.attachPagerAjax = function() { - this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a') - .each(jQuery.proxy(this.attachPagerLinkAjax, this)); -}; + // Store Drupal.ajax objects here for all pager links. + this.links = []; -/** - * Attach the ajax behavior to a singe link. - */ -Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) { - var $link = $(link); - var viewData = {}; - var href = $link.attr('href'); - // Construct an object using the settings defaults and then overriding - // with data specific to the link. - $.extend( + // Add the ajax to pagers. + this.$view + .once(jQuery.proxy(this.attachPagerAjax, this)); + + // Add a trigger to update this view specifically. In order to trigger a + // refresh use the following code. + // + // @code + // jQuery('.view-name').trigger('RefreshView'); + // @endcode + // Add a trigger to update this view specifically. + var self_settings = this.element_settings; + self_settings.event = 'RefreshView'; + this.refreshViewAjax = new Drupal.ajax(this.selector, this.$view, self_settings); + }; + + Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() { + var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form); + button = button[0]; + + // Call the autocomplete submit before doing AJAX. + $(button).click(function () { + if (Drupal.autocompleteSubmit) { + Drupal.autocompleteSubmit(); + } + }); + + this.exposedFormAjax = new Drupal.ajax($(button).attr('id'), button, this.element_settings); + }; + + /** + * Attach the ajax behavior to each link. + */ + Drupal.views.ajaxView.prototype.attachPagerAjax = function() { + this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a') + .each(jQuery.proxy(this.attachPagerLinkAjax, this)); + }; + + /** + * Attach the ajax behavior to a singe link. + */ + Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) { + var $link = $(link); + // Don't attach to pagers inside nested views. + if ($link.closest('.view')[0] !== this.$view[0]) { + return; + } + var viewData = {}; + var href = $link.attr('href'); + + // Provide a default page if none has been set. This must be done + // prior to merging with settings to avoid accidentally using the + // page landed on instead of page 1. + if (typeof(viewData.page) === 'undefined') { + viewData.page = 0; + } + + // Construct an object using the settings defaults and then overriding + // with data specific to the link. + $.extend( viewData, this.settings, Drupal.Views.parseQueryString(href), // Extract argument data from the URL. Drupal.Views.parseViewArgs(href, this.settings.view_base_path) - ); + ); - // For anchor tags, these will go to the target of the anchor rather - // than the usual location. - $.extend(viewData, Drupal.Views.parseViewArgs(href, this.settings.view_base_path)); + // For anchor tags, these will go to the target of the anchor rather + // than the usual location. + $.extend(viewData, Drupal.Views.parseViewArgs(href, this.settings.view_base_path)); - this.element_settings.submit = viewData; - this.pagerAjax = new Drupal.ajax(false, $link, this.element_settings); - this.links.push(this.pagerAjax); -}; + this.element_settings.submit = viewData; + this.pagerAjax = new Drupal.ajax(false, $link, this.element_settings); + this.links.push(this.pagerAjax); + }; -Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) { - // Scroll to the top of the view. This will allow users - // to browse newly loaded content after e.g. clicking a pager - // link. - var offset = $(response.selector).offset(); - // We can't guarantee that the scrollable object should be - // the body, as the view could be embedded in something - // more complex such as a modal popup. Recurse up the DOM - // and scroll the first element that has a non-zero top. - var scrollTarget = response.selector; - while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) { - scrollTarget = $(scrollTarget).parent(); - } - // Only scroll upward - if (offset.top - 10 < $(scrollTarget).scrollTop()) { - $(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500); - } -}; + Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) { + // Scroll to the top of the view. This will allow users + // to browse newly loaded content after e.g. clicking a pager + // link. + var offset = $(response.selector).offset(); + // We can't guarantee that the scrollable object should be + // the body, as the view could be embedded in something + // more complex such as a modal popup. Recurse up the DOM + // and scroll the first element that has a non-zero top. + var scrollTarget = response.selector; + while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) { + scrollTarget = $(scrollTarget).parent(); + } + // Only scroll upward. + if (offset.top - 10 < $(scrollTarget).scrollTop()) { + $(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500); + } + }; })(jQuery); diff --git a/sites/all/modules/views/js/base.js b/sites/all/modules/views/js/base.js index ce5bf6a..24fa02c 100644 --- a/sites/all/modules/views/js/base.js +++ b/sites/all/modules/views/js/base.js @@ -4,112 +4,112 @@ */ (function ($) { -Drupal.Views = {}; + Drupal.Views = {}; -/** - * jQuery UI tabs, Views integration component - */ -Drupal.behaviors.viewsTabs = { - attach: function (context) { - if ($.viewsUi && $.viewsUi.tabs) { - $('#views-tabset').once('views-processed').viewsTabs({ - selectedClass: 'active' - }); - } - - $('a.views-remove-link').once('views-processed').click(function(event) { - var id = $(this).attr('id').replace('views-remove-link-', ''); - $('#views-row-' + id).hide(); - $('#views-removed-' + id).attr('checked', true); - event.preventDefault(); - }); /** - * Here is to handle display deletion - * (checking in the hidden checkbox and hiding out the row) - */ - $('a.display-remove-link') - .addClass('display-processed') - .click(function() { - var id = $(this).attr('id').replace('display-remove-link-', ''); - $('#display-row-' + id).hide(); - $('#display-removed-' + id).attr('checked', true); - return false; - }); - } -}; + * JQuery UI tabs, Views integration component. + */ + Drupal.behaviors.viewsTabs = { + attach: function (context) { + if ($.viewsUi && $.viewsUi.tabs) { + $('#views-tabset').once('views-processed').viewsTabs({ + selectedClass: 'active' + }); + } -/** + $('a.views-remove-link').once('views-processed').click(function(event) { + var id = $(this).attr('id').replace('views-remove-link-', ''); + $('#views-row-' + id).hide(); + $('#views-removed-' + id).attr('checked', true); + event.preventDefault(); + }); + /** + * Here is to handle display deletion + * (checking in the hidden checkbox and hiding out the row). + */ + $('a.display-remove-link') + .addClass('display-processed') + .click(function() { + var id = $(this).attr('id').replace('display-remove-link-', ''); + $('#display-row-' + id).hide(); + $('#display-removed-' + id).attr('checked', true); + return false; + }); + } + }; + + /** * Helper function to parse a querystring. */ -Drupal.Views.parseQueryString = function (query) { - var args = {}; - var pos = query.indexOf('?'); - if (pos != -1) { - query = query.substring(pos + 1); - } - var pairs = query.split('&'); - for(var i in pairs) { - if (typeof(pairs[i]) == 'string') { - var pair = pairs[i].split('='); - // Ignore the 'q' path argument, if present. - if (pair[0] != 'q' && pair[1]) { - args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); + Drupal.Views.parseQueryString = function (query) { + var args = {}; + var pos = query.indexOf('?'); + if (pos != -1) { + query = query.substring(pos + 1); + } + var pairs = query.split('&'); + for (var i in pairs) { + if (typeof(pairs[i]) == 'string') { + var pair = pairs[i].split('='); + // Ignore the 'q' path argument, if present. + if (pair[0] != 'q' && pair[1]) { + args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); + } } } - } - return args; -}; + return args; + }; -/** + /** * Helper function to return a view's arguments based on a path. */ -Drupal.Views.parseViewArgs = function (href, viewPath) { + Drupal.Views.parseViewArgs = function (href, viewPath) { - // Provide language prefix. - if (Drupal.settings.pathPrefix) { - var viewPath = Drupal.settings.pathPrefix + viewPath; - } - var returnObj = {}; - var path = Drupal.Views.getPath(href); - // Ensure we have a correct path. - if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') { - var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length)); - returnObj.view_args = args; - returnObj.view_path = path; - } - return returnObj; -}; + // Provide language prefix. + if (Drupal.settings.pathPrefix) { + var viewPath = Drupal.settings.pathPrefix + viewPath; + } + var returnObj = {}; + var path = Drupal.Views.getPath(href); + // Ensure we have a correct path. + if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') { + var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length)); + returnObj.view_args = args; + returnObj.view_path = path; + } + return returnObj; + }; -/** + /** * Strip off the protocol plus domain from an href. */ -Drupal.Views.pathPortion = function (href) { - // Remove e.g. http://example.com if present. - var protocol = window.location.protocol; - if (href.substring(0, protocol.length) == protocol) { - // 2 is the length of the '//' that normally follows the protocol - href = href.substring(href.indexOf('/', protocol.length + 2)); - } - return href; -}; + Drupal.Views.pathPortion = function (href) { + // Remove e.g. http://example.com if present. + var protocol = window.location.protocol; + if (href.substring(0, protocol.length) == protocol) { + // 2 is the length of the '//' that normally follows the protocol. + href = href.substring(href.indexOf('/', protocol.length + 2)); + } + return href; + }; -/** + /** * Return the Drupal path portion of an href. */ -Drupal.Views.getPath = function (href) { - href = Drupal.Views.pathPortion(href); - href = href.substring(Drupal.settings.basePath.length, href.length); - // 3 is the length of the '?q=' added to the url without clean urls. - if (href.substring(0, 3) == '?q=') { - href = href.substring(3, href.length); - } - var chars = ['#', '?', '&']; - for (var i in chars) { - if (href.indexOf(chars[i]) > -1) { - href = href.substr(0, href.indexOf(chars[i])); + Drupal.Views.getPath = function (href) { + href = Drupal.Views.pathPortion(href); + href = href.substring(Drupal.settings.basePath.length, href.length); + // 3 is the length of the '?q=' added to the url without clean urls. + if (href.substring(0, 3) == '?q=') { + href = href.substring(3, href.length); } - } - return href; -}; + var chars = ['#', '?', '&']; + for (var i in chars) { + if (href.indexOf(chars[i]) > -1) { + href = href.substr(0, href.indexOf(chars[i])); + } + } + return href; + }; })(jQuery); diff --git a/sites/all/modules/views/js/jquery.ui.dialog.patch.js b/sites/all/modules/views/js/jquery.ui.dialog.patch.js index 3ac7704..0b099ce 100644 --- a/sites/all/modules/views/js/jquery.ui.dialog.patch.js +++ b/sites/all/modules/views/js/jquery.ui.dialog.patch.js @@ -1,4 +1,5 @@ /** + * @file * This is part of a patch to address a jQueryUI bug. The bug is responsible * for the inability to scroll a page when a modal dialog is active. If the content * of the dialog extends beyond the bottom of the viewport, the user is only able @@ -9,19 +10,22 @@ * @see views_ui.module * @see js/jquery.ui.dialog.min.js * - * This javascript patch overwrites the $.ui.dialog.overlay.events object to remove + * This JavaScript patch overwrites the $.ui.dialog.overlay.events object to remove * the mousedown, mouseup and click events from the list of events that are bound * in $.ui.dialog.overlay.create * * The original code for this object: * $.ui.dialog.overlay.events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','), - * function(event) { return event + '.dialog-overlay'; }).join(' '), - * + * function(event) { + * return event + '.dialog-overlay'; + * }).join(' '), */ (function ($, undefined) { if ($.ui && $.ui.dialog && $.ui.dialog.overlay) { $.ui.dialog.overlay.events = $.map('focus,keydown,keypress'.split(','), - function(event) { return event + '.dialog-overlay'; }).join(' '); + function(event) { + return event + '.dialog-overlay'; + }).join(' '); } }(jQuery)); diff --git a/sites/all/modules/views/js/views-admin.js b/sites/all/modules/views/js/views-admin.js index 3d91fae..807d7f7 100644 --- a/sites/all/modules/views/js/views-admin.js +++ b/sites/all/modules/views/js/views-admin.js @@ -187,7 +187,8 @@ Drupal.viewsUi.addItemForm.prototype.handleCheck = function (event) { else { var length = this.checkedItems.length; var position = jQuery.inArray(label, this.checkedItems); - // Delete the item from the list and take sure that the list doesn't have undefined items left. + // Delete the item from the list and take sure that the list doesn't have + // undefined items left. for (var i = 0; i < this.checkedItems.length; i++) { if (i == position) { this.checkedItems.splice(i, 1); @@ -245,7 +246,7 @@ Drupal.behaviors.viewsUiRenderAddViewButton.attach = function (context, settings }); $addDisplayDropdown.appendTo($menu); - // Add the click handler for the add display button + // Add the click handler for the add display button. $('li.add > a', $menu).bind('click', function (event) { event.preventDefault(); var $trigger = $(this); @@ -668,7 +669,7 @@ Drupal.viewsUi.rearrangeFilterHandler.prototype.modifyTableDrag = function () { // Make sure the "group" dropdown is properly updated when rows are dragged // into an empty filter group. This is borrowed heavily from the block.js - // implementation of tableDrag.onDrop(). + // Implements tableDrag.onDrop(). var groupRow = $(this.rowObject.element).prevAll('tr.group-message').get(0); var groupName = groupRow.className.replace(/([^ ]+[ ]+)*group-([^ ]+)-message([ ]+[^ ]+)*/, '$2'); var groupField = $('select.views-group-select', this.rowObject.element); @@ -769,14 +770,14 @@ Drupal.behaviors.viewsFilterConfigSelectAll.attach = function(context) { $('#views-ui-config-item-form div.form-item-options-value-all', context).once(function() { $(this).show(); }) - .find('input[type=checkbox]') - .click(function() { - var checked = $(this).is(':checked'); - // Update all checkbox beside the select all checkbox. - $(this).parents('.form-checkboxes').find('input[type=checkbox]').each(function() { - $(this).attr('checked', checked); + .find('input[type=checkbox]') + .click(function() { + var checked = $(this).is(':checked'); + // Update all checkbox beside the select all checkbox. + $(this).parents('.form-checkboxes').find('input[type=checkbox]').each(function() { + $(this).attr('checked', checked); + }); }); - }); // Uncheck the select all checkbox if any of the others are unchecked. $('#views-ui-config-item-form div.form-type-checkbox').not($('.form-item-options-value-all')).find('input[type=checkbox]').each(function() { $(this).click(function() { @@ -926,7 +927,7 @@ Drupal.behaviors.viewsUiOverrideSelect.attach = function (context, settings) { $submit.val(Drupal.t('Apply (this display)')); } }) - .trigger('change'); + .trigger('change'); }); }; @@ -935,13 +936,14 @@ Drupal.viewsUi.resizeModal = function (e, no_shrink) { var $ = jQuery; var $modal = $('.views-ui-dialog'); var $scroll = $('.scroll', $modal); - if ($modal.size() == 0 || $modal.css('display') == 'none') { + if ($modal.length == 0 || $modal.css('display') == 'none') { return; } - var maxWidth = parseInt($(window).width() * .85); // 70% of window - var minWidth = parseInt($(window).width() * .6); // 70% of window - + var maxWidth = parseInt($(window).width() * .85); + // 70% of window. + var minWidth = parseInt($(window).width() * .6); + // 70% of window. // Set the modal to the minwidth so that our width calculation of // children works. $modal.css('width', minWidth); @@ -976,15 +978,14 @@ Drupal.viewsUi.resizeModal = function (e, no_shrink) { // Now, calculate what the difference between the scroll and the modal // will be. - var difference = 0; difference += parseInt($scroll.css('padding-top')); difference += parseInt($scroll.css('padding-bottom')); - difference += $('.views-override').outerHeight(true); - difference += $('.views-messages').outerHeight(true); - difference += $('#views-ajax-title').outerHeight(true); - difference += $('.views-add-form-selected').outerHeight(true); - difference += $('.form-buttons', $modal).outerHeight(true); + difference += $('.views-override').outerHeight(true) || 0; + difference += $('.views-messages').outerHeight(true) || 0; + difference += $('#views-ajax-title').outerHeight(true) || 0; + difference += $('.views-add-form-selected').outerHeight(true) || 0; + difference += $('.form-buttons', $modal).outerHeight(true) || 0; height = scrollHeight + difference; @@ -1001,7 +1002,7 @@ Drupal.viewsUi.resizeModal = function (e, no_shrink) { width = maxWidth; } - // Get where we should move content to + // Get where we should move content to. var top = ($(window).height() / 2) - (height / 2); var left = ($(window).width() / 2) - (width / 2); diff --git a/sites/all/modules/views/js/views-contextual.js b/sites/all/modules/views/js/views-contextual.js index a2bbc2a..09fabc9 100644 --- a/sites/all/modules/views/js/views-contextual.js +++ b/sites/all/modules/views/js/views-contextual.js @@ -1,16 +1,16 @@ /** * @file - * Javascript related to contextual links. + * JavaScript related to contextual links. */ (function ($) { -Drupal.behaviors.viewsContextualLinks = { - attach: function (context) { - // If there are views-related contextual links attached to the main page - // content, find the smallest region that encloses both the links and the - // view, and display it as a contextual links region. - $('.views-contextual-links-page', context).closest(':has(".view"):not("body")').addClass('contextual-links-region'); - } -}; + Drupal.behaviors.viewsContextualLinks = { + attach: function (context) { + // If there are views-related contextual links attached to the main page + // content, find the smallest region that encloses both the links and the + // view, and display it as a contextual links region. + $('.views-contextual-links-page', context).closest(':has(".view"):not("body")').addClass('contextual-links-region'); + } + }; })(jQuery); diff --git a/sites/all/modules/views/js/views-list.js b/sites/all/modules/views/js/views-list.js index 9c6c5f0..d7a274d 100644 --- a/sites/all/modules/views/js/views-list.js +++ b/sites/all/modules/views/js/views-list.js @@ -1,21 +1,21 @@ /** * @file - * Javascript related to the main view list. + * JavaScript related to the main view list. */ (function ($) { -Drupal.behaviors.viewsUIList = { - attach: function (context) { - $('#ctools-export-ui-list-items thead a').once('views-ajax-processed').each(function() { - $(this).click(function() { - var query = $.deparam.querystring(this.href); - $('#ctools-export-ui-list-form select[name=order]').val(query['order']); - $('#ctools-export-ui-list-form select[name=sort]').val(query['sort']); - $('#ctools-export-ui-list-form input.ctools-auto-submit-click').trigger('click'); - return false; + Drupal.behaviors.viewsUIList = { + attach: function (context) { + $('#ctools-export-ui-list-items thead a').once('views-ajax-processed').each(function() { + $(this).click(function() { + var query = $.deparam.querystring(this.href); + $('#ctools-export-ui-list-form select[name=order]').val(query['order']); + $('#ctools-export-ui-list-form select[name=sort]').val(query['sort']); + $('#ctools-export-ui-list-form input.ctools-auto-submit-click').trigger('click'); + return false; + }); }); - }); - } -}; + } + }; })(jQuery); diff --git a/sites/all/modules/views/modules/aggregator.views.inc b/sites/all/modules/views/modules/aggregator.views.inc index 0fcae2c..54f2a40 100644 --- a/sites/all/modules/views/modules/aggregator.views.inc +++ b/sites/all/modules/views/modules/aggregator.views.inc @@ -12,13 +12,12 @@ */ function aggregator_views_data() { // ---------------------------------------------------------------------- - // Main Aggregator Item base table - - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + // Main Aggregator Item base table. + // Define the base group of this table. Fields that don't have a group + // defined will go into this field by default. $data['aggregator_item']['table']['group'] = t('Aggregator'); - // Advertise this table as a possible base table + // Advertise this table as a possible base table. $data['aggregator_item']['table']['base'] = array( 'field' => 'iid', 'title' => t('Aggregator item'), @@ -27,43 +26,25 @@ function aggregator_views_data() { // ---------------------------------------------------------------- // Fields - - // item id. - $data['aggregator_item']['iid'] = array( - 'title' => t('Feed Item ID'), - 'help' => t('The unique ID of the aggregator item.'), - 'field' => array( - 'handler' => 'views_handler_field_numeric', - 'click sortable' => TRUE, - ), - 'argument' => array( - 'handler' => 'views_handler_argument_numeric', - 'numeric' => TRUE, - ), - 'filter' => array( - 'handler' => 'views_handler_filter_numeric', - ), - 'sort' => array( - 'handler' => 'views_handler_sort', - ), - ); - - // iid + // Item ID / 'iid'. $data['aggregator_item']['iid'] = array( + // The item it appears as on the UI, 'title' => t('Item ID'), - 'help' => t('The unique ID of the aggregator item.'), // The help that appears on the UI, - // Information for displaying the iid + // The help that appears on the UI, + 'help' => t('The unique ID of the aggregator item.'), + // Information for displaying the iid. 'field' => array( 'handler' => 'views_handler_field_numeric', 'click sortable' => TRUE, ), - // Information for accepting a iid as an argument + // Information for accepting a iid as an argument. 'argument' => array( 'handler' => 'views_handler_argument_aggregator_iid', - 'name field' => 'title', // the field to display in the summary. + 'name field' => 'title', + // The field to display in the summary. 'numeric' => TRUE, ), - // Information for accepting a nid as a filter + // Information for accepting a nid as a filter. 'filter' => array( 'handler' => 'views_handler_filter_numeric', ), @@ -73,55 +54,58 @@ function aggregator_views_data() { ), ); - // title + // Title. $data['aggregator_item']['title'] = array( - 'title' => t('Title'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Title'), 'help' => t('The title of the aggregator item.'), - // Information for displaying a title as a field + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_aggregator_title_link', 'extra' => array('link'), 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), - // Information for accepting a title as a filter + // Information for accepting a title as a filter. 'filter' => array( 'handler' => 'views_handler_filter_string', ), ); - // link + // Link. $data['aggregator_item']['link'] = array( - 'title' => t('Link'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Link'), 'help' => t('The link to the original source URL of the item.'), 'field' => array( 'handler' => 'views_handler_field_url', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), - // Information for accepting a title as a filter + // Information for accepting a title as a filter. 'filter' => array( 'handler' => 'views_handler_filter_string', ), ); - // author + // Author. $data['aggregator_item']['author'] = array( - 'title' => t('Author'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Author'), 'help' => t('The author of the original imported item.'), - // Information for displaying a title as a field + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_aggregator_xss', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), - // Information for accepting a title as a filter + // Information for accepting a title as a filter. 'filter' => array( 'handler' => 'views_handler_filter_string', ), @@ -130,19 +114,20 @@ function aggregator_views_data() { ), ); - // guid + // 'guid'. $data['aggregator_item']['guid'] = array( - 'title' => t('GUID'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('GUID'), 'help' => t('The guid of the original imported item.'), - // Information for displaying a title as a field + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_xss', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), - // Information for accepting a title as a filter + // Information for accepting a title as a filter. 'filter' => array( 'handler' => 'views_handler_filter_string', ), @@ -151,34 +136,36 @@ function aggregator_views_data() { ), ); - // feed body + // Feed body. $data['aggregator_item']['description'] = array( - 'title' => t('Body'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Body'), 'help' => t('The actual content of the imported item.'), - // Information for displaying a title as a field + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_aggregator_xss', 'click sortable' => FALSE, - ), - // Information for accepting a title as a filter + ), + // Information for accepting a title as a filter. 'filter' => array( 'handler' => 'views_handler_filter_string', ), ); - // item timestamp + // Item timestamp. $data['aggregator_item']['timestamp'] = array( - 'title' => t('Timestamp'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Timestamp'), 'help' => t('The date the original feed item was posted. (With some feeds, this will be the date it was imported.)'), - // Information for displaying a title as a field + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_date', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort_date', ), - // Information for accepting a title as a filter + // Information for accepting a title as a filter. 'filter' => array( 'handler' => 'views_handler_filter_date', ), @@ -187,10 +174,8 @@ function aggregator_views_data() { ), ); - // ---------------------------------------------------------------------- - // Aggregator feed table - + // Aggregator feed table. $data['aggregator_feed']['table']['group'] = t('Aggregator feed'); // Explain how this table joins to others. @@ -201,22 +186,25 @@ function aggregator_views_data() { ), ); - // fid + // Feed ID / 'fid'. $data['aggregator_feed']['fid'] = array( + // The item it appears as on the UI, 'title' => t('Feed ID'), - 'help' => t('The unique ID of the aggregator feed.'), // The help that appears on the UI, - // Information for displaying the fid + // The help that appears on the UI, + 'help' => t('The unique ID of the aggregator feed.'), + // Information for displaying the fid. 'field' => array( 'handler' => 'views_handler_field_numeric', 'click sortable' => TRUE, ), - // Information for accepting a fid as an argument + // Information for accepting a fid as an argument. 'argument' => array( 'handler' => 'views_handler_argument_aggregator_fid', - 'name field' => 'title', // the field to display in the summary. + 'name field' => 'title', + // The field to display in the summary. 'numeric' => TRUE, ), - // Information for accepting a nid as a filter + // Information for accepting a nid as a filter. 'filter' => array( 'handler' => 'views_handler_filter_numeric', ), @@ -226,20 +214,22 @@ function aggregator_views_data() { ), ); - // title + // Title. $data['aggregator_feed']['title'] = array( - 'title' => t('Title'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Title'), + // The help that appears on the UI, 'help' => t('The title of the aggregator feed.'), - // Information for displaying a title as a field + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_aggregator_title_link', 'extra' => array('link'), 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), - // Information for accepting a title as a filter + // Information for accepting a title as a filter. 'filter' => array( 'handler' => 'views_handler_filter_string', ), @@ -248,15 +238,16 @@ function aggregator_views_data() { ), ); - // link + // Link. $data['aggregator_feed']['link'] = array( - 'title' => t('Link'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Link'), 'help' => t('The link to the source URL of the feed.'), - // Information for displaying a title as a field + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_url', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), @@ -265,15 +256,16 @@ function aggregator_views_data() { ), ); - // feed last updated + // Feed last updated. $data['aggregator_feed']['checked'] = array( - 'title' => t('Last checked'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Last checked'), 'help' => t('The date the feed was last checked for new content.'), - // Information for displaying a title as a field + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_date', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort_date', ), @@ -285,33 +277,35 @@ function aggregator_views_data() { ), ); - // feed description + // Feed description. $data['aggregator_feed']['description'] = array( - 'title' => t('Description'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Description'), 'help' => t('The description of the aggregator feed.'), - // Information for displaying a title as a field + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_xss', 'click sortable' => FALSE, - ), + ), 'filter' => array( 'handler' => 'views_handler_filter_string', ), ); - // feed last updated + // Feed last updated. $data['aggregator_feed']['modified'] = array( - 'title' => t('Last modified'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Last modified'), 'help' => t('The date of the most recent new content on the feed.'), - // Information for displaying a title as a field + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_date', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort_date', ), - // Information for accepting a title as a filter + // Information for accepting a title as a filter. 'filter' => array( 'handler' => 'views_handler_filter_date', ), @@ -321,8 +315,7 @@ function aggregator_views_data() { ); // ---------------------------------------------------------------------- - // Aggregator category feed table - + // Aggregator category feed table. $data['aggregator_category_feed']['table']['join'] = array( 'aggregator_item' => array( 'left_field' => 'fid', @@ -331,8 +324,7 @@ function aggregator_views_data() { ); // ---------------------------------------------------------------------- - // Aggregator category table - + // Aggregator category table. $data['aggregator_category']['table']['group'] = t('Aggregator category'); $data['aggregator_category']['table']['join'] = array( @@ -343,7 +335,7 @@ function aggregator_views_data() { ), ); - // cid + // Category ID / 'cid'. $data['aggregator_category']['cid'] = array( 'title' => t('Category ID'), 'help' => t('The unique ID of the aggregator category.'), @@ -364,14 +356,14 @@ function aggregator_views_data() { ), ); - // title + // Title. $data['aggregator_category']['title'] = array( 'title' => t('Category'), 'help' => t('The title of the aggregator category.'), 'field' => array( 'handler' => 'views_handler_field_aggregator_category', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), @@ -388,15 +380,18 @@ function aggregator_views_data() { */ function aggregator_views_plugins() { return array( - 'module' => 'views', // This just tells our themes are elsewhere. + 'module' => 'views', + // This just tells our themes are elsewhere. 'row' => array( 'aggregator_rss' => array( 'title' => t('Aggregator item'), 'help' => t('Display the aggregator item using the data from the original source.'), 'handler' => 'views_plugin_row_aggregator_rss', - 'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules + 'path' => drupal_get_path('module', 'views') . '/modules/node', + // Not necessary for most modules. 'theme' => 'views_view_row_rss', - 'base' => array('aggregator_item'), // only works with 'node' as base. + 'base' => array('aggregator_item'), + // Only works with 'node' as base. 'uses options' => TRUE, 'type' => 'feed', 'help topic' => 'style-aggregator-rss', diff --git a/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_category_cid.inc b/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_category_cid.inc index 92ae8b7..343201f 100644 --- a/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_category_cid.inc +++ b/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_category_cid.inc @@ -11,10 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_aggregator_category_cid extends views_handler_argument_numeric { + /** * Override the behavior of title(). Get the title of the category. */ - function title_query() { + public function title_query() { $titles = array(); $result = db_query("SELECT c.title FROM {aggregator_category} c WHERE c.cid IN (:cid)", array(':cid' => $this->value)); @@ -23,4 +24,5 @@ class views_handler_argument_aggregator_category_cid extends views_handler_argum } return $titles; } + } diff --git a/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_fid.inc b/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_fid.inc index 4147626..4c3f793 100644 --- a/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_fid.inc +++ b/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_fid.inc @@ -11,10 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_aggregator_fid extends views_handler_argument_numeric { + /** * Override the behavior of title(). Get the title of the feed. */ - function title_query() { + public function title_query() { $titles = array(); $result = db_query("SELECT f.title FROM {aggregator_feed} f WHERE f.fid IN (:fids)", array(':fids' => $this->value)); @@ -23,4 +24,5 @@ class views_handler_argument_aggregator_fid extends views_handler_argument_numer } return $titles; } + } diff --git a/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_iid.inc b/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_iid.inc index 4c7824e..edae517 100644 --- a/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_iid.inc +++ b/sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_iid.inc @@ -11,10 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_aggregator_iid extends views_handler_argument_numeric { + /** * Override the behavior of title(). Get the title of the category. */ - function title_query() { + public function title_query() { $titles = array(); $placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d')); @@ -27,4 +28,5 @@ class views_handler_argument_aggregator_iid extends views_handler_argument_numer } return $titles; } + } diff --git a/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_category.inc b/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_category.inc index 99fffa1..0630d0d 100644 --- a/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_category.inc +++ b/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_category.inc @@ -12,15 +12,19 @@ * @ingroup views_field_handlers */ class views_handler_field_aggregator_category extends views_handler_field { + /** * Constructor to provide additional field to add. */ - function construct() { + public function construct() { parent::construct(); $this->additional_fields['cid'] = 'cid'; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_category'] = array('default' => FALSE, 'bool' => TRUE); return $options; @@ -29,7 +33,7 @@ class views_handler_field_aggregator_category extends views_handler_field { /** * Provide link to category option */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['link_to_category'] = array( '#title' => t('Link this field to its aggregator category page'), '#description' => t('This will override any other link you have set.'), @@ -44,7 +48,7 @@ class views_handler_field_aggregator_category extends views_handler_field { * * Data should be made XSS safe prior to calling this function. */ - function render_link($data, $values) { + public function render_link($data, $values) { $cid = $this->get_value($values, 'cid'); if (!empty($this->options['link_to_category']) && !empty($cid) && $data !== NULL && $data !== '') { $this->options['alter']['make_link'] = TRUE; @@ -53,8 +57,12 @@ class views_handler_field_aggregator_category extends views_handler_field { return $data; } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->render_link($this->sanitize_value($value), $values); } + } diff --git a/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_title_link.inc b/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_title_link.inc index d8bf578..fee000e 100644 --- a/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_title_link.inc +++ b/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_title_link.inc @@ -6,18 +6,25 @@ */ /** - * Field handler that turns an item's title into a clickable link to the original - * source article. + * Field handler that turns an item's title into a clickable link to the + * original source article. * * @ingroup views_field_handlers */ class views_handler_field_aggregator_title_link extends views_handler_field { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['link'] = 'link'; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['display_as_link'] = array('default' => TRUE, 'bool' => TRUE); @@ -28,7 +35,7 @@ class views_handler_field_aggregator_title_link extends views_handler_field { /** * Provide link to the page being visited. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['display_as_link'] = array( '#title' => t('Display as link'), '#type' => 'checkbox', @@ -37,12 +44,18 @@ class views_handler_field_aggregator_title_link extends views_handler_field { parent::options_form($form, $form_state); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->render_link($this->sanitize_value($value), $values); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { $link = $this->get_value($values, 'link'); if (!empty($this->options['display_as_link'])) { $this->options['alter']['make_link'] = TRUE; @@ -52,4 +65,5 @@ class views_handler_field_aggregator_title_link extends views_handler_field { return $data; } + } diff --git a/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_xss.inc b/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_xss.inc index d39b101..66ecfc1 100644 --- a/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_xss.inc +++ b/sites/all/modules/views/modules/aggregator/views_handler_field_aggregator_xss.inc @@ -11,8 +11,13 @@ * @ingroup views_field_handlers */ class views_handler_field_aggregator_xss extends views_handler_field { - function render($values) { + + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return aggregator_filter_xss($value); } + } diff --git a/sites/all/modules/views/modules/aggregator/views_handler_filter_aggregator_category_cid.inc b/sites/all/modules/views/modules/aggregator/views_handler_filter_aggregator_category_cid.inc index f9931c8..a8757a9 100644 --- a/sites/all/modules/views/modules/aggregator/views_handler_filter_aggregator_category_cid.inc +++ b/sites/all/modules/views/modules/aggregator/views_handler_filter_aggregator_category_cid.inc @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_aggregator_category_cid extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { if (isset($this->value_options)) { return; } @@ -23,4 +27,5 @@ class views_handler_filter_aggregator_category_cid extends views_handler_filter_ $this->value_options[$category->cid] = $category->title; } } + } diff --git a/sites/all/modules/views/modules/aggregator/views_plugin_row_aggregator_rss.inc b/sites/all/modules/views/modules/aggregator/views_plugin_row_aggregator_rss.inc index 672952e..72e9418 100644 --- a/sites/all/modules/views/modules/aggregator/views_plugin_row_aggregator_rss.inc +++ b/sites/all/modules/views/modules/aggregator/views_plugin_row_aggregator_rss.inc @@ -2,17 +2,28 @@ /** * @file - * Contains the Aggregator Item RSS row style plugin. + * Definition of views_plugin_row_aggregator_rss. */ /** * Plugin which loads an aggregator item and formats it as an RSS item. */ class views_plugin_row_aggregator_rss extends views_plugin_row { - var $base_table = 'aggregator_item'; - var $base_field = 'iid'; - function option_definition() { + /** + * {@inheritdoc} + */ + public $base_table = 'aggregator_item'; + + /** + * {@inheritdoc} + */ + public $base_field = 'iid'; + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['item_length'] = array('default' => 'default'); @@ -20,7 +31,10 @@ class views_plugin_row_aggregator_rss extends views_plugin_row { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['item_length'] = array( '#type' => 'select', '#title' => t('Display type'), @@ -34,9 +48,12 @@ class views_plugin_row_aggregator_rss extends views_plugin_row { ); } - function render($row) { - $iid = $row->{$this->field_alias}; - $sql = "SELECT ai.iid, ai.fid, ai.title, ai.link, ai.author, ai.description, "; + /** + * {@inheritdoc} + */ + public function render($row) { + $iid = $row->{$this->field_alias}; + $sql = "SELECT ai.iid, ai.fid, ai.title, ai.link, ai.author, ai.description, "; $sql .= "ai.timestamp, ai.guid, af.title AS feed_title, ai.link AS feed_LINK "; $sql .= "FROM {aggregator_item} ai LEFT JOIN {aggregator_feed} af ON ai.fid = af.fid "; $sql .= "WHERE ai.iid = :iid"; @@ -55,7 +72,7 @@ class views_plugin_row_aggregator_rss extends views_plugin_row { array( 'key' => 'guid', 'value' => $item->guid, - 'attributes' => array('isPermaLink' => 'false') + 'attributes' => array('isPermaLink' => 'false'), ), ); @@ -68,7 +85,8 @@ class views_plugin_row_aggregator_rss extends views_plugin_row { return theme($this->theme_functions(), array( 'view' => $this->view, 'options' => $this->options, - 'row' => $item + 'row' => $item, )); } + } diff --git a/sites/all/modules/views/modules/book.views.inc b/sites/all/modules/views/modules/book.views.inc index 15a2183..87d5be6 100644 --- a/sites/all/modules/views/modules/book.views.inc +++ b/sites/all/modules/views/modules/book.views.inc @@ -12,8 +12,7 @@ */ function book_views_data() { // ---------------------------------------------------------------------- - // book table - + // 'book' table. $data['book']['table']['group'] = t('Book'); $data['book']['table']['join'] = array( 'node' => array( @@ -35,8 +34,7 @@ function book_views_data() { ); // ---------------------------------------------------------------------- - // menu_links table -- this is aliased so we can get just book relations - + // 'menu_links' table -- this is aliased so we can get just book relations. // Book hierarchy and weight data are now in {menu_links}. $data['book_menu_links']['table']['group'] = t('Book'); $data['book_menu_links']['table']['join'] = array( @@ -87,9 +85,8 @@ function book_views_data() { ); // ---------------------------------------------------------------------- - // book_parent table -- this is an alias of the book table which + // 'book_parent' table -- this is an alias of the book table which // represents the parent book. - // The {book} record for the parent node. $data['book_parent']['table']['group'] = t('Book'); $data['book_parent']['table']['join'] = array( @@ -119,13 +116,13 @@ function book_views_data() { * Implements hook_views_plugins(). */ function book_views_plugins() { - return array( - 'module' => 'views', - 'argument default' => array( - 'book_root' => array( - 'title' => t('Book root from current node'), - 'handler' => 'views_plugin_argument_default_book_root' - ), - ), - ); + return array( + 'module' => 'views', + 'argument default' => array( + 'book_root' => array( + 'title' => t('Book root from current node'), + 'handler' => 'views_plugin_argument_default_book_root', + ), + ), + ); } diff --git a/sites/all/modules/views/modules/book/views_plugin_argument_default_book_root.inc b/sites/all/modules/views/modules/book/views_plugin_argument_default_book_root.inc index 1ce3046..38ecc89 100644 --- a/sites/all/modules/views/modules/book/views_plugin_argument_default_book_root.inc +++ b/sites/all/modules/views/modules/book/views_plugin_argument_default_book_root.inc @@ -1,14 +1,19 @@ t('Title'), 'help' => t('The title of the comment.'), @@ -57,7 +55,7 @@ function comment_views_data() { ), ); - // cid + // Comment ID / 'cid'. $data['comment']['cid'] = array( 'title' => t('ID'), 'help' => t('The comment ID of the field'), @@ -76,7 +74,7 @@ function comment_views_data() { ), ); - // name (of comment author) + // Username of the comment author. $data['comment']['name'] = array( 'title' => t('Author'), 'help' => t("The name of the comment's author. Can be rendered as a link to the author's homepage."), @@ -95,7 +93,7 @@ function comment_views_data() { ), ); - // homepage + // Homepage. $data['comment']['homepage'] = array( 'title' => t("Author's website"), 'help' => t("The website address of the comment's author. Can be rendered as a link. Will be empty if the author is a registered user."), @@ -114,14 +112,14 @@ function comment_views_data() { ), ); - // hostname + // hostname. $data['comment']['hostname'] = array( 'title' => t('Hostname'), 'help' => t('Hostname of user that posted the comment.'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, - ), + ), 'filter' => array( 'handler' => 'views_handler_filter_string', ), @@ -133,14 +131,14 @@ function comment_views_data() { ), ); - // mail + // Email address. $data['comment']['mail'] = array( - 'title' => t('Mail'), - 'help' => t('Email of user that posted the comment. Will be empty if the author is a registered user.'), + 'title' => t('E-mail'), + 'help' => t('E-mail of user that posted the comment. Will be empty if the author is a registered user.'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, - ), + ), 'filter' => array( 'handler' => 'views_handler_filter_string', ), @@ -152,7 +150,7 @@ function comment_views_data() { ), ); - // created (when comment was posted) + // Created - when comment was posted. $data['comment']['created'] = array( 'title' => t('Post date'), 'help' => t('Date and time of when the comment was created.'), @@ -222,7 +220,7 @@ function comment_views_data() { ), ); - // Language field + // Language field. if (module_exists('locale')) { $data['comment']['language'] = array( 'title' => t('Language'), @@ -244,7 +242,7 @@ function comment_views_data() { } $data['comments']['timestamp']['moved to'] = array('comment', 'changed'); - // changed (when comment was last updated) + // Changed (when comment was last updated). $data['comment']['changed'] = array( 'title' => t('Updated date'), 'help' => t('Date and time of when the comment was last updated.'), @@ -320,9 +318,9 @@ function comment_views_data() { ), ); - // status (approved or not) + // Status (approved or not). $data['comment']['status'] = array( - 'title' => t('Approved'), + 'title' => t('Approved status'), 'help' => t('Whether the comment is approved (or still in the moderation queue).'), 'field' => array( 'handler' => 'views_handler_field_boolean', @@ -333,7 +331,7 @@ function comment_views_data() { ), 'filter' => array( 'handler' => 'views_handler_filter_boolean_operator', - 'label' => t('Approved comment'), + 'label' => t('Approved comment status'), 'type' => 'yes-no', ), 'sort' => array( @@ -341,47 +339,46 @@ function comment_views_data() { ), ); - // link to view comment + // Link to view comment. $data['comment']['view_comment'] = array( 'field' => array( - 'title' => t('View link'), + 'title' => t('Link to comment'), 'help' => t('Provide a simple link to view the comment.'), 'handler' => 'views_handler_field_comment_link', ), ); - // link to edit comment + // Link to edit comment. $data['comment']['edit_comment'] = array( 'field' => array( - 'title' => t('Edit link'), + 'title' => t('Link to edit comment'), 'help' => t('Provide a simple link to edit the comment.'), 'handler' => 'views_handler_field_comment_link_edit', ), ); - // link to delete comment + // Link to delete comment. $data['comment']['delete_comment'] = array( 'field' => array( - 'title' => t('Delete link'), + 'title' => t('Link to delete comment'), 'help' => t('Provide a simple link to delete the comment.'), 'handler' => 'views_handler_field_comment_link_delete', ), ); - - // link to approve comment + // Link to approve comment. $data['comment']['approve_comment'] = array( 'field' => array( - 'title' => t('Approve link'), + 'title' => t('Link to approve comment'), 'help' => t('Provide a simple link to approve the comment.'), 'handler' => 'views_handler_field_comment_link_approve', ), ); - // link to reply to comment + // Link to reply to comment. $data['comment']['replyto_comment'] = array( 'field' => array( - 'title' => t('Reply-to link'), + 'title' => t('Link to reply-to comment'), 'help' => t('Provide a simple link to reply to the comment.'), 'handler' => 'views_handler_field_comment_link_reply', ), @@ -422,6 +419,20 @@ function comment_views_data() { ), ); + $data['comment']['cid'] = array( + 'title' => t('Comment id'), + 'help' => t('Unique identifier for the comment.'), + 'filter' => array( + 'handler' => 'views_handler_filter_numeric', + ), + 'argument' => array( + 'handler' => 'views_handler_argument_numeric', + ), + 'field' => array( + 'handler' => 'views_handler_field_numeric', + ), + ); + $data['comment']['uid'] = array( 'title' => t('Author uid'), 'help' => t('If you need more fields than the uid add the comment: author relationship'), @@ -461,22 +472,21 @@ function comment_views_data() { ); // ---------------------------------------------------------------------- - // node_comment_statistics table - - // define the group + // 'node_comment_statistics' table. + // Define the group. $data['node_comment_statistics']['table']['group'] = t('Content'); - // joins + // Joins. $data['node_comment_statistics']['table']['join'] = array( - //...to the node table + // ...to the node table. 'node' => array( 'type' => 'INNER', 'left_field' => 'nid', 'field' => 'nid', - ), + ), ); - // last_comment_timestamp + // Timestamp of the last comment. $data['node_comment_statistics']['last_comment_timestamp'] = array( 'title' => t('Last comment time'), 'help' => t('Date and time of when the last comment was posted.'), @@ -492,7 +502,7 @@ function comment_views_data() { ), ); - // last_comment_name (author's name) + // Last comment author's username. $data['node_comment_statistics']['last_comment_name'] = array( 'title' => t("Last comment author"), 'help' => t('The name of the author of the last posted comment.'), @@ -507,7 +517,7 @@ function comment_views_data() { ), ); - // comment_count + // Comment count. $data['node_comment_statistics']['comment_count'] = array( 'title' => t('Comment count'), 'help' => t('The number of comments a node has.'), @@ -526,7 +536,7 @@ function comment_views_data() { ), ); - // last_comment_timestamp + // Timestamp of when the last comment update happened. $data['node_comment_statistics']['last_updated'] = array( 'title' => t('Updated/commented date'), 'help' => t('The most recent of last comment posted or node updated time.'), @@ -548,7 +558,7 @@ function comment_views_data() { 'title' => t('Last comment CID'), 'help' => t('Display the last comment of a node'), 'relationship' => array( - 'title' => t('Last Comment'), + 'title' => t('Last comment'), 'help' => t('The last comment of a node.'), 'group' => t('Comment'), 'base' => 'comment', @@ -558,7 +568,7 @@ function comment_views_data() { ), ); - // last_comment_uid + // The user ID / 'uid' of the user who last posted a comment. $data['node_comment_statistics']['last_comment_uid'] = array( 'title' => t('Last comment uid'), 'help' => t('The User ID of the author of the last comment of a node.'), @@ -584,11 +594,12 @@ function comment_views_data() { } /** - * Use views_data_alter to add items to the node table that are - * relevant to comments. + * Implements hook_views_data_alter() on behalf of comment.module. + * + * Add items to the node table that are relevant to comments. */ function comment_views_data_alter(&$data) { - // new comments + // New comments. $data['node']['new_comments'] = array( 'title' => t('New comments'), 'help' => t('The number of new comments on the node.'), @@ -606,7 +617,7 @@ function comment_views_data_alter(&$data) { ), ); - // Comment status of the node + // Comment status of the node. $data['node']['comment'] = array( 'title' => t('Comment status'), 'help' => t('Whether comments are enabled or disabled on the node.'), @@ -636,7 +647,7 @@ function comment_views_data_alter(&$data) { 'field' => 'uid', 'name table' => 'users', 'name field' => 'name', - 'handler' => 'views_handler_filter_comment_user_uid' + 'handler' => 'views_handler_filter_comment_user_uid', ), ); @@ -652,7 +663,6 @@ function comment_views_data_alter(&$data) { 'handler' => 'views_handler_relationship', ), ); - } /** @@ -667,8 +677,10 @@ function comment_views_plugins() { 'help' => t('Display the comment with standard comment view.'), 'handler' => 'views_plugin_row_comment_view', 'theme' => 'views_view_row_comment', - 'path' => drupal_get_path('module', 'views') . '/modules/comment', // not necessary for most modules - 'base' => array('comment'), // only works with 'comment' as base. + 'path' => drupal_get_path('module', 'views') . '/modules/comment', + // Not necessary for most modules. + 'base' => array('comment'), + // Only works with 'comment' as base. 'uses options' => TRUE, 'type' => 'normal', 'help topic' => 'style-comment', @@ -678,8 +690,10 @@ function comment_views_plugins() { 'help' => t('Display the comment as RSS.'), 'handler' => 'views_plugin_row_comment_rss', 'theme' => 'views_view_row_rss', - 'path' => drupal_get_path('module', 'views') . '/modules/comment', // not necessary for most modules - 'base' => array('comment'), // only works with 'comment' as base. + 'path' => drupal_get_path('module', 'views') . '/modules/comment', + // Not necessary for most modules. + 'base' => array('comment'), + // Only works with 'comment' as base. 'uses options' => TRUE, 'type' => 'feed', 'help topic' => 'style-comment-rss', @@ -689,7 +703,7 @@ function comment_views_plugins() { } /** - * Template helper for theme_views_view_row_comment + * Template helper for theme_views_view_row_comment. */ function template_preprocess_views_view_row_comment(&$vars) { $options = $vars['options']; @@ -701,9 +715,9 @@ function template_preprocess_views_view_row_comment(&$vars) { $node->view = &$view; $build = comment_view_multiple(array($comment->cid => $comment), $node, $plugin->options['view_mode']); - // If we're displaying the comments without links, remove them from the - // renderable array. There is no way to avoid building them in the first - // place (see comment_build_content()). + // If displaying the comments without links, remove them from the renderable + // array; there is no way to avoid building them in the first place. + // @see comment_build_content() if (empty($options['links'])) { foreach ($build as $cid => &$comment_build) { if (isset($comment_build['links'])) { diff --git a/sites/all/modules/views/modules/comment.views_default.inc b/sites/all/modules/views/modules/comment.views_default.inc index d0c4796..cee9227 100644 --- a/sites/all/modules/views/modules/comment.views_default.inc +++ b/sites/all/modules/views/modules/comment.views_default.inc @@ -6,12 +6,12 @@ */ /** - * Implementation of hook_views_default_views() + * Implements hook_views_default_views(). */ function comment_views_default_views() { $views = array(); - $view = new view; + $view = new view(); $view->name = 'comments_recent'; $view->description = 'Contains a block and a page to list recent comments; the block will automatically link to the page, which displays the comment body as well as a link to the node.'; $view->tag = 'default'; @@ -122,7 +122,7 @@ function comment_views_default_views() { $views['comments_recent'] = $view; - $view = new view; + $view = new view(); $view->name = 'tracker'; $view->description = 'Shows all new activity on system.'; $view->tag = 'default'; diff --git a/sites/all/modules/views/modules/comment/views_handler_argument_comment_user_uid.inc b/sites/all/modules/views/modules/comment/views_handler_argument_comment_user_uid.inc index d821f32..7748b40 100644 --- a/sites/all/modules/views/modules/comment/views_handler_argument_comment_user_uid.inc +++ b/sites/all/modules/views/modules/comment/views_handler_argument_comment_user_uid.inc @@ -12,7 +12,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_comment_user_uid extends views_handler_argument { - function title() { + + /** + * {@inheritdoc} + */ + public function title() { if (!$this->argument) { $title = variable_get('anonymous', t('Anonymous')); } @@ -26,7 +30,10 @@ class views_handler_argument_comment_user_uid extends views_handler_argument { return check_plain($title); } - function default_actions($which = NULL) { + /** + * {@inheritdoc} + */ + public function default_actions($which = NULL) { // Disallow summary views on this argument. if (!$which) { $actions = parent::default_actions(); @@ -40,7 +47,10 @@ class views_handler_argument_comment_user_uid extends views_handler_argument { } } - function query($group_by = FALSE) { + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { $this->ensure_my_table(); $subselect = db_select('comment', 'c'); @@ -55,7 +65,11 @@ class views_handler_argument_comment_user_uid extends views_handler_argument { $this->query->add_where(0, $condition); } - function get_sort_name() { + /** + * {@inheritdoc} + */ + public function get_sort_name() { return t('Numerical', array(), array('context' => 'Sort order')); } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_comment.inc b/sites/all/modules/views/modules/comment/views_handler_field_comment.inc index 7ca3256..596bb4a 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_comment.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_comment.inc @@ -11,10 +11,11 @@ * @ingroup views_field_handlers */ class views_handler_field_comment extends views_handler_field { + /** * Override init function to provide generic option to link to comment. */ - function init(&$view, &$options) { + public function init(&$view, &$options) { parent::init($view, $options); if (!empty($this->options['link_to_comment'])) { $this->additional_fields['cid'] = 'cid'; @@ -22,7 +23,10 @@ class views_handler_field_comment extends views_handler_field { } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_comment'] = array('default' => TRUE, 'bool' => TRUE); $options['link_to_node'] = array('default' => FALSE, 'bool' => TRUE); @@ -31,9 +35,9 @@ class views_handler_field_comment extends views_handler_field { } /** - * Provide link-to-comment option + * Provide link-to-comment option. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['link_to_comment'] = array( '#title' => t('Link this field to its comment'), '#description' => t("Enable to override this field's links."), @@ -48,7 +52,10 @@ class views_handler_field_comment extends views_handler_field { parent::options_form($form, $form_state); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { if (!empty($this->options['link_to_comment'])) { $this->options['alter']['make_link'] = TRUE; $nid = $this->get_value($values, 'nid'); @@ -58,7 +65,7 @@ class views_handler_field_comment extends views_handler_field { $this->options['alter']['fragment'] = "comment-" . $cid; } // If there is no comment link to the node. - else if ($this->options['link_to_node']) { + elseif ($this->options['link_to_node']) { $this->options['alter']['path'] = "node/" . $nid; } } @@ -66,8 +73,12 @@ class views_handler_field_comment extends views_handler_field { return $data; } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->render_link($this->sanitize_value($value), $values); } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_comment_depth.inc b/sites/all/modules/views/modules/comment/views_handler_field_comment_depth.inc index 4840a1e..8ea257d 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_comment_depth.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_comment_depth.inc @@ -11,11 +11,13 @@ * @ingroup views_field_handlers */ class views_handler_field_comment_depth extends views_handler_field { + /** - * Work out the depth of this comment + * Work out the depth of this comment. */ - function render($values) { + public function render($values) { $comment_thread = $this->get_value($values); return count(explode('.', $comment_thread)) - 1; } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_comment_link.inc b/sites/all/modules/views/modules/comment/views_handler_field_comment_link.inc index 162924e..26fd483 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_comment_link.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_comment_link.inc @@ -11,18 +11,21 @@ * @ingroup views_field_handlers */ class views_handler_field_comment_link extends views_handler_field_entity { - function construct() { - parent::construct(); - } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['text'] = array('default' => '', 'translatable' => TRUE); $options['link_to_node'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['text'] = array( '#type' => 'textfield', '#title' => t('Text to display'), @@ -36,17 +39,26 @@ class views_handler_field_comment_link extends views_handler_field_entity { parent::options_form($form, $form_state); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->add_additional_fields(); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values, 'cid'); return $this->render_link($this->sanitize_value($value), $values); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { $text = !empty($this->options['text']) ? $this->options['text'] : t('view'); $comment = $this->get_value($values); $nid = $comment->nid; @@ -60,10 +72,11 @@ class views_handler_field_comment_link extends views_handler_field_entity { $this->options['alter']['fragment'] = "comment-" . $cid; } // If there is no comment link to the node. - else if ($this->options['link_to_node']) { + elseif ($this->options['link_to_node']) { $this->options['alter']['path'] = "node/" . $nid; } return $text; } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_comment_link_approve.inc b/sites/all/modules/views/modules/comment/views_handler_field_comment_link_approve.inc index 0953d0c..6776a6c 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_comment_link_approve.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_comment_link_approve.inc @@ -11,12 +11,19 @@ * @ingroup views_field_handlers */ class views_handler_field_comment_link_approve extends views_handler_field_comment_link { - function access() { - //needs permission to administer comments in general + + /** + * {@inheritdoc} + */ + public function access() { + // Needs permission to administer comments in general. return user_access('administer comments'); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { $status = $this->get_value($values, 'status'); // Don't show an approve link on published nodes. @@ -25,7 +32,7 @@ class views_handler_field_comment_link_approve extends views_handler_field_comme } $text = !empty($this->options['text']) ? $this->options['text'] : t('approve'); - $cid = $this->get_value($values, 'cid'); + $cid = $this->get_value($values, 'cid'); $this->options['alter']['make_link'] = TRUE; $this->options['alter']['path'] = "comment/" . $cid . "/approve"; @@ -33,4 +40,5 @@ class views_handler_field_comment_link_approve extends views_handler_field_comme return $text; } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_comment_link_delete.inc b/sites/all/modules/views/modules/comment/views_handler_field_comment_link_delete.inc index c55ac1c..ade8cb9 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_comment_link_delete.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_comment_link_delete.inc @@ -11,14 +11,21 @@ * @ingroup views_field_handlers */ class views_handler_field_comment_link_delete extends views_handler_field_comment_link { - function access() { - //needs permission to administer comments in general + + /** + * {@inheritdoc} + */ + public function access() { + // Needs permission to administer comments in general. return user_access('administer comments'); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { $text = !empty($this->options['text']) ? $this->options['text'] : t('delete'); - $cid = $this->get_value($values, 'cid'); + $cid = $this->get_value($values, 'cid'); $this->options['alter']['make_link'] = TRUE; $this->options['alter']['path'] = "comment/" . $cid . "/delete"; @@ -26,4 +33,5 @@ class views_handler_field_comment_link_delete extends views_handler_field_commen return $text; } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_comment_link_edit.inc b/sites/all/modules/views/modules/comment/views_handler_field_comment_link_edit.inc index 0b06c0e..96df9dc 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_comment_link_edit.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_comment_link_edit.inc @@ -11,14 +11,21 @@ * @ingroup views_field_handlers */ class views_handler_field_comment_link_edit extends views_handler_field_comment_link { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['destination'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['destination'] = array( @@ -30,9 +37,12 @@ class views_handler_field_comment_link_edit extends views_handler_field_comment_ ); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { parent::render_link($data, $values); - // ensure user has access to edit this comment. + // Ensure user has access to edit this comment. $comment = $this->get_value($values); if (!comment_access('edit', $comment)) { return; @@ -49,4 +59,5 @@ class views_handler_field_comment_link_edit extends views_handler_field_comment_ return $text; } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_comment_link_reply.inc b/sites/all/modules/views/modules/comment/views_handler_field_comment_link_reply.inc index 47d0f17..aa2d7da 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_comment_link_reply.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_comment_link_reply.inc @@ -11,19 +11,27 @@ * @ingroup views_field_handlers */ class views_handler_field_comment_link_reply extends views_handler_field_comment_link { - function access() { - //check for permission to reply to comments + + /** + * {@inheritdoc} + */ + public function access() { + // Check for permission to reply to comments. return user_access('post comments'); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { $text = !empty($this->options['text']) ? $this->options['text'] : t('reply'); - $nid = $this->get_value($values, 'nid'); - $cid = $this->get_value($values, 'cid'); + $nid = $this->get_value($values, 'nid'); + $cid = $this->get_value($values, 'cid'); $this->options['alter']['make_link'] = TRUE; $this->options['alter']['path'] = "comment/reply/" . $nid . '/' . $cid; return $text; } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_comment_node_link.inc b/sites/all/modules/views/modules/comment/views_handler_field_comment_node_link.inc index 7feecfb..0e5ab6d 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_comment_node_link.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_comment_node_link.inc @@ -11,10 +11,14 @@ * @ingroup views_field_handlers */ class views_handler_field_comment_node_link extends views_handler_field_entity { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); - // Add the node fields that comment_link will need.. + // Add the node fields that comment_link will need. $this->additional_fields['nid'] = array( 'field' => 'nid', ); @@ -26,13 +30,19 @@ class views_handler_field_comment_node_link extends views_handler_field_entity { ); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['teaser'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['teaser'] = array( '#type' => 'checkbox', '#title' => t('Show teaser-style link'), @@ -43,22 +53,32 @@ class views_handler_field_comment_node_link extends views_handler_field_entity { parent::options_form($form, $form_state); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->add_additional_fields(); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { // Build fake $node. $node = $this->get_value($values); - // Call comment.module's hook_link: comment_link($type, $node = NULL, $teaser = FALSE) - // Call node by reference so that something is changed here + // Call comment.module's hook_link: + // comment_link($type, $node = NULL, $teaser = FALSE) + // Call node by reference so that something is changed here. comment_node_view($node, $this->options['teaser'] ? 'teaser' : 'full'); - // question: should we run these through: drupal_alter('link', $links, $node); - // might this have unexpected consequences if these hooks expect items in $node that we don't have? + // Question: should we run these through: + // drupal_alter('link', $links, $node); + // Might this have unexpected consequences if these hooks expect items in + // $node that we don't have? // Only render the links, if they are defined. return !empty($node->content['links']['comment']) ? drupal_render($node->content['links']['comment']) : ''; } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_comment_username.inc b/sites/all/modules/views/modules/comment/views_handler_field_comment_username.inc index 887a74e..7198d26 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_comment_username.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_comment_username.inc @@ -11,22 +11,29 @@ * @ingroup views_field_handlers */ class views_handler_field_comment_username extends views_handler_field { + /** * Override init function to add uid and homepage fields. */ - function init(&$view, &$data) { + public function init(&$view, &$data) { parent::init($view, $data); $this->additional_fields['uid'] = 'uid'; $this->additional_fields['homepage'] = 'homepage'; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_user'] = array('default' => TRUE, 'bool' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['link_to_user'] = array( '#title' => t("Link this field to its user or an author's homepage"), '#type' => 'checkbox', @@ -35,7 +42,10 @@ class views_handler_field_comment_username extends views_handler_field { parent::options_form($form, $form_state); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { if (!empty($this->options['link_to_user'])) { $account = new stdClass(); $account->uid = $this->get_value($values, 'uid'); @@ -51,8 +61,12 @@ class views_handler_field_comment_username extends views_handler_field { } } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->render_link($this->sanitize_value($value), $values); } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_last_comment_timestamp.inc b/sites/all/modules/views/modules/comment/views_handler_field_last_comment_timestamp.inc index e7cf8bd..50dd8d1 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_last_comment_timestamp.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_last_comment_timestamp.inc @@ -6,17 +6,24 @@ */ /** - * Field handler to display the timestamp of a comment with the count of comments. + * Field handler to display the timestamp of a comment with the comments count. * * @ingroup views_field_handlers */ class views_handler_field_last_comment_timestamp extends views_handler_field_date { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['comment_count'] = 'comment_count'; } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $comment_count = $this->get_value($values, 'comment_count'); if (empty($this->options['empty_zero']) || $comment_count) { return parent::render($values); @@ -25,4 +32,5 @@ class views_handler_field_last_comment_timestamp extends views_handler_field_dat return NULL; } } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_ncs_last_comment_name.inc b/sites/all/modules/views/modules/comment/views_handler_field_ncs_last_comment_name.inc index c9c6885..f38d3eb 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_ncs_last_comment_name.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_ncs_last_comment_name.inc @@ -11,17 +11,22 @@ * @ingroup views_field_handlers */ class views_handler_field_ncs_last_comment_name extends views_handler_field { - function query() { - // last_comment_name only contains data if the user is anonymous. So we - // have to join in a specially related user table. + + /** + * {@inheritdoc} + */ + public function query() { + // 'last_comment_name' only contains data if the user is anonymous, so join + // in a specially related user table. $this->ensure_my_table(); - // join 'users' to this table via vid + // Join 'users' to this table via vid. $join = new views_join(); $join->construct('users', $this->table_alias, 'last_comment_uid', 'uid'); $join->extra = array(array('field' => 'uid', 'operator' => '!=', 'value' => '0')); - // ncs_user alias so this can work with the sort handler, below. -// $this->user_table = $this->query->add_relationship(NULL, $join, 'users', $this->relationship); + // 'ncs_user' alias so this can work with the sort handler, below. + // $this->user_table = $this->query + // ->add_relationship(NULL, $join, 'users', $this->relationship); $this->user_table = $this->query->ensure_table('ncs_users', $this->relationship, $join); $this->field_alias = $this->query->add_field(NULL, "COALESCE($this->user_table.name, $this->table_alias.$this->field)", $this->table_alias . '_' . $this->field); @@ -30,7 +35,10 @@ class views_handler_field_ncs_last_comment_name extends views_handler_field { $this->uid = $this->query->add_field($this->table_alias, 'last_comment_uid'); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_user'] = array('default' => TRUE, 'bool' => TRUE); @@ -38,7 +46,10 @@ class views_handler_field_ncs_last_comment_name extends views_handler_field { return $options; } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { if (!empty($this->options['link_to_user'])) { $account = new stdClass(); $account->name = $this->get_value($values); @@ -51,4 +62,5 @@ class views_handler_field_ncs_last_comment_name extends views_handler_field { return $this->sanitize_value($this->get_value($values)); } } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_ncs_last_updated.inc b/sites/all/modules/views/modules/comment/views_handler_field_ncs_last_updated.inc index d1d7306..4d13551 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_ncs_last_updated.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_ncs_last_updated.inc @@ -4,15 +4,21 @@ * @file * Definition of views_handler_field_ncs_last_updated. */ + /** * Field handler to display the newer of last comment / node updated. * * @ingroup views_field_handlers */ class views_handler_field_ncs_last_updated extends views_handler_field_date { - function query() { + + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->node_table = $this->query->ensure_table('node', $this->relationship); $this->field_alias = $this->query->add_field(NULL, "GREATEST(" . $this->node_table . ".changed, " . $this->table_alias . ".last_comment_timestamp)", $this->table_alias . '_' . $this->field); } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_node_comment.inc b/sites/all/modules/views/modules/comment/views_handler_field_node_comment.inc index d863c44..c76adbf 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_node_comment.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_node_comment.inc @@ -11,7 +11,11 @@ * @ingroup views_field_handlers */ class views_handler_field_node_comment extends views_handler_field { - function render($values) { + + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); switch ($value) { case COMMENT_NODE_HIDDEN: @@ -23,4 +27,5 @@ class views_handler_field_node_comment extends views_handler_field { return t('Open'); } } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_field_node_new_comments.inc b/sites/all/modules/views/modules/comment/views_handler_field_node_new_comments.inc index 70b0581..776237a 100644 --- a/sites/all/modules/views/modules/comment/views_handler_field_node_new_comments.inc +++ b/sites/all/modules/views/modules/comment/views_handler_field_node_new_comments.inc @@ -11,24 +11,34 @@ * @ingroup views_field_handlers */ class views_handler_field_node_new_comments extends views_handler_field_numeric { - function init(&$view, &$options) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); - // translate an older setting: + // Translate an older setting. if (!empty($options['no_empty'])) { $this->options['hide_empty'] = TRUE; unset($this->options['no_empty']); } } - function construct() { + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['nid'] = 'nid'; $this->additional_fields['type'] = 'type'; $this->additional_fields['comment_count'] = array('table' => 'node_comment_statistics', 'field' => 'comment_count'); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_comment'] = array('default' => TRUE, 'bool' => TRUE); @@ -36,7 +46,10 @@ class views_handler_field_node_new_comments extends views_handler_field_numeric return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['link_to_comment'] = array( '#title' => t('Link this field to new comments'), '#description' => t("Enable to override this field's links."), @@ -47,13 +60,19 @@ class views_handler_field_node_new_comments extends views_handler_field_numeric parent::options_form($form, $form_state); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->add_additional_fields(); $this->field_alias = $this->table . '_' . $this->field; } - function pre_render(&$values) { + /** + * {@inheritdoc} + */ + public function pre_render(&$values) { global $user; if (!$user->uid || empty($values)) { return; @@ -89,7 +108,10 @@ class views_handler_field_node_new_comments extends views_handler_field_numeric } } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { if (!empty($this->options['link_to_comment']) && $data !== NULL && $data !== '') { $node = new stdClass(); $node->nid = $this->get_value($values, 'nid'); @@ -103,7 +125,10 @@ class views_handler_field_node_new_comments extends views_handler_field_numeric return $data; } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); if (!empty($value)) { return $this->render_link(parent::render($values), $values); @@ -112,4 +137,5 @@ class views_handler_field_node_new_comments extends views_handler_field_numeric $this->options['alter']['make_link'] = FALSE; } } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_filter_comment_user_uid.inc b/sites/all/modules/views/modules/comment/views_handler_filter_comment_user_uid.inc index e76ebb7..199a33c 100644 --- a/sites/all/modules/views/modules/comment/views_handler_filter_comment_user_uid.inc +++ b/sites/all/modules/views/modules/comment/views_handler_filter_comment_user_uid.inc @@ -12,7 +12,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_comment_user_uid extends views_handler_filter_user_name { - function query() { + + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $subselect = db_select('comment', 'c'); @@ -26,4 +30,5 @@ class views_handler_filter_comment_user_uid extends views_handler_filter_user_na $this->query->add_where($this->options['group'], $condition); } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_filter_ncs_last_updated.inc b/sites/all/modules/views/modules/comment/views_handler_filter_ncs_last_updated.inc index 2319edf..e696390 100644 --- a/sites/all/modules/views/modules/comment/views_handler_filter_ncs_last_updated.inc +++ b/sites/all/modules/views/modules/comment/views_handler_filter_ncs_last_updated.inc @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_ncs_last_updated extends views_handler_filter_date { - function query() { + + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->node_table = $this->query->ensure_table('node', $this->relationship); @@ -22,4 +26,5 @@ class views_handler_filter_ncs_last_updated extends views_handler_filter_date { $this->{$info[$this->operator]['method']}($field); } } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_filter_node_comment.inc b/sites/all/modules/views/modules/comment/views_handler_filter_node_comment.inc index befce10..6a19948 100644 --- a/sites/all/modules/views/modules/comment/views_handler_filter_node_comment.inc +++ b/sites/all/modules/views/modules/comment/views_handler_filter_node_comment.inc @@ -11,11 +11,16 @@ * @ingroup views_filter_handlers */ class views_handler_filter_node_comment extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { $this->value_options = array( COMMENT_NODE_HIDDEN => t('Hidden'), COMMENT_NODE_CLOSED => t('Closed'), COMMENT_NODE_OPEN => t('Open'), ); } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_sort_comment_thread.inc b/sites/all/modules/views/modules/comment/views_handler_sort_comment_thread.inc index e513a93..1251859 100644 --- a/sites/all/modules/views/modules/comment/views_handler_sort_comment_thread.inc +++ b/sites/all/modules/views/modules/comment/views_handler_sort_comment_thread.inc @@ -11,18 +11,23 @@ * @ingroup views_sort_handlers */ class views_handler_sort_comment_thread extends views_handler_sort { - function query() { + + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); - //Read comment_render() in comment.module for an explanation of the - //thinking behind this sort. + // Read comment_render() in comment.module for an explanation of the + // thinking behind this sort. if ($this->options['order'] == 'DESC') { $this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']); } else { $alias = $this->table_alias . '_' . $this->real_field . 'asc'; - //@todo is this secure? + // @todo Is this secure? $this->query->add_orderby(NULL, "SUBSTRING({$this->table_alias}.{$this->real_field}, 1, (LENGTH({$this->table_alias}.{$this->real_field}) - 1))", $this->options['order'], $alias); } } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_sort_ncs_last_comment_name.inc b/sites/all/modules/views/modules/comment/views_handler_sort_ncs_last_comment_name.inc index 613045a..cdb9fc5 100644 --- a/sites/all/modules/views/modules/comment/views_handler_sort_ncs_last_comment_name.inc +++ b/sites/all/modules/views/modules/comment/views_handler_sort_ncs_last_comment_name.inc @@ -6,25 +6,30 @@ */ /** - * Sort handler to sort by last comment name which might be in 2 different - * fields. + * Sort by last comment name, which might be in two different fields. * * @ingroup views_sort_handlers */ class views_handler_sort_ncs_last_comment_name extends views_handler_sort { - function query() { + + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $join = new views_join(); $join->construct('users', $this->table_alias, 'last_comment_uid', 'uid'); - // @todo this might be safer if we had an ensure_relationship rather than guessing - // the table alias. Though if we did that we'd be guessing the relationship name - // so that doesn't matter that much. -// $this->user_table = $this->query->add_relationship(NULL, $join, 'users', $this->relationship); + // @todo This might be safer if we had an ensure_relationship rather than + // guessing the table alias. Though if we did that we'd be guessing the + // relationship name so that doesn't matter that much. + // $this->user_table = $this->query + // ->add_relationship(NULL, $join, 'users', $this->relationship); $this->user_table = $this->query->ensure_table('ncs_users', $this->relationship, $join); $this->user_field = $this->query->add_field($this->user_table, 'name'); // Add the field. $this->query->add_orderby(NULL, "LOWER(COALESCE($this->user_table.name, $this->table_alias.$this->field))", $this->options['order'], $this->table_alias . '_' . $this->field); } + } diff --git a/sites/all/modules/views/modules/comment/views_handler_sort_ncs_last_updated.inc b/sites/all/modules/views/modules/comment/views_handler_sort_ncs_last_updated.inc index 83f0f54..fca3532 100644 --- a/sites/all/modules/views/modules/comment/views_handler_sort_ncs_last_updated.inc +++ b/sites/all/modules/views/modules/comment/views_handler_sort_ncs_last_updated.inc @@ -11,9 +11,14 @@ * @ingroup views_sort_handlers */ class views_handler_sort_ncs_last_updated extends views_handler_sort_date { - function query() { + + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->node_table = $this->query->ensure_table('node', $this->relationship); $this->field_alias = $this->query->add_orderby(NULL, "GREATEST(" . $this->node_table . ".changed, " . $this->table_alias . ".last_comment_timestamp)", $this->options['order'], $this->table_alias . '_' . $this->field); } + } diff --git a/sites/all/modules/views/modules/comment/views_plugin_row_comment_rss.inc b/sites/all/modules/views/modules/comment/views_plugin_row_comment_rss.inc index e349590..33b6a40 100644 --- a/sites/all/modules/views/modules/comment/views_plugin_row_comment_rss.inc +++ b/sites/all/modules/views/modules/comment/views_plugin_row_comment_rss.inc @@ -2,17 +2,28 @@ /** * @file - * Contains the comment RSS row style plugin. + * Definition of views_plugin_row_comment_rss. */ /** * Plugin which formats the comments as RSS items. */ class views_plugin_row_comment_rss extends views_plugin_row { - var $base_table = 'comment'; - var $base_field = 'cid'; - function option_definition() { + /** + * {@inheritdoc} + */ + public $base_table = 'comment'; + + /** + * {@inheritdoc} + */ + public $base_field = 'cid'; + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['item_length'] = array('default' => 'default'); @@ -21,7 +32,10 @@ class views_plugin_row_comment_rss extends views_plugin_row { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['item_length'] = array( @@ -37,8 +51,10 @@ class views_plugin_row_comment_rss extends views_plugin_row { ); } - - function pre_render($result) { + /** + * {@inheritdoc} + */ + public function pre_render($result) { $cids = array(); $nids = array(); @@ -59,10 +75,10 @@ class views_plugin_row_comment_rss extends views_plugin_row { * Return the main options, which are shown in the summary title * * @see views_plugin_row_node_rss::options_form_summary_options() - * @todo: Maybe provide a views_plugin_row_rss_entity and reuse this method + * @todo Maybe provide a views_plugin_row_rss_entity and reuse this method * in views_plugin_row_comment|node_rss.inc */ - function options_form_summary_options() { + public function options_form_summary_options() { $entity_info = entity_get_info('node'); $options = array(); if (!empty($entity_info['view modes'])) { @@ -75,8 +91,10 @@ class views_plugin_row_comment_rss extends views_plugin_row { return $options; } - - function render($row) { + /** + * {@inheritdoc} + */ + public function render($row) { global $base_url; $cid = $row->{$this->field_alias}; @@ -89,7 +107,7 @@ class views_plugin_row_comment_rss extends views_plugin_row { $item_length = variable_get('feed_item_length', 'teaser'); } - // Load the specified comment and its associated node: + // Load the specified comment and its associated node. $comment = $this->comments[$cid]; if (empty($comment) || empty($this->nodes[$comment->nid])) { return; @@ -149,4 +167,5 @@ class views_plugin_row_comment_rss extends views_plugin_row { 'row' => $item )); } + } diff --git a/sites/all/modules/views/modules/comment/views_plugin_row_comment_view.inc b/sites/all/modules/views/modules/comment/views_plugin_row_comment_view.inc index f78fa36..3895e9c 100644 --- a/sites/all/modules/views/modules/comment/views_plugin_row_comment_view.inc +++ b/sites/all/modules/views/modules/comment/views_plugin_row_comment_view.inc @@ -2,38 +2,55 @@ /** * @file - * Contains the node RSS row style plugin. + * Definition of views_plugin_row_comment_view. */ /** * Plugin which performs a comment_view on the resulting object. */ class views_plugin_row_comment_view extends views_plugin_row { - var $base_field = 'cid'; - var $base_table = 'comment'; + + /** + * {@inheritdoc} + */ + public $base_field = 'cid'; + + /** + * {@inheritdoc} + */ + public $base_table = 'comment'; /** * Stores all comments which are preloaded. */ - var $comments = array(); + public $comments = array(); /** * Stores all nodes of all comments which are preloaded. */ - var $nodes = array(); + public $nodes = array(); - function summary_title() { + /** + * {@inheritdoc} + */ + public function summary_title() { return t('Settings'); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['links'] = array('default' => TRUE, 'bool' => TRUE); $options['view_mode'] = array('default' => 'full'); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $options = $this->options_form_summary_options(); @@ -51,11 +68,10 @@ class views_plugin_row_comment_view extends views_plugin_row { ); } - /** * Return the main options, which are shown in the summary title. */ - function options_form_summary_options() { + public function options_form_summary_options() { $entity_info = entity_get_info('comment'); $options = array(); if (!empty($entity_info['view modes'])) { @@ -72,7 +88,10 @@ class views_plugin_row_comment_view extends views_plugin_row { return $options; } - function pre_render($result) { + /** + * {@inheritdoc} + */ + public function pre_render($result) { $cids = array(); foreach ($result as $row) { @@ -94,4 +113,5 @@ class views_plugin_row_comment_view extends views_plugin_row { $this->nodes[$node->nid] = $node; } } + } diff --git a/sites/all/modules/views/modules/contact/views_handler_field_contact_link.inc b/sites/all/modules/views/modules/contact/views_handler_field_contact_link.inc index 9d22f01..c8db429 100644 --- a/sites/all/modules/views/modules/contact/views_handler_field_contact_link.inc +++ b/sites/all/modules/views/modules/contact/views_handler_field_contact_link.inc @@ -12,21 +12,30 @@ */ class views_handler_field_contact_link extends views_handler_field_user_link { - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['text']['#title'] = t('Link label'); $form['text']['#required'] = TRUE; $form['text']['#default_value'] = empty($this->options['text']) ? t('contact') : $this->options['text']; parent::options_form($form, $form_state); } - // An example of field level access control. - // We must override the access method in the parent class, as that requires - // the 'access user profiles' permission, which the contact form does not. - function access() { + /** + * An example of field level access control. + * + * We must override the access method in the parent class, as that requires + * the 'access user profiles' permission, which the contact form does not. + */ + public function access() { return user_access('access user contact forms'); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { global $user; $uid = $this->get_value($values, 'uid'); @@ -54,4 +63,5 @@ class views_handler_field_contact_link extends views_handler_field_user_link { return $text; } + } diff --git a/sites/all/modules/views/modules/field.views.inc b/sites/all/modules/views/modules/field.views.inc index eae7f6d..9f19374 100644 --- a/sites/all/modules/views/modules/field.views.inc +++ b/sites/all/modules/views/modules/field.views.inc @@ -108,7 +108,14 @@ function field_views_field_default_views_data($field) { $revision_tables = array(); $groups = array(); - $group_name = count($field['bundles']) > 1 ? t('Field') : NULL; + // Store translations to avoid being called thousands of times. + $translations['no_value_bracket'] = t(''); + $translations['no_value_dash'] = t('- No value -'); + $translations['field'] = t('Field'); + $translations['node'] = t('Node'); + $translations['content'] = t('Content'); + + $group_name = count($field['bundles']) > 1 ? $translations['field'] : NULL; // Build the relationships between the field table and the entity tables. foreach ($field['bundles'] as $entity => $bundles) { @@ -116,8 +123,8 @@ function field_views_field_default_views_data($field) { $groups[$entity] = $entity_info['label']; // Override Node to Content. - if ($groups[$entity] == t('Node')) { - $groups[$entity] = t('Content'); + if ($groups[$entity] == $translations['node']) { + $groups[$entity] = $translations['content']; } // If only one bundle use this as the default name. @@ -175,6 +182,15 @@ function field_views_field_default_views_data($field) { // and take the one which is used the most frequently. $field_name = $field['field_name']; list($label, $all_labels) = field_views_field_label($field_name); + + $bundle_names_text = implode(', ', $bundles_names); + $translations['appears_in_help'] = t('Appears in: @bundles.', array('@bundles' => $bundle_names_text)); + $translations['delta_appears_in_help'] = t('Delta - Appears in: @bundles.', array('@bundles' => $bundle_names_text)); + $translations['language_appears_in_help'] = t('Language - Appears in: @bundles.', array('@bundles' => $bundle_names_text)); + $translations['group_historical'] = t('@group (historical data)', array('@group' => $group_name)); + $translations['alias_help'] = t('This is an alias of @group: @field.', array('@group' => $group_name, '@field' => $label)); + $translations['label_short_language'] = t('@label:language', array('@label' => $label)); + foreach ($tables as $type => $table) { if ($type == FIELD_LOAD_CURRENT) { $group = $group_name; @@ -182,7 +198,7 @@ function field_views_field_default_views_data($field) { $column = $field['field_name']; } else { - $group = t('@group (historical data)', array('@group' => $group_name)); + $group = $translations['group_historical']; $old_column = 'revision_id'; $column = $field['field_name'] . '-' . $old_column; } @@ -192,7 +208,7 @@ function field_views_field_default_views_data($field) { 'group' => $group, 'title' => $label, 'title short' => $label, - 'help' => t('Appears in: @bundles.', array('@bundles' => implode(', ', $bundles_names))), + 'help' => $translations['appears_in_help'], ); // Go through and create a list of aliases for all possible combinations of @@ -207,7 +223,7 @@ function field_views_field_default_views_data($field) { 'base' => $current_tables[$entity_name], 'group' => $groups[$entity_name], 'title' => $label_name, - 'help' => t('This is an alias of @group: @field.', array('@group' => $group_name, '@field' => $label)), + 'help' => $translations['alias_help'], ); } $also_known[] = t('@group: @field', array('@group' => $groups[$entity_name], '@field' => $label_name)); @@ -218,7 +234,7 @@ function field_views_field_default_views_data($field) { 'base' => $revision_tables[$entity_name], 'group' => t('@group (historical data)', array('@group' => $groups[$entity_name])), 'title' => $label_name, - 'help' => t('This is an alias of @group: @field.', array('@group' => $group_name, '@field' => $label)), + 'help' => $translations['alias_help'], ); } $also_known[] = t('@group (historical data): @field', array('@group' => $groups[$entity_name], '@field' => $label_name)); @@ -250,7 +266,8 @@ function field_views_field_default_views_data($field) { foreach ($field['columns'] as $column => $attributes) { $allow_sort = TRUE; - // Identify likely filters and arguments for each column based on field type. + // Identify likely filters and arguments for each column based on field + // type. switch ($attributes['type']) { case 'int': case 'mediumint': @@ -263,6 +280,7 @@ function field_views_field_default_views_data($field) { $argument = 'views_handler_argument_numeric'; $sort = 'views_handler_sort'; break; + case 'text': case 'blob': // It does not make sense to sort by blob or text. @@ -274,7 +292,6 @@ function field_views_field_default_views_data($field) { break; } - if (count($field['columns']) == 1 || $column == 'value') { $title = t('@label (!name)', array('@label' => $label, '!name' => $field['field_name'])); // CCK used the first 10 characters of $label. Probably doesn't matter. @@ -290,7 +307,7 @@ function field_views_field_default_views_data($field) { $group = $group_name; } else { - $group = t('@group (historical data)', array('@group' => $group_name)); + $group = $translations['group_historical']; } $column_real_name = $field['storage']['details']['sql'][$type][$table][$column]; @@ -301,19 +318,20 @@ function field_views_field_default_views_data($field) { 'group' => $group, 'title' => $title, 'title short' => $title_short, - 'help' => t('Appears in: @bundles.', array('@bundles' => implode(', ', $bundles_names))), + 'help' => $translations['appears_in_help'], ); - // Go through and create a list of aliases for all possible combinations of - // entity type + name. + // Go through and create a list of aliases for all possible combinations + // of entity type + name. $aliases = array(); $also_known = array(); foreach ($all_labels as $entity_name => $labels) { foreach ($labels as $label_name => $true) { if ($group_name != $groups[$entity_name] || $label != $label_name) { if (count($field['columns']) == 1 || $column == 'value') { + // CCK used the first 10 characters of $label. Probably doesn't + // matter. $alias_title = t('@label (!name)', array('@label' => $label_name, '!name' => $field['field_name'])); - // CCK used the first 10 characters of $label. Probably doesn't matter. } else { $alias_title = t('@label (!name:!column)', array('@label' => $label_name, '!name' => $field['field_name'], '!column' => $column)); @@ -338,7 +356,7 @@ function field_views_field_default_views_data($field) { 'handler' => $argument, 'additional fields' => $additional_fields, 'field_name' => $field['field_name'], - 'empty field name' => t('- No value -'), + 'empty field name' => $translations['no_value_dash'], ); $data[$table][$column_real_name]['filter'] = array( 'field' => $column_real_name, @@ -367,7 +385,7 @@ function field_views_field_default_views_data($field) { 'group' => $group, 'title' => $title_delta, 'title short' => $title_short_delta, - 'help' => t('Delta - Appears in: @bundles.', array('@bundles' => implode(', ', $bundles_names))), + 'help' => $translations['delta_appears_in_help'], ); $data[$table]['delta']['field'] = array( 'handler' => 'views_handler_field_numeric', @@ -377,7 +395,7 @@ function field_views_field_default_views_data($field) { 'table' => $table, 'handler' => 'views_handler_argument_numeric', 'additional fields' => $additional_fields, - 'empty field name' => t('- No value -'), + 'empty field name' => $translations['no_value_dash'], 'field_name' => $field['field_name'], ); $data[$table]['delta']['filter'] = array( @@ -416,7 +434,7 @@ function field_views_field_default_views_data($field) { 'table' => $table, 'handler' => 'views_handler_argument_locale_language', 'additional fields' => $additional_fields, - 'empty field name' => t(''), + 'empty field name' => $translations['no_value_bracket'], 'field_name' => $field['field_name'], ); $data[$table]['language']['filter'] = array( @@ -442,7 +460,9 @@ function field_views_field_default_views_data($field) { } /** - * Have a different filter handler for lists. This should allow to select values of the list. + * Have a different filter handler for lists. + * + * This should allow to select values of the list. */ function list_field_views_data($field) { $data = field_views_field_default_views_data($field); diff --git a/sites/all/modules/views/modules/field/views_handler_argument_field_list.inc b/sites/all/modules/views/modules/field/views_handler_argument_field_list.inc index e0f7abe..5ae0d43 100644 --- a/sites/all/modules/views/modules/field/views_handler_argument_field_list.inc +++ b/sites/all/modules/views/modules/field/views_handler_argument_field_list.inc @@ -12,27 +12,37 @@ * @ingroup views_argument_handlers */ class views_handler_argument_field_list extends views_handler_argument_numeric { + /** * Stores the allowed values of this field. * * @var array */ - var $allowed_values = NULL; + public $allowed_values = NULL; - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); $field = field_info_field($this->definition['field_name']); $this->allowed_values = list_allowed_values($field); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['summary']['contains']['human'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['summary']['human'] = array( @@ -43,16 +53,19 @@ class views_handler_argument_field_list extends views_handler_argument_numeric { ); } - - function summary_name($data) { + /** + * {@inheritdoc} + */ + public function summary_name($data) { $value = $data->{$this->name_alias}; // If the list element has a human readable name show it, if (isset($this->allowed_values[$value]) && !empty($this->options['summary']['human'])) { return field_filter_xss($this->allowed_values[$value]); } - // else fallback to the key. + // Else fallback to the key. else { return check_plain($value); } } + } diff --git a/sites/all/modules/views/modules/field/views_handler_argument_field_list_string.inc b/sites/all/modules/views/modules/field/views_handler_argument_field_list_string.inc index 67a9f2d..fae7094 100644 --- a/sites/all/modules/views/modules/field/views_handler_argument_field_list_string.inc +++ b/sites/all/modules/views/modules/field/views_handler_argument_field_list_string.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_argument_field_list_text. + * Definition of views_handler_argument_field_list_string. */ /** @@ -12,20 +12,27 @@ * @ingroup views_argument_handlers */ class views_handler_argument_field_list_string extends views_handler_argument_string { + /** * Stores the allowed values of this field. * * @var array */ - var $allowed_values = NULL; + public $allowed_values = NULL; - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); $field = field_info_field($this->definition['field_name']); $this->allowed_values = list_allowed_values($field); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['summary']['contains']['human'] = array('default' => FALSE, 'bool' => TRUE); @@ -33,7 +40,10 @@ class views_handler_argument_field_list_string extends views_handler_argument_st return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['summary']['human'] = array( @@ -44,16 +54,19 @@ class views_handler_argument_field_list_string extends views_handler_argument_st ); } - - function summary_name($data) { + /** + * {@inheritdoc} + */ + public function summary_name($data) { $value = $data->{$this->name_alias}; // If the list element has a human readable name show it, if (isset($this->allowed_values[$value]) && !empty($this->options['summary']['human'])) { return $this->case_transform(field_filter_xss($this->allowed_values[$value]), $this->options['case']); } - // else fallback to the key. + // Else fallback to the key. else { return $this->case_transform(check_plain($value), $this->options['case']); } } + } diff --git a/sites/all/modules/views/modules/field/views_handler_field_field.inc b/sites/all/modules/views/modules/field/views_handler_field_field.inc index e30a1e8..da31604 100644 --- a/sites/all/modules/views/modules/field/views_handler_field_field.inc +++ b/sites/all/modules/views/modules/field/views_handler_field_field.inc @@ -38,6 +38,7 @@ function _field_view_formatter_options($field_type = NULL) { * @ingroup views_field_handlers */ class views_handler_field_field extends views_handler_field { + /** * An array to store field renderable arrays for use by render_items. * @@ -52,7 +53,6 @@ class views_handler_field_field extends views_handler_field { */ public $field_info = array(); - /** * Does the field supports multiple field values. * @@ -81,7 +81,10 @@ class views_handler_field_field extends views_handler_field { */ public $instance; - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); $this->field_info = $field = field_info_field($this->definition['field_name']); @@ -97,13 +100,13 @@ class views_handler_field_field extends views_handler_field { $this->limit_values = TRUE; } - // If "First and last only" is chosen, limit the values + // If "First and last only" is chosen, limit the values. if (!empty($this->options['delta_first_last'])) { $this->limit_values = TRUE; } - // Otherwise, we only limit values if the user hasn't selected "all", 0, or - // the value matching field cardinality. + // Otherwise, we only limit values if the user hasn't selected "all", 0, + // or the value matching field cardinality. if ((intval($this->options['delta_limit']) && ($this->options['delta_limit'] != $field['cardinality'])) || intval($this->options['delta_offset'])) { $this->limit_values = TRUE; } @@ -122,9 +125,9 @@ class views_handler_field_field extends views_handler_field { * @return bool * Return TRUE if the user has access to view this field. */ - function access() { + public function access() { $base_table = $this->get_base_table(); - return field_access('view', $this->field_info, $this->definition['entity_tables'][$base_table]); + return isset($this->definition['entity_tables'][$base_table]) && field_access('view', $this->field_info, $this->definition['entity_tables'][$base_table]); } /** @@ -133,14 +136,15 @@ class views_handler_field_field extends views_handler_field { * @return string * The base table which is used in the current view "context". */ - function get_base_table() { + public function get_base_table() { if (!isset($this->base_table)) { // This base_table is coming from the entity not the field. $this->base_table = $this->view->base_table; // If the current field is under a relationship you can't be sure that the - // base table of the view is the base table of the current field. - // For example a field from a node author on a node view does have users as base table. + // base table of the view is the base table of the current field. For + // example, a field from a node author on a node view does have users as + // base table. if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') { $relationships = $this->view->display_handler->get_option('relationships'); if (!empty($relationships[$this->options['relationship']])) { @@ -165,7 +169,7 @@ class views_handler_field_field extends views_handler_field { * The 'add fields to query' switch is used by modules which need all data * present in the query itself (such as "sphinx"). */ - function query($use_groupby = FALSE) { + public function query($use_groupby = FALSE) { $this->get_base_table(); $params = array(); @@ -202,8 +206,8 @@ class views_handler_field_field extends views_handler_field { $this->aliases['entity_id'] = $this->query->add_field($this->base_table_alias, $entity_info['entity keys']['id'], '', $params); } - - // The alias needs to be unique, so we use both the field table and the entity type. + // The alias needs to be unique, so we use both the field table and the + // entity type. $entity_type_alias = $this->definition['table'] . '_' . $entity_type . '_entity_type'; $this->aliases['entity_type'] = $this->query->add_field(NULL, "'$entity_type'", $entity_type_alias); @@ -224,10 +228,10 @@ class views_handler_field_field extends views_handler_field { $options += is_array($this->options['group_columns']) ? $this->options['group_columns'] : array(); - $fields = array(); $rkey = $this->definition['is revision'] ? 'FIELD_LOAD_REVISION' : 'FIELD_LOAD_CURRENT'; - // Go through the list and determine the actual column name from field api. + // Go through the list and determine the actual column name from field + // API. foreach ($options as $column) { $name = $column; if (isset($this->field_info['storage']['details']['sql'][$rkey][$this->table][$column])) { @@ -249,7 +253,8 @@ class views_handler_field_field extends views_handler_field { $field = $this->field_info; if (field_is_translatable($entity_type, $field) && !empty($this->view->display_handler->options['field_language_add_to_query'])) { $column = $this->table_alias . '.language'; - // By the same reason as field_language the field might be LANGUAGE_NONE in reality so allow it as well. + // By the same reason as field_language the field might be + // LANGUAGE_NONE in reality so allow it as well. // @see this::field_language() global $language_content; $default_language = language_default('language'); @@ -282,7 +287,7 @@ class views_handler_field_field extends views_handler_field { /** * Determine if the field table should be added to the query. */ - function add_field_table($use_groupby) { + public function add_field_table($use_groupby) { // Grouping is enabled, or we are explicitly required to do this. if ($use_groupby || !empty($this->definition['add fields to query'])) { return TRUE; @@ -297,7 +302,7 @@ class views_handler_field_field extends views_handler_field { /** * Determine if this field is click sortable. */ - function click_sortable() { + public function click_sortable() { // Not click sortable in any case. if (empty($this->definition['click sortable'])) { return FALSE; @@ -314,7 +319,7 @@ class views_handler_field_field extends views_handler_field { /** * Called to determine what to tell the clicksorter. */ - function click_sort($order) { + public function click_sort($order) { // No column selected, can't continue. if (empty($this->options['click_sort_column'])) { return; @@ -329,7 +334,10 @@ class views_handler_field_field extends views_handler_field { $this->query->add_orderby(NULL, NULL, $order, $this->aliases[$column]); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); // option_definition runs before init/construct, so no $this->field_info @@ -389,10 +397,10 @@ class views_handler_field_field extends views_handler_field { ); $options['multi_type'] = array( - 'default' => 'separator' + 'default' => 'separator', ); $options['separator'] = array( - 'default' => ', ' + 'default' => ', ', ); $options['field_api_classes'] = array( @@ -403,7 +411,10 @@ class views_handler_field_field extends views_handler_field { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $field = $this->field_info; @@ -486,7 +497,7 @@ class views_handler_field_field extends views_handler_field { /** * Provide options for multiple value fields. */ - function multiple_options_form(&$form, &$form_state) { + public function multiple_options_form(&$form, &$form_state) { $field = $this->field_info; $form['multiple_field_settings'] = array( @@ -526,6 +537,7 @@ class views_handler_field_field extends views_handler_field { 'ul' => t('Unordered list'), 'ol' => t('Ordered list'), 'separator' => t('Simple separator'), + 'count' => t('Count'), ), '#dependency' => array('edit-options-group-rows' => array(TRUE)), '#default_value' => $this->options['multi_type'], @@ -597,7 +609,7 @@ class views_handler_field_field extends views_handler_field { /** * Extend the groupby form with group columns. */ - function groupby_form(&$form, &$form_state) { + public function groupby_form(&$form, &$form_state) { parent::groupby_form($form, $form_state); // With "field API" fields, the column target of the grouping function // and any additional grouping columns must be specified. @@ -625,7 +637,10 @@ class views_handler_field_field extends views_handler_field { ); } - function groupby_form_submit(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function groupby_form_submit(&$form, &$form_state) { parent::groupby_form_submit($form, $form_state); $item =& $form_state['handler']->options; @@ -637,7 +652,7 @@ class views_handler_field_field extends views_handler_field { /** * Load the entities for all fields that are about to be displayed. */ - function post_execute(&$values) { + public function post_execute(&$values) { if (!empty($values)) { // Divide the entity ids by entity type, so they can be loaded in bulk. $entities_by_type = array(); @@ -690,7 +705,8 @@ class views_handler_field_field extends views_handler_field { } } - // Now, transfer the data back into the resultset so it can be easily used. + // Now, transfer the data back into the resultset so it can be easily + // used. foreach ($values as $row_id => &$value) { $value->{'field_' . $this->options['id']} = $this->set_items($value, $row_id); } @@ -703,7 +719,7 @@ class views_handler_field_field extends views_handler_field { * When using advanced render, each possible item in the list is rendered * individually. Then the items are all pasted together. */ - function render_items($items) { + public function render_items($items) { if (!empty($items)) { if (!$this->options['group_rows']) { return implode('', $items); @@ -712,22 +728,31 @@ class views_handler_field_field extends views_handler_field { if ($this->options['multi_type'] == 'separator') { return implode(filter_xss_admin($this->options['separator']), $items); } + elseif ($this->options['multi_type'] == 'count') { + return count($items); + } else { return theme('item_list', array( 'items' => $items, 'title' => NULL, - 'type' => $this->options['multi_type'] + 'type' => $this->options['multi_type'], )); } } } - function get_items($values) { + /** + * {@inheritdoc} + */ + public function get_items($values) { return $values->{'field_' . $this->options['id']}; } - function get_value($values, $field = NULL) { + /** + * {@inheritdoc} + */ + public function get_value($values, $field = NULL) { if (!isset($values->_field_data[$this->field_alias]['entity']) || !is_object($values->_field_data[$this->field_alias]['entity'])) { return array(); } @@ -757,7 +782,7 @@ class views_handler_field_field extends views_handler_field { } } - // If any of our aggregated fields have data, fake it: + // If any of our aggregated fields have data, fake it. if ($data) { // Now, overwrite the original value with our aggregated value. // This overwrites it so there is always just one entry. @@ -808,7 +833,7 @@ class views_handler_field_field extends views_handler_field { } } - // Determine if only the first and last values should be shown + // Determine if only the first and last values should be shown. $delta_first_last = $this->options['delta_first_last']; $new_values = array(); @@ -816,7 +841,8 @@ class views_handler_field_field extends views_handler_field { $new_delta = $offset + $i; if (isset($all_values[$new_delta])) { - // If first-last option was selected, only use the first and last values + // If first-last option was selected, only use the first and last + // values. if (!$delta_first_last // Use the first value. || $new_delta == $offset @@ -840,7 +866,7 @@ class views_handler_field_field extends views_handler_field { /** * Return an array of items for the field. */ - function set_items($values, $row_id) { + public function set_items($values, $row_id) { // In some cases the instance on the entity might be easy, see // https://drupal.org/node/1161708 and https://drupal.org/node/1461536 for // more information. @@ -858,7 +884,6 @@ class views_handler_field_field extends views_handler_field { 'views_row_id' => $row_id, ); - $entity_type = $values->_field_data[$this->field_alias]['entity_type']; $entity = $this->get_value($values, 'entity'); if (!$entity) { @@ -870,8 +895,6 @@ class views_handler_field_field extends views_handler_field { $items = array(); if ($this->options['field_api_classes']) { - // Make a copy. - $array = $render_array; return array(array('rendered' => drupal_render($render_array))); } @@ -894,28 +917,37 @@ class views_handler_field_field extends views_handler_field { return $items; } - function render_item($count, $item) { + /** + * {@inheritdoc} + */ + public function render_item($count, $item) { return render($item['rendered']); } - function document_self_tokens(&$tokens) { + /** + * {@inheritdoc} + */ + public function document_self_tokens(&$tokens) { $field = $this->field_info; foreach ($field['columns'] as $id => $column) { $tokens['[' . $this->options['id'] . '-' . $id . ']'] = t('Raw @column', array('@column' => $id)); } } - function add_self_tokens(&$tokens, $item) { + /** + * {@inheritdoc} + */ + public function add_self_tokens(&$tokens, $item) { $field = $this->field_info; foreach ($field['columns'] as $id => $column) { - // Use filter_xss_admin because it's user data and we can't be sure it is safe. - // We know nothing about the data, though, so we can't really do much else. - + // Use filter_xss_admin because it's user data and we can't be sure it is + // safe. We know nothing about the data, though, so we can't really do + // much else. if (isset($item['raw'])) { // If $item['raw'] is an array then we can use as is, if it's an object // we cast it to an array, if it's neither, we can't use it. $raw = is_array($item['raw']) ? $item['raw'] : - (is_object($item['raw']) ? (array)$item['raw'] : NULL); + (is_object($item['raw']) ? (array) $item['raw'] : NULL); } if (isset($raw) && isset($raw[$id]) && is_scalar($raw[$id])) { $tokens['[' . $this->options['id'] . '-' . $id . ']'] = filter_xss_admin($raw[$id]); @@ -931,7 +963,7 @@ class views_handler_field_field extends views_handler_field { * Return the language code of the language the field should be displayed in, * according to the settings. */ - function field_language($entity_type, $entity) { + public function field_language($entity_type, $entity) { global $language_content; if (field_is_translatable($entity_type, $this->field_info)) { @@ -940,10 +972,11 @@ class views_handler_field_field extends views_handler_field { array($language_content->language, $default_language), $this->view->display_handler->options['field_language']); - // Give the Field Language API a chance to fallback to a different language - // (or LANGUAGE_NONE), in case the field has no data for the selected language. - // field_view_field() does this as well, but since the returned language code - // is used before calling it, the fallback needs to happen explicitly. + // Give the Field Language API a chance to fallback to a different + // language (or LANGUAGE_NONE), in case the field has no data for the + // selected language. field_view_field() does this as well, but since the + // returned language code is used before calling it, the fallback needs + // to happen explicitly. $language = field_language($entity_type, $entity, $this->field_info['field_name'], $language); return $language; @@ -952,4 +985,5 @@ class views_handler_field_field extends views_handler_field { return LANGUAGE_NONE; } } + } diff --git a/sites/all/modules/views/modules/field/views_handler_filter_field_list.inc b/sites/all/modules/views/modules/field/views_handler_filter_field_list.inc index 440d55b..e9fab80 100644 --- a/sites/all/modules/views/modules/field/views_handler_filter_field_list.inc +++ b/sites/all/modules/views/modules/field/views_handler_filter_field_list.inc @@ -12,9 +12,13 @@ */ class views_handler_filter_field_list extends views_handler_filter_many_to_one { - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); - // Migrate the settings from the old filter_in_operator values to filter_many_to_one. + // Migrate the settings from the old filter_in_operator values to + // filter_many_to_one. if ($this->options['operator'] == 'in') { $this->options['operator'] = 'or'; } @@ -24,9 +28,12 @@ class views_handler_filter_field_list extends views_handler_filter_many_to_one { $this->operator = $this->options['operator']; } - - function get_value_options() { + /** + * {@inheritdoc} + */ + public function get_value_options() { $field = field_info_field($this->definition['field_name']); $this->value_options = list_allowed_values($field); } + } diff --git a/sites/all/modules/views/modules/field/views_handler_filter_field_list_boolean.inc b/sites/all/modules/views/modules/field/views_handler_filter_field_list_boolean.inc index 34bca54..dd9938b 100644 --- a/sites/all/modules/views/modules/field/views_handler_filter_field_list_boolean.inc +++ b/sites/all/modules/views/modules/field/views_handler_filter_field_list_boolean.inc @@ -12,7 +12,10 @@ */ class views_handler_filter_field_list_boolean extends views_handler_filter_field_list { - function get_value_options() { + /** + * {@inheritdoc} + */ + public function get_value_options() { $field = field_info_field($this->definition['field_name']); $value_options = list_allowed_values($field); @@ -30,4 +33,5 @@ class views_handler_filter_field_list_boolean extends views_handler_filter_field $this->value_options = $value_options; } + } diff --git a/sites/all/modules/views/modules/field/views_handler_relationship_entity_reverse.inc b/sites/all/modules/views/modules/field/views_handler_relationship_entity_reverse.inc index 89f2483..04fde51 100644 --- a/sites/all/modules/views/modules/field/views_handler_relationship_entity_reverse.inc +++ b/sites/all/modules/views/modules/field/views_handler_relationship_entity_reverse.inc @@ -10,8 +10,12 @@ * * @ingroup views_relationship_handlers */ -class views_handler_relationship_entity_reverse extends views_handler_relationship { - function init(&$view, &$options) { +class views_handler_relationship_entity_reverse extends views_handler_relationship { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); $this->field_info = field_info_field($this->definition['field_name']); @@ -20,7 +24,7 @@ class views_handler_relationship_entity_reverse extends views_handler_relationsh /** * Called to implement a relationship in a query. */ - function query() { + public function query() { $this->ensure_my_table(); // First, relate our base table to the current base table to the // field, using the base table's id field to the field's column. @@ -76,9 +80,10 @@ class views_handler_relationship_entity_reverse extends views_handler_relationsh $second_join->construct(); $second_join->adjusted = TRUE; - // use a short alias for this: + // Use a short alias for this. $alias = $this->definition['field_name'] . '_' . $this->table; $this->alias = $this->query->add_relationship($alias, $second_join, $this->definition['base'], $this->relationship); } + } diff --git a/sites/all/modules/views/modules/filter.views.inc b/sites/all/modules/views/modules/filter.views.inc index 0a3b4fc..1a1bfd4 100644 --- a/sites/all/modules/views/modules/filter.views.inc +++ b/sites/all/modules/views/modules/filter.views.inc @@ -12,10 +12,9 @@ */ function filter_views_data() { // ---------------------------------------------------------------------- - // filter_format table - - // Have not defined $data['filter_formats']['table']['group'] since - // no fields are defined here yet. + // 'filter_format' table. + // Have not defined $data['filter_formats']['table']['group'] since no fields + // are defined here yet. $data['filter_formats']['moved to'] = 'filter_format'; $data['filter_format']['table']['join'] = array( 'node_revision' => array( diff --git a/sites/all/modules/views/modules/filter/views_handler_field_filter_format_name.inc b/sites/all/modules/views/modules/filter/views_handler_field_filter_format_name.inc index 0a7bf3b..ddddb3d 100644 --- a/sites/all/modules/views/modules/filter/views_handler_field_filter_format_name.inc +++ b/sites/all/modules/views/modules/filter/views_handler_field_filter_format_name.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_field_filter_format_name. + * Contains . */ /** @@ -11,18 +11,28 @@ * @ingroup views_field_handlers */ class views_handler_field_filter_format_name extends views_handler_field { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); // Be explicit about the table we are using. $this->additional_fields['name'] = array('table' => 'filter_formats', 'field' => 'name'); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->add_additional_fields(); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $format_name = $this->get_value($values, 'name'); if (!$format_name) { // Default or invalid input format. @@ -33,4 +43,5 @@ class views_handler_field_filter_format_name extends views_handler_field { } return $this->sanitize_value($format_name); } + } diff --git a/sites/all/modules/views/modules/locale.views.inc b/sites/all/modules/views/modules/locale.views.inc index fe6d050..3577e8c 100644 --- a/sites/all/modules/views/modules/locale.views.inc +++ b/sites/all/modules/views/modules/locale.views.inc @@ -12,7 +12,6 @@ */ function locale_views_data() { // Basic table information. - // Define the base group of this table. $data['locales_source']['table']['group'] = t('Locale source'); @@ -23,7 +22,7 @@ function locale_views_data() { 'help' => t('A source string for translation, in English or the default site language.'), ); - // lid + // Locale ID / 'lid'. $data['locales_source']['lid'] = array( 'title' => t('LID'), 'help' => t('The ID of the source string.'), @@ -44,7 +43,7 @@ function locale_views_data() { ), ); - // location + // Location. $data['locales_source']['location'] = array( 'group' => t('Locale source'), 'title' => t('Location'), @@ -52,7 +51,7 @@ function locale_views_data() { 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), @@ -64,7 +63,7 @@ function locale_views_data() { ), ); - // Group field + // Group field. $data['locales_source']['textgroup'] = array( 'group' => t('Locale source'), 'title' => t('Group'), @@ -81,7 +80,7 @@ function locale_views_data() { ), ); - // Source field + // Source field. $data['locales_source']['source'] = array( 'group' => t('Locale source'), 'title' => t('Source'), @@ -94,7 +93,7 @@ function locale_views_data() { ), ); - // Version field + // Version field. $data['locales_source']['version'] = array( 'group' => t('Locale source'), 'title' => t('Version'), @@ -121,13 +120,12 @@ function locale_views_data() { ); // ---------------------------------------------------------------------- - // Locales target table - - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + // 'locales_target' table. + // Define the base group of this table. Fields that don't have a group + // defined will go into this field by default. $data['locales_target']['table']['group'] = t('Locale target'); - // Join information + // Join information. $data['locales_target']['table']['join'] = array( 'locales_source' => array( 'left_field' => 'lid', @@ -135,7 +133,7 @@ function locale_views_data() { ), ); - // Translation field + // Translation field. $data['locales_target']['translation'] = array( 'group' => t('Locale target'), 'title' => t('Translation'), @@ -148,7 +146,7 @@ function locale_views_data() { ), ); - // Language field + // Language field. $data['locales_target']['language'] = array( 'group' => t('Locale target'), 'title' => t('Language'), @@ -174,7 +172,7 @@ function locale_views_data() { ), ); - // Plural + // Plural. $data['locales_target']['plural'] = array( 'group' => t('Locale target'), 'title' => t('Plural'), @@ -200,7 +198,7 @@ function locale_views_data() { * Implements hook_views_data_alter(). */ function locale_views_data_alter(&$data) { - // Language field + // Language field. $data['node']['language'] = array( 'title' => t('Language'), 'help' => t('The language the content is in.'), diff --git a/sites/all/modules/views/modules/locale/views_handler_argument_locale_group.inc b/sites/all/modules/views/modules/locale/views_handler_argument_locale_group.inc index 7ced836..6efcd55 100644 --- a/sites/all/modules/views/modules/locale/views_handler_argument_locale_group.inc +++ b/sites/all/modules/views/modules/locale/views_handler_argument_locale_group.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_argument_locale_group. + * Contains . */ /** @@ -11,7 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_locale_group extends views_handler_argument { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct('group'); } @@ -19,7 +23,7 @@ class views_handler_argument_locale_group extends views_handler_argument { * Override the behavior of summary_name(). Get the user friendly version * of the group. */ - function summary_name($data) { + public function summary_name($data) { return $this->locale_group($data->{$this->name_alias}); } @@ -27,14 +31,18 @@ class views_handler_argument_locale_group extends views_handler_argument { * Override the behavior of title(). Get the user friendly version * of the language. */ - function title() { + public function title() { return $this->locale_group($this->argument); } - function locale_group($group) { + /** + * {@inheritdoc} + */ + public function locale_group($group) { $groups = module_invoke_all('locale', 'groups'); // Sort the list. asort($groups); return isset($groups[$group]) ? $groups[$group] : t('Unknown group'); } + } diff --git a/sites/all/modules/views/modules/locale/views_handler_argument_locale_language.inc b/sites/all/modules/views/modules/locale/views_handler_argument_locale_language.inc index 316d4b1..0c3f61e 100644 --- a/sites/all/modules/views/modules/locale/views_handler_argument_locale_language.inc +++ b/sites/all/modules/views/modules/locale/views_handler_argument_locale_language.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_argument_locale_language. + * Contains . */ /** @@ -11,7 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_locale_language extends views_handler_argument { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct('language'); } @@ -19,7 +23,7 @@ class views_handler_argument_locale_language extends views_handler_argument { * Override the behavior of summary_name(). Get the user friendly version * of the language. */ - function summary_name($data) { + public function summary_name($data) { return $this->locale_language($data->{$this->name_alias}); } @@ -27,12 +31,16 @@ class views_handler_argument_locale_language extends views_handler_argument { * Override the behavior of title(). Get the user friendly version * of the language. */ - function title() { + public function title() { return $this->locale_language($this->argument); } - function locale_language($langcode) { + /** + * {@inheritdoc} + */ + public function locale_language($langcode) { $languages = views_language_list(); return isset($languages[$langcode]) ? $languages[$langcode] : t('Unknown language'); } + } diff --git a/sites/all/modules/views/modules/locale/views_handler_field_locale_group.inc b/sites/all/modules/views/modules/locale/views_handler_field_locale_group.inc index 393a948..dbdedc4 100644 --- a/sites/all/modules/views/modules/locale/views_handler_field_locale_group.inc +++ b/sites/all/modules/views/modules/locale/views_handler_field_locale_group.inc @@ -11,11 +11,16 @@ * @ingroup views_field_handlers */ class views_handler_field_locale_group extends views_handler_field { - function render($values) { + + /** + * {@inheritdoc} + */ + public function render($values) { $groups = module_invoke_all('locale', 'groups'); // Sort the list. asort($groups); $value = $this->get_value($values); return isset($groups[$value]) ? $groups[$value] : ''; } + } diff --git a/sites/all/modules/views/modules/locale/views_handler_field_locale_language.inc b/sites/all/modules/views/modules/locale/views_handler_field_locale_language.inc index 8038e2b..552ccf2 100644 --- a/sites/all/modules/views/modules/locale/views_handler_field_locale_language.inc +++ b/sites/all/modules/views/modules/locale/views_handler_field_locale_language.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_field_locale_language. + * Contains . */ /** @@ -11,14 +11,21 @@ * @ingroup views_field_handlers */ class views_handler_field_locale_language extends views_handler_field { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['native_language'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['native_language'] = array( '#title' => t('Native language'), @@ -28,9 +35,13 @@ class views_handler_field_locale_language extends views_handler_field { ); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $languages = locale_language_list(empty($this->options['native_language']) ? 'name' : 'native'); $value = $this->get_value($values); return isset($languages[$value]) ? $languages[$value] : ''; } + } diff --git a/sites/all/modules/views/modules/locale/views_handler_field_locale_link_edit.inc b/sites/all/modules/views/modules/locale/views_handler_field_locale_link_edit.inc index 811bcb2..6d2189d 100644 --- a/sites/all/modules/views/modules/locale/views_handler_field_locale_link_edit.inc +++ b/sites/all/modules/views/modules/locale/views_handler_field_locale_link_edit.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_field_locale_link_edit. + * Contains . */ /** @@ -11,12 +11,19 @@ * @ingroup views_field_handlers */ class views_handler_field_locale_link_edit extends views_handler_field { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['lid'] = 'lid'; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['text'] = array('default' => '', 'translatable' => TRUE); @@ -24,7 +31,10 @@ class views_handler_field_locale_link_edit extends views_handler_field { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['text'] = array( '#type' => 'textfield', '#title' => t('Text to display'), @@ -33,22 +43,34 @@ class views_handler_field_locale_link_edit extends views_handler_field { parent::options_form($form, $form_state); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->add_additional_fields(); } - function access() { + /** + * {@inheritdoc} + */ + public function access() { // Ensure user has access to edit translations. return user_access('translate interface'); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values, 'lid'); return $this->render_link($this->sanitize_value($value), $values); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { $text = !empty($this->options['text']) ? $this->options['text'] : t('edit'); $this->options['alter']['make_link'] = TRUE; @@ -57,4 +79,5 @@ class views_handler_field_locale_link_edit extends views_handler_field { return $text; } + } diff --git a/sites/all/modules/views/modules/locale/views_handler_field_node_language.inc b/sites/all/modules/views/modules/locale/views_handler_field_node_language.inc index 467605b..281d464 100644 --- a/sites/all/modules/views/modules/locale/views_handler_field_node_language.inc +++ b/sites/all/modules/views/modules/locale/views_handler_field_node_language.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_field_node_language. + * Contains . */ /** @@ -11,14 +11,21 @@ * @ingroup views_field_handlers */ class views_handler_field_node_language extends views_handler_field_node { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['native_language'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['native_language'] = array( '#title' => t('Native language'), @@ -28,10 +35,14 @@ class views_handler_field_node_language extends views_handler_field_node { ); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $languages = views_language_list(empty($this->options['native_language']) ? 'name' : 'native'); $value = $this->get_value($values); $value = isset($languages[$value]) ? $languages[$value] : ''; return $this->render_link($value, $values); } + } diff --git a/sites/all/modules/views/modules/locale/views_handler_filter_locale_group.inc b/sites/all/modules/views/modules/locale/views_handler_filter_locale_group.inc index 5ec1e92..b866972 100644 --- a/sites/all/modules/views/modules/locale/views_handler_filter_locale_group.inc +++ b/sites/all/modules/views/modules/locale/views_handler_filter_locale_group.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_filter_locale_group. + * Contains . */ /** @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_locale_group extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { if (!isset($this->value_options)) { $this->value_title = t('Group'); $groups = module_invoke_all('locale', 'groups'); @@ -20,4 +24,5 @@ class views_handler_filter_locale_group extends views_handler_filter_in_operator $this->value_options = $groups; } } + } diff --git a/sites/all/modules/views/modules/locale/views_handler_filter_locale_language.inc b/sites/all/modules/views/modules/locale/views_handler_filter_locale_language.inc index eee12a6..92d4bd8 100644 --- a/sites/all/modules/views/modules/locale/views_handler_filter_locale_language.inc +++ b/sites/all/modules/views/modules/locale/views_handler_filter_locale_language.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_filter_locale_language. + * Contains . */ /** @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_locale_language extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { if (!isset($this->value_options)) { $this->value_title = t('Language'); $languages = array( @@ -23,4 +27,5 @@ class views_handler_filter_locale_language extends views_handler_filter_in_opera $this->value_options = $languages; } } + } diff --git a/sites/all/modules/views/modules/locale/views_handler_filter_locale_version.inc b/sites/all/modules/views/modules/locale/views_handler_filter_locale_version.inc index 7170860..f5eafee 100644 --- a/sites/all/modules/views/modules/locale/views_handler_filter_locale_version.inc +++ b/sites/all/modules/views/modules/locale/views_handler_filter_locale_version.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_filter_locale_version. + * Contains . */ /** @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_locale_version extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { if (!isset($this->value_options)) { $this->value_title = t('Version'); // Enable filtering by the current installed Drupal version. @@ -25,4 +29,5 @@ class views_handler_filter_locale_version extends views_handler_filter_in_operat $this->value_options = $versions; } } + } diff --git a/sites/all/modules/views/modules/locale/views_handler_filter_node_language.inc b/sites/all/modules/views/modules/locale/views_handler_filter_node_language.inc index 7592577..ba6b670 100644 --- a/sites/all/modules/views/modules/locale/views_handler_filter_node_language.inc +++ b/sites/all/modules/views/modules/locale/views_handler_filter_node_language.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_filter_node_language. + * Contains . */ /** @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_node_language extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { if (!isset($this->value_options)) { $this->value_title = t('Language'); $languages = array( @@ -23,4 +27,5 @@ class views_handler_filter_node_language extends views_handler_filter_in_operato $this->value_options = $languages; } } + } diff --git a/sites/all/modules/views/modules/locale/views_handler_sort_node_language.inc b/sites/all/modules/views/modules/locale/views_handler_sort_node_language.inc index b429891..fa446a8 100644 --- a/sites/all/modules/views/modules/locale/views_handler_sort_node_language.inc +++ b/sites/all/modules/views/modules/locale/views_handler_sort_node_language.inc @@ -1,5 +1,10 @@ options['language'])) { $langcode = $this->get_system_langcode($this->options['language']); // Validate the langcode. @@ -33,7 +38,7 @@ class views_handler_sort_node_language extends views_handler_sort { /** * Converts a views language code into a Drupal language code. */ - function get_system_langcode($langcode) { + public function get_system_langcode($langcode) { global $language_content; $default_language = language_default('language'); $system_langcode = str_replace(array( @@ -51,7 +56,7 @@ class views_handler_sort_node_language extends views_handler_sort { /** * {@inheritdoc} */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); $options['language'] = array('default' => '***CURRENT_LANGUAGE***'); return $options; @@ -60,7 +65,7 @@ class views_handler_sort_node_language extends views_handler_sort { /** * {@inheritdoc} */ - function admin_summary() { + public function admin_summary() { $summary = parent::admin_summary(); if ($this->options['language']) { $language_options = $this->get_language_options(); @@ -78,11 +83,11 @@ class views_handler_sort_node_language extends views_handler_sort { * @return array * All the languages. */ - function get_language_options() { + public function get_language_options() { $languages = array( '***CURRENT_LANGUAGE***' => t("Current user's language"), '***DEFAULT_LANGUAGE***' => t("Default site language"), - LANGUAGE_NONE => t('No language') + LANGUAGE_NONE => t('No language'), ); $languages = array_merge($languages, views_language_list()); return $languages; @@ -91,7 +96,7 @@ class views_handler_sort_node_language extends views_handler_sort { /** * {@inheritdoc} */ - function show_sort_form(&$form, &$form_state) { + public function show_sort_form(&$form, &$form_state) { parent::show_sort_form($form, $form_state); $form['language'] = array( @@ -104,4 +109,3 @@ class views_handler_sort_node_language extends views_handler_sort { } } - diff --git a/sites/all/modules/views/modules/node.views.inc b/sites/all/modules/views/modules/node.views.inc index 57e6b28..2eb351d 100644 --- a/sites/all/modules/views/modules/node.views.inc +++ b/sites/all/modules/views/modules/node.views.inc @@ -12,13 +12,12 @@ */ function node_views_data() { // ---------------------------------------------------------------- - // node table -- basic table information. - - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + // 'node' table -- basic table information. + // Define the base group of this table. Fields that don't have a group + // defined will go into this field by default. $data['node']['table']['group'] = t('Content'); - // Advertise this table as a possible base table + // Advertise this table as a possible base table. $data['node']['table']['base'] = array( 'field' => 'nid', 'title' => t('Content'), @@ -38,25 +37,27 @@ function node_views_data() { ); // ---------------------------------------------------------------- - // node table -- fields - - // nid + // 'node' table -- fields. + // Node ID / 'nid'. $data['node']['nid'] = array( + // The item it appears as on the UI, 'title' => t('Nid'), - 'help' => t('The node ID.'), // The help that appears on the UI, - // Information for displaying the nid + // The help that appears on the UI, + 'help' => t('The node ID.'), + // Information for displaying the nid. 'field' => array( 'handler' => 'views_handler_field_node', 'click sortable' => TRUE, ), - // Information for accepting a nid as an argument + // Information for accepting a nid as an argument. 'argument' => array( 'handler' => 'views_handler_argument_node_nid', - 'name field' => 'title', // the field to display in the summary. + 'name field' => 'title', + // The field to display in the summary. 'numeric' => TRUE, 'validate type' => 'nid', ), - // Information for accepting a nid as a filter + // Information for accepting a nid as a filter. 'filter' => array( 'handler' => 'views_handler_filter_numeric', ), @@ -66,23 +67,27 @@ function node_views_data() { ), ); - // title + // Title. // This definition has more items in it than it needs to as an example. $data['node']['title'] = array( - 'title' => t('Title'), // The item it appears as on the UI, - 'help' => t('The content title.'), // The help that appears on the UI, - // Information for displaying a title as a field + // The item it appears as on the UI, + 'title' => t('Title'), + // The help that appears on the UI, + 'help' => t('The content title.'), + // Information for displaying a title as a field. 'field' => array( - 'field' => 'title', // the real field. This could be left out since it is the same. - 'group' => t('Content'), // The group it appears in on the UI. Could be left out. + 'field' => 'title', + // The real field. This could be left out since it is the same. + 'group' => t('Content'), + // The group it appears in on the UI. Could be left out. 'handler' => 'views_handler_field_node', 'click sortable' => TRUE, 'link_to_node default' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), - // Information for accepting a title as a filter + // Information for accepting a title as a filter. 'filter' => array( 'handler' => 'views_handler_filter_string', ), @@ -91,10 +96,12 @@ function node_views_data() { ), ); - // created field + // Created field. $data['node']['created'] = array( - 'title' => t('Post date'), // The item it appears as on the UI, - 'help' => t('The date the content was posted.'), // The help that appears on the UI, + // The item it appears as on the UI, + 'title' => t('Post date'), + // The help that appears on the UI, + 'help' => t('The date the content was posted.'), 'field' => array( 'handler' => 'views_handler_field_date', 'click sortable' => TRUE, @@ -107,10 +114,12 @@ function node_views_data() { ), ); - // changed field + // Changed field. $data['node']['changed'] = array( - 'title' => t('Updated date'), // The item it appears as on the UI, - 'help' => t('The date the content was last updated.'), // The help that appears on the UI, + // The item it appears as on the UI, + 'title' => t('Updated date'), + // The help that appears on the UI, + 'help' => t('The date the content was last updated.'), 'field' => array( 'handler' => 'views_handler_field_date', 'click sortable' => TRUE, @@ -123,10 +132,12 @@ function node_views_data() { ), ); - // Content type + // Content type. $data['node']['type'] = array( - 'title' => t('Type'), // The item it appears as on the UI, - 'help' => t('The content type (for example, "blog entry", "forum post", "story", etc).'), // The help that appears on the UI, + // The item it appears as on the UI, + 'title' => t('Type'), + // The help that appears on the UI, + 'help' => t('The content type (for example, "blog entry", "forum post", "story", etc).'), 'field' => array( 'handler' => 'views_handler_field_node_type', 'click sortable' => TRUE, @@ -142,9 +153,9 @@ function node_views_data() { ), ); - // published status + // Published status. $data['node']['status'] = array( - 'title' => t('Published'), + 'title' => t('Published status'), 'help' => t('Whether or not the content is published.'), 'field' => array( 'handler' => 'views_handler_field_boolean', @@ -155,29 +166,30 @@ function node_views_data() { ), 'filter' => array( 'handler' => 'views_handler_filter_boolean_operator', - 'label' => t('Published'), + 'label' => t('Published status'), 'type' => 'yes-no', - 'use equal' => TRUE, // Use status = 1 instead of status <> 0 in WHERE statment + 'use equal' => TRUE, + // Use status = 1 instead of status <> 0 in WHERE statment. ), 'sort' => array( 'handler' => 'views_handler_sort', ), ); - // published status + extra + // Published status + extra. $data['node']['status_extra'] = array( - 'title' => t('Published or admin'), + 'title' => t('Published status or admin user'), 'help' => t('Filters out unpublished content if the current user cannot view it.'), 'filter' => array( 'field' => 'status', 'handler' => 'views_handler_filter_node_status', - 'label' => t('Published or admin'), + 'label' => t('Published status or admin user'), ), ); - // promote status + // Promote status. $data['node']['promote'] = array( - 'title' => t('Promoted to front page'), + 'title' => t('Promoted to front page status'), 'help' => t('Whether or not the content is promoted to the front page.'), 'field' => array( 'handler' => 'views_handler_field_boolean', @@ -188,7 +200,7 @@ function node_views_data() { ), 'filter' => array( 'handler' => 'views_handler_filter_boolean_operator', - 'label' => t('Promoted to front page'), + 'label' => t('Promoted to front page status'), 'type' => 'yes-no', ), 'sort' => array( @@ -196,11 +208,13 @@ function node_views_data() { ), ); - // sticky + // Sticky. $data['node']['sticky'] = array( - 'title' => t('Sticky'), // The item it appears as on the UI, - 'help' => t('Whether or not the content is sticky.'), // The help that appears on the UI, - // Information for displaying a title as a field + // The item it appears as on the UI, + 'title' => t('Sticky status'), + // The help that appears on the UI, + 'help' => t('Whether or not the content is sticky.'), + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_boolean', 'click sortable' => TRUE, @@ -210,7 +224,7 @@ function node_views_data() { ), 'filter' => array( 'handler' => 'views_handler_filter_boolean_operator', - 'label' => t('Sticky'), + 'label' => t('Sticky status'), 'type' => 'yes-no', ), 'sort' => array( @@ -221,14 +235,13 @@ function node_views_data() { // Define some fields based upon views_handler_field_entity in the entity // table so they can be re-used with other query backends. - // @see views_handler_field_entity - + // @see views_handler_field_entity() $data['views_entity_node']['table']['group'] = t('Content'); $data['node']['view_node']['moved to'] = array('views_entity_node', 'view_node'); $data['views_entity_node']['view_node'] = array( 'field' => array( - 'title' => t('Link'), + 'title' => t('Link to content'), 'help' => t('Provide a simple link to the content.'), 'handler' => 'views_handler_field_node_link', ), @@ -237,7 +250,7 @@ function node_views_data() { $data['node']['edit_node']['moved to'] = array('views_entity_node', 'edit_node'); $data['views_entity_node']['edit_node'] = array( 'field' => array( - 'title' => t('Edit link'), + 'title' => t('Link to edit content'), 'help' => t('Provide a simple link to edit the content.'), 'handler' => 'views_handler_field_node_link_edit', ), @@ -246,7 +259,7 @@ function node_views_data() { $data['node']['delete_node']['moved to'] = array('views_entity_node', 'delete_node'); $data['views_entity_node']['delete_node'] = array( 'field' => array( - 'title' => t('Delete link'), + 'title' => t('Link to delete content'), 'help' => t('Provide a simple link to delete the content.'), 'handler' => 'views_handler_field_node_link_delete', ), @@ -260,9 +273,7 @@ function node_views_data() { ), ); - // Bogus fields for aliasing purposes. - $data['node']['created_fulldate'] = array( 'title' => t('Created date'), 'help' => t('Date in the form of CCYYMMDD.'), @@ -371,12 +382,12 @@ function node_views_data() { ), ); - // uid field + // User ID / 'uid' field. $data['node']['uid'] = array( 'title' => t('Author uid'), 'help' => t('The user authoring the content. If you need more fields than the uid add the content: author relationship'), 'relationship' => array( - 'title' => t('Author'), + 'title' => t('Content author'), 'help' => t('Relate content to the user who created it.'), 'handler' => 'views_handler_relationship', 'base' => 'users', @@ -424,18 +435,17 @@ function node_views_data() { ); // ---------------------------------------------------------------------- - // Content revision table - - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + // Content revision table. + // Define the base group of this table. Fields that don't have a group + // defined will go into this field by default. $data['node_revisions']['moved to'] = 'node_revision'; $data['node_revision']['table']['entity type'] = 'node'; $data['node_revision']['table']['revision'] = TRUE; $data['node_revision']['table']['group'] = t('Content revision'); - // Support the conversion of the field body + // Support the conversion of the field body. $data['node_revisions']['body']['moved to'] = array('field_revision_data', 'body-revision_id'); - // Advertise this table as a possible base table + // Advertise this table as a possible base table. $data['node_revision']['table']['base'] = array( 'field' => 'vid', 'title' => t('Content revision'), @@ -445,7 +455,7 @@ function node_views_data() { ), ); - // For other base tables, explain how we join + // For other base tables, explain how we join. $data['node_revision']['table']['join'] = array( // Directly links to node table. 'node' => array( @@ -461,7 +471,7 @@ function node_views_data() { ), ); - // uid field for node revision + // User ID / 'uid' field for node revision. $data['node_revision']['uid'] = array( 'title' => t('User'), 'help' => t('Relate a content revision to the user who created the revision.'), @@ -473,7 +483,7 @@ function node_views_data() { ), ); - // nid + // Node ID / 'nid'. $data['node_revision']['nid'] = array( 'title' => t('Nid'), // The help that appears on the UI. @@ -505,7 +515,7 @@ function node_views_data() { ), ); - // vid + // Revision ID / 'vid'. $data['node_revision']['vid'] = array( 'title' => t('Vid'), // The help that appears on the UI. @@ -537,16 +547,19 @@ function node_views_data() { ), ); - // title + // Title. $data['node_revision']['title'] = array( - 'title' => t('Title'), // The item it appears as on the UI, - 'help' => t('The content title.'), // The help that appears on the UI, - // Information for displaying a title as a field + // The item it appears as on the UI, + 'title' => t('Title'), + // The help that appears on the UI, + 'help' => t('The content title.'), + // Information for displaying a title as a field. 'field' => array( - 'field' => 'title', // the real field + 'field' => 'title', + // The real field. 'handler' => 'views_handler_field_node_revision', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), @@ -558,24 +571,27 @@ function node_views_data() { ), ); - // log field + // Log field. $data['node_revision']['log'] = array( - 'title' => t('Log message'), // The item it appears as on the UI, - 'help' => t('The log message entered when the revision was created.'), // The help that appears on the UI, - // Information for displaying a title as a field + // The item it appears as on the UI, + 'title' => t('Log message'), + // The help that appears on the UI, + 'help' => t('The log message entered when the revision was created.'), + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_xss', - ), + ), 'filter' => array( 'handler' => 'views_handler_filter_string', ), ); - // revision timestamp - // changed field + // Revision timestamp / 'changed' field. $data['node_revision']['timestamp'] = array( - 'title' => t('Updated date'), // The item it appears as on the UI, - 'help' => t('The date the node was last updated.'), // The help that appears on the UI, + // The item it appears as on the UI, + 'title' => t('Updated date'), + // The help that appears on the UI, + 'help' => t('The date the node was last updated.'), 'field' => array( 'handler' => 'views_handler_field_date', 'click sortable' => TRUE, @@ -590,7 +606,7 @@ function node_views_data() { $data['node_revision']['link_to_revision'] = array( 'field' => array( - 'title' => t('Link'), + 'title' => t('Link to revision'), 'help' => t('Provide a simple link to the revision.'), 'handler' => 'views_handler_field_node_revision_link', ), @@ -598,7 +614,7 @@ function node_views_data() { $data['node_revision']['revert_revision'] = array( 'field' => array( - 'title' => t('Revert link'), + 'title' => t('Link to revert revision'), 'help' => t('Provide a simple link to revert to the revision.'), 'handler' => 'views_handler_field_node_revision_link_revert', ), @@ -606,20 +622,19 @@ function node_views_data() { $data['node_revision']['delete_revision'] = array( 'field' => array( - 'title' => t('Delete link'), + 'title' => t('Link to delete revision'), 'help' => t('Provide a simple link to delete the content revision.'), 'handler' => 'views_handler_field_node_revision_link_delete', ), ); // ---------------------------------------------------------------------- - // Node access table - - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + // Node access table. + // Define the base group of this table. Fields that don't have a group + // defined will go into this field by default. $data['node_access']['table']['group'] = t('Content access'); - // For other base tables, explain how we join + // For other base tables, explain how we join. $data['node_access']['table']['join'] = array( // Directly links to node table. 'node' => array( @@ -627,7 +642,7 @@ function node_views_data() { 'field' => 'nid', ), ); - // nid field + // Node ID / 'nid' field. $data['node_access']['nid'] = array( 'title' => t('Access'), 'help' => t('Filter by access.'), @@ -638,11 +653,10 @@ function node_views_data() { ); // ---------------------------------------------------------------------- - // History table - - // We're actually defining a specific instance of the table, so let's - // alias it so that we can later add the real table for other purposes if we - // need it. + // History table. + // We're actually defining a specific instance of the table, so let's alias + // it so that we can later add the real table for other purposes if we need + // it. $data['history_user']['moved to'] = 'history'; $data['history']['table']['group'] = t('Content'); @@ -678,14 +692,17 @@ function node_views_data() { */ function node_views_plugins() { return array( - 'module' => 'views', // This just tells our themes are elsewhere. + 'module' => 'views', + // This just tells our themes are elsewhere. 'row' => array( 'node' => array( 'title' => t('Content'), 'help' => t('Display the content with standard node view.'), 'handler' => 'views_plugin_row_node_view', - 'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules - 'base' => array('node'), // only works with 'node' as base. + 'path' => drupal_get_path('module', 'views') . '/modules/node', + // Not necessary for most modules. + 'base' => array('node'), + // Only works with 'node' as base. 'uses options' => TRUE, 'type' => 'normal', 'help topic' => 'style-node', @@ -694,9 +711,11 @@ function node_views_plugins() { 'title' => t('Content'), 'help' => t('Display the content with standard node view.'), 'handler' => 'views_plugin_row_node_rss', - 'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules + 'path' => drupal_get_path('module', 'views') . '/modules/node', + // Not necessary for most modules. 'theme' => 'views_view_row_rss', - 'base' => array('node'), // only works with 'node' as base. + 'base' => array('node'), + // Only works with 'node' as base. 'uses options' => TRUE, 'type' => 'feed', 'help topic' => 'style-node-rss', @@ -711,7 +730,7 @@ function node_views_plugins() { 'argument default' => array( 'node' => array( 'title' => t('Content ID from URL'), - 'handler' => 'views_plugin_argument_default_node' + 'handler' => 'views_plugin_argument_default_node', ), ), ); @@ -745,7 +764,7 @@ function node_views_query_substitutions() { return array( '***ADMINISTER_NODES***' => intval(user_access('administer nodes')), '***VIEW_OWN_UNPUBLISHED_NODES***' => intval(user_access('view own unpublished content')), - '***BYPASS_NODE_ACCESS***' => intval(user_access('bypass node access')), + '***BYPASS_NODE_ACCESS***' => intval(user_access('bypass node access')), ); } @@ -754,14 +773,14 @@ function node_views_query_substitutions() { */ function node_views_analyze($view) { $ret = array(); - // Check for something other than the default display: + // Check for something other than the default display. if ($view->base_table == 'node') { foreach ($view->display as $id => $display) { if (empty($display->handler)) { continue; } if (!$display->handler->is_defaulted('access') || !$display->handler->is_defaulted('filters')) { - // check for no access control + // Check for no access control. $access = $display->handler->get_option('access'); if (empty($access['type']) || $access['type'] == 'none') { $select = db_select('role', 'r'); diff --git a/sites/all/modules/views/modules/node.views_default.inc b/sites/all/modules/views/modules/node.views_default.inc index de619c1..b46b52c 100644 --- a/sites/all/modules/views/modules/node.views_default.inc +++ b/sites/all/modules/views/modules/node.views_default.inc @@ -6,12 +6,12 @@ */ /** - * Implementation of hook_views_default_views() + * Implements hook_views_default_views(). */ function node_views_default_views() { $views = array(); - $view = new view; + $view = new view(); $view->name = 'archive'; $view->description = 'Display a list of months that link to content for that month.'; $view->tag = 'default'; @@ -99,7 +99,7 @@ function node_views_default_views() { $views['archive'] = $view; - $view = new view; + $view = new view(); $view->name = 'frontpage'; $view->description = 'Emulates the default Drupal front page; you may set the default home page path to this view to make it your front page.'; $view->tag = 'default'; @@ -181,7 +181,7 @@ function node_views_default_views() { $views['frontpage'] = $view; - $view = new view; + $view = new view(); $view->name = 'glossary'; $view->description = 'A list of all content, by letter.'; $view->tag = 'default'; diff --git a/sites/all/modules/views/modules/node.views_template.inc b/sites/all/modules/views/modules/node.views_template.inc index ad89414..861578d 100644 --- a/sites/all/modules/views/modules/node.views_template.inc +++ b/sites/all/modules/views/modules/node.views_template.inc @@ -2,15 +2,19 @@ /** * @file - * Contains views templates on behalf of the node module. + * Definition of views templates on behalf of the node module. */ +/** + * Implements hook_views_templates(). + */ function node_views_templates() { - // Only the standard install profile has the image field provided so only show it for it. + // Only the standard install profile has the image field provided so only + // show it for it. if (variable_get('install_profile', 'standard') != 'standard') { return array(); } - $view = new view; + $view = new view(); $view->name = 'image_gallery'; $view->description = 'Shows all images which was uploaded on the "field_image" field'; $view->tag = ''; diff --git a/sites/all/modules/views/modules/node/views_handler_argument_dates_various.inc b/sites/all/modules/views/modules/node/views_handler_argument_dates_various.inc index d6b2ec4..d80efb5 100644 --- a/sites/all/modules/views/modules/node/views_handler_argument_dates_various.inc +++ b/sites/all/modules/views/modules/node/views_handler_argument_dates_various.inc @@ -2,19 +2,18 @@ /** * @file - * Handlers for various date arguments. - * - * @ingroup views_argument_handlers + * Definition of views_handler_argument_node_created_fulldate. */ /** - * Argument handler for a full date (CCYYMMDD) + * Argument handler for a full date (CCYYMMDD). */ class views_handler_argument_node_created_fulldate extends views_handler_argument_date { + /** - * Constructor implementation + * {@inheritdoc} */ - function construct() { + public function construct() { parent::construct(); $this->format = 'F j, Y'; $this->arg_format = 'Ymd'; @@ -22,46 +21,50 @@ class views_handler_argument_node_created_fulldate extends views_handler_argumen } /** - * Provide a link to the next level of the view + * Provide a link to the next level of the view. */ - function summary_name($data) { + public function summary_name($data) { $created = $data->{$this->name_alias}; return format_date(strtotime($created . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } /** - * Provide a link to the next level of the view + * Provide a link to the next level of the view. */ - function title() { + public function title() { $timestamp = strtotime($this->argument . " 00:00:00 UTC"); if ($timestamp !== FALSE) { return format_date($timestamp, 'custom', $this->format, 'UTC'); } } + } /** - * Argument handler for a year (CCYY) + * Argument handler for a year (CCYY). */ class views_handler_argument_node_created_year extends views_handler_argument_date { + /** - * Constructor implementation + * {@inheritdoc} */ - function construct() { + public function construct() { parent::construct(); $this->arg_format = 'Y'; $this->formula = views_date_sql_extract('YEAR', "***table***.$this->real_field"); } + } /** - * Argument handler for a year plus month (CCYYMM) + * Argument handler for a year plus month (CCYYMM). */ class views_handler_argument_node_created_year_month extends views_handler_argument_date { + /** - * Constructor implementation + * {@inheritdoc} */ - function construct() { + public function construct() { parent::construct(); $this->format = 'F Y'; $this->arg_format = 'Ym'; @@ -71,7 +74,7 @@ class views_handler_argument_node_created_year_month extends views_handler_argum /** * Provide a link to the next level of the view */ - function summary_name($data) { + public function summary_name($data) { $created = $data->{$this->name_alias}; return format_date(strtotime($created . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } @@ -79,22 +82,24 @@ class views_handler_argument_node_created_year_month extends views_handler_argum /** * Provide a link to the next level of the view */ - function title() { + public function title() { $timestamp = strtotime($this->argument . "15" . " 00:00:00 UTC"); if ($timestamp !== FALSE) { return format_date($timestamp, 'custom', $this->format, 'UTC'); } } + } /** - * Argument handler for a month (MM) + * Argument handler for a month (MM). */ class views_handler_argument_node_created_month extends views_handler_argument_date { + /** - * Constructor implementation + * {@inheritdoc} */ - function construct() { + public function construct() { parent::construct(); $this->formula = views_date_sql_extract('MONTH', "***table***.$this->real_field"); $this->format = 'F'; @@ -104,7 +109,7 @@ class views_handler_argument_node_created_month extends views_handler_argument_d /** * Provide a link to the next level of the view */ - function summary_name($data) { + public function summary_name($data) { $month = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT); return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC" ), 'custom', $this->format, 'UTC'); } @@ -112,7 +117,7 @@ class views_handler_argument_node_created_month extends views_handler_argument_d /** * Provide a link to the next level of the view */ - function title() { + public function title() { $month = str_pad($this->argument, 2, '0', STR_PAD_LEFT); $timestamp = strtotime("2005" . $month . "15" . " 00:00:00 UTC"); if ($timestamp !== FALSE) { @@ -120,20 +125,25 @@ class views_handler_argument_node_created_month extends views_handler_argument_d } } - function summary_argument($data) { + /** + * {@inheritdoc} + */ + public function summary_argument($data) { // Make sure the argument contains leading zeroes. return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT); } + } /** - * Argument handler for a day (DD) + * Argument handler for a day (DD). */ class views_handler_argument_node_created_day extends views_handler_argument_date { + /** - * Constructor implementation + * {@inheritdoc} */ - function construct() { + public function construct() { parent::construct(); $this->formula = views_date_sql_extract('DAY', "***table***.$this->real_field"); $this->format = 'j'; @@ -141,18 +151,19 @@ class views_handler_argument_node_created_day extends views_handler_argument_dat } /** - * Provide a link to the next level of the view + * Provide a link to the next level of the view. */ - function summary_name($data) { + public function summary_name($data) { $day = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT); - // strtotime respects server timezone, so we need to set the time fixed as utc time + // strtotime() respects server timezone, so we need to set the time fixed + // as UTC time. return format_date(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } /** - * Provide a link to the next level of the view + * Provide a link to the next level of the view. */ - function title() { + public function title() { $day = str_pad($this->argument, 2, '0', STR_PAD_LEFT); $timestamp = strtotime("2005" . "05" . $day . " 00:00:00 UTC"); if ($timestamp !== FALSE) { @@ -160,30 +171,36 @@ class views_handler_argument_node_created_day extends views_handler_argument_dat } } - function summary_argument($data) { + /** + * {@inheritdoc} + */ + public function summary_argument($data) { // Make sure the argument contains leading zeroes. return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT); } + } /** * Argument handler for a week. */ class views_handler_argument_node_created_week extends views_handler_argument_date { + /** - * Constructor implementation + * {@inheritdoc} */ - function construct() { + public function construct() { parent::construct(); $this->arg_format = 'w'; $this->formula = views_date_sql_extract('WEEK', "***table***.$this->real_field"); } /** - * Provide a link to the next level of the view + * Provide a link to the next level of the view. */ - function summary_name($data) { + public function summary_name($data) { $created = $data->{$this->name_alias}; return t('Week @week', array('@week' => $created)); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_argument_node_language.inc b/sites/all/modules/views/modules/node/views_handler_argument_node_language.inc index 170388a..5effd65 100644 --- a/sites/all/modules/views/modules/node/views_handler_argument_node_language.inc +++ b/sites/all/modules/views/modules/node/views_handler_argument_node_language.inc @@ -9,7 +9,11 @@ * Argument handler to accept a language. */ class views_handler_argument_node_language extends views_handler_argument { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct('language'); } @@ -17,7 +21,7 @@ class views_handler_argument_node_language extends views_handler_argument { * Override the behavior of summary_name(). Get the user friendly version * of the language. */ - function summary_name($data) { + public function summary_name($data) { return $this->node_language($data->{$this->name_alias}); } @@ -25,12 +29,16 @@ class views_handler_argument_node_language extends views_handler_argument { * Override the behavior of title(). Get the user friendly version of the * node type. */ - function title() { + public function title() { return $this->node_language($this->argument); } - function node_language($langcode) { + /** + * + */ + public function node_language($langcode) { $languages = views_language_list(); return isset($languages[$langcode]) ? $languages[$langcode] : t('Unknown language'); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_argument_node_nid.inc b/sites/all/modules/views/modules/node/views_handler_argument_node_nid.inc index b0dbee0..7d64f79 100644 --- a/sites/all/modules/views/modules/node/views_handler_argument_node_nid.inc +++ b/sites/all/modules/views/modules/node/views_handler_argument_node_nid.inc @@ -2,17 +2,18 @@ /** * @file - * Provide node nid argument handler. + * Definition of views_handler_argument_node_nid. */ /** * Argument handler to accept a node id. */ class views_handler_argument_node_nid extends views_handler_argument_numeric { + /** * Override the behavior of title(). Get the title of the node. */ - function title_query() { + public function title_query() { $titles = array(); $result = db_query("SELECT n.title FROM {node} n WHERE n.nid IN (:nids)", array(':nids' => $this->value)); @@ -21,4 +22,5 @@ class views_handler_argument_node_nid extends views_handler_argument_numeric { } return $titles; } + } diff --git a/sites/all/modules/views/modules/node/views_handler_argument_node_type.inc b/sites/all/modules/views/modules/node/views_handler_argument_node_type.inc index ea99d7c..569e81e 100644 --- a/sites/all/modules/views/modules/node/views_handler_argument_node_type.inc +++ b/sites/all/modules/views/modules/node/views_handler_argument_node_type.inc @@ -9,7 +9,11 @@ * Argument handler to accept a node type. */ class views_handler_argument_node_type extends views_handler_argument_string { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct('type'); } @@ -17,7 +21,7 @@ class views_handler_argument_node_type extends views_handler_argument_string { * Override the behavior of summary_name(). Get the user friendly version * of the node type. */ - function summary_name($data) { + public function summary_name($data) { return $this->node_type($data->{$this->name_alias}); } @@ -25,15 +29,25 @@ class views_handler_argument_node_type extends views_handler_argument_string { * Override the behavior of title(). Get the user friendly version of the * node type. */ - function title() { + public function title() { return $this->node_type($this->argument); } - function node_type($type) { + /** + * Get the friendly version of a content type's name. + * + * @param string $type + * The content type to check. + * + * @return string + * The system friendly version of a content type's name. + */ + public function node_type($type) { $output = node_type_get_name($type); if (empty($output)) { $output = t('Unknown content type'); } return check_plain($output); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_argument_node_uid_revision.inc b/sites/all/modules/views/modules/node/views_handler_argument_node_uid_revision.inc index 142882a..ef981f0 100644 --- a/sites/all/modules/views/modules/node/views_handler_argument_node_uid_revision.inc +++ b/sites/all/modules/views/modules/node/views_handler_argument_node_uid_revision.inc @@ -2,17 +2,22 @@ /** * @file - * Defintion of views_handler_argument_node_uid_revision. + * Definition of views_handler_argument_node_uid_revision. */ /** - * Filter handler to accept a user id to check for nodes that - * user posted or created a revision on. + * Filter handler to accept a user id to check for nodes that user posted or + * created a revision on. */ class views_handler_argument_node_uid_revision extends views_handler_argument_comment_user_uid { - function query($group_by = FALSE) { + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { $this->ensure_my_table(); $placeholder = $this->placeholder(); $this->query->add_where_expression(0, "$this->table_alias.uid = $placeholder OR ((SELECT COUNT(*) FROM {node_revision} nr WHERE nr.uid = $placeholder AND nr.nid = $this->table_alias.nid) > 0)", array($placeholder => $this->argument)); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_argument_node_vid.inc b/sites/all/modules/views/modules/node/views_handler_argument_node_vid.inc index 1f970ad..a177804 100644 --- a/sites/all/modules/views/modules/node/views_handler_argument_node_vid.inc +++ b/sites/all/modules/views/modules/node/views_handler_argument_node_vid.inc @@ -2,19 +2,18 @@ /** * @file - * Provide node vid argument handler. + * Definition of views_handler_argument_node_vid. */ /** * Argument handler to accept a node revision id. */ class views_handler_argument_node_vid extends views_handler_argument_numeric { - // No constructor is necessary. /** * Override the behavior of title(). Get the title of the revision. */ - function title_query() { + public function title_query() { $titles = array(); $result = db_query("SELECT n.title FROM {node_revision} n WHERE n.vid IN (:vids)", array(':vids' => $this->value)); @@ -23,4 +22,5 @@ class views_handler_argument_node_vid extends views_handler_argument_numeric { } return $titles; } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_history_user_timestamp.inc b/sites/all/modules/views/modules/node/views_handler_field_history_user_timestamp.inc index dfe4931..bbda56b 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_history_user_timestamp.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_history_user_timestamp.inc @@ -14,7 +14,11 @@ * @ingroup views_field_handlers */ class views_handler_field_history_user_timestamp extends views_handler_field_node { - function init(&$view, &$options) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); global $user; if ($user->uid) { @@ -26,7 +30,10 @@ class views_handler_field_history_user_timestamp extends views_handler_field_nod } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['comments'] = array('default' => FALSE, 'bool' => TRUE); @@ -34,7 +41,10 @@ class views_handler_field_history_user_timestamp extends views_handler_field_nod return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); if (module_exists('comment')) { $form['comments'] = array( @@ -46,7 +56,10 @@ class views_handler_field_history_user_timestamp extends views_handler_field_nod } } - function query() { + /** + * {@inheritdoc} + */ + public function query() { // Only add ourselves to the query if logged in. global $user; if (!$user->uid) { @@ -55,7 +68,10 @@ class views_handler_field_history_user_timestamp extends views_handler_field_nod parent::query(); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { // Let's default to 'read' state. // This code shadows node_mark, but it reads from the db directly and // we already have that info. @@ -65,7 +81,7 @@ class views_handler_field_history_user_timestamp extends views_handler_field_nod $last_read = $this->get_value($values); $changed = $this->get_value($values, 'changed'); - $last_comment = module_exists('comment') && !empty($this->options['comments']) ? $this->get_value($values, 'last_comment') : 0; + $last_comment = module_exists('comment') && !empty($this->options['comments']) ? $this->get_value($values, 'last_comment') : 0; if (!$last_read && $changed > NODE_NEW_LIMIT) { $mark = MARK_NEW; @@ -79,4 +95,5 @@ class views_handler_field_history_user_timestamp extends views_handler_field_nod return $this->render_link(theme('mark', array('type' => $mark)), $values); } } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_node.inc b/sites/all/modules/views/modules/node/views_handler_field_node.inc index f712a53..76c4e87 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_node.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_node.inc @@ -2,21 +2,26 @@ /** * @file - * Contains the basic 'node' field handler. + * Definition of views_handler_field_node. */ /** * Field handler to provide simple renderer that allows linking to a node. + * * Definition terms: - * - link_to_node default: Should this field have the checkbox "link to node" enabled by default. + * - link_to_node default: Should this field have the checkbox "link to node" + * enabled by default. * * @ingroup views_field_handlers */ class views_handler_field_node extends views_handler_field { - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); - // Don't add the additional fields to groupby + // Don't add the additional fields to groupby. if (!empty($this->options['link_to_node'])) { $this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid'); if (module_exists('translation')) { @@ -25,16 +30,19 @@ class views_handler_field_node extends views_handler_field { } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_node'] = array('default' => isset($this->definition['link_to_node default']) ? $this->definition['link_to_node default'] : FALSE, 'bool' => TRUE); return $options; } /** - * Provide link to node option + * Provide link to node option. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['link_to_node'] = array( '#title' => t('Link this field to the original piece of content'), '#description' => t("Enable to override this field's links."), @@ -50,7 +58,7 @@ class views_handler_field_node extends views_handler_field { * * Data should be made XSS safe prior to calling this function. */ - function render_link($data, $values) { + public function render_link($data, $values) { if (!empty($this->options['link_to_node']) && !empty($this->additional_fields['nid'])) { if ($data !== NULL && $data !== '') { $this->options['alter']['make_link'] = TRUE; @@ -73,8 +81,12 @@ class views_handler_field_node extends views_handler_field { return $data; } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->render_link($this->sanitize_value($value), $values); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_node_link.inc b/sites/all/modules/views/modules/node/views_handler_field_node_link.inc index 7e9bbd2..594f62a 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_node_link.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_node_link.inc @@ -12,13 +12,19 @@ */ class views_handler_field_node_link extends views_handler_field_entity { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['text'] = array('default' => '', 'translatable' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['text'] = array( '#type' => 'textfield', '#title' => t('Text to display'), @@ -31,13 +37,19 @@ class views_handler_field_node_link extends views_handler_field_entity { $form['alter']['external'] = array('#access' => FALSE); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { if ($entity = $this->get_value($values)) { return $this->render_link($entity, $values); } } - function render_link($node, $values) { + /** + * {@inheritdoc} + */ + public function render_link($node, $values) { if (node_access('view', $node)) { $this->options['alter']['make_link'] = TRUE; $this->options['alter']['path'] = "node/$node->nid"; @@ -45,4 +57,5 @@ class views_handler_field_node_link extends views_handler_field_entity { return $text; } } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_node_link_delete.inc b/sites/all/modules/views/modules/node/views_handler_field_node_link_delete.inc index 8271c0b..8bc8292 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_node_link_delete.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_node_link_delete.inc @@ -15,7 +15,7 @@ class views_handler_field_node_link_delete extends views_handler_field_node_link /** * Renders the link. */ - function render_link($node, $values) { + public function render_link($node, $values) { // Ensure user has access to delete this node. if (!node_access('delete', $node)) { return; @@ -28,4 +28,5 @@ class views_handler_field_node_link_delete extends views_handler_field_node_link $text = !empty($this->options['text']) ? $this->options['text'] : t('delete'); return $text; } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_node_link_edit.inc b/sites/all/modules/views/modules/node/views_handler_field_node_link_edit.inc index 4e8aad0..b28afc3 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_node_link_edit.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_node_link_edit.inc @@ -15,7 +15,7 @@ class views_handler_field_node_link_edit extends views_handler_field_node_link { /** * Renders the link. */ - function render_link($node, $values) { + public function render_link($node, $values) { // Ensure user has access to edit this node. if (!node_access('update', $node)) { return; @@ -28,4 +28,5 @@ class views_handler_field_node_link_edit extends views_handler_field_node_link { $text = !empty($this->options['text']) ? $this->options['text'] : t('edit'); return $text; } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_node_path.inc b/sites/all/modules/views/modules/node/views_handler_field_node_path.inc index f47f85f..eb66415 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_node_path.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_node_path.inc @@ -2,7 +2,7 @@ /** * @file - * Handler for node path field. + * Definition of views_handler_field_node_path. */ /** @@ -12,19 +12,28 @@ */ class views_handler_field_node_path extends views_handler_field { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['absolute'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function construct() { + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['nid'] = 'nid'; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['absolute'] = array( '#type' => 'checkbox', @@ -35,13 +44,20 @@ class views_handler_field_node_path extends views_handler_field { ); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->add_additional_fields(); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $nid = $this->get_value($values, 'nid'); return url("node/$nid", array('absolute' => $this->options['absolute'])); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_node_revision.inc b/sites/all/modules/views/modules/node/views_handler_field_node_revision.inc index d29b070..1b47d90 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_node_revision.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_node_revision.inc @@ -7,15 +7,15 @@ /** * Contains the basic 'node_revision' field handler. - */ - -/** - * A basic node_revision handler. * * @ingroup views_field_handlers */ class views_handler_field_node_revision extends views_handler_field_node { - function init(&$view, &$options) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); if (!empty($this->options['link_to_node_revision'])) { $this->additional_fields['vid'] = 'vid'; @@ -25,7 +25,11 @@ class views_handler_field_node_revision extends views_handler_field_node { } } } - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_node_revision'] = array('default' => FALSE, 'bool' => TRUE); return $options; @@ -34,7 +38,7 @@ class views_handler_field_node_revision extends views_handler_field_node { /** * Provide link to revision option. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['link_to_node_revision'] = array( '#title' => t('Link this field to its content revision'), '#description' => t('This will override any other link you have set.'), @@ -49,7 +53,7 @@ class views_handler_field_node_revision extends views_handler_field_node { * * Data should be made XSS safe prior to calling this function. */ - function render_link($data, $values) { + public function render_link($data, $values) { if (!empty($this->options['link_to_node_revision']) && $data !== NULL && $data !== '') { $this->options['alter']['make_link'] = TRUE; $nid = $this->get_value($values, 'nid'); @@ -71,4 +75,5 @@ class views_handler_field_node_revision extends views_handler_field_node { } return $data; } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_node_revision_link.inc b/sites/all/modules/views/modules/node/views_handler_field_node_revision_link.inc index 69047bb..0be4230 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_node_revision_link.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_node_revision_link.inc @@ -12,16 +12,25 @@ */ class views_handler_field_node_revision_link extends views_handler_field_node_link { - function construct() { + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['node_vid'] = array('table' => 'node_revision', 'field' => 'vid'); } - function access() { + /** + * {@inheritdoc} + */ + public function access() { return user_access('view revisions') || user_access('administer nodes'); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { list($node, $vid) = $this->get_revision_entity($values, 'view'); if (!isset($vid)) { return; @@ -52,7 +61,7 @@ class views_handler_field_node_revision_link extends views_handler_field_node_li * A numerically indexed array containing the current node object and the * revision ID for this row. */ - function get_revision_entity($values, $op) { + public function get_revision_entity($values, $op) { $vid = $this->get_value($values, 'node_vid'); $node = $this->get_value($values); // Unpublished nodes ignore access control. @@ -63,4 +72,5 @@ class views_handler_field_node_revision_link extends views_handler_field_node_li } return array($node, $vid); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_node_revision_link_delete.inc b/sites/all/modules/views/modules/node/views_handler_field_node_revision_link_delete.inc index e0d00a7..8c07210 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_node_revision_link_delete.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_node_revision_link_delete.inc @@ -12,11 +12,17 @@ */ class views_handler_field_node_revision_link_delete extends views_handler_field_node_revision_link { - function access() { + /** + * {@inheritdoc} + */ + public function access() { return user_access('delete revisions') || user_access('administer nodes'); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { list($node, $vid) = $this->get_revision_entity($values, 'delete'); if (!isset($vid)) { return; @@ -33,4 +39,5 @@ class views_handler_field_node_revision_link_delete extends views_handler_field_ return !empty($this->options['text']) ? $this->options['text'] : t('delete'); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_node_revision_link_revert.inc b/sites/all/modules/views/modules/node/views_handler_field_node_revision_link_revert.inc index af20442..64ea972 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_node_revision_link_revert.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_node_revision_link_revert.inc @@ -12,11 +12,17 @@ */ class views_handler_field_node_revision_link_revert extends views_handler_field_node_revision_link { - function access() { + /** + * {@inheritdoc} + */ + public function access() { return user_access('revert revisions') || user_access('administer nodes'); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { list($node, $vid) = $this->get_revision_entity($values, 'update'); if (!isset($vid)) { return; @@ -33,4 +39,5 @@ class views_handler_field_node_revision_link_revert extends views_handler_field_ return !empty($this->options['text']) ? $this->options['text'] : t('revert'); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_node_type.inc b/sites/all/modules/views/modules/node/views_handler_field_node_type.inc index ba8ee3e..e644649 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_node_type.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_node_type.inc @@ -11,7 +11,11 @@ * @ingroup views_field_handlers */ class views_handler_field_node_type extends views_handler_field_node { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['machine_name'] = array('default' => FALSE, 'bool' => TRUE); @@ -21,7 +25,7 @@ class views_handler_field_node_type extends views_handler_field_node { /** * Provide machine_name option for to node type display. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['machine_name'] = array( @@ -33,17 +37,21 @@ class views_handler_field_node_type extends views_handler_field_node { } /** - * Render node type as human readable name, unless using machine_name option. - */ - function render_name($data, $values) { + * Render node type as human readable name, unless using machine_name option. + */ + public function render_name($data, $values) { if ($this->options['machine_name'] != 1 && $data !== NULL && $data !== '') { return t($this->sanitize_value(node_type_get_name($data))); } return $this->sanitize_value($data); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->render_link($this->render_name($value, $values), $values); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_field_node_version_count.inc b/sites/all/modules/views/modules/node/views_handler_field_node_version_count.inc index 73c2925..058bb7a 100644 --- a/sites/all/modules/views/modules/node/views_handler_field_node_version_count.inc +++ b/sites/all/modules/views/modules/node/views_handler_field_node_version_count.inc @@ -1,4 +1,5 @@ ensure_my_table(); // Add the field. $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); @@ -18,4 +23,5 @@ class views_handler_field_node_version_count extends views_handler_field_numeric $this->add_additional_fields(); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_filter_history_user_timestamp.inc b/sites/all/modules/views/modules/node/views_handler_filter_history_user_timestamp.inc index acdb831..0543acd 100644 --- a/sites/all/modules/views/modules/node/views_handler_filter_history_user_timestamp.inc +++ b/sites/all/modules/views/modules/node/views_handler_filter_history_user_timestamp.inc @@ -14,10 +14,16 @@ * @ingroup views_filter_handlers */ class views_handler_filter_history_user_timestamp extends views_handler_filter { - // Don't display empty space where the operator would be. - var $no_operator = TRUE; - function expose_form(&$form, &$form_state) { + /** + * Don't display empty space where the operator would be. + */ + public $no_operator = TRUE; + + /** + * {@inheritdoc} + */ + public function expose_form(&$form, &$form_state) { parent::expose_form($form, $form_state); // @todo There are better ways of excluding required and multiple (object flags) unset($form['expose']['required']); @@ -25,7 +31,10 @@ class views_handler_filter_history_user_timestamp extends views_handler_filter { unset($form['expose']['remember']); } - function value_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function value_form(&$form, &$form_state) { // Only present a checkbox for the exposed filter itself. There's no way // to tell the difference between not checked and the default value, so // specifying the default value via the views UI is meaningless. @@ -44,7 +53,10 @@ class views_handler_filter_history_user_timestamp extends views_handler_filter { } } - function query() { + /** + * {@inheritdoc} + */ + public function query() { global $user; // This can only work if we're logged in. if (!$user || !$user->uid) { @@ -58,7 +70,6 @@ class views_handler_filter_history_user_timestamp extends views_handler_filter { // Hey, Drupal kills old history, so nodes that haven't been updated // since NODE_NEW_LIMIT are bzzzzzzzt outta here! - $limit = REQUEST_TIME - NODE_NEW_LIMIT; $this->ensure_my_table(); @@ -79,9 +90,13 @@ class views_handler_filter_history_user_timestamp extends views_handler_filter { $this->query->add_where_expression($this->options['group'], "($field IS NULL AND ($node.changed > (***CURRENT_TIME*** - $limit) $clause)) OR $field < $node.changed $clause2"); } - function admin_summary() { + /** + * {@inheritdoc} + */ + public function admin_summary() { if (!empty($this->options['exposed'])) { return t('exposed'); } } + } diff --git a/sites/all/modules/views/modules/node/views_handler_filter_node_access.inc b/sites/all/modules/views/modules/node/views_handler_filter_node_access.inc index a29b13f..71a9c35 100644 --- a/sites/all/modules/views/modules/node/views_handler_filter_node_access.inc +++ b/sites/all/modules/views/modules/node/views_handler_filter_node_access.inc @@ -11,16 +11,30 @@ * @ingroup views_filter_handlers */ class views_handler_filter_node_access extends views_handler_filter { - function admin_summary() { } - function operator_form(&$form, &$form_state) { } - function can_expose() { + + /** + * {@inheritdoc} + */ + public function admin_summary() { + } + + /** + * {@inheritdoc} + */ + public function operator_form(&$form, &$form_state) { + } + + /** + * {@inheritdoc} + */ + public function can_expose() { return FALSE; } /** * See _node_access_where_sql() for a non-views query based implementation. */ - function query() { + public function query() { if (!user_access('administer nodes') && module_implements('node_grants')) { $table = $this->ensure_my_table(); $grants = db_or(); @@ -37,4 +51,5 @@ class views_handler_filter_node_access extends views_handler_filter { $this->query->add_where('AND', $table . '.grant_view', 1, '>='); } } + } diff --git a/sites/all/modules/views/modules/node/views_handler_filter_node_status.inc b/sites/all/modules/views/modules/node/views_handler_filter_node_status.inc index 2afb286..b402d9a 100644 --- a/sites/all/modules/views/modules/node/views_handler_filter_node_status.inc +++ b/sites/all/modules/views/modules/node/views_handler_filter_node_status.inc @@ -11,12 +11,32 @@ * @ingroup views_filter_handlers */ class views_handler_filter_node_status extends views_handler_filter { - function admin_summary() { } - function operator_form(&$form, &$form_state) { } - function can_expose() { return FALSE; } - function query() { + /** + * {@inheritdoc} + */ + public function admin_summary() { + } + + /** + * {@inheritdoc} + */ + public function operator_form(&$form, &$form_state) { + } + + /** + * {@inheritdoc} + */ + public function can_expose() { + return FALSE; + } + + /** + * {@inheritdoc} + */ + public function query() { $table = $this->ensure_my_table(); $this->query->add_where_expression($this->options['group'], "$table.status = 1 OR ($table.uid = ***CURRENT_USER*** AND ***CURRENT_USER*** <> 0 AND ***VIEW_OWN_UNPUBLISHED_NODES*** = 1) OR ***BYPASS_NODE_ACCESS*** = 1"); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_filter_node_type.inc b/sites/all/modules/views/modules/node/views_handler_filter_node_type.inc index 7f8ab4b..f743a87 100644 --- a/sites/all/modules/views/modules/node/views_handler_filter_node_type.inc +++ b/sites/all/modules/views/modules/node/views_handler_filter_node_type.inc @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_node_type extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { if (!isset($this->value_options)) { $this->value_title = t('Content types'); $types = node_type_get_types(); @@ -23,4 +27,5 @@ class views_handler_filter_node_type extends views_handler_filter_in_operator { $this->value_options = $options; } } + } diff --git a/sites/all/modules/views/modules/node/views_handler_filter_node_uid_revision.inc b/sites/all/modules/views/modules/node/views_handler_filter_node_uid_revision.inc index f8f4000..3741ef5 100644 --- a/sites/all/modules/views/modules/node/views_handler_filter_node_uid_revision.inc +++ b/sites/all/modules/views/modules/node/views_handler_filter_node_uid_revision.inc @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_node_uid_revision extends views_handler_filter_user_name { - function query($group_by = FALSE) { + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { $this->ensure_my_table(); $placeholder = $this->placeholder(); @@ -22,4 +26,5 @@ class views_handler_filter_node_uid_revision extends views_handler_filter_user_n ((SELECT COUNT(*) FROM {node_revision} nr WHERE nr.uid IN($placeholder) AND nr.nid = $this->table_alias.nid) > 0)", array($placeholder => $args), $args); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_filter_node_version_count.inc b/sites/all/modules/views/modules/node/views_handler_filter_node_version_count.inc index c39f1d9..3fb7314 100644 --- a/sites/all/modules/views/modules/node/views_handler_filter_node_version_count.inc +++ b/sites/all/modules/views/modules/node/views_handler_filter_node_version_count.inc @@ -1,12 +1,21 @@ operator == 'between') { $this->query->add_where_expression($this->options['group'], '(SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid) BETWEEN :min AND :max', array(':min' => $this->value['min'], ':max' => $this->value['max'])); } @@ -15,11 +24,17 @@ class views_handler_filter_node_version_count extends views_handler_filter_numer } } - function op_simple($field) { + /** + * {@inheritdoc} + */ + public function op_simple($field) { $this->query->add_where_expression($this->options['group'], '(SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid)' . $this->operator . ' :value', array(':value' => $this->value['value'])); } - function op_empty($field) { + /** + * {@inheritdoc} + */ + public function op_empty($field) { if ($this->operator == 'empty') { $operator = "IS NULL"; } @@ -30,7 +45,11 @@ class views_handler_filter_node_version_count extends views_handler_filter_numer $this->query->add_where_expression($this->options['group'], '(SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid) ' . $this->operator); } - function op_regex($field) { + /** + * {@inheritdoc} + */ + public function op_regex($field) { $this->query->add_where_expression($this->options['group'], '(SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid) RLIKE :value', array(':value' => $this->value['value'])); } + } diff --git a/sites/all/modules/views/modules/node/views_handler_sort_node_version_count.inc b/sites/all/modules/views/modules/node/views_handler_sort_node_version_count.inc index a8e1cf6..3abb36a 100644 --- a/sites/all/modules/views/modules/node/views_handler_sort_node_version_count.inc +++ b/sites/all/modules/views/modules/node/views_handler_sort_node_version_count.inc @@ -11,9 +11,14 @@ * @ingroup views_sort_handlers */ class views_handler_sort_node_version_count extends views_handler_sort { - function query() { + + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->query->add_orderby(NULL, '(SELECT COUNT(vid) FROM {node_revision} WHERE nid = {' . $this->table_alias . '}.nid)', $this->options['order'], 'sort_node_version_count'); } + } diff --git a/sites/all/modules/views/modules/node/views_plugin_argument_default_node.inc b/sites/all/modules/views/modules/node/views_plugin_argument_default_node.inc index 65fc0eb..257b39f 100644 --- a/sites/all/modules/views/modules/node/views_plugin_argument_default_node.inc +++ b/sites/all/modules/views/modules/node/views_plugin_argument_default_node.inc @@ -2,16 +2,20 @@ /** * @file - * Contains the node from URL argument default plugin. + * Definition of views_plugin_argument_default_node. */ /** - * Default argument plugin to extract a node via menu_get_object + * Default argument plugin to extract a node via menu_get_object. * * This plugin actually has no options so it odes not need to do a great deal. */ class views_plugin_argument_default_node extends views_plugin_argument_default { - function get_argument() { + + /** + * {@inheritdoc} + */ + public function get_argument() { foreach (range(1, 3) as $i) { $node = menu_get_object('node', $i); if (!empty($node)) { @@ -23,4 +27,5 @@ class views_plugin_argument_default_node extends views_plugin_argument_default { return arg(1); } } + } diff --git a/sites/all/modules/views/modules/node/views_plugin_argument_validate_node.inc b/sites/all/modules/views/modules/node/views_plugin_argument_validate_node.inc index 018965d..5fedbab 100644 --- a/sites/all/modules/views/modules/node/views_plugin_argument_validate_node.inc +++ b/sites/all/modules/views/modules/node/views_plugin_argument_validate_node.inc @@ -2,14 +2,18 @@ /** * @file - * Contains the 'node' argument validator plugin. + * Definition of views_plugin_argument_validate_node. */ /** * Validate whether an argument is an acceptable node. */ class views_plugin_argument_validate_node extends views_plugin_argument_validate { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['types'] = array('default' => array()); $options['access'] = array('default' => FALSE, 'bool' => TRUE); @@ -19,7 +23,10 @@ class views_plugin_argument_validate_node extends views_plugin_argument_validate return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $types = node_type_get_types(); $options = array(); foreach ($types as $type => $info) { @@ -58,12 +65,19 @@ class views_plugin_argument_validate_node extends views_plugin_argument_validate ); } - function options_submit(&$form, &$form_state, &$options = array()) { - // filter trash out of the options so we don't store giant unnecessary arrays + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state, &$options = array()) { + // Filter trash out of the options so we don't store giant unnecessary + // arrays. $options['types'] = array_filter($options['types']); } - function convert_options(&$options) { + /** + * {@inheritdoc} + */ + public function convert_options(&$options) { if (!isset($options['types']) && !empty($this->argument->options['validate_argument_node_type'])) { $options['types'] = isset($this->argument->options['validate_argument_node_type']) ? $this->argument->options['validate_argument_node_type'] : array(); $options['access'] = !empty($this->argument->options['validate_argument_node_access']); @@ -72,7 +86,10 @@ class views_plugin_argument_validate_node extends views_plugin_argument_validate } } - function validate_argument($argument) { + /** + * {@inheritdoc} + */ + public function validate_argument($argument) { $types = $this->options['types']; switch ($this->options['nid_type']) { @@ -99,7 +116,8 @@ class views_plugin_argument_validate_node extends views_plugin_argument_validate } return isset($types[$node->type]); - break; + break; + case 'nids': $nids = new stdClass(); $nids->value = array($argument); @@ -111,7 +129,7 @@ class views_plugin_argument_validate_node extends views_plugin_argument_validate $test = drupal_map_assoc($nids->value); $titles = array(); - $result = db_query("SELECT * FROM {node} WHERE nid IN (:nids)", array(':nids' => $nids->value)); + $result = db_query("SELECT * FROM {node} WHERE nid IN (:nids)", array(':nids' => $nids->value)); foreach ($result as $node) { if ($types && empty($types[$node->type])) { return FALSE; @@ -132,4 +150,5 @@ class views_plugin_argument_validate_node extends views_plugin_argument_validate return empty($test); } } + } diff --git a/sites/all/modules/views/modules/node/views_plugin_row_node_rss.inc b/sites/all/modules/views/modules/node/views_plugin_row_node_rss.inc index 6671892..d9228e4 100644 --- a/sites/all/modules/views/modules/node/views_plugin_row_node_rss.inc +++ b/sites/all/modules/views/modules/node/views_plugin_row_node_rss.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the node RSS row style plugin. + * Definition of views_plugin_row_node_rss. */ /** @@ -10,14 +10,26 @@ * and formats it as an RSS item. */ class views_plugin_row_node_rss extends views_plugin_row { - // Basic properties that let the row style follow relationships. - var $base_table = 'node'; - var $base_field = 'nid'; - // Stores the nodes loaded with pre_render. - var $nodes = array(); + /** + * Basic properties that let the row style follow relationships. + */ + public $base_table = 'node'; - function option_definition() { + /** + * + */ + public $base_field = 'nid'; + + /** + * Stores the nodes loaded with pre_render. + */ + public $nodes = array(); + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['item_length'] = array('default' => 'default'); @@ -29,7 +41,7 @@ class views_plugin_row_node_rss extends views_plugin_row { /** * Override init function to convert fulltext view-mode to full. */ - function init(&$view, &$display, $options = NULL) { + public function init(&$view, &$display, $options = NULL) { parent::init($view, $display, $options); if ($this->options['item_length'] == 'fulltext') { @@ -37,7 +49,10 @@ class views_plugin_row_node_rss extends views_plugin_row { } } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['item_length'] = array( @@ -56,7 +71,7 @@ class views_plugin_row_node_rss extends views_plugin_row { /** * Return the main options, which are shown in the summary title. */ - function options_form_summary_options() { + public function options_form_summary_options() { $entity_info = entity_get_info('node'); $options = array(); if (!empty($entity_info['view modes'])) { @@ -69,13 +84,18 @@ class views_plugin_row_node_rss extends views_plugin_row { return $options; } - function summary_title() { + /** + * {@inheritdoc} + */ + public function summary_title() { $options = $this->options_form_summary_options(); return check_plain($options[$this->options['item_length']]); } - - function pre_render($values) { + /** + * {@inheritdoc} + */ + public function pre_render($values) { $nids = array(); foreach ($values as $row) { $nids[] = $row->{$this->field_alias}; @@ -85,8 +105,11 @@ class views_plugin_row_node_rss extends views_plugin_row { } } - function render($row) { - // For the most part, this code is taken from node_feed() in node.module + /** + * {@inheritdoc} + */ + public function render($row) { + // For the most part; This code is taken from node_feed() in node.module. global $base_url; $nid = $row->{$this->field_alias}; @@ -99,7 +122,7 @@ class views_plugin_row_node_rss extends views_plugin_row { $display_mode = variable_get('feed_item_length', 'teaser'); } - // Load the specified node: + // Load the specified node. $node = $this->nodes[$nid]; if (empty($node)) { return; @@ -128,7 +151,6 @@ class views_plugin_row_node_rss extends views_plugin_row { // The node gets built and modules add to or modify $node->rss_elements // and $node->rss_namespaces. - $build_mode = $display_mode; $build = node_view($node, $build_mode); @@ -168,7 +190,8 @@ class views_plugin_row_node_rss extends views_plugin_row { return theme($this->theme_functions(), array( 'view' => $this->view, 'options' => $this->options, - 'row' => $item + 'row' => $item, )); } + } diff --git a/sites/all/modules/views/modules/node/views_plugin_row_node_view.inc b/sites/all/modules/views/modules/node/views_plugin_row_node_view.inc index 70e4923..f758dfc 100644 --- a/sites/all/modules/views/modules/node/views_plugin_row_node_view.inc +++ b/sites/all/modules/views/modules/node/views_plugin_row_node_view.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the node view row style plugin. + * Definition of views_plugin_row_node_view. */ /** @@ -13,14 +13,26 @@ * @ingroup views_row_plugins */ class views_plugin_row_node_view extends views_plugin_row { - // Basic properties that let the row style follow relationships. - var $base_table = 'node'; - var $base_field = 'nid'; - // Stores the nodes loaded with pre_render. - var $nodes = array(); + /** + * Basic properties that let the row style follow relationships. + */ + public $base_table = 'node'; - function init(&$view, &$display, $options = NULL) { + /** + * + */ + public $base_field = 'nid'; + + /** + * Stores the nodes loaded with pre_render. + */ + public $nodes = array(); + + /** + * {@inheritdoc} + */ + public function init(&$view, &$display, $options = NULL) { parent::init($view, $display, $options); // Handle existing views with the deprecated 'teaser' option. if (isset($this->options['teaser'])) { @@ -32,7 +44,10 @@ class views_plugin_row_node_view extends views_plugin_row { } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['view_mode'] = array('default' => 'teaser'); @@ -42,7 +57,10 @@ class views_plugin_row_node_view extends views_plugin_row { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $options = $this->options_form_summary_options(); @@ -51,7 +69,7 @@ class views_plugin_row_node_view extends views_plugin_row { '#options' => $options, '#title' => t('View mode'), '#default_value' => $this->options['view_mode'], - ); + ); $form['links'] = array( '#type' => 'checkbox', '#title' => t('Display links'), @@ -68,7 +86,7 @@ class views_plugin_row_node_view extends views_plugin_row { /** * Return the main options, which are shown in the summary title. */ - function options_form_summary_options() { + public function options_form_summary_options() { $entity_info = entity_get_info('node'); $options = array(); if (!empty($entity_info['view modes'])) { @@ -79,19 +97,25 @@ class views_plugin_row_node_view extends views_plugin_row { if (empty($options)) { $options = array( 'teaser' => t('Teaser'), - 'full' => t('Full content') + 'full' => t('Full content'), ); } return $options; } - function summary_title() { + /** + * {@inheritdoc} + */ + public function summary_title() { $options = $this->options_form_summary_options(); return check_plain($options[$this->options['view_mode']]); } - function pre_render($values) { + /** + * {@inheritdoc} + */ + public function pre_render($values) { $nids = array(); foreach ($values as $row) { $nids[] = $row->{$this->field_alias}; @@ -99,7 +123,10 @@ class views_plugin_row_node_view extends views_plugin_row { $this->nodes = node_load_multiple($nids); } - function render($row) { + /** + * {@inheritdoc} + */ + public function render($row) { if (isset($this->nodes[$row->{$this->field_alias}])) { $node = $this->nodes[$row->{$this->field_alias}]; $node->view = $this->view; @@ -108,4 +135,5 @@ class views_plugin_row_node_view extends views_plugin_row { return drupal_render($build); } } + } diff --git a/sites/all/modules/views/modules/poll.views.inc b/sites/all/modules/views/modules/poll.views.inc index d3fd76a..58f3b66 100644 --- a/sites/all/modules/views/modules/poll.views.inc +++ b/sites/all/modules/views/modules/poll.views.inc @@ -23,9 +23,8 @@ function poll_views_data() { ); // ---------------------------------------------------------------- - // Fields - - // poll active status + // Fields. + // Poll active status. $data['poll']['active'] = array( 'title' => t('Active'), 'help' => t('Whether the poll is open for voting.'), diff --git a/sites/all/modules/views/modules/profile.views.inc b/sites/all/modules/views/modules/profile.views.inc index 89db913..96fa227 100644 --- a/sites/all/modules/views/modules/profile.views.inc +++ b/sites/all/modules/views/modules/profile.views.inc @@ -12,8 +12,8 @@ */ function profile_views_data() { $data['profile_values']['moved to'] = 'profile_value'; - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + // Define the base group of this table. Fields that don't have a group + // defined will go into this field by default. $data['profile_value']['table']['group'] = t('Profile'); $data['profile_value']['table']['join'] = array( @@ -60,7 +60,7 @@ function profile_views_data() { } /** - * Get all profile fields + * Get all profile fields. */ function profile_views_get_fields() { static $fields = NULL; @@ -71,14 +71,14 @@ function profile_views_get_fields() { foreach ($results as $row) { if (!empty($row->options)) { - if (!in_array(substr($row->options, 0, 2), array('a:', 'b:', 'i:', 'f:', 'o:', 's:', ))) { - // unserialized fields default version + if (!in_array(substr($row->options, 0, 2), array('a:', 'b:', 'i:', 'f:', 'o:', 's:'))) { + // unserialized fields default version. $options = $row->options; unset($row->options); $row->options = $options; } else { - // serialized fields or modified version + // serialized fields or modified version. $row->options = unserialize($row->options); } } @@ -90,7 +90,7 @@ function profile_views_get_fields() { /** - * Add profile fields to view table + * Add profile fields to view table. */ function profile_views_fetch_field($field) { $data = array( @@ -116,8 +116,8 @@ function profile_views_fetch_field($field) { 'handler' => 'views_handler_argument_string', ), ); - break; + case 'textarea': $data += array( 'help' => t('Profile textarea'), @@ -132,8 +132,8 @@ function profile_views_fetch_field($field) { 'handler' => 'views_handler_filter_string', ), ); - break; + case 'checkbox': $data += array( 'help' => t('Profile checkbox'), @@ -148,10 +148,10 @@ function profile_views_fetch_field($field) { 'handler' => 'views_handler_filter_boolean_operator', 'accept null' => TRUE, ), - // @todo there ought to be a boolean argument handler + // @todo There ought to be a boolean argument handler. ); - break; + case 'url': $data += array( 'help' => t('Profile URL'), @@ -166,8 +166,8 @@ function profile_views_fetch_field($field) { 'handler' => 'views_handler_filter_string', ), ); - break; + case 'selection': $data += array( 'help' => t('Profile selection'), @@ -186,8 +186,8 @@ function profile_views_fetch_field($field) { 'handler' => 'views_handler_argument_string', ), ); - break; + case 'list': $data += array( 'help' => t('Profile freeform list %field-name.', array('%field-name' => $field->title)), @@ -199,8 +199,8 @@ function profile_views_fetch_field($field) { 'handler' => 'views_handler_filter_string', ), ); - break; + case 'date': $data += array( 'help' => t('Profile date %field-name.', array('%field-name' => $field->title)), @@ -208,10 +208,9 @@ function profile_views_fetch_field($field) { 'handler' => 'views_handler_field_profile_date', ), ); - break; } - // @todo: add access control to hidden fields. + // @todo Add access control to hidden fields. return $data; } diff --git a/sites/all/modules/views/modules/profile/views_handler_field_profile_date.inc b/sites/all/modules/views/modules/profile/views_handler_field_profile_date.inc index c2cf691..89b099e 100644 --- a/sites/all/modules/views/modules/profile/views_handler_field_profile_date.inc +++ b/sites/all/modules/views/modules/profile/views_handler_field_profile_date.inc @@ -6,7 +6,7 @@ */ /** - * Field handler display a profile date + * Field handler display a profile date. * * The dates are stored serialized, which makes them mostly useless from * SQL. About all we can do is unserialize and display them. @@ -14,16 +14,20 @@ * @ingroup views_field_handlers */ class views_handler_field_profile_date extends views_handler_field_date { - function options_form(&$form, &$form_state) { + + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // we can't do "time ago" so remove it from the form. unset($form['date_format']['#options']['time ago']); } /** - * Display a profile field of type 'date' + * Display a profile field of type 'date'. */ - function render($values) { + public function render($values) { $value = $this->get_value($values); if (!$value) { return; @@ -34,12 +38,15 @@ class views_handler_field_profile_date extends views_handler_field_date { case 'custom': $format = $this->options['custom_date_format']; break; + case 'small': $format = variable_get('date_format_short', 'm/d/Y - H:i'); break; + case 'medium': $format = variable_get('date_format_medium', 'D, m/d/Y - H:i'); break; + case 'large': $format = variable_get('date_format_long', 'l, F j, Y - H:i'); break; @@ -48,12 +55,11 @@ class views_handler_field_profile_date extends views_handler_field_date { // Note: Avoid PHP's date() because it does not handle dates before // 1970 on Windows. This would make the date field useless for e.g. // birthdays. - - // But we *can* deal with non-year stuff: + // But we *can* deal with non-year stuff. $date = gmmktime(0, 0, 0, $value['month'], $value['day'], $value['year']); $replace = array( - // day + // day. 'd' => sprintf('%02d', $value['day']), 'D' => NULL, 'l' => NULL, @@ -61,7 +67,7 @@ class views_handler_field_profile_date extends views_handler_field_date { 'S' => gmdate('S', $date), 'w' => NULL, 'j' => $value['day'], - // month + // month. 'F' => gmdate('F', $date), 'm' => sprintf('%02d', $value['month']), 'M' => gmdate('M', $date), @@ -70,7 +76,7 @@ class views_handler_field_profile_date extends views_handler_field_date { 'Y' => $value['year'], 'y' => substr($value['year'], 2, 2), - // kill time stuff + // kill time stuff. 'a' => NULL, 'A' => NULL, 'g' => NULL, @@ -87,4 +93,5 @@ class views_handler_field_profile_date extends views_handler_field_date { return strtr($format, $replace); } + } diff --git a/sites/all/modules/views/modules/profile/views_handler_field_profile_list.inc b/sites/all/modules/views/modules/profile/views_handler_field_profile_list.inc index 8917b93..5233850 100644 --- a/sites/all/modules/views/modules/profile/views_handler_field_profile_list.inc +++ b/sites/all/modules/views/modules/profile/views_handler_field_profile_list.inc @@ -11,10 +11,11 @@ * @ingroup views_field_handlers */ class views_handler_field_profile_list extends views_handler_field_prerender_list { + /** * Break up our field into a proper list. */ - function pre_render(&$values) { + public function pre_render(&$values) { $this->items = array(); foreach ($values as $value) { $field = $this->get_value($value); @@ -27,15 +28,25 @@ class views_handler_field_profile_list extends views_handler_field_prerender_lis } } - function render_item($count, $item) { + /** + * {@inheritdoc} + */ + public function render_item($count, $item) { return $item['item']; } - function document_self_tokens(&$tokens) { + /** + * {@inheritdoc} + */ + public function document_self_tokens(&$tokens) { $tokens['[' . $this->options['id'] . '-item' . ']'] = t('The text of the profile item.'); } - function add_self_tokens(&$tokens, $item) { + /** + * {@inheritdoc} + */ + public function add_self_tokens(&$tokens, $item) { $tokens['[' . $this->options['id'] . '-item' . ']'] = $item['item']; } + } diff --git a/sites/all/modules/views/modules/profile/views_handler_filter_profile_selection.inc b/sites/all/modules/views/modules/profile/views_handler_filter_profile_selection.inc index d3403c9..29b2c7a 100644 --- a/sites/all/modules/views/modules/profile/views_handler_filter_profile_selection.inc +++ b/sites/all/modules/views/modules/profile/views_handler_filter_profile_selection.inc @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_profile_selection extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { if (isset($this->value_options)) { return; } @@ -27,4 +31,5 @@ class views_handler_filter_profile_selection extends views_handler_filter_in_ope } } } + } diff --git a/sites/all/modules/views/modules/search.views.inc b/sites/all/modules/views/modules/search.views.inc index a956ec2..09aad14 100644 --- a/sites/all/modules/views/modules/search.views.inc +++ b/sites/all/modules/views/modules/search.views.inc @@ -12,12 +12,11 @@ */ function search_views_data() { // Basic table information. - - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + // Define the base group of this table. Fields that don't have a group + // defined will go into this field by default. $data['search_index']['table']['group'] = t('Search'); - // For other base tables, explain how we join + // For other base tables, explain how we join. $data['search_index']['table']['join'] = array( 'node' => array( 'left_field' => 'nid', @@ -35,7 +34,7 @@ function search_views_data() { 'left_table' => 'search_index', 'left_field' => 'word', 'field' => 'word', - ) + ), ); $data['search_dataset']['table']['join'] = array( @@ -56,9 +55,8 @@ function search_views_data() { ); // ---------------------------------------------------------------- - // Fields - - // score + // Fields. + // Score. $data['search_index']['score'] = array( 'title' => t('Score'), 'help' => t('The score of the search item. This will not be used if the search filter is not also present.'), @@ -111,11 +109,13 @@ function search_views_data() { ), ); - // search filter + // Search filter. $data['search_index']['keys'] = array( - 'title' => t('Search Terms'), // The item it appears as on the UI, - 'help' => t('The terms to search for.'), // The help that appears on the UI, - // Information for searching terms using the full search syntax + // The item it appears as on the UI, + 'title' => t('Search Terms'), + // The help that appears on the UI, + 'help' => t('The terms to search for.'), + // Information for searching terms using the full search syntax. 'filter' => array( 'handler' => 'views_handler_filter_search', 'no group by' => TRUE, @@ -135,16 +135,20 @@ function search_views_data() { function search_views_plugins() { return; // DISABLED. This currently doesn't work. + // @todo Fix this. return array( - 'module' => 'views', // This just tells our themes are elsewhere. + 'module' => 'views', + // This just tells our themes are elsewhere. 'row' => array( 'search' => array( 'title' => t('Search'), 'help' => t('Display the results with standard search view.'), 'handler' => 'views_plugin_row_search_view', 'theme' => 'views_view_row_search', - 'path' => drupal_get_path('module', 'views') . '/modules/search', // not necessary for most modules - 'base' => array('node'), // only works with 'node' as base. + 'path' => drupal_get_path('module', 'views') . '/modules/search', + // Not necessary for most modules. + 'base' => array('node'), + // Only works with 'node' as base. 'type' => 'normal', ), 'views_handler_argument_search' => array( @@ -155,16 +159,18 @@ function search_views_plugins() { } /** - * Template helper for theme_views_view_row_search + * Template helper for theme_views_view_row_search. */ function template_preprocess_views_view_row_search(&$vars) { - $vars['node'] = ''; // make sure var is defined. + $vars['node'] = ''; + // Make sure var is defined. $nid = $vars['row']->nid; if (!is_numeric($nid)) { return; } - // @todo: Once the search row is fixed this node_load should be replace by a node_load_multiple + // @todo Once the search row is fixed this node_load should be replace by a + // node_load_multiple(). $node = node_load($nid); if (empty($node)) { @@ -175,10 +181,10 @@ function template_preprocess_views_view_row_search(&$vars) { $node = node_build_content($node, FALSE, FALSE); $node->body = drupal_render($node->content); - // Fetch comments for snippet + // Fetch comments for snippet. $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index'); - // Fetch terms for snippet + // Fetch terms for snippet. $node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index'); $vars['url'] = url('node/' . $nid); @@ -196,7 +202,7 @@ function template_preprocess_views_view_row_search(&$vars) { $vars['info'] = implode(' - ', $info); $vars['node'] = $node; - // @todo: get score from ??? -//$vars['score'] = $item->score; + // @todo Where does the score come from? + // $vars['score'] = $item->score; $vars['snippet'] = search_excerpt($vars['view']->value, $node->body); } diff --git a/sites/all/modules/views/modules/search.views_default.inc b/sites/all/modules/views/modules/search.views_default.inc index dcde622..bfd96b8 100644 --- a/sites/all/modules/views/modules/search.views_default.inc +++ b/sites/all/modules/views/modules/search.views_default.inc @@ -6,12 +6,12 @@ */ /** - * Implementation of hook_views_default_views() + * Implements hook_views_default_views(). */ function search_views_default_views() { $views = array(); - $view = new view; + $view = new view(); $view->name = 'backlinks'; $view->description = 'Displays a list of nodes that link to the node, using the search backlinks table.'; $view->tag = 'default'; diff --git a/sites/all/modules/views/modules/search/views_handler_argument_search.inc b/sites/all/modules/views/modules/search/views_handler_argument_search.inc index 4ab3658..1c2d8f6 100644 --- a/sites/all/modules/views/modules/search/views_handler_argument_search.inc +++ b/sites/all/modules/views/modules/search/views_handler_argument_search.inc @@ -13,12 +13,12 @@ class views_handler_argument_search extends views_handler_argument { /** - * Take sure that parseSearchExpression is runned and everything is set up for it. + * Take sure that parseSearchExpression is runned and everything is set up. * - * @param $input + * @param string $input * The search phrase which was input by the user. */ - function query_parse_search_expression($input) { + public function query_parse_search_expression($input) { if (!isset($this->search_query)) { $this->search_query = db_select('search_index', 'i', array('target' => 'slave'))->extend('viewsSearchQuery'); $this->search_query->searchExpression($input, $this->view->base_table); @@ -29,7 +29,7 @@ class views_handler_argument_search extends views_handler_argument { /** * Add this argument to the query. */ - function query($group_by = FALSE) { + public function query($group_by = FALSE) { $required = FALSE; $this->query_parse_search_expression($this->argument); if (!isset($this->search_query)) { @@ -51,8 +51,9 @@ class views_handler_argument_search extends views_handler_argument { $search_condition = db_and(); - // Create a new join to relate the 'search_total' table to our current 'search_index' table. - $join = new views_join; + // Create a new join to relate the 'search_total' table to our current + // 'search_index' table. + $join = new views_join(); $join->construct('search_total', $search_index, 'word', 'word'); $search_total = $this->query->add_relationship('search_total', $join, $search_index); @@ -70,7 +71,7 @@ class views_handler_argument_search extends views_handler_argument { $search_dataset = $this->query->add_table('search_dataset'); $conditions = $this->search_query->conditions(); $condition_conditions =& $conditions->conditions(); - foreach ($condition_conditions as $key => &$condition) { + foreach ($condition_conditions as $key => &$condition) { // Take sure we just look at real conditions. if (is_numeric($key)) { // Replace the conditions with the table alias of views. @@ -97,4 +98,5 @@ class views_handler_argument_search extends views_handler_argument { $this->query->add_having_expression(0, "COUNT(*) >= $placeholder", array($placeholder => $matches)); } } + } diff --git a/sites/all/modules/views/modules/search/views_handler_field_search_score.inc b/sites/all/modules/views/modules/search/views_handler_field_search_score.inc index 0feddac..3fa26ef 100644 --- a/sites/all/modules/views/modules/search/views_handler_field_search_score.inc +++ b/sites/all/modules/views/modules/search/views_handler_field_search_score.inc @@ -11,7 +11,11 @@ * @ingroup views_field_handlers */ class views_handler_field_search_score extends views_handler_field_numeric { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['alternate_sort'] = array('default' => ''); @@ -20,7 +24,10 @@ class views_handler_field_search_score extends views_handler_field_numeric { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $style_options = $this->view->display_handler->get_option('style_options'); if (isset($style_options['default']) && $style_options['default'] == $this->options['id']) { $handlers = $this->view->display_handler->get_handlers('field'); @@ -48,7 +55,10 @@ class views_handler_field_search_score extends views_handler_field_numeric { parent::options_form($form, $form_state); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { // Check to see if the search filter added 'score' to the table. // Our filter stores it as $handler->search_score -- and we also // need to check its relationship to make sure that we're using the same @@ -65,17 +75,22 @@ class views_handler_field_search_score extends views_handler_field_numeric { $this->options['exclude'] = TRUE; if (!empty($this->options['alternate_sort'])) { if (isset($this->view->style_plugin->options['default']) && $this->view->style_plugin->options['default'] == $this->options['id']) { - // Since the style handler initiates fields, we plug these values right into the active handler. + // Since the style handler initiates fields, we plug these values right + // into the active handler. $this->view->style_plugin->options['default'] = $this->options['alternate_sort']; $this->view->style_plugin->options['order'] = $this->options['alternate_order']; } } } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { // Only render if we exist. if (isset($this->table_alias)) { return parent::render($values); } } + } diff --git a/sites/all/modules/views/modules/search/views_handler_filter_search.inc b/sites/all/modules/views/modules/search/views_handler_filter_search.inc index 3ec53a3..178858b 100644 --- a/sites/all/modules/views/modules/search/views_handler_filter_search.inc +++ b/sites/all/modules/views/modules/search/views_handler_filter_search.inc @@ -2,7 +2,7 @@ /** * @file - * Contains a search filter handler. + * Definition of views_handler_filter_search. */ /** @@ -11,21 +11,28 @@ * @ingroup views_filter_handlers */ class views_handler_filter_search extends views_handler_filter { - var $always_multiple = TRUE; + + /** + * + */ + public $always_multiple = TRUE; /** * Stores a viewsSearchQuery object to be able to use the search.module "api". * * @var viewsSearchQuery */ - var $search_query = NULL; + public $search_query = NULL; /** * Checks if the search query has been parsed. */ - var $parsed = FALSE; + public $parsed = FALSE; - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['operator']['default'] = 'optional'; @@ -35,13 +42,12 @@ class views_handler_filter_search extends views_handler_filter { } /** - * Overrides views_handler_filter::options_form(). - * - * Add an option to remove search scores from the query. + * {@inheritdoc} */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); + // Add an option to remove search scores from the query. $form['remove_score'] = array( '#type' => 'checkbox', '#title' => t('Remove search score'), @@ -50,11 +56,10 @@ class views_handler_filter_search extends views_handler_filter { ); } - /** - * Provide simple equality operator + * Provide simple equality operator. */ - function operator_form(&$form, &$form_state) { + public function operator_form(&$form, &$form_state) { $form['operator'] = array( '#type' => 'radios', '#title' => t('On empty input'), @@ -67,9 +72,9 @@ class views_handler_filter_search extends views_handler_filter { } /** - * Provide a simple textfield for equality + * Provide a simple textfield for equality. */ - function value_form(&$form, &$form_state) { + public function value_form(&$form, &$form_state) { $form['value'] = array( '#type' => 'textfield', '#size' => 15, @@ -82,7 +87,7 @@ class views_handler_filter_search extends views_handler_filter { /** * Validate the options form. */ - function exposed_validate(&$form, &$form_state) { + public function exposed_validate(&$form, &$form_state) { if (!isset($this->options['expose']['identifier'])) { return; } @@ -97,12 +102,12 @@ class views_handler_filter_search extends views_handler_filter { } /** - * Take sure that parseSearchExpression is runned and everything is set up for it. + * Make sure that parseSearchExpression is run and everything is set up. * - * @param $input + * @param string $input * The search phrase which was input by the user. */ - function query_parse_search_expression($input) { + public function query_parse_search_expression($input) { if (!isset($this->search_query)) { $this->parsed = TRUE; $this->search_query = db_select('search_index', 'i', array('target' => 'slave'))->extend('viewsSearchQuery'); @@ -118,7 +123,7 @@ class views_handler_filter_search extends views_handler_filter { * level of indirection. You will find them in $this->operator * and $this->value respectively. */ - function query() { + public function query() { // Since attachment views don't validate the exposed input, parse the search // expression if required. if (!$this->parsed) { @@ -145,8 +150,9 @@ class views_handler_filter_search extends views_handler_filter { $search_condition = db_and(); if (!$this->options['remove_score']) { - // Create a new join to relate the 'serach_total' table to our current 'search_index' table. - $join = new views_join; + // Create a new join to relate the 'serach_total' table to our current + // 'search_index' table. + $join = new views_join(); $join->construct('search_total', $search_index, 'word', 'word'); $search_total = $this->query->add_relationship('search_total', $join, $search_index); @@ -164,7 +170,7 @@ class views_handler_filter_search extends views_handler_filter { $search_dataset = $this->query->add_table('search_dataset'); $conditions = $this->search_query->conditions(); $condition_conditions =& $conditions->conditions(); - foreach ($condition_conditions as $key => &$condition) { + foreach ($condition_conditions as $key => &$condition) { // Take sure we just look at real conditions. if (is_numeric($key)) { // Replace the conditions with the table alias of views. @@ -193,32 +199,53 @@ class views_handler_filter_search extends views_handler_filter { // Set to NULL to prevent PDO exception when views object is cached. $this->search_query = NULL; } + } /** * Extends the core SearchQuery. */ class viewsSearchQuery extends SearchQuery { + + /** + * {@inheritdoc} + */ public function &conditions() { return $this->conditions; } + + /** + * {@inheritdoc} + */ public function words() { return $this->words; } + /** + * {@inheritdoc} + */ public function simple() { return $this->simple; } + /** + * {@inheritdoc} + */ public function matches() { return $this->matches; } + /** + * {@inheritdoc} + */ public function publicParseSearchExpression() { return $this->parseSearchExpression(); } - function condition_replace_string($search, $replace, &$condition) { + /** + * {@inheritdoc} + */ + public function condition_replace_string($search, $replace, &$condition) { if ($condition['field'] instanceof DatabaseCondition) { $conditions =& $condition['field']->conditions(); foreach ($conditions as $key => &$subcondition) { @@ -231,4 +258,5 @@ class viewsSearchQuery extends SearchQuery { $condition['field'] = str_replace($search, $replace, $condition['field']); } } + } diff --git a/sites/all/modules/views/modules/search/views_handler_sort_search_score.inc b/sites/all/modules/views/modules/search/views_handler_sort_search_score.inc index d37fb65..d21c17c 100644 --- a/sites/all/modules/views/modules/search/views_handler_sort_search_score.inc +++ b/sites/all/modules/views/modules/search/views_handler_sort_search_score.inc @@ -11,11 +11,15 @@ * @ingroup views_sort_handlers */ class views_handler_sort_search_score extends views_handler_sort { - function query() { + + /** + * {@inheritdoc} + */ + public function query() { // Check to see if the search filter/argument added 'score' to the table. - // Our filter stores it as $handler->search_score -- and we also - // need to check its relationship to make sure that we're using the same - // one or obviously this won't work. + // Our filter stores it as $handler->search_score -- and we also need to + // check its relationship to make sure that we're using the same one or + // obviously this won't work. foreach (array('filter', 'argument') as $type) { foreach ($this->view->{$type} as $handler) { if (isset($handler->search_score) && $handler->relationship == $this->relationship) { @@ -26,7 +30,8 @@ class views_handler_sort_search_score extends views_handler_sort { } } - // Do absolutely nothing if there is no filter/argument in place; there is no reason to - // sort on the raw scores with this handler. + // Do absolutely nothing if there is no filter/argument in place; there is + // no reason to sort on the raw scores with this handler. } + } diff --git a/sites/all/modules/views/modules/search/views_plugin_row_search_view.inc b/sites/all/modules/views/modules/search/views_plugin_row_search_view.inc index e4aacdc..0579f0d 100644 --- a/sites/all/modules/views/modules/search/views_plugin_row_search_view.inc +++ b/sites/all/modules/views/modules/search/views_plugin_row_search_view.inc @@ -9,7 +9,11 @@ * Plugin which performs a node_view on the resulting object. */ class views_plugin_row_search_view extends views_plugin_row { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['score'] = array('default' => TRUE, 'bool' => TRUE); @@ -17,7 +21,10 @@ class views_plugin_row_search_view extends views_plugin_row { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['score'] = array( '#type' => 'checkbox', '#title' => t('Display score'), @@ -28,12 +35,13 @@ class views_plugin_row_search_view extends views_plugin_row { /** * Override the behavior of the render() function. */ - function render($row) { + public function render($row) { return theme($this->theme_functions(), array( 'view' => $this->view, 'options' => $this->options, - 'row' => $row + 'row' => $row, )); } + } diff --git a/sites/all/modules/views/modules/statistics.views.inc b/sites/all/modules/views/modules/statistics.views.inc index 6d99c5e..3fe0a28 100644 --- a/sites/all/modules/views/modules/statistics.views.inc +++ b/sites/all/modules/views/modules/statistics.views.inc @@ -12,21 +12,19 @@ */ function statistics_views_data() { // Basic table information. - // ---------------------------------------------------------------- - // node_counter table - + // 'node_counter' table. $data['node_counter']['table']['group'] = t('Content statistics'); + // Joins to the node table. $data['node_counter']['table']['join'] = array( - // ...to the node table 'node' => array( 'left_field' => 'nid', 'field' => 'nid', ), ); - // totalcount + // Total count. $data['node_counter']['totalcount'] = array( 'title' => t('Total views'), 'help' => t('The total number of times the node has been viewed.'), @@ -34,7 +32,7 @@ function statistics_views_data() { 'field' => array( 'handler' => 'views_handler_field_statistics_numeric', 'click sortable' => TRUE, - ), + ), 'filter' => array( 'handler' => 'views_handler_filter_numeric', ), @@ -43,7 +41,7 @@ function statistics_views_data() { ), ); - // daycount + // Day count. $data['node_counter']['daycount'] = array( 'title' => t('Views today'), 'help' => t('The total number of times the node has been viewed today.'), @@ -51,7 +49,7 @@ function statistics_views_data() { 'field' => array( 'handler' => 'views_handler_field_statistics_numeric', 'click sortable' => TRUE, - ), + ), 'filter' => array( 'handler' => 'views_handler_filter_numeric', ), @@ -60,7 +58,7 @@ function statistics_views_data() { ), ); - // timestamp + // Timestamp. $data['node_counter']['timestamp'] = array( 'title' => t('Most recent view'), 'help' => t('The most recent time the node has been viewed.'), @@ -77,13 +75,11 @@ function statistics_views_data() { ), ); - // ---------------------------------------------------------------- - // accesslog table - + // 'accesslog' table. $data['accesslog']['table']['group'] = t('Access log'); - // Advertise this table as a possible base table + // Advertise this table as a possible base table. $data['accesslog']['table']['base'] = array( 'field' => 'aid', 'title' => t('Access log'), @@ -91,15 +87,15 @@ function statistics_views_data() { 'weight' => 10, ); - // For other base tables, explain how we join + // For other base tables, explain how we join. $data['accesslog']['table']['join'] = array( 'users' => array( 'field' => 'uid', 'left_field' => 'uid', - ), + ), ); - // accesslog.aid + // Access event ID / 'aid'. $data['accesslog']['aid'] = array( 'title' => t('Aid'), 'help' => t('Unique access event ID.'), @@ -120,7 +116,7 @@ function statistics_views_data() { ), ); - // session id + // Session ID. $data['accesslog']['sid'] = array( 'title' => t('Session ID'), 'help' => t('Browser session ID of user that visited page.'), @@ -128,19 +124,19 @@ function statistics_views_data() { 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, - ), - 'filter' => array( + ), + 'filter' => array( 'handler' => 'views_handler_filter_string', - ), - 'argument' => array( - 'handler' => 'views_handler_argument_string', - ), - 'sort' => array( + ), + 'argument' => array( + 'handler' => 'views_handler_argument_string', + ), + 'sort' => array( 'handler' => 'views_handler_sort', - ), + ), ); - // title + // Title. $data['accesslog']['title'] = array( 'title' => t('Page title'), 'help' => t('Title of page visited.'), @@ -148,62 +144,7 @@ function statistics_views_data() { 'field' => array( 'handler' => 'views_handler_field_accesslog_path', 'click sortable' => TRUE, - ), - 'filter' => array( - 'handler' => 'views_handler_filter_string', - ), - 'sort' => array( - 'handler' => 'views_handler_sort', - ), - 'argument' => array( - 'handler' => 'views_handler_argument_string', - ), - ); - - // path - $data['accesslog']['path'] = array( - 'title' => t('Path'), - 'help' => t('Internal path to page visited (relative to Drupal root.)'), - - 'field' => array( - 'handler' => 'views_handler_field_accesslog_path', - 'click sortable' => TRUE, - ), - 'filter' => array( - 'handler' => 'views_handler_filter_string', - ), - 'sort' => array( - 'handler' => 'views_handler_sort', - ), - //No argument here. Can't send forward slashes as arguments. - //Can be worked around by node ID. - //(but what about aliases?) - ); - - // referrer - $data['accesslog']['url'] = array( - 'title' => t('Referrer'), - 'help' => t('Referrer URI.'), - 'field' => array( - 'handler' => 'views_handler_field_url', - 'click sortable' => TRUE, - ), - 'filter' => array( - 'handler' => 'views_handler_filter_string', ), - 'sort' => array( - 'handler' => 'views_handler_sort', - ), - ); - - // hostname - $data['accesslog']['hostname'] = array( - 'title' => t('Hostname'), - 'help' => t('Hostname of user that visited the page.'), - 'field' => array( - 'handler' => 'views_handler_field', - 'click sortable' => TRUE, - ), 'filter' => array( 'handler' => 'views_handler_filter_string', ), @@ -215,7 +156,61 @@ function statistics_views_data() { ), ); - // user + // Path. + $data['accesslog']['path'] = array( + 'title' => t('Path'), + 'help' => t('Internal path to page visited (relative to Drupal root.)'), + + 'field' => array( + 'handler' => 'views_handler_field_accesslog_path', + 'click sortable' => TRUE, + ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + // No argument here. Can't send forward slashes as arguments. Can be + // worked around by node ID. (but what about aliases?) + ); + + // Referrer. + $data['accesslog']['url'] = array( + 'title' => t('Referrer'), + 'help' => t('Referrer URI.'), + 'field' => array( + 'handler' => 'views_handler_field_url', + 'click sortable' => TRUE, + ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + + // Hostname. + $data['accesslog']['hostname'] = array( + 'title' => t('Hostname'), + 'help' => t('Hostname of user that visited the page.'), + 'field' => array( + 'handler' => 'views_handler_field', + 'click sortable' => TRUE, + ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + 'argument' => array( + 'handler' => 'views_handler_argument_string', + ), + ); + + // User ID / 'uid'. $data['accesslog']['uid'] = array( 'title' => t('User'), 'help' => t('The user who visited the site.'), @@ -223,10 +218,10 @@ function statistics_views_data() { 'handler' => 'views_handler_relationship', 'base' => 'users', 'base field' => 'uid', - ), + ), ); - // timer + // Timer. $data['accesslog']['timer'] = array( 'title' => t('Timer'), 'help' => t('Time in milliseconds that the page took to load.'), @@ -242,7 +237,7 @@ function statistics_views_data() { ), ); - // timestamp + // Timestamp. $data['accesslog']['timestamp'] = array( 'title' => t('Timestamp'), 'help' => t('Timestamp of when the page was visited.'), @@ -258,6 +253,5 @@ function statistics_views_data() { ), ); - return $data; } diff --git a/sites/all/modules/views/modules/statistics.views_default.inc b/sites/all/modules/views/modules/statistics.views_default.inc index 7f527d5..704e033 100644 --- a/sites/all/modules/views/modules/statistics.views_default.inc +++ b/sites/all/modules/views/modules/statistics.views_default.inc @@ -6,12 +6,12 @@ */ /** - * Implementation of hook_views_default_views() + * Implements hook_views_default_views(). */ function statistics_views_default_views() { $views = array(); - $view = new view; + $view = new view(); $view->name = 'popular'; $view->description = 'Shows the most-viewed nodes on the site. This requires the statistics to be enabled at administer >> reports >> access log settings.'; $view->tag = 'default'; diff --git a/sites/all/modules/views/modules/statistics/views_handler_field_accesslog_path.inc b/sites/all/modules/views/modules/statistics/views_handler_field_accesslog_path.inc index 85b2352..a0132a2 100644 --- a/sites/all/modules/views/modules/statistics/views_handler_field_accesslog_path.inc +++ b/sites/all/modules/views/modules/statistics/views_handler_field_accesslog_path.inc @@ -6,22 +6,26 @@ */ /** - * Field handler to provide simple renderer that turns a URL into a clickable link. + * Provide simple renderer that turns a URL into a clickable link. * * @ingroup views_field_handlers */ class views_handler_field_accesslog_path extends views_handler_field { + /** * Override init function to provide generic option to link to node. */ - function init(&$view, &$options) { + public function init(&$view, &$options) { parent::init($view, $options); if (!empty($this->options['display_as_link'])) { $this->additional_fields['path'] = 'path'; } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['display_as_link'] = array('default' => TRUE, 'bool' => TRUE); @@ -32,7 +36,7 @@ class views_handler_field_accesslog_path extends views_handler_field { /** * Provide link to the page being visited. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['display_as_link'] = array( '#title' => t('Display as link'), '#type' => 'checkbox', @@ -41,12 +45,18 @@ class views_handler_field_accesslog_path extends views_handler_field { parent::options_form($form, $form_state); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->render_link($this->sanitize_value($value), $values); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { if (!empty($this->options['display_as_link'])) { $this->options['alter']['make_link'] = TRUE; $this->options['alter']['path'] = $this->get_value($values, 'path'); @@ -55,4 +65,5 @@ class views_handler_field_accesslog_path extends views_handler_field { return $data; } + } diff --git a/sites/all/modules/views/modules/statistics/views_handler_field_node_counter_timestamp.inc b/sites/all/modules/views/modules/statistics/views_handler_field_node_counter_timestamp.inc index d665519..a57c9ff 100644 --- a/sites/all/modules/views/modules/statistics/views_handler_field_node_counter_timestamp.inc +++ b/sites/all/modules/views/modules/statistics/views_handler_field_node_counter_timestamp.inc @@ -11,6 +11,7 @@ * @ingroup views_field_handlers */ class views_handler_field_node_counter_timestamp extends views_handler_field_date { + /** * {@inheritdoc} */ @@ -18,4 +19,5 @@ class views_handler_field_node_counter_timestamp extends views_handler_field_dat // Needs permission to see total page views. return user_access('view post access counter'); } + } diff --git a/sites/all/modules/views/modules/statistics/views_handler_field_statistics_numeric.inc b/sites/all/modules/views/modules/statistics/views_handler_field_statistics_numeric.inc index 3e60c8d..24b79ef 100644 --- a/sites/all/modules/views/modules/statistics/views_handler_field_statistics_numeric.inc +++ b/sites/all/modules/views/modules/statistics/views_handler_field_statistics_numeric.inc @@ -11,6 +11,7 @@ * @ingroup views_field_handlers */ class views_handler_field_statistics_numeric extends views_handler_field_numeric { + /** * {@inheritdoc} */ @@ -18,4 +19,5 @@ class views_handler_field_statistics_numeric extends views_handler_field_numeric // Needs permission to see total page views. return user_access('view post access counter'); } + } diff --git a/sites/all/modules/views/modules/system.views.inc b/sites/all/modules/views/modules/system.views.inc index 243cbc7..b4c93c5 100644 --- a/sites/all/modules/views/modules/system.views.inc +++ b/sites/all/modules/views/modules/system.views.inc @@ -14,23 +14,22 @@ function system_views_data() { $data = array(); // ---------------------------------------------------------------------- - // file_managed table - + // 'file_managed' table. $data['files']['moved to'] = 'file_managed'; $data['file_managed']['table']['group'] = t('File'); - // Advertise this table as a possible base table + // Advertise this table as a possible base table. $data['file_managed']['table']['base'] = array( 'field' => 'fid', 'title' => t('File'), 'help' => t("Files maintained by Drupal and various modules."), 'defaults' => array( - 'field' => 'filename' + 'field' => 'filename', ), ); $data['file_managed']['table']['entity type'] = 'file'; - // fid + // File ID / 'fid'. $data['file_managed']['fid'] = array( 'title' => t('File ID'), 'help' => t('The ID of the file.'), @@ -40,7 +39,8 @@ function system_views_data() { ), 'argument' => array( 'handler' => 'views_handler_argument_file_fid', - 'name field' => 'filename', // the field to display in the summary. + 'name field' => 'filename', + // the field to display in the summary. 'numeric' => TRUE, ), 'filter' => array( @@ -51,14 +51,14 @@ function system_views_data() { ), ); - // filename + // Filename. $data['file_managed']['filename'] = array( 'title' => t('Name'), 'help' => t('The name of the file.'), 'field' => array( 'handler' => 'views_handler_field_file', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), @@ -70,14 +70,14 @@ function system_views_data() { ), ); - // uri + // URI. $data['file_managed']['uri'] = array( 'title' => t('Path'), 'help' => t('The path of the file.'), 'field' => array( 'handler' => 'views_handler_field_file_uri', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), @@ -89,14 +89,14 @@ function system_views_data() { ), ); - // filemime + // The file's MIME Type. $data['file_managed']['filemime'] = array( 'title' => t('Mime type'), 'help' => t('The mime type of the file.'), 'field' => array( 'handler' => 'views_handler_field_file_filemime', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), @@ -108,7 +108,7 @@ function system_views_data() { ), ); - // extension + // Extension. $data['file_managed']['extension'] = array( 'title' => t('Extension'), 'help' => t('The extension of the file.'), @@ -116,17 +116,17 @@ function system_views_data() { 'field' => array( 'handler' => 'views_handler_field_file_extension', 'click sortable' => FALSE, - ), + ), ); - // filesize + // Filesize. $data['file_managed']['filesize'] = array( 'title' => t('Size'), 'help' => t('The size of the file.'), 'field' => array( 'handler' => 'views_handler_field_file_size', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), @@ -135,14 +135,14 @@ function system_views_data() { ), ); - // status + // Status. $data['file_managed']['status'] = array( 'title' => t('Status'), 'help' => t('The status of the file.'), 'field' => array( 'handler' => 'views_handler_field_file_status', 'click sortable' => TRUE, - ), + ), 'sort' => array( 'handler' => 'views_handler_sort', ), @@ -151,7 +151,7 @@ function system_views_data() { ), ); - // timestamp field + // Timestamp field. $data['file_managed']['timestamp'] = array( 'title' => t('Upload date'), 'help' => t('The date the file was uploaded.'), @@ -167,7 +167,7 @@ function system_views_data() { ), ); - // uid + // User ID / 'uid'. $data['file_managed']['uid'] = array( 'title' => t('User who uploaded'), 'help' => t('The user that uploaded the file.'), @@ -180,44 +180,50 @@ function system_views_data() { ); // ---------------------------------------------------------------------- - // file_usage table - + // file_usage table. $data['file_usage']['table']['group'] = t('File Usage'); - // Provide field-type-things to several base tables; on the core files table ("file_managed") so - // that we can create relationships from files to entities, and then on each core entity type base - // table so that we can provide general relationships between entities and files. + // Provide field-type-things to several base tables; on the core files table + // ("file_managed") so that we can create relationships from files to + // entities, and then on each core entity type base table so that we can + // provide general relationships between entities and files. $data['file_usage']['table']['join'] = array( - // Link ourself to the {file_managed} table so we can provide file->entity relationships. + // Link ourself to the {file_managed} table so we can provide file->entity + // relationships. 'file_managed' => array( 'field' => 'fid', 'left_field' => 'fid', ), - // Link ourself to the {node} table so we can provide node->file relationships. + // Link ourself to the {node} table so we can provide node->file + // relationships. 'node' => array( 'field' => 'id', 'left_field' => 'nid', 'extra' => array(array('field' => 'type', 'value' => 'node')), ), - // Link ourself to the {users} table so we can provide user->file relationships. + // Link ourself to the {users} table so we can provide user->file + // relationships. 'users' => array( 'field' => 'id', 'left_field' => 'uid', 'extra' => array(array('field' => 'type', 'value' => 'user')), ), - // Link ourself to the {comment} table so we can provide comment->file relationships. + // Link ourself to the {comment} table so we can provide comment->file + // relationships. 'comment' => array( 'field' => 'id', 'left_field' => 'cid', 'extra' => array(array('field' => 'type', 'value' => 'comment')), ), - // Link ourself to the {taxonomy_term_data} table so we can provide taxonomy_term->file relationships. + // Link ourself to the {taxonomy_term_data} table so we can provide + // taxonomy_term->file relationships. 'taxonomy_term_data' => array( 'field' => 'id', 'left_field' => 'tid', 'extra' => array(array('field' => 'type', 'value' => 'taxonomy_term')), ), - // Link ourself to the {taxonomy_vocabulary} table so we can provide taxonomy_vocabulary->file relationships. + // Link ourself to the {taxonomy_vocabulary} table so we can provide + // taxonomy_vocabulary->file relationships. 'taxonomy_vocabulary' => array( 'field' => 'id', 'left_field' => 'vid', @@ -225,16 +231,16 @@ function system_views_data() { ), ); - // Provide a relationship between the files table and each entity type, and between each entity - // type and the files table. Entity->file relationships are type-restricted in the joins - // declared above, and file->entity relationships are type-restricted in the relationship - // declarations below. - + // Provide a relationship between the files table and each entity type, and + // between each entity type and the files table. Entity->file relationships + // are type-restricted in the joins declared above, and file->entity + // relationships are type-restricted in the relationship declarations below. // Relationships between files and nodes. $data['file_usage']['file_to_node'] = array( 'title' => t('Content'), 'help' => t('Content that is associated with this file, usually because this file is in a field on the content.'), - // Only provide this field/relationship/etc. when the 'file_managed' base table is present. + // Only provide this field/relationship/etc. when the 'file_managed' base + // table is present. 'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'), 'real field' => 'id', 'relationship' => array( @@ -249,7 +255,8 @@ function system_views_data() { $data['file_usage']['node_to_file'] = array( 'title' => t('File'), 'help' => t('A file that is associated with this node, usually because it is in a field on the node.'), - // Only provide this field/relationship/etc. when the 'node' base table is present. + // Only provide this field/relationship/etc. when the 'node' base table is + // present. 'skip base' => array('file_managed', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'), 'real field' => 'fid', 'relationship' => array( @@ -265,7 +272,8 @@ function system_views_data() { $data['file_usage']['file_to_user'] = array( 'title' => t('User'), 'help' => t('A user that is associated with this file, usually because this file is in a field on the user.'), - // Only provide this field/relationship/etc. when the 'file_managed' base table is present. + // Only provide this field/relationship/etc. when the 'file_managed' base + // table is present. 'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'), 'real field' => 'id', 'relationship' => array( @@ -280,7 +288,8 @@ function system_views_data() { $data['file_usage']['user_to_file'] = array( 'title' => t('File'), 'help' => t('A file that is associated with this user, usually because it is in a field on the user.'), - // Only provide this field/relationship/etc. when the 'users' base table is present. + // Only provide this field/relationship/etc. when the 'users' base table is + // present. 'skip base' => array('file_managed', 'node', 'node_revision', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'), 'real field' => 'fid', 'relationship' => array( @@ -296,7 +305,8 @@ function system_views_data() { $data['file_usage']['file_to_comment'] = array( 'title' => t('Comment'), 'help' => t('A comment that is associated with this file, usually because this file is in a field on the comment.'), - // Only provide this field/relationship/etc. when the 'file_managed' base table is present. + // Only provide this field/relationship/etc. when the 'file_managed' base + // table is present. 'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'), 'real field' => 'id', 'relationship' => array( @@ -311,7 +321,8 @@ function system_views_data() { $data['file_usage']['comment_to_file'] = array( 'title' => t('File'), 'help' => t('A file that is associated with this comment, usually because it is in a field on the comment.'), - // Only provide this field/relationship/etc. when the 'comment' base table is present. + // Only provide this field/relationship/etc. when the 'comment' base table + // is present. 'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'taxonomy_term_data', 'taxonomy_vocabulary'), 'real field' => 'fid', 'relationship' => array( @@ -327,7 +338,8 @@ function system_views_data() { $data['file_usage']['file_to_taxonomy_term'] = array( 'title' => t('Taxonomy Term'), 'help' => t('A taxonomy term that is associated with this file, usually because this file is in a field on the taxonomy term.'), - // Only provide this field/relationship/etc. when the 'file_managed' base table is present. + // Only provide this field/relationship/etc. when the 'file_managed' base + // table is present. 'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'), 'real field' => 'id', 'relationship' => array( @@ -342,7 +354,8 @@ function system_views_data() { $data['file_usage']['taxonomy_term_to_file'] = array( 'title' => t('File'), 'help' => t('A file that is associated with this taxonomy term, usually because it is in a field on the taxonomy term.'), - // Only provide this field/relationship/etc. when the 'taxonomy_term_data' base table is present. + // Only provide this field/relationship/etc. when the 'taxonomy_term_data' + // base table is present. 'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'comment', 'taxonomy_vocabulary'), 'real field' => 'fid', 'relationship' => array( @@ -358,7 +371,8 @@ function system_views_data() { $data['file_usage']['file_to_taxonomy_vocabulary'] = array( 'title' => t('Taxonomy Vocabulary'), 'help' => t('A taxonomy vocabulary that is associated with this file, usually because this file is in a field on the taxonomy vocabulary.'), - // Only provide this field/relationship/etc. when the 'file_managed' base table is present. + // Only provide this field/relationship/etc. when the 'file_managed' base + // table is present. 'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'), 'real field' => 'id', 'relationship' => array( @@ -373,7 +387,8 @@ function system_views_data() { $data['file_usage']['taxonomy_vocabulary_to_file'] = array( 'title' => t('File'), 'help' => t('A file that is associated with this taxonomy vocabulary, usually because it is in a field on the taxonomy vocabulary.'), - // Only provide this field/relationship/etc. when the 'taxonomy_vocabulary' base table is present. + // Only provide this field/relationship/etc. when the 'taxonomy_vocabulary' + // base table is present. 'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'comment', 'taxonomy_term_data'), 'real field' => 'fid', 'relationship' => array( @@ -385,15 +400,16 @@ function system_views_data() { ), ); - // Provide basic fields from the {file_usage} table to all of the base tables we've declared - // joins to (because there is no 'skip base' property on these fields). + // Provide basic fields from the {file_usage} table to all of the base tables + // we've declared joins to (because there is no 'skip base' property on these + // fields). $data['file_usage']['module'] = array( 'title' => t('Module'), 'help' => t('The module managing this file relationship.'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, - ), + ), 'filter' => array( 'handler' => 'views_handler_filter_string', ), @@ -410,7 +426,7 @@ function system_views_data() { 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, - ), + ), 'filter' => array( 'handler' => 'views_handler_filter_string', ), @@ -444,7 +460,7 @@ function system_views_data() { 'field' => array( 'handler' => 'views_handler_field_numeric', 'click sortable' => TRUE, - ), + ), 'filter' => array( 'handler' => 'views_handler_filter_numeric', ), @@ -454,18 +470,18 @@ function system_views_data() { ); // ---------------------------------------------------------------------- - // system table + // System table. $data['system']['table']['group'] = t('System'); - // Advertise this table as a possible base table + // Advertise this table as a possible base table. $data['system']['table']['base'] = array( 'field' => 'filename', 'title' => t('Module/Theme/Theme engine'), 'help' => t('Modules/Themes/Theme engines in your codebase.'), ); - // fields - // - filename + // Fields. + // - filename. $data['system']['filename'] = array( 'title' => t('Module/Theme/Theme engine filename'), 'help' => t('The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.'), @@ -474,8 +490,9 @@ function system_views_data() { 'click sortable' => TRUE, ), 'argument' => array( + // The field to display in the summary. 'handler' => 'views_handler_argument_string', - 'name field' => 'filename', // the field to display in the summary. + 'name field' => 'filename', ), 'filter' => array( 'handler' => 'views_handler_filter_string', @@ -484,7 +501,7 @@ function system_views_data() { 'handler' => 'views_handler_sort', ), ); - // - name + // - name. $data['system']['name'] = array( 'title' => t('Module/Theme/Theme engine name'), 'help' => t('The name of the item; e.g. node.'), @@ -493,8 +510,9 @@ function system_views_data() { 'click sortable' => TRUE, ), 'argument' => array( + // The field to display in the summary. 'handler' => 'views_handler_argument_string', - 'name field' => 'name', // the field to display in the summary. + 'name field' => 'name', ), 'filter' => array( 'handler' => 'views_handler_filter_string', @@ -503,7 +521,7 @@ function system_views_data() { 'handler' => 'views_handler_sort', ), ); - // - type + // - type. $data['system']['type'] = array( 'title' => t('Type'), 'help' => t('The type of the item, either module, theme, or theme_engine.'), @@ -512,8 +530,9 @@ function system_views_data() { 'click sortable' => TRUE, ), 'argument' => array( + // The field to display in the summary. 'handler' => 'views_handler_argument_string', - 'name field' => 'type', // the field to display in the summary. + 'name field' => 'type', ), 'filter' => array( 'handler' => 'views_handler_filter_system_type', @@ -522,7 +541,7 @@ function system_views_data() { 'handler' => 'views_handler_sort', ), ); - // - status + // - status. $data['system']['status'] = array( 'title' => t('Status'), 'help' => t('Boolean indicating whether or not this item is enabled.'), @@ -531,8 +550,9 @@ function system_views_data() { 'click sortable' => TRUE, ), 'argument' => array( + // The field to display in the summary. 'handler' => 'views_handler_argument_numeric', - 'name field' => 'status', // the field to display in the summary. + 'name field' => 'status', ), 'filter' => array( 'handler' => 'views_handler_filter_boolean_operator', @@ -541,7 +561,7 @@ function system_views_data() { 'handler' => 'views_handler_sort', ), ); - // - schema version + // - schema version. $data['system']['schema_version'] = array( 'title' => t('Schema version'), 'help' => t("The module's database schema version number. -1 if the module is not installed (its tables do not exist); 0 or the largest N of the module's hook_update_N() function that has either been run or existed when the module was first installed."), @@ -550,8 +570,9 @@ function system_views_data() { 'click sortable' => TRUE, ), 'argument' => array( + // The field to display in the summary. 'handler' => 'views_handler_argument_numeric', - 'name field' => 'schema_version', // the field to display in the summary. + 'name field' => 'schema_version', ), 'filter' => array( 'handler' => 'views_handler_filter_numeric', @@ -564,6 +585,17 @@ function system_views_data() { return $data; } +/** + * Obtain a human readable label for a file's status. + * + * @param int $choice + * Indicate the file's status, expected to be either '0' for a temporary file + * or the value of FILE_STATUS_PERMANENT for a permanent file; any other value + * will be indicated as being 'Unknown'. + * + * @return string + * A string representing the file's status. + */ function _views_file_status($choice = NULL) { $status = array( 0 => t('Temporary'), diff --git a/sites/all/modules/views/modules/system/views_handler_argument_file_fid.inc b/sites/all/modules/views/modules/system/views_handler_argument_file_fid.inc index aa2d947..15860dc 100644 --- a/sites/all/modules/views/modules/system/views_handler_argument_file_fid.inc +++ b/sites/all/modules/views/modules/system/views_handler_argument_file_fid.inc @@ -11,10 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_file_fid extends views_handler_argument_numeric { + /** * Override the behavior of title_query(). Get the filenames. */ - function title_query() { + public function title_query() { $titles = db_select('file_managed', 'f') ->fields('f', array('filename')) ->condition('fid', $this->value) @@ -25,4 +26,5 @@ class views_handler_argument_file_fid extends views_handler_argument_numeric { } return $titles; } + } diff --git a/sites/all/modules/views/modules/system/views_handler_field_file.inc b/sites/all/modules/views/modules/system/views_handler_field_file.inc index 4168acf..a69bca8 100644 --- a/sites/all/modules/views/modules/system/views_handler_field_file.inc +++ b/sites/all/modules/views/modules/system/views_handler_field_file.inc @@ -11,26 +11,30 @@ * @ingroup views_field_handlers */ class views_handler_field_file extends views_handler_field { + /** * Constructor to provide additional field to add. */ - function init(&$view, &$options) { + public function init(&$view, &$options) { parent::init($view, $options); if (!empty($options['link_to_file'])) { $this->additional_fields['uri'] = 'uri'; } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_file'] = array('default' => FALSE, 'bool' => TRUE); return $options; } /** - * Provide link to file option + * Provide link to file option. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['link_to_file'] = array( '#title' => t('Link this field to download the file'), '#description' => t("Enable to override this field's links."), @@ -45,7 +49,7 @@ class views_handler_field_file extends views_handler_field { * * Data should be made XSS safe prior to calling this function. */ - function render_link($data, $values) { + public function render_link($data, $values) { if (!empty($this->options['link_to_file']) && $data !== NULL && $data !== '') { $this->options['alter']['make_link'] = TRUE; $this->options['alter']['path'] = file_create_url($this->get_value($values, 'uri')); @@ -54,8 +58,12 @@ class views_handler_field_file extends views_handler_field { return $data; } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->render_link($this->sanitize_value($value), $values); } + } diff --git a/sites/all/modules/views/modules/system/views_handler_field_file_extension.inc b/sites/all/modules/views/modules/system/views_handler_field_file_extension.inc index b543d8a..55a0db2 100644 --- a/sites/all/modules/views/modules/system/views_handler_field_file_extension.inc +++ b/sites/all/modules/views/modules/system/views_handler_field_file_extension.inc @@ -7,15 +7,23 @@ /** * Returns a pure file extension of the file, for example 'module'. + * * @ingroup views_field_handlers */ class views_handler_field_file_extension extends views_handler_field { + + /** + * {@inheritdoc} + */ public function option_definition() { $options = parent::option_definition(); $options['extension_detect_tar'] = array('default' => FALSE, 'bool' => TRUE); return $options; } + /** + * {@inheritdoc} + */ public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['extension_detect_tar'] = array( @@ -26,7 +34,10 @@ class views_handler_field_file_extension extends views_handler_field { ); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); if (!$this->options['extension_detect_tar']) { if (preg_match('/\.([^\.]+)$/', $value, $match)) { @@ -46,4 +57,5 @@ class views_handler_field_file_extension extends views_handler_field { } } } + } diff --git a/sites/all/modules/views/modules/system/views_handler_field_file_filemime.inc b/sites/all/modules/views/modules/system/views_handler_field_file_filemime.inc index 318fdcf..9648d0f 100644 --- a/sites/all/modules/views/modules/system/views_handler_field_file_filemime.inc +++ b/sites/all/modules/views/modules/system/views_handler_field_file_filemime.inc @@ -6,18 +6,25 @@ */ /** - * Field handler to add rendering MIME type images as an option on the filemime field. + * Add rendering MIME type images as an option on the 'filemime' field. * * @ingroup views_field_handlers */ class views_handler_field_file_filemime extends views_handler_field_file { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['filemime_image'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['filemime_image'] = array( '#title' => t('Display an icon representing the file type, instead of the MIME text (such as "image/jpeg")'), '#type' => 'checkbox', @@ -26,7 +33,10 @@ class views_handler_field_file_filemime extends views_handler_field_file { parent::options_form($form, $form_state); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $data = $values->{$this->field_alias}; if (!empty($this->options['filemime_image']) && $data !== NULL && $data !== '') { $fake_file = (object) array('filemime' => $data); @@ -35,4 +45,5 @@ class views_handler_field_file_filemime extends views_handler_field_file { return $this->render_link($data, $values); } + } diff --git a/sites/all/modules/views/modules/system/views_handler_field_file_status.inc b/sites/all/modules/views/modules/system/views_handler_field_file_status.inc index ac1022c..ecfaf99 100644 --- a/sites/all/modules/views/modules/system/views_handler_field_file_status.inc +++ b/sites/all/modules/views/modules/system/views_handler_field_file_status.inc @@ -11,8 +11,13 @@ * @ingroup views_field_handlers */ class views_handler_field_file_status extends views_handler_field { - function render($values) { + + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return _views_file_status($value); } + } diff --git a/sites/all/modules/views/modules/system/views_handler_field_file_uri.inc b/sites/all/modules/views/modules/system/views_handler_field_file_uri.inc index 334e505..527fdc7 100644 --- a/sites/all/modules/views/modules/system/views_handler_field_file_uri.inc +++ b/sites/all/modules/views/modules/system/views_handler_field_file_uri.inc @@ -6,16 +6,24 @@ */ /** - * Field handler to add rendering file paths as file URLs instead of as internal file URIs. + * Field handler to add rendering file paths as file URLs instead of as internal + * file URIs. */ class views_handler_field_file_uri extends views_handler_field_file { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['file_download_path'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['file_download_path'] = array( '#title' => t('Display download path instead of file storage URI'), '#description' => t('This will provide the full download URL rather than the internal filestream address.'), @@ -25,11 +33,15 @@ class views_handler_field_file_uri extends views_handler_field_file { parent::options_form($form, $form_state); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $data = $values->{$this->field_alias}; if (!empty($this->options['file_download_path']) && $data !== NULL && $data !== '') { $data = file_create_url($data); } return $this->render_link($data, $values); } + } diff --git a/sites/all/modules/views/modules/system/views_handler_filter_file_status.inc b/sites/all/modules/views/modules/system/views_handler_filter_file_status.inc index 6194395..057d1bf 100644 --- a/sites/all/modules/views/modules/system/views_handler_filter_file_status.inc +++ b/sites/all/modules/views/modules/system/views_handler_filter_file_status.inc @@ -11,9 +11,14 @@ * @ingroup views_filter_handlers */ class views_handler_filter_file_status extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { if (!isset($this->value_options)) { $this->value_options = _views_file_status(); } } + } diff --git a/sites/all/modules/views/modules/system/views_handler_filter_system_type.inc b/sites/all/modules/views/modules/system/views_handler_filter_system_type.inc index 84d4bcd..ff6b4bd 100644 --- a/sites/all/modules/views/modules/system/views_handler_filter_system_type.inc +++ b/sites/all/modules/views/modules/system/views_handler_filter_system_type.inc @@ -9,7 +9,11 @@ * Filter by system type. */ class views_handler_filter_system_type extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { if (!isset($this->value_options)) { $this->value_title = t('Type'); // Enable filtering by type. @@ -18,4 +22,5 @@ class views_handler_filter_system_type extends views_handler_filter_in_operator $this->value_options = $types; } } + } diff --git a/sites/all/modules/views/modules/taxonomy.views.inc b/sites/all/modules/views/modules/taxonomy.views.inc index 93c2081..99c3b71 100644 --- a/sites/all/modules/views/modules/taxonomy.views.inc +++ b/sites/all/modules/views/modules/taxonomy.views.inc @@ -14,13 +14,12 @@ function taxonomy_views_data() { $data = array(); // ---------------------------------------------------------------------- - // taxonomy_vocabulary table - + // 'taxonomy_vocabulary' table. $data['vocabulary']['moved to'] = 'taxonomy_vocabulary'; $data['taxonomy_vocabulary']['table']['group'] = t('Taxonomy vocabulary'); - + $data['taxonomy_vocabulary']['table']['entity type'] = 'taxonomy_vocabulary'; $data['taxonomy_vocabulary']['table']['join'] = array( - // vocabulary links to taxonomy_term_data directly via vid. + // Vocabulary links to taxonomy_term_data directly via vid. 'taxonomy_term_data' => array( 'left_field' => 'vid', 'field' => 'vid', @@ -35,9 +34,10 @@ function taxonomy_views_data() { ), ); - // vocabulary name + // Vocabulary name. $data['taxonomy_vocabulary']['name'] = array( - 'title' => t('Name'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Name'), 'field' => array( 'help' => t('Name of the vocabulary a term is a member of. This will be the vocabulary that whichever term the "Taxonomy: Term" field is; and can similarly cause duplicates.'), 'handler' => 'views_handler_field', @@ -49,7 +49,8 @@ function taxonomy_views_data() { ), ); $data['taxonomy_vocabulary']['machine_name'] = array( - 'title' => t('Machine name'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Machine name'), 'field' => array( 'help' => t('Machine-Name of the vocabulary a term is a member of. This will be the vocabulary that whichever term the "Taxonomy: Term" field is; and can similarly cause duplicates.'), 'handler' => 'views_handler_field', @@ -65,7 +66,8 @@ function taxonomy_views_data() { ), ); $data['taxonomy_vocabulary']['vid'] = array( - 'title' => t('Vocabulary ID'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Vocabulary ID'), 'help' => t('The taxonomy vocabulary ID'), 'field' => array( 'handler' => 'views_handler_field_numeric', @@ -80,7 +82,8 @@ function taxonomy_views_data() { ), ); $data['taxonomy_vocabulary']['description'] = array( - 'title' => t('Description'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Description'), 'help' => t('The taxonomy vocabulary description'), 'field' => array( 'handler' => 'views_handler_field', @@ -106,8 +109,7 @@ function taxonomy_views_data() { ); // ---------------------------------------------------------------------- - // taxonomy_term_data table - + // 'taxonomy_term_data' table. $data['term_data']['moved to'] = 'taxonomy_term_data'; $data['taxonomy_term_data']['table']['group'] = t('Taxonomy term'); $data['taxonomy_term_data']['table']['base'] = array( @@ -118,15 +120,13 @@ function taxonomy_views_data() { ); $data['taxonomy_term_data']['table']['entity type'] = 'taxonomy_term'; - - - // The term data table + // The term data table. $data['taxonomy_term_data']['table']['join'] = array( 'taxonomy_vocabulary' => array( 'field' => 'vid', 'left_field' => 'vid', ), - // This is provided for many_to_one argument + // This is provided for many_to_one argument. 'taxonomy_index' => array( 'field' => 'tid', 'left_field' => 'tid', @@ -141,7 +141,7 @@ function taxonomy_views_data() { ), ); - // tid field + // Term ID / 'tid' field. $data['taxonomy_term_data']['tid'] = array( 'title' => t('Term ID'), 'help' => t('The tid of a taxonomy term.'), @@ -166,7 +166,7 @@ function taxonomy_views_data() { ), ); - // raw tid field + // The raw term 'tid' field. $data['taxonomy_term_data']['tid_raw'] = array( 'title' => t('Term ID'), 'help' => t('The tid of a taxonomy term.'), @@ -186,13 +186,13 @@ function taxonomy_views_data() { 'relationship field' => 'tid', 'outer field' => 'taxonomy_term_data.tid', 'argument table' => 'taxonomy_term_data', - 'argument field' => 'tid', + 'argument field' => 'tid', 'base' => 'node', 'field' => 'nid', ), ); - // Term name field + // Term name field. $data['taxonomy_term_data']['name'] = array( 'title' => t('Name'), 'help' => t('The taxonomy term name.'), @@ -215,7 +215,7 @@ function taxonomy_views_data() { ), ); - // taxonomy weight + // Term weight. $data['taxonomy_term_data']['weight'] = array( 'title' => t('Weight'), 'help' => t('The term weight field'), @@ -234,7 +234,7 @@ function taxonomy_views_data() { ), ); - // Term description + // Term description. $data['taxonomy_term_data']['description'] = array( 'title' => t('Term description'), 'help' => t('The description associated with a taxonomy term.'), @@ -247,7 +247,7 @@ function taxonomy_views_data() { ), ); - // Term vocabulary + // Term vocabulary. $data['taxonomy_term_data']['vid'] = array( 'title' => t('Vocabulary'), 'help' => t('Filter the results of "Taxonomy: Term" to a particular vocabulary.'), @@ -256,7 +256,7 @@ function taxonomy_views_data() { ), ); - // Link to edit the term + // Link to edit the term. $data['taxonomy_term_data']['edit_term'] = array( 'field' => array( 'title' => t('Term edit link'), @@ -266,19 +266,18 @@ function taxonomy_views_data() { ); // ---------------------------------------------------------------------- - // taxonomy_index table - + // 'taxonomy_index' table. $data['term_node']['moved to'] = 'taxonomy_index'; $data['taxonomy_index']['table']['group'] = t('Taxonomy term'); $data['taxonomy_index']['table']['join'] = array( 'taxonomy_term_data' => array( - // links directly to taxonomy_term_data via tid + // Links directly to taxonomy_term_data via tid. 'left_field' => 'tid', 'field' => 'tid', ), 'node' => array( - // links directly to node via nid + // Links directly to node via nid. 'left_field' => 'nid', 'field' => 'nid', ), @@ -300,9 +299,8 @@ function taxonomy_views_data() { ), ); - // @todo This stuff needs to move to a node field since - // really it's all about nodes. - // tid field + // @todo Should be moved to a node field since really it's all about nodes. + // Term ID / 'tid' field. $data['taxonomy_index']['tid'] = array( 'group' => t('Content'), 'title' => t('Has taxonomy term ID'), @@ -326,19 +324,18 @@ function taxonomy_views_data() { ); // ---------------------------------------------------------------------- - // term_hierarchy table - + // 'term_hierarchy' table. $data['taxonomy_term_hierarchy']['table']['group'] = t('Taxonomy term'); $data['term_hierarchy']['moved to'] = 'taxonomy_term_hierarchy'; $data['taxonomy_term_hierarchy']['table']['join'] = array( 'taxonomy_term_hierarchy' => array( - // links to self through left.parent = right.tid (going down in depth) + // Links to self through left.parent = right.tid (going down in depth). 'left_field' => 'tid', 'field' => 'parent', ), 'taxonomy_term_data' => array( - // links directly to taxonomy_term_data via tid + // Links directly to taxonomy_term_data via tid. 'left_field' => 'tid', 'field' => 'tid', ), @@ -433,8 +430,8 @@ function taxonomy_views_data_alter(&$data) { /** * Implements hook_field_views_data(). * - * Views integration for taxonomy_term_reference fields. Adds a term relationship to the default - * field data. + * Views integration for taxonomy_term_reference fields. Adds a term + * relationship to the default field data. * * @see field_views_field_default_views_data() */ @@ -455,7 +452,6 @@ function taxonomy_field_views_data($field) { 'base field' => 'tid', 'label' => t('term from !field_name', array('!field_name' => $field['field_name'])), ); - } return $data; @@ -507,12 +503,13 @@ function taxonomy_field_views_data_views_data_alter(&$data, $field) { */ function taxonomy_views_plugins() { return array( - 'module' => 'views', // This just tells our themes are elsewhere. + // This just tells our themes are elsewhere. + 'module' => 'views', 'argument validator' => array( 'taxonomy_term' => array( 'title' => t('Taxonomy term'), 'handler' => 'views_plugin_argument_validate_taxonomy_term', - 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy', // not necessary for most modules + 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy', ), ), 'argument default' => array( diff --git a/sites/all/modules/views/modules/taxonomy.views_default.inc b/sites/all/modules/views/modules/taxonomy.views_default.inc index f43a082..bb6a079 100644 --- a/sites/all/modules/views/modules/taxonomy.views_default.inc +++ b/sites/all/modules/views/modules/taxonomy.views_default.inc @@ -6,12 +6,12 @@ */ /** - * Implementation of hook_views_default_views() + * Implements hook_views_default_views(). */ function taxonomy_views_default_views() { $views = array(); - $view = new view; + $view = new view(); $view->name = 'taxonomy_term'; $view->description = 'A view to emulate Drupal core\'s handling of taxonomy/term.'; $view->tag = 'default'; diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_argument_taxonomy.inc b/sites/all/modules/views/modules/taxonomy/views_handler_argument_taxonomy.inc index 10fc500..0aa04b9 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_argument_taxonomy.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_argument_taxonomy.inc @@ -15,7 +15,7 @@ class views_handler_argument_taxonomy extends views_handler_argument_numeric { /** * Override the behavior of title(). Get the title of the node. */ - function title() { + public function title() { // There might be no valid argument. if ($this->argument) { $term = taxonomy_term_load($this->argument); @@ -23,7 +23,8 @@ class views_handler_argument_taxonomy extends views_handler_argument_numeric { return check_plain($term->name); } } - // TODO review text + // @todo review text. return t('No name'); } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid.inc b/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid.inc index da79f32..c5c8ada 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid.inc @@ -11,13 +11,20 @@ * @ingroup views_argument_handlers */ class views_handler_argument_term_node_tid extends views_handler_argument_many_to_one { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['set_breadcrumb'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['set_breadcrumb'] = array( '#type' => 'checkbox', @@ -27,7 +34,10 @@ class views_handler_argument_term_node_tid extends views_handler_argument_many_t ); } - function set_breadcrumb(&$breadcrumb) { + /** + * {@inheritdoc} + */ + public function set_breadcrumb(&$breadcrumb) { if (empty($this->options['set_breadcrumb']) || !is_numeric($this->argument)) { return; } @@ -35,7 +45,10 @@ class views_handler_argument_term_node_tid extends views_handler_argument_many_t return views_taxonomy_set_breadcrumb($breadcrumb, $this); } - function title_query() { + /** + * {@inheritdoc} + */ + public function title_query() { $titles = array(); $result = db_select('taxonomy_term_data', 'td') ->addTag('taxonomy_term_access') @@ -47,4 +60,5 @@ class views_handler_argument_term_node_tid extends views_handler_argument_many_t } return $titles; } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc b/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc index 116a4de..69f27ab 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc @@ -14,7 +14,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_term_node_tid_depth extends views_handler_argument { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['depth'] = array('default' => 0); @@ -25,7 +29,10 @@ class views_handler_argument_term_node_tid_depth extends views_handler_argument return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['depth'] = array( '#type' => 'weight', '#title' => t('Depth'), @@ -57,7 +64,10 @@ class views_handler_argument_term_node_tid_depth extends views_handler_argument parent::options_form($form, $form_state); } - function set_breadcrumb(&$breadcrumb) { + /** + * {@inheritdoc} + */ + public function set_breadcrumb(&$breadcrumb) { if (empty($this->options['set_breadcrumb']) || !is_numeric($this->argument)) { return; } @@ -68,7 +78,7 @@ class views_handler_argument_term_node_tid_depth extends views_handler_argument /** * Override default_actions() to remove summary actions. */ - function default_actions($which = NULL) { + public function default_actions($which = NULL) { if ($which) { if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) { return parent::default_actions($which); @@ -83,7 +93,10 @@ class views_handler_argument_term_node_tid_depth extends views_handler_argument return $actions; } - function query($group_by = FALSE) { + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { $this->ensure_my_table(); if (!empty($this->options['break_phrase'])) { @@ -134,12 +147,16 @@ class views_handler_argument_term_node_tid_depth extends views_handler_argument $this->query->add_where(0, "$this->table_alias.$this->real_field", $subquery, 'IN'); } - function title() { + /** + * {@inheritdoc} + */ + public function title() { $term = taxonomy_term_load($this->argument); if (!empty($term)) { return check_plain($term->name); } - // TODO review text + // @todo review text. return t('No name'); } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_join.inc b/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_join.inc index 23ac62d..220b0c7 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_join.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_join.inc @@ -14,7 +14,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_term_node_tid_depth_join extends views_handler_argument { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['depth'] = array('default' => 0); @@ -25,7 +29,10 @@ class views_handler_argument_term_node_tid_depth_join extends views_handler_argu return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['depth'] = array( '#type' => 'weight', '#title' => t('Depth'), @@ -57,7 +64,10 @@ class views_handler_argument_term_node_tid_depth_join extends views_handler_argu parent::options_form($form, $form_state); } - function set_breadcrumb(&$breadcrumb) { + /** + * {@inheritdoc} + */ + public function set_breadcrumb(&$breadcrumb) { if (empty($this->options['set_breadcrumb']) || !is_numeric($this->argument)) { return; } @@ -68,7 +78,7 @@ class views_handler_argument_term_node_tid_depth_join extends views_handler_argu /** * Override default_actions() to remove summary actions. */ - function default_actions($which = NULL) { + public function default_actions($which = NULL) { if ($which) { if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) { return parent::default_actions($which); @@ -83,7 +93,10 @@ class views_handler_argument_term_node_tid_depth_join extends views_handler_argu return $actions; } - function query($group_by = FALSE) { + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { $this->ensure_my_table(); if (!empty($this->options['break_phrase'])) { @@ -172,7 +185,7 @@ class views_handler_argument_term_node_tid_depth_join extends views_handler_argu 'field' => 'tid', 'value' => $tids, 'operator' => $operator, - ) + ), ); $taxonomy_index_alias = $this->query->add_relationship('taxonomy_index', $join, 'node'); @@ -180,7 +193,10 @@ class views_handler_argument_term_node_tid_depth_join extends views_handler_argu $this->query->distinct = TRUE; } - function title() { + /** + * + */ + public function title() { $term = taxonomy_term_load($this->argument); if (!empty($term)) { return check_plain($term->name); @@ -188,4 +204,5 @@ class views_handler_argument_term_node_tid_depth_join extends views_handler_argu return t('No name'); } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc b/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc index 2f9dd4e..b911378 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_argument_term_node_tid_depth_modif. + * Definition of views_handler_argument_term_node_tid_depth_modifier. */ /** @@ -14,10 +14,24 @@ * @ingroup views_argument_handlers */ class views_handler_argument_term_node_tid_depth_modifier extends views_handler_argument { - function options_form(&$form, &$form_state) { } - function query($group_by = FALSE) { } - function pre_query() { - // We don't know our argument yet, but it's based upon our position: + + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { + } + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { + } + + /** + * {@inheritdoc} + */ + public function pre_query() { + // We don't know our argument yet, but it's based upon our position. $argument = isset($this->view->args[$this->position]) ? $this->view->args[$this->position] : NULL; if (!is_numeric($argument)) { return; @@ -31,7 +45,7 @@ class views_handler_argument_term_node_tid_depth_modifier extends views_handler_ $argument = -10; } - // figure out which argument preceded us. + // Figure out which argument preceded us. $keys = array_reverse(array_keys($this->view->argument)); $skip = TRUE; foreach ($keys as $key) { @@ -61,4 +75,5 @@ class views_handler_argument_term_node_tid_depth_modifier extends views_handler_ $handler->options['depth'] = $argument; } } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_machine_name.inc b/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_machine_name.inc index 427cf2b..066ce05 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_machine_name.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_machine_name.inc @@ -11,10 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_vocabulary_machine_name extends views_handler_argument_string { + /** * Override the behavior of title(). Get the name of the vocabulary.. */ - function title() { + public function title() { $title = db_query("SELECT v.name FROM {taxonomy_vocabulary} v WHERE v.machine_name = :machine_name", array(':machine_name' => $this->argument))->fetchField(); if (empty($title)) { @@ -23,4 +24,5 @@ class views_handler_argument_vocabulary_machine_name extends views_handler_argum return check_plain($title); } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_vid.inc b/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_vid.inc index c696640..6030a88 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_vid.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_argument_vocabulary_vid.inc @@ -11,10 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_vocabulary_vid extends views_handler_argument_numeric { + /** * Override the behavior of title(). Get the name of the vocabulary. */ - function title() { + public function title() { $title = db_query("SELECT v.name FROM {taxonomy_vocabulary} v WHERE v.vid = :vid", array(':vid' => $this->argument))->fetchField(); if (empty($title)) { @@ -23,4 +24,5 @@ class views_handler_argument_vocabulary_vid extends views_handler_argument_numer return check_plain($title); } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_field_taxonomy.inc b/sites/all/modules/views/modules/taxonomy/views_handler_field_taxonomy.inc index 192b803..9be652e 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_field_taxonomy.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_field_taxonomy.inc @@ -12,13 +12,14 @@ * @ingroup views_field_handlers */ class views_handler_field_taxonomy extends views_handler_field { + /** * Constructor to provide additional field to add. * * This constructer assumes the taxonomy_term_data table. If using another * table, we'll need to be more specific. */ - function construct() { + public function construct() { parent::construct(); $this->additional_fields['vid'] = 'vid'; $this->additional_fields['tid'] = 'tid'; @@ -29,7 +30,10 @@ class views_handler_field_taxonomy extends views_handler_field { ); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_taxonomy'] = array('default' => FALSE, 'bool' => TRUE); $options['convert_spaces'] = array('default' => FALSE, 'bool' => TRUE); @@ -37,16 +41,16 @@ class views_handler_field_taxonomy extends views_handler_field { } /** - * Provide link to taxonomy option + * Provide link to taxonomy option. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['link_to_taxonomy'] = array( '#title' => t('Link this field to its taxonomy term page'), '#description' => t("Enable to override this field's links."), '#type' => 'checkbox', '#default_value' => !empty($this->options['link_to_taxonomy']), ); - $form['convert_spaces'] = array( + $form['convert_spaces'] = array( '#title' => t('Convert spaces in term names to hyphens'), '#description' => t('This allows links to work with Views taxonomy term arguments.'), '#type' => 'checkbox', @@ -60,7 +64,7 @@ class views_handler_field_taxonomy extends views_handler_field { * * Data should be made XSS safe prior to calling this function. */ - function render_link($data, $values) { + public function render_link($data, $values) { $tid = $this->get_value($values, 'tid'); if (!empty($this->options['link_to_taxonomy']) && !empty($tid) && $data !== NULL && $data !== '') { $term = new stdClass(); @@ -87,8 +91,12 @@ class views_handler_field_taxonomy extends views_handler_field { return $data; } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->render_link($this->sanitize_value($value), $values); } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_field_term_link_edit.inc b/sites/all/modules/views/modules/taxonomy/views_handler_field_term_link_edit.inc index 2efb4a6..3bd3212 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_field_term_link_edit.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_field_term_link_edit.inc @@ -11,7 +11,11 @@ * @ingroup views_field_handlers */ class views_handler_field_term_link_edit extends views_handler_field { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['tid'] = 'tid'; $this->additional_fields['vid'] = 'vid'; @@ -21,7 +25,10 @@ class views_handler_field_term_link_edit extends views_handler_field { ); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['text'] = array('default' => '', 'translatable' => TRUE); @@ -29,7 +36,10 @@ class views_handler_field_term_link_edit extends views_handler_field { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['text'] = array( '#type' => 'textfield', '#title' => t('Text to display'), @@ -38,25 +48,38 @@ class views_handler_field_term_link_edit extends views_handler_field { parent::options_form($form, $form_state); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->add_additional_fields(); } + /** + * {@inheritdoc} + */ function render($values) { - // Check there is an actual value, as on a relationship there may not be. - if ($tid = $this->get_value($values, 'tid')) { - // Mock a term object for taxonomy_term_edit_access(). Use machine name and - // vid to ensure compatibility with vid based and machine name based - // access checks. See http://drupal.org/node/995156 - $term = new stdClass(); - $term->vid = $values->{$this->aliases['vid']}; - $term->vocabulary_machine_name = $values->{$this->aliases['vocabulary_machine_name']}; - if (taxonomy_term_edit_access($term)) { - $text = !empty($this->options['text']) ? $this->options['text'] : t('edit'); - $tid = $this->get_value($values, 'tid'); - return l($text, 'taxonomy/term/'. $tid . '/edit', array('query' => drupal_get_destination())); - } + $value = $this->get_value($values, 'tid'); + return $this->render_link($this->sanitize_value($value), $values); + } + + /** + * {@inheritdoc} + */ + function render_link($data, $values) { + // Mock a term object for taxonomy_term_edit_access(). Use machine name and + // vid to ensure compatibility with vid based and machine name based + // access checks. See http://drupal.org/node/995156 + $term = new stdClass(); + $term->vid = $values->{$this->aliases['vid']}; + $term->vocabulary_machine_name = $values->{$this->aliases['vocabulary_machine_name']}; + if ($data && taxonomy_term_edit_access($term)) { + $text = !empty($this->options['text']) ? $this->options['text'] : t('edit'); + $this->options['alter']['path'] = "taxonomy/term/$data/edit"; + $this->options['alter']['query'] = drupal_get_destination(); + return $text; } } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc b/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc index 658b21e..67bb2a5 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc @@ -11,9 +11,13 @@ * @ingroup views_field_handlers */ class views_handler_field_term_node_tid extends views_handler_field_prerender_list { - function init(&$view, &$options) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); - // @todo: Wouldn't it be possible to use $this->base_table and no if here? + // @todo Wouldn't it be possible to use $this->base_table and no if here? if ($view->base_table == 'node_revision') { $this->additional_fields['nid'] = array('table' => 'node_revision', 'field' => 'nid'); } @@ -32,7 +36,10 @@ class views_handler_field_term_node_tid extends views_handler_field_prerender_li } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_taxonomy'] = array('default' => TRUE, 'bool' => TRUE); @@ -45,7 +52,7 @@ class views_handler_field_term_node_tid extends views_handler_field_prerender_li /** * Provide "link to term" option. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['link_to_taxonomy'] = array( '#title' => t('Link this field to its term page'), '#type' => 'checkbox', @@ -55,7 +62,7 @@ class views_handler_field_term_node_tid extends views_handler_field_prerender_li $form['limit'] = array( '#type' => 'checkbox', '#title' => t('Limit terms by vocabulary'), - '#default_value'=> $this->options['limit'], + '#default_value' => $this->options['limit'], ); $options = array(); @@ -78,13 +85,16 @@ class views_handler_field_term_node_tid extends views_handler_field_prerender_li } /** - * Add this term to the query + * Add this term to the query. */ - function query() { + public function query() { $this->add_additional_fields(); } - function pre_render(&$values) { + /** + * {@inheritdoc} + */ + public function pre_render(&$values) { $this->field_alias = $this->aliases['nid']; $nids = array(); foreach ($values as $result) { @@ -125,21 +135,31 @@ class views_handler_field_term_node_tid extends views_handler_field_prerender_li } } - function render_item($count, $item) { + /** + * {@inheritdoc} + */ + public function render_item($count, $item) { return $item['name']; } - function document_self_tokens(&$tokens) { + /** + * {@inheritdoc} + */ + public function document_self_tokens(&$tokens) { $tokens['[' . $this->options['id'] . '-tid' . ']'] = t('The taxonomy term ID for the term.'); $tokens['[' . $this->options['id'] . '-name' . ']'] = t('The taxonomy term name for the term.'); $tokens['[' . $this->options['id'] . '-vocabulary-machine-name' . ']'] = t('The machine name for the vocabulary the term belongs to.'); $tokens['[' . $this->options['id'] . '-vocabulary' . ']'] = t('The name for the vocabulary the term belongs to.'); } - function add_self_tokens(&$tokens, $item) { - foreach(array('tid', 'name', 'vocabulary_machine_name', 'vocabulary') as $token) { + /** + * {@inheritdoc} + */ + public function add_self_tokens(&$tokens, $item) { + foreach (array('tid', 'name', 'vocabulary_machine_name', 'vocabulary') as $token) { // Replace _ with - for the vocabulary machine name. - $tokens['[' . $this->options['id'] . '-' . str_replace('_', '-', $token). ']'] = isset($item[$token]) ? $item[$token] : ''; + $tokens['[' . $this->options['id'] . '-' . str_replace('_', '-', $token) . ']'] = isset($item[$token]) ? $item[$token] : ''; } } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc b/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc index 6c33392..03b8d11 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc @@ -11,10 +11,16 @@ * @ingroup views_filter_handlers */ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_one { - // Stores the exposed input for this filter. - var $validated_exposed_input = NULL; - function init(&$view, &$options) { + /** + * Stores the exposed input for this filter. + */ + public $validated_exposed_input = NULL; + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); if (!empty($this->definition['vocabulary'])) { $this->options['vocabulary'] = $this->definition['vocabulary']; @@ -30,11 +36,24 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on } } - function has_extra_options() { return TRUE; } + /** + * {@inheritdoc} + */ + public function has_extra_options() { + return TRUE; + } - function get_value_options() { /* don't overwrite the value options */ } + /** + * {@inheritdoc} + */ + public function get_value_options() { + // Don't overwrite the value options. + } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['type'] = array('default' => 'textfield'); @@ -42,11 +61,15 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on $options['vocabulary'] = array('default' => 0); $options['hierarchy'] = array('default' => 0); $options['error_message'] = array('default' => TRUE, 'bool' => TRUE); + $options['optgroups'] = array('default' => 0); return $options; } - function extra_options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function extra_options_form(&$form, &$form_state) { $vocabularies = taxonomy_get_vocabularies(); $options = array(); foreach ($vocabularies as $voc) { @@ -84,9 +107,20 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on '#default_value' => !empty($this->options['hierarchy']), '#dependency' => array('radio:options[type]' => array('select')), ); + + $form['optgroups'] = array( + '#type' => 'checkbox', + '#title' => t('Show groups in dropdown'), + '#default_value' => !empty($this->options['optgroups']), + '#dependency' => array('radio:options[type]' => array('select')), + ); + } - function value_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function value_form(&$form, &$form_state) { $vocabulary = taxonomy_vocabulary_machine_name_load($this->options['vocabulary']); if (empty($vocabulary) && $this->options['limit']) { $form['markup'] = array( @@ -120,14 +154,22 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on else { if (!empty($this->options['hierarchy']) && $this->options['limit']) { $tree = taxonomy_get_tree($vocabulary->vid, 0, NULL, TRUE); - $options = array(); - - if ($tree) { - // Translation system needs full entity objects, so we have access to label. - foreach ($tree as $term) { - $choice = new stdClass(); - $choice->option = array($term->tid => str_repeat('-', $term->depth) . entity_label('taxonomy_term', $term)); - $options[] = $choice; + if (!empty($tree)) { + if (!empty($this->options['optgroups'])) { + foreach ($tree as $term) { + $term_name = entity_label('taxonomy_term', $term); + if ($term->parents[0] == 0) { + $parent_name = $term_name; + } + else { + $options[$parent_name][$term->tid] = str_repeat('-', $term->depth - 1) . $term_name; + } + } + } + else { + foreach ($tree as $term) { + $options[$term->tid] = str_repeat('-', $term->depth) . entity_label('taxonomy_term', $term); + } } } } @@ -177,8 +219,8 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on $keys = array_keys($options); $default_value = array_shift($keys); } - // Due to #1464174 there is a chance that array('') was saved in the admin ui. - // Let's choose a safe default value. + // Due to #1464174 there is a chance that array('') was saved in the + // admin UI. Let's choose a safe default value. elseif ($default_value == array('')) { $default_value = 'All'; } @@ -212,7 +254,10 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on } } - function value_validate($form, &$form_state) { + /** + * {@inheritdoc} + */ + public function value_validate($form, &$form_state) { // We only validate if they've chosen the text field style. if ($this->options['type'] != 'textfield') { return; @@ -226,7 +271,10 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on } } - function accept_exposed_input($input) { + /** + * {@inheritdoc} + */ + public function accept_exposed_input($input) { if (empty($this->options['exposed'])) { return TRUE; } @@ -266,7 +314,10 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on return $rc; } - function exposed_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function exposed_validate(&$form, &$form_state) { if (empty($this->options['exposed'])) { return; } @@ -298,15 +349,15 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on * or the exposed filter, this is abstracted out a bit so it can * handle the multiple input sources. * - * @param $form + * @param array $form * The form which is used, either the views ui or the exposed filters. - * @param $values + * @param array $values * The taxonomy names which will be converted to tids. * * @return array * The taxonomy ids fo all validated terms. */ - function validate_term_strings(&$form, $values) { + public function validate_term_strings(&$form, $values) { if (empty($values)) { return array(); } @@ -345,11 +396,17 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on return $tids; } - function value_submit($form, &$form_state) { + /** + * {@inheritdoc} + */ + public function value_submit($form, &$form_state) { // prevent array_filter from messing up our arrays in parent submit. } - function expose_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function expose_form(&$form, &$form_state) { parent::expose_form($form, $form_state); if ($this->options['type'] != 'select') { unset($form['expose']['reduce']); @@ -361,7 +418,10 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on ); } - function admin_summary() { + /** + * {@inheritdoc} + */ + public function admin_summary() { // set up $this->value_options for the parent summary $this->value_options = array(); @@ -374,4 +434,5 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on } return parent::admin_summary(); } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth.inc b/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth.inc index fe12780..872d90e 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth.inc @@ -14,13 +14,20 @@ * @ingroup views_filter_handlers */ class views_handler_filter_term_node_tid_depth extends views_handler_filter_term_node_tid { - function operator_options($which = 'title') { + + /** + * {@inheritdoc} + */ + public function operator_options($which = 'title') { return array( 'or' => t('Is one of'), ); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['depth'] = array('default' => 0); @@ -28,7 +35,10 @@ class views_handler_filter_term_node_tid_depth extends views_handler_filter_term return $options; } - function extra_options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function extra_options_form(&$form, &$form_state) { parent::extra_options_form($form, $form_state); $form['depth'] = array( @@ -39,7 +49,10 @@ class views_handler_filter_term_node_tid_depth extends views_handler_filter_term ); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { // If no filter values are present, then do nothing. if (count($this->value) == 0) { return; @@ -52,7 +65,10 @@ class views_handler_filter_term_node_tid_depth extends views_handler_filter_term $operator = '='; } else { - $operator = 'IN';# " IN (" . implode(', ', array_fill(0, sizeof($this->value), '%d')) . ")"; + $operator = 'IN'; + // " IN (" + // . implode(', ', array_fill(0, sizeof($this->value), '%d')) + // . ")"; } // The normal use of ensure_my_table() here breaks Views. @@ -97,4 +113,5 @@ class views_handler_filter_term_node_tid_depth extends views_handler_filter_term $subquery->condition($where); $this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", $subquery, 'IN'); } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth_join.inc b/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth_join.inc index 8139b8d..043db99 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth_join.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid_depth_join.inc @@ -14,13 +14,20 @@ * @ingroup views_filter_handlers */ class views_handler_filter_term_node_tid_depth_join extends views_handler_filter_term_node_tid { - function operator_options($which = 'title') { + + /** + * {@inheritdoc} + */ + public function operator_options($which = 'title') { return array( 'or' => t('Is one of'), ); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['depth'] = array('default' => 0); @@ -28,7 +35,10 @@ class views_handler_filter_term_node_tid_depth_join extends views_handler_filter return $options; } - function extra_options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function extra_options_form(&$form, &$form_state) { parent::extra_options_form($form, $form_state); $form['depth'] = array( @@ -39,7 +49,10 @@ class views_handler_filter_term_node_tid_depth_join extends views_handler_filter ); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { // If no filter values are present, then do nothing. if (count($this->value) == 0) { return; @@ -52,7 +65,10 @@ class views_handler_filter_term_node_tid_depth_join extends views_handler_filter $operator = '='; } else { - $operator = 'IN';# " IN (" . implode(', ', array_fill(0, sizeof($this->value), '%d')) . ")"; + $operator = 'IN'; + // " IN (" + // . implode(', ', array_fill(0, sizeof($this->value), '%d')) + // . ")"; } // The normal use of ensure_my_table() here breaks Views. @@ -72,7 +88,7 @@ class views_handler_filter_term_node_tid_depth_join extends views_handler_filter } // The tids variable can be an integer or an array of integers. - $tids = is_array($this->value) ? $this->value : array($this->value); + $tids = is_array($this->value) ? $this->value : array($this->value); if ($this->options['depth'] > 0) { // When the depth is positive search the children. @@ -135,8 +151,9 @@ class views_handler_filter_term_node_tid_depth_join extends views_handler_filter 'field' => 'tid', 'value' => $tids, 'operator' => $operator, - ) + ), ); $taxonomy_index_alias = $this->query->add_relationship('taxonomy_index', $join, 'node'); } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc b/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc index 062450c..09c92fc 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_vocabulary_machine_name extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { if (isset($this->value_options)) { return; } @@ -22,4 +26,5 @@ class views_handler_filter_vocabulary_machine_name extends views_handler_filter_ $this->value_options[$voc->machine_name] = $voc->name; } } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_vid.inc b/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_vid.inc index 2759ee1..0b77599 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_vid.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_filter_vocabulary_vid.inc @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_vocabulary_vid extends views_handler_filter_in_operator { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { if (isset($this->value_options)) { return; } @@ -22,4 +26,5 @@ class views_handler_filter_vocabulary_vid extends views_handler_filter_in_operat $this->value_options[$voc->vid] = $voc->name; } } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_handler_relationship_node_term_data.inc b/sites/all/modules/views/modules/taxonomy/views_handler_relationship_node_term_data.inc index 5712fb8..ba05487 100644 --- a/sites/all/modules/views/modules/taxonomy/views_handler_relationship_node_term_data.inc +++ b/sites/all/modules/views/modules/taxonomy/views_handler_relationship_node_term_data.inc @@ -10,8 +10,12 @@ * * @ingroup views_relationship_handlers */ -class views_handler_relationship_node_term_data extends views_handler_relationship { - function init(&$view, &$options) { +class views_handler_relationship_node_term_data extends views_handler_relationship { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); // Convert legacy vids option to machine name vocabularies. @@ -25,13 +29,19 @@ class views_handler_relationship_node_term_data extends views_handler_relationsh } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['vocabularies'] = array('default' => array()); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $vocabularies = taxonomy_get_vocabularies(); $options = array(); foreach ($vocabularies as $voc) { @@ -51,7 +61,7 @@ class views_handler_relationship_node_term_data extends views_handler_relationsh /** * Called to implement a relationship in a query. */ - function query() { + public function query() { $this->ensure_my_table(); $def = $this->definition; @@ -65,7 +75,7 @@ class views_handler_relationship_node_term_data extends views_handler_relationsh $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER'; } else { - // If vocabularies are supplied join a subselect instead + // If vocabularies are supplied join a subselect instead. $def['left_table'] = $this->table_alias; $def['left_field'] = 'nid'; $def['field'] = 'nid'; @@ -89,9 +99,10 @@ class views_handler_relationship_node_term_data extends views_handler_relationsh $join->construct(); $join->adjusted = TRUE; - // use a short alias for this: + // Use a short alias for this. $alias = $def['table'] . '_' . $this->table; $this->alias = $this->query->add_relationship($alias, $join, 'taxonomy_term_data', $this->relationship); } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc b/sites/all/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc index 9c1d81f..27a484b 100644 --- a/sites/all/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc +++ b/sites/all/modules/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc @@ -9,7 +9,11 @@ * Taxonomy tid default argument. */ class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_default { - function init(&$view, &$argument, $options) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$argument, $options) { parent::init($view, $argument, $options); // Convert legacy vids option to machine name vocabularies. @@ -23,7 +27,10 @@ class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_d } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['term_page'] = array('default' => TRUE, 'bool' => TRUE); @@ -35,7 +42,10 @@ class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_d return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['term_page'] = array( '#type' => 'checkbox', '#title' => t('Load default filter from term page'), @@ -92,12 +102,18 @@ class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_d ); } - function options_submit(&$form, &$form_state, &$options = array()) { + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state, &$options = array()) { // Filter unselected items so we don't unnecessarily store giant arrays. $options['vocabularies'] = array_filter($options['vocabularies']); } - function get_argument() { + /** + * {@inheritdoc} + */ + public function get_argument() { // Load default argument from taxonomy page. if (!empty($this->options['term_page'])) { if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) { @@ -151,4 +167,5 @@ class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_d return $views_page->argument['tid']->argument; } } + } diff --git a/sites/all/modules/views/modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc b/sites/all/modules/views/modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc index 5994bbe..7e7f2c1 100644 --- a/sites/all/modules/views/modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc +++ b/sites/all/modules/views/modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc @@ -2,14 +2,18 @@ /** * @file - * Contains the 'taxonomy term' argument validator plugin. + * Definition of views_plugin_argument_validate_taxonomy_term. */ /** * Validate whether an argument is an acceptable node. */ class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument_validate { - function init(&$view, &$argument, $options) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$argument, $options) { parent::init($view, $argument, $options); // Convert legacy vids option to machine name vocabularies. @@ -23,7 +27,10 @@ class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['vocabularies'] = array('default' => array()); $options['type'] = array('default' => 'tid'); @@ -32,7 +39,10 @@ class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $vocabularies = taxonomy_get_vocabularies(); $options = array(); foreach ($vocabularies as $voc) { @@ -69,12 +79,18 @@ class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument ); } - function options_submit(&$form, &$form_state, &$options = array()) { + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state, &$options = array()) { // Filter unselected items so we don't unnecessarily store giant arrays. $options['vocabularies'] = array_filter($options['vocabularies']); } - function convert_options(&$options) { + /** + * {@inheritdoc} + */ + public function convert_options(&$options) { if (!isset($options['vocabularies']) && !empty($this->argument->options['validate_argument_vocabulary'])) { $options['vocabularies'] = $this->argument->options['validate_argument_vocabulary']; $options['type'] = $this->argument->options['validate_argument_type']; @@ -82,7 +98,10 @@ class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument } } - function validate_argument($argument) { + /** + * {@inheritdoc} + */ + public function validate_argument($argument) { $vocabularies = array_filter($this->options['vocabularies']); $type = $this->options['type']; $transform = $this->options['transform']; @@ -122,7 +141,7 @@ class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument $test = drupal_map_assoc($tids->value); $titles = array(); - // check, if some tids already verified + // check, if some tids already verified. static $validated_cache = array(); foreach ($test as $tid) { if (isset($validated_cache[$tid])) { @@ -136,7 +155,7 @@ class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument } } - // if unverified tids left - verify them and cache results + // if unverified tids left - verify them and cache results. if (count($test)) { $query = db_select('taxonomy_term_data', 'td'); $query->addTag('taxonomy_term_access'); @@ -158,7 +177,7 @@ class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument } } - // Remove duplicate titles + // Remove duplicate titles. $titles = array_unique($titles); $this->argument->validated_title = implode($tids->operator == 'or' ? ' + ' : ', ', $titles); @@ -195,7 +214,10 @@ class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument } } - function process_summary_arguments(&$args) { + /** + * {@inheritdoc} + */ + public function process_summary_arguments(&$args) { $type = $this->options['type']; $transform = $this->options['transform']; $vocabularies = array_filter($this->options['vocabularies']); @@ -205,7 +227,7 @@ class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument $query = db_select('taxonomy_term_data', 'td'); $query->addTag('taxonomy_term_access'); - $query->condition('tid', $args); + $query->condition('td.tid', $args); $query->addField('td', 'tid', 'tid'); if (!empty($vocabularies)) { $query->leftJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid'); @@ -223,4 +245,5 @@ class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument } } } + } diff --git a/sites/all/modules/views/modules/tracker.views.inc b/sites/all/modules/views/modules/tracker.views.inc index ee14589..b7b3748 100644 --- a/sites/all/modules/views/modules/tracker.views.inc +++ b/sites/all/modules/views/modules/tracker.views.inc @@ -6,8 +6,9 @@ * * @ingroup views_module_handlers */ + /** - * Implementation of hook_views_data(). + * Implements hook_views_data(). */ function tracker_views_data() { $data = array(); @@ -158,10 +159,10 @@ function tracker_views_data() { } /** - * Implementation of hook_views_data_alter(). + * Implements hook_views_data_alter(). */ function tracker_views_data_alter(&$data) { - // Provide additional uid_touch handlers which are handled by tracker + // Provide additional uid_touch handlers which are handled by tracker. $data['node']['uid_touch_tracker'] = array( 'group' => t('Tracker - User'), 'title' => t('User posted or commented'), @@ -177,7 +178,7 @@ function tracker_views_data_alter(&$data) { 'field' => 'uid', 'name table' => 'users', 'name field' => 'name', - 'handler' => 'views_handler_filter_tracker_comment_user_uid' + 'handler' => 'views_handler_filter_tracker_comment_user_uid', ), ); } diff --git a/sites/all/modules/views/modules/tracker/views_handler_argument_tracker_comment_user_uid.inc b/sites/all/modules/views/modules/tracker/views_handler_argument_tracker_comment_user_uid.inc index e614482..5fad996 100644 --- a/sites/all/modules/views/modules/tracker/views_handler_argument_tracker_comment_user_uid.inc +++ b/sites/all/modules/views/modules/tracker/views_handler_argument_tracker_comment_user_uid.inc @@ -2,7 +2,7 @@ /** * @file - * Contains views_handler_argument_tracker_comment_user_uid + * Definition of views_handler_argument_tracker_comment_user_uid. */ /** @@ -13,9 +13,9 @@ class views_handler_argument_tracker_comment_user_uid extends views_handler_argument_comment_user_uid { /** - * Overrides views_handler_argument_comment_user_uid::query(). + * {@inheritdoc} */ - function query($group_by = FALSE) { + public function query($group_by = FALSE) { // Because this handler thinks it's an argument for a field on the {node} // table, we need to make sure {tracker_user} is JOINed and use its alias // for the WHERE clause. diff --git a/sites/all/modules/views/modules/tracker/views_handler_filter_tracker_boolean_operator.inc b/sites/all/modules/views/modules/tracker/views_handler_filter_tracker_boolean_operator.inc index 455e824..923ab06 100644 --- a/sites/all/modules/views/modules/tracker/views_handler_filter_tracker_boolean_operator.inc +++ b/sites/all/modules/views/modules/tracker/views_handler_filter_tracker_boolean_operator.inc @@ -2,18 +2,18 @@ /** * @file - * Contains views_handler_filter_tracker_boolean_operator + * Definition of views_handler_filter_tracker_boolean_operator. */ - /** - * Filter handler for boolean values to use = 1 instead of <> 0. - */ +/** + * Filter handler for boolean values to use = 1 instead of <> 0. + */ class views_handler_filter_tracker_boolean_operator extends views_handler_filter_boolean_operator { /** - * Overrides views_handler_filter_boolean_operator::query(). + * {@inheritdoc} */ - function query() { + public function query() { $this->ensure_my_table(); $where = "$this->table_alias.$this->real_field "; if (empty($this->value)) { diff --git a/sites/all/modules/views/modules/tracker/views_handler_filter_tracker_comment_user_uid.inc b/sites/all/modules/views/modules/tracker/views_handler_filter_tracker_comment_user_uid.inc index da6f65b..b813237 100644 --- a/sites/all/modules/views/modules/tracker/views_handler_filter_tracker_comment_user_uid.inc +++ b/sites/all/modules/views/modules/tracker/views_handler_filter_tracker_comment_user_uid.inc @@ -1,7 +1,8 @@ 'tnid', 'field' => 'tnid', ); - // The translation ID (nid of the "source" translation) + // The translation ID (nid of the "source" translation). $data['node']['tnid'] = array( 'group' => t('Content translation'), 'title' => t('Translation set node ID'), @@ -34,7 +33,8 @@ function translation_views_data_alter(&$data) { ), 'argument' => array( 'handler' => 'views_handler_argument_node_tnid', - 'name field' => 'title', // the field to display in the summary. + // The field to display in the summary. + 'name field' => 'title', 'numeric' => TRUE, 'validate type' => 'tnid', ), @@ -88,7 +88,7 @@ function translation_views_data_alter(&$data) { ), ); - // Translation status + // Translation status. $data['node']['translate'] = array( 'group' => t('Content translation'), 'title' => t('Translation status'), @@ -117,5 +117,4 @@ function translation_views_data_alter(&$data) { ), ); - } diff --git a/sites/all/modules/views/modules/translation/views_handler_argument_node_tnid.inc b/sites/all/modules/views/modules/translation/views_handler_argument_node_tnid.inc index 61e9eba..f88cafa 100644 --- a/sites/all/modules/views/modules/translation/views_handler_argument_node_tnid.inc +++ b/sites/all/modules/views/modules/translation/views_handler_argument_node_tnid.inc @@ -2,7 +2,7 @@ /** * @file - * Provide node tnid argument handler. + * Definition of views_handler_argument_node_tnid. */ /** @@ -11,10 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_node_tnid extends views_handler_argument_numeric { + /** - * Override the behavior of title(). Get the title of the node. + * {@inheritdoc} */ - function title_query() { + public function title_query() { $titles = array(); $result = db_query("SELECT n.title FROM {node} n WHERE n.tnid IN (:tnids)", array(':tnids' => $this->value)); @@ -23,4 +24,5 @@ class views_handler_argument_node_tnid extends views_handler_argument_numeric { } return $titles; } + } diff --git a/sites/all/modules/views/modules/translation/views_handler_field_node_link_translate.inc b/sites/all/modules/views/modules/translation/views_handler_field_node_link_translate.inc index 3e30725..257c3b8 100644 --- a/sites/all/modules/views/modules/translation/views_handler_field_node_link_translate.inc +++ b/sites/all/modules/views/modules/translation/views_handler_field_node_link_translate.inc @@ -11,11 +11,16 @@ * @ingroup views_field_handlers */ class views_handler_field_node_link_translate extends views_handler_field_node_link { - function render_link($data, $values) { + + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { // ensure user has access to edit this node. $node = $this->get_value($values); - $node->status = 1; // unpublished nodes ignore access control - if (empty($node->language) || !translation_supported_type($node->type) || !node_access('view', $node) || !user_access('translate content')) { + $node->status = 1; + // unpublished nodes ignore access control. + if ($node->language == LANGUAGE_NONE || !translation_supported_type($node->type) || !node_access('view', $node) || !user_access('translate content')) { return; } @@ -26,4 +31,5 @@ class views_handler_field_node_link_translate extends views_handler_field_node_l $text = !empty($this->options['text']) ? $this->options['text'] : t('translate'); return $text; } + } diff --git a/sites/all/modules/views/modules/translation/views_handler_field_node_translation_link.inc b/sites/all/modules/views/modules/translation/views_handler_field_node_translation_link.inc index 9d50369..38e6c31 100644 --- a/sites/all/modules/views/modules/translation/views_handler_field_node_translation_link.inc +++ b/sites/all/modules/views/modules/translation/views_handler_field_node_translation_link.inc @@ -11,7 +11,11 @@ * @ingroup views_field_handlers */ class views_handler_field_node_translation_link extends views_handler_field { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['nid'] = 'nid'; $this->additional_fields['tnid'] = 'tnid'; @@ -19,17 +23,26 @@ class views_handler_field_node_translation_link extends views_handler_field { $this->additional_fields['language'] = 'language'; } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->add_additional_fields(); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values, 'tnid'); return $this->render_link($this->sanitize_value($value), $values); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { global $language; $tnid = $this->get_value($values, 'tnid'); @@ -46,4 +59,5 @@ class views_handler_field_node_translation_link extends views_handler_field { $this->options['alter']['path'] = "node/" . $this->get_value($values, 'nid'); return $this->get_value($values, 'title'); } + } diff --git a/sites/all/modules/views/modules/translation/views_handler_filter_node_tnid.inc b/sites/all/modules/views/modules/translation/views_handler_filter_node_tnid.inc index ed4d6a9..5bff048 100644 --- a/sites/all/modules/views/modules/translation/views_handler_filter_node_tnid.inc +++ b/sites/all/modules/views/modules/translation/views_handler_filter_node_tnid.inc @@ -11,8 +11,17 @@ * @ingroup views_filter_handlers */ class views_handler_filter_node_tnid extends views_handler_filter { - function admin_summary() { } - function option_definition() { + + /** + * {@inheritdoc} + */ + public function admin_summary() { + } + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['operator']['default'] = 1; @@ -21,9 +30,9 @@ class views_handler_filter_node_tnid extends views_handler_filter { } /** - * Provide simple boolean operator + * Provide simple boolean operator. */ - function operator_form(&$form, &$form_state) { + public function operator_form(&$form, &$form_state) { $form['operator'] = array( '#type' => 'radios', '#title' => t('Include untranslated content'), @@ -35,11 +44,25 @@ class views_handler_filter_node_tnid extends views_handler_filter { ); } - function can_expose() { return FALSE; } - - function query() { - $table = $this->ensure_my_table(); - // Select for source translations (tnid = nid). Conditionally, also accept either untranslated nodes (tnid = 0). - $this->query->add_where_expression($this->options['group'], "$table.tnid = $table.nid" . ($this->operator ? " OR $table.tnid = 0" : '')); + /** + * {@inheritdoc} + */ + public function can_expose() { + return FALSE; } + + /** + * {@inheritdoc} + */ + public function query() { + $table = $this->ensure_my_table(); + // Select for source translations (tnid = nid). Conditionally, also accept + // either untranslated nodes (tnid = 0). + $expression = "$table.tnid = $table.nid"; + if ($this->operator) { + $expression .= " OR $table.tnid = 0"; + } + $this->query->add_where_expression($this->options['group'], $expression); + } + } diff --git a/sites/all/modules/views/modules/translation/views_handler_filter_node_tnid_child.inc b/sites/all/modules/views/modules/translation/views_handler_filter_node_tnid_child.inc index 51316eb..a2f3e38 100644 --- a/sites/all/modules/views/modules/translation/views_handler_filter_node_tnid_child.inc +++ b/sites/all/modules/views/modules/translation/views_handler_filter_node_tnid_child.inc @@ -11,12 +11,32 @@ * @ingroup views_filter_handlers */ class views_handler_filter_node_tnid_child extends views_handler_filter { - function admin_summary() { } - function operator_form(&$form, &$form_state) { } - function can_expose() { return FALSE; } - function query() { + /** + * {@inheritdoc} + */ + public function admin_summary() { + } + + /** + * {@inheritdoc} + */ + public function operator_form(&$form, &$form_state) { + } + + /** + * {@inheritdoc} + */ + public function can_expose() { + return FALSE; + } + + /** + * {@inheritdoc} + */ + public function query() { $table = $this->ensure_my_table(); $this->query->add_where_expression($this->options['group'], "$table.tnid <> $table.nid AND $table.tnid > 0"); } + } diff --git a/sites/all/modules/views/modules/translation/views_handler_relationship_translation.inc b/sites/all/modules/views/modules/translation/views_handler_relationship_translation.inc index 509a935..7601c25 100644 --- a/sites/all/modules/views/modules/translation/views_handler_relationship_translation.inc +++ b/sites/all/modules/views/modules/translation/views_handler_relationship_translation.inc @@ -12,7 +12,11 @@ * @ingroup views_relationship_handlers */ class views_handler_relationship_translation extends views_handler_relationship { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['language'] = array('default' => 'current'); @@ -22,7 +26,7 @@ class views_handler_relationship_translation extends views_handler_relationship /** * Add a translation selector. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $options = array( @@ -43,7 +47,7 @@ class views_handler_relationship_translation extends views_handler_relationship /** * Called to implement a relationship in a query. */ - function query() { + public function query() { // Figure out what base table this relationship brings to the party. $table_data = views_fetch_data($this->definition['base']); $base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field']; @@ -68,12 +72,14 @@ class views_handler_relationship_translation extends views_handler_relationship 'value' => '***CURRENT_LANGUAGE***', ); break; + case 'default': $def['extra'][] = array( 'field' => 'language', 'value' => '***DEFAULT_LANGUAGE***', ); break; + // Other values will be the language codes. default: $def['extra'][] = array( @@ -92,12 +98,14 @@ class views_handler_relationship_translation extends views_handler_relationship } $join->definition = $def; + $join->extra = "(%alias.tnid != 0 OR ({$def['left_table']}.tnid = 0 AND %alias.nid = {$def['left_table']}.nid))"; $join->construct(); $join->adjusted = TRUE; - // use a short alias for this: + // Use a short alias for this. $alias = $def['table'] . '_' . $this->table; $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship); } + } diff --git a/sites/all/modules/views/modules/user.views.inc b/sites/all/modules/views/modules/user.views.inc index 7077104..7d96a73 100644 --- a/sites/all/modules/views/modules/user.views.inc +++ b/sites/all/modules/views/modules/user.views.inc @@ -12,10 +12,9 @@ */ function user_views_data() { // ---------------------------------------------------------------- - // users table - - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + // 'users' table. + // Define the base group of this table. Fields that don't have a group + // defined will go into this field by default. $data['users']['table']['group'] = t('User'); $data['users']['table']['base'] = array( @@ -26,7 +25,6 @@ function user_views_data() { ); $data['users']['table']['entity type'] = 'user'; - $data['users']['table']['default_relationship'] = array( 'node' => array( 'table' => 'node', @@ -42,17 +40,20 @@ function user_views_data() { ), ); - // uid + // User ID / 'uid'. $data['users']['uid'] = array( + // The item it appears as on the UI, 'title' => t('Uid'), - 'help' => t('The user ID'), // The help that appears on the UI, + // The help that appears on the UI, + 'help' => t('The user ID'), 'field' => array( 'handler' => 'views_handler_field_user', 'click sortable' => TRUE, ), 'argument' => array( 'handler' => 'views_handler_argument_user_uid', - 'name field' => 'name', // display this field in the summary + // Display this field in the summary. + 'name field' => 'name', ), 'filter' => array( 'title' => t('Name'), @@ -72,7 +73,7 @@ function user_views_data() { ), ); - // uid_raw + // The raw user ID / 'uid_raw'. $data['users']['uid_raw'] = array( 'help' => t('The raw numeric user ID.'), 'real field' => 'uid', @@ -82,7 +83,7 @@ function user_views_data() { ), ); - // uid + // Representative node for the user. $data['users']['uid_representative'] = array( 'relationship' => array( 'title' => t('Representative node'), @@ -92,13 +93,13 @@ function user_views_data() { 'relationship field' => 'uid', 'outer field' => 'users.uid', 'argument table' => 'users', - 'argument field' => 'uid', + 'argument field' => 'uid', 'base' => 'node', 'field' => 'nid', ), ); - // uid + // Current user's ID / 'uid'. $data['users']['uid_current'] = array( 'real field' => 'uid', 'title' => t('Current'), @@ -109,10 +110,25 @@ function user_views_data() { ), ); - // name + // Comments authored. + $data['users']['uid_comment'] = array( + 'relationship' => array( + 'title' => t('Comments authored'), + 'help' => t('Relate comments to the user who created it. This relationship will create one record for each comment created by the user.'), + 'handler' => 'views_handler_relationship', + 'base' => 'comment', + 'base field' => 'uid', + 'field' => 'uid', + 'label' => t('comments'), + ), + ); + + // User name. $data['users']['name'] = array( - 'title' => t('Name'), // The item it appears as on the UI, - 'help' => t('The user or author name.'), // The help that appears on the UI, + // The item it appears as on the UI, + 'title' => t('Name'), + // The help that appears on the UI, + 'help' => t('The user or author name.'), 'field' => array( 'handler' => 'views_handler_field_user_name', 'click sortable' => TRUE, @@ -126,15 +142,17 @@ function user_views_data() { 'filter' => array( 'handler' => 'views_handler_filter_string', 'title' => t('Name (raw)'), - 'help' => t('The user or author name. This filter does not check if the user exists and allows partial matching. Does not utilize autocomplete.') + 'help' => t('The user or author name. This filter does not check if the user exists and allows partial matching. Does not utilize autocomplete.'), ), ); - // mail + // Email address. // Note that this field implements field level access control. $data['users']['mail'] = array( - 'title' => t('E-mail'), // The item it appears as on the UI, - 'help' => t('Email address for a given user. This field is normally not shown to users, so be cautious when using it.'), // The help that appears on the UI, + // The item it appears as on the UI, + 'title' => t('E-mail'), + // The help that appears on the UI, + 'help' => t('E-mail address for a given user. This field is normally not shown to users, so be cautious when using it.'), 'field' => array( 'handler' => 'views_handler_field_user_mail', 'click sortable' => TRUE, @@ -150,9 +168,10 @@ function user_views_data() { ), ); - // language + // Language. $data['users']['language'] = array( - 'title' => t('Language'), // The item it appears as on the UI, + // The item it appears as on the UI, + 'title' => t('Language'), 'help' => t('Language of the user'), 'field' => array( 'handler' => 'views_handler_field_user_language', @@ -169,12 +188,14 @@ function user_views_data() { ), ); - // picture + // Picture. $data['users']['picture_fid']['moved to'] = array('users', 'picture'); $data['users']['picture'] = array( + // The item it appears as on the UI, 'title' => t('Picture'), - 'help' => t("The user's picture, if allowed."), // The help that appears on the UI, - // Information for displaying the uid + // The help that appears on the UI, + 'help' => t("The user's picture, if allowed."), + // Information for displaying the uid. 'field' => array( 'handler' => 'views_handler_field_user_picture', 'click sortable' => TRUE, @@ -189,19 +210,21 @@ function user_views_data() { ), ); - // link + // Link. $data['users']['view_user'] = array( 'field' => array( - 'title' => t('Link'), + 'title' => t('Link to user'), 'help' => t('Provide a simple link to the user.'), 'handler' => 'views_handler_field_user_link', ), ); - // created field + // Created field. $data['users']['created'] = array( - 'title' => t('Created date'), // The item it appears as on the UI, - 'help' => t('The date the user was created.'), // The help that appears on the UI, + // The item it appears as on the UI, + 'title' => t('Created date'), + // The help that appears on the UI, + 'help' => t('The date the user was created.'), 'field' => array( 'handler' => 'views_handler_field_date', 'click sortable' => TRUE, @@ -269,10 +292,12 @@ function user_views_data() { ), ); - // access field + // Access field. $data['users']['access'] = array( - 'title' => t('Last access'), // The item it appears as on the UI, - 'help' => t("The user's last access date."), // The help that appears on the UI, + // The item it appears as on the UI, + 'title' => t('Last access'), + // The help that appears on the UI, + 'help' => t("The user's last access date."), 'field' => array( 'handler' => 'views_handler_field_date', 'click sortable' => TRUE, @@ -285,10 +310,12 @@ function user_views_data() { ), ); - // login field + // Login field. $data['users']['login'] = array( - 'title' => t('Last login'), // The item it appears as on the UI, - 'help' => t("The user's last login date."), // The help that appears on the UI, + // The item it appears as on the UI, + 'title' => t('Last login'), + // The help that appears on the UI, + 'help' => t("The user's last login date."), 'field' => array( 'handler' => 'views_handler_field_date', 'click sortable' => TRUE, @@ -301,11 +328,13 @@ function user_views_data() { ), ); - // active status + // Active status. $data['users']['status'] = array( - 'title' => t('Active'), // The item it appears as on the UI, - 'help' => t('Whether a user is active or blocked.'), // The help that appears on the UI, - // Information for displaying a title as a field + // The item it appears as on the UI, + 'title' => t('Active status'), + // The help that appears on the UI, + 'help' => t('Whether a user is active or blocked.'), + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_boolean', 'click sortable' => TRUE, @@ -323,11 +352,13 @@ function user_views_data() { ), ); - // log field + // Log field. $data['users']['signature'] = array( - 'title' => t('Signature'), // The item it appears as on the UI, - 'help' => t("The user's signature."), // The help that appears on the UI, - // Information for displaying a title as a field + // The item it appears as on the UI, + 'title' => t('Signature'), + // The help that appears on the UI, + 'help' => t("The user's signature."), + // Information for displaying a title as a field. 'field' => array( 'handler' => 'views_handler_field_markup', 'format' => filter_fallback_format(), @@ -339,7 +370,7 @@ function user_views_data() { $data['users']['edit_node'] = array( 'field' => array( - 'title' => t('Edit link'), + 'title' => t('Link to edit user'), 'help' => t('Provide a simple link to edit the user.'), 'handler' => 'views_handler_field_user_link_edit', ), @@ -347,7 +378,7 @@ function user_views_data() { $data['users']['cancel_node'] = array( 'field' => array( - 'title' => t('Cancel link'), + 'title' => t('Link to cancel user'), 'help' => t('Provide a simple link to cancel the user.'), 'handler' => 'views_handler_field_user_link_cancel', ), @@ -362,8 +393,7 @@ function user_views_data() { ); // ---------------------------------------------------------------------- - // users_roles table - + // 'users_roles' table. $data['users_roles']['table']['group'] = t('User'); // Explain how this table joins to others. @@ -409,8 +439,7 @@ function user_views_data() { ); // ---------------------------------------------------------------------- - // role table - + // 'role' table. $data['role']['table']['join'] = array( // Directly links to users table. 'users' => array( @@ -418,7 +447,7 @@ function user_views_data() { 'left_field' => 'rid', 'field' => 'rid', ), - // needed for many to one helper sometimes + // Needed for many to one helper sometimes. 'users_roles' => array( 'left_field' => 'rid', 'field' => 'rid', @@ -436,7 +465,7 @@ function user_views_data() { ), ); - // permission table + // 'permission' table. $data['role_permission']['table']['group'] = t('User'); $data['role_permission']['table']['join'] = array( // Directly links to users table. @@ -460,8 +489,7 @@ function user_views_data() { ); // ---------------------------------------------------------------------- - // authmap table - + // 'authmap' table. $data['authmap']['table']['group'] = t('User'); $data['authmap']['table']['join'] = array( // Directly links to users table. @@ -532,13 +560,15 @@ function user_views_data() { */ function user_views_plugins() { return array( - 'module' => 'views', // This just tells our themes are elsewhere. + // This just tells our themes are elsewhere. + 'module' => 'views', 'row' => array( 'user' => array( 'title' => t('User'), 'help' => t('Display the user with standard user view.'), 'handler' => 'views_plugin_row_user_view', - 'base' => array('users'), // only works with 'users' as base. + // Only works with 'users' as base. + 'base' => array('users'), 'uses options' => TRUE, 'type' => 'normal', 'help topic' => 'style-users', @@ -548,26 +578,29 @@ function user_views_plugins() { 'user' => array( 'title' => t('User ID from URL'), 'handler' => 'views_plugin_argument_default_user', - 'path' => drupal_get_path('module', 'views') . '/modules/user', // not necessary for most modules + // Not necessary for most modules. + 'path' => drupal_get_path('module', 'views') . '/modules/user', ), 'current_user' => array( 'title' => t('User ID from logged in user'), 'handler' => 'views_plugin_argument_default_current_user', - 'path' => drupal_get_path('module', 'views') . '/modules/user', // not necessary for most modules + // Not necessary for most modules. + 'path' => drupal_get_path('module', 'views') . '/modules/user', ), ), 'argument validator' => array( 'user' => array( 'title' => t('User'), 'handler' => 'views_plugin_argument_validate_user', - 'path' => drupal_get_path('module', 'views') . '/modules/user', // not necessary for most modules + // Not necessary for most modules. + 'path' => drupal_get_path('module', 'views') . '/modules/user', ), ), ); } /** - * Allow replacement of current userid so we can cache these queries + * Allow replacement of current userid so we can cache these queries. */ function user_views_query_substitutions($view) { global $user; diff --git a/sites/all/modules/views/modules/user/views_handler_argument_user_uid.inc b/sites/all/modules/views/modules/user/views_handler_argument_user_uid.inc index 6ab9167..8cf20d9 100644 --- a/sites/all/modules/views/modules/user/views_handler_argument_user_uid.inc +++ b/sites/all/modules/views/modules/user/views_handler_argument_user_uid.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_handler_argument_user_uid. + * Contains . */ /** @@ -11,13 +11,14 @@ * @ingroup views_argument_handlers */ class views_handler_argument_user_uid extends views_handler_argument_numeric { + /** * Override the behavior of title(). Get the name of the user. * * @return array * A list of usernames. */ - function title_query() { + public function title_query() { if (!$this->argument) { return array(variable_get('anonymous', t('Anonymous'))); } @@ -30,4 +31,5 @@ class views_handler_argument_user_uid extends views_handler_argument_numeric { } return $titles; } + } diff --git a/sites/all/modules/views/modules/user/views_handler_argument_users_roles_rid.inc b/sites/all/modules/views/modules/user/views_handler_argument_users_roles_rid.inc index 31c5814..e7457c9 100644 --- a/sites/all/modules/views/modules/user/views_handler_argument_users_roles_rid.inc +++ b/sites/all/modules/views/modules/user/views_handler_argument_users_roles_rid.inc @@ -11,7 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_users_roles_rid extends views_handler_argument_many_to_one { - function title_query() { + + /** + * {@inheritdoc} + */ + public function title_query() { $titles = array(); $result = db_query("SELECT name FROM {role} WHERE rid IN (:rids)", array(':rids' => $this->value)); @@ -20,4 +24,5 @@ class views_handler_argument_users_roles_rid extends views_handler_argument_many } return $titles; } + } diff --git a/sites/all/modules/views/modules/user/views_handler_field_user.inc b/sites/all/modules/views/modules/user/views_handler_field_user.inc index f6b15b5..8856c4a 100644 --- a/sites/all/modules/views/modules/user/views_handler_field_user.inc +++ b/sites/all/modules/views/modules/user/views_handler_field_user.inc @@ -11,26 +11,28 @@ * @ingroup views_field_handlers */ class views_handler_field_user extends views_handler_field { + /** * Override init function to provide generic option to link to user. */ - function init(&$view, &$data) { + public function init(&$view, &$data) { parent::init($view, $data); - if (!empty($this->options['link_to_user'])) { - $this->additional_fields['uid'] = 'uid'; - } + $this->additional_fields['uid'] = 'uid'; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_user'] = array('default' => TRUE, 'bool' => TRUE); return $options; } /** - * Provide link to node option + * Provide link to node option. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { $form['link_to_user'] = array( '#title' => t('Link this field to its user'), '#description' => t("Enable to override this field's links."), @@ -40,7 +42,10 @@ class views_handler_field_user extends views_handler_field { parent::options_form($form, $form_state); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { if (!empty($this->options['link_to_user']) && user_access('access user profiles') && ($uid = $this->get_value($values, 'uid')) && $data !== NULL && $data !== '') { $this->options['alter']['make_link'] = TRUE; $this->options['alter']['path'] = "user/" . $uid; @@ -48,8 +53,12 @@ class views_handler_field_user extends views_handler_field { return $data; } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->render_link($this->sanitize_value($value), $values); } + } diff --git a/sites/all/modules/views/modules/user/views_handler_field_user_language.inc b/sites/all/modules/views/modules/user/views_handler_field_user_language.inc index e29da31..9f2ae4f 100644 --- a/sites/all/modules/views/modules/user/views_handler_field_user_language.inc +++ b/sites/all/modules/views/modules/user/views_handler_field_user_language.inc @@ -12,7 +12,10 @@ */ class views_handler_field_user_language extends views_handler_field_user { - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { $uid = $this->get_value($values, 'uid'); if (!empty($this->options['link_to_user'])) { $uid = $this->get_value($values, 'uid'); @@ -32,8 +35,4 @@ class views_handler_field_user_language extends views_handler_field_user { return $this->sanitize_value($lang->name); } - function render($values) { - $value = $this->get_value($values); - return $this->render_link($this->sanitize_value($value), $values); - } } diff --git a/sites/all/modules/views/modules/user/views_handler_field_user_link.inc b/sites/all/modules/views/modules/user/views_handler_field_user_link.inc index 03b5e0d..103e554 100644 --- a/sites/all/modules/views/modules/user/views_handler_field_user_link.inc +++ b/sites/all/modules/views/modules/user/views_handler_field_user_link.inc @@ -11,18 +11,28 @@ * @ingroup views_field_handlers */ class views_handler_field_user_link extends views_handler_field { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['uid'] = 'uid'; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['text'] = array('default' => '', 'translatable' => TRUE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['text'] = array( '#type' => 'textfield', '#title' => t('Text to display'), @@ -31,22 +41,33 @@ class views_handler_field_user_link extends views_handler_field { parent::options_form($form, $form_state); } - // An example of field level access control. - function access() { + /** + * An example of field level access control. + */ + public function access() { return user_access('access user profiles'); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $this->add_additional_fields(); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values, 'uid'); return $this->render_link($this->sanitize_value($value), $values); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { $text = !empty($this->options['text']) ? $this->options['text'] : t('view'); $this->options['alter']['make_link'] = TRUE; diff --git a/sites/all/modules/views/modules/user/views_handler_field_user_link_cancel.inc b/sites/all/modules/views/modules/user/views_handler_field_user_link_cancel.inc index fe038da..607caa7 100644 --- a/sites/all/modules/views/modules/user/views_handler_field_user_link_cancel.inc +++ b/sites/all/modules/views/modules/user/views_handler_field_user_link_cancel.inc @@ -12,7 +12,10 @@ */ class views_handler_field_user_link_cancel extends views_handler_field_user_link { - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { $uid = $values->{$this->aliases['uid']}; // Build a pseudo account object to be able to check the access. @@ -30,4 +33,5 @@ class views_handler_field_user_link_cancel extends views_handler_field_user_link return $text; } } + } diff --git a/sites/all/modules/views/modules/user/views_handler_field_user_link_edit.inc b/sites/all/modules/views/modules/user/views_handler_field_user_link_edit.inc index e37feae..b7122d8 100644 --- a/sites/all/modules/views/modules/user/views_handler_field_user_link_edit.inc +++ b/sites/all/modules/views/modules/user/views_handler_field_user_link_edit.inc @@ -11,7 +11,11 @@ * @ingroup views_field_handlers */ class views_handler_field_user_link_edit extends views_handler_field_user_link { - function render_link($data, $values) { + + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { // Build a pseudo account object to be able to check the access. $account = new stdClass(); $account->uid = $data; @@ -27,4 +31,5 @@ class views_handler_field_user_link_edit extends views_handler_field_user_link { return $text; } } + } diff --git a/sites/all/modules/views/modules/user/views_handler_field_user_mail.inc b/sites/all/modules/views/modules/user/views_handler_field_user_mail.inc index 82d1933..d71bdc5 100644 --- a/sites/all/modules/views/modules/user/views_handler_field_user_mail.inc +++ b/sites/all/modules/views/modules/user/views_handler_field_user_mail.inc @@ -11,13 +11,20 @@ * @ingroup views_field_handlers */ class views_handler_field_user_mail extends views_handler_field_user { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_to_user'] = array('default' => 'mailto'); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['link_to_user'] = array( '#title' => t('Link this field'), @@ -31,7 +38,10 @@ class views_handler_field_user_mail extends views_handler_field_user { ); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { parent::render_link($data, $values); if ($this->options['link_to_user'] == 'mailto') { @@ -41,4 +51,5 @@ class views_handler_field_user_mail extends views_handler_field_user { return $data; } + } diff --git a/sites/all/modules/views/modules/user/views_handler_field_user_name.inc b/sites/all/modules/views/modules/user/views_handler_field_user_name.inc index 1770f2a..c7bf8c6 100644 --- a/sites/all/modules/views/modules/user/views_handler_field_user_name.inc +++ b/sites/all/modules/views/modules/user/views_handler_field_user_name.inc @@ -6,22 +6,16 @@ */ /** - * Field handler to provide simple renderer that allows using a themed user link. + * Field handler for a simple renderer that allows using a themed user link. * * @ingroup views_field_handlers */ class views_handler_field_user_name extends views_handler_field_user { - /** - * Add uid in the query so we can test for anonymous if needed. - */ - function init(&$view, &$data) { - parent::init($view, $data); - if (!empty($this->options['overwrite_anonymous']) || !empty($this->options['format_username'])) { - $this->additional_fields['uid'] = 'uid'; - } - } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['overwrite_anonymous'] = array('default' => FALSE, 'bool' => TRUE); @@ -31,7 +25,10 @@ class views_handler_field_user_name extends views_handler_field_user { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['format_username'] = array( '#title' => t('Use formatted username'), '#type' => 'checkbox', @@ -59,10 +56,17 @@ class views_handler_field_user_name extends views_handler_field_user { parent::options_form($form, $form_state); } - function render_link($data, $values) { + /** + * {@inheritdoc} + */ + public function render_link($data, $values) { $account = new stdClass(); $account->uid = $this->get_value($values, 'uid'); $account->name = $this->get_value($values); + // If we don't have a UID, we can't format anything. + if (!isset($account->uid)) { + return $data; + } if (!empty($this->options['link_to_user']) || !empty($this->options['overwrite_anonymous'])) { if (!empty($this->options['overwrite_anonymous']) && !$account->uid) { // This is an anonymous user, and we're overriting the text. @@ -80,4 +84,5 @@ class views_handler_field_user_name extends views_handler_field_user { // Otherwise, there's no special handling, so return the data directly. return $data; } + } diff --git a/sites/all/modules/views/modules/user/views_handler_field_user_permissions.inc b/sites/all/modules/views/modules/user/views_handler_field_user_permissions.inc index edc9c44..1bf2934 100644 --- a/sites/all/modules/views/modules/user/views_handler_field_user_permissions.inc +++ b/sites/all/modules/views/modules/user/views_handler_field_user_permissions.inc @@ -11,17 +11,27 @@ * @ingroup views_field_handlers */ class views_handler_field_user_permissions extends views_handler_field_prerender_list { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid'); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->add_additional_fields(); $this->field_alias = $this->aliases['uid']; } - function pre_render(&$values) { + /** + * {@inheritdoc} + */ + public function pre_render(&$values) { $uids = array(); $this->items = array(); @@ -30,8 +40,8 @@ class views_handler_field_user_permissions extends views_handler_field_prerender } if ($uids) { - // Get a list of all the modules implementing a hook_permission() and sort by - // display name. + // Get a list of all the modules implementing a hook_permission() and + // sort by display name. $module_info = system_get_info('module'); $modules = array(); foreach (module_implements('permission') as $module) { @@ -50,19 +60,27 @@ class views_handler_field_user_permissions extends views_handler_field_prerender } } - function render_item($count, $item) { + /** + * {@inheritdoc} + */ + public function render_item($count, $item) { return $item['permission']; } - /* - function document_self_tokens(&$tokens) { - $tokens['[' . $this->options['id'] . '-role' . ']'] = t('The name of the role.'); - $tokens['[' . $this->options['id'] . '-rid' . ']'] = t('The role ID of the role.'); - } + /** + * + */ + // function document_self_tokens(&$tokens) { + // $tokens['[' . $this->options['id'] . '-role' . ']'] = t('The name of the role.'); + // $tokens['[' . $this->options['id'] . '-rid' . ']'] = t('The role ID of the role.'); + // } + + /** + * + */ + // function add_self_tokens(&$tokens, $item) { + // $tokens['[' . $this->options['id'] . '-role' . ']'] = $item['role']; + // $tokens['[' . $this->options['id'] . '-rid' . ']'] = $item['rid']; + // } - function add_self_tokens(&$tokens, $item) { - $tokens['[' . $this->options['id'] . '-role' . ']'] = $item['role']; - $tokens['[' . $this->options['id'] . '-rid' . ']'] = $item['rid']; - } - */ } diff --git a/sites/all/modules/views/modules/user/views_handler_field_user_picture.inc b/sites/all/modules/views/modules/user/views_handler_field_user_picture.inc index babbae5..7769900 100644 --- a/sites/all/modules/views/modules/user/views_handler_field_user_picture.inc +++ b/sites/all/modules/views/modules/user/views_handler_field_user_picture.inc @@ -6,19 +6,26 @@ */ /** - * Field handler to provide simple renderer that allows using a themed user link. + * Field handler for a simple renderer that allows using a themed user link. * * @ingroup views_field_handlers */ class views_handler_field_user_picture extends views_handler_field { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['uid'] = 'uid'; $this->additional_fields['name'] = 'name'; $this->additional_fields['mail'] = 'mail'; } - function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) { + /** + * {@inheritdoc} + */ + public function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) { if ($inline) { return 'span'; } @@ -40,14 +47,20 @@ class views_handler_field_user_picture extends views_handler_field { return 'div'; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['link_photo_to_profile'] = array('default' => TRUE, 'bool' => TRUE); $options['image_style'] = array('default' => ''); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['link_photo_to_profile'] = array( '#title' => t("Link to user's profile"), @@ -73,19 +86,29 @@ class views_handler_field_user_picture extends views_handler_field { } } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { if ($this->options['image_style'] && module_exists('image')) { - // @todo: Switch to always using theme('user_picture') when it starts + // @todo Switch to always using theme('user_picture') when it starts // supporting image styles. See http://drupal.org/node/1021564 if ($picture_fid = $this->get_value($values)) { $picture = file_load($picture_fid); - $picture_filepath = $picture->uri; + if (!empty($picture)) { + $picture_filepath = $picture->uri; + } + else { + $picture_filepath = variable_get('user_picture_default', ''); + } } else { $picture_filepath = variable_get('user_picture_default', ''); } if (file_valid_uri($picture_filepath)) { - $output = theme('image_style', array('style_name' => $this->options['image_style'], 'path' => $picture_filepath)); + $account = user_load($this->get_value($values, 'uid')); + $alt = t("@user's picture", array('@user' => format_username($account))); + $output = theme('image_style', array('style_name' => $this->options['image_style'], 'path' => $picture_filepath, 'alt' => $alt)); if ($this->options['link_photo_to_profile'] && user_access('access user profiles')) { $uid = $this->get_value($values, 'uid'); $output = l($output, "user/$uid", array('html' => TRUE)); @@ -111,4 +134,5 @@ class views_handler_field_user_picture extends views_handler_field { return $output; } + } diff --git a/sites/all/modules/views/modules/user/views_handler_field_user_roles.inc b/sites/all/modules/views/modules/user/views_handler_field_user_roles.inc index e6571cd..86a0b7a 100644 --- a/sites/all/modules/views/modules/user/views_handler_field_user_roles.inc +++ b/sites/all/modules/views/modules/user/views_handler_field_user_roles.inc @@ -11,17 +11,27 @@ * @ingroup views_field_handlers */ class views_handler_field_user_roles extends views_handler_field_prerender_list { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid'); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->add_additional_fields(); $this->field_alias = $this->aliases['uid']; } - function pre_render(&$values) { + /** + * {@inheritdoc} + */ + public function pre_render(&$values) { $uids = array(); $this->items = array(); @@ -39,19 +49,29 @@ class views_handler_field_user_roles extends views_handler_field_prerender_list } } - function render_item($count, $item) { + /** + * {@inheritdoc} + */ + public function render_item($count, $item) { return $item['role']; } - function document_self_tokens(&$tokens) { + /** + * {@inheritdoc} + */ + public function document_self_tokens(&$tokens) { $tokens['[' . $this->options['id'] . '-role' . ']'] = t('The name of the role.'); $tokens['[' . $this->options['id'] . '-rid' . ']'] = t('The role ID of the role.'); } - function add_self_tokens(&$tokens, $item) { + /** + * {@inheritdoc} + */ + public function add_self_tokens(&$tokens, $item) { if (!empty($item['role'])) { $tokens['[' . $this->options['id'] . '-role' . ']'] = $item['role']; $tokens['[' . $this->options['id'] . '-rid' . ']'] = $item['rid']; } } + } diff --git a/sites/all/modules/views/modules/user/views_handler_filter_user_current.inc b/sites/all/modules/views/modules/user/views_handler_filter_user_current.inc index 5f8fe4c..320d5cd 100644 --- a/sites/all/modules/views/modules/user/views_handler_filter_user_current.inc +++ b/sites/all/modules/views/modules/user/views_handler_filter_user_current.inc @@ -11,12 +11,19 @@ * @ingroup views_filter_handlers */ class views_handler_filter_user_current extends views_handler_filter_boolean_operator { - function construct() { + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); $this->value_value = t('Is the logged in user'); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->ensure_my_table(); $field = $this->table_alias . '.' . $this->real_field . ' '; @@ -33,4 +40,5 @@ class views_handler_filter_user_current extends views_handler_filter_boolean_ope } $this->query->add_where($this->options['group'], $or); } + } diff --git a/sites/all/modules/views/modules/user/views_handler_filter_user_name.inc b/sites/all/modules/views/modules/user/views_handler_filter_user_name.inc index 300607f..fa40989 100644 --- a/sites/all/modules/views/modules/user/views_handler_filter_user_name.inc +++ b/sites/all/modules/views/modules/user/views_handler_filter_user_name.inc @@ -11,9 +11,16 @@ * @ingroup views_filter_handlers */ class views_handler_filter_user_name extends views_handler_filter_in_operator { - var $always_multiple = TRUE; - function value_form(&$form, &$form_state) { + /** + * + */ + public $always_multiple = TRUE; + + /** + * {@inheritdoc} + */ + public function value_form(&$form, &$form_state) { $values = array(); if ($this->value) { $result = db_query("SELECT * FROM {users} u WHERE uid IN (:uids)", array(':uids' => $this->value)); @@ -22,7 +29,8 @@ class views_handler_filter_user_name extends views_handler_filter_in_operator { $values[] = $account->name; } else { - $values[] = 'Anonymous'; // Intentionally NOT translated. + // Intentionally NOT translated. + $values[] = 'Anonymous'; } } } @@ -42,7 +50,10 @@ class views_handler_filter_user_name extends views_handler_filter_in_operator { } } - function value_validate($form, &$form_state) { + /** + * {@inheritdoc} + */ + public function value_validate($form, &$form_state) { $values = drupal_explode_tags($form_state['values']['options']['value']); $uids = $this->validate_user_strings($form['value'], $values); @@ -51,7 +62,10 @@ class views_handler_filter_user_name extends views_handler_filter_in_operator { } } - function accept_exposed_input($input) { + /** + * {@inheritdoc} + */ + public function accept_exposed_input($input) { $rc = parent::accept_exposed_input($input); if ($rc) { @@ -64,7 +78,10 @@ class views_handler_filter_user_name extends views_handler_filter_in_operator { return $rc; } - function exposed_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function exposed_validate(&$form, &$form_state) { if (empty($this->options['exposed'])) { return; } @@ -96,11 +113,12 @@ class views_handler_filter_user_name extends views_handler_filter_in_operator { } /** - * Validate the user string. Since this can come from either the form - * or the exposed filter, this is abstracted out a bit so it can - * handle the multiple input sources. + * Validate the user string. + * + * Since this can come from either the form or the exposed filter, this is + * abstracted out a bit so it can handle the multiple input sources. */ - function validate_user_strings(&$form, $values) { + public function validate_user_strings(&$form, $values) { $uids = array(); $placeholders = array(); $args = array(); @@ -133,15 +151,24 @@ class views_handler_filter_user_name extends views_handler_filter_in_operator { return $uids; } - function value_submit($form, &$form_state) { - // prevent array filter from removing our anonymous user. + /** + * {@inheritdoc} + */ + public function value_submit($form, &$form_state) { + // Prevent array filter from removing our anonymous user. } - // Override to do nothing. - function get_value_options() { } + /** + * {@inheritdoc} + */ + public function get_value_options() { + } - function admin_summary() { - // set up $this->value_options for the parent summary + /** + * {@inheritdoc} + */ + public function admin_summary() { + // Set up $this->value_options for the parent summary. $this->value_options = array(); if ($this->value) { @@ -152,11 +179,13 @@ class views_handler_filter_user_name extends views_handler_filter_in_operator { $this->value_options[$account->uid] = $account->name; } else { - $this->value_options[$account->uid] = 'Anonymous'; // Intentionally NOT translated. + // Intentionally NOT translated. + $this->value_options[$account->uid] = 'Anonymous'; } } } return parent::admin_summary(); } + } diff --git a/sites/all/modules/views/modules/user/views_handler_filter_user_permissions.inc b/sites/all/modules/views/modules/user/views_handler_filter_user_permissions.inc index f999045..ee63818 100644 --- a/sites/all/modules/views/modules/user/views_handler_filter_user_permissions.inc +++ b/sites/all/modules/views/modules/user/views_handler_filter_user_permissions.inc @@ -11,11 +11,15 @@ * @ingroup views_filter_handlers */ class views_handler_filter_user_permissions extends views_handler_filter_many_to_one { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { $module_info = system_get_info('module'); - // Get a list of all the modules implementing a hook_permission() and sort by - // display name. + // Get a list of all the modules implementing a hook_permission() and sort + // by display name. $modules = array(); foreach (module_implements('permission') as $module) { $modules[$module] = $module_info[$module]['name']; @@ -26,10 +30,11 @@ class views_handler_filter_user_permissions extends views_handler_filter_many_to foreach ($modules as $module => $display_name) { if ($permissions = module_invoke($module, 'permission')) { foreach ($permissions as $perm => $perm_item) { - // @todo: group by module but views_handler_filter_many_to_one does not support this. + // @todo group by module but views_handler_filter_many_to_one does not support this. $this->value_options[$perm] = check_plain(strip_tags($perm_item['title'])); } } } } + } diff --git a/sites/all/modules/views/modules/user/views_handler_filter_user_roles.inc b/sites/all/modules/views/modules/user/views_handler_filter_user_roles.inc index ab9b8a2..d717230 100644 --- a/sites/all/modules/views/modules/user/views_handler_filter_user_roles.inc +++ b/sites/all/modules/views/modules/user/views_handler_filter_user_roles.inc @@ -11,7 +11,11 @@ * @ingroup views_filter_handlers */ class views_handler_filter_user_roles extends views_handler_filter_many_to_one { - function get_value_options() { + + /** + * {@inheritdoc} + */ + public function get_value_options() { $this->value_options = user_roles(TRUE); unset($this->value_options[DRUPAL_AUTHENTICATED_RID]); } @@ -19,10 +23,11 @@ class views_handler_filter_user_roles extends views_handler_filter_many_to_one { /** * Override empty and not empty operator labels to be clearer for user roles. */ - function operators() { + public function operators() { $operators = parent::operators(); $operators['empty']['title'] = t("Only has the 'authenticated user' role"); $operators['not empty']['title'] = t("Has roles in addition to 'authenticated user'"); return $operators; } + } diff --git a/sites/all/modules/views/modules/user/views_plugin_argument_default_current_user.inc b/sites/all/modules/views/modules/user/views_plugin_argument_default_current_user.inc index e11c702..b4f25dd 100644 --- a/sites/all/modules/views/modules/user/views_plugin_argument_default_current_user.inc +++ b/sites/all/modules/views/modules/user/views_plugin_argument_default_current_user.inc @@ -2,17 +2,22 @@ /** * @file - * Contains the current user argument default plugin. + * Definition of views_plugin_argument_default_current_user. */ /** - * Default argument plugin to extract the global $user + * Default argument plugin to extract the global $user. * * This plugin actually has no options so it odes not need to do a great deal. */ class views_plugin_argument_default_current_user extends views_plugin_argument_default { - function get_argument() { + + /** + * {@inheritdoc} + */ + public function get_argument() { global $user; return $user->uid; } + } diff --git a/sites/all/modules/views/modules/user/views_plugin_argument_default_user.inc b/sites/all/modules/views/modules/user/views_plugin_argument_default_user.inc index bb10429..128286e 100644 --- a/sites/all/modules/views/modules/user/views_plugin_argument_default_user.inc +++ b/sites/all/modules/views/modules/user/views_plugin_argument_default_user.inc @@ -2,21 +2,28 @@ /** * @file - * Contains the user from URL argument default plugin. + * Definition of views_plugin_argument_default_user. */ /** * Default argument plugin to extract a user via menu_get_object. */ class views_plugin_argument_default_user extends views_plugin_argument_default { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['user'] = array('default' => '', 'bool' => TRUE, 'translatable' => FALSE); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['user'] = array( '#type' => 'checkbox', '#title' => t('Also look for a node and use the node author'), @@ -24,13 +31,19 @@ class views_plugin_argument_default_user extends views_plugin_argument_default { ); } - function convert_options(&$options) { + /** + * {@inheritdoc} + */ + public function convert_options(&$options) { if (!isset($options['user']) && isset($this->argument->options['default_argument_user'])) { $options['user'] = $this->argument->options['default_argument_user']; } } - function get_argument() { + /** + * {@inheritdoc} + */ + public function get_argument() { foreach (range(1, 3) as $i) { $user = menu_get_object('user', $i); if (!empty($user)) { @@ -67,11 +80,13 @@ class views_plugin_argument_default_user extends views_plugin_argument_default { } } - // If the current page is a view that takes uid as an argument, return the uid. + // If the current page is a view that takes uid as an argument, return the + // uid. $view = views_get_page_view(); if ($view && isset($view->argument['uid'])) { return $view->argument['uid']->argument; } } + } diff --git a/sites/all/modules/views/modules/user/views_plugin_argument_validate_user.inc b/sites/all/modules/views/modules/user/views_plugin_argument_validate_user.inc index b727094..37064e6 100644 --- a/sites/all/modules/views/modules/user/views_plugin_argument_validate_user.inc +++ b/sites/all/modules/views/modules/user/views_plugin_argument_validate_user.inc @@ -13,7 +13,11 @@ * argument's title to the username. */ class views_plugin_argument_validate_user extends views_plugin_argument_validate { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['type'] = array('default' => 'uid'); $options['restrict_roles'] = array('default' => FALSE, 'bool' => TRUE); @@ -22,7 +26,10 @@ class views_plugin_argument_validate_user extends views_plugin_argument_validate return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['type'] = array( '#type' => 'radios', '#title' => t('Type of user filter value to allow'), @@ -54,12 +61,19 @@ class views_plugin_argument_validate_user extends views_plugin_argument_validate ); } - function options_submit(&$form, &$form_state, &$options = array()) { - // filter trash out of the options so we don't store giant unnecessary arrays + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state, &$options = array()) { + // Filter trash out of the options so we don't store giant unnecessary + // arrays. $options['roles'] = array_filter($options['roles']); } - function convert_options(&$options) { + /** + * {@inheritdoc} + */ + public function convert_options(&$options) { if (!isset($options['type']) && isset($this->argument->options['validate_user_argument_type'])) { $options['type'] = $this->argument->options['validate_user_argument_type']; $options['restrict_roles'] = $this->argument->options['validate_user_restrict_roles']; @@ -67,11 +81,14 @@ class views_plugin_argument_validate_user extends views_plugin_argument_validate } } - function validate_argument($argument) { + /** + * {@inheritdoc} + */ + public function validate_argument($argument) { $type = $this->options['type']; // is_numeric() can return false positives, so we ensure it's an integer. // However, is_integer() will always fail, since $argument is a string. - if (is_numeric($argument) && $argument == (int)$argument) { + if (is_numeric($argument) && $argument == (int) $argument) { if ($type == 'uid' || $type == 'either') { if ($argument == $GLOBALS['user']->uid) { // If you assign an object to a variable in PHP, the variable @@ -126,7 +143,10 @@ class views_plugin_argument_validate_user extends views_plugin_argument_validate return TRUE; } - function process_summary_arguments(&$args) { + /** + * {@inheritdoc} + */ + public function process_summary_arguments(&$args) { // If the validation says the input is an username, we should reverse the // argument so it works for example for generation summary urls. $uids_arg_keys = array_flip($args); @@ -137,4 +157,5 @@ class views_plugin_argument_validate_user extends views_plugin_argument_validate } } } + } diff --git a/sites/all/modules/views/modules/user/views_plugin_row_user_view.inc b/sites/all/modules/views/modules/user/views_plugin_row_user_view.inc index 2927811..3ce818a 100644 --- a/sites/all/modules/views/modules/user/views_plugin_row_user_view.inc +++ b/sites/all/modules/views/modules/user/views_plugin_row_user_view.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the user view row plugin. + * Definition of views_plugin_row_user_view. */ /** @@ -11,20 +11,34 @@ * @ingroup views_row_plugins */ class views_plugin_row_user_view extends views_plugin_row { - var $base_table = 'users'; - var $base_field = 'uid'; + + /** + * + */ + public $base_table = 'users'; + + /** + * + */ + public $base_field = 'uid'; // Store the users to be used for pre_render. - var $users = array(); + public $users = array(); - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['view_mode'] = array('default' => 'full'); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $options = $this->options_form_summary_options(); @@ -33,37 +47,42 @@ class views_plugin_row_user_view extends views_plugin_row { '#options' => $options, '#title' => t('View mode'), '#default_value' => $this->options['view_mode'], - ); + ); $form['help']['#markup'] = t("Display the user with standard user view. It might be necessary to add a user-profile.tpl.php in your theme's template folder, because the default user-profile template doesn't show the username by default.", array('@user-profile-api-link' => url('http://api.drupal.org/api/drupal/modules--user--user-profile.tpl.php/7'))); } - - /** - * Return the main options, which are shown in the summary title. - */ - function options_form_summary_options() { - $entity_info = entity_get_info('user'); - $options = array(); - if (!empty($entity_info['view modes'])) { - foreach ($entity_info['view modes'] as $mode => $settings) { - $options[$mode] = $settings['label']; - } + /** + * Return the main options, which are shown in the summary title. + */ + public function options_form_summary_options() { + $entity_info = entity_get_info('user'); + $options = array(); + if (!empty($entity_info['view modes'])) { + foreach ($entity_info['view modes'] as $mode => $settings) { + $options[$mode] = $settings['label']; } - if (empty($options)) { - $options = array( - 'full' => t('User account') - ); - } - - return $options; + } + if (empty($options)) { + $options = array( + 'full' => t('User account'), + ); } - function summary_title() { - $options = $this->options_form_summary_options(); - return check_plain($options[$this->options['view_mode']]); - } + return $options; + } - function pre_render($values) { + /** + * {@inheritdoc} + */ + public function summary_title() { + $options = $this->options_form_summary_options(); + return check_plain($options[$this->options['view_mode']]); + } + + /** + * {@inheritdoc} + */ + public function pre_render($values) { $uids = array(); foreach ($values as $row) { $uids[] = $row->{$this->field_alias}; @@ -71,11 +90,15 @@ class views_plugin_row_user_view extends views_plugin_row { $this->users = user_load_multiple($uids); } - function render($row) { + /** + * {@inheritdoc} + */ + public function render($row) { $account = $this->users[$row->{$this->field_alias}]; $account->view = $this->view; $build = user_view($account, $this->options['view_mode']); return drupal_render($build); } + } diff --git a/sites/all/modules/views/modules/views.views.inc b/sites/all/modules/views/modules/views.views.inc index 0f99870..b9a1275 100644 --- a/sites/all/modules/views/modules/views.views.inc +++ b/sites/all/modules/views/modules/views.views.inc @@ -13,7 +13,7 @@ function views_views_data() { $data['views']['table']['group'] = t('Global'); $data['views']['table']['join'] = array( - // #global is a special flag which let's a table appear all the time. + // '#global' is a special flag which let's a table appear all the time. '#global' => array(), ); @@ -108,7 +108,7 @@ function views_views_data() { ); $data['views']['combine'] = array( - 'title' => t('Combine fields filter'), + 'title' => t('Combine fields filter'), 'help' => t('Combine multiple fields together and search by them.'), 'filter' => array( 'handler' => 'views_handler_filter_combine', @@ -132,7 +132,7 @@ function views_views_data() { 'filter' => array( 'help' => t('Use fields comparison to filter the result of the view.'), 'handler' => 'views_handler_filter_fields_compare', - ) + ), ); return $data; diff --git a/sites/all/modules/views/plugins/export_ui/views_ui.class.php b/sites/all/modules/views/plugins/export_ui/views_ui.class.php index 6f87e40..81cbdac 100644 --- a/sites/all/modules/views/plugins/export_ui/views_ui.class.php +++ b/sites/all/modules/views/plugins/export_ui/views_ui.class.php @@ -12,10 +12,12 @@ */ class views_ui extends ctools_export_ui { + /** + * + */ function init($plugin) { - // We modify the plugin info here so that we take the defaults and - // twiddle, rather than completely override them. - + // We modify the plugin info here so that we take the defaults and twiddle, + // rather than completely override them. // Reset the edit path to match what we're really using. $plugin['menu']['items']['edit']['path'] = 'view/%ctools_export_ui/edit'; $plugin['menu']['items']['clone']['path'] = 'view/%ctools_export_ui/clone'; @@ -44,12 +46,13 @@ class views_ui extends ctools_export_ui { return parent::init($plugin); } + /** + * + */ function hook_menu(&$items) { // We are using our own 'edit' still, rather than having edit on this - // object (maybe in the future) so unset the edit callbacks: - - // Store this so we can put them back as sometimes they're needed - // again laster: + // object (maybe in the future) so unset the edit callbacks. Store this so + // we can put them back as sometimes they're needed again laster. $stored_items = $this->plugin['menu']['items']; // We leave these to make sure the operations still exist in the plugin so // that the path finder. @@ -63,10 +66,16 @@ class views_ui extends ctools_export_ui { $this->plugin['menu']['items'] = $stored_items; } + /** + * + */ function load_item($item_name) { return views_ui_cache_load($item_name); } + /** + * + */ function list_form(&$form, &$form_state) { $row_class = 'container-inline'; if (!variable_get('views_ui_show_listing_filters', FALSE)) { @@ -77,8 +86,8 @@ class views_ui extends ctools_export_ui { parent::list_form($form, $form_state); - // ctools only has two rows. We want four. - // That's why we create our own structure. + // CTools only has two rows. We want four. That's why we create our own + // structure. $form['bottom row']['submit']['#attributes']['class'][] = 'js-hide'; $form['first row'] = array( '#prefix' => '
    ', @@ -164,6 +173,9 @@ class views_ui extends ctools_export_ui { ); } + /** + * + */ function list_filter($form_state, $view) { // Don't filter by tags if all is set up. if ($form_state['values']['tag'] != 'all') { @@ -183,6 +195,9 @@ class views_ui extends ctools_export_ui { return parent::list_filter($form_state, $view); } + /** + * + */ function list_sort_options() { return array( 'disabled' => t('Enabled, name'), @@ -193,7 +208,9 @@ class views_ui extends ctools_export_ui { ); } - + /** + * + */ function list_build_row($view, &$form_state, $operations) { if (!empty($view->human_name)) { $title = $view->human_name; @@ -212,45 +229,79 @@ class views_ui extends ctools_export_ui { $info = theme('views_ui_view_info', array('view' => $view, 'base' => $base)); - // Reorder the operations so that enable is the default action for a templatic views + // Reorder the operations so that enable is the default action for a + // templatic views. if (!empty($operations['enable'])) { $operations = array('enable' => $operations['enable']) + $operations; } - // Set up sorting + // Set up sorting. switch ($form_state['values']['order']) { case 'disabled': $this->sorts[$view->name] = strtolower(empty($view->disabled) . $title); break; + case 'name': $this->sorts[$view->name] = strtolower($title); break; + case 'path': $this->sorts[$view->name] = strtolower($paths); break; + case 'tag': $this->sorts[$view->name] = strtolower($view->tag); break; + case 'storage': $this->sorts[$view->name] = strtolower($view->type . $title); break; } - $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline')))); + $theme_args = array( + 'links' => $operations, + 'attributes' => array( + 'class' => array( + 'links', + 'inline', + ), + ), + ); + $ops = theme('links__ctools_dropbutton', $theme_args); $this->rows[$view->name] = array( 'data' => array( - array('data' => $info, 'class' => array('views-ui-name')), - array('data' => check_plain($view->description), 'class' => array('views-ui-description')), - array('data' => check_plain($view->tag), 'class' => array('views-ui-tag')), - array('data' => $paths, 'class' => array('views-ui-path')), - array('data' => $ops, 'class' => array('views-ui-operations')), + array( + 'data' => $info, + 'class' => array('views-ui-name'), + ), + array( + 'data' => check_plain($view->description), + 'class' => array('views-ui-description'), + ), + array( + 'data' => check_plain($view->tag), + 'class' => array('views-ui-tag'), + ), + array( + 'data' => $paths, + 'class' => array('views-ui-path'), + ), + array( + 'data' => $ops, + 'class' => array('views-ui-operations'), + ), ), 'title' => t('Machine name: ') . check_plain($view->name), - 'class' => array(!empty($view->disabled) ? 'ctools-export-ui-disabled' : 'ctools-export-ui-enabled'), + 'class' => array( + !empty($view->disabled) ? 'ctools-export-ui-disabled' : 'ctools-export-ui-enabled', + ), ); } + /** + * + */ function list_render(&$form_state) { views_include('admin'); views_ui_add_admin_css(); @@ -263,7 +314,7 @@ class views_ui extends ctools_export_ui { $this->active = $form_state['values']['order']; $this->order = $form_state['values']['sort']; - $query = tablesort_get_query_parameters(); + $query = tablesort_get_query_parameters(); $header = array( $this->tablesort_link(t('View name'), 'name', 'views-ui-name'), @@ -282,6 +333,9 @@ class views_ui extends ctools_export_ui { return theme('table', $table); } + /** + * + */ function tablesort_link($label, $field, $class) { $title = t('sort by @s', array('@s' => $label)); $initial = 'asc'; @@ -306,7 +360,12 @@ class views_ui extends ctools_export_ui { return array('data' => $link, 'class' => $class); } + /** + * + */ function clone_page($js, $input, $item, $step = NULL) { + $args = func_get_args(); + drupal_set_title($this->get_page_title('clone', $item)); $name = $item->{$this->plugin['export']['key']}; @@ -323,7 +382,7 @@ class views_ui extends ctools_export_ui { 'no_redirect' => TRUE, 'step' => $step, // Store these in case additional args are needed. - 'function args' => func_get_args(), + 'function args' => $args, ); $output = drupal_build_form('views_ui_clone_form', $form_state); @@ -339,6 +398,9 @@ class views_ui extends ctools_export_ui { return $output; } + /** + * + */ function add_template_page($js, $input, $name, $step = NULL) { $templates = views_get_all_templates(); @@ -348,9 +410,8 @@ class views_ui extends ctools_export_ui { $template = $templates[$name]; - // The template description probably describes the template, not the - // view that will be created from it, but users aren't that likely to - // touch it. + // The template description probably describes the template, not the view + // that will be created from it, but users aren't that likely to touch it. if (!empty($template->description)) { unset($template->description); } @@ -363,6 +424,9 @@ class views_ui extends ctools_export_ui { return $output; } + /** + * + */ function set_item_state($state, $js, $input, $item) { ctools_export_set_object_status($item, $state); menu_rebuild(); @@ -375,23 +439,27 @@ class views_ui extends ctools_export_ui { } } + /** + * + */ function list_page($js, $input) { // Remove filters values from session if filters are hidden. if (!variable_get('views_ui_show_listing_filters', FALSE) && isset($_SESSION['ctools_export_ui'][$this->plugin['name']])) { unset($_SESSION['ctools_export_ui'][$this->plugin['name']]); } - // wrap output in a div for CSS + // Wrap output in a div for CSS. $output = parent::list_page($js, $input); if (is_string($output)) { $output = '
    ' . $output . '
    '; } return $output; } + } /** - * Form callback to edit an exportable item using the wizard + * Form callback to edit an exportable item using the wizard. * * This simply loads the object defined in the plugin and hands it off. */ diff --git a/sites/all/modules/views/plugins/views_plugin_access.inc b/sites/all/modules/views/plugins/views_plugin_access.inc index 7f80d9b..0a47d7c 100644 --- a/sites/all/modules/views/plugins/views_plugin_access.inc +++ b/sites/all/modules/views/plugins/views_plugin_access.inc @@ -17,59 +17,63 @@ * The base plugin to handle access control. */ class views_plugin_access extends views_plugin { + /** * Initialize the plugin. * - * @param $view + * @param view $view * The view object. - * @param $display + * @param object $display * The display handler. */ - function init(&$view, &$display) { + public function init(&$view, &$display) { $this->view = &$view; $this->display = &$display; if (is_object($display->handler)) { $options = $display->handler->get_option('access'); - // Overlay incoming options on top of defaults + // Overlay incoming options on top of defaults. $this->unpack_options($this->options, $options); } } /** - * Retrieve the options when this is a new access - * control plugin + * Retrieve the options when this is a new access control plugin. */ - function option_definition() { return array(); } + public function option_definition() { + return array(); + } /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { } + public function options_form(&$form, &$form_state) { + } /** - * Provide the default form form for validating options + * Provide the default form form for validating options. */ - function options_validate(&$form, &$form_state) { } + public function options_validate(&$form, &$form_state) { + } /** - * Provide the default form form for submitting options + * Provide the default form form for submitting options. */ - function options_submit(&$form, &$form_state) { } + public function options_submit(&$form, &$form_state) { + } /** - * Return a string to display as the clickable title for the - * access control. + * Return a string to display as the clickable title for the access control. */ - function summary_title() { + public function summary_title() { return t('Unknown'); } /** * Determine if the current user has access or not. */ - function access($account) { - // default to no access control. + public function access($account) { + // Default to no access control. return TRUE; } @@ -80,15 +84,16 @@ class views_plugin_access extends views_plugin { * performance hits during menu item access testing, which happens * a lot. * - * @return an array; the first item should be the function to call, - * and the second item should be an array of arguments. The first - * item may also be TRUE (bool only) which will indicate no - * access control.) + * @return array + * The first item should be the function to call, and the second item should + * be an array of arguments. The first item may also be TRUE (bool only) + * which will indicate no access control. */ - function get_access_callback() { - // default to no access control. + public function get_access_callback() { + // Default to no access control. return TRUE; } + } /** diff --git a/sites/all/modules/views/plugins/views_plugin_access_none.inc b/sites/all/modules/views/plugins/views_plugin_access_none.inc index d69fe8e..af2a7c9 100644 --- a/sites/all/modules/views/plugins/views_plugin_access_none.inc +++ b/sites/all/modules/views/plugins/views_plugin_access_none.inc @@ -2,7 +2,7 @@ /** * @file - * Definition of views_plugin_access_none. + * Contains . */ /** @@ -11,7 +11,12 @@ * @ingroup views_access_plugins */ class views_plugin_access_none extends views_plugin_access { - function summary_title() { + + /** + * {@inheritdoc} + */ + public function summary_title() { return t('Unrestricted'); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_access_perm.inc b/sites/all/modules/views/plugins/views_plugin_access_perm.inc index 7279d7d..4c39309 100644 --- a/sites/all/modules/views/plugins/views_plugin_access_perm.inc +++ b/sites/all/modules/views/plugins/views_plugin_access_perm.inc @@ -11,15 +11,25 @@ * @ingroup views_access_plugins */ class views_plugin_access_perm extends views_plugin_access { - function access($account) { + + /** + * {@inheritdoc} + */ + public function access($account) { return views_check_perm($this->options['perm'], $account); } - function get_access_callback() { + /** + * {@inheritdoc} + */ + public function get_access_callback() { return array('views_check_perm', array($this->options['perm'])); } - function summary_title() { + /** + * {@inheritdoc} + */ + public function summary_title() { $permissions = module_invoke_all('permission'); if (isset($permissions[$this->options['perm']])) { return $permissions[$this->options['perm']]['title']; @@ -29,19 +39,25 @@ class views_plugin_access_perm extends views_plugin_access { } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['perm'] = array('default' => 'access content'); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $perms = array(); $module_info = system_get_info('module'); - // Get list of permissions + // Get list of permissions. foreach (module_implements('permission') as $module) { $permissions = module_invoke($module, 'permission'); foreach ($permissions as $name => $perm) { @@ -59,4 +75,5 @@ class views_plugin_access_perm extends views_plugin_access { '#description' => t('Only users with the selected permission flag will be able to access this display. Note that users with "access all views" can see any view, regardless of other permissions.'), ); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_access_role.inc b/sites/all/modules/views/plugins/views_plugin_access_role.inc index b06812e..21ae181 100644 --- a/sites/all/modules/views/plugins/views_plugin_access_role.inc +++ b/sites/all/modules/views/plugins/views_plugin_access_role.inc @@ -11,15 +11,25 @@ * @ingroup views_access_plugins */ class views_plugin_access_role extends views_plugin_access { - function access($account) { + + /** + * {@inheritdoc} + */ + public function access($account) { return views_check_roles(array_filter($this->options['role']), $account); } - function get_access_callback() { + /** + * {@inheritdoc} + */ + public function get_access_callback() { return array('views_check_roles', array(array_filter($this->options['role']))); } - function summary_title() { + /** + * {@inheritdoc} + */ + public function summary_title() { $count = count($this->options['role']); if ($count < 1) { return t('No role(s) selected'); @@ -34,15 +44,20 @@ class views_plugin_access_role extends views_plugin_access { } } - - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['role'] = array('default' => array()); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['role'] = array( '#type' => 'checkboxes', @@ -53,14 +68,21 @@ class views_plugin_access_role extends views_plugin_access { ); } - function options_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { if (!array_filter($form_state['values']['access_options']['role'])) { form_error($form['role'], t('You must select at least one role if type is "by role"')); } } - function options_submit(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { // I hate checkboxes. $form_state['values']['access_options']['role'] = array_filter($form_state['values']['access_options']['role']); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_argument_default.inc b/sites/all/modules/views/plugins/views_plugin_argument_default.inc index 2b87730..f686151 100644 --- a/sites/all/modules/views/plugins/views_plugin_argument_default.inc +++ b/sites/all/modules/views/plugins/views_plugin_argument_default.inc @@ -17,18 +17,20 @@ * The fixed argument default handler; also used as the base. */ class views_plugin_argument_default extends views_plugin { + /** * Return the default argument. * - * This needs to be overridden by every default argument handler to properly do what is needed. + * This needs to be overridden by every default argument handler to properly + * do what is needed. */ - function get_argument() { } + public function get_argument() { + } /** - * Initialize this plugin with the view and the argument - * it is linked to. + * Initialize this plugin with the view and the argument it is linked to. */ - function init(&$view, &$argument, $options) { + public function init(&$view, &$argument, $options) { $this->view = &$view; $this->argument = &$argument; @@ -37,31 +39,36 @@ class views_plugin_argument_default extends views_plugin { } /** - * Retrieve the options when this is a new access - * control plugin + * Retrieve the options when this is a new access control plugin. */ - function option_definition() { return array(); } + public function option_definition() { + return array(); + } /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { } + public function options_form(&$form, &$form_state) { + } /** - * Provide the default form form for validating options + * Provide the default form form for validating options. */ - function options_validate(&$form, &$form_state) { } + public function options_validate(&$form, &$form_state) { + } /** - * Provide the default form form for submitting options + * Provide the default form form for submitting options. */ - function options_submit(&$form, &$form_state, &$options = array()) { } + public function options_submit(&$form, &$form_state, &$options = array()) { + } /** - * Determine if the administrator has the privileges to use this - * plugin + * Determine if the administrator has the privileges to use this plugin. */ - function access() { return TRUE; } + public function access() { + return TRUE; + } /** * If we don't have access to the form but are showing it anyway, ensure that @@ -70,7 +77,7 @@ class views_plugin_argument_default extends views_plugin { * This is only called by child objects if specified in the options_form(), * so it will not always be used. */ - function check_access(&$form, $option_name) { + public function check_access(&$form, $option_name) { if (!$this->access()) { $form[$option_name]['#disabled'] = TRUE; $form[$option_name]['#value'] = $form[$this->option_name]['#default_value']; @@ -86,7 +93,9 @@ class views_plugin_argument_default extends views_plugin { * move arguments from the old style to the new style. See * views_plugin_argument_default_fixed for a good example of this method. */ - function convert_options(&$options) { } + public function convert_options(&$options) { + } + } /** diff --git a/sites/all/modules/views/plugins/views_plugin_argument_default_fixed.inc b/sites/all/modules/views/plugins/views_plugin_argument_default_fixed.inc index 38ede34..f5c056d 100644 --- a/sites/all/modules/views/plugins/views_plugin_argument_default_fixed.inc +++ b/sites/all/modules/views/plugins/views_plugin_argument_default_fixed.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the fixed argument default plugin. + * Definition of views_plugin_argument_default_fixed. */ /** @@ -11,14 +11,21 @@ * @ingroup views_argument_default_plugins */ class views_plugin_argument_default_fixed extends views_plugin_argument_default { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['argument'] = array('default' => ''); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['argument'] = array( '#type' => 'textfield', @@ -30,15 +37,19 @@ class views_plugin_argument_default_fixed extends views_plugin_argument_default /** * Return the default argument. */ - function get_argument() { + public function get_argument() { return $this->options['argument']; } - function convert_options(&$options) { + /** + * {@inheritdoc} + */ + public function convert_options(&$options) { if (!isset($options['argument']) && isset($this->argument->options['default_argument_fixed'])) { $options['argument'] = $this->argument->options['default_argument_fixed']; } } + } /** diff --git a/sites/all/modules/views/plugins/views_plugin_argument_default_php.inc b/sites/all/modules/views/plugins/views_plugin_argument_default_php.inc index c2fb14f..9ae8600 100644 --- a/sites/all/modules/views/plugins/views_plugin_argument_default_php.inc +++ b/sites/all/modules/views/plugins/views_plugin_argument_default_php.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the php code argument default plugin. + * Definition of views_plugin_argument_default_php. */ /** @@ -11,14 +11,21 @@ * @ingroup views_argument_default_plugins */ class views_plugin_argument_default_php extends views_plugin_argument_default { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['code'] = array('default' => ''); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['code'] = array( '#type' => 'textarea', @@ -27,11 +34,14 @@ class views_plugin_argument_default_php extends views_plugin_argument_default { '#description' => t('Enter PHP code that returns a value to use for this filter. Do not use <?php ?>. You must return only a single value for just this filter. Some variables are available: the view object will be "$view". The argument handler will be "$argument", for example you may change the title used for substitutions for this argument by setting "argument->validated_title"".'), ); - // Only do this if using one simple standard form gadget + // Only do this if using one simple standard form gadget. $this->check_access($form, 'code'); } - function convert_options(&$options) { + /** + * {@inheritdoc} + */ + public function convert_options(&$options) { if (!isset($options['code']) && isset($this->argument->options['default_argument_php'])) { $options['code'] = $this->argument->options['default_argument_php']; } @@ -41,11 +51,14 @@ class views_plugin_argument_default_php extends views_plugin_argument_default { * Only let users with PHP block visibility permissions set/modify this * default plugin. */ - function access() { + public function access() { return user_access('use PHP for settings'); } - function get_argument() { + /** + * {@inheritdoc} + */ + public function get_argument() { // set up variables to make it easier to reference during the argument. $view = &$this->view; $argument = &$this->argument; @@ -54,4 +67,5 @@ class views_plugin_argument_default_php extends views_plugin_argument_default { ob_end_clean(); return $result; } + } diff --git a/sites/all/modules/views/plugins/views_plugin_argument_default_raw.inc b/sites/all/modules/views/plugins/views_plugin_argument_default_raw.inc index 385ca91..4d42a89 100644 --- a/sites/all/modules/views/plugins/views_plugin_argument_default_raw.inc +++ b/sites/all/modules/views/plugins/views_plugin_argument_default_raw.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the raw value argument default plugin. + * Definition of views_plugin_argument_default_raw. */ /** @@ -11,7 +11,11 @@ * @ingroup views_argument_default_plugins */ class views_plugin_argument_default_raw extends views_plugin_argument_default { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['index'] = array('default' => ''); $options['use_alias'] = array('default' => FALSE, 'bool' => TRUE); @@ -19,7 +23,10 @@ class views_plugin_argument_default_raw extends views_plugin_argument_default { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // Using range(1, 10) will create an array keyed 0-9, which allows arg() to // properly function since it is also zero-based. @@ -38,7 +45,10 @@ class views_plugin_argument_default_raw extends views_plugin_argument_default { ); } - function get_argument() { + /** + * {@inheritdoc} + */ + public function get_argument() { $path = NULL; if ($this->options['use_alias']) { $path = drupal_get_path_alias(); @@ -47,4 +57,5 @@ class views_plugin_argument_default_raw extends views_plugin_argument_default { return $arg; } } + } diff --git a/sites/all/modules/views/plugins/views_plugin_argument_validate.inc b/sites/all/modules/views/plugins/views_plugin_argument_validate.inc index 350cb43..19aebc7 100644 --- a/sites/all/modules/views/plugins/views_plugin_argument_validate.inc +++ b/sites/all/modules/views/plugins/views_plugin_argument_validate.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the base argument validator plugin. + * Definition of views_plugin_argument_validate. */ /** @@ -19,10 +19,9 @@ class views_plugin_argument_validate extends views_plugin { /** - * Initialize this plugin with the view and the argument - * it is linked to. + * Initialize this plugin with the view and the argument it is linked to. */ - function init(&$view, &$argument, $options) { + public function init(&$view, &$argument, $options) { $this->view = &$view; $this->argument = &$argument; @@ -31,25 +30,29 @@ class views_plugin_argument_validate extends views_plugin { } /** - * Retrieve the options when this is a new access - * control plugin + * Retrieve the options when this is a new access control plugin. */ - function option_definition() { return array(); } + public function option_definition() { + return array(); + } /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { } + public function options_form(&$form, &$form_state) { + } /** - * Provide the default form form for validating options + * Provide the default form form for validating options. */ - function options_validate(&$form, &$form_state) { } + public function options_validate(&$form, &$form_state) { + } /** * Provide the default form form for submitting options */ - function options_submit(&$form, &$form_state, &$options = array()) { } + public function options_submit(&$form, &$form_state, &$options = array()) { + } /** * Convert options from the older style. @@ -59,12 +62,15 @@ class views_plugin_argument_validate extends views_plugin { * move arguments from the old style to the new style. See * views_plugin_argument_default_fixed for a good example of this method. */ - function convert_options(&$options) { } + public function convert_options(&$options) { + } /** - * Determine if the administrator has the privileges to use this plugin + * Determine if the administrator has the privileges to use this plugin. */ - function access() { return TRUE; } + public function access() { + return TRUE; + } /** * If we don't have access to the form but are showing it anyway, ensure that @@ -73,7 +79,7 @@ class views_plugin_argument_validate extends views_plugin { * This is only called by child objects if specified in the options_form(), * so it will not always be used. */ - function check_access(&$form, $option_name) { + public function check_access(&$form, $option_name) { if (!$this->access()) { $form[$option_name]['#disabled'] = TRUE; $form[$option_name]['#value'] = $form[$this->option_name]['#default_value']; @@ -81,7 +87,12 @@ class views_plugin_argument_validate extends views_plugin { } } - function validate_argument($arg) { return TRUE; } + /** + * {@inheritdoc} + */ + public function validate_argument($arg) { + return TRUE; + } /** * Process the summary arguments for displaying. @@ -91,7 +102,9 @@ class views_plugin_argument_validate extends views_plugin { * for a faster query. But there are use cases where you want to use * the old value again, for example the summary. */ - function process_summary_arguments(&$args) { } + public function process_summary_arguments(&$args) { + } + } /** diff --git a/sites/all/modules/views/plugins/views_plugin_argument_validate_numeric.inc b/sites/all/modules/views/plugins/views_plugin_argument_validate_numeric.inc index 049531b..bb0abcb 100644 --- a/sites/all/modules/views/plugins/views_plugin_argument_validate_numeric.inc +++ b/sites/all/modules/views/plugins/views_plugin_argument_validate_numeric.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the numeric argument validator plugin. + * Definition of views_plugin_argument_validate_numeric. */ /** @@ -11,7 +11,12 @@ * @ingroup views_argument_validate_plugins */ class views_plugin_argument_validate_numeric extends views_plugin_argument_validate { - function validate_argument($argument) { + + /** + * {@inheritdoc} + */ + public function validate_argument($argument) { return is_numeric($argument); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_argument_validate_php.inc b/sites/all/modules/views/plugins/views_plugin_argument_validate_php.inc index 83b22b4..1d6a137 100644 --- a/sites/all/modules/views/plugins/views_plugin_argument_validate_php.inc +++ b/sites/all/modules/views/plugins/views_plugin_argument_validate_php.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the php code argument validator plugin. + * Definition of views_plugin_argument_validate_php. */ /** @@ -11,14 +11,21 @@ * @ingroup views_argument_validate_plugins */ class views_plugin_argument_validate_php extends views_plugin_argument_validate { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['code'] = array('default' => ''); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['code'] = array( '#type' => 'textarea', @@ -34,17 +41,23 @@ class views_plugin_argument_validate_php extends views_plugin_argument_validate * Only let users with PHP block visibility permissions set/modify this * validate plugin. */ - function access() { + public function access() { return user_access('use PHP for settings'); } - function convert_options(&$options) { + /** + * {@inheritdoc} + */ + public function convert_options(&$options) { if (!isset($options['code']) && isset($this->argument->options['validate_argument_php'])) { $options['code'] = $this->argument->options['validate_argument_php']; } } - function validate_argument($argument) { + /** + * {@inheritdoc} + */ + public function validate_argument($argument) { // set up variables to make it easier to reference during the argument. $view = &$this->view; $handler = &$this->argument; @@ -54,4 +67,5 @@ class views_plugin_argument_validate_php extends views_plugin_argument_validate ob_end_clean(); return $result; } + } diff --git a/sites/all/modules/views/plugins/views_plugin_cache.inc b/sites/all/modules/views/plugins/views_plugin_cache.inc index d5d785f..80eb831 100644 --- a/sites/all/modules/views/plugins/views_plugin_cache.inc +++ b/sites/all/modules/views/plugins/views_plugin_cache.inc @@ -17,31 +17,32 @@ * The base plugin to handle caching. */ class views_plugin_cache extends views_plugin { + /** * Contains all data that should be written/read from cache. */ - var $storage = array(); + public $storage = array(); /** * What table to store data in. */ - var $table = 'cache_views_data'; + public $table = 'cache_views_data'; /** * Initialize the plugin. * - * @param $view + * @param view $view * The view object. - * @param $display + * @param object $display * The display handler. */ - function init(&$view, &$display) { + public function init(&$view, &$display) { $this->view = &$view; $this->display = &$display; if (is_object($display->handler)) { $options = $display->handler->get_option('cache'); - // Overlay incoming options on top of defaults + // Overlay incoming options on top of defaults. $this->unpack_options($this->options, $options); } } @@ -50,7 +51,7 @@ class views_plugin_cache extends views_plugin { * Return a string to display as the clickable title for the * access control. */ - function summary_title() { + public function summary_title() { return t('Unknown'); } @@ -59,35 +60,37 @@ class views_plugin_cache extends views_plugin { * * Plugins must override this to implement expiration. * - * @param $type + * @param string $type * The cache type, either 'query', 'result' or 'output'. */ - function cache_expire($type) { } - - /** - * Determine expiration time in the cache table of the cache type - * or CACHE_PERMANENT if item shouldn't be removed automatically from cache. - * - * Plugins must override this to implement expiration in the cache table. - * - * @param $type - * The cache type, either 'query', 'result' or 'output'. - */ - function cache_set_expire($type) { - return CACHE_PERMANENT; + public function cache_expire($type) { } + /** + * Determine expiration time in the cache table of the cache type. + * + * Or CACHE_PERMANENT if item shouldn't be removed automatically from cache. + * + * Plugins must override this to implement expiration in the cache table. + * + * @param string $type + * The cache type, either 'query', 'result' or 'output'. + */ + public function cache_set_expire($type) { + return CACHE_PERMANENT; + } /** * Save data to the cache. * * A plugin should override this to provide specialized caching behavior. */ - function cache_set($type) { + public function cache_set($type) { switch ($type) { case 'query': // Not supported currently, but this is certainly where we'd put it. break; + case 'results': $data = array( 'result' => $this->view->result, @@ -96,6 +99,7 @@ class views_plugin_cache extends views_plugin { ); cache_set($this->get_results_key(), $data, $this->table, $this->cache_set_expire($type)); break; + case 'output': $this->gather_headers(); $this->storage['output'] = $this->view->display_handler->output; @@ -104,18 +108,18 @@ class views_plugin_cache extends views_plugin { } } - /** * Retrieve data from the cache. * * A plugin should override this to provide specialized caching behavior. */ - function cache_get($type) { + public function cache_get($type) { $cutoff = $this->cache_expire($type); switch ($type) { case 'query': // Not supported currently, but this is certainly where we'd put it. return FALSE; + case 'results': // Values to set: $view->result, $view->total_rows, $view->execute_time, // $view->current_page. @@ -129,6 +133,7 @@ class views_plugin_cache extends views_plugin { } } return FALSE; + case 'output': if ($cache = cache_get($this->get_output_key(), $this->table)) { if (!$cutoff || $cache->created > $cutoff) { @@ -145,18 +150,18 @@ class views_plugin_cache extends views_plugin { /** * Clear out cached data for a view. * - * We're just going to nuke anything related to the view, regardless of display, - * to be sure that we catch everything. Maybe that's a bad idea. + * We're just going to nuke anything related to the view, regardless of + * display, to be sure that we catch everything. Maybe that's a bad idea. */ - function cache_flush() { + public function cache_flush() { cache_clear_all($this->view->name . ':', $this->table, TRUE); } /** * Post process any rendered data. * - * This can be valuable to be able to cache a view and still have some level of - * dynamic output. In an ideal world, the actual output will include HTML + * This can be valuable to be able to cache a view and still have some level + * of dynamic output. In an ideal world, the actual output will include HTML * comment based tokens, and then the post process can replace those tokens. * * Example usage. If it is known that the view is a node view and that the @@ -172,16 +177,17 @@ class views_plugin_cache extends views_plugin { * All of the cached result data will be available in $view->result, as well, * so all ids used in the query should be discoverable. */ - function post_render(&$output) { } + public function post_render(&$output) { + } /** - * Start caching javascript, css and other out of band info. + * Start caching JavaScript, css and other out of band info. * * This takes a snapshot of the current system state so that we don't * duplicate it. Later on, when gather_headers() is run, this information * will be removed so that we don't hold onto it. */ - function cache_start() { + public function cache_start() { $this->storage['head'] = drupal_add_html_head(); $this->storage['css'] = drupal_add_css(); $this->storage['js'] = drupal_add_js(); @@ -189,10 +195,10 @@ class views_plugin_cache extends views_plugin { } /** - * Gather out of band data, compare it to what we started with and store the difference. + * Gather out of band data, compare it to the start data and store the diff. */ - function gather_headers() { - // Simple replacement for head + public function gather_headers() { + // Simple replacement for head. if (isset($this->storage['head'])) { $this->storage['head'] = str_replace($this->storage['head'], '', drupal_add_html_head()); } @@ -203,15 +209,15 @@ class views_plugin_cache extends views_plugin { // Check if the advanced mapping function of D 7.23 is available. $array_mapping_func = function_exists('drupal_array_diff_assoc_recursive') ? 'drupal_array_diff_assoc_recursive' : 'array_diff_assoc'; - // Slightly less simple for CSS: + // Slightly less simple for CSS. $css = drupal_add_css(); $css_start = isset($this->storage['css']) ? $this->storage['css'] : array(); $this->storage['css'] = $this->assetDiff($css, $css_start, $array_mapping_func); - // Get javascript after/before views renders. + // Get JavaScript after/before views renders. $js = drupal_add_js(); $js_start = isset($this->storage['js']) ? $this->storage['js'] : array(); - // If there are any differences between the old and the new javascript then + // If there are any differences between the old and the new JavaScript then // store them to be added later. $this->storage['js'] = $this->assetDiff($js, $js_start, $array_mapping_func); @@ -259,7 +265,7 @@ class views_plugin_cache extends views_plugin { /** * Restore out of band data saved to cache. Copied from Panels. */ - function restore_headers() { + public function restore_headers() { if (!empty($this->storage['head'])) { drupal_add_html_head($this->storage['head']); } @@ -287,7 +293,10 @@ class views_plugin_cache extends views_plugin { } } - function get_results_key() { + /** + * + */ + public function get_results_key() { if (!isset($this->_results_key)) { $key_data = array(); foreach (array('exposed_info', 'page', 'sort', 'order', 'items_per_page', 'offset') as $key) { @@ -302,7 +311,10 @@ class views_plugin_cache extends views_plugin { return $this->_results_key; } - function get_output_key() { + /** + * + */ + public function get_output_key() { if (!isset($this->_output_key)) { $key_data = array( 'result' => $this->view->result, @@ -323,24 +335,33 @@ class views_plugin_cache extends views_plugin { * * @return string */ - function get_cache_key($key_data = array()) { + public function get_cache_key($key_data = array()) { global $user; $key_data += array( 'roles' => array_keys($user->roles), - 'super-user' => $user->uid == 1, // special caching for super user. + 'super-user' => $user->uid == 1, + // special caching for super user. 'language' => $GLOBALS['language']->language, + 'language_content' => $GLOBALS['language_content']->language, 'base_url' => $GLOBALS['base_url'], ); if (empty($key_data['build_info'])) { $build_info = $this->view->build_info; - foreach (array('query','count_query') as $index) { + foreach (array('query', 'count_query') as $index) { // If the default query back-end is used generate SQL query strings from // the query objects. if ($build_info[$index] instanceof SelectQueryInterface) { - $query = clone $build_info[$index]; - $query->preExecute(); + $query = $build_info[$index]; + + // If the query was not yet prepared, work on a clone and run + // preExecute(). + if (!$query->isPrepared()) { + $query = clone $build_info[$index]; + $query->preExecute(); + } + $key_data['build_info'][$index] = array( 'sql' => (string) $query, 'arguments' => $query->getArguments(), @@ -348,9 +369,9 @@ class views_plugin_cache extends views_plugin { } } } - $key = md5(serialize($key_data)); - return $key; + return md5(serialize($key_data)); } + } /** diff --git a/sites/all/modules/views/plugins/views_plugin_cache_none.inc b/sites/all/modules/views/plugins/views_plugin_cache_none.inc index 9927a9d..ae57404 100644 --- a/sites/all/modules/views/plugins/views_plugin_cache_none.inc +++ b/sites/all/modules/views/plugins/views_plugin_cache_none.inc @@ -11,15 +11,32 @@ * @ingroup views_cache_plugins */ class views_plugin_cache_none extends views_plugin_cache { - function cache_start() { /* do nothing */ } - function summary_title() { + /** + * {@inheritdoc} + */ + public function cache_start() { + // Do nothing. + } + + /** + * {@inheritdoc} + */ + public function summary_title() { return t('None'); } - function cache_get($type) { + /** + * {@inheritdoc} + */ + public function cache_get($type) { return FALSE; } - function cache_set($type) { } + /** + * {@inheritdoc} + */ + public function cache_set($type) { + } + } diff --git a/sites/all/modules/views/plugins/views_plugin_cache_time.inc b/sites/all/modules/views/plugins/views_plugin_cache_time.inc index c11a192..efd717e 100644 --- a/sites/all/modules/views/plugins/views_plugin_cache_time.inc +++ b/sites/all/modules/views/plugins/views_plugin_cache_time.inc @@ -11,7 +11,11 @@ * @ingroup views_cache_plugins */ class views_plugin_cache_time extends views_plugin_cache { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['results_lifespan'] = array('default' => 3600); $options['results_lifespan_custom'] = array('default' => 0); @@ -21,7 +25,10 @@ class views_plugin_cache_time extends views_plugin_cache { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $options = array(60, 300, 1800, 3600, 21600, 518400); $options = drupal_map_assoc($options, 'format_interval'); @@ -67,27 +74,39 @@ class views_plugin_cache_time extends views_plugin_cache { ); } - function options_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { $custom_fields = array('output_lifespan', 'results_lifespan'); foreach ($custom_fields as $field) { if ($form_state['values']['cache_options'][$field] == 'custom' && !is_numeric($form_state['values']['cache_options'][$field . '_custom'])) { - form_error($form[$field .'_custom'], t('Custom time values must be numeric.')); + form_error($form[$field . '_custom'], t('Custom time values must be numeric.')); } } } - function summary_title() { + /** + * {@inheritdoc} + */ + public function summary_title() { $results_lifespan = $this->get_lifespan('results'); $output_lifespan = $this->get_lifespan('output'); return format_interval($results_lifespan, 1) . '/' . format_interval($output_lifespan, 1); } - function get_lifespan($type) { + /** + * {@inheritdoc} + */ + public function get_lifespan($type) { $lifespan = $this->options[$type . '_lifespan'] == 'custom' ? $this->options[$type . '_lifespan_custom'] : $this->options[$type . '_lifespan']; return $lifespan; } - function cache_expire($type) { + /** + * {@inheritdoc} + */ + public function cache_expire($type) { $lifespan = $this->get_lifespan($type); if ($lifespan) { $cutoff = REQUEST_TIME - $lifespan; @@ -98,7 +117,10 @@ class views_plugin_cache_time extends views_plugin_cache { } } - function cache_set_expire($type) { + /** + * {@inheritdoc} + */ + public function cache_set_expire($type) { $lifespan = $this->get_lifespan($type); if ($lifespan) { return time() + $lifespan; @@ -108,14 +130,20 @@ class views_plugin_cache_time extends views_plugin_cache { } } - function cache_set($type) { + /** + * {@inheritdoc} + */ + public function cache_set($type) { $lifespan = $this->get_lifespan($type); if ($lifespan >= 0) { parent::cache_set($type); } } - function cache_get($type) { + /** + * {@inheritdoc} + */ + public function cache_get($type) { $lifespan = $this->get_lifespan($type); if ($lifespan >= 0) { return parent::cache_get($type); @@ -124,4 +152,5 @@ class views_plugin_cache_time extends views_plugin_cache { return FALSE; } } + } diff --git a/sites/all/modules/views/plugins/views_plugin_display.inc b/sites/all/modules/views/plugins/views_plugin_display.inc index 0750fa8..7383ac9 100644 --- a/sites/all/modules/views/plugins/views_plugin_display.inc +++ b/sites/all/modules/views/plugins/views_plugin_display.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the base display plugin. + * Definition of views_plugin_display. */ /** @@ -23,21 +23,32 @@ * basic mechanisms for different output methods. */ class views_plugin_display extends views_plugin { + /** * The top object of a view. * * @var view */ - var $view = NULL; + public $view = NULL; - var $handlers = array(); + /** + * List of handlers for this display. + * + * @var array + */ + public $handlers = array(); /** * Stores all available display extenders. + * + * @var array */ - var $extender = array(); + public $extender = array(); - function init(&$view, &$display, $options = NULL) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$display, $options = NULL) { $this->view = &$view; $this->display = &$display; @@ -61,7 +72,7 @@ class views_plugin_display extends views_plugin { // Track changes that the user should know about. $changed = FALSE; - // Make some modifications: + // Make some modifications. if (!isset($options) && isset($display->display_options)) { $options = $display->display_options; } @@ -93,7 +104,7 @@ class views_plugin_display extends views_plugin { $this->unpack_options($this->options, $options); } - // Translate changed settings: + // Translate changed settings. $items_per_page = $this->get_option('items_per_page'); $offset = $this->get_option('offset'); $use_pager = $this->get_option('use_pager'); @@ -106,7 +117,7 @@ class views_plugin_display extends views_plugin { // for exported Views as it's not stored in the database. // If you would like to change this code, really take care that you thought // of every possibility. - // @TODO: Provide a way to convert the database views as well. + // @todo Provide a way to convert the database views as well. if (((!empty($items_per_page) && $items_per_page != 10) || !empty($offset) || !empty($use_pager)) || (!empty($view->api_version) && $view->api_version == 2)) { // Find out the right pager type. @@ -124,7 +135,7 @@ class views_plugin_display extends views_plugin { $pager = array( 'type' => $type, 'options' => array( - 'offset' => intval($offset) + 'offset' => intval($offset), ), ); @@ -136,8 +147,8 @@ class views_plugin_display extends views_plugin { $pager['options']['id'] = $id; } - // Unset the previous options - // After edit and save the view they will be erased + // Unset the previous options. After edit and save the view they will be + // erased. $this->set_option('items_per_page', NULL); $this->set_option('offset', NULL); $this->set_option('use_pager', NULL); @@ -145,10 +156,9 @@ class views_plugin_display extends views_plugin { $changed = TRUE; } - - // Plugable headers, footer and empty texts are - // not compatible with previous version of views - // This code converts old values into a configured handler for each area + // Plugable headers, footer and empty texts are not compatible with + // previous version of views. This code converts old values into a + // configured handler for each area. foreach (array('header', 'footer', 'empty') as $area) { $converted = FALSE; if (isset($this->options[$area]) && !is_array($this->options[$area])) { @@ -175,7 +185,7 @@ class views_plugin_display extends views_plugin { $changed = TRUE; } } - // Ensure that options are at least an empty array + // Ensure that options are at least an empty array. if (!$converted) { $this->set_option($area, array()); } @@ -188,7 +198,7 @@ class views_plugin_display extends views_plugin { $query_settings = $this->get_option('query'); $query_settings['options']['distinct'] = $distinct; $this->set_option('query', $query_settings); - // Clear the values + // Clear the values. $this->set_option('distinct', NULL); $changed = TRUE; } @@ -209,10 +219,11 @@ class views_plugin_display extends views_plugin { // Convert filter groups. $filter_groups = $this->get_option('filter_groups'); - // Only convert if it wasn't converted yet, which is the case if there is a 0 group. + // Only convert if it wasn't converted yet, which is the case if there is a + // '0' group. if (isset($filter_groups['groups'][0])) { // Update filter groups. - $filter_groups ['groups'] = views_array_key_plus($filter_groups['groups']); + $filter_groups['groups'] = views_array_key_plus($filter_groups['groups']); $this->set_option('filter_groups', $filter_groups); // Update the filter group on each filter. $filters = $this->get_option('filters'); @@ -253,7 +264,10 @@ class views_plugin_display extends views_plugin { } } - function destroy() { + /** + * {@inheritdoc} + */ + public function destroy() { parent::destroy(); foreach ($this->handlers as $type => $handlers) { @@ -274,16 +288,21 @@ class views_plugin_display extends views_plugin { } /** - * Determine if this display is the 'default' display which contains - * fallback settings + * If this display is the 'default' display which contains fallback settings. + * + * @return bool + * This is the default display and contains fallback settings. */ - function is_default_display() { return FALSE; } + public function is_default_display() { + return FALSE; + } /** - * Determine if this display uses exposed filters, so the view - * will know whether or not to build them. + * Does this display uses exposed filters? + * + * So the view will know whether or not to build them. */ - function uses_exposed() { + public function uses_exposed() { if (!isset($this->has_exposed)) { foreach ($this->handlers as $type => $value) { foreach ($this->view->$type as $id => $handler) { @@ -306,22 +325,21 @@ class views_plugin_display extends views_plugin { } /** - * Determine if this display should display the exposed - * filters widgets, so the view will know whether or not - * to render them. + * Determine if this display should display the exposed filters widgets. * - * Regardless of what this function - * returns, exposed filters will not be used nor - * displayed unless uses_exposed() returns TRUE. + * If so, the view will know whether or not to render them. + * + * Regardless of what this function returns, exposed filters will not be used + * nor displayed unless uses_exposed() returns TRUE. */ - function displays_exposed() { + public function displays_exposed() { return TRUE; } /** * Does the display use AJAX? */ - function use_ajax() { + public function use_ajax() { if (!empty($this->definition['use ajax'])) { return $this->get_option('use_ajax'); } @@ -331,7 +349,7 @@ class views_plugin_display extends views_plugin { /** * Does the display have a pager enabled? */ - function use_pager() { + public function use_pager() { $pager = $this->get_plugin('pager'); if ($pager) { return $pager->use_pager(); @@ -341,7 +359,7 @@ class views_plugin_display extends views_plugin { /** * Does the display have a more link enabled? */ - function use_more() { + public function use_more() { if (!empty($this->definition['use more'])) { return $this->get_option('use_more'); } @@ -351,14 +369,14 @@ class views_plugin_display extends views_plugin { /** * Does the display have groupby enabled? */ - function use_group_by() { + public function use_group_by() { return $this->get_option('group_by'); } /** * Should the enabled display more link be shown when no more items? */ - function use_more_always() { + public function use_more_always() { if (!empty($this->definition['use more'])) { return $this->get_option('use_more_always'); } @@ -367,11 +385,8 @@ class views_plugin_display extends views_plugin { /** * Should the enabled display more link being opened in an new window? - * - * @codingStandardsIgnoreStart */ - function use_more_open_new_window() { - // @codingStandardsIgnoreEnd + public function use_more_open_new_window() { if (!empty($this->definition['use more'])) { return $this->get_option('open_new_window'); } @@ -381,7 +396,7 @@ class views_plugin_display extends views_plugin { /** * Does the display have custom link text? */ - function use_more_text() { + public function use_more_text() { if (!empty($this->definition['use more'])) { return $this->get_option('use_more_text'); } @@ -391,7 +406,7 @@ class views_plugin_display extends views_plugin { /** * Can this display accept attachments? */ - function accept_attachments() { + public function accept_attachments() { if (empty($this->definition['accept attachments'])) { return FALSE; } @@ -408,13 +423,13 @@ class views_plugin_display extends views_plugin { /** * Allow displays to attach to other views. */ - function attach_to($display_id) { } + public function attach_to($display_id) { + } /** - * Static member function to list which sections are defaultable - * and what items each section contains. + * List which sections are defaultable and what items each section contains. */ - function defaultable_sections($section = NULL) { + public function defaultable_sections($section = NULL) { $sections = array( 'access' => array('access', 'access_options'), 'access_options' => array('access', 'access_options'), @@ -453,10 +468,30 @@ class views_plugin_display extends views_plugin { 'link_display' => array('link_display', 'link_url'), // Force these to cascade properly. - 'style_plugin' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'), - 'style_options' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'), - 'row_plugin' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'), - 'row_options' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'), + 'style_plugin' => array( + 'style_plugin', + 'style_options', + 'row_plugin', + 'row_options', + ), + 'style_options' => array( + 'style_plugin', + 'style_options', + 'row_plugin', + 'row_options', + ), + 'row_plugin' => array( + 'style_plugin', + 'style_options', + 'row_plugin', + 'row_options', + ), + 'row_options' => array( + 'style_plugin', + 'style_options', + 'row_plugin', + 'row_options', + ), 'pager' => array('pager', 'pager_options'), 'pager_options' => array('pager', 'pager_options'), @@ -464,7 +499,7 @@ class views_plugin_display extends views_plugin { 'exposed_form' => array('exposed_form', 'exposed_form_options'), 'exposed_form_options' => array('exposed_form', 'exposed_form_options'), - // These guys are special + // These guys are special. 'header' => array('header'), 'footer' => array('footer'), 'empty' => array('empty'), @@ -496,7 +531,10 @@ class views_plugin_display extends views_plugin { } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = array( 'defaults' => array( 'default' => array( @@ -574,9 +612,9 @@ class views_plugin_display extends views_plugin { 'default' => FALSE, 'bool' => TRUE, ), - // This is legacy code: - // Items_per/offset/use_pager is moved to the pager plugin - // but the automatic update path needs this items defined, so don't remove it. + // This is legacy code. + // Items_per/offset/use_pager is moved to the pager plugin but the + // automatic update path needs this items defined, so don't remove it. // @see views_plugin_display::init() 'items_per_page' => array( 'default' => 10, @@ -618,46 +656,64 @@ class views_plugin_display extends views_plugin { 'default' => 1, ), - // These types are all plugins that can have individual settings - // and therefore need special handling. + // These types are all plugins that can have individual settings and + // therefore need special handling. 'access' => array( 'contains' => array( - 'type' => array('default' => 'none', 'export' => 'export_plugin', 'unpack_translatable' => 'unpack_plugin'), - ), + 'type' => array( + 'default' => 'none', + 'export' => 'export_plugin', + 'unpack_translatable' => 'unpack_plugin', + ), + ), ), 'cache' => array( 'contains' => array( - 'type' => array('default' => 'none', 'export' => 'export_plugin', 'unpack_translatable' => 'unpack_plugin'), - ), + 'type' => array( + 'default' => 'none', + 'export' => 'export_plugin', + 'unpack_translatable' => 'unpack_plugin', + ), + ), ), 'query' => array( 'contains' => array( - 'type' => array('default' => 'views_query', 'export' => 'export_plugin'), + 'type' => array( + 'default' => 'views_query', + 'export' => 'export_plugin', + ), 'options' => array('default' => array(), 'export' => FALSE), - ), + ), ), - // Note that exposed_form plugin has options in a separate array, - // while access and cache do not. access and cache are legacy and - // that pattern should not be repeated, but it is left as is to - // reduce the need to modify older views. Let's consider the - // pattern used here to be the template from which future plugins - // should be copied. + // Note that exposed_form plugin has options in a separate array, while + // access and cache do not. access and cache are legacy and that pattern + // should not be repeated, but it is left as is to reduce the need to + // modify older views. Let's consider the pattern used here to be the + // template from which future plugins should be copied. 'exposed_form' => array( 'contains' => array( - 'type' => array('default' => 'basic', 'export' => 'export_plugin', 'unpack_translatable' => 'unpack_plugin'), + 'type' => array( + 'default' => 'basic', + 'export' => 'export_plugin', + 'unpack_translatable' => 'unpack_plugin', + ), 'options' => array('default' => array(), 'export' => FALSE), - ), + ), ), 'pager' => array( 'contains' => array( - 'type' => array('default' => 'full', 'export' => 'export_plugin', 'unpack_translatable' => 'unpack_plugin'), + 'type' => array( + 'default' => 'full', + 'export' => 'export_plugin', + 'unpack_translatable' => 'unpack_plugin', + ), 'options' => array('default' => array(), 'export' => FALSE), - ), + ), ), - // Note that the styles have their options completely independent. - // Like access and cache above, this is a legacy pattern and - // should not be repeated. + // Note that the styles have their options completely independent. Like + // access and cache above, this is a legacy pattern and should not be + // repeated. 'style_plugin' => array( 'default' => 'default', 'export' => 'export_style', @@ -761,32 +817,36 @@ class views_plugin_display extends views_plugin { * * By default, displays do not have a path. */ - function has_path() { return FALSE; } + public function has_path() { + return FALSE; + } /** * Check to see if the display has some need to link to another display. * - * For the most part, displays without a path will use a link display. However, - * sometimes displays that have a path might also need to link to another display. - * This is true for feeds. + * For the most part, displays without a path will use a link display. + * However, sometimes displays that have a path might also need to link to + * another display. This is true for feeds. */ - function uses_link_display() { return !$this->has_path(); } + public function uses_link_display() { + return !$this->has_path(); + } /** * Check to see if the display can put the exposed form in a block. * - * By default, displays that do not have a path cannot disconnect - * the exposed form and put it in a block, because the form has no - * place to go and Views really wants the forms to go to a specific - * page. + * By default, displays that do not have a path cannot disconnect the exposed + * form and put it in a block, because the form has no place to go and Views + * really wants the forms to go to a specific page. */ - function uses_exposed_form_in_block() { return $this->has_path(); } + public function uses_exposed_form_in_block() { + return $this->has_path(); + } /** - * Check to see which display to use when creating links within - * a view using this display. + * Check to see which display to use when creating links. */ - function get_link_display() { + public function get_link_display() { $display_id = $this->get_option('link_display'); // If unknown, pick the first one. if (empty($display_id) || empty($this->view->display[$display_id])) { @@ -799,16 +859,15 @@ class views_plugin_display extends views_plugin { else { return $display_id; } - // fall-through returns NULL + // Fall-through returns NULL. } /** * Return the base path to use for this display. * - * This can be overridden for displays that do strange things - * with the path. + * This can be overridden for displays that do strange things with the path. */ - function get_path() { + public function get_path() { if ($this->has_path()) { return $this->get_option('path'); } @@ -823,38 +882,41 @@ class views_plugin_display extends views_plugin { } } - function get_url() { + /** + * + */ + public function get_url() { return $this->view->get_url(); } /** - * Check to see if the display needs a breadcrumb + * Check to see if the display needs a breadcrumb. * - * By default, displays do not need breadcrumbs + * By default, displays do not need breadcrumbs. */ - function uses_breadcrumb() { return FALSE; } + public function uses_breadcrumb() { + return FALSE; + } /** - * Determine if a given option is set to use the default display or the - * current display + * Determine if a given option is set to use the default or current display. * * @return - * TRUE for the default display + * TRUE for the default display. */ - function is_defaulted($option) { + public function is_defaulted($option) { return !$this->is_default_display() && !empty($this->default_display) && !empty($this->options['defaults'][$option]); } /** - * Intelligently get an option either from this display or from the - * default display, if directed to do so. + * Intelligently get an option either from this or default display. */ - function get_option($option) { + public function get_option($option) { if ($this->is_defaulted($option)) { return $this->default_display->get_option($option); } - if (array_key_exists($option, $this->options)) { + if (isset($this->options[$option]) || array_key_exists($option, $this->options)) { return $this->options[$option]; } } @@ -862,7 +924,7 @@ class views_plugin_display extends views_plugin { /** * Determine if the display's style uses fields. */ - function uses_fields() { + public function uses_fields() { $plugin = $this->get_plugin(); if ($plugin) { return $plugin->uses_fields(); @@ -878,8 +940,9 @@ class views_plugin_display extends views_plugin { * The name of the plugin defined in hook_views_plugins. * * @return views_plugin|FALSE + * FALSE if no plugin, otherwise the requested instance of a plugin. */ - function get_plugin($type = 'style', $name = NULL) { + public function get_plugin($type = 'style', $name = NULL) { static $cache = array(); if (!isset($cache[$type][$name])) { switch ($type) { @@ -890,8 +953,8 @@ class views_plugin_display extends views_plugin { if (!$name) { $name = $this->get_option($option_name); } - break; + case 'query': $views_data = views_fetch_data($this->view->base_table); $name = !empty($views_data['table']['base']['query class']) ? $views_data['table']['base']['query class'] : 'views_query'; @@ -902,8 +965,8 @@ class views_plugin_display extends views_plugin { $name = $options['type']; } - // access & cache store their options as siblings with the - // type; all others use an 'options' array. + // Access & cache store their options as siblings with the type; all + // others use an 'options' array. if ($type != 'access' && $type != 'cache') { $options = $options['options']; } @@ -911,7 +974,7 @@ class views_plugin_display extends views_plugin { $plugin = views_get_plugin($type, $name); if (!$plugin) { - return; + return FALSE; } if ($type != 'query') { $plugin->init($this->view, $this->display, $options); @@ -935,7 +998,7 @@ class views_plugin_display extends views_plugin { /** * Get the handler object for a single handler. */ - function &get_handler($type, $id) { + public function &get_handler($type, $id) { if (!isset($this->handlers[$type])) { $this->get_handlers($type); } @@ -952,7 +1015,7 @@ class views_plugin_display extends views_plugin { /** * Get a full array of handlers for $type. This caches them. */ - function &get_handlers($type) { + public function &get_handlers($type) { if (!isset($this->handlers[$type])) { $this->handlers[$type] = array(); $types = views_object_types(); @@ -1011,17 +1074,15 @@ class views_plugin_display extends views_plugin { } /** - * Retrieve a list of fields for the current display with the - * relationship associated if it exists. + * List of fields for the current display with the associated relationship. * - * @param $groupable_only - * Return only an array of field labels from handler that return TRUE - * from use_string_group_by method. + * @param bool $groupable_only + * Return only an array of field labels from handler that return TRUE from + * use_string_group_by method. */ - function get_field_labels() { - // Use func_get_arg so the function signature isn't amended - // but we can still pass TRUE into the function to filter - // by groupable handlers. + public function get_field_labels() { + // Use func_get_arg so the function signature isn't amended but we can still + // pass TRUE into the function to filter by groupable handlers. $args = func_get_args(); $groupable_only = isset($args[0]) ? $args[0] : FALSE; @@ -1057,14 +1118,13 @@ class views_plugin_display extends views_plugin { * Intelligently set an option either from this display or from the * default display, if directed to do so. */ - function set_option($option, $value) { + public function set_option($option, $value) { if ($this->is_defaulted($option)) { return $this->default_display->set_option($option, $value); } - // Set this in two places: On the handler where we'll notice it - // but also on the display object so it gets saved. This should - // only be a temporary fix. + // Set this in two places: On the handler where we'll notice it but also on + // the display object so it gets saved. This should only be a temporary fix. $this->display->display_options[$option] = $value; return $this->options[$option] = $value; } @@ -1072,7 +1132,7 @@ class views_plugin_display extends views_plugin { /** * Set an option and force it to be an override. */ - function override_option($option, $value) { + public function override_option($option, $value) { $this->set_override($option, FALSE); $this->set_option($option, $value); } @@ -1081,7 +1141,7 @@ class views_plugin_display extends views_plugin { * Because forms may be split up into sections, this provides * an easy URL to exactly the right section. Don't override this. */ - function option_link($text, $section, $class = '', $title = '') { + public function option_link($text, $section, $class = '', $title = '') { views_add_js('ajax'); if (!empty($class)) { $text = '' . $text . ''; @@ -1100,16 +1160,26 @@ class views_plugin_display extends views_plugin { $text = views_ui_truncate($text, 24); } - return l($text, 'admin/structure/views/nojs/display/' . $this->view->name . '/' . $this->display->id . '/' . $section, array('attributes' => array('class' => 'views-ajax-link ' . $class, 'title' => $title, 'id' => drupal_html_id('views-' . $this->display->id . '-' . $section)), 'html' => TRUE)); + return l($text, + 'admin/structure/views/nojs/display/' . $this->view->name . '/' . $this->display->id . '/' . $section, + array( + 'attributes' => array( + 'class' => 'views-ajax-link ' . $class, + 'title' => $title, + 'id' => drupal_html_id('views-' . $this->display->id . '-' . $section), + ), + 'html' => TRUE, + ) + ); } /** * Returns to tokens for arguments. * - * This function is similar to views_handler_field::get_render_tokens() - * but without fields tokens. + * This function is similar to views_handler_field::get_render_tokens() but + * without fields tokens. */ - function get_arguments_tokens() { + public function get_arguments_tokens() { $tokens = array(); if (!empty($this->view->build_info['substitutions'])) { $tokens = $this->view->build_info['substitutions']; @@ -1135,7 +1205,7 @@ class views_plugin_display extends views_plugin { * * This output is returned as an array. */ - function options_summary(&$categories, &$options) { + public function options_summary(&$categories, &$options) { $categories = array( 'title' => array( 'title' => t('Title'), @@ -1224,7 +1294,8 @@ class views_plugin_display extends views_plugin { 'desc' => t('Change the way content is formatted.'), ); - // This adds a 'Settings' link to the style_options setting if the style has options. + // This adds a 'Settings' link to the style_options setting if the style + // has options. if (!empty($style_plugin['uses options'])) { $options['style_plugin']['links']['style_options'] = t('Change settings for this format'); } @@ -1242,7 +1313,8 @@ class views_plugin_display extends views_plugin { 'setting' => $row_summary, 'desc' => t('Change the way each row in the view is styled.'), ); - // This adds a 'Settings' link to the row_options setting if the row style has options. + // This adds a 'Settings' link to the row_options setting if the row + // style has options. if (!empty($row_plugin['uses options'])) { $options['row_plugin']['links']['row_options'] = t('Change settings for this style'); } @@ -1274,7 +1346,7 @@ class views_plugin_display extends views_plugin { $pager_plugin = $this->get_plugin('pager'); if (!$pager_plugin) { - // default to the no pager plugin. + // Default to the no pager plugin. $pager_plugin = views_get_plugin('pager', 'none'); } @@ -1288,7 +1360,7 @@ class views_plugin_display extends views_plugin { 'desc' => t("Change this display's pager setting."), ); - // If pagers aren't allowed, change the text of the item: + // If pagers aren't allowed, change the text of the item. if (empty($this->definition['use pager'])) { $options['pager']['title'] = t('Items to display'); } @@ -1324,9 +1396,9 @@ class views_plugin_display extends views_plugin { ); $languages = array( - '***CURRENT_LANGUAGE***' => t("Current user's language"), - '***DEFAULT_LANGUAGE***' => t("Default site language"), - LANGUAGE_NONE => t('Language neutral'), + '***CURRENT_LANGUAGE***' => t("Current user's language"), + '***DEFAULT_LANGUAGE***' => t("Default site language"), + LANGUAGE_NONE => t('Language neutral'), ); if (module_exists('locale')) { $languages = array_merge($languages, locale_language_list()); @@ -1341,7 +1413,7 @@ class views_plugin_display extends views_plugin { $access_plugin = $this->get_plugin('access'); if (!$access_plugin) { - // default to the no access control plugin. + // Default to the no access control plugin. $access_plugin = views_get_plugin('access', 'none'); } @@ -1361,7 +1433,7 @@ class views_plugin_display extends views_plugin { $cache_plugin = $this->get_plugin('cache'); if (!$cache_plugin) { - // default to the no cache control plugin. + // Default to the no cache control plugin. $cache_plugin = views_get_plugin('cache', 'none'); } @@ -1386,7 +1458,7 @@ class views_plugin_display extends views_plugin { if ($this->uses_link_display()) { $display_id = $this->get_link_display(); $link_display = empty($this->view->display[$display_id]) ? t('None') : check_plain($this->view->display[$display_id]->display_title); - $link_display = $this->get_option('link_display') == 'custom_url' ? t('Custom URL') : $link_display; + $link_display = $this->get_option('link_display') == 'custom_url' ? t('Custom URL') : $link_display; $options['link_display'] = array( 'category' => 'other', 'title' => t('Link display'), @@ -1406,7 +1478,7 @@ class views_plugin_display extends views_plugin { $exposed_form_plugin = $this->get_plugin('exposed_form'); if (!$exposed_form_plugin) { - // default to the no cache control plugin. + // Default to the no cache control plugin. $exposed_form_plugin = views_get_plugin('exposed_form', 'basic'); } @@ -1451,17 +1523,16 @@ class views_plugin_display extends views_plugin { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); if ($this->defaultable_sections($form_state['section'])) { views_ui_standard_display_dropdown($form, $form_state, $form_state['section']); } $form['#title'] = check_plain($this->display->display_title) . ': '; - // Set the 'section' to highlight on the form. - // If it's the item we're looking at is pulling from the default display, - // reflect that. Don't use is_defaulted since we want it to show up even - // on the default display. + // Set the 'section' to highlight on the form. If it's the item we're + // looking at is pulling from the default display, reflect that. Don't use + // is_defaulted since we want it to show up even on the default display. if (!empty($this->options['defaults'][$form_state['section']])) { $form['#section'] = 'default-' . $form_state['section']; } @@ -1480,6 +1551,7 @@ class views_plugin_display extends views_plugin { '#size' => 64, ); break; + case 'display_title': $form['#title'] .= t('The name and the description of this display'); $form['display_title'] = array( @@ -1495,6 +1567,7 @@ class views_plugin_display extends views_plugin { '#default_value' => $this->get_option('display_description'), ); break; + case 'display_comment': $form['#title'] .= t("This display's comments"); $form['display_comment'] = array( @@ -1503,6 +1576,7 @@ class views_plugin_display extends views_plugin { '#default_value' => $this->get_option('display_comment'), ); break; + case 'title': $form['#title'] .= t('The title of this view'); $form['title'] = array( @@ -1511,6 +1585,7 @@ class views_plugin_display extends views_plugin { '#default_value' => $this->get_option('title'), ); break; + case 'css_class': $form['#title'] .= t('CSS class'); $form['css_class'] = array( @@ -1519,6 +1594,7 @@ class views_plugin_display extends views_plugin { '#default_value' => $this->get_option('css_class'), ); break; + case 'use_ajax': $form['#title'] .= t('Use AJAX when available to load this view'); $form['description'] = array( @@ -1530,6 +1606,7 @@ class views_plugin_display extends views_plugin { '#default_value' => $this->get_option('use_ajax') ? 1 : 0, ); break; + case 'hide_attachment_summary': $form['#title'] .= t('Hide attachments when displaying a contextual filter summary'); $form['hide_attachment_summary'] = array( @@ -1538,6 +1615,7 @@ class views_plugin_display extends views_plugin { '#default_value' => $this->get_option('hide_attachment_summary') ? 1 : 0, ); break; + case 'hide_admin_links': $form['#title'] .= t('Hide contextual links on this view.'); $form['hide_admin_links'] = array( @@ -1545,7 +1623,8 @@ class views_plugin_display extends views_plugin { '#options' => array(1 => t('Yes'), 0 => t('No')), '#default_value' => $this->get_option('hide_admin_links') ? 1 : 0, ); - break; + break; + case 'use_more': $form['#title'] .= t('Add a more link to the bottom of the display.'); $form['use_more'] = array( @@ -1559,11 +1638,10 @@ class views_plugin_display extends views_plugin { '#title' => t("Display 'more' link only if there is more content"), '#description' => t("Leave this unchecked to display the 'more' link even if there are no more items to display."), '#default_value' => !$this->get_option('use_more_always'), - '#dependency' => array( - 'edit-use-more' => array(TRUE), - ), + '#dependency' => array( + 'edit-use-more' => array(TRUE), + ), ); - $form['open_new_window'] = array( '#type' => 'checkbox', '#title' => t("Open 'more' link in new window (target='blank')"), @@ -1573,7 +1651,6 @@ class views_plugin_display extends views_plugin { 'edit-use-more' => array(TRUE), ), ); - $form['use_more_text'] = array( '#type' => 'textfield', '#title' => t('More link text'), @@ -1584,6 +1661,7 @@ class views_plugin_display extends views_plugin { ), ); break; + case 'group_by': $form['#title'] .= t('Allow grouping and aggregation (calculation) of fields.'); $form['group_by'] = array( @@ -1593,6 +1671,7 @@ class views_plugin_display extends views_plugin { '#default_value' => $this->get_option('group_by'), ); break; + case 'access': $form['#title'] .= t('Access restrictions'); $form['access'] = array( @@ -1600,14 +1679,12 @@ class views_plugin_display extends views_plugin { '#suffix' => '
    ', '#tree' => TRUE, ); - $access = $this->get_option('access'); - $form['access']['type'] = array( + $form['access']['type'] = array( '#type' => 'radios', '#options' => views_fetch_plugin_names('access', NULL, array($this->view->base_table)), '#default_value' => $access['type'], ); - $access_plugin = views_fetch_plugin_data('access', $access['type']); if (!empty($access_plugin['uses options'])) { $form['markup'] = array( @@ -1616,8 +1693,8 @@ class views_plugin_display extends views_plugin { '#suffix' => '
    ', ); } - break; + case 'access_options': $access = $this->get_option('access'); $plugin = $this->get_plugin('access'); @@ -1629,7 +1706,6 @@ class views_plugin_display extends views_plugin { if (!empty($plugin->definition['module'])) { $form['#help_module'] = $plugin->definition['module']; } - $form['access_options'] = array( '#tree' => TRUE, ); @@ -1640,6 +1716,7 @@ class views_plugin_display extends views_plugin { $plugin->options_form($form['access_options'], $form_state); } break; + case 'cache': $form['#title'] .= t('Caching'); $form['cache'] = array( @@ -1647,14 +1724,12 @@ class views_plugin_display extends views_plugin { '#suffix' => '
    ', '#tree' => TRUE, ); - $cache = $this->get_option('cache'); - $form['cache']['type'] = array( + $form['cache']['type'] = array( '#type' => 'radios', '#options' => views_fetch_plugin_names('cache', NULL, array($this->view->base_table)), '#default_value' => $cache['type'], ); - $cache_plugin = views_fetch_plugin_data('cache', $cache['type']); if (!empty($cache_plugin['uses options'])) { $form['markup'] = array( @@ -1664,6 +1739,7 @@ class views_plugin_display extends views_plugin { ); } break; + case 'cache_options': $cache = $this->get_option('cache'); $plugin = $this->get_plugin('cache'); @@ -1675,7 +1751,6 @@ class views_plugin_display extends views_plugin { if (!empty($plugin->definition['module'])) { $form['#help_module'] = $plugin->definition['module']; } - $form['cache_options'] = array( '#tree' => TRUE, ); @@ -1686,6 +1761,7 @@ class views_plugin_display extends views_plugin { $plugin->options_form($form['cache_options'], $form_state); } break; + case 'query': $query_options = $this->get_option('query'); $plugin_name = $query_options['type']; @@ -1699,7 +1775,6 @@ class views_plugin_display extends views_plugin { if (!empty($this->view->query->definition['module'])) { $form['#help_module'] = $this->view->query->definition['module']; } - $form['query'] = array( '#tree' => TRUE, 'type' => array( @@ -1710,10 +1785,10 @@ class views_plugin_display extends views_plugin { '#tree' => TRUE, ), ); - $this->view->query->options_form($form['query']['options'], $form_state); } break; + case 'field_language': $form['#title'] .= t('Field Language'); @@ -1756,10 +1831,11 @@ class views_plugin_display extends views_plugin { $form['field_language']['#markup'] = t("You don't have translatable entity types."); } break; + case 'style_plugin': $form['#title'] .= t('How should this view be styled'); $form['#help_topic'] = 'style'; - $form['style_plugin'] = array( + $form['style_plugin'] = array( '#type' => 'radios', '#options' => views_fetch_plugin_names('style', $this->get_style_type(), array($this->view->base_table)), '#default_value' => $this->get_option('style_plugin'), @@ -1772,8 +1848,8 @@ class views_plugin_display extends views_plugin { '#markup' => '
    ' . t('You may also adjust the !settings for the currently selected style.', array('!settings' => $this->option_link(t('settings'), 'style_options'))) . '
    ', ); } - break; + case 'style_options': $form['#title'] .= t('Style options'); $style = TRUE; @@ -1784,7 +1860,7 @@ class views_plugin_display extends views_plugin { if (!isset($name)) { $name = $this->get_option('row_plugin'); } - // if row, $style will be empty. + // If row, $style will be empty. if (empty($style)) { $form['#title'] .= t('Row style options'); $type = 'row_plugin'; @@ -1803,10 +1879,11 @@ class views_plugin_display extends views_plugin { $plugin->options_form($form[$form_state['section']], $form_state); } break; + case 'row_plugin': $form['#title'] .= t('How should each row in this view be styled'); $form['#help_topic'] = 'style-row'; - $form['row_plugin'] = array( + $form['row_plugin'] = array( '#type' => 'radios', '#options' => views_fetch_plugin_names('row', $this->get_style_type(), array($this->view->base_table)), '#default_value' => $this->get_option('row_plugin'), @@ -1818,8 +1895,8 @@ class views_plugin_display extends views_plugin { '#markup' => '
    ' . t('You may also adjust the !settings for the currently selected row style.', array('!settings' => $this->option_link(t('settings'), 'row_options'))) . '
    ', ); } - break; + case 'link_display': $form['#title'] .= t('Which display to use for path'); foreach ($this->view->display as $display_id => $display) { @@ -1838,14 +1915,14 @@ class views_plugin_display extends views_plugin { } $options = array(); - $count = 0; // This lets us prepare the key as we want it printed. + // This lets us prepare the key as we want it printed. + $count = 0; foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { $options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name())); $options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name())); } - // Default text. - // We have some options, so make a list. + // Default text. We have some options, so make a list. $output = ''; if (!empty($options)) { $output = t('

    The following tokens are available for this link.

    '); @@ -1858,7 +1935,7 @@ class views_plugin_display extends views_plugin { $output .= theme('item_list', array( 'items' => $items, - 'type' => $type + 'type' => $type, )); } } @@ -1872,6 +1949,7 @@ class views_plugin_display extends views_plugin { '#dependency' => array('radio:link_display' => array('custom_url')), ); break; + case 'analyze-theme': $form['#title'] .= t('Theming information'); $form['#help_topic'] = 'analyze-theme'; @@ -1902,7 +1980,7 @@ class views_plugin_display extends views_plugin { // The base themes should be initialized in the right order. $base_theme = array_reverse($base_theme); - // This code is copied directly from _drupal_theme_initialize() + // This code is copied directly from _drupal_theme_initialize(). $theme_engine = NULL; // Initialize the theme. @@ -1919,14 +1997,14 @@ class views_plugin_display extends views_plugin { } } else { - // include non-engine theme files + // Include non-engine theme files. foreach ($base_theme as $base) { // Include the theme file or the engine. if (!empty($base->owner)) { include_once DRUPAL_ROOT . '/' . $base->owner; } } - // and our theme gets one too. + // And our theme gets one too. if (!empty($theme->owner)) { include_once DRUPAL_ROOT . '/' . $theme->owner; } @@ -1934,8 +2012,8 @@ class views_plugin_display extends views_plugin { $this->theme_registry = _theme_load_registry($theme, $base_theme, $theme_engine); } - // If there's a theme engine involved, we also need to know its extension - // so we can give the proper filename. + // If there's a theme engine involved, we also need to know its + // extension so we can give the proper filename. $this->theme_extension = '.tpl.php'; if (isset($theme_engine)) { $extension_function = $theme_engine . '_extension'; @@ -1945,15 +2023,15 @@ class views_plugin_display extends views_plugin { } $funcs = array(); - // Get theme functions for the display. Note that some displays may - // not have themes. The 'feed' display, for example, completely - // delegates to the style. + // Get theme functions for the display. Note that some displays may not + // have themes. The 'feed' display, for example, completely delegates to + // the style. if (!empty($this->definition['theme'])) { - $funcs[] = $this->option_link(t('Display output'), 'analyze-theme-display') . ': ' . $this->format_themes($this->theme_functions()); + $funcs[] = $this->option_link(t('Display output'), 'analyze-theme-display') . ': ' . $this->format_themes($this->theme_functions()); $themes = $this->additional_theme_functions(); if ($themes) { foreach ($themes as $theme) { - $funcs[] = $this->option_link(t('Alternative display output'), 'analyze-theme-display') . ': ' . $this->format_themes($theme); + $funcs[] = $this->option_link(t('Alternative display output'), 'analyze-theme-display') . ': ' . $this->format_themes($theme); } } } @@ -1964,7 +2042,7 @@ class views_plugin_display extends views_plugin { $themes = $plugin->additional_theme_functions(); if ($themes) { foreach ($themes as $theme) { - $funcs[] = $this->option_link(t('Alternative style'), 'analyze-theme-style') . ': ' . $this->format_themes($theme); + $funcs[] = $this->option_link(t('Alternative style'), 'analyze-theme-style') . ': ' . $this->format_themes($theme); } } @@ -1975,7 +2053,7 @@ class views_plugin_display extends views_plugin { $themes = $row_plugin->additional_theme_functions(); if ($themes) { foreach ($themes as $theme) { - $funcs[] = $this->option_link(t('Alternative row style'), 'analyze-theme-row') . ': ' . $this->format_themes($theme); + $funcs[] = $this->option_link(t('Alternative row style'), 'analyze-theme-row') . ': ' . $this->format_themes($theme); } } } @@ -2042,6 +2120,7 @@ class views_plugin_display extends views_plugin { $form_state['ok_button'] = TRUE; break; + case 'analyze-theme-display': $form['#title'] .= t('Theming information (display)'); $output = '

    ' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '

    '; @@ -2067,6 +2146,7 @@ class views_plugin_display extends views_plugin { $form_state['ok_button'] = TRUE; break; + case 'analyze-theme-style': $form['#title'] .= t('Theming information (style)'); $output = '

    ' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '

    '; @@ -2094,6 +2174,7 @@ class views_plugin_display extends views_plugin { $form_state['ok_button'] = TRUE; break; + case 'analyze-theme-row': $form['#title'] .= t('Theming information (row style)'); $output = '

    ' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '

    '; @@ -2121,14 +2202,15 @@ class views_plugin_display extends views_plugin { $form_state['ok_button'] = TRUE; break; + case 'analyze-theme-field': $form['#title'] .= t('Theming information (row style)'); $output = '

    ' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '

    '; $output .= '

    ' . t('This is the default theme template used for this row style.') . '

    '; - // Field templates aren't registered the normal way...and they're always - // this one, anyhow. + // Field templates aren't registered the normal way... and they're + // always this one, anyhow. $output .= '
    ' . check_plain(file_get_contents(drupal_get_path('module', 'views') . '/theme/views-view-field.tpl.php')) . '
    '; $form['analysis'] = array( @@ -2148,6 +2230,7 @@ class views_plugin_display extends views_plugin { '#default_value' => $this->get_option('exposed_block') ? 1 : 0, ); break; + case 'exposed_form': $form['#title'] .= t('Exposed Form'); $form['exposed_form'] = array( @@ -2157,7 +2240,7 @@ class views_plugin_display extends views_plugin { ); $exposed_form = $this->get_option('exposed_form'); - $form['exposed_form']['type'] = array( + $form['exposed_form']['type'] = array( '#type' => 'radios', '#options' => views_fetch_plugin_names('exposed_form', NULL, array($this->view->base_table)), '#default_value' => $exposed_form['type'], @@ -2172,6 +2255,7 @@ class views_plugin_display extends views_plugin { ); } break; + case 'exposed_form_options': $plugin = $this->get_plugin('exposed_form'); $form['#title'] .= t('Exposed form options'); @@ -2189,6 +2273,7 @@ class views_plugin_display extends views_plugin { $plugin->options_form($form['exposed_form_options'], $form_state); } break; + case 'pager': $form['#title'] .= t('Select which pager, if any, to use for this view'); $form['pager'] = array( @@ -2198,7 +2283,7 @@ class views_plugin_display extends views_plugin { ); $pager = $this->get_option('pager'); - $form['pager']['type'] = array( + $form['pager']['type'] = array( '#type' => 'radios', '#options' => views_fetch_plugin_names('pager', empty($this->definition['use pager']) ? 'basic' : NULL, array($this->view->base_table)), '#default_value' => $pager['type'], @@ -2212,8 +2297,8 @@ class views_plugin_display extends views_plugin { '#markup' => t('You may also adjust the !settings for the currently selected pager.', array('!settings' => $this->option_link(t('settings'), 'pager_options'))), ); } - break; + case 'pager_options': $plugin = $this->get_plugin('pager'); $form['#title'] .= t('Pager options'); @@ -2241,7 +2326,7 @@ class views_plugin_display extends views_plugin { /** * Format a list of theme templates for output by the theme info helper. */ - function format_themes($themes) { + public function format_themes($themes) { $registry = $this->theme_registry; $extension = $this->theme_extension; @@ -2253,7 +2338,7 @@ class views_plugin_display extends views_plugin { $template_path = isset($registry[$theme]['path']) ? $registry[$theme]['path'] . '/' : './'; if (file_exists($template_path . $template)) { $hint = t('File found in folder @template-path', array('@template-path' => $template_path)); - $template = '' . $template . ''; + $template = '' . $template . ''; } else { $template = '' . $template . ' ' . t('(File not found, in folder @template-path)', array('@template-path' => $template_path)) . ''; @@ -2263,25 +2348,27 @@ class views_plugin_display extends views_plugin { $fixed[] = $template; } - return implode(', ', array_reverse($fixed)); + return theme('item_list', array('items' => array_reverse($fixed))); } /** * Validate the options form. */ - function options_validate(&$form, &$form_state) { + public function options_validate(&$form, &$form_state) { switch ($form_state['section']) { case 'display_title': if (empty($form_state['values']['display_title'])) { form_error($form['display_title'], t('Display title may not be empty.')); } break; + case 'css_class': $css_class = $form_state['values']['css_class']; if (preg_match('/[^a-zA-Z0-9-_ ]/', $css_class)) { form_error($form['css_class'], t('CSS classes must be alphanumeric or dashes only.')); } - break; + break; + case 'display_id': if ($form_state['values']['display_id']) { if (preg_match('/[^a-z0-9_]/', $form_state['values']['display_id'])) { @@ -2295,38 +2382,44 @@ class views_plugin_display extends views_plugin { } } break; + case 'style_options': $style = TRUE; case 'row_options': - // if row, $style will be empty. + // If row, $style will be empty. $plugin = $this->get_plugin(empty($style) ? 'row' : 'style'); if ($plugin) { $plugin->options_validate($form[$form_state['section']], $form_state); } break; + case 'access_options': $plugin = $this->get_plugin('access'); if ($plugin) { $plugin->options_validate($form['access_options'], $form_state); } break; + case 'query': if ($this->view->query) { $this->view->query->options_validate($form['query'], $form_state); } break; + case 'cache_options': $plugin = $this->get_plugin('cache'); if ($plugin) { $plugin->options_validate($form['cache_options'], $form_state); } break; + case 'exposed_form_options': $plugin = $this->get_plugin('exposed_form'); if ($plugin) { $plugin->options_validate($form['exposed_form_options'], $form_state); } break; + case 'pager_options': $plugin = $this->get_plugin('pager'); if ($plugin) { @@ -2342,9 +2435,10 @@ class views_plugin_display extends views_plugin { /** * Perform any necessary changes to the form values prior to storage. + * * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { + public function options_submit(&$form, &$form_state) { // Not sure I like this being here, but it seems (?) like a logical place. $cache_plugin = $this->get_plugin('cache'); if ($cache_plugin) { @@ -2358,10 +2452,12 @@ class views_plugin_display extends views_plugin { $this->display->new_id = $form_state['values']['display_id']; } break; + case 'display_title': $this->display->display_title = $form_state['values']['display_title']; $this->set_option('display_description', $form_state['values']['display_description']); break; + case 'access': $access = $this->get_option('access'); if ($access['type'] != $form_state['values']['access']['type']) { @@ -2374,8 +2470,8 @@ class views_plugin_display extends views_plugin { } } } - break; + case 'access_options': $plugin = views_get_plugin('access', $form_state['values'][$section]['type']); if ($plugin) { @@ -2383,6 +2479,7 @@ class views_plugin_display extends views_plugin { $this->set_option('access', $form_state['values'][$section]); } break; + case 'cache': $cache = $this->get_option('cache'); if ($cache['type'] != $form_state['values']['cache']['type']) { @@ -2395,8 +2492,8 @@ class views_plugin_display extends views_plugin { } } } - break; + case 'cache_options': $plugin = views_get_plugin('cache', $form_state['values'][$section]['type']); if ($plugin) { @@ -2404,6 +2501,7 @@ class views_plugin_display extends views_plugin { $this->set_option('cache', $form_state['values'][$section]); } break; + case 'query': $plugin = $this->get_plugin('query'); if ($plugin) { @@ -2419,15 +2517,18 @@ class views_plugin_display extends views_plugin { case 'display_comment': $this->set_option($section, $form_state['values'][$section]); break; + case 'field_language': $this->set_option('field_language', $form_state['values']['field_language']); $this->set_option('field_language_add_to_query', $form_state['values']['field_language_add_to_query']); break; + case 'use_ajax': case 'hide_attachment_summary': case 'hide_admin_links': - $this->set_option($section, (bool)$form_state['values'][$section]); + $this->set_option($section, (bool) $form_state['values'][$section]); break; + case 'use_more': $this->set_option($section, intval($form_state['values'][$section])); $this->set_option('use_more_always', !intval($form_state['values']['use_more_always'])); @@ -2436,9 +2537,11 @@ class views_plugin_display extends views_plugin { case 'distinct': $this->set_option($section, $form_state['values'][$section]); break; + case 'group_by': $this->set_option($section, $form_state['values'][$section]); break; + case 'row_plugin': // This if prevents resetting options to default if they don't change // the plugin. @@ -2448,13 +2551,14 @@ class views_plugin_display extends views_plugin { $this->set_option($section, $form_state['values'][$section]); $this->set_option('row_options', array()); - // send ajax form to options page if we use it. + // Send ajax form to options page if we use it. if (!empty($plugin->definition['uses options'])) { views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('row_options')); } } } break; + case 'style_plugin': // This if prevents resetting options to default if they don't change // the plugin. @@ -2463,26 +2567,29 @@ class views_plugin_display extends views_plugin { if ($plugin) { $this->set_option($section, $form_state['values'][$section]); $this->set_option('style_options', array()); - // send ajax form to options page if we use it. + // Send ajax form to options page if we use it. if (!empty($plugin->definition['uses options'])) { views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('style_options')); } } } break; + case 'style_options': $style = TRUE; case 'row_options': - // if row, $style will be empty. + // If row, $style will be empty. $plugin = $this->get_plugin(empty($style) ? 'row' : 'style'); if ($plugin) { $plugin->options_submit($form['options'][$section], $form_state); } $this->set_option($section, $form_state['values'][$section]); break; + case 'exposed_block': $this->set_option($section, (bool) $form_state['values'][$section]); break; + case 'exposed_form': $exposed_form = $this->get_option('exposed_form'); if ($exposed_form['type'] != $form_state['values']['exposed_form']['type']) { @@ -2495,8 +2602,8 @@ class views_plugin_display extends views_plugin { } } } - break; + case 'exposed_form_options': $plugin = $this->get_plugin('exposed_form'); if ($plugin) { @@ -2506,6 +2613,7 @@ class views_plugin_display extends views_plugin { $this->set_option('exposed_form', $exposed_form); } break; + case 'pager': $pager = $this->get_option('pager'); if ($pager['type'] != $form_state['values']['pager']['type']) { @@ -2522,8 +2630,8 @@ class views_plugin_display extends views_plugin { } } } - break; + case 'pager_options': $plugin = $this->get_plugin('pager'); if ($plugin) { @@ -2543,7 +2651,7 @@ class views_plugin_display extends views_plugin { /** * If override/revert was clicked, perform the proper toggle. */ - function options_override($form, &$form_state) { + public function options_override($form, &$form_state) { $this->set_override($form_state['section']); } @@ -2554,10 +2662,10 @@ class views_plugin_display extends views_plugin { * Which option should be marked as overridden, for example "filters". * @param bool $new_state * Select the new state of the option. - * - TRUE: Revert to default. - * - FALSE: Mark it as overridden. + * - TRUE: Revert to default. + * - FALSE: Mark it as overridden. */ - function set_override($section, $new_state = NULL) { + public function set_override($section, $new_state = NULL) { $options = $this->defaultable_sections($section); if (!$options) { return; @@ -2575,7 +2683,7 @@ class views_plugin_display extends views_plugin { unset($this->display->display_options[$option]); } else { - // copy existing values into our display. + // Copy existing values into our display. $this->options[$option] = $this->get_option($option); $this->display->display_options[$option] = $this->options[$option]; } @@ -2587,28 +2695,29 @@ class views_plugin_display extends views_plugin { /** * Inject anything into the query that the display handler needs. */ - function query() { + public function query() { foreach ($this->extender as $extender) { $extender->query(); } } /** - * Not all display plugins will support filtering + * Not all display plugins will support filtering. */ - function render_filters() { } + public function render_filters() { + } /** * Not all display plugins will suppert pager rendering. */ - function render_pager() { + public function render_pager() { return TRUE; } /** - * Render the 'more' link + * Render the 'more' link. */ - function render_more_link() { + public function render_more_link() { if ($this->use_more() && ($this->use_more_always() || (!empty($this->view->query->pager) && $this->view->query->pager->has_more_records()))) { $path = $this->get_path(); @@ -2645,12 +2754,16 @@ class views_plugin_display extends views_plugin { $path = check_url(url($path, $url_options)); - return theme($theme, array('more_url' => $path, 'new_window' => $this->use_more_open_new_window(), 'link_text' => check_plain($this->use_more_text()), 'view' => $this->view)); + return theme($theme, array( + 'more_url' => $path, + 'new_window' => $this->use_more_open_new_window(), + 'link_text' => check_plain($this->use_more_text()), + 'view' => $this->view, + )); } } } - /** * Legacy functions. */ @@ -2658,7 +2771,7 @@ class views_plugin_display extends views_plugin { /** * Render the header of the view. */ - function render_header() { + public function render_header() { $empty = !empty($this->view->result); return $this->render_area('header', $empty); } @@ -2666,33 +2779,43 @@ class views_plugin_display extends views_plugin { /** * Render the footer of the view. */ - function render_footer() { + public function render_footer() { $empty = !empty($this->view->result); return $this->render_area('footer', $empty); } - function render_empty() { + /** + * + */ + public function render_empty() { return $this->render_area('empty'); } /** * If this display creates a block, implement one of these. */ - function hook_block_list($delta = 0, $edit = array()) { return array(); } + public function hook_block_list($delta = 0, $edit = array()) { + return array(); + } /** * If this display creates a page with a menu item, implement it here. */ - function hook_menu() { return array(); } + public function hook_menu() { + return array(); + } /** * Render this display. */ - function render() { + public function render() { return theme($this->theme_functions(), array('view' => $this->view)); } - function render_area($area, $empty = FALSE) { + /** + * + */ + public function render_area($area, $empty = FALSE) { $return = ''; foreach ($this->get_handlers($area) as $area) { $return .= $area->render($empty); @@ -2700,11 +2823,10 @@ class views_plugin_display extends views_plugin { return $return; } - /** * Determine if the user has access to this display of the view. */ - function access($account = NULL) { + public function access($account = NULL) { if (!isset($account)) { global $user; $account = $user; @@ -2720,16 +2842,17 @@ class views_plugin_display extends views_plugin { return $plugin->access($account); } - // fallback to all access if no plugin. + // Fallback to all access if no plugin. return TRUE; } /** - * Set up any variables on the view prior to execution. These are separated - * from execute because they are extremely common and unlikely to be - * overridden on an individual display. + * Set up any variables on the view prior to execution. + * + * These are separated from execute because they are extremely common and + * unlikely to be overridden on an individual display. */ - function pre_execute() { + public function pre_execute() { $this->view->set_use_ajax($this->use_ajax()); if ($this->use_more() && !$this->use_more_always()) { $this->view->get_total_rows = TRUE; @@ -2755,27 +2878,35 @@ class views_plugin_display extends views_plugin { * * The base class cannot be executed. */ - function execute() { } + public function execute() { + } /** - * Fully render the display for the purposes of a live preview or - * some other AJAXy reason. + * Fully render the display. + * + * Used for the purposes of a live preview or some other AJAXy reason. */ - function preview() { return $this->view->render(); } + public function preview() { + return $this->view->render(); + } /** - * Displays can require a certain type of style plugin. By default, they will - * be 'normal'. + * Displays can require a certain type of style plugin. + * + * By default, they will be 'normal'. */ - function get_style_type() { return 'normal'; } + public function get_style_type() { + return 'normal'; + } /** * Make sure the display and all associated handlers are valid. * * @return - * Empty array if the display is valid; an array of error strings if it is not. + * Empty array if the display is valid; an array of error strings if it is + * not. */ - function validate() { + public function validate() { $errors = array(); // Make sure displays that use fields HAVE fields. if ($this->uses_fields()) { @@ -2795,7 +2926,7 @@ class views_plugin_display extends views_plugin { $errors[] = t('Display "@display" uses a path but the path is undefined.', array('@display' => $this->display->display_title)); } - // Validate style plugin + // Validate style plugin. $style = $this->get_plugin(); if (empty($style)) { $errors[] = t('Display "@display" has an invalid style plugin.', array('@display' => $this->display->display_title)); @@ -2814,7 +2945,7 @@ class views_plugin_display extends views_plugin { $errors = array_merge($errors, $result); } - // Validate handlers + // Validate handlers. foreach (views_object_types() as $type => $info) { foreach ($this->get_handlers($type) as $handler) { $result = $handler->validate(); @@ -2837,9 +2968,8 @@ class views_plugin_display extends views_plugin { * * @return bool * Returns whether the identifier is unique on all handlers. - * */ - function is_identifier_unique($id, $identifier) { + public function is_identifier_unique($id, $identifier) { foreach (views_object_types() as $type => $info) { foreach ($this->get_handlers($type) as $key => $handler) { if ($handler->can_expose() && $handler->is_exposed()) { @@ -2862,7 +2992,7 @@ class views_plugin_display extends views_plugin { /** * Provide the block system with any exposed widget blocks for this display. */ - function get_special_blocks() { + public function get_special_blocks() { $blocks = array(); if ($this->uses_exposed_form_in_block()) { @@ -2881,9 +3011,9 @@ class views_plugin_display extends views_plugin { /** * Render any special blocks provided for this display. */ - function view_special_blocks($type) { + public function view_special_blocks($type) { if ($type == '-exp') { - // avoid interfering with the admin forms. + // Avoid interfering with the admin forms. if (arg(0) == 'admin' && arg(1) == 'structure' && arg(2) == 'views') { return; } @@ -2901,11 +3031,13 @@ class views_plugin_display extends views_plugin { /** * Override of export_option() * - * Because displays do not want to export options that are NOT overridden from the - * default display, we need some special handling during the export process. + * Because displays do not want to export options that are NOT overridden from + * the default display, we need some special handling during the export + * process. */ - function export_option($indent, $prefix, $storage, $option, $definition, $parents) { - // The $prefix is wrong because we store our actual options a little differently: + public function export_option($indent, $prefix, $storage, $option, $definition, $parents) { + // The $prefix is wrong because we store our actual options a little + // differently. $prefix = '$handler->display->display_options'; $output = ''; if (!$parents && !$this->is_default_display()) { @@ -2914,8 +3046,8 @@ class views_plugin_display extends views_plugin { return; } - // If this is not defaulted and is overrideable, flip the switch to say this - // is overridden. + // If this is not defaulted and is overrideable, flip the switch to say + // this is overridden. if ($this->defaultable_sections($option)) { $output .= $indent . $prefix . "['defaults']['$option'] = FALSE;\n"; } @@ -2928,16 +3060,16 @@ class views_plugin_display extends views_plugin { /** * Special method to export items that have handlers. * - * This method was specified in the option_definition() as the method to utilize to - * export fields, filters, sort criteria, relationships and arguments. This passes - * the export off to the individual handlers so that they can export themselves - * properly. + * This method was specified in the option_definition() as the method to + * utilize to export fields, filters, sort criteria, relationships and + * arguments. This passes the export off to the individual handlers so that + * they can export themselves properly. */ - function export_handler($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_handler($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; - // cut the 's' off because the data is stored as the plural form but we need - // the singular form. Who designed that anyway? Oh yeah, I did. :( + // Cut the 's' off because the data is stored as the plural form but we need + // the singular form. if ($option != 'header' && $option != 'footer' && $option != 'empty') { $type = substr($option, 0, -1); } @@ -2952,9 +3084,9 @@ class views_plugin_display extends views_plugin { else { $handler_type = $type; } - // If aggregation is on, the group type might override the actual - // handler that is in use. This piece of code checks that and, - // if necessary, sets the override handler. + // If aggregation is on, the group type might override the actual handler + // that is in use. This piece of code checks that and, if necessary, sets + // the override handler. $override = NULL; if ($this->use_group_by() && !empty($info['group_type'])) { if (empty($this->view->query)) { @@ -2983,10 +3115,10 @@ class views_plugin_display extends views_plugin { * Special handling for the style export. * * Styles are stored as style_plugin and style_options or row_plugin and - * row_options accordingly. The options are told not to export, and the - * export for the plugin should export both. + * row_options accordingly. The options are told not to export, and the export + * for the plugin should export both. */ - function export_style($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_style($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; $style_plugin = $this->get_plugin(); if ($option == 'style_plugin') { @@ -3018,14 +3150,14 @@ class views_plugin_display extends views_plugin { } /** - * Special handling for plugin export + * Special handling for plugin export. * * Plugins other than styles are stored in array with 'type' being the key * to the plugin. For modern plugins, the options are stored in the 'options' * array, but for legacy plugins (access and cache) options are stored as * siblings to the type. */ - function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; $plugin_type = end($parents); $plugin = $this->get_plugin($plugin_type); @@ -3036,7 +3168,7 @@ class views_plugin_display extends views_plugin { $output .= $indent . $new_prefix . "['$option'] = '$value';\n"; - if ($plugin_type != 'access' && $plugin_type!= 'cache') { + if ($plugin_type != 'access' && $plugin_type != 'cache') { $new_prefix .= "['options']"; } @@ -3047,7 +3179,10 @@ class views_plugin_display extends views_plugin { return $output; } - function unpack_style($indent, $prefix, $storage, $option, $definition, $parents) { + /** + * + */ + public function unpack_style($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; $style_plugin = $this->get_plugin(); if ($option == 'style_plugin') { @@ -3074,7 +3209,7 @@ class views_plugin_display extends views_plugin { /** * Special handling for plugin unpacking. */ - function unpack_plugin(&$translatable, $storage, $option, $definition, $parents) { + public function unpack_plugin(&$translatable, $storage, $option, $definition, $parents) { $plugin_type = end($parents); $plugin = $this->get_plugin($plugin_type); if ($plugin) { @@ -3083,19 +3218,19 @@ class views_plugin_display extends views_plugin { } } - /** + /** * Special method to unpack items that have handlers. * - * This method was specified in the option_definition() as the method to utilize to - * export fields, filters, sort criteria, relationships and arguments. This passes - * the export off to the individual handlers so that they can export themselves - * properly. + * This method was specified in the option_definition() as the method to + * utilize to export fields, filters, sort criteria, relationships and + * arguments. This passes the export off to the individual handlers so that + * they can export themselves properly. */ - function unpack_handler(&$translatable, $storage, $option, $definition, $parents) { + public function unpack_handler(&$translatable, $storage, $option, $definition, $parents) { $output = ''; - // cut the 's' off because the data is stored as the plural form but we need - // the singular form. Who designed that anyway? Oh yeah, I did. :( + // Cut the 's' off because the data is stored as the plural form but we need + // the singular form. if ($option != 'header' && $option != 'footer' && $option != 'empty') { $type = substr($option, 0, -1); } @@ -3113,7 +3248,8 @@ class views_plugin_display extends views_plugin { $handler = views_get_handler($info['table'], $info['field'], $handler_type); if ($handler) { $handler->init($this->view, $info); - $handler->unpack_translatables($translatable, array_merge($parents, array($type, $info['table'], $info['id']))); + $items = array_merge($parents, array($type, $info['table'], $info['id'])); + $handler->unpack_translatables($translatable, $items); } // Prevent reference problems. @@ -3125,16 +3261,16 @@ class views_plugin_display extends views_plugin { /** * Provide some helpful text for the arguments. - * The result should contain of an array with - * - filter value present: The title of the fieldset in the argument - * where you can configure what should be done with a given argument. - * - filter value not present: The tiel of the fieldset in the argument - * where you can configure what should be done if the argument does not - * exist. - * - description: A description about how arguments comes to the display. - * For example blocks don't get it from url. + * + * The result should contain of an array with: + * - filter value present: The title of the fieldset in the argument where + * you can configure what should be done with a given argument. + * - filter value not present: The tiel of the fieldset in the argument where + * you can configure what should be done if the argument does not exist. + * - description: A description about how arguments comes to the display. For + * example blocks don't get it from url. */ - function get_argument_text() { + public function get_argument_text() { return array( 'filter value not present' => t('When the filter value is NOT available'), 'filter value present' => t('When the filter value IS available or a default is provided'), @@ -3145,17 +3281,18 @@ class views_plugin_display extends views_plugin { /** * Provide some helpful text for pagers. * - * The result should contain of an array within - * - items per page title + * The result should contain of an array with: + * - items per page title. + * - items per page description. */ - function get_pager_text() { + public function get_pager_text() { return array( 'items per page title' => t('Items to display'), - 'items per page description' => t('The number of items to display. Enter 0 for no limit.') + 'items per page description' => t('The number of items to display. Enter 0 for no limit.'), ); } -} +} /** * @} diff --git a/sites/all/modules/views/plugins/views_plugin_display_attachment.inc b/sites/all/modules/views/plugins/views_plugin_display_attachment.inc index 8608cfc..57bd090 100644 --- a/sites/all/modules/views/plugins/views_plugin_display_attachment.inc +++ b/sites/all/modules/views/plugins/views_plugin_display_attachment.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the attachment display plugin. + * Definition of views_plugin_display_attachment. */ /** @@ -15,9 +15,15 @@ * @ingroup views_display_plugins */ class views_plugin_display_attachment extends views_plugin_display { - function option_definition () { + + /** + * {@inheritdoc} + */ + public function option_definition () { $options = parent::option_definition(); + $options['show_title'] = array('default' => FALSE, 'bool' => TRUE); + $options['show_title_empty'] = array('default' => FALSE, 'bool' => TRUE); $options['displays'] = array('default' => array()); $options['attachment_position'] = array('default' => 'before'); $options['inherit_arguments'] = array('default' => TRUE, 'bool' => TRUE); @@ -28,11 +34,17 @@ class views_plugin_display_attachment extends views_plugin_display { return $options; } - function execute() { + /** + * {@inheritdoc} + */ + public function execute() { return $this->view->render($this->display->id); } - function attachment_positions($position = NULL) { + /** + * {@inheritdoc} + */ + public function attachment_positions($position = NULL) { $positions = array( 'before' => t('Before'), 'after' => t('After'), @@ -51,8 +63,8 @@ class views_plugin_display_attachment extends views_plugin_display { * * This output is returned as an array. */ - function options_summary(&$categories, &$options) { - // It is very important to call the parent function here: + public function options_summary(&$categories, &$options) { + // It is very important to call the parent function here. parent::options_summary($categories, $options); $categories['attachment'] = array( @@ -78,6 +90,18 @@ class views_plugin_display_attachment extends views_plugin_display { $attach_to = t('Not defined'); } + $options['show_title'] = array( + 'category' => 'title', + 'title' => t('Show title'), + 'value' => $this->get_option('show_title') ? t('Yes') : t('No'), + ); + + $options['show_title_empty'] = array( + 'category' => 'title', + 'title' => t('Show title even if view has no results'), + 'value' => $this->get_option('show_title_empty') ? t('Yes') : t('No'), + ); + $options['displays'] = array( 'category' => 'attachment', 'title' => t('Attach to'), @@ -119,11 +143,29 @@ class views_plugin_display_attachment extends views_plugin_display { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_form(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_form($form, $form_state); switch ($form_state['section']) { + case 'show_title': + $form['#title'] .= t('Title'); + $form['show_title'] = array( + '#type' => 'checkbox', + '#title' => t('Show title'), + '#description' => t('Do you want to show the title of the attachment?'), + '#default_value' => $this->get_option('show_title'), + ); + break; + case 'show_title_empty': + $form['#title'] .= t('Title'); + $form['show_title_empty'] = array( + '#type' => 'checkbox', + '#title' => t('Show title for empty view'), + '#description' => t('Do you want to show the title of the attachment even if the view has no results?'), + '#default_value' => $this->get_option('show_title_empty'), + ); + break; case 'inherit_arguments': $form['#title'] .= t('Inherit contextual filters'); $form['inherit_arguments'] = array( @@ -133,6 +175,7 @@ class views_plugin_display_attachment extends views_plugin_display { '#default_value' => $this->get_option('inherit_arguments'), ); break; + case 'inherit_exposed_filters': $form['#title'] .= t('Inherit exposed filters'); $form['inherit_exposed_filters'] = array( @@ -142,6 +185,7 @@ class views_plugin_display_attachment extends views_plugin_display { '#default_value' => $this->get_option('inherit_exposed_filters'), ); break; + case 'inherit_pager': $form['#title'] .= t('Inherit pager'); $form['inherit_pager'] = array( @@ -151,6 +195,7 @@ class views_plugin_display_attachment extends views_plugin_display { '#default_value' => $this->get_option('inherit_pager'), ); break; + case 'render_pager': $form['#title'] .= t('Render pager'); $form['render_pager'] = array( @@ -160,6 +205,7 @@ class views_plugin_display_attachment extends views_plugin_display { '#default_value' => $this->get_option('render_pager'), ); break; + case 'attachment_position': $form['#title'] .= t('Position'); $form['attachment_position'] = array( @@ -169,6 +215,7 @@ class views_plugin_display_attachment extends views_plugin_display { '#default_value' => $this->get_option('attachment_position'), ); break; + case 'displays': $form['#title'] .= t('Attach to'); $displays = array(); @@ -191,10 +238,12 @@ class views_plugin_display_attachment extends views_plugin_display { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_submit(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_submit($form, $form_state); switch ($form_state['section']) { + case 'show_title': + case 'show_title_empty': case 'inherit_arguments': case 'inherit_pager': case 'render_pager': @@ -209,7 +258,7 @@ class views_plugin_display_attachment extends views_plugin_display { /** * Attach to another view. */ - function attach_to($display_id) { + public function attach_to($display_id) { $displays = $this->get_option('displays'); if (empty($displays[$display_id])) { @@ -220,14 +269,14 @@ class views_plugin_display_attachment extends views_plugin_display { return; } - // Get a fresh view because our current one has a lot of stuff on it because it's - // already been executed. + // Get a fresh view because our current one has a lot of stuff on it + // because it's already been executed. $view = $this->view->clone_view(); $view->original_args = $view->args; $args = $this->get_option('inherit_arguments') ? $this->view->args : array(); $view->set_arguments($args); - $exposed_input = $this->get_option('inherit_exposed_filters') ? $this->view->exposed_input : array(); + $exposed_input = $this->get_option('inherit_exposed_filters') && isset($this->view->exposed_input) ? $this->view->exposed_input : array(); $view->set_exposed_input($exposed_input); $view->set_display($this->display->id); if ($this->get_option('inherit_pager')) { @@ -235,15 +284,30 @@ class views_plugin_display_attachment extends views_plugin_display { $view->display_handler->set_option('pager', $this->view->display[$display_id]->handler->get_option('pager')); } - $attachment = $view->execute_display($this->display->id, $args); + $attachment_output = $view->execute_display($this->display->id, $args); + + $attachment = ''; + if ($view->display_handler->get_option('show_title') && $view->display_handler->get_option('title')) { + if ($view->display_handler->get_option('show_title_empty') || !empty($view->result)) { + $attachment .= theme('html_tag', array( + 'element' => array( + '#tag' => 'h2', + '#value' => $view->display_handler->get_option('title'), + ), + )); + } + } + $attachment .= $attachment_output; switch ($this->get_option('attachment_position')) { case 'before': $this->view->attachment_before .= $attachment; break; + case 'after': $this->view->attachment_after .= $attachment; break; + case 'both': $this->view->attachment_before .= $attachment; $this->view->attachment_after .= $attachment; @@ -254,11 +318,10 @@ class views_plugin_display_attachment extends views_plugin_display { } /** - * Attachment displays only use exposed widgets if - * they are set to inherit the exposed filter settings - * of their parent display. + * Attachment displays only use exposed widgets if they are set to inherit + * the exposed filter settings of their parent display. */ - function uses_exposed() { + public function uses_exposed() { if (!empty($this->options['inherit_exposed_filters']) && parent::uses_exposed()) { return TRUE; } @@ -266,19 +329,26 @@ class views_plugin_display_attachment extends views_plugin_display { } /** - * If an attachment is set to inherit the exposed filter - * settings from its parent display, then don't render and - * display a second set of exposed filter widgets. + * If an attachment is set to inherit the exposed filter settings from its + * parent display, then don't render and display a second set of exposed + * filter widgets. */ - function displays_exposed() { + public function displays_exposed() { return $this->options['inherit_exposed_filters'] ? FALSE : TRUE; } - function use_pager() { + /** + * {@inheritdoc} + */ + public function use_pager() { return !empty($this->use_pager); } - function render_pager() { + /** + * {@inheritdoc} + */ + public function render_pager() { return !empty($this->use_pager) && $this->get_option('render_pager'); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_display_block.inc b/sites/all/modules/views/plugins/views_plugin_display_block.inc index 88d22d0..9fc0111 100644 --- a/sites/all/modules/views/plugins/views_plugin_display_block.inc +++ b/sites/all/modules/views/plugins/views_plugin_display_block.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the block display plugin. + * Definition of views_plugin_display_block. */ /** @@ -11,7 +11,11 @@ * @ingroup views_display_plugins */ class views_plugin_display_block extends views_plugin_display { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['block_description'] = array('default' => '', 'translatable' => TRUE); @@ -25,7 +29,7 @@ class views_plugin_display_block extends views_plugin_display { * but extended block handlers might be able to do interesting * stuff with it. */ - function execute_hook_block_list($delta = 0, $edit = array()) { + public function execute_hook_block_list($delta = 0, $edit = array()) { $delta = $this->view->name . '-' . $this->display->id; $desc = $this->get_option('block_description'); @@ -40,7 +44,7 @@ class views_plugin_display_block extends views_plugin_display { return array( $delta => array( 'info' => $desc, - 'cache' => $this->get_cache_type() + 'cache' => $this->get_cache_type(), ), ); } @@ -48,7 +52,7 @@ class views_plugin_display_block extends views_plugin_display { /** * The display block handler returns the structure necessary for a block. */ - function execute() { + public function execute() { // Prior to this being called, the $view should already be set to this // display, and arguments should be set on the view. $info['content'] = $this->view->render(); @@ -64,8 +68,8 @@ class views_plugin_display_block extends views_plugin_display { * * This output is returned as an array. */ - function options_summary(&$categories, &$options) { - // It is very important to call the parent function here: + public function options_summary(&$categories, &$options) { + // It is very important to call the parent function here. parent::options_summary($categories, $options); $categories['block'] = array( @@ -98,7 +102,7 @@ class views_plugin_display_block extends views_plugin_display { /** * Provide a list of core's block caching modes. */ - function block_caching_modes() { + public function block_caching_modes() { return array( DRUPAL_NO_CACHE => t('Do not cache'), DRUPAL_CACHE_GLOBAL => t('Cache once for everything (global)'), @@ -114,7 +118,7 @@ class views_plugin_display_block extends views_plugin_display { * Provide a single method to figure caching type, keeping a sensible default * for when it's unset. */ - function get_cache_type() { + public function get_cache_type() { $cache_type = $this->get_option('block_caching'); if (empty($cache_type)) { $cache_type = DRUPAL_NO_CACHE; @@ -125,8 +129,8 @@ class views_plugin_display_block extends views_plugin_display { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_form(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_form($form, $form_state); switch ($form_state['section']) { @@ -138,6 +142,7 @@ class views_plugin_display_block extends views_plugin_display { '#default_value' => $this->get_option('block_description'), ); break; + case 'block_caching': $form['#title'] .= t('Block caching type'); @@ -148,6 +153,7 @@ class views_plugin_display_block extends views_plugin_display { '#default_value' => $this->get_cache_type(), ); break; + case 'exposed_form_options': $this->view->init_handlers(); if (!$this->uses_exposed() && parent::uses_exposed()) { @@ -156,6 +162,7 @@ class views_plugin_display_block extends views_plugin_display { '#markup' => '
    ' . t('Exposed filters in block displays require "Use AJAX" to be set to work correctly.') . '
    ', ); } + break; } } @@ -163,19 +170,21 @@ class views_plugin_display_block extends views_plugin_display { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_submit(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_submit($form, $form_state); switch ($form_state['section']) { case 'display_id': $this->update_block_bid($form_state['view']->name, $this->display->id, $this->display->new_id); break; + case 'block_description': $this->set_option('block_description', $form_state['values']['block_description']); break; + case 'block_caching': $this->set_option('block_caching', $form_state['values']['block_caching']); - $this->save_block_cache($form_state['view']->name . '-'. $form_state['display_id'], $form_state['values']['block_caching']); + $this->save_block_cache($form_state['view']->name . '-' . $form_state['display_id'], $form_state['values']['block_caching']); break; } } @@ -183,17 +192,17 @@ class views_plugin_display_block extends views_plugin_display { /** * Block views use exposed widgets only if AJAX is set. */ - function uses_exposed() { - if ($this->use_ajax()) { - return parent::uses_exposed(); - } - return FALSE; + public function uses_exposed() { + if ($this->use_ajax()) { + return parent::uses_exposed(); } + return FALSE; + } /** - * Update the block delta when you change the machine readable name of the display. + * Update the block delta when the machine name of the display changes. */ - function update_block_bid($name, $old_delta, $delta) { + public function update_block_bid($name, $old_delta, $delta) { $old_hashes = $hashes = variable_get('views_block_hashes', array()); $old_delta = $name . '-' . $old_delta; @@ -224,21 +233,22 @@ class views_plugin_display_block extends views_plugin_display { /** * Save the block cache setting in the blocks table if this block already - * exists in the blocks table. Dirty fix until http://drupal.org/node/235673 gets in. + * exists in the blocks table. Dirty fix until http://drupal.org/node/235673 + * gets in. */ - function save_block_cache($delta, $cache_setting) { + public function save_block_cache($delta, $cache_setting) { if (strlen($delta) >= 32) { $delta = md5($delta); } - if (db_table_exists('block') && $bid = db_query("SELECT bid FROM {block} WHERE module = 'views' AND delta = :delta", array( - ':delta' => $delta))->fetchField()) { + if (db_table_exists('block') && $bid = db_query("SELECT bid FROM {block} WHERE module = 'views' AND delta = :delta", array(':delta' => $delta))->fetchField()) { db_update('block') ->fields(array( - 'cache' => $cache_setting, + 'cache' => $cache_setting, )) - ->condition('module','views') + ->condition('module', 'views') ->condition('delta', $delta) ->execute(); } } + } diff --git a/sites/all/modules/views/plugins/views_plugin_display_default.inc b/sites/all/modules/views/plugins/views_plugin_display_default.inc index 4b1fc08..9531013 100644 --- a/sites/all/modules/views/plugins/views_plugin_display_default.inc +++ b/sites/all/modules/views/plugins/views_plugin_display_default.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the default display plugin. + * Definition of views_plugin_display_default. */ /** @@ -11,11 +11,14 @@ * @ingroup views_display_plugins */ class views_plugin_display_default extends views_plugin_display { + /** * Determine if this display is the 'default' display which contains - * fallback settings + * fallback settings. */ - function is_default_display() { return TRUE; } + public function is_default_display() { + return TRUE; + } /** * The default execute handler fully renders the view. @@ -26,32 +29,34 @@ class views_plugin_display_default extends views_plugin_display { * @endcode * * For more complex usages, a view can be partially built: + * * @code * $view->set_arguments($args); - * $view->build('default'); // Build the query + * $view->build('default'); // Build the query. * $view->pre_execute(); // Pre-execute the query. - * $view->execute(); // Run the query - * $output = $view->render(); // Render the view + * $view->execute(); // Run the query. + * $output = $view->render(); // Render the view. * @endcode * - * If short circuited at any point, look in $view->build_info for - * information about the query. After execute, look in $view->result - * for the array of objects returned from db_query. + * If short circuited at any point, look in $view->build_info for information + * about the query. After execute, look in $view->result for the array of + * objects returned from db_query. * * You can also do: + * * @code * $view->set_arguments($args); - * $output = $view->render('default'); // Render the view + * $output = $view->render('default'); // Render the view. * @endcode * - * This illustrates that render is smart enough to call build and execute - * if these items have not already been accomplished. + * This illustrates that render is smart enough to call build and execute if + * these items have not already been accomplished. * - * Note that execute also must accomplish other tasks, such - * as setting page titles, breadcrumbs, and generating exposed filter - * data if necessary. + * Note that execute also must accomplish other tasks, such as setting page + * titles, breadcrumbs, and generating exposed filter data if necessary. */ - function execute() { + public function execute() { return $this->view->render($this->display->id); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_display_embed.inc b/sites/all/modules/views/plugins/views_plugin_display_embed.inc index 8b25cf9..65cc6ca 100644 --- a/sites/all/modules/views/plugins/views_plugin_display_embed.inc +++ b/sites/all/modules/views/plugins/views_plugin_display_embed.inc @@ -1,7 +1,8 @@ view = $view; $this->display = $display; } + /** + * Provide a form to edit options for this plugin. + */ + public function options_definition_alter(&$options) { + } /** * Provide a form to edit options for this plugin. */ - function options_definition_alter(&$options) { } - - /** - * Provide a form to edit options for this plugin. - */ - function options_form(&$form, &$form_state) { } + public function options_form(&$form, &$form_state) { + } /** * Validate the options form. */ - function options_validate(&$form, &$form_state) { } + public function options_validate(&$form, &$form_state) { + } /** * Handle any special handling on the validate form. */ - function options_submit(&$form, &$form_state) { } + public function options_submit(&$form, &$form_state) { + } /** * Set up any variables on the view prior to execution. */ - function pre_execute() { } + public function pre_execute() { + } /** * Inject anything into the query that the display_extender handler needs. */ - function query() { } + public function query() { + } /** * Provide the default summary for options in the views UI. * * This output is returned as an array. */ - function options_summary(&$categories, &$options) { } + public function options_summary(&$categories, &$options) { + } /** * Static member function to list which sections are defaultable * and what items each section contains. */ - function defaultable_sections(&$sections, $section = NULL) { } + public function defaultable_sections(&$sections, $section = NULL) { + } + } diff --git a/sites/all/modules/views/plugins/views_plugin_display_feed.inc b/sites/all/modules/views/plugins/views_plugin_display_feed.inc index 5eb68e3..a3c2333 100644 --- a/sites/all/modules/views/plugins/views_plugin_display_feed.inc +++ b/sites/all/modules/views/plugins/views_plugin_display_feed.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the feed display plugin. + * Definition of views_plugin_display_feed. */ /** @@ -13,7 +13,11 @@ * @ingroup views_display_plugins */ class views_plugin_display_feed extends views_plugin_display_page { - function init(&$view, &$display, $options = NULL) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$display, $options = NULL) { parent::init($view, $display, $options); // Set the default row style. Ideally this would be part of the option @@ -26,23 +30,40 @@ class views_plugin_display_feed extends views_plugin_display_page { } } - function uses_breadcrumb() { return FALSE; } - function get_style_type() { return 'feed'; } + /** + * {@inheritdoc} + */ + public function uses_breadcrumb() { + return FALSE; + } + + /** + * {@inheritdoc} + */ + public function get_style_type() { + return 'feed'; + } /** * Feeds do not go through the normal page theming mechanism. Instead, they * go through their own little theme function and then return NULL so that * Drupal believes that the page has already rendered itself...which it has. */ - function execute() { + public function execute() { $output = $this->view->render(); + if (!empty($this->view->build_info['denied'])) { + return MENU_ACCESS_DENIED; + } if (empty($output)) { return MENU_NOT_FOUND; } print $output; } - function preview() { + /** + * {@inheritdoc} + */ + public function preview() { if (!empty($this->view->live_preview)) { return '
    ' . check_plain($this->view->render()) . '
    '; } @@ -53,11 +74,14 @@ class views_plugin_display_feed extends views_plugin_display_page { * Instead of going through the standard views_view.tpl.php, delegate this * to the style handler. */ - function render() { + public function render() { return $this->view->style_plugin->render($this->view->result); } - function defaultable_sections($section = NULL) { + /** + * {@inheritdoc} + */ + public function defaultable_sections($section = NULL) { if (in_array($section, array('style_options', 'style_plugin', 'row_options', 'row_plugin',))) { return FALSE; } @@ -74,12 +98,15 @@ class views_plugin_display_feed extends views_plugin_display_page { return $sections; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['displays'] = array('default' => array()); - // Overrides for standard stuff: + // Overrides for standard stuff. $options['style_plugin']['default'] = 'rss'; $options['style_options']['default'] = array('description' => ''); $options['sitename_title']['default'] = FALSE; @@ -92,8 +119,11 @@ class views_plugin_display_feed extends views_plugin_display_page { return $options; } - function options_summary(&$categories, &$options) { - // It is very important to call the parent function here: + /** + * {@inheritdoc} + */ + public function options_summary(&$categories, &$options) { + // It is very important to call the parent function here. parent::options_summary($categories, $options); // Since we're childing off the 'page' type, we'll still *call* our @@ -138,7 +168,7 @@ class views_plugin_display_feed extends views_plugin_display_page { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { // It is very important to call the parent function here. parent::options_form($form, $form_state); @@ -155,6 +185,7 @@ class views_plugin_display_feed extends views_plugin_display_page { $form['title'] = $title; $form['title']['#dependency'] = array('edit-sitename-title' => array(FALSE)); break; + case 'displays': $form['#title'] .= t('Attach to'); $displays = array(); @@ -170,8 +201,10 @@ class views_plugin_display_feed extends views_plugin_display_page { '#default_value' => $this->get_option('displays'), ); break; + case 'path': $form['path']['#description'] = t('This view will be displayed by visiting this path on your site. It is recommended that the path be something like "path/%/%/feed" or "path/%/%/rss.xml", putting one % in the path for each contextual filter you have defined in the view.'); + break; } } @@ -179,13 +212,14 @@ class views_plugin_display_feed extends views_plugin_display_page { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_submit(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_submit($form, $form_state); switch ($form_state['section']) { case 'title': $this->set_option('sitename_title', $form_state['values']['sitename_title']); break; + case 'displays': $this->set_option($form_state['section'], $form_state['values'][$form_state['section']]); break; @@ -195,7 +229,7 @@ class views_plugin_display_feed extends views_plugin_display_page { /** * Attach to another view. */ - function attach_to($display_id) { + public function attach_to($display_id) { $displays = $this->get_option('displays'); if (empty($displays[$display_id])) { return; @@ -216,7 +250,11 @@ class views_plugin_display_feed extends views_plugin_display_page { } } - function uses_link_display() { + /** + * {@inheritdoc} + */ + public function uses_link_display() { return TRUE; } + } diff --git a/sites/all/modules/views/plugins/views_plugin_display_page.inc b/sites/all/modules/views/plugins/views_plugin_display_page.inc index 913a5a9..9b9e900 100644 --- a/sites/all/modules/views/plugins/views_plugin_display_page.inc +++ b/sites/all/modules/views/plugins/views_plugin_display_page.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the page display plugin. + * Definition of views_plugin_display_page. */ /** @@ -11,13 +11,25 @@ * @ingroup views_display_plugins */ class views_plugin_display_page extends views_plugin_display { + /** * The page display has a path. */ - function has_path() { return TRUE; } - function uses_breadcrumb() { return TRUE; } + public function has_path() { + return TRUE; + } - function option_definition() { + /** + * {@inheritdoc} + */ + public function uses_breadcrumb() { + return TRUE; + } + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['path'] = array('default' => ''); @@ -50,7 +62,7 @@ class views_plugin_display_page extends views_plugin_display { /** * Add this display's path information to Drupal's menu system. */ - function execute_hook_menu($callbacks) { + public function execute_hook_menu($callbacks) { $items = array(); // Replace % with the link to our standard views argument loader // views_arg_load -- which lives in views.module @@ -79,7 +91,8 @@ class views_plugin_display_page extends views_plugin_display { $access_plugin = views_get_plugin('access', 'none'); } - // Get access callback might return an array of the callback + the dynamic arguments. + // Get access callback might return an array of the callback + the dynamic + // arguments. $access_plugin_callback = $access_plugin->get_access_callback(); if (is_array($access_plugin_callback)) { @@ -140,17 +153,23 @@ class views_plugin_display_page extends views_plugin_display { default: $items[$path]['type'] = MENU_CALLBACK; break; + case 'normal': $items[$path]['type'] = MENU_NORMAL_ITEM; // Insert item into the proper menu $items[$path]['menu_name'] = $menu['name']; break; + case 'tab': $items[$path]['type'] = MENU_LOCAL_TASK; break; + case 'default tab': $items[$path]['type'] = MENU_DEFAULT_LOCAL_TASK; break; + case 'local action': + $items[$path]['type'] = MENU_LOCAL_ACTION; + break; } // Add context for contextual links. @@ -169,7 +188,7 @@ class views_plugin_display_page extends views_plugin_display { $bit = array_pop($bits); // we can't do this if they tried to make the last path bit variable. - // @todo: We can validate this. + // @todo We can validate this. if ($bit != '%views_arg' && !empty($bits)) { $default_path = implode('/', $bits); $items[$default_path] = array( @@ -192,6 +211,7 @@ class views_plugin_display_page extends views_plugin_display { case 'normal': $items[$default_path]['type'] = MENU_NORMAL_ITEM; break; + case 'tab': $items[$default_path]['type'] = MENU_LOCAL_TASK; break; @@ -212,7 +232,7 @@ class views_plugin_display_page extends views_plugin_display { * a drupal_set_title for the page, and does a views_set_page_view * on the view. */ - function execute() { + public function execute() { // Let the world know that this is the page view we're using. views_set_page_view($this->view); @@ -250,8 +270,8 @@ class views_plugin_display_page extends views_plugin_display { * * This output is returned as an array. */ - function options_summary(&$categories, &$options) { - // It is very important to call the parent function here: + public function options_summary(&$categories, &$options) { + // It is very important to call the parent function here. parent::options_summary($categories, $options); $categories['page'] = array( @@ -280,18 +300,22 @@ class views_plugin_display_page extends views_plugin_display { if (!is_array($menu)) { $menu = array('type' => 'none'); } - switch($menu['type']) { + switch ($menu['type']) { case 'none': default: $menu_str = t('No menu'); break; + case 'normal': $menu_str = t('Normal: @title', array('@title' => $menu['title'])); break; + case 'tab': case 'default tab': $menu_str = t('Tab: @title', array('@title' => $menu['title'])); break; + case 'local action': + $menu_str = t('Local action: @title', array('@title' => $menu['title'])); } $options['menu'] = array( @@ -300,7 +324,8 @@ class views_plugin_display_page extends views_plugin_display { 'value' => views_ui_truncate($menu_str, 24), ); - // This adds a 'Settings' link to the style_options setting if the style has options. + // This adds a 'Settings' link to the style_options setting if the style + // has options. if ($menu['type'] == 'default tab') { $options['menu']['setting'] = t('Parent menu item'); $options['menu']['links']['tab_options'] = t('Change settings for the parent menu'); @@ -310,8 +335,8 @@ class views_plugin_display_page extends views_plugin_display { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_form(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_form($form, $form_state); switch ($form_state['section']) { @@ -322,11 +347,13 @@ class views_plugin_display_page extends views_plugin_display { '#type' => 'textfield', '#description' => t('This view will be displayed by visiting this path on your site. You may use "%" in your URL to represent values that will be used for contextual filters: For example, "node/%/feed".'), '#default_value' => $this->get_option('path'), - '#field_prefix' => '' . url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), - '#field_suffix' => '‎', - '#attributes' => array('dir'=>'ltr'), + '#field_prefix' => '' . url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), + '#field_suffix' => '‎', + '#attributes' => array('dir'=>'ltr'), + '#maxlength' => 255, ); break; + case 'menu': $form['#title'] .= t('Menu item entry'); $form['#help_topic'] = 'menu'; @@ -339,6 +366,7 @@ class views_plugin_display_page extends views_plugin_display { if (empty($menu)) { $menu = array('type' => 'none', 'title' => '', 'weight' => 0); } + $menu_type_dependencies = array('normal', 'tab', 'default tab', 'local action'); $form['menu']['type'] = array( '#prefix' => '
    ', '#suffix' => '
    ', @@ -348,7 +376,8 @@ class views_plugin_display_page extends views_plugin_display { 'none' => t('No menu entry'), 'normal' => t('Normal menu entry'), 'tab' => t('Menu tab'), - 'default tab' => t('Default menu tab') + 'default tab' => t('Default menu tab'), + 'local action' => t('Local action'), ), '#default_value' => $menu['type'], ); @@ -358,14 +387,14 @@ class views_plugin_display_page extends views_plugin_display { '#type' => 'textfield', '#default_value' => $menu['title'], '#description' => t('If set to normal or tab, enter the text to use for the menu item.'), - '#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')), + '#dependency' => array('radio:menu[type]' => $menu_type_dependencies), ); $form['menu']['description'] = array( '#title' => t('Description'), '#type' => 'textfield', '#default_value' => $menu['description'], '#description' => t("If set to normal or tab, enter the text to use for the menu item's description."), - '#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')), + '#dependency' => array('radio:menu[type]' => $menu_type_dependencies), ); // Only display the menu selector if menu module is enabled. @@ -393,7 +422,7 @@ class views_plugin_display_page extends views_plugin_display { '#type' => 'textfield', '#default_value' => isset($menu['weight']) ? $menu['weight'] : 0, '#description' => t('The lower the weight the higher/further left it will appear.'), - '#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')), + '#dependency' => array('radio:menu[type]' => $menu_type_dependencies), ); $form['menu']['context'] = array( '#title' => t('Context'), @@ -415,6 +444,7 @@ class views_plugin_display_page extends views_plugin_display { '#dependency_count' => 2, ); break; + case 'tab_options': $form['#title'] .= t('Default tab options'); $tab_options = $this->get_option('tab_options'); @@ -480,15 +510,18 @@ class views_plugin_display_page extends views_plugin_display { '#type' => 'textfield', '#default_value' => $tab_options['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.'), - '#dependency' => array('radio:tab_options[type]' => array('tab')), + '#description' => t('Enter the weight of the item. The lower the number, the more to the left it will be.'), + '#dependency' => array('radio:tab_options[type]' => array('normal', 'tab')), ); break; } } - function options_validate(&$form, &$form_state) { - // It is very important to call the parent function here: + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_validate($form, $form_state); switch ($form_state['section']) { case 'path': @@ -500,9 +533,10 @@ class views_plugin_display_page extends views_plugin_display { form_error($form['path'], t('"%" may not be used for the first segment of a path.')); } - // automatically remove '/' and trailing whitespace from path. + // Automatically remove '/' and trailing whitespace from path. $form_state['values']['path'] = trim($form_state['values']['path'], '/ '); break; + case 'menu': $path = $this->get_option('path'); if ($form_state['values']['menu']['type'] == 'normal' && strpos($path, '%') !== FALSE) { @@ -524,27 +558,35 @@ class views_plugin_display_page extends views_plugin_display { } } - function options_submit(&$form, &$form_state) { - // It is very important to call the parent function here: + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_submit($form, $form_state); switch ($form_state['section']) { case 'path': $this->set_option('path', $form_state['values']['path']); break; + case 'menu': $this->set_option('menu', $form_state['values']['menu']); - // send ajax form to options page if we use it. + // Send ajax form to options page if we use it. if ($form_state['values']['menu']['type'] == 'default tab') { views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('tab_options')); } break; + case 'tab_options': $this->set_option('tab_options', $form_state['values']['tab_options']); break; } } - function validate() { + /** + * {@inheritdoc} + */ + public function validate() { $errors = parent::validate(); $menu = $this->get_option('menu'); @@ -562,7 +604,10 @@ class views_plugin_display_page extends views_plugin_display { return $errors; } - function get_argument_text() { + /** + * {@inheritdoc} + */ + public function get_argument_text() { return array( 'filter value not present' => t('When the filter value is NOT in the URL'), 'filter value present' => t('When the filter value IS in the URL or a default is provided'), @@ -570,10 +615,14 @@ class views_plugin_display_page extends views_plugin_display { ); } - function get_pager_text() { + /** + * {@inheritdoc} + */ + public function get_pager_text() { return array( 'items per page title' => t('Items per page'), - 'items per page description' => t('The number of items to display per page. Enter 0 for no limit.') + 'items per page description' => t('The number of items to display per page. Enter 0 for no limit.'), ); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_exposed_form.inc b/sites/all/modules/views/plugins/views_plugin_exposed_form.inc index 5d54600..5493be3 100644 --- a/sites/all/modules/views/plugins/views_plugin_exposed_form.inc +++ b/sites/all/modules/views/plugins/views_plugin_exposed_form.inc @@ -23,19 +23,24 @@ class views_plugin_exposed_form extends views_plugin { /** * Initialize the plugin. * - * @param $view + * @param object $view * The view object. - * @param $display + * @param object $display * The display handler. + * @param array $options + * Any additional options that are being added. */ - function init(&$view, &$display, $options = array()) { + public function init(&$view, &$display, $options = array()) { $this->view = &$view; $this->display = &$display; $this->unpack_options($this->options, $options); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['submit_button'] = array('default' => 'Apply', 'translatable' => TRUE); $options['reset_button'] = array('default' => FALSE, 'bool' => TRUE); @@ -49,7 +54,10 @@ class views_plugin_exposed_form extends views_plugin { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['submit_button'] = array( '#type' => 'textfield', @@ -120,7 +128,7 @@ class views_plugin_exposed_form extends views_plugin { $form['autosubmit_hide'] = array( '#type' => 'checkbox', '#title' => t('Hide submit button'), - '#description' => t('Hide submit button if javascript is enabled.'), + '#description' => t('Hide submit button if JavaScript is enabled.'), '#default_value' => $this->options['autosubmit_hide'], '#dependency' => array( 'edit-exposed-form-options-autosubmit' => array(1), @@ -135,7 +143,7 @@ class views_plugin_exposed_form extends views_plugin { * also assign data to the appropriate handlers for use in building the * query. */ - function render_exposed_form($block = FALSE) { + public function render_exposed_form($block = FALSE) { // Deal with any exposed filters we may have, before building. $form_state = array( 'view' => &$this->view, @@ -169,7 +177,10 @@ class views_plugin_exposed_form extends views_plugin { } } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $view = $this->view; $exposed_data = isset($view->exposed_data) ? $view->exposed_data : array(); $sort_by = isset($exposed_data['sort_by']) ? $exposed_data['sort_by'] : NULL; @@ -182,7 +193,7 @@ class views_plugin_exposed_form extends views_plugin { if (!$sort->is_exposed()) { $sort->query(); } - else if ($key == $sort_by) { + elseif ($key == $sort_by) { if (isset($exposed_data['sort_order']) && in_array($exposed_data['sort_order'], array('ASC', 'DESC'))) { $sort->options['order'] = $exposed_data['sort_order']; } @@ -194,15 +205,34 @@ class views_plugin_exposed_form extends views_plugin { } } - function pre_render($values) { } + /** + * {@inheritdoc} + */ + public function pre_render($values) { + } - function post_render(&$output) { } + /** + * {@inheritdoc} + */ + public function post_render(&$output) { + } - function pre_execute() { } + /** + * {@inheritdoc} + */ + public function pre_execute() { + } - function post_execute() { } + /** + * {@inheritdoc} + */ + public function post_execute() { + } - function exposed_form_alter(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function exposed_form_alter(&$form, &$form_state) { if (!empty($this->options['reset_button'])) { $form['reset'] = array( '#value' => $this->options['reset_button_label'], @@ -231,7 +261,8 @@ class views_plugin_exposed_form extends views_plugin { ); if (isset($form_state['input']['sort_by']) && isset($this->view->sort[$form_state['input']['sort_by']])) { $default_sort_order = $this->view->sort[$form_state['input']['sort_by']]->options['order']; - } else { + } + else { $first_sort = reset($this->view->sort); $default_sort_order = $first_sort->options['order']; } @@ -275,7 +306,10 @@ class views_plugin_exposed_form extends views_plugin { } } - function exposed_form_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function exposed_form_validate(&$form, &$form_state) { if (isset($form_state['pager_plugin'])) { $form_state['pager_plugin']->exposed_form_validate($form, $form_state); } @@ -284,15 +318,14 @@ class views_plugin_exposed_form extends views_plugin { /** * This function is executed when exposed form is submited. * - * @param $form + * @param array $form * Nested array of form elements that comprise the form. - * @param $form_state + * @param array $form_state * A keyed array containing the current state of the form. - * @param $exclude - * Nested array of keys to exclude of insert into - * $view->exposed_raw_input + * @param array $exclude + * Nested array of keys to exclude of insert into $view->exposed_raw_input. */ - function exposed_form_submit(&$form, &$form_state, &$exclude) { + public function exposed_form_submit(&$form, &$form_state, &$exclude) { if (!empty($form_state['values']['op']) && $form_state['values']['op'] == $this->options['reset_button_label']) { $this->reset_form($form, $form_state); } @@ -302,7 +335,10 @@ class views_plugin_exposed_form extends views_plugin { } } - function reset_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function reset_form(&$form, &$form_state) { // _SESSION is not defined for users who are not logged in. // If filters are not overridden, store the 'remember' settings on the @@ -327,6 +363,7 @@ class views_plugin_exposed_form extends views_plugin { $form_state['redirect'] = current_path(); $form_state['values'] = array(); } + } /** diff --git a/sites/all/modules/views/plugins/views_plugin_exposed_form_basic.inc b/sites/all/modules/views/plugins/views_plugin_exposed_form_basic.inc index 73ae54a..2bf8162 100644 --- a/sites/all/modules/views/plugins/views_plugin_exposed_form_basic.inc +++ b/sites/all/modules/views/plugins/views_plugin_exposed_form_basic.inc @@ -10,4 +10,6 @@ * * @ingroup views_exposed_form_plugins */ -class views_plugin_exposed_form_basic extends views_plugin_exposed_form { } +class views_plugin_exposed_form_basic extends views_plugin_exposed_form { + // Nothing to see here. +} diff --git a/sites/all/modules/views/plugins/views_plugin_exposed_form_input_required.inc b/sites/all/modules/views/plugins/views_plugin_exposed_form_input_required.inc index ca97674..93a3bc3 100644 --- a/sites/all/modules/views/plugins/views_plugin_exposed_form_input_required.inc +++ b/sites/all/modules/views/plugins/views_plugin_exposed_form_input_required.inc @@ -12,7 +12,10 @@ */ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['text_input_required'] = array('default' => 'Select any filter and click on Apply to see results', 'translatable' => TRUE); @@ -20,7 +23,10 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['text_input_required'] = array( @@ -33,13 +39,19 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form ); } - function options_submit(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { $form_state['values']['exposed_form_options']['text_input_required_format'] = $form_state['values']['exposed_form_options']['text_input_required']['format']; $form_state['values']['exposed_form_options']['text_input_required'] = $form_state['values']['exposed_form_options']['text_input_required']['value']; parent::options_submit($form, $form_state); } - function exposed_filter_applied() { + /** + * {@inheritdoc} + */ + public function exposed_filter_applied() { static $cache = NULL; if (!isset($cache)) { $view = $this->view; @@ -60,7 +72,10 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form return $cache; } - function pre_render($values) { + /** + * {@inheritdoc} + */ + public function pre_render($values) { if (!$this->exposed_filter_applied()) { $options = array( 'id' => 'area', @@ -82,7 +97,10 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form } } - function query() { + /** + * {@inheritdoc} + */ + public function query() { if (!$this->exposed_filter_applied()) { // We return with no query; this will force the empty text. $this->view->built = TRUE; diff --git a/sites/all/modules/views/plugins/views_plugin_localization.inc b/sites/all/modules/views/plugins/views_plugin_localization.inc index 08caf9e..f572a8d 100644 --- a/sites/all/modules/views/plugins/views_plugin_localization.inc +++ b/sites/all/modules/views/plugins/views_plugin_localization.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the base class for views localization plugins. + * Definition of views_plugin_localization. */ /** @@ -17,22 +17,29 @@ * The base plugin to handle localization of Views strings. */ class views_plugin_localization extends views_plugin { - // Store for exported strings - var $export_strings = array(); - var $translate = TRUE; + + /** + * Store for exported strings. + */ + public $export_strings = array(); + + /** + * + */ + public $translate = TRUE; /** * Initialize the plugin. * - * @param $view + * @param view $view * The view object. */ - function init(&$view) { + public function init(&$view) { $this->view = &$view; } /** - * Translate a string / text with format + * Translate a string / text with format. * * The $source parameter is an array with the following elements: * - value, source string @@ -40,14 +47,15 @@ class views_plugin_localization extends views_plugin { * - keys. An array of keys to identify the string. Generally constructed from * view name, display_id, and a property, e.g., 'header'. * - * @param $source + * @param string $source * Full data for the string to be translated. * * @return string - * Translated string / text + * Translated string / text. */ - function translate($source) { - // Allow other modules to make changes to the string before and after translation + public function translate($source) { + // Allow other modules to make changes to the string before and after + // translation. $source['pre_process'] = $this->invoke_translation_process($source, 'pre'); $source['translation'] = $this->translate_string($source['value'], $source['keys'], $source['format']); $source['post_process'] = $this->invoke_translation_process($source, 'post'); @@ -57,64 +65,67 @@ class views_plugin_localization extends views_plugin { /** * Translate a string. * - * @param $string + * @param string $string * The string to be translated. - * @param $keys + * @param array $keys * An array of keys to identify the string. Generally constructed from - * view name, display_id, and a property, e.g., 'header'. - * @param $format + * view name, display_id, and a property, e.g. 'header'. + * @param string $format * The input format of the string. This is optional. */ - function translate_string($string, $keys = array(), $format = '') {} + public function translate_string($string, $keys = array(), $format = '') {} /** * Save string source for translation. * - * @param $source + * @param string $source * Full data for the string to be translated. */ - function save($source) { - // Allow other modules to make changes to the string before saving + public function save($source) { + // Allow other modules to make changes to the string before saving. $source['pre_process'] = $this->invoke_translation_process($source, 'pre'); $this->save_string($source['value'], $source['keys'], isset($source['format']) ? $source['format'] : ''); } /** - * Save a string for translation + * Save a string for translation. * - * @param $string + * @param string $string * The string to be translated. - * @param $keys + * @param array $keys * An array of keys to identify the string. Generally constructed from * view name, display_id, and a property, e.g., 'header'. - * @param $format + * @param string $format * The input format of the string. This is optional. */ - function save_string($string, $keys = array(), $format = '') {} + public function save_string($string, $keys = array(), $format = '') {} /** * Delete a string. * - * @param $source + * @param string $source * Full data for the string to be translated. */ - function delete($source) { } + public function delete($source) { + } /** * Collect strings to be exported to code. * - * @param $source + * @param string $source * Full data for the string to be translated. */ - function export($source) { } + public function export($source) { + } /** * Render any collected exported strings to code. * - * @param $indent + * @param string $indent * An optional indentation for prettifying nested code. */ - function export_render($indent = ' ') { } + public function export_render($indent = ' ') { + } /** * Invoke hook_translation_pre_process() or hook_translation_post_process(). @@ -122,7 +133,7 @@ class views_plugin_localization extends views_plugin { * Like node_invoke_nodeapi(), this function is needed to enable both passing * by reference and fetching return values. */ - function invoke_translation_process(&$value, $op) { + public function invoke_translation_process(&$value, $op) { $return = array(); $hook = 'translation_' . $op . '_process'; foreach (module_implements($hook) as $module) { @@ -135,7 +146,10 @@ class views_plugin_localization extends views_plugin { return $return; } - function process_locale_strings($op) { + /** + * + */ + public function process_locale_strings($op) { $this->view->init_display(); foreach ($this->view->display as $display_id => $display) { @@ -154,9 +168,11 @@ class views_plugin_localization extends views_plugin { case 'save': $this->save($data); break; + case 'delete': $this->delete($data); break; + case 'export': $this->export($data); break; @@ -164,6 +180,7 @@ class views_plugin_localization extends views_plugin { } } } + } /** diff --git a/sites/all/modules/views/plugins/views_plugin_localization_core.inc b/sites/all/modules/views/plugins/views_plugin_localization_core.inc index 87443ca..92feb2d 100644 --- a/sites/all/modules/views/plugins/views_plugin_localization_core.inc +++ b/sites/all/modules/views/plugins/views_plugin_localization_core.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the Drupal core localization plugin. + * Definition of views_plugin_localization_core. */ /** @@ -15,35 +15,35 @@ class views_plugin_localization_core extends views_plugin_localization { /** * Translate a string. * - * @param $string + * @param string $string * The string to be translated. - * @param $keys + * @param array $keys * An array of keys to identify the string. Generally constructed from * view name, display_id, and a property, e.g., 'header'. - * @param $format + * @param string $format * The input format of the string. This is optional. */ - function translate_string($string, $keys = array(), $format = '') { + public function translate_string($string, $keys = array(), $format = '') { return t($string); } /** * Save a string for translation. * - * @param $string + * @param string $string * The string to be translated. - * @param $keys + * @param array $keys * An array of keys to identify the string. Generally constructed from * view name, display_id, and a property, e.g., 'header'. - * @param $format + * @param string $format * The input format of the string. This is optional. */ - function save_string($string, $keys = array(), $format = '') { + public function save_string($string, $keys = array(), $format = '') { global $language; // If the current language is 'en', we need to reset the language // in order to trigger an update. - // TODO: add test for number of languages. + // @todo add test for number of languages. if ($language->language == 'en') { $changed = TRUE; $languages = language_list(); @@ -67,22 +67,23 @@ class views_plugin_localization_core extends views_plugin_localization { * * Deletion is not supported. * - * @param $source + * @param mixed $source * Full data for the string to be translated. */ - function delete($source) { + public function delete($source) { return FALSE; } /** * Collect strings to be exported to code. * - * String identifiers are not supported so strings are anonymously in an array. + * String identifiers are not supported so strings are anonymously in an + * array. * - * @param $source + * @param array $source * Full data for the string to be translated. */ - function export($source) { + public function export($source) { if (!empty($source['value'])) { $this->export_strings[] = $source['value']; } @@ -91,10 +92,10 @@ class views_plugin_localization_core extends views_plugin_localization { /** * Render any collected exported strings to code. * - * @param $indent + * @param string $indent * An optional indentation for prettifying nested code. */ - function export_render($indent = ' ') { + public function export_render($indent = ' ') { $output = ''; if (!empty($this->export_strings)) { $this->export_strings = array_unique($this->export_strings); @@ -106,4 +107,5 @@ class views_plugin_localization_core extends views_plugin_localization { } return $output; } + } diff --git a/sites/all/modules/views/plugins/views_plugin_localization_none.inc b/sites/all/modules/views/plugins/views_plugin_localization_none.inc index 620352a..4a1a7d9 100644 --- a/sites/all/modules/views/plugins/views_plugin_localization_none.inc +++ b/sites/all/modules/views/plugins/views_plugin_localization_none.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the 'none' localization plugin. + * Definition of views_plugin_localization_none. */ /** @@ -11,26 +11,31 @@ * @ingroup views_localization_plugins */ class views_plugin_localization_none extends views_plugin_localization { - var $translate = FALSE; + + /** + * {@inheritdoc} + */ + public $translate = FALSE; /** * Translate a string; simply return the string. */ - function translate($source) { + public function translate($source) { return $source['value']; } /** * Save a string for translation; not supported. */ - function save($source) { + public function save($source) { return FALSE; } /** * Delete a string; not supported. */ - function delete($source) { + public function delete($source) { return FALSE; } + } diff --git a/sites/all/modules/views/plugins/views_plugin_pager.inc b/sites/all/modules/views/plugins/views_plugin_pager.inc index 312f54b..0217f4d 100644 --- a/sites/all/modules/views/plugins/views_plugin_pager.inc +++ b/sites/all/modules/views/plugins/views_plugin_pager.inc @@ -17,18 +17,26 @@ * The base plugin to handle pager. */ class views_plugin_pager extends views_plugin { - var $current_page = NULL; - var $total_items = 0; + + /** + * + */ + public $current_page = NULL; + + /** + * + */ + public $total_items = 0; /** * Initialize the plugin. * - * @param $view + * @param view $view * The view object. - * @param $display + * @param object $display * The display handler. */ - function init(&$view, &$display, $options = array()) { + public function init(&$view, &$display, $options = array()) { $this->view = &$view; $this->display = &$display; @@ -41,8 +49,8 @@ class views_plugin_pager extends views_plugin { * All but the leanest pagers should probably return a value here, so * most pagers will not need to override this method. */ - function get_items_per_page() { - return isset($this->options['items_per_page']) ? $this->options['items_per_page'] : 0; + public function get_items_per_page() { + return isset($this->options['items_per_page']) ? (int) $this->options['items_per_page'] : 0; } /** @@ -50,8 +58,8 @@ class views_plugin_pager extends views_plugin { * * This is mostly used for things that will override the value. */ - function set_items_per_page($items) { - $this->options['items_per_page'] = $items; + public function set_items_per_page($items) { + $this->options['items_per_page'] = (int) $items; } /** @@ -60,15 +68,15 @@ class views_plugin_pager extends views_plugin { * Even pagers that don't actually page can skip items at the beginning, * so few pagers will need to override this method. */ - function get_offset() { - return isset($this->options['offset']) ? $this->options['offset'] : 0; + public function get_offset() { + return isset($this->options['offset']) ? (int) $this->options['offset'] : 0; } /** * Set the page offset, or how many items to skip. */ - function set_offset($offset) { - $this->options['offset'] = $offset; + public function set_offset($offset) { + $this->options['offset'] = (int) $offset; } /** @@ -76,18 +84,18 @@ class views_plugin_pager extends views_plugin { * * If NULL, we do not know what the current page is. */ - function get_current_page() { + public function get_current_page() { return $this->current_page; } /** * Set the current page. * - * @param $number + * @param int $number * If provided, the page number will be set to this. If NOT provided, * the page number will be set from the global page array. */ - function set_current_page($number = NULL) { + public function set_current_page($number = NULL) { if (!is_numeric($number) || $number < 0) { $number = 0; } @@ -99,32 +107,34 @@ class views_plugin_pager extends views_plugin { * * If NULL, we do not yet know what the total number of items are. */ - function get_total_items() { + public function get_total_items() { return $this->total_items; } /** - * Get the pager id, if it exists + * Get the pager id, if it exists. */ - function get_pager_id() { + public function get_pager_id() { return !empty($this->options['id']) ? $this->options['id'] : 0; } /** - * Provide the default form form for validating options + * Provide the default form form for validating options. */ - function options_validate(&$form, &$form_state) { } + public function options_validate(&$form, &$form_state) { + } /** - * Provide the default form form for submitting options + * Provide the default form form for submitting options. */ - function options_submit(&$form, &$form_state) { } + public function options_submit(&$form, &$form_state) { + } /** * Return a string to display as the clickable title for the * pager plugin. */ - function summary_title() { + public function summary_title() { return t('Unknown'); } @@ -133,7 +143,7 @@ class views_plugin_pager extends views_plugin { * * Only a couple of very specific pagers will set this to false. */ - function use_pager() { + public function use_pager() { return TRUE; } @@ -142,7 +152,7 @@ class views_plugin_pager extends views_plugin { * * If a pager needs a count query, a simple query */ - function use_count_query() { + public function use_count_query() { return TRUE; } @@ -150,7 +160,7 @@ class views_plugin_pager extends views_plugin { * Execute the count query, which will be done just prior to the query * itself being executed. */ - function execute_count_query(&$count_query) { + public function execute_count_query(&$count_query) { $this->total_items = $count_query->execute()->fetchField(); if (!empty($this->options['offset'])) { $this->total_items -= $this->options['offset']; @@ -164,8 +174,7 @@ class views_plugin_pager extends views_plugin { * If there are pagers that need global values set, this method can * be used to set them. It will be called when the count query is run. */ - function update_page_info() { - + public function update_page_info() { } /** @@ -173,22 +182,26 @@ class views_plugin_pager extends views_plugin { * * This is called during the build phase and can directly modify the query. */ - function query() { } + public function query() { + } /** * Perform any needed actions just prior to the query executing. */ - function pre_execute(&$query) { } + public function pre_execute(&$query) { + } /** * Perform any needed actions just after the query executing. */ - function post_execute(&$result) { } + public function post_execute(&$result) { + } /** * Perform any needed actions just before rendering. */ - function pre_render(&$result) { } + public function pre_render(&$result) { + } /** * Render the pager. @@ -196,39 +209,62 @@ class views_plugin_pager extends views_plugin { * Called during the view render process, this will render the * pager. * - * @param $input + * @param array $input * Any extra GET parameters that should be retained, such as exposed * input. */ - function render($input) { } + public function render($input) { + } /** * Determine if there are more records available. * * This is primarily used to control the display of a more link. */ - function has_more_records() { + public function has_more_records() { return $this->get_items_per_page() && $this->total_items > (intval($this->current_page) + 1) * $this->get_items_per_page(); } - function exposed_form_alter(&$form, &$form_state) { } + /** + * {@inheritdoc} + */ + public function exposed_form_alter(&$form, &$form_state) { + } - function exposed_form_validate(&$form, &$form_state) { } + /** + * {@inheritdoc} + */ + public function exposed_form_validate(&$form, &$form_state) { + } - function exposed_form_submit(&$form, &$form_state, &$exclude) { } + /** + * {@inheritdoc} + */ + public function exposed_form_submit(&$form, &$form_state, &$exclude) { + } - function uses_exposed() { + /** + * {@inheritdoc} + */ + public function uses_exposed() { return FALSE; } - function items_per_page_exposed() { + /** + * {@inheritdoc} + */ + public function items_per_page_exposed() { return FALSE; } - function offset_exposed() { + /** + * {@inheritdoc} + */ + public function offset_exposed() { return FALSE; } + } /** diff --git a/sites/all/modules/views/plugins/views_plugin_pager_full.inc b/sites/all/modules/views/plugins/views_plugin_pager_full.inc index 084aa0a..578bebe 100644 --- a/sites/all/modules/views/plugins/views_plugin_pager_full.inc +++ b/sites/all/modules/views/plugins/views_plugin_pager_full.inc @@ -11,14 +11,21 @@ * @ingroup views_pager_plugins */ class views_plugin_pager_full extends views_plugin_pager { - function summary_title() { + + /** + * {@inheritdoc} + */ + public function summary_title() { if (!empty($this->options['offset'])) { return format_plural($this->options['items_per_page'], '@count item, skip @skip', 'Paged, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset'])); } - return format_plural($this->options['items_per_page'], '@count item', 'Paged, @count items', array('@count' => $this->options['items_per_page'])); + return format_plural($this->options['items_per_page'], '@count item', 'Paged, @count items', array('@count' => $this->options['items_per_page'])); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['items_per_page'] = array('default' => 10); $options['offset'] = array('default' => 0); @@ -52,7 +59,7 @@ class views_plugin_pager_full extends views_plugin_pager { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $pager_text = $this->display->handler->get_pager_text(); $form['items_per_page'] = array( @@ -90,7 +97,7 @@ class views_plugin_pager_full extends views_plugin_pager { '#default_value' => $this->options['quantity'], ); - $form['tags'] = array ( + $form['tags'] = array( '#type' => 'fieldset', '#collapsible' => FALSE, '#collapsed' => FALSE, @@ -128,7 +135,7 @@ class views_plugin_pager_full extends views_plugin_pager { '#default_value' => $this->options['tags']['last'], ); - $form['expose'] = array ( + $form['expose'] = array( '#type' => 'fieldset', '#collapsible' => FALSE, '#collapsed' => FALSE, @@ -152,7 +159,7 @@ class views_plugin_pager_full extends views_plugin_pager { '#description' => t('Label to use in the exposed items per page form element.'), '#default_value' => $this->options['expose']['items_per_page_label'], '#dependency' => array( - 'edit-pager-options-expose-items-per-page' => array(1) + 'edit-pager-options-expose-items-per-page' => array(1), ), ); @@ -163,11 +170,10 @@ class views_plugin_pager_full extends views_plugin_pager { '#description' => t('Set between which values the user can choose when determining the items per page. Separated by comma.'), '#default_value' => $this->options['expose']['items_per_page_options'], '#dependency' => array( - 'edit-pager-options-expose-items-per-page' => array(1) + 'edit-pager-options-expose-items-per-page' => array(1), ), ); - $form['expose']['items_per_page_options_all'] = array( '#type' => 'checkbox', '#title' => t('Include all items option'), @@ -199,19 +205,22 @@ class views_plugin_pager_full extends views_plugin_pager { '#description' => t('Label to use in the exposed offset form element.'), '#default_value' => $this->options['expose']['offset_label'], '#dependency' => array( - 'edit-pager-options-expose-offset' => array(1) + 'edit-pager-options-expose-offset' => array(1), ), ); } - function options_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { // Only accept integer values. $error = FALSE; $exposed_options = $form_state['values']['pager_options']['expose']['items_per_page_options']; if (strpos($exposed_options, '.') !== FALSE) { $error = TRUE; } - $options = explode(',',$exposed_options); + $options = explode(',', $exposed_options); if (!$error && is_array($options)) { foreach ($options as $option) { if (!is_numeric($option) || intval($option) == 0) { @@ -237,10 +246,13 @@ class views_plugin_pager_full extends views_plugin_pager { } } - function query() { + /** + * {@inheritdoc} + */ + public function query() { if ($this->items_per_page_exposed()) { if (!empty($_GET['items_per_page']) && $_GET['items_per_page'] > 0) { - $this->options['items_per_page'] = $_GET['items_per_page']; + $this->options['items_per_page'] = (int) $_GET['items_per_page']; } elseif (!empty($_GET['items_per_page']) && $_GET['items_per_page'] == 'All' && $this->options['expose']['items_per_page_options_all']) { $this->options['items_per_page'] = 0; @@ -248,16 +260,15 @@ class views_plugin_pager_full extends views_plugin_pager { } if ($this->offset_exposed()) { if (isset($_GET['offset']) && $_GET['offset'] >= 0) { - $this->options['offset'] = $_GET['offset']; + $this->options['offset'] = (int) $_GET['offset']; } } - $limit = $this->options['items_per_page']; - $offset = $this->current_page * $this->options['items_per_page'] + $this->options['offset']; + $limit = $this->get_items_per_page(); + $offset = $this->current_page * $limit + $this->get_offset(); if (!empty($this->options['total_pages'])) { if ($this->current_page >= $this->options['total_pages']) { - $limit = $this->options['items_per_page']; - $offset = $this->options['total_pages'] * $this->options['items_per_page']; + $offset = $this->options['total_pages'] * $limit; } } @@ -265,7 +276,10 @@ class views_plugin_pager_full extends views_plugin_pager { $this->view->query->set_offset($offset); } - function render($input) { + /** + * {@inheritdoc} + */ + public function render($input) { $pager_theme = views_theme_functions('pager', $this->view, $this->display); // The 0, 1, 3, 4 index are correct. See theme_pager documentation. $tags = array( @@ -286,11 +300,11 @@ class views_plugin_pager_full extends views_plugin_pager { /** * Set the current page. * - * @param $number + * @param int $number * If provided, the page number will be set to this. If NOT provided, * the page number will be set from the global page array. */ - function set_current_page($number = NULL) { + public function set_current_page($number = NULL) { if (isset($number)) { $this->current_page = $number; return; @@ -320,7 +334,10 @@ class views_plugin_pager_full extends views_plugin_pager { } } - function get_pager_total() { + /** + * {@inheritdoc} + */ + public function get_pager_total() { if ($items_per_page = intval($this->get_items_per_page())) { return ceil($this->total_items / $items_per_page); } @@ -336,7 +353,7 @@ class views_plugin_pager_full extends views_plugin_pager { * items available and to update the current page if the requested * page is out of range. */ - function update_page_info() { + public function update_page_info() { if (!empty($this->options['total_pages'])) { if (($this->options['total_pages'] * $this->options['items_per_page']) < $this->total_items) { $this->total_items = $this->options['total_pages'] * $this->options['items_per_page']; @@ -356,34 +373,47 @@ class views_plugin_pager_full extends views_plugin_pager { // Calculate and set the count of available pages. $pager_total[$pager_id] = $this->get_pager_total(); - // See if the requested page was within range: + // See if the requested page was within range. if ($this->current_page < 0) { $this->current_page = 0; } - else if ($this->current_page >= $pager_total[$pager_id]) { - // Pages are numbered from 0 so if there are 10 pages, the last page is 9. + elseif ($this->current_page >= $pager_total[$pager_id]) { + // Pages are numbered from 0 so if there are 10 pages, the last page is + // 9. $this->current_page = $pager_total[$pager_id] - 1; } - // Put this number in to guarantee that we do not generate notices when the pager - // goes to look for it later. + // Put this number in to guarantee that we do not generate notices when + // the pager goes to look for it later. $pager_page_array[$pager_id] = $this->current_page; } } - function uses_exposed() { + /** + * + */ + public function uses_exposed() { return $this->items_per_page_exposed() || $this->offset_exposed(); } - function items_per_page_exposed() { + /** + * + */ + public function items_per_page_exposed() { return !empty($this->options['expose']['items_per_page']); } - function offset_exposed() { + /** + * + */ + public function offset_exposed() { return !empty($this->options['expose']['offset']); } - function exposed_form_alter(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function exposed_form_alter(&$form, &$form_state) { if ($this->items_per_page_exposed()) { $options = explode(',', $this->options['expose']['items_per_page_options']); $sanitized_options = array(); @@ -414,11 +444,15 @@ class views_plugin_pager_full extends views_plugin_pager { } } - function exposed_form_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function exposed_form_validate(&$form, &$form_state) { if (!empty($form_state['values']['offset']) && trim($form_state['values']['offset'])) { if (!is_numeric($form_state['values']['offset']) || $form_state['values']['offset'] < 0) { - form_set_error('offset', t('Offset must be an number greater or equal than 0.')); + form_set_error('offset', t('Offset must be a number greater than or equal to 0.')); } } } + } diff --git a/sites/all/modules/views/plugins/views_plugin_pager_mini.inc b/sites/all/modules/views/plugins/views_plugin_pager_mini.inc index 87d5541..4e7dc35 100644 --- a/sites/all/modules/views/plugins/views_plugin_pager_mini.inc +++ b/sites/all/modules/views/plugins/views_plugin_pager_mini.inc @@ -11,21 +11,24 @@ * @ingroup views_pager_plugins */ class views_plugin_pager_mini extends views_plugin_pager_full { - function summary_title() { + + /** + * {@inheritdoc} + */ + public function summary_title() { if (!empty($this->options['offset'])) { return format_plural($this->options['items_per_page'], 'Mini pager, @count item, skip @skip', 'Mini pager, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset'])); } - return format_plural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', array('@count' => $this->options['items_per_page'])); + return format_plural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', array('@count' => $this->options['items_per_page'])); } /** - * Overrides views_plugin_pager_full::option_definition(). - * - * Overrides the full pager options form by deleting unused settings. + * {@inheritdoc} */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); + // Overrides the full pager options form by deleting unused settings. unset($options['quantity']); unset($options['tags']['first']); unset($options['tags']['last']); @@ -36,25 +39,25 @@ class views_plugin_pager_mini extends views_plugin_pager_full { } /** - * Overrides views_plugin_pager_full::options_form(). - * - * Overrides the full pager options form by deleting unused settings. + * {@inheritdoc} */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); + + // Overrides the full pager options form by deleting unused settings. unset($form['quantity']); unset($form['tags']['first']); unset($form['tags']['last']); } /** - * Overrides views_plugin_pager_full::render(). - * - * Overrides the full pager renderer by changing the theme function - * and leaving out variables that are not used in the mini pager. + * {@inheritdoc} */ - function render($input) { + public function render($input) { + // Overrides the full pager renderer by changing the theme function and + // leaving out variables that are not used in the mini pager. $pager_theme = views_theme_functions('views_mini_pager', $this->view, $this->display); + // The 1, 3 index are correct. // @see theme_pager(). $tags = array( @@ -67,4 +70,5 @@ class views_plugin_pager_mini extends views_plugin_pager_full { 'parameters' => $input, )); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_pager_none.inc b/sites/all/modules/views/plugins/views_plugin_pager_none.inc index 12b96d0..3faa301 100644 --- a/sites/all/modules/views/plugins/views_plugin_pager_none.inc +++ b/sites/all/modules/views/plugins/views_plugin_pager_none.inc @@ -12,21 +12,30 @@ */ class views_plugin_pager_none extends views_plugin_pager { - function init(&$view, &$display, $options = array()) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$display, $options = array()) { parent::init($view, $display, $options); // If the pager is set to none, then it should show all items. $this->set_items_per_page(0); } - function summary_title() { + /** + * {@inheritdoc} + */ + public function summary_title() { if (!empty($this->options['offset'])) { return t('All items, skip @skip', array('@skip' => $this->options['offset'])); } return t('All items'); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['offset'] = array('default' => 0); @@ -36,7 +45,7 @@ class views_plugin_pager_none extends views_plugin_pager { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['offset'] = array( '#type' => 'textfield', @@ -46,30 +55,50 @@ class views_plugin_pager_none extends views_plugin_pager { ); } - function use_pager() { + /** + * {@inheritdoc} + */ + public function use_pager() { return FALSE; } - function use_count_query() { + /** + * {@inheritdoc} + */ + public function use_count_query() { return FALSE; } - function get_items_per_page() { + /** + * {@inheritdoc} + */ + public function get_items_per_page() { return 0; } - function execute_count_query(&$count_query) { - // If we are displaying all items, never count. But we can update the count in post_execute. + /** + * {@inheritdoc} + */ + public function execute_count_query(&$count_query) { + // If we are displaying all items, never count. But we can update the count + // in post_execute. } - function post_execute(&$result) { + /** + * {@inheritdoc} + */ + public function post_execute(&$result) { $this->total_items = count($result); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { // The only query modifications we might do are offsets. if (!empty($this->options['offset'])) { $this->view->query->set_offset($this->options['offset']); } } + } diff --git a/sites/all/modules/views/plugins/views_plugin_pager_some.inc b/sites/all/modules/views/plugins/views_plugin_pager_some.inc index 09452ce..12025b2 100644 --- a/sites/all/modules/views/plugins/views_plugin_pager_some.inc +++ b/sites/all/modules/views/plugins/views_plugin_pager_some.inc @@ -11,14 +11,21 @@ * @ingroup views_pager_plugins */ class views_plugin_pager_some extends views_plugin_pager { - function summary_title() { + + /** + * + */ + public function summary_title() { if (!empty($this->options['offset'])) { return format_plural($this->options['items_per_page'], '@count item, skip @skip', '@count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset'])); } - return format_plural($this->options['items_per_page'], '@count item', '@count items', array('@count' => $this->options['items_per_page'])); + return format_plural($this->options['items_per_page'], '@count item', '@count items', array('@count' => $this->options['items_per_page'])); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['items_per_page'] = array('default' => 10); $options['offset'] = array('default' => 0); @@ -29,7 +36,7 @@ class views_plugin_pager_some extends views_plugin_pager { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $pager_text = $this->display->handler->get_pager_text(); $form['items_per_page'] = array( @@ -47,16 +54,26 @@ class views_plugin_pager_some extends views_plugin_pager { ); } - function use_pager() { + /** + * {@inheritdoc} + */ + public function use_pager() { return FALSE; } - function use_count_query() { + /** + * {@inheritdoc} + */ + public function use_count_query() { return FALSE; } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->view->query->set_limit($this->options['items_per_page']); $this->view->query->set_offset($this->options['offset']); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_query.inc b/sites/all/modules/views/plugins/views_plugin_query.inc index 7418e61..fe45793 100644 --- a/sites/all/modules/views/plugins/views_plugin_query.inc +++ b/sites/all/modules/views/plugins/views_plugin_query.inc @@ -2,7 +2,7 @@ /** * @file - * Defines the base query class, which is the underlying layer in a View. + * Definition of views_plugin_query. */ /** @@ -14,20 +14,21 @@ */ /** - * Object used to create a SELECT query. + * The base query class, which is the underlying layer in a View. */ class views_plugin_query extends views_plugin { + /** * A pager plugin that should be provided by the display. * * @var views_plugin_pager */ - var $pager = NULL; + public $pager = NULL; /** * Constructor; Create the basic query object and fill with default values. */ - function init($base_table, $base_field, $options) { + public function init($base_table, $base_field, $options) { $this->base_table = $base_table; $this->base_field = $base_field; $this->unpack_options($this->options, $options); @@ -37,13 +38,14 @@ class views_plugin_query extends views_plugin { * Generate a query and a countquery from all of the information supplied * to the object. * - * @param $get_count - * Provide a countquery if this is true, otherwise provide a normal query. + * @param bool $get_count + * Provide a countquery if this is TRUE, otherwise provide a normal query. * * @return SelectQuery * A SelectQuery object. */ - function query($get_count = FALSE) { } + public function query($get_count = FALSE) { + } /** * Let modules modify the query just prior to finalizing it. @@ -51,7 +53,8 @@ class views_plugin_query extends views_plugin { * @param view $view * The view which is executed. */ - function alter(&$view) { } + public function alter(&$view) { + } /** * Builds the necessary info to execute the query. @@ -59,7 +62,8 @@ class views_plugin_query extends views_plugin { * @param view $view * The view which is executed. */ - function build(&$view) { } + public function build(&$view) { + } /** * Executes the query and fills the associated view object with according @@ -74,7 +78,8 @@ class views_plugin_query extends views_plugin { * @param view $view * The view which is executed. */ - function execute(&$view) { } + public function execute(&$view) { + } /** * Add a signature to the query, if such a thing is feasible. @@ -85,48 +90,61 @@ class views_plugin_query extends views_plugin { * @param view $view * The view which is executed. */ - function add_signature(&$view) { } + public function add_signature(&$view) { + } /** * Get aggregation info for group by queries. * * If NULL, aggregation is not allowed. */ - function get_aggregation_info() { } + public function get_aggregation_info() { + } /** * Add settings for the ui. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); } - function options_validate(&$form, &$form_state) { } + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { + } - function options_submit(&$form, &$form_state) { } + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { + } - function summary_title() { + /** + * {@inheritdoc} + */ + public function summary_title() { return t('Settings'); } /** * Set a LIMIT on the query, specifying a maximum number of results. */ - function set_limit($limit) { + public function set_limit($limit) { $this->limit = $limit; } /** * Set an OFFSET on the query, specifying a number of results to skip */ - function set_offset($offset) { + public function set_offset($offset) { $this->offset = $offset; } /** * Render the pager, if necessary. */ - function render_pager($exposed_input) { + public function render_pager($exposed_input) { if (!empty($this->pager) && $this->pager->use_pager()) { return $this->pager->render($exposed_input); } @@ -137,18 +155,18 @@ class views_plugin_query extends views_plugin { /** * Create a new grouping for the WHERE or HAVING clause. * - * @param $type + * @param string $type * Either 'AND' or 'OR'. All items within this group will be added * to the WHERE clause with this logical operator. - * @param $group + * @param string $group * An ID to use for this group. If unspecified, an ID will be generated. - * @param $where + * @param string $where * 'where' or 'having'. * - * @return $group + * @return string * The group ID generated. */ - function set_where_group($type = 'AND', $group = NULL, $where = 'where') { + public function set_where_group($type = 'AND', $group = NULL, $where = 'where') { // Set an alias. $groups = &$this->$where; @@ -168,19 +186,20 @@ class views_plugin_query extends views_plugin { /** * Control how all WHERE and HAVING groups are put together. * - * @param $type - * Either 'AND' or 'OR' + * @param string $type + * Either 'AND' or 'OR'. */ - function set_group_operator($type = 'AND') { + public function set_group_operator($type = 'AND') { $this->group_operator = strtoupper($type); } /** * Returns the according entity objects for the given query results. */ - function get_result_entities($results, $relationship = NULL) { + public function get_result_entities($results, $relationship = NULL) { return FALSE; } + } /** diff --git a/sites/all/modules/views/plugins/views_plugin_query_default.inc b/sites/all/modules/views/plugins/views_plugin_query_default.inc index 99e0f0e..db3e7e2 100644 --- a/sites/all/modules/views/plugins/views_plugin_query_default.inc +++ b/sites/all/modules/views/plugins/views_plugin_query_default.inc @@ -2,7 +2,7 @@ /** * @file - * Defines the default query object. + * Definition of views_plugin_query_default. */ /** @@ -15,95 +15,98 @@ class views_plugin_query_default extends views_plugin_query { /** * A list of tables in the order they should be added, keyed by alias. */ - var $table_queue = array(); + public $table_queue = array(); /** - * Holds an array of tables and counts added so that we can create aliases + * Holds an array of tables and counts added so that we can create aliases. */ - var $tables = array(); + public $tables = array(); /** * Holds an array of relationships, which are aliases of the primary * table that represent different ways to join the same table in. */ - var $relationships = array(); + public $relationships = array(); /** * An array of sections of the WHERE query. Each section is in itself * an array of pieces and a flag as to whether or not it should be AND * or OR. */ - var $where = array(); + public $where = array(); + /** * An array of sections of the HAVING query. Each section is in itself * an array of pieces and a flag as to whether or not it should be AND * or OR. */ - var $having = array(); + public $having = array(); + /** * The default operator to use when connecting the WHERE groups. May be * AND or OR. */ - var $group_operator = 'AND'; + public $group_operator = 'AND'; /** * A simple array of order by clauses. */ - var $orderby = array(); + public $orderby = array(); /** * A simple array of group by clauses. */ - var $groupby = array(); - + public $groupby = array(); /** * An array of fields. */ - var $fields = array(); - + public $fields = array(); /** * The table header to use for tablesort. This matters because tablesort * needs to modify the query and needs the header. */ - var $header = array(); + public $header = array(); /** * A flag as to whether or not to make the primary field distinct. */ - var $distinct = FALSE; + public $distinct = FALSE; - var $has_aggregate = FALSE; + /** + * + */ + public $has_aggregate = FALSE; /** * Should this query be optimized for counts, for example no sorts. */ - var $get_count_optimized = NULL; + public $get_count_optimized = NULL; /** * The current used pager plugin. * * @var views_plugin_pager */ - var $pager = NULL; + public $pager = NULL; - /** + /** * An array mapping table aliases and field names to field aliases. */ - var $field_aliases = array(); + public $field_aliases = array(); - /** + /** * Query tags which will be passed over to the dbtng query object. */ - var $tags = array(); + public $tags = array(); /** * Is the view marked as not distinct. * * @var bool */ - var $no_distinct; + public $no_distinct; /** * Defines the distinct type. @@ -115,20 +118,21 @@ class views_plugin_query_default extends views_plugin_query { public $pure_distinct = FALSE; /** - * Constructor; Create the basic query object and fill with default values. + * {@inheritdoc} */ - function init($base_table = 'node', $base_field = 'nid', $options) { + public function init($base_table = 'node', $base_field = 'nid', $options) { parent::init($base_table, $base_field, $options); - $this->base_table = $base_table; // Predefine these above, for clarity. + $this->base_table = $base_table; + // Predefine these above, for clarity. $this->base_field = $base_field; $this->relationships[$base_table] = array( 'link' => NULL, 'table' => $base_table, 'alias' => $base_table, - 'base' => $base_table + 'base' => $base_table, ); - // init the table queue with our primary table. + // Unit the table queue with our primary table. $this->table_queue[$base_table] = array( 'alias' => $base_table, 'table' => $base_table, @@ -136,22 +140,20 @@ class views_plugin_query_default extends views_plugin_query { 'join' => NULL, ); - // init the tables with our primary table + // Init the tables with our primary table. $this->tables[$base_table][$base_table] = array( 'count' => 1, 'alias' => $base_table, ); -/** - * -- we no longer want the base field to appear automatically. - if ($base_field) { - $this->fields[$base_field] = array( - 'table' => $base_table, - 'field' => $base_field, - 'alias' => $base_field, - ); - } - */ + // We no longer want the base field to appear automatically. + // if ($base_field) { + // $this->fields[$base_field] = array( + // 'table' => $base_table, + // 'field' => $base_field, + // 'alias' => $base_field, + // ); + // } $this->count_field = array( 'table' => $base_table, @@ -161,8 +163,9 @@ class views_plugin_query_default extends views_plugin_query { ); } - // ---------------------------------------------------------------- - // Utility methods to set flags and data. + /** + * Utility methods to set flags and data. + */ /** * Set the view to be distinct. @@ -175,7 +178,7 @@ class views_plugin_query_default extends views_plugin_query { * @param bool $pure_distinct * Should only the sql keyword be added. */ - function set_distinct($value = TRUE, $pure_distinct = FALSE) { + public function set_distinct($value = TRUE, $pure_distinct = FALSE) { if (!(isset($this->no_distinct) && $value)) { $this->distinct = $value; $this->pure_distinct = $pure_distinct; @@ -185,7 +188,7 @@ class views_plugin_query_default extends views_plugin_query { /** * Set what field the query will count() on for paging. */ - function set_count_field($table, $field, $alias = NULL) { + public function set_count_field($table, $field, $alias = NULL) { if (empty($alias)) { $alias = $table . '_' . $field; } @@ -198,14 +201,19 @@ class views_plugin_query_default extends views_plugin_query { } /** - * Set the table header; used for click-sorting because it's needed - * info to modify the ORDER BY clause. + * Set the table header. + * + * Used for click-sorting because it's needed info to modify the ORDER BY + * clause. */ - function set_header($header) { + public function set_header($header) { $this->header = $header; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['disable_sql_rewrite'] = array( 'default' => FALSE, @@ -237,16 +245,29 @@ class views_plugin_query_default extends views_plugin_query { /** * Add settings for the ui. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); - $form['disable_sql_rewrite'] = array( - '#title' => t('Disable SQL rewriting'), - '#description' => t('Disabling SQL rewriting will disable node_access checks as well as other modules that implement hook_query_alter().'), - '#type' => 'checkbox', - '#default_value' => !empty($this->options['disable_sql_rewrite']), - '#suffix' => '
    ' . t('WARNING: Disabling SQL rewriting means that node access security is disabled. This may allow users to see data they should not be able to see if your view is misconfigured. Please use this option only if you understand and accept this security risk.') . '
    ', - ); + // Establish which query tag will be affected by disable_sql_rewrite. + // This 'access query tag' is defined by hook_views_data() for the base table. + // e.g. node_views_data() + if (!empty($form_state['view']->base_table)) { + $base_table = $form_state['view']->base_table; + $base_table_data = views_fetch_data($base_table); + if (!empty($base_table_data['table']['base']['access query tag'])) { + $access_tag = $base_table_data['table']['base']['access query tag']; + $disable_rewrite = !empty($this->options['disable_sql_rewrite']); + $form['disable_sql_rewrite'] = array( + '#title' => t('Disable access checks'), + '#description' => t('Do not apply %access_tag checks to this query. Selecting this option omits that tag from the alterable query.', array('%access_tag' => $access_tag)), + '#type' => 'checkbox', + '#default_value' => $disable_rewrite, + '#suffix' => '
    ' + . t('WARNING: Disabling access checks means that %access_tag security is disabled. This may allow users to see data they should not be able to see if your view is misconfigured. Please use this option only if you understand and accept this security risk.', array('%access_tag' => $access_tag)) + . '
    ', + ); + } + } $form['distinct'] = array( '#type' => 'checkbox', '#title' => t('Distinct'), @@ -284,45 +305,45 @@ class views_plugin_query_default extends views_plugin_query { /** * Special submit handling. */ - function options_submit(&$form, &$form_state) { + public function options_submit(&$form, &$form_state) { $element = array('#parents' => array('query', 'options', 'query_tags')); $value = explode(',', drupal_array_get_nested_value($form_state['values'], $element['#parents'])); $value = array_filter(array_map('trim', $value)); form_set_value($element, $value, $form_state); } - // ---------------------------------------------------------------- - // Table/join adding + /** + * Table/join adding. + */ /** - * A relationship is an alternative endpoint to a series of table - * joins. Relationships must be aliases of the primary table and - * they must join either to the primary table or to a pre-existing - * relationship. + * A relationship is an alternative endpoint to a series of table joins. * - * An example of a relationship would be a nodereference table. - * If you have a nodereference named 'book_parent' which links to a - * parent node, you could set up a relationship 'node_book_parent' - * to 'node'. Then, anything that links to 'node' can link to - * 'node_book_parent' instead, thus allowing all properties of - * both nodes to be available in the query. + * Relationships must be aliases of the primary table and they must join + * either to the primary table or to a pre-existing relationship. * - * @param $alias - * What this relationship will be called, and is also the alias - * for the table. + * An example of a relationship would be a nodereference table. If you have a + * nodereference named 'book_parent' which links to a parent node, you could + * set up a relationship 'node_book_parent' to 'node'. Then, anything that + * links to 'node' can link to 'node_book_parent' instead, thus allowing all + * properties of both nodes to be available in the query. + * + * @param string $alias + * What this relationship will be called, and is also the alias for the + * table. * @param views_join $join * A views_join object (or derived object) to join the alias in. - * @param $base - * The name of the 'base' table this relationship represents; this - * tells the join search which path to attempt to use when finding - * the path to this relationship. - * @param $link_point - * If this relationship links to something other than the primary - * table, specify that table here. For example, a 'track' node - * might have a relationship to an 'album' node, which might - * have a relationship to an 'artist' node. + * @param string $base + * The name of the 'base' table this relationship represents; this tells the + * join search which path to attempt to use when finding the path to this + * relationship. + * @param string $link_point + * If this relationship links to something other than the primary table, + * specify that table here. For example, a 'track' node might have a + * relationship to an 'album' node, which might have a relationship to an + * 'artist' node. */ - function add_relationship($alias, $join, $base, $link_point = NULL) { + public function add_relationship($alias, $join, $base, $link_point = NULL) { if (empty($link_point)) { $link_point = $this->base_table; } @@ -342,8 +363,7 @@ class views_plugin_query_default extends views_plugin_query { $join = $this->adjust_join($join, $link_point); } - // Add the table directly to the queue to avoid accidentally marking - // it. + // Add the table directly to the queue to avoid accidentally marking it. $this->table_queue[$alias] = array( 'table' => $join->table, 'num' => 1, @@ -369,34 +389,34 @@ class views_plugin_query_default extends views_plugin_query { /** * Add a table to the query, ensuring the path exists. * - * This function will test to ensure that the path back to the primary - * table is valid and exists; if you do not wish for this testing to - * occur, use $query->queue_table() instead. + * This function will test to ensure that the path back to the primary table + * is valid and exists; if you do not wish for this testing to occur, use + * $query->queue_table() instead. * - * @param $table + * @param string $table * The name of the table to add. It needs to exist in the global table * array. - * @param $relationship - * An alias of a table; if this is set, the path back to this table will - * be tested prior to adding the table, making sure that all intermediary - * tables exist and are properly aliased. If set to NULL the path to - * the primary table will be ensured. If the path cannot be made, the - * table will NOT be added. + * @param string $relationship + * An alias of a table; if this is set, the path back to this table will be + * tested prior to adding the table, making sure that all intermediary + * tables exist and are properly aliased. If set to NULL the path to the + * primary table will be ensured. If the path cannot be made, the table + * will NOT be added. * @param views_join $join - * In some join configurations this table may actually join back through - * a different method; this is most likely to be used when tracing - * a hierarchy path. (node->parent->parent2->parent3). This parameter - * will specify how this table joins if it is not the default. - * @param $alias + * In some join configurations this table may actually join back through a + * different method; this is most likely to be used when tracing a + * hierarchy path. (node->parent->parent2->parent3). This parameter will + * specify how this table joins if it is not the default. + * @param string $alias * A specific alias to use, rather than the default alias. * - * @return $alias + * @return string * The alias of the table; this alias can be used to access information * about the table and should always be used to refer to the table when * adding parts to the query. Or FALSE if the table was not able to be * added. */ - function add_table($table, $relationship = NULL, $join = NULL, $alias = NULL) { + public function add_table($table, $relationship = NULL, $join = NULL, $alias = NULL) { if (!$this->ensure_path($table, $relationship, $join)) { return FALSE; } @@ -415,27 +435,27 @@ class views_plugin_query_default extends views_plugin_query { * ensure_table() should be used instead of this one, unless you are * absolutely sure this is what you want. * - * @param $table + * @param string $table * The name of the table to add. It needs to exist in the global table * array. - * @param $relationship + * @param string $relationship * The primary table alias this table is related to. If not set, the * primary table will be used. * @param views_join $join - * In some join configurations this table may actually join back through - * a different method; this is most likely to be used when tracing - * a hierarchy path. (node->parent->parent2->parent3). This parameter - * will specify how this table joins if it is not the default. - * @param $alias + * In some join configurations this table may actually join back through a + * different method; this is most likely to be used when tracing a + * hierarchy path. (node->parent->parent2->parent3). This parameter will + * specify how this table joins if it is not the default. + * @param string $alias * A specific alias to use, rather than the default alias. * - * @return $alias + * @return string * The alias of the table; this alias can be used to access information * about the table and should always be used to refer to the table when * adding parts to the query. Or FALSE if the table was not able to be * added. */ - function queue_table($table, $relationship = NULL, $join = NULL, $alias = NULL) { + public function queue_table($table, $relationship = NULL, $join = NULL, $alias = NULL) { // If the alias is set, make sure it doesn't already exist. if (isset($this->table_queue[$alias])) { return $alias; @@ -458,8 +478,8 @@ class views_plugin_query_default extends views_plugin_query { } } - // Check this again to make sure we don't blow up existing aliases for already - // adjusted joins. + // Check this again to make sure we don't blow up existing aliases for + // already adjusted joins. if (isset($this->table_queue[$alias])) { return $alias; } @@ -471,8 +491,8 @@ class views_plugin_query_default extends views_plugin_query { $alias = $this->tables[$relationship][$table]['alias'] . $this->tables[$relationship][$table]['count']; } - // If this is a relationship based table, add a marker with - // the relationship as a primary table for the alias. + // If this is a relationship based table, add a marker with the + // relationship as a primary table for the alias. if ($table != $alias) { $this->mark_table($alias, $this->base_table, $alias); } @@ -498,14 +518,17 @@ class views_plugin_query_default extends views_plugin_query { return $alias; } - function mark_table($table, $relationship, $alias) { + /** + * + */ + public function mark_table($table, $relationship, $alias) { // Mark that this table has been added. if (empty($this->tables[$relationship][$table])) { if (!isset($alias)) { $alias = ''; if ($relationship != $this->base_table) { - // double underscore will help prevent accidental name - // space collisions. + // Double underscore will help prevent accidental name space + // collisions. $alias = $relationship . '__'; } $alias .= $table; @@ -523,33 +546,33 @@ class views_plugin_query_default extends views_plugin_query { } /** - * Ensure a table exists in the queue; if it already exists it won't - * do anything, but if it doesn't it will add the table queue. It will ensure - * a path leads back to the relationship table. + * Ensure a table exists in the queue; if it already exists it won't do + * anything, but if it doesn't it will add the table queue. It will ensure a + * path leads back to the relationship table. * - * @param $table + * @param string $table * The unaliased name of the table to ensure. - * @param $relationship + * @param string $relationship * The relationship to ensure the table links to. Each relationship will - * get a unique instance of the table being added. If not specified, - * will be the primary table. + * get a unique instance of the table being added. If not specified, will + * be the primary table. * @param views_join $join * A views_join object (or derived object) to join the alias in. * - * @return + * @return string * The alias used to refer to this specific table, or NULL if the table * cannot be ensured. */ - function ensure_table($table, $relationship = NULL, $join = NULL) { - // ensure a relationship + public function ensure_table($table, $relationship = NULL, $join = NULL) { + // Ensure a relationship. if (empty($relationship)) { $relationship = $this->base_table; } // If the relationship is the primary table, this actually be a relationship - // link back from an alias. We store all aliases along with the primary table - // to detect this state, because eventually it'll hit a table we already - // have and that's when we want to stop. + // link back from an alias. We store all aliases along with the primary + // table to detect this state, because eventually it'll hit a table we + // already have and that's when we want to stop. if ($relationship == $this->base_table && !empty($this->tables[$relationship][$table])) { return $this->tables[$relationship][$table]['alias']; } @@ -578,31 +601,28 @@ class views_plugin_query_default extends views_plugin_query { $join = $this->adjust_join($join, $relationship); if ($this->ensure_path($table, $relationship, $join)) { - // Attempt to eliminate redundant joins. If this table's - // relationship and join exactly matches an existing table's - // relationship and join, we do not have to join to it again; - // just return the existing table's alias. See - // http://groups.drupal.org/node/11288 for details. + // Attempt to eliminate redundant joins. If this table's relationship + // and join exactly matches an existing table's relationship and join, we + // do not have to join to it again; just return the existing table's + // alias. + // @see http://groups.drupal.org/node/11288 // - // This can be done safely here but not lower down in - // queue_table(), because queue_table() is also used by - // add_table() which requires the ability to intentionally add - // the same table with the same join multiple times. For - // example, a view that filters on 3 taxonomy terms using AND - // needs to join taxonomy_term_data 3 times with the same join. - + // This can be done safely here but not lower down in queue_table(), + // because queue_table() is also used by add_table() which requires the + // ability to intentionally add the same table with the same join + // multiple times. For example, a view that filters on 3 taxonomy terms + // using AND needs to join taxonomy_term_data 3 times with the same join. // scan through the table queue to see if a matching join and // relationship exists. If so, use it instead of this join. - - // TODO: Scanning through $this->table_queue results in an - // O(N^2) algorithm, and this code runs every time the view is - // instantiated (Views 2 does not currently cache queries). - // There are a couple possible "improvements" but we should do - // some performance testing before picking one. + // @todo Scanning through $this->table_queue results in an O(N^2) + // algorithm, and this code runs every time the view is instantiated + // (Views 2 does not currently cache queries). There are a couple + // possible "improvements" but we should do some performance testing + // before picking one. foreach ($this->table_queue as $queued_table) { - // In PHP 4 and 5, the == operation returns TRUE for two objects - // if they are instances of the same class and have the same - // attributes and values. + // In PHP 4 and 5, the == operation returns TRUE for two objects if + // they are instances of the same class and have the same attributes + // and values. if ($queued_table['relationship'] == $relationship && $queued_table['join'] == $join) { return $queued_table['alias']; } @@ -614,12 +634,12 @@ class views_plugin_query_default extends views_plugin_query { /** * Make sure that the specified table can be properly linked to the primary - * table in the JOINs. This function uses recursion. If the tables - * needed to complete the path back to the primary table are not in the - * query they will be added, but additional copies will NOT be added - * if the table is already there. + * table in the JOINs. This function uses recursion. If the tables needed + * to complete the path back to the primary table are not in the query they + * will be added, but additional copies will NOT be added if the table is + * already there. */ - function ensure_path($table, $relationship = NULL, $join = NULL, $traced = array(), $add = array()) { + public function ensure_path($table, $relationship = NULL, $join = NULL, $traced = array(), $add = array()) { if (!isset($relationship)) { $relationship = $this->base_table; } @@ -652,7 +672,7 @@ class views_plugin_query_default extends views_plugin_query { // Have we been this way? if (isset($traced[$join->left_table])) { - // we looped. Broked. + // We looped. Broked. return FALSE; } @@ -668,10 +688,12 @@ class views_plugin_query_default extends views_plugin_query { } /** - * Fix a join to adhere to the proper relationship; the left table can vary - * based upon what relationship items are joined in on. + * Fix a join to adhere to the proper relationship. + * + * The left table can vary based upon what relationship items are joined in + * on. */ - function adjust_join($join, $relationship) { + public function adjust_join($join, $relationship) { if (!empty($join->adjusted)) { return $join; } @@ -683,9 +705,8 @@ class views_plugin_query_default extends views_plugin_query { // Adjusts the left table for our relationship. if ($relationship != $this->base_table) { // If we're linking to the primary table, the relationship to use will - // be the prior relationship. Unless it's a direct link. - - // Safety! Don't modify an original here. + // be the prior relationship. Unless it's a direct link. Safety! Don't + // modify an original here. $join = clone $join; // Do we need to try to ensure a path? @@ -695,7 +716,8 @@ class views_plugin_query_default extends views_plugin_query { $this->ensure_table($join->left_table, $relationship); } - // First, if this is our link point/anchor table, just use the relationship + // First, if this is our link point/anchor table, just use the + // relationship. if ($join->left_table == $this->relationships[$relationship]['table']) { $join->left_table = $relationship; } @@ -716,15 +738,15 @@ class views_plugin_query_default extends views_plugin_query { /** * Retrieve join data from the larger join data cache. * - * @param $table + * @param string $table * The table to get the join information for. - * @param $base_table + * @param string $base_table * The path we're following to get this join. * * @return views_join * A views_join object or child object, if one exists. */ - function get_join_data($table, $base_table) { + public function get_join_data($table, $base_table) { // Check to see if we're linking to a known alias. If so, get the real // table's data instead. if (!empty($this->table_queue[$table])) { @@ -739,7 +761,7 @@ class views_plugin_query_default extends views_plugin_query { * If you need the alias of a table with a particular relationship, use * ensure_table(). */ - function get_table_info($table) { + public function get_table_info($table) { if (!empty($this->table_queue[$table])) { return $this->table_queue[$table]; } @@ -755,27 +777,26 @@ class views_plugin_query_default extends views_plugin_query { /** * Add a field to the query table, possibly with an alias. This will - * automatically call ensure_table to make sure the required table - * exists, *unless* $table is unset. + * automatically call ensure_table to make sure the required table exists, + * *unless* $table is unset. * - * @param $table - * The table this field is attached to. If NULL, it is assumed this will - * be a formula; otherwise, ensure_table is used to make sure the - * table exists. - * @param $field + * @param string $table + * The table this field is attached to. If NULL, it is assumed this will be + * a formula; otherwise, ensure_table is used to make sure the table exists. + * @param string $field * The name of the field to add. This may be a real field or a formula. - * @param $alias + * @param string $alias * The alias to create. If not specified, the alias will be $table_$field * unless $table is NULL. When adding formulae, it is recommended that an * alias be used. - * @param $params + * @param array $params * An array of parameters additional to the field that will control items * such as aggregation functions and DISTINCT. * - * @return $name - * The name that this field can be referred to as. Usually this is the alias. + * @return string + * The name that this field can be referred to as, usually the alias. */ - function add_field($table, $field, $alias = '', $params = array()) { + public function add_field($table, $field, $alias = '', $params = array()) { // We check for this specifically because it gets a special alias. if ($table == $this->base_table && $field == $this->base_field && empty($alias)) { $alias = $this->base_field; @@ -789,13 +810,13 @@ class views_plugin_query_default extends views_plugin_query { $alias = $table . '_' . $field; } - // Make sure an alias is assigned + // Make sure an alias is assigned. $alias = $alias ? $alias : $field; - // PostgreSQL truncates aliases to 63 characters: http://drupal.org/node/571548 - + // PostgreSQL truncates aliases to 63 characters. + // @see http://drupal.org/node/571548 // We limit the length of the original alias up to 60 characters - // to get a unique alias later if its have duplicates + // to get a unique alias later if its have duplicates. $alias = strtolower(substr($alias, 0, 60)); // Create a field info array. @@ -805,9 +826,9 @@ class views_plugin_query_default extends views_plugin_query { 'alias' => $alias, ) + $params; - // Test to see if the field is actually the same or not. Due to - // differing parameters changing the aggregation function, we need - // to do some automatic alias collision detection: + // Test to see if the field is actually the same or not. Due to differing + // parameters changing the aggregation function, we need to do some + // automatic alias collision detection. $base = $alias; $counter = 0; while (!empty($this->fields[$alias]) && $this->fields[$alias] != $field_info) { @@ -825,35 +846,40 @@ class views_plugin_query_default extends views_plugin_query { } /** - * Remove all fields that may've been added; primarily used for summary - * mode where we're changing the query because we didn't get data we needed. + * Remove all fields that may've been added. + * + * Primarily used for summary mode where we're changing the query because we + * didn't get data we needed. */ - function clear_fields() { + public function clear_fields() { $this->fields = array(); } /** - * Add a simple WHERE clause to the query. The caller is responsible for - * ensuring that all fields are fully qualified (TABLE.FIELD) and that - * the table already exists in the query. + * Add a simple WHERE clause to the query. * - * @param $group + * The caller is responsible for ensuring that all fields are fully qualified + * (TABLE.FIELD) and that the table already exists in the query. + * + * @param string $group * The WHERE group to add these to; groups are used to create AND/OR - * sections. Groups cannot be nested. Use 0 as the default group. - * If the group does not yet exist it will be created as an AND group. - * @param $field + * sections. Groups cannot be nested. Use 0 as the default group. If the + * group does not yet exist it will be created as an AND group. + * @param string $field * The name of the field to check. - * @param $value - * The value to test the field against. In most cases, this is a scalar. For more - * complex options, it is an array. The meaning of each element in the array is - * dependent on the $operator. - * @param $operator - * The comparison operator, such as =, <, or >=. It also accepts more complex - * options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array - * = otherwise. If $field is a string you have to use 'formula' here. + * @param string $value + * The value to test the field against. In most cases, this is a scalar. For + * more complex options, it is an array. The meaning of each element in the + * array is dependent on the $operator. + * @param string $operator + * The comparison operator, such as =, <, or >=. It also accepts more + * complex options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is + * an array = otherwise. If $field is a string you have to use 'formula' + * here. * * The $field, $value and $operator arguments can also be passed in with a * single DatabaseCondition object, like this: + * * @code * $this->query->add_where( * $this->options['group'], @@ -866,9 +892,9 @@ class views_plugin_query_default extends views_plugin_query { * @see QueryConditionInterface::condition() * @see DatabaseCondition */ - function add_where($group, $field, $value = NULL, $operator = NULL) { - // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all - // the default group. + public function add_where($group, $field, $value = NULL, $operator = NULL) { + // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all the + // default group. if (empty($group)) { $group = 0; } @@ -889,22 +915,22 @@ class views_plugin_query_default extends views_plugin_query { * Add a complex WHERE clause to the query. * * The caller is responsible for ensuring that all fields are fully qualified - * (TABLE.FIELD) and that the table already exists in the query. - * Internally the dbtng method "where" is used. + * (TABLE.FIELD) and that the table already exists in the query. Internally + * the dbtng method "where" is used. * - * @param $group + * @param string $group * The WHERE group to add these to; groups are used to create AND/OR - * sections. Groups cannot be nested. Use 0 as the default group. - * If the group does not yet exist it will be created as an AND group. - * @param $snippet - * The snippet to check. This can be either a column or - * a complex expression like "UPPER(table.field) = 'value'" - * @param $args + * sections. Groups cannot be nested. Use 0 as the default group. If the + * group does not yet exist it will be created as an AND group. + * @param string $snippet + * The snippet to check. This can be either a column or a complex expression + * like "UPPER(table.field) = 'value'". + * @param array $args * An associative array of arguments. * * @see QueryConditionInterface::where() */ - function add_where_expression($group, $snippet, $args = array()) { + public function add_where_expression($group, $snippet, $args = array()) { // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all // the default group. if (empty($group)) { @@ -927,29 +953,30 @@ class views_plugin_query_default extends views_plugin_query { * Add a simple HAVING clause to the query. * * The caller is responsible for ensuring that all fields are fully qualified - * (TABLE.FIELD) and that the table and an appropriate GROUP BY already exist in the query. - * Internally the dbtng method "havingCondition" is used. + * (TABLE.FIELD) and that the table and an appropriate GROUP BY already exist + * in the query. Internally the dbtng method "havingCondition" is used. * - * @param $group + * @param string $group * The HAVING group to add these to; groups are used to create AND/OR - * sections. Groups cannot be nested. Use 0 as the default group. - * If the group does not yet exist it will be created as an AND group. - * @param $field + * sections. Groups cannot be nested. Use 0 as the default group. If the + * group does not yet exist it will be created as an AND group. + * @param string $field * The name of the field to check. - * @param $value - * The value to test the field against. In most cases, this is a scalar. For more - * complex options, it is an array. The meaning of each element in the array is - * dependent on the $operator. - * @param $operator - * The comparison operator, such as =, <, or >=. It also accepts more complex - * options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array - * = otherwise. If $field is a string you have to use 'formula' here. + * @param string $value + * The value to test the field against. In most cases, this is a scalar. For + * more complex options, it is an array. The meaning of each element in the + * array is dependent on the $operator. + * @param string $operator + * The comparison operator, such as =, <, or >=. It also accepts more + * complex options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is + * an array = otherwise. If $field is a string you have to use 'formula' + * here. * * @see SelectQueryInterface::havingCondition() */ - function add_having($group, $field, $value = NULL, $operator = NULL) { - // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all - // the default group. + public function add_having($group, $field, $value = NULL, $operator = NULL) { + // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all the + // default group. if (empty($group)) { $group = 0; } @@ -969,23 +996,24 @@ class views_plugin_query_default extends views_plugin_query { /** * Add a complex HAVING clause to the query. - * The caller is responsible for ensuring that all fields are fully qualified - * (TABLE.FIELD) and that the table and an appropriate GROUP BY already exist in the query. - * Internally the dbtng method "having" is used. * - * @param $group + * The caller is responsible for ensuring that all fields are fully qualified + * (TABLE.FIELD) and that the table and an appropriate GROUP BY already exist + * in the query. Internally the dbtng method "having" is used. + * + * @param string $group * The HAVING group to add these to; groups are used to create AND/OR - * sections. Groups cannot be nested. Use 0 as the default group. - * If the group does not yet exist it will be created as an AND group. - * @param $snippet - * The snippet to check. This can be either a column or - * a complex expression like "COUNT(table.field) > 3" - * @param $args + * sections. Groups cannot be nested. Use 0 as the default group. If the + * group does not yet exist it will be created as an AND group. + * @param string $snippet + * The snippet to check. This can be either a column or a complex + * expression like "COUNT(table.field) > 3" + * @param array $args * An associative array of arguments. * * @see QueryConditionInterface::having() */ - function add_having_expression($group, $snippet, $args = array()) { + public function add_having_expression($group, $snippet, $args = array()) { // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all // the default group. if (empty($group)) { @@ -1008,31 +1036,32 @@ class views_plugin_query_default extends views_plugin_query { /** * Add an ORDER BY clause to the query. * - * @param $table - * The table this field is part of. If a formula, enter NULL. - * If you want to orderby random use "rand" as table and nothing else. - * @param $field - * The field or formula to sort on. If already a field, enter NULL - * and put in the alias. - * @param $order + * @param string $table + * The table this field is part of. If a formula, enter NULL. If you want to + * orderby random use "rand" as table and nothing else. + * @param string $field + * The field or formula to sort on. If already a field, enter NULL and put + * in the alias. + * @param string $order * Either ASC or DESC. - * @param $alias - * The alias to add the field as. In SQL, all fields in the order by - * must also be in the SELECT portion. If an $alias isn't specified - * one will be generated for from the $field; however, if the - * $field is a formula, this alias will likely fail. - * @param $params + * @param string $alias + * The alias to add the field as. In SQL, all fields in the order by must + * also be in the SELECT portion. If an $alias isn't specified one will be + * generated for from the $field; however, if the $field is a formula, this + * alias will likely fail. + * @param string $params * Any params that should be passed through to the add_field. */ - function add_orderby($table, $field = NULL, $order = 'ASC', $alias = '', $params = array()) { + public function add_orderby($table, $field = NULL, $order = 'ASC', $alias = '', $params = array()) { // Only ensure the table if it's not the special random key. - // @todo: Maybe it would make sense to just add a add_orderby_rand or something similar. + // @todo Maybe it would make sense to just add a add_orderby_rand or + // something similar. if ($table && $table != 'rand') { $this->ensure_table($table); } - // Only fill out this aliasing if there is a table; - // otherwise we assume it is a formula. + // Only fill out this aliasing if there is a table; otherwise we assume it + // is a formula. if (!$alias && $table) { $as = $table . '_' . $field; } @@ -1046,27 +1075,17 @@ class views_plugin_query_default extends views_plugin_query { $this->orderby[] = array( 'field' => $as, - 'direction' => strtoupper($order) + 'direction' => strtoupper($order), ); - - /** - * -- removing, this should be taken care of by field adding now. - * -- leaving commented because I am unsure. - // If grouping, all items in the order by must also be in the - // group by clause. Check $table to ensure that this is not a - // formula. - if ($this->groupby && $table) { - $this->add_groupby($as); - } - */ } /** - * Add a simple GROUP BY clause to the query. The caller is responsible - * for ensuring that the fields are fully qualified and the table is properly - * added. + * Add a simple GROUP BY clause to the query. + * + * The caller is responsible for ensuring that the fields are fully qualified + * and the table is properly added. */ - function add_groupby($clause) { + public function add_groupby($clause) { // Only add it if it's not already in there. if (!in_array($clause, $this->groupby)) { $this->groupby[] = $clause; @@ -1078,7 +1097,7 @@ class views_plugin_query_default extends views_plugin_query { * * @see views_plugin_query_default::add_field() */ - function get_field_alias($table_alias, $field) { + public function get_field_alias($table_alias, $field) { return isset($this->field_aliases[$table_alias][$field]) ? $this->field_aliases[$table_alias][$field] : FALSE; } @@ -1087,14 +1106,14 @@ class views_plugin_query_default extends views_plugin_query { * * @see SelectQuery::addTag() */ - function add_tag($tag) { + public function add_tag($tag) { $this->tags[] = $tag; } /** * Generates a unique placeholder used in the db query. */ - function placeholder($base = 'views') { + public function placeholder($base = 'views') { static $placeholders = array(); if (!isset($placeholders[$base])) { $placeholders[$base] = 0; @@ -1113,10 +1132,10 @@ class views_plugin_query_default extends views_plugin_query { * There is other code in filters which makes sure that the group IDs are * higher than zero. * - * @param $where - * 'where' or 'having'. + * @param string $where + * Either 'where' or 'having'. */ - function build_condition($where = 'where') { + public function build_condition($where = 'where') { $has_condition = FALSE; $has_arguments = FALSE; $has_filter = FALSE; @@ -1130,8 +1149,9 @@ class views_plugin_query_default extends views_plugin_query { $sub_group = $info['type'] == 'OR' ? db_or() : db_and(); foreach ($info['conditions'] as $key => $clause) { // DBTNG doesn't support to add the same subquery twice to the main - // query and the count query, so clone the subquery to have two instances - // of the same object. - http://drupal.org/node/1112854 + // query and the count query, so clone the subquery to have two + // instances of the same object. + // @see http://drupal.org/node/1112854 if (is_object($clause['value']) && $clause['value'] instanceof SelectQuery) { $clause['value'] = clone $clause['value']; } @@ -1172,7 +1192,7 @@ class views_plugin_query_default extends views_plugin_query { /** * Build fields array. */ - function compile_fields($fields_array, $query) { + public function compile_fields($fields_array, $query) { $non_aggregates = array(); foreach ($fields_array as $field) { $string = ''; @@ -1187,7 +1207,7 @@ class views_plugin_query_default extends views_plugin_query { } if (!empty($field['count'])) { - // Retained for compatibility + // Retained for compatibility. $field['function'] = 'count'; // It seems there's no way to abstract the table+column reference // without adding a field, aliasing, and then using the alias. @@ -1205,7 +1225,12 @@ class views_plugin_query_default extends views_plugin_query { } // This is a formula, using no tables. elseif (empty($field['table'])) { - $non_aggregates[] = $fieldname; + if (Database::getConnection()->databaseType() != 'pgsql') { + $non_aggregates[] = $fieldname; + } + elseif (!in_array($fieldname, $non_aggregates)) { + $non_aggregates[] = $fieldname; + } $placeholders = !empty($field['placeholders']) ? $field['placeholders'] : array(); $query->addExpression($string, $fieldname, $placeholders); } @@ -1213,14 +1238,22 @@ class views_plugin_query_default extends views_plugin_query { elseif ($this->distinct && !in_array($fieldname, $this->groupby)) { // d7cx: This code was there, apparently needed for PostgreSQL // $string = db_driver() == 'pgsql' ? "FIRST($string)" : $string; + if (Database::getConnection()->databaseType() == 'pgsql' && !in_array($string, $non_aggregates)) { + $non_aggregates[] = $string; + } $query->addField(!empty($field['table']) ? $field['table'] : $this->base_table, $field['field'], $fieldname); } elseif (empty($field['aggregate'])) { - $non_aggregates[] = $fieldname; + if (Database::getConnection()->databaseType() != 'pgsql') { + $non_aggregates[] = $fieldname; + } + elseif (!in_array($string, $non_aggregates)) { + $non_aggregates[] = $string; + } $query->addField(!empty($field['table']) ? $field['table'] : $this->base_table, $field['field'], $fieldname); } - // @TODO Remove this old code. + // @todo Remove this old code. if (!empty($field['distinct']) && empty($field['function'])) { $distinct[] = $string; } @@ -1242,26 +1275,25 @@ class views_plugin_query_default extends views_plugin_query { * Generate a query and a countquery from all of the information supplied * to the object. * - * @param $get_count + * @param bool $get_count * Provide a countquery if this is true, otherwise provide a normal query. * * @return SelectQuery * A SelectQuery object. */ - function query($get_count = FALSE) { + public function query($get_count = FALSE) { // Check query distinct value. if (empty($this->no_distinct) && $this->distinct && !empty($this->fields)) { - if ($this->pure_distinct === FALSE){ + if ($this->pure_distinct === FALSE) { $base_field_alias = $this->add_field($this->base_table, $this->base_field); $this->add_groupby($base_field_alias); } $distinct = TRUE; } - /** - * An optimized count query includes just the base field instead of all the fields. - * Determine of this query qualifies by checking for a groupby or distinct. - */ + // An optimized count query includes just the base field instead of all the + // fields. Determine of this query qualifies by checking for a groupby or + // distinct. $fields_array = $this->fields; if ($get_count && !$this->groupby) { foreach ($fields_array as $field) { @@ -1281,18 +1313,18 @@ class views_plugin_query_default extends views_plugin_query { $options = array(); $target = 'default'; $key = 'default'; - // Detect an external database and set the + // Detect an external database and set the. if (isset($this->view->base_database)) { $key = $this->view->base_database; } - // Set the slave target if the slave option is set + // Set the slave target if the slave option is set. if (!empty($this->options['slave'])) { $target = 'slave'; } - // Go ahead and build the query. - // db_select doesn't support to specify the key, so use getConnection directly. + // Go ahead and build the query. db_select doesn't support to specify the + // key, so use getConnection directly. $query = Database::getConnection($target, $key) ->select($this->base_table, $this->base_table, $options) ->addTag('views') @@ -1325,8 +1357,9 @@ class views_plugin_query_default extends views_plugin_query { if (count($this->having)) { $this->has_aggregate = TRUE; } - elseif (!$this->has_aggregate) { - // Allow 'GROUP BY' even no aggregation function has been set. + // Allow 'GROUP BY' even if no aggregation function has been set, but only + // when there is a legitimate display_handler. + elseif (!$this->has_aggregate && !empty($this->view->display_handler)) { $this->has_aggregate = $this->view->display_handler->get_option('group_by'); } if ($this->has_aggregate && (!empty($this->groupby) || !empty($non_aggregates))) { @@ -1340,7 +1373,7 @@ class views_plugin_query_default extends views_plugin_query { } if (!$this->get_count_optimized) { - // we only add the orderby if we're not counting. + // We only add the orderby if we're not counting. if ($this->orderby) { foreach ($this->orderby as $order) { if ($order['field'] == 'rand_') { @@ -1374,8 +1407,8 @@ class views_plugin_query_default extends views_plugin_query { if (!$get_count) { if (!empty($this->limit) || !empty($this->offset)) { - // We can't have an offset without a limit, so provide a very large limit - // instead. + // We can't have an offset without a limit, so provide a very large + // limit instead. $limit = intval(!empty($this->limit) ? $this->limit : 999999); $offset = intval(!empty($this->offset) ? $this->offset : 0); $query->range($offset, $limit); @@ -1388,7 +1421,7 @@ class views_plugin_query_default extends views_plugin_query { /** * Get the arguments attached to the WHERE and HAVING clauses of this query. */ - function get_where_args() { + public function get_where_args() { $args = array(); foreach ($this->where as $group => $where) { $args = array_merge($args, $where['args']); @@ -1402,7 +1435,7 @@ class views_plugin_query_default extends views_plugin_query { /** * Let modules modify the query just prior to finalizing it. */ - function alter(&$view) { + public function alter(&$view) { foreach (module_implements('views_query_alter') as $module) { $function = $module . '_views_query_alter'; $function($view, $this); @@ -1412,7 +1445,7 @@ class views_plugin_query_default extends views_plugin_query { /** * Builds the necessary info to execute the query. */ - function build(&$view) { + public function build(&$view) { // Make the query distinct if the option was set. if (!empty($this->options['distinct'])) { $this->set_distinct(TRUE, !empty($this->options['pure_distinct'])); @@ -1437,8 +1470,9 @@ class views_plugin_query_default extends views_plugin_query { * Values to set: $view->result, $view->total_rows, $view->execute_time, * $view->current_page. */ - function execute(&$view) { - $external = FALSE; // Whether this query will run against an external database. + public function execute(&$view) { + // Whether this query will run against an external database. + $external = FALSE; $query = $view->build_info['query']; $count_query = $view->build_info['count_query']; @@ -1462,9 +1496,9 @@ class views_plugin_query_default extends views_plugin_query { // If not, then hook_query_node_access_alter() may munge the count by // adding a distinct against an empty query string // (e.g. COUNT DISTINCT(1) ...) and no pager will return. - // See pager.inc > PagerDefault::execute() - // http://api.drupal.org/api/drupal/includes--pager.inc/function/PagerDefault::execute/7 - // See http://drupal.org/node/1046170. + // @see pager.inc > PagerDefault::execute() + // @see http://api.drupal.org/api/drupal/includes--pager.inc/function/PagerDefault::execute/7 + // @see http://drupal.org/node/1046170. $count_query->preExecute(); // Build the count query. @@ -1480,7 +1514,6 @@ class views_plugin_query_default extends views_plugin_query { $start = microtime(TRUE); - try { if ($this->pager->use_count_query() || !empty($view->get_total_rows)) { $this->pager->execute_count_query($count_query); @@ -1518,12 +1551,18 @@ class views_plugin_query_default extends views_plugin_query { $view->execute_time = microtime(TRUE) - $start; } - function add_signature(&$view) { + /** + * + */ + public function add_signature(&$view) { $view->query->add_field(NULL, "'" . $view->name . ':' . $view->current_display . "'", 'view_name'); } - function get_aggregation_info() { - // @todo -- need a way to get database specific and customized aggregation + /** + * + */ + public function get_aggregation_info() { + // @todo Need a way to get database specific and customized aggregation // functions into here. return array( 'group' => array( @@ -1594,15 +1633,14 @@ class views_plugin_query_default extends views_plugin_query { 'filter' => 'views_handler_filter_group_by_numeric', 'sort' => 'views_handler_sort_group_by_numeric', ), - ) + ), ) + views_fetch_plugin_data('query_aggregate'); } /** * Returns the according entity objects for the given query results. - * */ - function get_result_entities($results, $relationship = NULL) { + public function get_result_entities($results, $relationship = NULL) { $base_table = $this->base_table; $base_table_alias = $base_table; @@ -1664,12 +1702,19 @@ class views_plugin_query_default extends views_plugin_query { return array($entity_type, $result); } + } +/** + * + */ function views_query_default_aggregation_method_simple($group_type, $field) { return strtoupper($group_type) . '(' . $field . ')'; } +/** + * + */ function views_query_default_aggregation_method_distinct($group_type, $field) { $group_type = str_replace('_distinct', '', $group_type); return strtoupper($group_type) . '(DISTINCT ' . $field . ')'; diff --git a/sites/all/modules/views/plugins/views_plugin_row.inc b/sites/all/modules/views/plugins/views_plugin_row.inc index 157cc26..833a675 100644 --- a/sites/all/modules/views/plugins/views_plugin_row.inc +++ b/sites/all/modules/views/plugins/views_plugin_row.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the base row style plugin. + * Definition of views_plugin_row. */ /** @@ -17,14 +17,15 @@ */ /** - * Default plugin to view a single row of a table. This is really just a wrapper around - * a theme function. + * Default plugin to view a single row of a table. This is really just a wrapper + * around a theme function. */ class views_plugin_row extends views_plugin { + /** - * Initialize the row plugin. + * {@inheritdoc} */ - function init(&$view, &$display, $options = NULL) { + public function init(&$view, &$display, $options = NULL) { $this->view = &$view; $this->display = &$display; @@ -32,12 +33,17 @@ class views_plugin_row extends views_plugin { $this->unpack_options($this->options, isset($options) ? $options : $display->handler->get_option('row_options')); } - function uses_fields() { + /** + * {@inheritdoc} + */ + public function uses_fields() { return !empty($this->definition['uses fields']); } - - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); if (isset($this->base_table)) { $options['relationship'] = array('default' => 'none'); @@ -49,7 +55,7 @@ class views_plugin_row extends views_plugin { /** * Provide a form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); if (isset($this->base_table)) { $view = &$form_state['view']; @@ -98,15 +104,20 @@ class views_plugin_row extends views_plugin { /** * Validate the options form. */ - function options_validate(&$form, &$form_state) { } + public function options_validate(&$form, &$form_state) { + } /** * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { } + public function options_submit(&$form, &$form_state) { + } - function query() { + /** + * {@inheritdoc} + */ + public function query() { if (isset($this->base_table)) { if (isset($this->options['relationship']) && isset($this->view->relationship[$this->options['relationship']])) { $relationship = $this->view->relationship[$this->options['relationship']]; @@ -121,10 +132,11 @@ class views_plugin_row extends views_plugin { /** * Allow the style to do stuff before each row is rendered. * - * @param $result + * @param array $result * The full array of results from the query. */ - function pre_render($result) { } + public function pre_render($result) { + } /** * Render a row object. This usually passes through to a theme template @@ -136,7 +148,7 @@ class views_plugin_row extends views_plugin { * @return string * The rendered output of a single row, used by the style plugin. */ - function render($row) { + public function render($row) { return theme($this->theme_functions(), array( 'view' => $this->view, @@ -145,6 +157,7 @@ class views_plugin_row extends views_plugin { 'field_alias' => isset($this->field_alias) ? $this->field_alias : '', )); } + } /** diff --git a/sites/all/modules/views/plugins/views_plugin_row_fields.inc b/sites/all/modules/views/plugins/views_plugin_row_fields.inc index b1c02e1..edc854c 100644 --- a/sites/all/modules/views/plugins/views_plugin_row_fields.inc +++ b/sites/all/modules/views/plugins/views_plugin_row_fields.inc @@ -2,11 +2,11 @@ /** * @file - * Contains the base row style plugin. + * Definition of views_plugin_row_fields. */ /** - * The basic 'fields' row plugin + * The basic 'fields' row plugin. * * This displays fields one after another, giving options for inline * or not. @@ -14,7 +14,11 @@ * @ingroup views_row_plugins */ class views_plugin_row_fields extends views_plugin_row { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['inline'] = array('default' => array()); @@ -27,7 +31,7 @@ class views_plugin_row_fields extends views_plugin_row { /** * Provide a form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $options = $this->display->handler->get_field_labels(); @@ -80,7 +84,8 @@ class views_plugin_row_fields extends views_plugin_row { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { + public function options_submit(&$form, &$form_state) { $form_state['values']['row_options']['inline'] = array_filter($form_state['values']['row_options']['inline']); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_row_rss_fields.inc b/sites/all/modules/views/plugins/views_plugin_row_rss_fields.inc index 9355e83..4af7c9f 100644 --- a/sites/all/modules/views/plugins/views_plugin_row_rss_fields.inc +++ b/sites/all/modules/views/plugins/views_plugin_row_rss_fields.inc @@ -1,14 +1,19 @@ ''); $options['link_field'] = array('default' => ''); @@ -20,7 +25,10 @@ class views_plugin_row_rss_fields extends views_plugin_row { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $initial_labels = array('' => t('- None -')); @@ -89,7 +97,10 @@ class views_plugin_row_rss_fields extends views_plugin_row { ); } - function validate() { + /** + * + */ + public function validate() { $errors = parent::validate(); $required_options = array('title_field', 'link_field', 'description_field', 'creator_field', 'date_field'); foreach ($required_options as $required_option) { @@ -105,7 +116,10 @@ class views_plugin_row_rss_fields extends views_plugin_row { return $errors; } - function render($row) { + /** + * {@inheritdoc} + */ + public function render($row) { static $row_index; if (!isset($row_index)) { $row_index = 0; @@ -165,12 +179,12 @@ class views_plugin_row_rss_fields extends views_plugin_row { /** * Retrieves a views field value from the style plugin. * - * @param $index - * The index count of the row as expected by views_plugin_style::get_field(). - * @param $field_id + * @param int $index + * The index of the row as expected by views_plugin_style::get_field(). + * @param string $field_id * The ID assigned to the required field in the display. */ - function get_field($index, $field_id) { + public function get_field($index, $field_id) { if (empty($this->view->style_plugin) || !is_object($this->view->style_plugin) || empty($field_id)) { return ''; } diff --git a/sites/all/modules/views/plugins/views_plugin_style.inc b/sites/all/modules/views/plugins/views_plugin_style.inc index 5bd7086..1433f31 100644 --- a/sites/all/modules/views/plugins/views_plugin_style.inc +++ b/sites/all/modules/views/plugins/views_plugin_style.inc @@ -8,13 +8,13 @@ /** * @defgroup views_style_plugins Views style plugins * @{ - * Style plugins control how a view is rendered. For example, they - * can choose to display a collection of fields, node_view() output, - * table output, or any kind of crazy output they want. + * Style plugins control how a view is rendered. For example, they can choose to + * display a collection of fields, node_view() output, table output, or any kind + * of crazy output they want. * - * Many style plugins can have an optional 'row' plugin, that displays - * a single record. Not all style plugins can utilize this, so it is - * up to the plugin to set this up and call through to the row plugin. + * Many style plugins can have an optional 'row' plugin, that displays a single + * record. Not all style plugins can utilize this, so it is up to the plugin to + * set this up and call through to the row plugin. * * @see hook_views_plugins() */ @@ -23,29 +23,29 @@ * Base class to define a style plugin handler. */ class views_plugin_style extends views_plugin { + /** * Store all available tokens row rows. */ - var $row_tokens = array(); + public $row_tokens = array(); /** - * Contains the row plugin, if it's initialized - * and the style itself supports it. + * The row plugin, if it's initialized and the style itself supports it. * * @var views_plugin_row */ - var $row_plugin; + public $row_plugin; /** * Initialize a style plugin. * - * @param $view - * @param $display - * @param $options + * @param view $view + * @param object $display + * @param array $options * The style options might come externally as the style can be sourced * from at least two locations. If it's not included, look on the display. */ - function init(&$view, &$display, $options = NULL) { + public function init(&$view, &$display, $options = NULL) { $this->view = &$view; $this->display = &$display; @@ -65,7 +65,10 @@ class views_plugin_style extends views_plugin { ); } - function destroy() { + /** + * + */ + public function destroy() { parent::destroy(); if (isset($this->row_plugin)) { @@ -76,14 +79,14 @@ class views_plugin_style extends views_plugin { /** * Return TRUE if this style also uses a row plugin. */ - function uses_row_plugin() { + public function uses_row_plugin() { return !empty($this->definition['uses row plugin']); } /** * Return TRUE if this style also uses a row plugin. */ - function uses_row_class() { + public function uses_row_class() { return !empty($this->definition['uses row class']); } @@ -92,7 +95,7 @@ class views_plugin_style extends views_plugin { * * @return bool */ - function uses_fields() { + public function uses_fields() { // If we use a row plugin, ask the row plugin. Chances are, we don't // care, it does. $row_uses_fields = FALSE; @@ -108,7 +111,7 @@ class views_plugin_style extends views_plugin { * * Used to ensure we don't fetch tokens when not needed for performance. */ - function uses_tokens() { + public function uses_tokens() { if ($this->uses_row_class()) { $class = $this->options['row_class']; if (strpos($class, '[') !== FALSE || strpos($class, '!') !== FALSE || strpos($class, '%') !== FALSE) { @@ -120,7 +123,7 @@ class views_plugin_style extends views_plugin { /** * Return the token replaced row class for the specified row. */ - function get_row_class($row_index) { + public function get_row_class($row_index) { if ($this->uses_row_class()) { $class = $this->options['row_class']; @@ -129,7 +132,7 @@ class views_plugin_style extends views_plugin { // Explode the value by whitespace, this allows the function to handle // a single class name and multiple class names that are then tokenized. - foreach(explode(' ', $class) as $token_class) { + foreach (explode(' ', $class) as $token_class) { $classes = array_merge($classes, explode(' ', strip_tags($this->tokenize_value($token_class, $row_index)))); } } @@ -148,7 +151,7 @@ class views_plugin_style extends views_plugin { /** * Take a value and apply token replacement logic to it. */ - function tokenize_value($value, $row_index) { + public function tokenize_value($value, $row_index) { if (strpos($value, '[') !== FALSE || strpos($value, '!') !== FALSE || strpos($value, '%') !== FALSE) { $fake_item = array( 'alter_text' => TRUE, @@ -170,13 +173,16 @@ class views_plugin_style extends views_plugin { } /** - * Should the output of the style plugin be rendered even if it's a empty view. + * Should the output of the style plugin be rendered even if it's empty. */ - function even_empty() { + public function even_empty() { return !empty($this->definition['even empty']); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['grouping'] = array('default' => array()); if ($this->uses_row_class()) { @@ -189,19 +195,23 @@ class views_plugin_style extends views_plugin { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); - // Only fields-based views can handle grouping. Style plugins can also exclude - // themselves from being groupable by setting their "use grouping" definition - // key to FALSE. - // @TODO: Document "uses grouping" in docs.php when docs.php is written. + // Only fields-based views can handle grouping. Style plugins can also + // exclude themselves from being groupable by setting their "use grouping" + // definition key to FALSE. + // @todo Document "uses grouping" in docs.php when docs.php is written. if ($this->uses_fields() && $this->definition['uses grouping']) { $options = array('' => t('- None -')); $field_labels = $this->display->handler->get_field_labels(TRUE); $options += $field_labels; // If there are no fields, we can't group on them. if (count($options) > 1) { - // This is for backward compatibility, when there was just a single select form. + // This is for backward compatibility, when there was just a single + // select form. if (is_string($this->options['grouping'])) { $grouping = $this->options['grouping']; $this->options['grouping'] = array(); @@ -282,7 +292,10 @@ class views_plugin_style extends views_plugin { } } - function options_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { // Don't run validation on style plugins without the grouping setting. if (isset($form_state['values']['style_options']['grouping'])) { // Don't save grouping if no field is specified. @@ -299,21 +312,24 @@ class views_plugin_style extends views_plugin { * interfere with the sorts. If so it should build; if it returns * any non-TRUE value, normal sorting will NOT be added to the query. */ - function build_sort() { return TRUE; } + public function build_sort() { + return TRUE; + } /** * Called by the view builder to let the style build a second set of * sorts that will come after any other sorts in the view. */ - function build_sort_post() { } + public function build_sort_post() { + } /** * Allow the style to do stuff before each row is rendered. * - * @param $result + * @param array $result * The full array of results from the query. */ - function pre_render($result) { + public function pre_render($result) { if (!empty($this->row_plugin)) { $this->row_plugin->pre_render($result); } @@ -322,7 +338,7 @@ class views_plugin_style extends views_plugin { /** * Render the display in this style. */ - function render() { + public function render() { if ($this->uses_row_plugin() && empty($this->row_plugin)) { debug('views_plugin_style_default: Missing row plugin'); return; @@ -344,18 +360,19 @@ class views_plugin_style extends views_plugin { * Plugins may override this method if they wish some other way of handling * grouping. * - * @param $sets + * @param array $sets * Array containing the grouping sets to render. - * @param $level + * @param int $level * Integer indicating the hierarchical level of the grouping. * * @return string * Rendered output of given grouping sets. */ - function render_grouping_sets($sets, $level = 0) { + public function render_grouping_sets($sets, $level = 0) { $output = ''; foreach ($sets as $set) { $row = reset($set['rows']); + $level = isset($set['level']) ? $set['level'] : 0; // Render as a grouping set. if (is_array($row) && isset($row['group'])) { $output .= theme(views_theme_functions('views_view_grouping', $this->view, $this->display), @@ -393,18 +410,19 @@ class views_plugin_style extends views_plugin { /** * Group records as needed for rendering. * - * @param $records + * @param array $records * An array of records from the view to group. - * @param $groupings + * @param array $groupings * An array of grouping instructions on which fields to group. If empty, the * result set will be given a single group with an empty string as a label. - * @param $group_rendered + * @param bool $group_rendered * Boolean value whether to use the rendered or the raw field value for * grouping. If set to NULL the return is structured as before * Views 7.x-3.0-rc2. After Views 7.x-3.0 this boolean is only used if * $groupings is an old-style string or if the rendered option is missing * for a grouping instruction. - * @return + * + * @return array * The grouped record set. * A nested set structure is generated if multiple grouping fields are used. * @@ -429,9 +447,9 @@ class views_plugin_style extends views_plugin { * ) * @endcode */ - function render_grouping($records, $groupings = array(), $group_rendered = NULL) { - // This is for backward compatibility, when $groupings was a string containing - // the ID of a single field. + public function render_grouping($records, $groupings = array(), $group_rendered = NULL) { + // This is for backward compatibility, when $groupings was a string + // containing the ID of a single field. if (is_string($groupings)) { $rendered = $group_rendered === NULL ? TRUE : $group_rendered; $groupings = array(array('field' => $groupings, 'rendered' => $rendered)); @@ -446,7 +464,7 @@ class views_plugin_style extends views_plugin { // hierarchically positioned set where the current row belongs to. // While iterating, parent groups, that do not exist yet, are added. $set = &$sets; - foreach ($groupings as $info) { + foreach ($groupings as $level => $info) { $field = $info['field']; $rendered = isset($info['rendered']) ? $info['rendered'] : $group_rendered; $rendered_strip = isset($info['rendered_strip']) ? $info['rendered_strip'] : FALSE; @@ -479,13 +497,16 @@ class views_plugin_style extends views_plugin { // Create the group if it does not exist yet. if (empty($set[$grouping])) { $set[$grouping]['group'] = $group_content; + $set[$grouping]['level'] = $level; $set[$grouping]['rows'] = array(); } - // Move the set reference into the row set of the group we just determined. + // Move the set reference into the row set of the group we just + // determined. $set = &$set[$grouping]['rows']; } - // Add the row to the hierarchically positioned row set we just determined. + // Add the row to the hierarchically positioned row set we just + // determined. $set[$index] = $row; } } @@ -499,7 +520,7 @@ class views_plugin_style extends views_plugin { // If this parameter isn't explicitly set modify the output to be fully // backward compatible to code before Views 7.x-3.0-rc2. - // @TODO Remove this as soon as possible e.g. October 2020 + // @todo Remove this as soon as possible e.g. October 2020 if ($group_rendered === NULL) { $old_style_sets = array(); foreach ($sets as $group) { @@ -514,10 +535,10 @@ class views_plugin_style extends views_plugin { /** * Render all of the fields for a given style and store them on the object. * - * @param $result + * @param array $result * The result array from $view->result */ - function render_fields($result) { + public function render_fields($result) { if (!$this->uses_fields()) { return; } @@ -548,12 +569,12 @@ class views_plugin_style extends views_plugin { /** * Get a rendered field. * - * @param $index + * @param int $index * The index count of the row. - * @param $field + * @param string $field * The id of the field. */ - function get_field($index, $field) { + public function get_field($index, $field) { if (!isset($this->rendered_fields)) { $this->render_fields($this->view->result); } @@ -566,19 +587,22 @@ class views_plugin_style extends views_plugin { /** * Get the raw field value. * - * @param $index + * @param int $index * The index count of the row. - * @param $field + * @param string $field * The id of the field. */ - function get_field_value($index, $field) { + public function get_field_value($index, $field) { $this->view->row_index = $index; $value = $this->view->field[$field]->get_value($this->view->result[$index]); unset($this->view->row_index); return $value; } - function validate() { + /** + * {@inheritdoc} + */ + public function validate() { $errors = parent::validate(); if ($this->uses_row_plugin()) { @@ -596,12 +620,16 @@ class views_plugin_style extends views_plugin { return $errors; } - function query() { + /** + * {@inheritdoc} + */ + public function query() { parent::query(); if (isset($this->row_plugin)) { $this->row_plugin->query(); } } + } /** diff --git a/sites/all/modules/views/plugins/views_plugin_style_default.inc b/sites/all/modules/views/plugins/views_plugin_style_default.inc index a18f6cc..131b991 100644 --- a/sites/all/modules/views/plugins/views_plugin_style_default.inc +++ b/sites/all/modules/views/plugins/views_plugin_style_default.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the default style plugin. + * Definition of views_plugin_style_default. */ /** @@ -12,14 +12,19 @@ * @ingroup views_style_plugins */ class views_plugin_style_default extends views_plugin_style { + /** - * Set default options + * Set default options. */ - function options(&$options) { + public function options(&$options) { parent::options($options); } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_style_grid.inc b/sites/all/modules/views/plugins/views_plugin_style_grid.inc index a2e4375..ffa4cf0 100644 --- a/sites/all/modules/views/plugins/views_plugin_style_grid.inc +++ b/sites/all/modules/views/plugins/views_plugin_style_grid.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the grid style plugin. + * Definition of views_plugin_style_grid. */ /** @@ -11,10 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_grid extends views_plugin_style { + /** - * Set default options + * Set default options. */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); $options['columns'] = array('default' => '4'); @@ -29,7 +30,7 @@ class views_plugin_style_grid extends views_plugin_style { /** * Render the given style. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['columns'] = array( '#type' => 'textfield', @@ -67,4 +68,5 @@ class views_plugin_style_grid extends views_plugin_style { '#default_value' => $this->options['summary'], ); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_style_jump_menu.inc b/sites/all/modules/views/plugins/views_plugin_style_jump_menu.inc index b82facd..418766b 100644 --- a/sites/all/modules/views/plugins/views_plugin_style_jump_menu.inc +++ b/sites/all/modules/views/plugins/views_plugin_style_jump_menu.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the table style plugin. + * Definition of views_plugin_style_jump_menu. */ /** @@ -11,7 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_jump_menu extends views_plugin_style { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['hide'] = array('default' => FALSE, 'bool' => TRUE); @@ -28,7 +32,7 @@ class views_plugin_style_jump_menu extends views_plugin_style { /** * Render the given style. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $handlers = $this->display->handler->get_handlers('field'); if (empty($handlers)) { @@ -61,7 +65,7 @@ class views_plugin_style_jump_menu extends views_plugin_style { '#type' => 'checkbox', '#title' => t('Hide the "Go" button'), '#default_value' => !empty($this->options['hide']), - '#description' => t('If hidden, this button will only be hidden for users with javascript and the page will automatically jump when the select is changed.'), + '#description' => t('If hidden, this button will only be hidden for users with JavaScript and the page will automatically jump when the select is changed.'), ); $form['text'] = array( @@ -103,7 +107,7 @@ class views_plugin_style_jump_menu extends views_plugin_style { * * This is overridden so that we can render our grouping specially. */ - function render() { + public function render() { $sets = $this->render_grouping($this->view->result, $this->options['grouping']); // Turn this all into an $options array for the jump menu. @@ -122,8 +126,8 @@ class views_plugin_style_jump_menu extends views_plugin_style { $path = drupal_substr($path, drupal_strlen($base_path)); } - // use drupal_parse_url() to preserve query and fragment in case the user - // wants to do fun tricks. + // Use drupal_parse_url() to preserve query and fragment in case the + // user wants to do fun tricks. $url_options = drupal_parse_url($path); $path = url($url_options['path'], $url_options); @@ -144,8 +148,8 @@ class views_plugin_style_jump_menu extends views_plugin_style { $default_value = ''; if ($this->options['default_value']) { $lookup_options = array(); - // We need to check if the path is absolute - // or else language is not taken in account. + // We need to check if the path is absolute or else language is not taken + // in account. if (!empty($this->view->display[$this->view->current_display]->display_options['fields'][$this->options['path']]['absolute'])) { $lookup_options['absolute'] = TRUE; } @@ -169,8 +173,12 @@ class views_plugin_style_jump_menu extends views_plugin_style { return $form; } - function render_set($title, $records) { + /** + * + */ + public function render_set($title, $records) { $options = array(); $fields = $this->rendered_fields; } + } diff --git a/sites/all/modules/views/plugins/views_plugin_style_list.inc b/sites/all/modules/views/plugins/views_plugin_style_list.inc index 2a1dadb..7c8417f 100644 --- a/sites/all/modules/views/plugins/views_plugin_style_list.inc +++ b/sites/all/modules/views/plugins/views_plugin_style_list.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the list style plugin. + * Definition of views_plugin_style_list. */ /** @@ -11,10 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_list extends views_plugin_style { + /** - * Set default options + * Set default options. */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); $options['type'] = array('default' => 'ul'); @@ -27,7 +28,7 @@ class views_plugin_style_list extends views_plugin_style { /** * Render the given style. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['type'] = array( '#type' => 'radios', @@ -50,4 +51,5 @@ class views_plugin_style_list extends views_plugin_style { '#default_value' => $this->options['class'], ); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_style_mapping.inc b/sites/all/modules/views/plugins/views_plugin_style_mapping.inc index 513a71e..29ecebc 100644 --- a/sites/all/modules/views/plugins/views_plugin_style_mapping.inc +++ b/sites/all/modules/views/plugins/views_plugin_style_mapping.inc @@ -27,9 +27,9 @@ abstract class views_plugin_style_mapping extends views_plugin_style { abstract protected function define_mapping(); /** - * Overrides views_plugin_style::option_definition(). + * {@inheritdoc} */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); // Parse the mapping and add a default for each. @@ -50,9 +50,9 @@ abstract class views_plugin_style_mapping extends views_plugin_style { } /** - * Overrides views_plugin_style::options_form(). + * {@inheritdoc} */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // Get the mapping. @@ -110,11 +110,10 @@ abstract class views_plugin_style_mapping extends views_plugin_style { } /** - * Overrides views_plugin_style::render(). - * - * Provides the mapping definition as an available variable. + * {@inheritdoc} */ - function render() { + public function render() { + // Provides the mapping definition as an available variable. return theme($this->theme_functions(), array( 'view' => $this->view, 'options' => $this->options, diff --git a/sites/all/modules/views/plugins/views_plugin_style_rss.inc b/sites/all/modules/views/plugins/views_plugin_style_rss.inc index 79fef3d..0092ea4 100644 --- a/sites/all/modules/views/plugins/views_plugin_style_rss.inc +++ b/sites/all/modules/views/plugins/views_plugin_style_rss.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the RSS style plugin. + * Definition of views_plugin_style_rss. */ /** @@ -11,7 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_rss extends views_plugin_style { - function attach_to($display_id, $path, $title) { + + /** + * + */ + public function attach_to($display_id, $path, $title) { $display = $this->view->display[$display_id]->handler; $url_options = array(); $input = $this->view->get_exposed_input(); @@ -36,12 +40,15 @@ class views_plugin_style_rss extends views_plugin_style { 'rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => $title, - 'href' => $url + 'href' => $url, )); } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['description'] = array('default' => '', 'translatable' => TRUE); @@ -49,7 +56,10 @@ class views_plugin_style_rss extends views_plugin_style { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['description'] = array( @@ -67,7 +77,7 @@ class views_plugin_style_rss extends views_plugin_style { * @return * An array that can be passed to format_xml_elements(). */ - function get_channel_elements() { + public function get_channel_elements() { return array(); } @@ -80,7 +90,7 @@ class views_plugin_style_rss extends views_plugin_style { * @return * An array that can be passed to format_xml_elements(). */ - function get_channel_elements_atom_link() { + public function get_channel_elements_atom_link() { $url_options = array('absolute' => TRUE); $input = $this->view->get_exposed_input(); if ($input) { @@ -107,7 +117,7 @@ class views_plugin_style_rss extends views_plugin_style { * @return string * The string containing the description with the tokens replaced. */ - function get_description() { + public function get_description() { $description = $this->options['description']; // Allow substitutions from the first row. @@ -116,7 +126,10 @@ class views_plugin_style_rss extends views_plugin_style { return $description; } - function render() { + /** + * {@inheritdoc} + */ + public function render() { if (empty($this->row_plugin)) { vpr('views_plugin_style_default: Missing row plugin'); return; @@ -148,9 +161,10 @@ class views_plugin_style_rss extends views_plugin_style { array( 'view' => $this->view, 'options' => $this->options, - 'rows' => $rows + 'rows' => $rows, )); unset($this->view->row_index); return $output; } + } diff --git a/sites/all/modules/views/plugins/views_plugin_style_summary.inc b/sites/all/modules/views/plugins/views_plugin_style_summary.inc index 5081dd6..02e8973 100644 --- a/sites/all/modules/views/plugins/views_plugin_style_summary.inc +++ b/sites/all/modules/views/plugins/views_plugin_style_summary.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the default summary style plugin, which displays items in an HTML list. + * Definition of views_plugin_style_summary. */ /** @@ -11,7 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_summary extends views_plugin_style { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['base_path'] = array('default' => ''); @@ -22,13 +26,19 @@ class views_plugin_style_summary extends views_plugin_style { return $options; } - function query() { + /** + * {@inheritdoc} + */ + public function query() { if (!empty($this->options['override'])) { $this->view->set_items_per_page(intval($this->options['items_per_page'])); } } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['base_path'] = array( '#type' => 'textfield', '#title' => t('Base path'), @@ -55,22 +65,26 @@ class views_plugin_style_summary extends views_plugin_style { '#title' => t('Items to display'), '#default_value' => $this->options['items_per_page'], '#dependency' => array( - 'edit-options-summary-options-' . str_replace('_', '-', $this->definition['name']) . '-override' => array(1) + 'edit-options-summary-options-' . str_replace('_', '-', $this->definition['name']) . '-override' => array(1), ), ); } - function render() { + /** + * {@inheritdoc} + */ + public function render() { $rows = array(); foreach ($this->view->result as $row) { - // @todo: Include separator as an option. + // @todo Include separator as an option. $rows[] = $row; } return theme($this->theme_functions(), array( 'view' => $this->view, 'options' => $this->options, - 'rows' => $rows + 'rows' => $rows, )); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_style_summary_jump_menu.inc b/sites/all/modules/views/plugins/views_plugin_style_summary_jump_menu.inc index a16a84b..ee75f24 100644 --- a/sites/all/modules/views/plugins/views_plugin_style_summary_jump_menu.inc +++ b/sites/all/modules/views/plugins/views_plugin_style_summary_jump_menu.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the default summary style plugin, which displays items in an HTML list. + * Definition of views_plugin_style_summary_jump_menu. */ /** @@ -11,7 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_summary_jump_menu extends views_plugin_style { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['base_path'] = array('default' => ''); @@ -26,7 +30,10 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style { return $options; } - function query() { + /** + * {@inheritdoc} + */ + public function query() { // Copy the offset option. $pager = array( 'type' => 'none', @@ -35,7 +42,10 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style { $this->display->handler->set_option('pager', $pager); } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['base_path'] = array( '#type' => 'textfield', '#title' => t('Base path'), @@ -56,7 +66,7 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style { '#type' => 'checkbox', '#title' => t('Hide the "Go" button'), '#default_value' => !empty($this->options['hide']), - '#description' => t('If hidden, this button will only be hidden for users with javascript and the page will automatically jump when the select is changed.'), + '#description' => t('If hidden, this button will only be hidden for users with JavaScript and the page will automatically jump when the select is changed.'), ); $form['text'] = array( @@ -93,7 +103,10 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style { ); } - function render() { + /** + * {@inheritdoc} + */ + public function render() { $argument = $this->view->argument[$this->view->build_info['summary_level']]; $url_options = array(); @@ -143,4 +156,5 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style { $form = drupal_get_form('ctools_jump_menu', $options, $settings); return drupal_render($form); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_style_summary_unformatted.inc b/sites/all/modules/views/plugins/views_plugin_style_summary_unformatted.inc index fc46624..fb16207 100644 --- a/sites/all/modules/views/plugins/views_plugin_style_summary_unformatted.inc +++ b/sites/all/modules/views/plugins/views_plugin_style_summary_unformatted.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the unformatted summary style plugin. + * Definition of views_plugin_style_summary_unformatted. */ /** @@ -11,14 +11,21 @@ * @ingroup views_style_plugins */ class views_plugin_style_summary_unformatted extends views_plugin_style_summary { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['inline'] = array('default' => FALSE, 'bool' => TRUE); $options['separator'] = array('default' => ''); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['inline'] = array( '#type' => 'checkbox', @@ -31,4 +38,5 @@ class views_plugin_style_summary_unformatted extends views_plugin_style_summary '#default_value' => $this->options['separator'], ); } + } diff --git a/sites/all/modules/views/plugins/views_plugin_style_table.inc b/sites/all/modules/views/plugins/views_plugin_style_table.inc index 45ed976..5467920 100644 --- a/sites/all/modules/views/plugins/views_plugin_style_table.inc +++ b/sites/all/modules/views/plugins/views_plugin_style_table.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the table style plugin. + * Definition of views_plugin_style_table. */ /** @@ -24,10 +24,14 @@ class views_plugin_style_table extends views_plugin_style { */ public $order; - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['columns'] = array('default' => array()); + $options['class'] = array('default' => array()); $options['default'] = array('default' => ''); $options['info'] = array('default' => array()); $options['override'] = array('default' => TRUE, 'bool' => TRUE); @@ -45,7 +49,7 @@ class views_plugin_style_table extends views_plugin_style { * * @return bool */ - function build_sort() { + public function build_sort() { if (!isset($_GET['order']) && ($this->options['default'] == -1 || empty($this->view->field[$this->options['default']]))) { return TRUE; } @@ -62,7 +66,7 @@ class views_plugin_style_table extends views_plugin_style { /** * Add our actual sort criteria */ - function build_sort_post() { + public function build_sort_post() { if (!isset($_GET['order'])) { // check for a 'default' clicksort. If there isn't one, exit gracefully. if (empty($this->options['default'])) { @@ -111,10 +115,10 @@ class views_plugin_style_table extends views_plugin_style { * - Any fields not currently represented must be added. * - Columns must be re-ordered to match the fields. * - * @param $columns + * @param array $columns * An array of all fields; the key is the id of the field and the * value is the id of the column the field should be in. - * @param $fields + * @param array $fields * The fields to use for the columns. If not provided, they will * be requested from the current display. The running render should * send the fields through, as they may be different than what the @@ -123,7 +127,7 @@ class views_plugin_style_table extends views_plugin_style { * @return array * An array of all the sanitized columns. */ - function sanitize_columns($columns, $fields = NULL) { + public function sanitize_columns($columns, $fields = NULL) { $sanitized = array(); if ($fields === NULL) { $fields = $this->display->handler->get_option('fields'); @@ -157,7 +161,7 @@ class views_plugin_style_table extends views_plugin_style { /** * Render the given style. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $handlers = $this->display->handler->get_handlers('field'); if (empty($handlers)) { @@ -175,7 +179,7 @@ class views_plugin_style_table extends views_plugin_style { $form['sticky'] = array( '#type' => 'checkbox', - '#title' => t('Enable Drupal style "sticky" table headers (Javascript)'), + '#title' => t('Enable Drupal style "sticky" table headers (JavaScript)'), '#default_value' => !empty($this->options['sticky']), '#description' => t('(Sticky header effects will not be active for preview below, only on live output.)'), ); @@ -195,6 +199,14 @@ class views_plugin_style_table extends views_plugin_style { '#default_value' => $this->options['summary'], '#maxlength' => 255, ); + + $form['class'] = array( + '#type' => 'textfield', + '#title' => t('CSS classes'), + '#description' => t('Add CSS classes to the table; multiple classes may be separated by spaces.'), + '#default_value' => $this->options['class'], + '#maxlength' => 255, + ); // Note: views UI registers this theme handler on our behalf. Your module // will have to register your theme handlers if you do stuff like this. @@ -202,7 +214,7 @@ class views_plugin_style_table extends views_plugin_style { $columns = $this->sanitize_columns($this->options['columns']); - // Create an array of allowed columns from the data we know: + // Create an array of allowed columns from the data we know. $field_names = $this->display->handler->get_field_labels(); if (isset($this->options['default'])) { @@ -293,7 +305,7 @@ class views_plugin_style_table extends views_plugin_style { '#type' => 'checkbox', '#title' => t('Show the empty text in the table'), '#default_value' => $this->options['empty_table'], - '#description' => t('Per default the table is hidden for an empty view. With this option it is posible to show an empty table with the text in it.'), + '#description' => t('Per default the table is hidden for an empty view. With this option it is possible to show an empty table with the text in it.'), ); $form['description_markup'] = array( @@ -301,7 +313,10 @@ class views_plugin_style_table extends views_plugin_style { ); } - function even_empty() { + /** + * + */ + public function even_empty() { return parent::even_empty() || !empty($this->options['empty_table']); } } diff --git a/sites/all/modules/views/plugins/views_wizard/file_managed.inc b/sites/all/modules/views/plugins/views_wizard/file_managed.inc index 049ce1b..191f9ab 100644 --- a/sites/all/modules/views/plugins/views_wizard/file_managed.inc +++ b/sites/all/modules/views/plugins/views_wizard/file_managed.inc @@ -14,8 +14,7 @@ $plugin = array( 'class' => 'ViewsUiFileManagedViewsWizard', ), 'title' => t('Files'), - 'filters' => array( - ), + 'filters' => array(), 'path_field' => array( 'id' => 'uri', 'table' => 'file_managed', diff --git a/sites/all/modules/views/plugins/views_wizard/node.inc b/sites/all/modules/views/plugins/views_wizard/node.inc index ccca48d..d5b3e3d 100644 --- a/sites/all/modules/views/plugins/views_wizard/node.inc +++ b/sites/all/modules/views/plugins/views_wizard/node.inc @@ -10,7 +10,7 @@ $plugin = array( 'base_table' => 'node', 'created_column' => 'created', 'available_sorts' => array( - 'title:DESC' => t('Title') + 'title:DESC' => t('Title'), ), 'form_wizard_class' => array( 'file' => 'views_ui_node_views_wizard.class.php', diff --git a/sites/all/modules/views/plugins/views_wizard/node_revision.inc b/sites/all/modules/views/plugins/views_wizard/node_revision.inc index ddf1d61..3a9ea64 100644 --- a/sites/all/modules/views/plugins/views_wizard/node_revision.inc +++ b/sites/all/modules/views/plugins/views_wizard/node_revision.inc @@ -17,7 +17,8 @@ $plugin = array( 'filters' => array( 'status' => array( 'value' => '1', - 'table' => 'node', // @todo - unclear if this should be node or node_revision + 'table' => 'node', +// @todo - unclear if this should be node or node_revision 'field' => 'status', ), ), diff --git a/sites/all/modules/views/plugins/views_wizard/taxonomy_term.inc b/sites/all/modules/views/plugins/views_wizard/taxonomy_term.inc index 599e354..687a4e9 100644 --- a/sites/all/modules/views/plugins/views_wizard/taxonomy_term.inc +++ b/sites/all/modules/views/plugins/views_wizard/taxonomy_term.inc @@ -14,8 +14,7 @@ if (module_exists('taxonomy')) { 'class' => 'ViewsUiTaxonomyTermViewsWizard', ), 'title' => t('Taxonomy terms'), - 'filters' => array( - ), + 'filters' => array(), 'path_field' => array( 'id' => 'tid', 'table' => 'taxonomy_term_data', diff --git a/sites/all/modules/views/plugins/views_wizard/views_ui_base_views_wizard.class.php b/sites/all/modules/views/plugins/views_wizard/views_ui_base_views_wizard.class.php index 8893ab8..35989c4 100644 --- a/sites/all/modules/views/plugins/views_wizard/views_ui_base_views_wizard.class.php +++ b/sites/all/modules/views/plugins/views_wizard/views_ui_base_views_wizard.class.php @@ -9,6 +9,10 @@ * Defines a common interface for Views Wizard plugins. */ interface ViewsWizardInterface { + + /** + * Constructor. + */ function __construct($plugin); /** @@ -31,6 +35,7 @@ interface ViewsWizardInterface { * @throws ViewsWizardException in the event of a problem. */ function create_view($form, &$form_state); + } /** @@ -43,6 +48,7 @@ class ViewsWizardException extends Exception { * A very generic Views Wizard class - can be constructed for any base table. */ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { + protected $base_table; protected $entity_type; protected $entity_info = array(); @@ -87,7 +93,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { $form['displays']['page'] = array( '#type' => 'fieldset', - '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend'),), + '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')), '#tree' => TRUE, ); $form['displays']['page']['create'] = array( @@ -102,7 +108,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { // can be hidden en masse when the "Create a page" checkbox is unchecked. $form['displays']['page']['options'] = array( '#type' => 'container', - '#attributes' => array('class' => array('options-set'),), + '#attributes' => array('class' => array('options-set')), '#dependency' => array( 'edit-page-create' => array(1), ), @@ -224,7 +230,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { $form['displays']['block'] = array( '#type' => 'fieldset', - '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend'),), + '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')), '#tree' => TRUE, ); $form['displays']['block']['create'] = array( @@ -238,7 +244,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { // can be hidden en masse when the "Create a block" checkbox is unchecked. $form['displays']['block']['options'] = array( '#type' => 'container', - '#attributes' => array('class' => array('options-set'),), + '#attributes' => array('class' => array('options-set')), '#dependency' => array( 'edit-block-create' => array(1), ), @@ -334,7 +340,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { } /** - * Build the part of the form that allows the user to select the view's filters. + * Build the part of the form that allows the user to select the filters. * * By default, this adds "of type" and "tagged with" filters (when they are * available). @@ -344,7 +350,8 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { $fields = views_fetch_fields($this->base_table, 'filter'); $entity_info = $this->entity_info; - // If the current base table support bundles and has more than one (like user). + // If the current base table support bundles and has more than one (like + // user). if (isset($entity_info['bundle keys']) && isset($entity_info['bundles'])) { // Get all bundles and their human readable names. $options = array('all' => t('All')); @@ -431,7 +438,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { } /** - * Build the part of the form that allows the user to select the view's sort order. + * Build the part of the form that allows the user to select the sort order. * * By default, this adds a "sorted by [date]" filter (when it is available). */ @@ -492,7 +499,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { * arrays of options for that display. */ protected function build_display_options($form, $form_state) { - // Display: Master + // Display: Master. $display_options['default'] = $this->default_display_options($form, $form_state); $display_options['default'] += array( 'filters' => array(), @@ -501,17 +508,17 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { $display_options['default']['filters'] += $this->default_display_filters($form, $form_state); $display_options['default']['sorts'] += $this->default_display_sorts($form, $form_state); - // Display: Page + // Display: Page. if (!empty($form_state['values']['page']['create'])) { $display_options['page'] = $this->page_display_options($form, $form_state); - // Display: Feed (attached to the page) + // Display: Feed (attached to the page). if (!empty($form_state['values']['page']['feed'])) { $display_options['feed'] = $this->page_feed_display_options($form, $form_state); } } - // Display: Block + // Display: Block. if (!empty($form_state['values']['block']['create'])) { $display_options['block'] = $this->block_display_options($form, $form_state); } @@ -573,13 +580,13 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { * Add the array of display options to the view, with appropriate overrides. */ protected function add_displays($view, $display_options, $form, $form_state) { - // Display: Master + // Display: Master. $default_display = $view->new_display('default', 'Master', 'default'); foreach ($display_options['default'] as $option => $value) { $default_display->set_option($option, $value); } - // Display: Page + // Display: Page. if (isset($display_options['page'])) { $display = $view->new_display('page', 'Page', 'page'); // The page display is usually the main one (from the user's point of @@ -587,14 +594,14 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { // so that new displays which are added later automatically inherit them. $this->set_default_options($display_options['page'], $display, $default_display); - // Display: Feed (attached to the page) + // Display: Feed (attached to the page). if (isset($display_options['feed'])) { $display = $view->new_display('feed', 'Feed', 'feed'); $this->set_override_options($display_options['feed'], $display, $default_display); } } - // Display: Block + // Display: Block. if (isset($display_options['block'])) { $display = $view->new_display('block', 'Block', 'block'); // When there is no page, the block display options should become the @@ -622,9 +629,10 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { $display_options['style_plugin'] = 'default'; $display_options['row_plugin'] = 'fields'; - // Add a least one field so the view validates and the user has already a preview. - // Therefore the basefield could provide 'defaults][field]' in it's base settings. - // If there is nothing like this choose the first field with a field handler. + // Add a least one field so the view validates and the user has already a + // preview. Therefore the basefield could provide 'defaults][field]' in + // it's base settings. If there is nothing like this choose the first field + // with a field handler. $data = views_fetch_data($this->base_table); if (isset($data['table']['base']['defaults']['field'])) { $field = $data['table']['base']['defaults']['field']; @@ -682,8 +690,9 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { } } $table_data = views_fetch_data($table); - // Check whether the bundle key filter handler is or an child of it views_handler_filter_in_operator - // If it's not just use a single value instead of an array. + // Check whether the bundle key filter handler is or an child of it + // views_handler_filter_in_operator. If it's not just use a single value + // instead of an array. $handler = $table_data[$bundle_key]['filter']['handler']; if ($handler == 'views_handler_filter_in_operator' || is_subclass_of($handler, 'views_handler_filter_in_operator')) { $value = drupal_map_assoc(array($form_state['values']['show']['type'])); @@ -700,7 +709,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { ); } - // @todo: Figure out why this isn't part of node_views_wizard. + // @todo Figure out why this isn't part of node_views_wizard. if (!empty($form_state['values']['show']['tagged_with']['tids'])) { $filters['tid'] = array( 'id' => 'tid', @@ -741,7 +750,8 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { protected function default_display_sorts_user($form, $form_state) { $sorts = array(); - // Don't add a sort if there is no form value or the user selected none as sort. + // Don't add a sort if there is no form value or the user selected none as + // sort. if (!empty($form_state['values']['show']['sort']) && $form_state['values']['show']['sort'] != 'none') { list($column, $sort) = explode(':', $form_state['values']['show']['sort']); // Column either be a column-name or the table-columnn-ame. @@ -826,14 +836,14 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { * so that new displays which the user adds later will be similar to this * one. * - * @param $options + * @param array $options * An array whose keys are the name of each option and whose values are the * desired values to set. - * @param $display + * @param object $display * The display which the options will be applied to. The default display * will actually be assigned the options (and this display will inherit * them) when possible. - * @param $default_display + * @param object$default_display * The default display, which will store the options when possible. */ protected function set_default_options($options, $display, $default_display) { @@ -862,13 +872,13 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { * the views wizard, then the view will wind up with the title stored as the * default (with the page and block both inheriting from it). * - * @param $options + * @param array $options * An array whose keys are the name of each option and whose values are the * desired values. - * @param $display + * @param object $display * The display which the options will apply to. It will get the options by * inheritance from the default display when possible. - * @param $default_display + * @param object $default_display * The default display, from which the options will be inherited when * possible. */ @@ -918,12 +928,12 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { * * @throws ViewsWizardException if the values have not been validated. */ - function create_view($form, &$form_state) { - $view = $this->retrieve_validated_view($form, $form_state); - if (empty($view)) { - throw new ViewsWizardException(t('Attempted to create_view with values that have not been validated')); - } - return $view; - } + function create_view($form, &$form_state) { + $view = $this->retrieve_validated_view($form, $form_state); + if (empty($view)) { + throw new ViewsWizardException(t('Attempted to create_view with values that have not been validated')); + } + return $view; + } } diff --git a/sites/all/modules/views/plugins/views_wizard/views_ui_comment_views_wizard.class.php b/sites/all/modules/views/plugins/views_wizard/views_ui_comment_views_wizard.class.php index fa26d33..4b68e98 100644 --- a/sites/all/modules/views/plugins/views_wizard/views_ui_comment_views_wizard.class.php +++ b/sites/all/modules/views/plugins/views_wizard/views_ui_comment_views_wizard.class.php @@ -105,4 +105,5 @@ class ViewsUiCommentViewsWizard extends ViewsUiBaseViewsWizard { return $display_options; } + } diff --git a/sites/all/modules/views/plugins/views_wizard/views_ui_file_managed_views_wizard.class.php b/sites/all/modules/views/plugins/views_wizard/views_ui_file_managed_views_wizard.class.php index 111b631..12435cb 100644 --- a/sites/all/modules/views/plugins/views_wizard/views_ui_file_managed_views_wizard.class.php +++ b/sites/all/modules/views/plugins/views_wizard/views_ui_file_managed_views_wizard.class.php @@ -9,6 +9,7 @@ * Tests creating managed files views with the wizard. */ class ViewsUiFileManagedViewsWizard extends ViewsUiBaseViewsWizard { + protected function default_display_options($form, $form_state) { $display_options = parent::default_display_options($form, $form_state); @@ -37,4 +38,5 @@ class ViewsUiFileManagedViewsWizard extends ViewsUiBaseViewsWizard { return $display_options; } + } diff --git a/sites/all/modules/views/plugins/views_wizard/views_ui_node_revision_views_wizard.class.php b/sites/all/modules/views/plugins/views_wizard/views_ui_node_revision_views_wizard.class.php index 3623f53..49d52e0 100644 --- a/sites/all/modules/views/plugins/views_wizard/views_ui_node_revision_views_wizard.class.php +++ b/sites/all/modules/views/plugins/views_wizard/views_ui_node_revision_views_wizard.class.php @@ -65,4 +65,5 @@ class ViewsUiNodeRevisionViewsWizard extends ViewsUiNodeViewsWizard { return $display_options; } + } diff --git a/sites/all/modules/views/plugins/views_wizard/views_ui_node_views_wizard.class.php b/sites/all/modules/views/plugins/views_wizard/views_ui_node_views_wizard.class.php index 07bb91d..ffdd7d1 100644 --- a/sites/all/modules/views/plugins/views_wizard/views_ui_node_views_wizard.class.php +++ b/sites/all/modules/views/plugins/views_wizard/views_ui_node_views_wizard.class.php @@ -118,20 +118,24 @@ class ViewsUiNodeViewsWizard extends ViewsUiBaseViewsWizard { $display_options['row_options']['links'] = !empty($row_options['links']); $display_options['row_options']['comments'] = !empty($row_options['comments']); break; + case 'teasers': $display_options['row_plugin'] = 'node'; $display_options['row_options']['build_mode'] = 'teaser'; $display_options['row_options']['links'] = !empty($row_options['links']); $display_options['row_options']['comments'] = !empty($row_options['comments']); break; + case 'titles_linked': $display_options['row_plugin'] = 'fields'; $display_options['field']['title']['link_to_node'] = 1; break; + case 'titles': $display_options['row_plugin'] = 'fields'; $display_options['field']['title']['link_to_node'] = 0; break; } } + } diff --git a/sites/all/modules/views/plugins/views_wizard/views_ui_taxonomy_term_views_wizard.class.php b/sites/all/modules/views/plugins/views_wizard/views_ui_taxonomy_term_views_wizard.class.php index 8c1d6d5..b73156e 100644 --- a/sites/all/modules/views/plugins/views_wizard/views_ui_taxonomy_term_views_wizard.class.php +++ b/sites/all/modules/views/plugins/views_wizard/views_ui_taxonomy_term_views_wizard.class.php @@ -39,4 +39,5 @@ class ViewsUiTaxonomyTermViewsWizard extends ViewsUiBaseViewsWizard { return $display_options; } + } diff --git a/sites/all/modules/views/plugins/views_wizard/views_ui_users_views_wizard.class.php b/sites/all/modules/views/plugins/views_wizard/views_ui_users_views_wizard.class.php index 73eff48..c20c89e 100644 --- a/sites/all/modules/views/plugins/views_wizard/views_ui_users_views_wizard.class.php +++ b/sites/all/modules/views/plugins/views_wizard/views_ui_users_views_wizard.class.php @@ -9,6 +9,7 @@ * Tests creating user views with the wizard. */ class ViewsUiUsersViewsWizard extends ViewsUiBaseViewsWizard { + protected function default_display_options($form, $form_state) { $display_options = parent::default_display_options($form, $form_state); @@ -39,4 +40,5 @@ class ViewsUiUsersViewsWizard extends ViewsUiBaseViewsWizard { return $display_options; } + } diff --git a/sites/all/modules/views/test_templates/views-view--frontpage.tpl.php b/sites/all/modules/views/test_templates/views-view--frontpage.tpl.php index eb4f58b..bfe67b1 100644 --- a/sites/all/modules/views/test_templates/views-view--frontpage.tpl.php +++ b/sites/all/modules/views/test_templates/views-view--frontpage.tpl.php @@ -22,7 +22,7 @@ * - $pager: The pager next/prev links to display, if any * - $exposed: Exposed widget form/info to display * - $feed_icon: Feed icon to display, if any - * - $more: A link to view more, if any + * - $more: A link to view more, if any. * * @ingroup views_templates */ diff --git a/sites/all/modules/views/tests/README.txt b/sites/all/modules/views/tests/README.txt new file mode 100644 index 0000000..e292de3 --- /dev/null +++ b/sites/all/modules/views/tests/README.txt @@ -0,0 +1,29 @@ +Views Tests +``````````` +All of the tests may be executed with the following command: + +$ scripts/run-tests.sh --color --url http://example.com/ --php `which php` --concurrency 4 --verbose --directory 'sites/all/modules/contrib/views/tests' 2> /dev/null + +Explanation: + --color + Colorizes the output. Optional. + --url http://example.com/ + The name of the Drupal 7 hostname used locally for running tests, e.g. + "http://drupal7.dev". Required. + --php `which php` + Tells the test runner the path to the PHP binary. Only necessary if the test + runner is unable to find the path automatically or to use an alternative + PHP binary. Optional. + --cuncurrency 4 + Run multiple test processes simultaneously. Four appears to be a good + balance between melting the computer and improving performance. Optional. + --verbose + Display results for all of the assertion statements after the summary + details. Optional. + --directory 'sites/all/modules/contrib/views/tests' + Run all of the commands in the following directory. The path is relative to + the Drupal installation's root directory. This will run all of Views' tests + in one go, rather than either repeating the names of test groups or running + multiple commands. Optional. + 2> /dev/null + Outputs all error messages to /dev/null, i.e. hides them. Optional. diff --git a/sites/all/modules/views/tests/comment/views_handler_argument_comment_user_uid.test b/sites/all/modules/views/tests/comment/views_handler_argument_comment_user_uid.test index 353d929..9599499 100644 --- a/sites/all/modules/views/tests/comment/views_handler_argument_comment_user_uid.test +++ b/sites/all/modules/views/tests/comment/views_handler_argument_comment_user_uid.test @@ -20,10 +20,10 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest { /** * Post comment. * - * @param $node + * @param object $node * Node to post comment on. - * @param $comment - * Comment to save + * @param array $comment + * Comment to save. */ function postComment($node, $comment = array()) { $comment += array( @@ -38,8 +38,8 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest { function setUp() { parent::setUp(); - // Add two users, create a node with the user1 as author and another node with user2 as author. - // For the second node add a comment from user1. + // Add two users, create a node with the user1 as author and another node + // with user2 as author. For the second node add a comment from user1. $this->account = $this->drupalCreateUser(); $this->account2 = $this->drupalCreateUser(); $this->drupalLogin($this->account); @@ -51,7 +51,6 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest { function testCommentUserUidTest() { $view = $this->view_comment_user_uid(); - $this->executeView($view, array($this->account->uid)); $resultset = array( array( @@ -67,7 +66,7 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest { } function view_comment_user_uid() { - $view = new view; + $view = new view(); $view->name = 'test_comment_user_uid'; $view->description = ''; $view->tag = 'default'; @@ -103,4 +102,5 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/views/tests/comment/views_handler_filter_comment_user_uid.test b/sites/all/modules/views/tests/comment/views_handler_filter_comment_user_uid.test index 1f3f75c..4093317 100644 --- a/sites/all/modules/views/tests/comment/views_handler_filter_comment_user_uid.test +++ b/sites/all/modules/views/tests/comment/views_handler_filter_comment_user_uid.test @@ -38,4 +38,5 @@ class viewsHandlerFilterCommentUserUidTest extends viewsHandlerArgumentCommentUs return $view; } + } diff --git a/sites/all/modules/views/tests/field/views_fieldapi.test b/sites/all/modules/views/tests/field/views_fieldapi.test index da4c27b..0d049e1 100644 --- a/sites/all/modules/views/tests/field/views_fieldapi.test +++ b/sites/all/modules/views/tests/field/views_fieldapi.test @@ -6,33 +6,40 @@ */ /** - * @TODO - * - Test on a generic entity not on a node. + * @todo Test on a generic entity not on a node. * * What has to be tested: - * - Take sure that every wanted field is added to the according entity type. - * - Take sure the joins are done correct. - * - Use basic fields and take sure that the full wanted object is build. - * - Use relationships between different entity types, for example node and the node author(user). + * - Take sure that every wanted field is added to the according entity type. + * - Take sure the joins are done correct. + * - Use basic fields and take sure that the full wanted object is build. + * - Use relationships between different entity types, for example node and + * the node author(user). */ /** * Provides some helper methods for testing fieldapi integration into views. */ class ViewsFieldApiTestHelper extends ViewsSqlTest { + /** * Stores the field definitions used by the test. + * * @var array */ public $fields; + /** * Stores the instances of the fields. They have * the same keys as the fields. + * * @var array */ public $instances; - protected function CreateUser($extra_edit = array()) { + /** + * + */ + protected function createUser($extra_edit = array()) { $permissions = array('access comments', 'access content', 'post comments', 'skip comment approval'); // Create a role with the given permission set. if (!($rid = $this->drupalCreateRole($permissions))) { @@ -92,6 +99,7 @@ class ViewsFieldApiTestHelper extends ViewsSqlTest { drupal_static_reset('_views_fetch_data_recursion_protected'); drupal_static_reset('_views_fetch_data_fully_loaded'); } + } /** @@ -116,7 +124,6 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { $langcode = LANGUAGE_NONE; - $field_names = $this->setUpFields(); // The first one will be attached to nodes only. @@ -152,7 +159,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { // Now create some example nodes/users for the view result. for ($i = 0; $i < 5; $i++) { $edit = array( - // @TODO Write a helper method to create such values. + // @todo Write a helper method to create such values. 'field_name_0' => array($langcode => array((array('value' => $this->randomName())))), 'field_name_2' => array($langcode => array((array('value' => $this->randomName())))), ); @@ -164,7 +171,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { 'field_name_1' => array($langcode => array((array('value' => $this->randomName())))), 'field_name_2' => array($langcode => array((array('value' => $this->randomName())))), ); - $this->users[] = $this->CreateUser($edit); + $this->users[] = $this->createUser($edit); } // Reset views data cache. @@ -178,7 +185,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { */ function testViewsData() { $data = views_fetch_data(); - + // Check the table and the joins of the first field. // Attached to node only. $field = $this->fields[0]; @@ -210,7 +217,6 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { ); $this->assertEqual($expected_join, $data[$revision_table]['table']['join']['node_revision']); - // Check the table and the joins of the second field. // Attached to both node and user. $field_2 = $this->fields[2]; @@ -230,7 +236,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { 'extra' => array( array('field' => 'entity_type', 'value' => 'node'), array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE), - ) + ), ); $this->assertEqual($expected_join, $data[$current_table_2]['table']['join']['node']); $expected_join = array( @@ -239,7 +245,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { 'extra' => array( array('field' => 'entity_type', 'value' => 'node'), array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE), - ) + ), ); $this->assertEqual($expected_join, $data[$revision_table_2]['table']['join']['node_revision']); $expected_join = array( @@ -248,32 +254,25 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { 'extra' => array( array('field' => 'entity_type', 'value' => 'user'), array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE), - ) + ), ); $this->assertEqual($expected_join, $data[$current_table_2]['table']['join']['users']); - // Check the fields - // @todo - - // Check the arguments - // @todo - - // Check the sort criterias - // @todo - - // Check the relationships - // @todo - + // @todo Check the fields. + // @todo Check the arguments. + // @todo Check the sort criterias. + // @todo Check the relationships. } + } /** * Tests the field_field handler. - * @TODO - * Check a entity-type with bundles - * Check a entity-type without bundles - * Check locale:disabled, locale:enabled and locale:enabled with another language - * Check revisions + * + * @todo Check a entity-type with bundles. + * @todo Check a entity-type without bundles. + * @todo Check locale:disabled, locale:enabled and locale:enabled with another language. + * @todo Check revisions. */ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { public $nodes; @@ -282,7 +281,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { return array( 'name' => 'Fieldapi: Field handler', 'description' => 'Tests the field itself of the fieldapi integration', - 'group' => 'Views Modules' + 'group' => 'Views Modules', ); } @@ -353,7 +352,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { $this->executeView($view); // Take sure that the formatter works as expected. - // @TODO: actually there should be a specific formatter. + // @todo actually there should be a specific formatter. for ($i = 0; $i < 2; $i++) { $rendered_field = $view->style_plugin->get_field($i, $this->fields[0]['field_name']); $this->assertEqual(strlen($rendered_field), 3); @@ -384,7 +383,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { $view->destroy(); - // Test delta limit + offset + // Test delta limit + offset. $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3; $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_offset'] = 1; @@ -459,7 +458,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { } protected function getFieldView() { - $view = new view; + $view = new view(); $view->name = 'view_fieldapi'; $view->description = ''; $view->tag = 'default'; @@ -491,4 +490,3 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { } } - diff --git a/sites/all/modules/views/tests/handlers/views_handler_area_text.test b/sites/all/modules/views/tests/handlers/views_handler_area_text.test index 9f30e0c..c5ebe81 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_area_text.test +++ b/sites/all/modules/views/tests/handlers/views_handler_area_text.test @@ -22,7 +22,7 @@ class ViewsHandlerAreaTextTest extends ViewsSqlTest { public function testAreaText() { $view = $this->getBasicView(); - // add a text header + // add a text header. $string = $this->randomName(); $view->display['default']->handler->override_option('header', array( 'area' => array( diff --git a/sites/all/modules/views/tests/handlers/views_handler_argument_null.test b/sites/all/modules/views/tests/handlers/views_handler_argument_null.test index e8650a3..95db4df 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_argument_null.test +++ b/sites/all/modules/views/tests/handlers/views_handler_argument_null.test @@ -25,7 +25,7 @@ class ViewsHandlerArgumentNullTest extends ViewsSqlTest { } public function testAreaText() { - // Test validation + // Test validation. $view = $this->getBasicView(); // Add a null argument. diff --git a/sites/all/modules/views/tests/handlers/views_handler_argument_string.test b/sites/all/modules/views/tests/handlers/views_handler_argument_string.test index d078abf..4c76ff6 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_argument_string.test +++ b/sites/all/modules/views/tests/handlers/views_handler_argument_string.test @@ -53,6 +53,7 @@ class ViewsHandlerArgumentStringTest extends ViewsSqlTest { * Provide a test view for testGlossary. * * @see testGlossary + * * @return view */ function viewGlossary() { @@ -93,4 +94,5 @@ class ViewsHandlerArgumentStringTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_field.test b/sites/all/modules/views/tests/handlers/views_handler_field.test index 9e6dfca..df9574f 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_field.test +++ b/sites/all/modules/views/tests/handlers/views_handler_field.test @@ -6,11 +6,15 @@ */ /** - * Tests the generic field handler + * Tests the generic field handler. * * @see views_handler_field */ class ViewsHandlerFieldTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Field', @@ -19,6 +23,9 @@ class ViewsHandlerFieldTest extends ViewsSqlTest { ); } + /** + * + */ protected function setUp() { parent::setUp(); $this->column_map = array( @@ -26,17 +33,12 @@ class ViewsHandlerFieldTest extends ViewsSqlTest { ); } - function testEmpty() { - $this->_testHideIfEmpty(); - $this->_testEmptyText(); - } - /** * Tests the hide if empty functionality. * * This tests alters the result to get easier and less coupled results. */ - function _testHideIfEmpty() { + public function testHideIfEmpty() { $view = $this->getBasicView(); $view->init_display(); $this->executeView($view); @@ -139,7 +141,8 @@ class ViewsHandlerFieldTest extends ViewsSqlTest { $render = $view->field['name']->advanced_render($view->result[0]); $this->assertIdentical($render, $random_name, 'If the rewritten string is not empty, "0" should not be treated as empty.'); - // Test when results are rewritten to an empty string and non-zero empty results are hidden. + // Test when results are rewritten to an empty string and non-zero empty + // results are hidden. $view->field['name']->options['hide_alter_empty'] = TRUE; $view->field['name']->options['hide_empty'] = TRUE; $view->field['name']->options['empty_zero'] = FALSE; @@ -254,7 +257,7 @@ class ViewsHandlerFieldTest extends ViewsSqlTest { /** * Tests the usage of the empty text. */ - function _testEmptyText() { + public function testEmptyText() { $view = $this->getBasicView(); $view->init_display(); $this->executeView($view); @@ -291,7 +294,7 @@ class ViewsHandlerFieldTest extends ViewsSqlTest { /** * Tests views_handler_field::is_value_empty(). */ - function testIsValueEmpty() { + public function testIsValueEmpty() { $view = $this->getBasicView(); $view->init_display(); $view->init_handlers(); diff --git a/sites/all/modules/views/tests/handlers/views_handler_field_boolean.test b/sites/all/modules/views/tests/handlers/views_handler_field_boolean.test index 286b942..38eb38c 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_field_boolean.test +++ b/sites/all/modules/views/tests/handlers/views_handler_field_boolean.test @@ -18,7 +18,7 @@ class ViewsHandlerFieldBooleanTest extends ViewsSqlTest { } function dataSet() { - // Use default dataset but remove the age from john and paul + // Use default dataset but remove the age from john and paul. $data = parent::dataSet(); $data[0]['age'] = 0; $data[3]['age'] = 0; @@ -105,4 +105,5 @@ class ViewsHandlerFieldBooleanTest extends ViewsSqlTest { $this->assertNotEqual($values['false'], $view->field['age']->advanced_render($view->result[0])); $this->assertNotEqual($values['true'], $view->field['age']->advanced_render($view->result[1])); } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_field_counter.test b/sites/all/modules/views/tests/handlers/views_handler_field_counter.test index 2ddcb6f..9a4766a 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_field_counter.test +++ b/sites/all/modules/views/tests/handlers/views_handler_field_counter.test @@ -48,7 +48,7 @@ class ViewsHandlerFilterCounterTest extends ViewsSqlTest { 'table' => 'views', 'field' => 'counter', 'relationship' => 'none', - 'counter_start' => $rand_start + 'counter_start' => $rand_start, ), 'name' => array( 'id' => 'name', @@ -64,7 +64,8 @@ class ViewsHandlerFilterCounterTest extends ViewsSqlTest { $this->assertEqual(2 + $rand_start, $view->style_plugin->rendered_fields[2]['counter']); } - // @TODO: Write tests for pager. + // @todo Write tests for pager. function testPager() { } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_field_custom.test b/sites/all/modules/views/tests/handlers/views_handler_field_custom.test index b45fd17..b8f8a08 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_field_custom.test +++ b/sites/all/modules/views/tests/handlers/views_handler_field_custom.test @@ -44,4 +44,5 @@ class ViewsHandlerFieldCustomTest extends ViewsSqlTest { $this->assertEqual($random, $view->style_plugin->get_field(0, 'name')); } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_field_date.test b/sites/all/modules/views/tests/handlers/views_handler_field_date.test index 7944142..54cbf0e 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_field_date.test +++ b/sites/all/modules/views/tests/handlers/views_handler_field_date.test @@ -9,6 +9,10 @@ * Tests the core views_handler_field_date handler. */ class ViewsHandlerFieldDateTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Field: Date', @@ -17,12 +21,18 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest { ); } + /** + * + */ function viewsData() { $data = parent::viewsData(); $data['views_test']['created']['field']['handler'] = 'views_handler_field_date'; return $data; } + /** + * + */ public function testFieldDate() { $view = $this->getBasicView(); @@ -32,7 +42,8 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest { 'table' => 'views_test', 'field' => 'created', 'relationship' => 'none', - // c is iso 8601 date format @see http://php.net/manual/en/function.date.php + // c is iso 8601 date format. + // @see http://php.net/manual/en/function.date.php 'custom_date_format' => 'c', 'second_date_format' => 'custom', 'second_date_format_custom' => 'c', @@ -62,13 +73,17 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest { $intervals = array( 'raw time ago' => format_interval(REQUEST_TIME - $time, 2), 'time ago' => t('%time ago', array('%time' => format_interval(REQUEST_TIME - $time, 2))), - // TODO write tests for them -// 'raw time span' => format_interval(REQUEST_TIME - $time, 2), -// 'time span' => t('%time hence', array('%time' => format_interval(REQUEST_TIME - $time, 2))), + // @todo write tests for them + // 'raw time span' => format_interval(REQUEST_TIME - $time, 2), + // 'time span' => t('%time hence', + // array('%time' => format_interval(REQUEST_TIME - $time, 2))), ); $this->assertRenderedDatesEqual($view, $intervals); } + /** + * + */ protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) { foreach ($map as $date_format => $expected_result) { $check_result_number = 0; @@ -114,4 +129,5 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest { return $data; } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_field_file_extension.test b/sites/all/modules/views/tests/handlers/views_handler_field_file_extension.test index ab8b0a9..ddc12f9 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_field_file_extension.test +++ b/sites/all/modules/views/tests/handlers/views_handler_field_file_extension.test @@ -63,4 +63,5 @@ class ViewsHandlerFileExtensionTest extends ViewsSqlTest { $this->assertEqual($view->field['name']->advanced_render($view->result[2]), 'tar.gz'); $this->assertEqual($view->field['name']->advanced_render($view->result[3]), ''); } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_field_file_size.test b/sites/all/modules/views/tests/handlers/views_handler_field_file_size.test index 8652754..a8828c7 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_field_file_size.test +++ b/sites/all/modules/views/tests/handlers/views_handler_field_file_size.test @@ -61,4 +61,5 @@ class ViewsHandlerTestFileSize extends ViewsSqlTest { $this->assertEqual($view->field['age']->advanced_render($view->result[2]), 1000); $this->assertEqual($view->field['age']->advanced_render($view->result[3]), 10000); } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_field_math.test b/sites/all/modules/views/tests/handlers/views_handler_field_math.test index ac33ac4..cd39528 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_field_math.test +++ b/sites/all/modules/views/tests/handlers/views_handler_field_math.test @@ -42,4 +42,5 @@ class ViewsHandlerFieldMath extends ViewsSqlTest { $this->assertEqual($rand1 + $rand2, $view->style_plugin->get_field(0, 'expression')); } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_field_url.test b/sites/all/modules/views/tests/handlers/views_handler_field_url.test index 527e94f..ad6f71d 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_field_url.test +++ b/sites/all/modules/views/tests/handlers/views_handler_field_url.test @@ -57,4 +57,5 @@ class ViewsHandlerFieldUrlTest extends ViewsSqlTest { $this->assertEqual(l('John', 'John'), $view->field['name']->advanced_render($view->result[0])); } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_field_xss.test b/sites/all/modules/views/tests/handlers/views_handler_field_xss.test index 65a1ce2..c12a408 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_field_xss.test +++ b/sites/all/modules/views/tests/handlers/views_handler_field_xss.test @@ -23,7 +23,7 @@ class ViewsHandlerTestXss extends ViewsSqlTest { $map = array( 'John' => 'John', "Foo\xC0barbaz" => '', - 'Fooÿñ' => 'Fooÿñ' + 'Fooÿñ' => 'Fooÿñ', ); return $map; @@ -57,4 +57,5 @@ class ViewsHandlerTestXss extends ViewsSqlTest { $counter++; } } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_filter_combine.test b/sites/all/modules/views/tests/handlers/views_handler_filter_combine.test index 99bf1eb..57d5e6f 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_filter_combine.test +++ b/sites/all/modules/views/tests/handlers/views_handler_filter_combine.test @@ -102,4 +102,5 @@ class ViewsHandlerFilterCombineTest extends ViewsSqlTest { unset($schema['views_test']['fields']['job']['not null']); return $schema; } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_filter_date.test b/sites/all/modules/views/tests/handlers/views_handler_filter_date.test index 8b92ccb..ad6a98b 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_filter_date.test +++ b/sites/all/modules/views/tests/handlers/views_handler_filter_date.test @@ -168,7 +168,7 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest { $view = $this->views_test_between(); $view->save(); - $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); + $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); $this->drupalLogin($admin_user); menu_rebuild(); $this->drupalGet('admin/structure/views/view/test_filter_date_between/edit'); @@ -182,7 +182,7 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest { } function views_test_between() { - $view = new view; + $view = new view(); $view->name = 'test_filter_date_between'; $view->description = ''; $view->tag = ''; @@ -218,4 +218,5 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest { $view = $this->views_test_between(); return $view; } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_filter_equality.test b/sites/all/modules/views/tests/handlers/views_handler_filter_equality.test index 5bb48c8..a1dbc4e 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_filter_equality.test +++ b/sites/all/modules/views/tests/handlers/views_handler_filter_equality.test @@ -34,7 +34,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest { function testEqual() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -59,7 +59,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: =, Value: Ringo + // Filter: Name, Operator: =, Value: Ringo. $filters['name']['group_info']['default_group'] = 1; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -76,7 +76,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest { function testNotEqual() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -110,7 +110,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: !=, Value: Ringo + // Filter: Name, Operator: !=, Value: Ringo. $filters['name']['group_info']['default_group'] = 2; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); diff --git a/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test b/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test index 2ab1aea..a18e20a 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test +++ b/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test @@ -38,7 +38,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { public function testFilterNumericSimple() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'age' => array( 'id' => 'age', @@ -82,7 +82,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { public function testFilterNumericBetween() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'age' => array( 'id' => 'age', @@ -114,11 +114,11 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); - // test not between + // test not between. $view->delete(); $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'age' => array( 'id' => 'age', @@ -160,7 +160,6 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); - $this->executeView($view); $resultset = array( array( @@ -188,7 +187,6 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); - $this->executeView($view); $resultset = array( array( @@ -211,7 +209,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { public function testFilterNumericEmpty() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'age' => array( 'id' => 'age', @@ -223,14 +221,13 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { )); $this->executeView($view); - $resultset = array( - ); + $resultset = array(); $this->assertIdenticalResultset($view, $resultset, $this->column_map); $view->delete(); $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'age' => array( 'id' => 'age', @@ -243,7 +240,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { $this->executeView($view); $resultset = array( - array( + array( 'name' => 'John', 'age' => 25, ), @@ -272,15 +269,13 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Age, Operator: empty, Value: + // Filter: Age, Operator: empty, Value. $filters['age']['group_info']['default_group'] = 4; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); - $this->executeView($view); - $resultset = array( - ); + $resultset = array(); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -288,15 +283,14 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Age, Operator: empty, Value: + // Filter: Age, Operator: empty, Value. $filters['age']['group_info']['default_group'] = 5; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); - $this->executeView($view); $resultset = array( - array( + array( 'name' => 'John', 'age' => 25, ), @@ -320,6 +314,38 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { $this->assertIdenticalResultset($view, $resultset, $this->column_map); } + /** + * Tests the limit operators functionality. + */ + public function testFilterNumericExposedLimitOperators() { + $filters = $this->getGroupedExposedFilters(); + $view = $this->getBasicView(); + + $available_operators = array('<', '>', 'between'); + + $filters['age']['expose'] += array( + 'limit_operators' => TRUE, + 'available_operators' => drupal_map_assoc($available_operators), + ); + + $view->display['default']->handler->override_option('filters', $filters); + + + $this->executeView($view); + + $form = array(); + $form_state = array(); + $view->filter['age']->operator_form($form, $form_state); + + $operator = $form['operator']; + + $this->assertTrue(in_array($operator['#default_value'], $available_operators), 'Default value operator found in list of available operators.'); + + foreach ($available_operators as $available_operator) { + $this->assertTrue($operator['#options'][$available_operator], format_string('@operator found in options', array('@operator' => $available_operator))); + } + } + public function testAllowEmpty() { $view = $this->getBasicView(); diff --git a/sites/all/modules/views/tests/handlers/views_handler_filter_string.test b/sites/all/modules/views/tests/handlers/views_handler_filter_string.test index ee74a28..ab6af92 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_filter_string.test +++ b/sites/all/modules/views/tests/handlers/views_handler_filter_string.test @@ -75,7 +75,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringEqual() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -100,7 +100,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: =, Value: Ringo + // Filter: Name, Operator: =, Value: Ringo. $filters['name']['group_info']['default_group'] = 1; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -119,7 +119,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringNotEqual() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -153,7 +153,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: !=, Value: Ringo + // Filter: Name, Operator: !=, Value: Ringo. $filters['name']['group_info']['default_group'] = '2'; $view->set_display('page_1'); @@ -182,7 +182,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringContains() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -208,7 +208,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: contains, Value: ing + // Filter: Name, Operator: contains, Value: ing. $filters['name']['group_info']['default_group'] = '3'; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -228,7 +228,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringWord() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -254,7 +254,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -277,10 +277,10 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringGroupedExposedWord() { - $filters = $this->getGroupedExposedFilters(); + $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: contains, Value: ing + // Filter: Name, Operator: contains, Value: ing. $filters['name']['group_info']['default_group'] = '3'; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -299,7 +299,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Description, Operator: contains, Value: actor + // Filter: Description, Operator: contains, Value: actor. $filters['description']['group_info']['default_group'] = '1'; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -319,7 +319,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringStarts() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -344,7 +344,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: starts, Value: George + // Filter: Name, Operator: starts, Value: George. $filters['description']['group_info']['default_group'] = 2; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -362,7 +362,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringNotStarts() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -385,7 +385,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -394,7 +394,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: not_starts, Value: George + // Filter: Name, Operator: not_starts, Value: George. $filters['description']['group_info']['default_group'] = 3; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -411,7 +411,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -419,7 +419,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringEnds() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -447,7 +447,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Descriptino, Operator: ends, Value: Beatles + // Filter: Descriptino, Operator: ends, Value: Beatles. $filters['description']['group_info']['default_group'] = 4; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -468,7 +468,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringNotEnds() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -488,7 +488,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -497,7 +497,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Description, Operator: not_ends, Value: Beatles + // Filter: Description, Operator: not_ends, Value: Beatles. $filters['description']['group_info']['default_group'] = 5; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -511,7 +511,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -519,7 +519,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringNot() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -539,7 +539,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -549,7 +549,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Description, Operator: not (does not contains), Value: Beatles + // Filter: Description, Operator: not (does not contains), Value: Beatles. $filters['description']['group_info']['default_group'] = 6; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -563,7 +563,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); @@ -572,7 +572,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringShorter() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -620,7 +620,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringLonger() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -663,7 +663,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringEmpty() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -687,7 +687,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Description, Operator: empty, Value: + // Filter: Description, Operator: empty, Value. $filters['description']['group_info']['default_group'] = 7; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); diff --git a/sites/all/modules/views/tests/handlers/views_handler_manytoone.test b/sites/all/modules/views/tests/handlers/views_handler_manytoone.test new file mode 100644 index 0000000..fb06645 --- /dev/null +++ b/sites/all/modules/views/tests/handlers/views_handler_manytoone.test @@ -0,0 +1,1099 @@ + 'Handler: Many To One Helper', + 'description' => 'Tests the many to one helper handler', + 'group' => 'Views Handlers', + ); + } + + /** + * Clears views data cache. + */ + protected function clearViewsDataCache() { + drupal_static_reset('_views_fetch_data_cache'); + drupal_static_reset('_views_fetch_data_recursion_protected'); + drupal_static_reset('_views_fetch_data_fully_loaded'); + } + + /** + * Returns a new term with random properties. + * + * @param string $vocabulary + * Vocabulary ID to create term in. + * + * @return object + * Term with random properties. + */ + protected function createTerm($vocabulary) { + $term = new stdClass(); + $term->name = $this->randomName(); + $term->description = $this->randomName(); + // Use the first available text format. + $term->format = db_query_range('SELECT format FROM {filter_format}', 0, 1)->fetchField(); + $term->vid = $vocabulary->vid; + taxonomy_term_save($term); + return $term; + } + + /** + * {@inheritdoc} + */ + public function setUp() { + parent::setUp(); + + // Create boolean field. + $this->fields[0] = array( + 'field_name' => 'field_bool', + 'type' => 'list_boolean', + 'cardinality' => 1, + 'settings' => array( + 'allowed_values' => array( + 0 => '', + 1 => '', + ), + ), + ); + $this->fields[0] = field_create_field($this->fields[0]); + + // Create text list field. + $this->fields[1] = array( + 'field_name' => 'field_list', + 'type' => 'list_text', + 'cardinality' => FIELD_CARDINALITY_UNLIMITED, + 'settings' => array( + 'allowed_values' => array( + 1 => '1', + 2 => '2', + 3 => '3', + ), + ), + ); + $this->fields[1] = field_create_field($this->fields[1]); + + // Create boolean field instance for article nodes. + $instance = array( + 'field_name' => $this->fields[0]['field_name'], + 'entity_type' => 'node', + 'bundle' => 'article', + 'widget' => array( + 'type' => 'options_onoff', + ), + ); + $this->instances[0][] = field_create_instance($instance); + + // Create text list field instance for article nodes. + $instance = array( + 'field_name' => $this->fields[1]['field_name'], + 'entity_type' => 'node', + 'bundle' => 'article', + 'widget' => array( + 'type' => 'options_buttons', + ), + ); + $this->instances[1][] = field_create_instance($instance); + + // Create boolean field instance for users. + $instance = array( + 'field_name' => $this->fields[0]['field_name'], + 'entity_type' => 'user', + 'bundle' => 'user', + 'widget' => array( + 'type' => 'options_onoff', + ), + ); + $this->instances[0][] = field_create_instance($instance); + + // Create text list field instance for users. + $instance = array( + 'field_name' => $this->fields[1]['field_name'], + 'entity_type' => 'user', + 'bundle' => 'user', + 'widget' => array( + 'type' => 'options_buttons', + ), + ); + $this->instances[1][] = field_create_instance($instance); + + // Create tags field instance for users. + $instance = array( + 'field_name' => 'field_tags', + 'entity_type' => 'user', + 'bundle' => 'user', + ); + $this->instances[2][] = field_create_instance($instance); + + // Clear views data cache. + $this->clearViewsDataCache(); + + // Create 62 tags. + $vocabulary = taxonomy_vocabulary_machine_name_load('tags'); + for ($i = 0; $i < 62; $i++) { + $this->terms[] = $this->createTerm($vocabulary); + } + + // Create a node where the field_bool is checked, field_list is '1' and + // tag is term 2. + $node = array(); + $node['type'] = 'article'; + $node[$this->fields[0]['field_name']][LANGUAGE_NONE][]['value'] = '1'; + $node[$this->fields[1]['field_name']][LANGUAGE_NONE][]['value'] = '1'; + $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[1]->tid; + $this->nodes[0] = $this->drupalCreateNode($node); + + // Create a node where the field_bool is not checked, field_list is empty + // and tag is term 1. + $node = array(); + $node['type'] = 'article'; + $node[$this->fields[0]['field_name']] = array(); + $node[$this->fields[1]['field_name']] = array(); + $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[0]->tid; + $this->nodes[1] = $this->drupalCreateNode($node); + + // Create a node where the field_bool is not checked, field_list is empty + // and tag is term 1 and 2. + $node = array(); + $node['type'] = 'article'; + $node[$this->fields[0]['field_name']] = array(); + $node[$this->fields[1]['field_name']] = array(); + $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[0]->tid; + $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[1]->tid; + $this->nodes[2] = $this->drupalCreateNode($node); + + // Create a user where field_bool is checked, field_list is '1' and tag is + // term 1. + $permissions = array('access content'); + $account = $this->drupalCreateUser($permissions); + $account->{$this->fields[0]['field_name']}[LANGUAGE_NONE][]['value'] = '1'; + $account->{$this->fields[1]['field_name']}[LANGUAGE_NONE][]['value'] = '1'; + $account->field_tags[LANGUAGE_NONE][]['tid'] = $this->terms[0]->tid; + $this->accounts[0] = user_save($account); + } + + /** + * Tests "none of" filter with terms in excess of JOIN limit selected. + */ + public function testJoinLimitNoneOf() { + $view = $this->getJoinLimitNoneOfTestView(); + $this->executeView($view); + + // Assert that nodes have been created and have expected field values. + $value = field_get_items('node', $this->nodes[0], 'field_tags', LANGUAGE_NONE); + $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0; + $this->assertIdentical($value, 2, 'First node has been created and tags field references term 2.'); + + $value = field_get_items('node', $this->nodes[1], 'field_tags', LANGUAGE_NONE); + $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0; + $this->assertIdentical($value, 1, 'Second node has been created and tags field references term 1.'); + + // Assert that user has been created and has expected field values. + $value = field_get_items('user', $this->accounts[0], 'field_tags', LANGUAGE_NONE); + $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0; + $this->assertIdentical($value, 1, 'User has been created and tags field references term 1.'); + + // Assert that node id with empty field value matches user id so that the + // node would be excluded from the result, if the joins are missing extras. + $this->assertIdentical((int) $this->accounts[0]->uid, (int) $this->nodes[1]->nid, 'Node id of second node matches uid of first user.'); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 1, 'View has one result.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $this->assertIdentical($nid, (int) $this->nodes[1]->nid, 'View result has correct node id.'); + } + + /** + * Tests duplicate grouped "none of" filters on boolean field. + */ + public function testGroupedNoneOf() { + $view = $this->getGroupedNoneOfTestView(); + $this->executeView($view); + + // Assert that nodes have been created and have expected field values. + $value = field_get_items('node', $this->nodes[0], $this->fields[0]['field_name'], LANGUAGE_NONE); + $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0; + $this->assertIdentical($value, 1, 'First node has been created and boolean field is checked.'); + + $value = field_get_items('node', $this->nodes[1], $this->fields[0]['field_name'], LANGUAGE_NONE); + $this->assertFalse($value, 'Second node has been created and boolean field is not checked.'); + + $value = field_get_items('node', $this->nodes[2], $this->fields[0]['field_name'], LANGUAGE_NONE); + $this->assertFalse($value, 'Third node has been created and boolean field is not checked.'); + + // Assert that user has been created and has expected field values. + $value = field_get_items('user', $this->accounts[0], $this->fields[0]['field_name'], LANGUAGE_NONE); + $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0; + $this->assertIdentical($value, 1, 'User has been created and boolean field is checked.'); + + // Assert that node ID with empty field value matches user ID so that the + // node would be excluded from the result, if the joins are missing extras. + $this->assertIdentical((int) $this->accounts[0]->uid, (int) $this->nodes[1]->nid, 'Node ID of second node matches UID of first user.'); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 2, 'View has two results.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $result1 = ($nid === (int) $this->nodes[1]->nid); + $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0; + $result2 = ($nid === (int) $this->nodes[2]->nid); + $this->assertTrue($result1 && $result2, 'View result has correct node IDs.'); + } + + /** + * Tests duplicate grouped "one of" filters on taxonomy term field. + */ + public function testGroupedOneOf() { + $view = $this->getGroupedOneOfTestView(); + $this->executeView($view); + + // Assert that nodes have been created and have expected field values. + $value = field_get_items('node', $this->nodes[0], 'field_tags', LANGUAGE_NONE); + $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0; + $this->assertIdentical($value, 2, 'First node has been created and tags field references term 2.'); + + $value = field_get_items('node', $this->nodes[1], 'field_tags', LANGUAGE_NONE); + $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0; + $this->assertIdentical($value, 1, 'Second node has been created and tags field references term 1.'); + + $value = field_get_items('node', $this->nodes[2], 'field_tags', LANGUAGE_NONE); + $value = !empty($value[0]['tid']) && !empty($value[1]['tid']); + $this->assertTrue($value, 'Third node has been created and tags field references both terms 1 and 2.'); + + // Assert that user has been created and has expected field values. + $value = field_get_items('user', $this->accounts[0], 'field_tags', LANGUAGE_NONE); + $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0; + $this->assertIdentical($value, 1, 'User has been created and tags field references term 1.'); + + // Assert that node ID with empty field value matches user ID so that the + // node would be excluded from the result, if the joins are missing extras. + $this->assertIdentical((int) $this->accounts[0]->uid, (int) $this->nodes[1]->nid, 'Node ID of second node matches UID of first user.'); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 2, 'View has two results.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $result1 = ($nid === (int) $this->nodes[1]->nid); + $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0; + $result2 = ($nid === (int) $this->nodes[2]->nid); + $this->assertTrue($result1 && $result2, 'View result has correct node IDs.'); + } + + /** + * Tests exposed filter with "Reduce duplicates." and grouped options. + */ + public function testReducedExposedGroupedOptions() { + // Assert that nodes have been created and have expected field values. + $value = field_get_items('node', $this->nodes[0], 'field_list', LANGUAGE_NONE); + $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0; + $this->assertIdentical($value, 1, 'First node has been created and list field has value 1.'); + + $value = field_get_items('node', $this->nodes[1], 'field_list', LANGUAGE_NONE); + $this->assertFalse($value, 'Second node has been created and list field is empty.'); + + $value = field_get_items('node', $this->nodes[2], 'field_list', LANGUAGE_NONE); + $this->assertFalse($value, 'Third node has been created and list field is empty.'); + + // Assert that user has been created and has expected field values. + $value = field_get_items('user', $this->accounts[0], 'field_list', LANGUAGE_NONE); + $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0; + $this->assertIdentical($value, 1, 'User has been created and list field has value 1.'); + + // Assert that node ID with empty field value matches user ID so that the + // node would be excluded from the result option 1, if the joins are missing + // extras. + $this->assertIdentical((int) $this->accounts[0]->uid, (int) $this->nodes[1]->nid, 'Node ID of second node matches UID of first user.'); + + // Default option: Any. + $view = $this->getReducedExposedGroupedOptionsTestView(); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 3, 'Default option: View has three results.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $result1 = ($nid === (int) $this->nodes[0]->nid); + $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0; + $result2 = ($nid === (int) $this->nodes[1]->nid); + $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0; + $result3 = ($nid === (int) $this->nodes[2]->nid); + $this->assertTrue($result1 && $result2 && $result3, 'Default option: View result has correct node ID.'); + + // Option 1: Is none of 1 or 2. + $view = $this->getReducedExposedGroupedOptionsTestView(); + $view->set_exposed_input(array( + 'field_list_value' => '1', + )); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 2, 'Option 1: View has two results.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $result1 = ($nid === (int) $this->nodes[1]->nid); + $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0; + $result2 = ($nid === (int) $this->nodes[2]->nid); + $this->assertTrue($result1 && $result2, 'Option 1: View result has correct node ID.'); + + // Option 2: Is one of 1. + $view = $this->getReducedExposedGroupedOptionsTestView(); + $view->set_exposed_input(array( + 'field_list_value' => '2', + )); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 1, 'Option 2: View has one result.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $this->assertIdentical($nid, (int) $this->nodes[0]->nid, 'Option 2: View result has correct node ID.'); + + // Option 3: Is one of 1 or 2. + $view = $this->getReducedExposedGroupedOptionsTestView(); + $view->set_exposed_input(array( + 'field_list_value' => '3', + )); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 1, 'Option 3: View has one result.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $this->assertIdentical($nid, (int) $this->nodes[0]->nid, 'Option 3: View result has correct node ID.'); + + /* @todo: Fix and uncomment in issue #3045168. + * // Option 4: Is all of 1 and 2. + * $view = $this->getReducedExposedGroupedOptionsTestView(); + * $view->set_exposed_input(array( + * 'field_list_value' => '4', + * )); + * $this->executeView($view); + * + * // Assert correct result set. + * $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 1; + * $this->assertEqual($result_count, 0, 'Option 4: View has empty result.'); + */ + + // Option 5: Is empty. + $view = $this->getReducedExposedGroupedOptionsTestView(); + $view->set_exposed_input(array( + 'field_list_value' => '5', + )); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 2, 'Option 5: View has two results.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $result1 = ($nid === (int) $this->nodes[1]->nid); + $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0; + $result2 = ($nid === (int) $this->nodes[2]->nid); + $this->assertTrue($result1 && $result2, 'Option 5: View result has correct node IDs.'); + + // Option 6: Is not empty. + $view = $this->getReducedExposedGroupedOptionsTestView(); + $view->set_exposed_input(array( + 'field_list_value' => '6', + )); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 1, 'Option 6: View has one result.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $this->assertIdentical($nid, (int) $this->nodes[0]->nid, 'Option 6: View result has correct node ID.'); + } + + /** + * Tests exposed filter on term ID with grouped options. + */ + public function testTermIdExposedGroupedOptions() { + // Assert that nodes have been created and have expected field values. + $value = field_get_items('node', $this->nodes[0], 'field_tags', LANGUAGE_NONE); + $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0; + $this->assertIdentical($value, 2, 'First node has been created and tags field references term 2.'); + + $value = field_get_items('node', $this->nodes[1], 'field_tags', LANGUAGE_NONE); + $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0; + $this->assertIdentical($value, 1, 'Second node has been created and tags field references term 1.'); + + // Assert that user has been created and has expected field values. + $value = field_get_items('user', $this->accounts[0], 'field_tags', LANGUAGE_NONE); + $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0; + $this->assertIdentical($value, 1, 'User has been created and tags field references term 1.'); + + // Assert that node ID with empty field value matches user ID so that the + // node would be excluded from the result option 1, if the joins are missing + // extras. + $this->assertIdentical((int) $this->accounts[0]->uid, (int) $this->nodes[1]->nid, 'Node ID of second node matches UID of first user.'); + + // Default option: Any. + $view = $this->getTermIdExposedGroupedOptionsTestView(); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 3, 'Default option: View has three results.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $result1 = ($nid === (int) $this->nodes[0]->nid); + $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0; + $result2 = ($nid === (int) $this->nodes[1]->nid); + $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0; + $result3 = ($nid === (int) $this->nodes[2]->nid); + $this->assertTrue($result1 && $result2 && $result3, 'Default option: View result has correct node ID.'); + + // Option 1: Is none of 2. + $view = $this->getTermIdExposedGroupedOptionsTestView(); + $view->set_exposed_input(array( + 'field_tags_tid' => '1', + )); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 1, 'Option 1: View has one result.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $this->assertIdentical($nid, (int) $this->nodes[1]->nid, 'Option 1: View result has correct node ID.'); + + // Option 2: Is none of 1 or 2. + $view = $this->getTermIdExposedGroupedOptionsTestView(); + $view->set_exposed_input(array( + 'field_tags_tid' => '2', + )); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 1; + $this->assertEqual($result_count, 0, 'Option 2: View has empty result.'); + + // Option 3: Is one of 1. + $view = $this->getTermIdExposedGroupedOptionsTestView(); + $view->set_exposed_input(array( + 'field_tags_tid' => '3', + )); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $this->assertEqual($result_count, 2, 'Option 3: View has two results.'); + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $result1 = ($nid === (int) $this->nodes[1]->nid); + $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0; + $result2 = ($nid === (int) $this->nodes[2]->nid); + $this->assertTrue($result1 && $result2, 'Option 3: View result has correct node ID.'); + + // Option 4: Is one of 1 or 2. + $view = $this->getTermIdExposedGroupedOptionsTestView(); + $view->set_exposed_input(array( + 'field_tags_tid' => '4', + )); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $result1 = ($nid === (int) $this->nodes[0]->nid); + $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0; + $result2 = ($nid === (int) $this->nodes[1]->nid); + $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0; + $result3 = ($nid === (int) $this->nodes[2]->nid); + $nid = isset($view->result[3]->nid) ? (int) $view->result[3]->nid : 0; + $result4 = ($nid === (int) $this->nodes[2]->nid); + $this->assertTrue($result1 && $result2 && $result3 && $result4, 'Option 4: View result has correct node ID.'); + $this->verbose($view->result); + $this->assertEqual($result_count, 4, 'Option 4: View has four results.'); + + /* @todo: Fix and uncomment in issue #3045168. + * // Option 5: Is all of 1 and 2. + * $view = $this->getTermIdExposedGroupedOptionsTestView(); + * $view->set_exposed_input(array( + * 'field_tags_tid' => '5', + * )); + * $this->executeView($view); + * + * // Assert correct result set. + * $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + * $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + * $this->assertIdentical($nid, (int) $this->nodes[2]->nid, 'Option 5: View result has correct node ID.'); + * $this->assertIdentical($result_count, 1, 'Option 5: View has one result.'); + */ + + // Option 6: Is empty. + $view = $this->getTermIdExposedGroupedOptionsTestView(); + $view->set_exposed_input(array( + 'field_tags_tid' => '6', + )); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 1; + $this->assertIdentical($result_count, 0, 'Option 6: View has empty result.'); + + // Option 7: Is not empty. + $view = $this->getTermIdExposedGroupedOptionsTestView(); + $view->set_exposed_input(array( + 'field_tags_tid' => '7', + )); + $this->executeView($view); + + // Assert correct result set. + $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0; + $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0; + $result1 = ($nid === (int) $this->nodes[0]->nid); + $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0; + $result2 = ($nid === (int) $this->nodes[1]->nid); + $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0; + $result3 = ($nid === (int) $this->nodes[2]->nid); + $nid = isset($view->result[3]->nid) ? (int) $view->result[3]->nid : 0; + $result4 = ($nid === (int) $this->nodes[2]->nid); + $this->assertTrue($result1 && $result2 && $result3 && $result4, 'Option 7: View result has correct node ID.'); + $this->verbose($view->result); + $this->assertIdentical($result_count, 4, 'Option 7: View has four results.'); + } + + /** + * Generates test_not view. + */ + protected function getGroupedNoneOfTestView() { + $view = new view(); + $view->name = 'test_not'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'test_not'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Nid */ + $handler->display->display_options['sorts']['nid']['id'] = 'nid'; + $handler->display->display_options['sorts']['nid']['table'] = 'node'; + $handler->display->display_options['sorts']['nid']['field'] = 'nid'; + $handler->display->display_options['filter_groups']['operator'] = 'OR'; + $handler->display->display_options['filter_groups']['groups'] = array( + 1 => 'AND', + 2 => 'AND', + ); + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'article' => 'article', + ); + $handler->display->display_options['filters']['type']['group'] = 1; + /* Filter criterion: Field: field_bool (field_bool) */ + $handler->display->display_options['filters']['field_bool_value']['id'] = 'field_bool_value'; + $handler->display->display_options['filters']['field_bool_value']['table'] = 'field_data_field_bool'; + $handler->display->display_options['filters']['field_bool_value']['field'] = 'field_bool_value'; + $handler->display->display_options['filters']['field_bool_value']['operator'] = 'not'; + $handler->display->display_options['filters']['field_bool_value']['value'] = array( + 1 => '1', + ); + $handler->display->display_options['filters']['field_bool_value']['group'] = 1; + /* Filter criterion: Field: field_bool (field_bool) */ + $handler->display->display_options['filters']['field_bool_value_1']['id'] = 'field_bool_value_1'; + $handler->display->display_options['filters']['field_bool_value_1']['table'] = 'field_data_field_bool'; + $handler->display->display_options['filters']['field_bool_value_1']['field'] = 'field_bool_value'; + $handler->display->display_options['filters']['field_bool_value_1']['operator'] = 'not'; + $handler->display->display_options['filters']['field_bool_value_1']['value'] = array( + 1 => '1', + ); + $handler->display->display_options['filters']['field_bool_value_1']['group'] = 2; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type_1']['id'] = 'type_1'; + $handler->display->display_options['filters']['type_1']['table'] = 'node'; + $handler->display->display_options['filters']['type_1']['field'] = 'type'; + $handler->display->display_options['filters']['type_1']['value'] = array( + 'article' => 'article', + ); + $handler->display->display_options['filters']['type_1']['group'] = 2; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status_1']['id'] = 'status_1'; + $handler->display->display_options['filters']['status_1']['table'] = 'node'; + $handler->display->display_options['filters']['status_1']['field'] = 'status'; + $handler->display->display_options['filters']['status_1']['value'] = '1'; + $handler->display->display_options['filters']['status_1']['group'] = 2; + + return $view; + } + + /** + * Generates test_oneof view. + */ + protected function getGroupedOneOfTestView() { + $view = new view(); + $view->name = 'test_oneof'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'test_oneof'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Nid */ + $handler->display->display_options['sorts']['nid']['id'] = 'nid'; + $handler->display->display_options['sorts']['nid']['table'] = 'node'; + $handler->display->display_options['sorts']['nid']['field'] = 'nid'; + $handler->display->display_options['filter_groups']['operator'] = 'OR'; + $handler->display->display_options['filter_groups']['groups'] = array( + 1 => 'AND', + 2 => 'AND', + ); + /* Filter criterion: Content: Tags (field_tags) */ + $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags'; + $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['value'] = array( + 1 => '1', + ); + $handler->display->display_options['filters']['field_tags_tid']['group'] = 2; + $handler->display->display_options['filters']['field_tags_tid']['reduce_duplicates'] = TRUE; + $handler->display->display_options['filters']['field_tags_tid']['type'] = 'select'; + $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags'; + /* Filter criterion: Content: Tags (field_tags) */ + $handler->display->display_options['filters']['field_tags_tid_1']['id'] = 'field_tags_tid_1'; + $handler->display->display_options['filters']['field_tags_tid_1']['table'] = 'field_data_field_tags'; + $handler->display->display_options['filters']['field_tags_tid_1']['field'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid_1']['value'] = array( + 1 => '1', + ); + $handler->display->display_options['filters']['field_tags_tid_1']['reduce_duplicates'] = TRUE; + $handler->display->display_options['filters']['field_tags_tid_1']['type'] = 'select'; + $handler->display->display_options['filters']['field_tags_tid_1']['vocabulary'] = 'tags'; + return $view; + } + + /** + * Generates test_reduced_exposed_grouped_options view. + */ + protected function getReducedExposedGroupedOptionsTestView() { + $view = new view(); + $view->name = 'test_reduced_exposed_grouped_options'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'test_reduced_exposed_grouped_options'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Nid */ + $handler->display->display_options['sorts']['nid']['id'] = 'nid'; + $handler->display->display_options['sorts']['nid']['table'] = 'node'; + $handler->display->display_options['sorts']['nid']['field'] = 'nid'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: list (field_list) */ + $handler->display->display_options['filters']['field_list_value']['id'] = 'field_list_value'; + $handler->display->display_options['filters']['field_list_value']['table'] = 'field_data_field_list'; + $handler->display->display_options['filters']['field_list_value']['field'] = 'field_list_value'; + $handler->display->display_options['filters']['field_list_value']['exposed'] = TRUE; + $handler->display->display_options['filters']['field_list_value']['expose']['operator_id'] = 'field_list_value_op'; + $handler->display->display_options['filters']['field_list_value']['expose']['label'] = 'list (field_list)'; + $handler->display->display_options['filters']['field_list_value']['expose']['operator'] = 'field_list_value_op'; + $handler->display->display_options['filters']['field_list_value']['expose']['identifier'] = 'field_list_value'; + $handler->display->display_options['filters']['field_list_value']['is_grouped'] = TRUE; + $handler->display->display_options['filters']['field_list_value']['group_info']['label'] = 'list (field_list)'; + $handler->display->display_options['filters']['field_list_value']['group_info']['identifier'] = 'field_list_value'; + $handler->display->display_options['filters']['field_list_value']['group_info']['group_items'] = array( + 1 => array( + 'title' => 'Not 1 or 2', + 'operator' => 'not', + 'value' => array( + 1 => '1', + 2 => '2', + ), + ), + 2 => array( + 'title' => '1', + 'operator' => 'or', + 'value' => array( + 1 => '1', + ), + ), + 3 => array( + 'title' => '1 or 2', + 'operator' => 'or', + 'value' => array( + 1 => '1', + 2 => '2', + ), + ), + 4 => array( + 'title' => '1 and 2', + 'operator' => 'and', + 'value' => array( + 1 => '1', + 2 => '2', + ), + ), + 5 => array( + 'title' => 'empty', + 'operator' => 'empty', + 'value' => array(), + ), + 6 => array( + 'title' => 'not empty', + 'operator' => 'not empty', + 'value' => array(), + ), + ); + return $view; + } + + /** + * Generates test_tid_exposed_grouped_options view. + */ + protected function getTermIdExposedGroupedOptionsTestView() { + $view = new view(); + $view->name = 'test_tid_exposed_grouped_options'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'test_tid_exposed_grouped_options'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Nid */ + $handler->display->display_options['sorts']['nid']['id'] = 'nid'; + $handler->display->display_options['sorts']['nid']['table'] = 'node'; + $handler->display->display_options['sorts']['nid']['field'] = 'nid'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Tags (field_tags) */ + $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags'; + $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['value'] = array( + 1 => '1', + 2 => '2', + ); + $handler->display->display_options['filters']['field_tags_tid']['exposed'] = TRUE; + $handler->display->display_options['filters']['field_tags_tid']['expose']['operator_id'] = 'field_tags_tid_op'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['label'] = 'Tags (field_tags)'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['operator'] = 'field_tags_tid_op'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['identifier'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['remember_roles'] = array( + 2 => '2', + ); + $handler->display->display_options['filters']['field_tags_tid']['is_grouped'] = TRUE; + $handler->display->display_options['filters']['field_tags_tid']['group_info']['label'] = 'Tags (field_tags)'; + $handler->display->display_options['filters']['field_tags_tid']['group_info']['identifier'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['group_info']['group_items'] = array( + 1 => array( + 'title' => 'Is none of 2', + 'operator' => 'not', + 'value' => array( + 2 => '2', + ), + ), + 2 => array( + 'title' => 'Is none of 1 or 2', + 'operator' => 'not', + 'value' => array( + 1 => '1', + 2 => '2', + ), + ), + 3 => array( + 'title' => 'Is one of 1', + 'operator' => 'or', + 'value' => array( + 1 => '1', + ), + ), + 4 => array( + 'title' => 'Is one of 1 or 2', + 'operator' => 'or', + 'value' => array( + 1 => '1', + 2 => '2', + ), + ), + 5 => array( + 'title' => 'Is all of 1 and 2', + 'operator' => 'and', + 'value' => array( + 1 => '1', + 2 => '2', + ), + ), + 6 => array( + 'title' => 'Is empty', + 'operator' => 'empty', + 'value' => array( + 1 => '1', + 2 => '2', + ), + ), + 7 => array( + 'title' => 'Is not empty', + 'operator' => 'not empty', + 'value' => array( + 1 => '1', + 2 => '2', + ), + ), + ); + $handler->display->display_options['filters']['field_tags_tid']['type'] = 'select'; + $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags'; + return $view; + } + + /** + * Generates test_join_limit_none_of view. + */ + protected function getJoinLimitNoneOfTestView() { + $view = new view(); + $view->name = 'test_join_limit_none_of'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'test_join_limit_none_of'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Tags (field_tags) */ + $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags'; + $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['operator'] = 'not'; + $handler->display->display_options['filters']['field_tags_tid']['value'] = array( + 2 => '2', + 3 => '3', + 4 => '4', + 5 => '5', + 6 => '6', + 7 => '7', + 8 => '8', + 9 => '9', + 10 => '10', + 11 => '11', + 12 => '12', + 13 => '13', + 14 => '14', + 15 => '15', + 16 => '16', + 17 => '17', + 18 => '18', + 19 => '19', + 20 => '20', + 21 => '21', + 22 => '22', + 23 => '23', + 24 => '24', + 25 => '25', + 26 => '26', + 27 => '27', + 28 => '28', + 29 => '29', + 30 => '30', + 31 => '31', + 32 => '32', + 33 => '33', + 34 => '34', + 35 => '35', + 36 => '36', + 37 => '37', + 38 => '38', + 39 => '39', + 40 => '40', + 41 => '41', + 42 => '42', + 43 => '43', + 44 => '44', + 45 => '45', + 46 => '46', + 47 => '47', + 48 => '48', + 49 => '49', + 50 => '50', + 51 => '51', + 52 => '52', + 53 => '53', + 54 => '54', + 55 => '55', + 56 => '56', + 57 => '57', + 58 => '58', + 59 => '59', + 60 => '60', + 61 => '61', + 62 => '62', + 63 => '63', + 64 => '64', + 65 => '65', + 66 => '66', + 67 => '67', + 68 => '68', + 69 => '69', + 61 => '61', + 62 => '62', + ); + $handler->display->display_options['filters']['field_tags_tid']['type'] = 'select'; + $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags'; + return $view; + } + +} diff --git a/sites/all/modules/views/tests/handlers/views_handler_sort.test b/sites/all/modules/views/tests/handlers/views_handler_sort.test index 70f2aac..35708c1 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_sort.test +++ b/sites/all/modules/views/tests/handlers/views_handler_sort.test @@ -23,7 +23,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest { public function testNumericOrdering() { $view = $this->getBasicView(); - // Change the ordering + // Change the ordering. $view->display['default']->handler->override_option('sorts', array( 'age' => array( 'order' => 'ASC', @@ -46,7 +46,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest { $view = $this->getBasicView(); - // Reverse the ordering + // Reverse the ordering. $view->display['default']->handler->override_option('sorts', array( 'age' => array( 'order' => 'DESC', @@ -74,7 +74,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest { public function testStringOrdering() { $view = $this->getBasicView(); - // Change the ordering + // Change the ordering. $view->display['default']->handler->override_option('sorts', array( 'name' => array( 'order' => 'ASC', @@ -97,7 +97,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest { $view = $this->getBasicView(); - // Reverse the ordering + // Reverse the ordering. $view->display['default']->handler->override_option('sorts', array( 'name' => array( 'order' => 'DESC', @@ -118,4 +118,5 @@ class ViewsHandlerSortTest extends ViewsSqlTest { 'views_test_age' => 'age', )); } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_sort_date.test b/sites/all/modules/views/tests/handlers/views_handler_sort_date.test index 65a94e8..4a8c4ca 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_sort_date.test +++ b/sites/all/modules/views/tests/handlers/views_handler_sort_date.test @@ -21,61 +21,66 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { $expected = array(); if (!$reverse) { switch ($granularity) { - case 'second': - $expected = array( - array('name' => 'John'), - array('name' => 'Paul'), - array('name' => 'Meredith'), - array('name' => 'Ringo'), - array('name' => 'George'), - ); - break; - case 'minute': - $expected = array( - array('name' => 'John'), - array('name' => 'Paul'), - array('name' => 'Ringo'), - array('name' => 'Meredith'), - array('name' => 'George'), - ); - break; - case 'hour': - $expected = array( - array('name' => 'John'), - array('name' => 'Ringo'), - array('name' => 'Paul'), - array('name' => 'Meredith'), - array('name' => 'George'), - ); - break; - case 'day': - $expected = array( - array('name' => 'John'), - array('name' => 'Ringo'), - array('name' => 'Paul'), - array('name' => 'Meredith'), - array('name' => 'George'), - ); - break; - case 'month': - $expected = array( - array('name' => 'John'), - array('name' => 'George'), - array('name' => 'Ringo'), - array('name' => 'Paul'), - array('name' => 'Meredith'), - ); - break; - case 'year': - $expected = array( - array('name' => 'John'), - array('name' => 'George'), - array('name' => 'Ringo'), - array('name' => 'Paul'), - array('name' => 'Meredith'), - ); - break; - } + case 'second': + $expected = array( + array('name' => 'John'), + array('name' => 'Paul'), + array('name' => 'Meredith'), + array('name' => 'Ringo'), + array('name' => 'George'), + ); + break; + + case 'minute': + $expected = array( + array('name' => 'John'), + array('name' => 'Paul'), + array('name' => 'Ringo'), + array('name' => 'Meredith'), + array('name' => 'George'), + ); + break; + + case 'hour': + $expected = array( + array('name' => 'John'), + array('name' => 'Ringo'), + array('name' => 'Paul'), + array('name' => 'Meredith'), + array('name' => 'George'), + ); + break; + + case 'day': + $expected = array( + array('name' => 'John'), + array('name' => 'Ringo'), + array('name' => 'Paul'), + array('name' => 'Meredith'), + array('name' => 'George'), + ); + break; + + case 'month': + $expected = array( + array('name' => 'John'), + array('name' => 'George'), + array('name' => 'Ringo'), + array('name' => 'Paul'), + array('name' => 'Meredith'), + ); + break; + + case 'year': + $expected = array( + array('name' => 'John'), + array('name' => 'George'), + array('name' => 'Ringo'), + array('name' => 'Paul'), + array('name' => 'Meredith'), + ); + break; + } } else { switch ($granularity) { @@ -88,6 +93,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { array('name' => 'John'), ); break; + case 'minute': $expected = array( array('name' => 'George'), @@ -95,8 +101,9 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { array('name' => 'Meredith'), array('name' => 'Paul'), array('name' => 'John'), - ); + ); break; + case 'hour': $expected = array( array('name' => 'George'), @@ -106,6 +113,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { array('name' => 'John'), ); break; + case 'day': $expected = array( array('name' => 'George'), @@ -115,6 +123,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { array('name' => 'Meredith'), ); break; + case 'month': $expected = array( array('name' => 'John'), @@ -124,6 +133,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { array('name' => 'Meredith'), ); break; + case 'year': $expected = array( array('name' => 'John'), @@ -163,7 +173,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { ), )); - // Change the ordering + // Change the ordering. $view->display['default']->handler->override_option('sorts', array( 'created' => array( 'id' => 'created', @@ -195,4 +205,5 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { } } } + } diff --git a/sites/all/modules/views/tests/handlers/views_handler_sort_random.test b/sites/all/modules/views/tests/handlers/views_handler_sort_random.test index 19db8a9..b7a620d 100644 --- a/sites/all/modules/views/tests/handlers/views_handler_sort_random.test +++ b/sites/all/modules/views/tests/handlers/views_handler_sort_random.test @@ -9,6 +9,10 @@ * Tests for core views_handler_sort_random handler. */ class ViewsHandlerSortRandomTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Sort: random', @@ -77,7 +81,8 @@ class ViewsHandlerSortRandomTest extends ViewsSqlTest { 'views_test_age' => 'views_test_name', )); - // Execute a second random view, we expect the result set to be different again. + // Execute a second random view, we expect the result set to be different + // again. $view_random_2 = $this->getBasicRandomView(); $this->executeView($view_random_2); $this->assertEqual(count($this->dataSet()), count($view_random_2->result), t('The number of returned rows match.')); @@ -86,4 +91,5 @@ class ViewsHandlerSortRandomTest extends ViewsSqlTest { 'views_test_age' => 'views_test_name', )); } + } diff --git a/sites/all/modules/views/tests/handlers/views_handlers.test b/sites/all/modules/views/tests/handlers/views_handlers.test index f2faee3..6f010ac 100644 --- a/sites/all/modules/views/tests/handlers/views_handlers.test +++ b/sites/all/modules/views/tests/handlers/views_handlers.test @@ -2,7 +2,7 @@ /** * @file - * Contains ViewsHandlerTest. + * Definition of ViewsHandlerTest. */ /** @@ -42,7 +42,7 @@ class ViewsHandlerTest extends ViewsSqlTest { public function testHandlerAccess() { $view = $this->getBasicView(); - // add a test area + // add a test area. $view->display['default']->handler->override_option('header', array( 'test_access' => array( 'id' => 'test_access', @@ -61,7 +61,7 @@ class ViewsHandlerTest extends ViewsSqlTest { $view = $this->getBasicView(); - // add a test area + // add a test area. $view->display['default']->handler->override_option('header', array( 'test_access' => array( 'id' => 'test_access', diff --git a/sites/all/modules/views/tests/node/views_node_revision_relations.test b/sites/all/modules/views/tests/node/views_node_revision_relations.test index 6b38396..e3a50c0 100644 --- a/sites/all/modules/views/tests/node/views_node_revision_relations.test +++ b/sites/all/modules/views/tests/node/views_node_revision_relations.test @@ -174,4 +174,5 @@ class ViewsNodeRevisionRelationsTestCase extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/views/tests/plugins/views_plugin_display.test b/sites/all/modules/views/tests/plugins/views_plugin_display.test index df33a34..7efb2e7 100644 --- a/sites/all/modules/views/tests/plugins/views_plugin_display.test +++ b/sites/all/modules/views/tests/plugins/views_plugin_display.test @@ -10,6 +10,9 @@ */ class ViewsPluginDisplayTestCase extends ViewsSqlTest { + /** + * + */ public static function getInfo() { return array( 'name' => 'Display plugin', @@ -35,6 +38,7 @@ class ViewsPluginDisplayTestCase extends ViewsSqlTest { * Returns a test view for testFilterGroupsOverriding. * * @see testFilterGroupsOverriding + * * @return view */ function viewFilterGroupsOverriding() { @@ -80,7 +84,9 @@ class ViewsPluginDisplayTestCase extends ViewsSqlTest { } /** - * Based on a bug some filter_groups landed in the overridden display, even the filters weren't overridden. + * Based on a bug some filter_groups landed in the overridden display. + * + * Even the filters weren't overridden. * This caused multiple issues. * Take sure that the value from the default display are used. * @@ -191,4 +197,5 @@ class ViewsPluginDisplayTestCase extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/views/tests/styles/views_plugin_style.test b/sites/all/modules/views/tests/styles/views_plugin_style.test index e915d3b..89d2816 100644 --- a/sites/all/modules/views/tests/styles/views_plugin_style.test +++ b/sites/all/modules/views/tests/styles/views_plugin_style.test @@ -78,6 +78,7 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase { $expected = array(); $expected['Job: Singer'] = array(); $expected['Job: Singer']['group'] = 'Job: Singer'; + $expected['Job: Singer']['level'] = '0'; $expected['Job: Singer']['rows'][0] = new StdClass(); $expected['Job: Singer']['rows'][0]->views_test_name = 'John'; $expected['Job: Singer']['rows'][0]->views_test_job = 'Singer'; @@ -88,6 +89,7 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase { $expected['Job: Singer']['rows'][1]->views_test_id = '2'; $expected['Job: Drummer'] = array(); $expected['Job: Drummer']['group'] = 'Job: Drummer'; + $expected['Job: Drummer']['level'] = '0'; $expected['Job: Drummer']['rows'][2] = new StdClass(); $expected['Job: Drummer']['rows'][2]->views_test_name = 'Ringo'; $expected['Job: Drummer']['rows'][2]->views_test_job = 'Drummer'; @@ -161,8 +163,10 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase { $expected = array(); $expected['Job: Singer'] = array(); $expected['Job: Singer']['group'] = 'Job: Singer'; + $expected['Job: Singer']['level'] = 0; $expected['Job: Singer']['rows']['Age: 25'] = array(); $expected['Job: Singer']['rows']['Age: 25']['group'] = 'Age: 25'; + $expected['Job: Singer']['rows']['Age: 25']['level'] = 1; $expected['Job: Singer']['rows']['Age: 25']['rows'][0] = new StdClass(); $expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_name = 'John'; $expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_job = 'Singer'; @@ -170,6 +174,7 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase { $expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_id = '1'; $expected['Job: Singer']['rows']['Age: 27'] = array(); $expected['Job: Singer']['rows']['Age: 27']['group'] = 'Age: 27'; + $expected['Job: Singer']['rows']['Age: 27']['level'] = 1; $expected['Job: Singer']['rows']['Age: 27']['rows'][1] = new StdClass(); $expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_name = 'George'; $expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_job = 'Singer'; @@ -177,15 +182,16 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase { $expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_id = '2'; $expected['Job: Drummer'] = array(); $expected['Job: Drummer']['group'] = 'Job: Drummer'; + $expected['Job: Drummer']['level'] = 0; $expected['Job: Drummer']['rows']['Age: 28'] = array(); $expected['Job: Drummer']['rows']['Age: 28']['group'] = 'Age: 28'; + $expected['Job: Drummer']['rows']['Age: 28']['level'] = 1; $expected['Job: Drummer']['rows']['Age: 28']['rows'][2] = new StdClass(); $expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_name = 'Ringo'; $expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_job = 'Drummer'; $expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_age = '28'; $expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_id = '3'; - // Alter the results to support the stripped case. if ($stripped) { @@ -206,7 +212,6 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase { $view->style_plugin->options['grouping'][1] = array('field' => 'age', 'rendered' => TRUE, 'rendered_strip' => TRUE); } - // The newer api passes the value of the grouping as well. $sets_new_rendered = $view->style_plugin->render_grouping($view->result, $view->style_plugin->options['grouping'], TRUE); @@ -261,4 +266,5 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase { $count++; } } + } diff --git a/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test b/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test index dd4eca0..aadaa56 100644 --- a/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test +++ b/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test @@ -17,6 +17,9 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { */ var $nodes; + /** + * + */ public static function getInfo() { return array( 'name' => 'Jump menu', @@ -25,7 +28,9 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { ); } - + /** + * + */ public function setUp() { parent::setUp(); $this->nodes = array(); @@ -37,7 +42,6 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { $this->nodeTitles = array($this->nodes['page'][0]->title, $this->nodes['page'][1]->title, $this->nodes['story'][0]->title, $this->nodes['story'][1]->title); } - /** * Tests jump menues with more then one same path but maybe differnet titles. */ @@ -46,7 +50,8 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { $view->set_display(); $view->init_handlers(); - // Setup a [path] which would leed to "duplicate" paths, but still the shouldn't be used for grouping. + // Setup a [path] which would leed to "duplicate" paths, but still the + // shouldn't be used for grouping. $view->field['nothing']->options['alter']['text'] = '[path]'; $view->preview(); $form = $view->style_plugin->render($view->result); @@ -65,8 +70,11 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { } } + /** + * + */ function getJumpMenuView() { - $view = new view; + $view = new view(); $view->name = 'test_jump_menu'; $view->description = ''; $view->tag = 'default'; @@ -148,4 +156,5 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/views/tests/styles/views_plugin_style_mapping.test b/sites/all/modules/views/tests/styles/views_plugin_style_mapping.test index 5785075..c73cb57 100644 --- a/sites/all/modules/views/tests/styles/views_plugin_style_mapping.test +++ b/sites/all/modules/views/tests/styles/views_plugin_style_mapping.test @@ -27,7 +27,7 @@ class ViewsPluginStyleMappingTest extends ViewsPluginStyleTestBase { protected function viewsPlugins() { return array( - 'style' => array( + 'style' => array( 'test_mapping' => array( 'title' => t('Field mapping'), 'help' => t('Maps specific fields to specific purposes.'), diff --git a/sites/all/modules/views/tests/styles/views_plugin_style_unformatted.test b/sites/all/modules/views/tests/styles/views_plugin_style_unformatted.test index 0c0e882..eb5cc99 100644 --- a/sites/all/modules/views/tests/styles/views_plugin_style_unformatted.test +++ b/sites/all/modules/views/tests/styles/views_plugin_style_unformatted.test @@ -42,7 +42,7 @@ class ViewsPluginStyleUnformattedTestCase extends ViewsPluginStyleTestBase { if ($count == 1) { $this->assertTrue(strpos($class, "views-row-first") !== FALSE, 'Take sure that the first class is set right.'); } - else if ($count == $count_result) { + elseif ($count == $count_result) { $this->assertTrue(strpos($class, "views-row-last") !== FALSE, 'Take sure that the last class is set right.'); } diff --git a/sites/all/modules/views/tests/taxonomy/views_handler_relationship_node_term_data.test b/sites/all/modules/views/tests/taxonomy/views_handler_relationship_node_term_data.test index 37e8aa6..7bce980 100644 --- a/sites/all/modules/views/tests/taxonomy/views_handler_relationship_node_term_data.test +++ b/sites/all/modules/views/tests/taxonomy/views_handler_relationship_node_term_data.test @@ -34,9 +34,8 @@ class ViewsHandlerRelationshipNodeTermDataTest extends ViewsSqlTest { function setUp() { parent::setUp(); - //$web_user = $this->drupalCreateUser(array('create article content')); - //$this->drupalLogin($web_user); - + // $web_user = $this->drupalCreateUser(array('create article content')); + // $this->drupalLogin($web_user); $vocabulary = taxonomy_vocabulary_machine_name_load('tags'); $this->term_1 = $this->createTerm($vocabulary); $this->term_2 = $this->createTerm($vocabulary); @@ -119,4 +118,5 @@ class ViewsHandlerRelationshipNodeTermDataTest extends ViewsSqlTest { return $view; } -} \ No newline at end of file + +} diff --git a/sites/all/modules/views/tests/test_handlers/views_test_area_access.inc b/sites/all/modules/views/tests/test_handlers/views_test_area_access.inc index 57a0014..268c675 100644 --- a/sites/all/modules/views/tests/test_handlers/views_test_area_access.inc +++ b/sites/all/modules/views/tests/test_handlers/views_test_area_access.inc @@ -2,22 +2,25 @@ /** * @file - * Contains views_test_area_access + * Definition of views_test_area_access. */ +/** + * A test access plugin. + */ class views_test_area_access extends views_handler_area { /** * {@inheritdoc} */ - function access() { + public function access() { return $this->options['custom_access']; - } + } /** * {@inheritdoc} */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); $options['custom_access'] = array('default' => TRUE, 'bool' => TRUE); diff --git a/sites/all/modules/views/tests/test_plugins/views_test_plugin_access_test_dynamic.inc b/sites/all/modules/views/tests/test_plugins/views_test_plugin_access_test_dynamic.inc index cecec2f..39f7600 100644 --- a/sites/all/modules/views/tests/test_plugins/views_test_plugin_access_test_dynamic.inc +++ b/sites/all/modules/views/tests/test_plugins/views_test_plugin_access_test_dynamic.inc @@ -9,18 +9,29 @@ * Tests a dynamic access plugin. */ class views_test_plugin_access_test_dynamic extends views_plugin_access { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['access'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function access($account) { + /** + * {@inheritdoc} + */ + public function access($account) { return !empty($this->options['access']) && isset($this->view->args[0]) && $this->view->args[0] == variable_get('test_dynamic_access_argument1', NULL) && isset($this->view->args[1]) && $this->view->args[1] == variable_get('test_dynamic_access_argument2', NULL); } - function get_access_callback() { + /** + * {@inheritdoc} + */ + public function get_access_callback() { return array('views_test_test_dynamic_access_callback', array(!empty($options['access']), 1, 2)); } + } diff --git a/sites/all/modules/views/tests/test_plugins/views_test_plugin_access_test_static.inc b/sites/all/modules/views/tests/test_plugins/views_test_plugin_access_test_static.inc index 187d6ea..eb6dde3 100644 --- a/sites/all/modules/views/tests/test_plugins/views_test_plugin_access_test_static.inc +++ b/sites/all/modules/views/tests/test_plugins/views_test_plugin_access_test_static.inc @@ -9,18 +9,29 @@ * Tests a static access plugin. */ class views_test_plugin_access_test_static extends views_plugin_access { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['access'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function access($account) { + /** + * {@inheritdoc} + */ + public function access($account) { return !empty($this->options['access']); } - function get_access_callback() { + /** + * {@inheritdoc} + */ + public function get_access_callback() { return array('views_test_test_static_access_callback', array(!empty($options['access']))); } + } diff --git a/sites/all/modules/views/tests/test_plugins/views_test_plugin_style_test_mapping.inc b/sites/all/modules/views/tests/test_plugins/views_test_plugin_style_test_mapping.inc index b926787..46d202a 100644 --- a/sites/all/modules/views/tests/test_plugins/views_test_plugin_style_test_mapping.inc +++ b/sites/all/modules/views/tests/test_plugins/views_test_plugin_style_test_mapping.inc @@ -11,7 +11,7 @@ class views_test_plugin_style_test_mapping extends views_plugin_style_mapping { /** - * Overrides views_plugin_style_mapping::define_mapping(). + * {@inheritdoc} */ protected function define_mapping() { return array( @@ -49,4 +49,5 @@ class views_test_plugin_style_test_mapping extends views_plugin_style_mapping { } } } + } diff --git a/sites/all/modules/views/tests/user/views_handler_field_user_name.test b/sites/all/modules/views/tests/user/views_handler_field_user_name.test index 6ace471..73a8ac1 100644 --- a/sites/all/modules/views/tests/user/views_handler_field_user_name.test +++ b/sites/all/modules/views/tests/user/views_handler_field_user_name.test @@ -43,17 +43,33 @@ class viewsHandlerFieldUserNameTest extends ViewsSqlTest { $anon_name = variable_get('anonymous', t('Anonymous')); $view->result[0]->users_name = ''; $render = $view->field['name']->advanced_render($view->result[0]); - $this->assertIdentical($render, $anon_name , 'For user0 it should use the default anonymous name by default.'); + $this->assertIdentical($render, $anon_name, 'For user0 it should use the default anonymous name by default.'); $view->field['name']->options['overwrite_anonymous'] = TRUE; $anon_name = $view->field['name']->options['anonymous_text'] = $this->randomName(); $render = $view->field['name']->advanced_render($view->result[0]); - $this->assertIdentical($render, $anon_name , 'For user0 it should use the configured anonymous text if overwrite_anonymous is checked.'); - + $this->assertIdentical($render, $anon_name, 'For user0 it should use the configured anonymous text if overwrite_anonymous is checked.'); } + + /** + * Tests that deselecting 'link_to_user' and 'format_username' works. + */ + public function testOptions() { + $view = $this->view_raw_user_name(); + $view->init_display(); + $this->executeView($view); + + $view->row_index = 0; + + $username = $view->result[0]->users_name = 'test'; + $view->result[0]->uid = 1; + $render = $view->field['name']->advanced_render($view->result[0]); + $this->assertTrue(strpos($render, $username) !== FALSE, 'If link to user is checked the username should be part of the output.'); + } + function view_user_name() { - $view = new view; + $view = new view(); $view->name = 'test_views_handler_field_user_name'; $view->description = ''; $view->tag = 'default'; @@ -93,4 +109,47 @@ class viewsHandlerFieldUserNameTest extends ViewsSqlTest { return $view; } + + function view_raw_user_name() { + $view = new view; + $view->name = 'test_views_handler_field_user_name'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'users'; + $view->human_name = 'test_views_handler_field_user_name'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['query']['options']['query_comment'] = FALSE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['label'] = ''; + $handler->display->display_options['fields']['name']['alter']['alter_text'] = 0; + $handler->display->display_options['fields']['name']['alter']['make_link'] = 0; + $handler->display->display_options['fields']['name']['alter']['absolute'] = 0; + $handler->display->display_options['fields']['name']['alter']['word_boundary'] = 0; + $handler->display->display_options['fields']['name']['alter']['ellipsis'] = 0; + $handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0; + $handler->display->display_options['fields']['name']['alter']['trim'] = 0; + $handler->display->display_options['fields']['name']['alter']['html'] = 0; + $handler->display->display_options['fields']['name']['hide_empty'] = 0; + $handler->display->display_options['fields']['name']['empty_zero'] = 0; + $handler->display->display_options['fields']['name']['link_to_user'] = 0; + $handler->display->display_options['fields']['name']['format_username'] = 0; + $handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0; + + return $view; + } } diff --git a/sites/all/modules/views/tests/user/views_user.test b/sites/all/modules/views/tests/user/views_user.test index 52c5026..2f0e2cd 100644 --- a/sites/all/modules/views/tests/user/views_user.test +++ b/sites/all/modules/views/tests/user/views_user.test @@ -9,9 +9,20 @@ * Tests basic user module integration into views. */ class ViewsUserTestCase extends ViewsSqlTest { + + /** + * + */ var $users = array(); + + /** + * + */ var $nodes = array(); + /** + * + */ public static function getInfo() { return array( 'name' => 'Tests basic user integration', @@ -20,7 +31,9 @@ class ViewsUserTestCase extends ViewsSqlTest { ); } - + /** + * + */ protected function setUp() { parent::setUp(); @@ -31,7 +44,7 @@ class ViewsUserTestCase extends ViewsSqlTest { } /** - * Add a view which has no explicit relationship to the author and check the result. + * Add a view which has no explicit relationship to the author. * * @todo: Remove the following comment once the relationship is required. * One day a view will require the relationship so it should still work @@ -51,8 +64,11 @@ class ViewsUserTestCase extends ViewsSqlTest { $this->assertIdenticalResultset($view, $expected); } + /** + * + */ function test_view_user_relationship() { - $view = new view; + $view = new view(); $view->name = 'test_user_relationship'; $view->description = ''; $view->tag = 'default'; @@ -140,4 +156,5 @@ class ViewsUserTestCase extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/views/tests/user/views_user_argument_default.test b/sites/all/modules/views/tests/user/views_user_argument_default.test index afb24d1..2888193 100644 --- a/sites/all/modules/views/tests/user/views_user_argument_default.test +++ b/sites/all/modules/views/tests/user/views_user_argument_default.test @@ -9,6 +9,10 @@ * Tests views user argument default plugin. */ class ViewsUserArgumentDefault extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Tests user argument default plugin', @@ -17,11 +21,15 @@ class ViewsUserArgumentDefault extends ViewsSqlTest { ); } + /** + * + */ public function test_plugin_argument_default_current_user() { // Create a user to test. $account = $this->drupalCreateUser(); - // Switch the user, we have to check the global user too, because drupalLogin is only for the simpletest browser. + // Switch the user, we have to check the global user too, because + // drupalLogin is only for the simpletest browser. $this->drupalLogin($account); global $user; $admin = $user; @@ -40,8 +48,11 @@ class ViewsUserArgumentDefault extends ViewsSqlTest { drupal_save_session(TRUE); } + /** + * + */ function view_plugin_argument_default_current_user() { - $view = new view; + $view = new view(); $view->name = 'test_plugin_argument_default_current_user'; $view->description = ''; $view->tag = ''; @@ -87,4 +98,5 @@ class ViewsUserArgumentDefault extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/views/tests/user/views_user_argument_validate.test b/sites/all/modules/views/tests/user/views_user_argument_validate.test index 6e157bf..91aebba 100644 --- a/sites/all/modules/views/tests/user/views_user_argument_validate.test +++ b/sites/all/modules/views/tests/user/views_user_argument_validate.test @@ -24,7 +24,7 @@ class ViewsUserArgumentValidate extends ViewsSqlTest { function testArgumentValidateUserUid() { $account = $this->account; - // test 'uid' case + // test 'uid' case. $view = $this->view_argument_validate_user('uid'); $view->set_display('default'); $view->pre_execute(); @@ -36,13 +36,13 @@ class ViewsUserArgumentValidate extends ViewsSqlTest { $this->assertFalse($view->argument['null']->validate_arg($account->name)); // Reset safed argument validation. $view->argument['null']->argument_validated = NULL; - // Fail for a valid numeric, but for a user that doesn't exist + // Fail for a valid numeric, but for a user that doesn't exist. $this->assertFalse($view->argument['null']->validate_arg(32)); } function testArgumentValidateUserName() { $account = $this->account; - // test 'name' case + // test 'name' case. $view = $this->view_argument_validate_user('name'); $view->set_display('default'); $view->pre_execute(); @@ -54,13 +54,13 @@ class ViewsUserArgumentValidate extends ViewsSqlTest { $this->assertFalse($view->argument['null']->validate_arg($account->uid)); // Reset safed argument validation. $view->argument['null']->argument_validated = NULL; - // Fail for a valid string, but for a user that doesn't exist + // Fail for a valid string, but for a user that doesn't exist. $this->assertFalse($view->argument['null']->validate_arg($this->randomName())); } function testArgumentValidateUserEither() { $account = $this->account; - // test 'either' case + // test 'either' case. $view = $this->view_argument_validate_user('either'); $view->set_display('default'); $view->pre_execute(); @@ -72,16 +72,16 @@ class ViewsUserArgumentValidate extends ViewsSqlTest { $this->assertTrue($view->argument['null']->validate_arg($account->uid)); // Reset safed argument validation. $view->argument['null']->argument_validated = NULL; - // Fail for a valid string, but for a user that doesn't exist + // Fail for a valid string, but for a user that doesn't exist. $this->assertFalse($view->argument['null']->validate_arg($this->randomName())); // Reset safed argument validation. $view->argument['null']->argument_validated = NULL; - // Fail for a valid uid, but for a user that doesn't exist + // Fail for a valid uid, but for a user that doesn't exist. $this->assertFalse($view->argument['null']->validate_arg(32)); } function view_argument_validate_user($argtype) { - $view = new view; + $view = new view(); $view->name = 'view_argument_validate_user'; $view->description = ''; $view->tag = ''; diff --git a/sites/all/modules/views/tests/views_access.test b/sites/all/modules/views/tests/views_access.test index f02eca9..73b23ef 100644 --- a/sites/all/modules/views/tests/views_access.test +++ b/sites/all/modules/views/tests/views_access.test @@ -17,6 +17,9 @@ class ViewsAccessTest extends ViewsSqlTest { ); } + /** + * {@inheritdoc} + */ public function setUp() { parent::setUp(); diff --git a/sites/all/modules/views/tests/views_analyze.test b/sites/all/modules/views/tests/views_analyze.test index c21a4bb..d16103e 100644 --- a/sites/all/modules/views/tests/views_analyze.test +++ b/sites/all/modules/views/tests/views_analyze.test @@ -20,7 +20,7 @@ class ViewsAnalyzeTest extends ViewsSqlTest { public function setUp() { parent::setUp('views_ui'); module_enable(array('views_ui')); - // @TODO Figure out why it's required to clear the cache here. + // @todo Figure out why it's required to clear the cache here. views_module_include('views_default', TRUE); views_get_all_views(TRUE); menu_rebuild(); @@ -48,4 +48,5 @@ class ViewsAnalyzeTest extends ViewsSqlTest { // This redirects the user back to the main views edit page. $this->drupalPost(NULL, array(), t('Ok')); } + } diff --git a/sites/all/modules/views/tests/views_argument_default.test b/sites/all/modules/views/tests/views_argument_default.test index 9c0a7eb..f6e1282 100644 --- a/sites/all/modules/views/tests/views_argument_default.test +++ b/sites/all/modules/views/tests/views_argument_default.test @@ -13,7 +13,7 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest { return array( 'name' => 'Argument_default', 'description' => 'Tests pluggable argument_default for views.', - 'group' => 'Views Plugins' + 'group' => 'Views Plugins', ); } @@ -62,7 +62,7 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest { $view->destroy(); - // Make sure that a normal argument provided is used + // Make sure that a normal argument provided is used. $view = $this->view_argument_default_fixed(); $view->set_display('default'); @@ -87,7 +87,7 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest { } function view_argument_default_fixed() { - $view = new view; + $view = new view(); $view->name = 'test_argument_default_fixed'; $view->description = ''; $view->tag = ''; @@ -134,4 +134,5 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/views/tests/views_argument_validator.test b/sites/all/modules/views/tests/views_argument_validator.test index fb2e4f2..6927584 100644 --- a/sites/all/modules/views/tests/views_argument_validator.test +++ b/sites/all/modules/views/tests/views_argument_validator.test @@ -40,10 +40,27 @@ class ViewsArgumentValidatorTest extends ViewsSqlTest { $this->assertTrue($view->argument['null']->validate_arg(12)); } + /** + * Make sure argument validation works properly. + */ + function testArgumentValidatePhpFailure() { + $view = $this->view_test_argument_validate_php_failure(); + $view->save(); + $this->drupalGet('test-php-failure'); + + // This should return a 403, indicating that the arguments validation fails. + $this->assertResponse(403); + + $this->drupalGet('test-php-failure-feed'); + + // This should return a 403, indicating that the arguments validation fails. + $this->assertResponse(403); + } + function view_test_argument_validate_php($string) { - $code = 'return $argument == \''. $string .'\';'; - $view = new view; - $view->name = 'view_argument_validate_numeric'; + $code = 'return $argument == \'' . $string . '\';'; + $view = new view(); + $view->name = 'view_argument_validate_php'; $view->description = ''; $view->tag = ''; $view->view_php = ''; @@ -74,7 +91,7 @@ class ViewsArgumentValidatorTest extends ViewsSqlTest { } function view_argument_validate_numeric() { - $view = new view; + $view = new view(); $view->name = 'view_argument_validate_numeric'; $view->description = ''; $view->tag = ''; @@ -103,4 +120,69 @@ class ViewsArgumentValidatorTest extends ViewsSqlTest { return $view; } + + /** + * + * + * @return view $view + * The required view object. + */ + function view_test_argument_validate_php_failure() { + $view = new view(); + $view->name = 'view_argument_validate_php_failure'; + $view->description = ''; + $view->tag = ''; + $view->base_table = 'node'; + $view->human_name = ''; + $view->core = 0; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['title']['link_to_node'] = FALSE; + /* Contextual filter: Global: Null */ + $handler->display->display_options['arguments']['null']['id'] = 'null'; + $handler->display->display_options['arguments']['null']['table'] = 'views'; + $handler->display->display_options['arguments']['null']['field'] = 'null'; + $handler->display->display_options['arguments']['null']['default_action'] = 'default'; + $handler->display->display_options['arguments']['null']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['null']['default_argument_options']['argument'] = 'No filter'; + $handler->display->display_options['arguments']['null']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['null']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['null']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['null']['specify_validation'] = TRUE; + $handler->display->display_options['arguments']['null']['validate']['type'] = 'php'; + $handler->display->display_options['arguments']['null']['validate_options']['code'] = 'return FALSE;'; + $handler->display->display_options['arguments']['null']['validate']['fail'] = 'access denied'; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page_1'); + $handler->display->display_options['path'] = 'test-php-failure'; + + /* Display: Feed */ + $handler = $view->new_display('feed', 'Feed', 'feed_1'); + $handler->display->display_options['path'] = 'test-php-failure-feed'; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'rss'; + $handler->display->display_options['row_plugin'] = 'node_rss'; + + return $view; + } + } diff --git a/sites/all/modules/views/tests/views_basic.test b/sites/all/modules/views/tests/views_basic.test index 5fc60d8..5d590f9 100644 --- a/sites/all/modules/views/tests/views_basic.test +++ b/sites/all/modules/views/tests/views_basic.test @@ -2,18 +2,20 @@ /** * @file - * Definition of ViewsBasicTest. */ /** * Basic test class for Views query builder tests. */ +/** + * + */ class ViewsBasicTest extends ViewsSqlTest { public static function getInfo() { return array( 'name' => 'Basic query test', 'description' => 'A basic query test for Views.', - 'group' => 'Views' + 'group' => 'Views', ); } @@ -137,12 +139,12 @@ class ViewsBasicTest extends ViewsSqlTest { 'validate_argument_transform' => 0, 'validate_user_restrict_roles' => 0, 'validate_argument_php' => '', - ) + ), )); $saved_view = clone $view; - // Execute with a view + // Execute with a view. $view->set_arguments(array(27)); $this->executeView($view); @@ -175,4 +177,5 @@ class ViewsBasicTest extends ViewsSqlTest { 'views_test_age' => 'age', )); } + } diff --git a/sites/all/modules/views/tests/views_cache.test b/sites/all/modules/views/tests/views_cache.test index 28534a2..cb1fdfb 100644 --- a/sites/all/modules/views/tests/views_cache.test +++ b/sites/all/modules/views/tests/views_cache.test @@ -11,11 +11,15 @@ * @see views_plugin_cache */ class ViewsCacheTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Cache', 'description' => 'Tests pluggable caching for views.', - 'group' => 'Views Plugins' + 'group' => 'Views Plugins', ); } @@ -153,9 +157,9 @@ class ViewsCacheTest extends ViewsSqlTest { * Tests css/js storage and restoring mechanism. */ function testHeaderStorage() { - // Create a view with output caching enabled. - // Some hook_views_pre_render in views_test.module adds the test css/js file. - // so they should be added to the css/js storage. + // Create a view with output caching enabled. Some hook_views_pre_render in + // views_test.module adds the test css/js file, so they should be added to + // the css/js storage. $view = $this->getBasicView(); $view->init_display(); $view->name = 'test_cache_header_storage'; diff --git a/sites/all/modules/views/tests/views_cache.test.js b/sites/all/modules/views/tests/views_cache.test.js index 8dd17c1..26644cf 100644 --- a/sites/all/modules/views/tests/views_cache.test.js +++ b/sites/all/modules/views/tests/views_cache.test.js @@ -1,5 +1,6 @@ /** * @file * Just a placeholder file for the test. + * * @see ViewsCacheTest::testHeaderStorage */ diff --git a/sites/all/modules/views/tests/views_clone.test b/sites/all/modules/views/tests/views_clone.test new file mode 100644 index 0000000..7ac10ab --- /dev/null +++ b/sites/all/modules/views/tests/views_clone.test @@ -0,0 +1,277 @@ + 'Test cloning a view', + 'description' => 'Tests clone_view method of views class', + 'group' => 'Views', + ); + } + + /** + * Returns a new term with random properties in vocabulary $vocabulary. + */ + protected function createTerm($vocabulary) { + $term = new stdClass(); + $term->name = $this->randomName(); + $term->description = $this->randomName(); + // Use the first available text format. + $term->format = db_query_range('SELECT format FROM {filter_format}', 0, 1)->fetchField(); + $term->vid = $vocabulary->vid; + taxonomy_term_save($term); + return $term; + } + + /** + * {@inheritdoc} + */ + public function setUp() { + parent::setUp(); + + $vocabulary = taxonomy_vocabulary_machine_name_load('tags'); + $this->term = $this->createTerm($vocabulary); + + $node = array(); + $node['type'] = 'article'; + $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->term->tid; + $this->node = $this->drupalCreateNode($node); + } + + /** + * Test cloning a view. + */ + public function testClone() { + // Prepare view to be cloned. + $view = $this->getTestCloneView(); + $view->set_arguments(array( + 0 => $this->node->nid, + )); + $view->set_exposed_input(array( + 'field_tags_tid' => $this->term->tid, + )); + + // Execute view to be cloned. + $result = $view->execute(); + + // To make sure that we are properly testing removal of all properties, we + // first need to assert that they are actually present in the original view. + $keys = array( + 'current_display', + 'display_handler', + 'field', + 'argument', + 'filter', + 'sort', + 'relationship', + 'header', + 'footer', + 'empty', + 'query', + 'inited', + 'style_plugin', + 'plugin_name', + 'exposed_data', + 'exposed_input', + 'exposed_widgets', + 'many_to_one_aliases', + 'many_to_one_tables', + 'feed_icon', + ); + foreach ($keys as $key) { + $this->assertTrue(isset($view->{$key}), $key . 'is set in original view.'); + } + $this->assertTrue($view->built, 'Assert original view built.'); + $this->assertTrue($view->executed, 'Assert original view executed.'); + $this->assertNotEqual($view->build_info, array(), 'Assert original view has build_info.'); + $this->assertNotEqual($view->attachment_before, '', 'Assert original view has attachment_before.'); + $this->assertNotEqual($view->attachment_after, '', 'Assert original view has attachment_after.'); + $this->assertNotEqual($view->result, array(), 'Assert original view has result.'); + + // Clone view. + $clone = $view->clone_view(); + + // Assert that all relevant properties have been removed or reset. + $keys = array( + 'current_display', + 'display_handler', + 'field', + 'argument', + 'filter', + 'sort', + 'relationship', + 'header', + 'footer', + 'empty', + 'query', + 'inited', + 'style_plugin', + 'plugin_name', + 'exposed_data', + 'exposed_input', + 'exposed_widgets', + 'many_to_one_aliases', + 'many_to_one_tables', + 'feed_icon', + ); + foreach ($keys as $key) { + $this->assertFalse(isset($clone->{$key}), $key . ' has been removed in cloned view.'); + } + foreach ($clone->display as $id => $display) { + $this->assertFalse(isset($clone->display[$id]->handler), 'Make sure all display handlers have been destroyed.'); + } + $this->assertFalse($clone->built, 'Assert cloned view not built.'); + $this->assertFalse($clone->executed, 'Assert cloned view not executed.'); + $this->assertEqual($clone->build_info, array(), 'Assert cloned view has empty build_info.'); + $this->assertEqual($clone->attachment_before, '', 'Assert cloned view has empty attachment_before.'); + $this->assertEqual($clone->attachment_after, '', 'Assert cloned view has empty attachment_after.'); + $this->assertEqual($clone->result, array(), 'Assert cloned view has empty result.'); + + // Execute cloned view. + $clone->execute(); + + // Assert result sets are equal. + $this->assertEqual($view->result, $clone->result, 'Result sets of cloned view and original view match.'); + } + + /** + * Generate test_clone view. + */ + protected function getTestCloneView() { + $view = new view(); + $view->name = 'test_clone'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'test_clone'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'test_clone'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* Header: Global: Text area */ + $handler->display->display_options['header']['area']['id'] = 'area'; + $handler->display->display_options['header']['area']['table'] = 'views'; + $handler->display->display_options['header']['area']['field'] = 'area'; + $handler->display->display_options['header']['area']['label'] = 'Header'; + $handler->display->display_options['header']['area']['content'] = 'Header'; + $handler->display->display_options['header']['area']['format'] = 'filtered_html'; + /* Footer: Global: Text area */ + $handler->display->display_options['footer']['area']['id'] = 'area'; + $handler->display->display_options['footer']['area']['table'] = 'views'; + $handler->display->display_options['footer']['area']['field'] = 'area'; + $handler->display->display_options['footer']['area']['label'] = 'Footer'; + $handler->display->display_options['footer']['area']['content'] = 'Footer'; + $handler->display->display_options['footer']['area']['format'] = 'filtered_html'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['label'] = 'Empty'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'Empty'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: Comment: Last Comment */ + $handler->display->display_options['relationships']['cid']['id'] = 'cid'; + $handler->display->display_options['relationships']['cid']['table'] = 'node_comment_statistics'; + $handler->display->display_options['relationships']['cid']['field'] = 'cid'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Contextual filter: Content: Nid */ + $handler->display->display_options['arguments']['nid']['id'] = 'nid'; + $handler->display->display_options['arguments']['nid']['table'] = 'node'; + $handler->display->display_options['arguments']['nid']['field'] = 'nid'; + $handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 'All'; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['exposed'] = TRUE; + $handler->display->display_options['filters']['status']['expose']['operator_id'] = ''; + $handler->display->display_options['filters']['status']['expose']['label'] = 'Published'; + $handler->display->display_options['filters']['status']['expose']['operator'] = 'status_op'; + $handler->display->display_options['filters']['status']['expose']['identifier'] = 'status'; + $handler->display->display_options['filters']['status']['expose']['remember_roles'] = array( + 2 => '2', + ); + /* Filter criterion: Content: Tags (field_tags) */ + $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags'; + $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['exposed'] = TRUE; + $handler->display->display_options['filters']['field_tags_tid']['expose']['operator_id'] = 'field_tags_tid_op'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['label'] = 'Tags (field_tags)'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['operator'] = 'field_tags_tid_op'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['identifier'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['remember_roles'] = array( + 2 => '2', + ); + $handler->display->display_options['filters']['field_tags_tid']['reduce_duplicates'] = TRUE; + $handler->display->display_options['filters']['field_tags_tid']['type'] = 'select'; + $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags'; + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page'); + $handler->display->display_options['path'] = 'test-clone'; + /* Display: attachment_before */ + $handler = $view->new_display('attachment', 'attachment_before', 'attachment_1'); + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['displays'] = array( + 'default' => 'default', + 'page' => 'page', + ); + $handler->display->display_options['inherit_exposed_filters'] = TRUE; + /* Display: attachment_after */ + $handler = $view->new_display('attachment', 'attachment_after', 'attachment_2'); + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['displays'] = array( + 'default' => 'default', + 'page' => 'page', + ); + $handler->display->display_options['attachment_position'] = 'after'; + $handler->display->display_options['inherit_exposed_filters'] = TRUE; + /* Display: Feed */ + $handler = $view->new_display('feed', 'Feed', 'feed_1'); + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['style_plugin'] = 'rss'; + $handler->display->display_options['row_plugin'] = 'node_rss'; + $handler->display->display_options['path'] = 'test_clone/rss'; + $handler->display->display_options['displays'] = array( + 'default' => 'default', + 'page' => 'page', + ); + return $view; + } + +} diff --git a/sites/all/modules/views/tests/views_exposed_form.test b/sites/all/modules/views/tests/views_exposed_form.test index afa4f42..b202564 100644 --- a/sites/all/modules/views/tests/views_exposed_form.test +++ b/sites/all/modules/views/tests/views_exposed_form.test @@ -9,6 +9,10 @@ * Tests exposed forms. */ class ViewsExposedFormTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Exposed forms', @@ -17,10 +21,13 @@ class ViewsExposedFormTest extends ViewsSqlTest { ); } + /** + * + */ public function setUp() { parent::setUp('views_ui'); module_enable(array('views_ui')); - // @TODO Figure out why it's required to clear the cache here. + // @todo Figure out why it's required to clear the cache here. views_module_include('views_default', TRUE); views_get_all_views(TRUE); menu_rebuild(); @@ -75,7 +82,8 @@ class ViewsExposedFormTest extends ViewsSqlTest { $this->drupalGet('test_exposed_remember'); $this->assertFieldByName('type', 'page'); - // Request the page with an unrelated GET argument, filter should still be set. + // Request the page with an unrelated GET argument, filter should still be + // set. $this->drupalGet('test_exposed_remember', array('query' => array('argument' => 'value'))); $this->assertFieldByName('type', 'page'); @@ -101,8 +109,8 @@ class ViewsExposedFormTest extends ViewsSqlTest { // Be sure that the button is called exposed. $this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose filter')); - // The first time the filter UI is displayed, the operator and the - // value forms should be shown. + // The first time the filter UI is displayed, the operator and the value + // forms should be shown. $this->assertFieldById('edit-options-operator-in', '', 'Operator In exists'); $this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists'); $this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists'); @@ -112,10 +120,10 @@ class ViewsExposedFormTest extends ViewsSqlTest { $this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter')); // Check the label of the expose button. $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide filter')); - // Check the label of the grouped exposed button + // Check the label of the grouped exposed button. $this->helperButtonHasLabel('edit-options-group-button-button', t('Grouped filters')); - // After Expose the filter, Operator and Value should be still here + // After Expose the filter, Operator and Value should be still here. $this->assertFieldById('edit-options-operator-in', '', 'Operator In exists'); $this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists'); $this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists'); @@ -141,18 +149,18 @@ class ViewsExposedFormTest extends ViewsSqlTest { $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'); $this->drupalPost(NULL, array(), t('Grouped filters')); - // After click on 'Grouped Filters' standard operator and value should not be displayed + // After click on 'Grouped Filters' standard operator and value should not + // be displayed. $this->assertNoFieldById('edit-options-operator-in', '', 'Operator In not exists'); $this->assertNoFieldById('edit-options-operator-not-in', '', 'Operator Not In not exists'); $this->assertNoFieldById('edit-options-value-page', '', 'Checkbox for Page not exists'); $this->assertNoFieldById('edit-options-value-article', '', 'Checkbox for Article not exists'); - // Check that after click on 'Grouped Filters', a new button is shown to // add more items to the list. $this->helperButtonHasLabel('edit-options-group-info-add-group', t('Add another item')); - // Create a grouped filter + // Create a grouped filter. $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'); $edit = array(); $edit["options[group_info][group_items][1][title]"] = 'Is Article'; @@ -166,13 +174,13 @@ class ViewsExposedFormTest extends ViewsSqlTest { $edit["options[group_info][group_items][3][value][page]"] = TRUE; $this->drupalPost(NULL, $edit, t('Apply')); - // Validate that all the titles are defined for each group + // Validate that all the titles are defined for each group. $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'); $edit = array(); $edit["options[group_info][group_items][1][title]"] = 'Is Article'; $edit["options[group_info][group_items][1][value][article]"] = TRUE; - // This should trigger an error + // This should trigger an error. $edit["options[group_info][group_items][2][title]"] = ''; $edit["options[group_info][group_items][2][value][page]"] = TRUE; @@ -182,11 +190,11 @@ class ViewsExposedFormTest extends ViewsSqlTest { $this->drupalPost(NULL, $edit, t('Apply')); $this->assertRaw(t('The title is required if value for this item is defined.'), t('Group items should have a title')); - // Un-Expose the filter + // Un-Expose the filter. $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'); $this->drupalPost(NULL, array(), t('Hide filter')); - // After Un-Expose the filter, Operator and Value should be shown again + // After Un-Expose the filter, Operator and Value should be shown again. $this->assertFieldById('edit-options-operator-in', '', 'Operator In exists after hide filter'); $this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists after hide filter'); $this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists after hide filter'); @@ -199,4 +207,5 @@ class ViewsExposedFormTest extends ViewsSqlTest { $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide sort')); $this->assertFieldById('edit-options-expose-label', '', t('Make sure a label field is shown')); } + } diff --git a/sites/all/modules/views/tests/views_glossary.test b/sites/all/modules/views/tests/views_glossary.test index 0fe0fba..d7d7c64 100644 --- a/sites/all/modules/views/tests/views_glossary.test +++ b/sites/all/modules/views/tests/views_glossary.test @@ -37,7 +37,7 @@ class ViewsGlossaryTestCase extends ViewsSqlTest { ); foreach ($nodes_per_char as $char => $count) { $setting = array( - 'type' => $type->type + 'type' => $type->type, ); for ($i = 0; $i < $count; $i++) { $node = $setting; @@ -46,7 +46,7 @@ class ViewsGlossaryTestCase extends ViewsSqlTest { } } - // Execute glossary view + // Execute glossary view. $view = views_get_view('glossary'); $view->set_display('attachment'); $view->execute_display('attachment'); @@ -57,4 +57,5 @@ class ViewsGlossaryTestCase extends ViewsSqlTest { $this->assertEqual($nodes_per_char[$item->title_truncated], $item->num_records); } } + } diff --git a/sites/all/modules/views/tests/views_groupby.test b/sites/all/modules/views/tests/views_groupby.test index 4e09256..364e61b 100644 --- a/sites/all/modules/views/tests/views_groupby.test +++ b/sites/all/modules/views/tests/views_groupby.test @@ -2,20 +2,103 @@ /** * @file - * Tests aggregate functionality of Views. + * Definitions of ViewsQueryGroupByTest and ViewsUiGroupbyTestCase. */ /** * Tests aggregate functionality of views, for example count. */ class ViewsQueryGroupByTest extends ViewsSqlTest { + + /** + * Test meta data. + */ public static function getInfo() { return array( 'name' => 'Groupby', 'description' => 'Tests aggregate functionality of views, for example count.', 'group' => 'Views', ); + } + // tests ambiguous group by column error (postgresql) + public function testAggregateAmbiguity() { + // Create 4 nodes of type1 + $type1 = $this->drupalCreateContentType(); + + $node_1 = array( + 'type' => $type1->type, + ); + $this->drupalCreateNode($node_1); + $this->drupalCreateNode($node_1); + $this->drupalCreateNode($node_1); + $this->drupalCreateNode($node_1); + + $view = $this->viewsAggregateAmbiguityView(); + $output = $view->execute_display(); + + $this->assertEqual(count($view->result), 1, 'Make sure there are no ambiguity problems with the group by operation.'); + } + + public function viewsAggregateAmbiguityView() { + $view = new view(); + $view->name = 'aggregate_ambiguity'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = ''; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['group_by'] = TRUE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: COUNT(Content revision: Nid) */ + $handler->display->display_options['fields']['nid']['id'] = 'nid'; + $handler->display->display_options['fields']['nid']['table'] = 'node_revision'; + $handler->display->display_options['fields']['nid']['field'] = 'nid'; + $handler->display->display_options['fields']['nid']['group_type'] = 'count'; + $handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0; + $handler->display->display_options['fields']['nid']['alter']['make_link'] = 0; + $handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1; + $handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1; + $handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0; + $handler->display->display_options['fields']['nid']['alter']['trim'] = 0; + $handler->display->display_options['fields']['nid']['alter']['html'] = 0; + $handler->display->display_options['fields']['nid']['hide_empty'] = 0; + $handler->display->display_options['fields']['nid']['empty_zero'] = 0; + /* Field: Content: Nid */ + $handler->display->display_options['fields']['nid_1']['id'] = 'nid_1'; + $handler->display->display_options['fields']['nid_1']['table'] = 'node'; + $handler->display->display_options['fields']['nid_1']['field'] = 'nid'; + $handler->display->display_options['fields']['nid_1']['alter']['alter_text'] = 0; + $handler->display->display_options['fields']['nid_1']['alter']['make_link'] = 0; + $handler->display->display_options['fields']['nid_1']['alter']['word_boundary'] = 1; + $handler->display->display_options['fields']['nid_1']['alter']['ellipsis'] = 1; + $handler->display->display_options['fields']['nid_1']['alter']['strip_tags'] = 0; + $handler->display->display_options['fields']['nid_1']['alter']['trim'] = 0; + $handler->display->display_options['fields']['nid_1']['alter']['html'] = 0; + $handler->display->display_options['fields']['nid_1']['hide_empty'] = 0; + $handler->display->display_options['fields']['nid_1']['empty_zero'] = 0; + /* Contextual filter: Content: Type */ + $handler->display->display_options['arguments']['type']['id'] = 'type'; + $handler->display->display_options['arguments']['type']['table'] = 'node'; + $handler->display->display_options['arguments']['type']['field'] = 'type'; + $handler->display->display_options['arguments']['type']['default_action'] = 'summary'; + $handler->display->display_options['arguments']['type']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['type']['summary']['format'] = 'default_summary'; + + + return $view; } /** @@ -48,7 +131,7 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $types = array(); foreach ($view->result as $item) { - // num_records is a alias for nid. + // 'num_records' is a alias for nid. $types[$item->node_type] = $item->num_records; } @@ -56,9 +139,15 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $this->assertEqual($types[$type2->type], 3); } - //public function testAggregateSum() { - //} + /** + * + */ + // public function testAggregateSum() { + // } + /** + * + */ public function viewsAggregateCountView() { $view = new view; $view->name = 'aggregate_count'; @@ -103,7 +192,6 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $handler->display->display_options['arguments']['type']['default_argument_type'] = 'fixed'; $handler->display->display_options['arguments']['type']['summary']['format'] = 'default_summary'; - return $view; } @@ -144,7 +232,9 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { // There's no need for a function in order to have aggregation. if (empty($group_by)) { $types = array($type1->type, $type2->type); - $results = array_map(function ($item) { return $item->node_type; }, $view->result); + $results = array_map(function ($item) { + return $item->node_type; + }, $view->result); sort($types); sort($results); $this->assertIdentical($results, $types); @@ -160,6 +250,9 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $this->assertEqual($results[$type2->type], $values[1]); } + /** + * + */ function viewsGroupByViewHelper($group_by = NULL) { $view = new view; $view->name = 'group_by_count'; @@ -219,31 +312,51 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { return $view; } + /** + * + */ public function testGroupByCount() { $this->GroupByTestHelper('count', array(4, 3)); } - function testGroupBySum() { + /** + * + */ + public function testGroupBySum() { $this->GroupByTestHelper('sum', array(10, 18)); } - - function testGroupByAverage() { + /** + * + */ + public function testGroupByAverage() { $this->GroupByTestHelper('avg', array(2.5, 6)); } - function testGroupByMin() { + /** + * + */ + public function testGroupByMin() { $this->GroupByTestHelper('min', array(1, 5)); } - function testGroupByMax() { + /** + * {@inheritdoc} + */ + public function testGroupByMax() { $this->GroupByTestHelper('max', array(4, 7)); } - function testGroupByNone() { + /** + * + */ + public function testGroupByNone() { $this->GroupByTestHelper(); } + /** + * + */ public function testGroupByCountOnlyFilters() { // Check if GROUP BY and HAVING are included when a view // Doesn't display SUM, COUNT, MAX... functions in SELECT statment @@ -264,6 +377,9 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $this->assertTrue(strpos($view->build_info['query'], 'HAVING'), t('Make sure that HAVING is in the query')); } + /** + * + */ function viewsGroupByCountViewOnlyFilters() { $view = new view; $view->name = 'group_by_in_filters'; @@ -308,12 +424,17 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { return $view; } + } /** - * Tests UI of aggregate functionality.. + * Tests UI of aggregate functionality. */ -class viewsUiGroupbyTestCase extends DrupalWebTestCase { +class ViewsUiGroupbyTestCase extends DrupalWebTestCase { + + /** + * {@inheritdoc} + */ function setUp() { // Enable views_ui. parent::setUp('views_ui', 'views_test'); @@ -323,6 +444,9 @@ class viewsUiGroupbyTestCase extends DrupalWebTestCase { $this->drupalLogin($views_admin); } + /** + * Test meta data. + */ public static function getInfo() { return array( 'name' => 'Groupby UI', @@ -349,4 +473,5 @@ class viewsUiGroupbyTestCase extends DrupalWebTestCase { $this->drupalGet('admin/structure/views/nojs/display/test_views_groupby_save/default/group_by'); } + } diff --git a/sites/all/modules/views/tests/views_handler_filter.test b/sites/all/modules/views/tests/views_handler_filter.test new file mode 100644 index 0000000..e41b35a --- /dev/null +++ b/sites/all/modules/views/tests/views_handler_filter.test @@ -0,0 +1,161 @@ + 'Handler filter test', + 'description' => 'test filter handler definitions', + 'group' => 'Views', + ); + } + + /** + * {@inheritdoc} + */ + protected function setUp() { + // The Views and Views UI modules will be enabled with this. + parent::setUp(); + + // Assign vocabulary 'tag' to user entity. + $field_definition = field_read_field('field_tags'); + $instance_definition = array( + 'field_name' => $field_definition['field_name'], + 'entity_type' => 'user', + 'bundle' => 'user', + 'widget' => array( + 'type' => 'taxonomy_autocomplete', + ), + 'display' => array( + 'default' => array( + 'type' => 'taxonomy_term_reference_link', + 'weight' => 10, + ), + 'teaser' => array( + 'type' => 'taxonomy_term_reference_link', + 'weight' => 10, + ), + ), + ); + field_create_instance($instance_definition); + } + + /** + * Tests "is all of" of filter operation. + */ + function testFilterInOperatorUi() { + $term = $this->drupalCreateTerm(1); + + $node1 = $this->drupalCreateNode(array('type' => 'article','field_tags_tid' => $term->tid, 'created' => REQUEST_TIME)); + $node2 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 1)); + $user2 = $this->drupalCreateUser(array('access content')); + // $this->drupalLogin($this->drupalCreateUser(array('administer users')); + $this->drupalLogin($this->drupalCreateUser(array('administer users', 'access administration pages', 'administer site configuration', 'administer nodes', 'bypass node access'))); + + $this->drupalGet('node/1/edit'); + $edit['field_tags' . '[' . LANGUAGE_NONE . ']'] = $term->name; + $this->drupalPost('node/' . $node1->nid . '/edit', $edit, t('Save')); + + $edit['field_tags' . '[' . LANGUAGE_NONE . ']'] = $term->name; + $this->drupalPost('user/' . $user2->uid . '/edit', $edit, t('Save')); + + $result[] = array('nid' => $node1->nid); + $view = $this->get_sample_view(); + $this->executeView($view); + $this->assertIdenticalResultset($view, $result); + } + + /** + * Sample view. + * + * @return \view + */ + protected function get_sample_view() { + $view = new view(); + $view->name = 'article'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Article'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Article'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['style_plugin'] = 'table'; + $handler->display->display_options['style_options']['columns'] = array( + 'title' => 'title', + ); + $handler->display->display_options['style_options']['default'] = '-1'; + $handler->display->display_options['style_options']['info'] = array( + 'title' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + ); + /* Field: Content: Nid */ + $handler->display->display_options['fields']['nid']['id'] = 'nid'; + $handler->display->display_options['fields']['nid']['table'] = 'node'; + $handler->display->display_options['fields']['nid']['field'] = 'nid'; + $handler->display->display_options['fields']['nid']['label'] = ''; + $handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Field: Tags (field_tags) */ + $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags'; + $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['operator'] = 'and'; + $handler->display->display_options['filters']['field_tags_tid']['value'] = array( + 0 => '1', + ); + $handler->display->display_options['filters']['field_tags_tid']['expose']['operator_id'] = 'field_tags_tid_op'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['label'] = 'Tags (field_tags)'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['operator'] = 'field_tags_tid_op'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['identifier'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['remember_roles'] = array( + 2 => '2', + ); + $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags'; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page'); + $handler->display->display_options['path'] = 'article'; + + return $view; + } + +} diff --git a/sites/all/modules/views/tests/views_handlers.test b/sites/all/modules/views/tests/views_handlers.test index d54a7df..e0ace98 100644 --- a/sites/all/modules/views/tests/views_handlers.test +++ b/sites/all/modules/views/tests/views_handlers.test @@ -48,13 +48,13 @@ class ViewsHandlersTest extends ViewsSqlTest { $empty_stdclass->value = array(); $null = NULL; - // check defaults + // check defaults. $this->assertEqual($empty_stdclass, views_break_phrase_string('', $null)); $handler = views_get_handler('node', 'title', 'argument'); $this->assertEqual($handler, views_break_phrase_string('', $handler)); - // test ors + // test ors. $handler = views_break_phrase_string('word1 word2+word'); $this->assertEqualValue(array('word1', 'word2', 'word'), $handler); $this->assertEqual('or', $handler->operator); @@ -88,7 +88,7 @@ class ViewsHandlersTest extends ViewsSqlTest { $this->assertEqualValue(array('wõrd1', 'wõrd2', 'wõrd'), $handler); $this->assertEqual('and', $handler->operator); - // test a single word + // test a single word. $handler = views_break_phrase_string('word'); $this->assertEqualValue(array('word'), $handler); $this->assertEqual('and', $handler->operator); @@ -103,7 +103,7 @@ class ViewsHandlersTest extends ViewsSqlTest { $empty_stdclass->value = array(); $null = NULL; - // check defaults + // check defaults. $this->assertEqual($empty_stdclass, views_break_phrase('', $null)); $handler = views_get_handler('node', 'title', 'argument'); @@ -113,7 +113,7 @@ class ViewsHandlersTest extends ViewsSqlTest { $n1 = rand(0, 100); $n2 = rand(0, 100); $n3 = rand(0, 100); - // test ors + // test ors. $this->assertEqualValue(array($n1, $n2, $n3), views_break_phrase("$n1 $n2+$n3", $handler)); $this->assertEqual('or', $handler->operator); $this->assertEqualValue(array($n1, $n2, $n3), views_break_phrase("$n1+$n2+$n3", $handler)); @@ -133,7 +133,7 @@ class ViewsHandlersTest extends ViewsSqlTest { /** * Check to see if two values are equal. * - * @param $first + * @param string $first * The first value to check. * @param views_handler $handler * @param string $message @@ -147,4 +147,5 @@ class ViewsHandlersTest extends ViewsSqlTest { protected function assertEqualValue($first, $handler, $message = '', $group = 'Other') { return $this->assert($first == $handler->value, $message ? $message : t('First value is equal to second value'), $group); } + } diff --git a/sites/all/modules/views/tests/views_module.test b/sites/all/modules/views/tests/views_module.test index e160964..c3dd994 100644 --- a/sites/all/modules/views/tests/views_module.test +++ b/sites/all/modules/views/tests/views_module.test @@ -45,7 +45,7 @@ class ViewsModuleTest extends ViewsSqlTest { 'khoảng cách từ đại lí đến', 'của hãng bao gồm ba dòng', 'сд асд асд ас', - 'асд асд асд ас' + 'асд асд асд ас', ); // Just test maxlength without word boundry. $alter = array( @@ -91,7 +91,8 @@ class ViewsModuleTest extends ViewsSqlTest { */ function testModuleTemplates() { $views_status = variable_get('views_defaults', array()); - $views_status['frontpage'] = FALSE; // false is enabled + $views_status['frontpage'] = FALSE; + // false is enabled. variable_set('views_defaults', $views_status); $existing = array(); @@ -127,7 +128,6 @@ class ViewsModuleTest extends ViewsSqlTest { } // Test the automatic conversion feature. - // Test the automatic table renaming. $handler = views_get_handler('views_test_previous', 'id', 'field'); $this->assertInstanceHandler($handler, 'views_test', 'id', 'field'); @@ -194,7 +194,6 @@ class ViewsModuleTest extends ViewsSqlTest { $this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once'); $this->assertFalse(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is not fully loaded'); - // Test if the cache consistency is ensured. There was an issue where // calling _views_fetch_data() first with a table would prevent the function // from properly rebuilt a missing the general cache entry. @@ -238,4 +237,5 @@ class ViewsModuleTest extends ViewsSqlTest { drupal_static_reset('_views_fetch_data_recursion_protected'); drupal_static_reset('_views_fetch_data_fully_loaded'); } + } diff --git a/sites/all/modules/views/tests/views_pager.test b/sites/all/modules/views/tests/views_pager.test index fef4915..7a99fb6 100644 --- a/sites/all/modules/views/tests/views_pager.test +++ b/sites/all/modules/views/tests/views_pager.test @@ -9,6 +9,10 @@ * Tests the pluggable pager system. */ class ViewsPagerTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Pager', @@ -17,6 +21,9 @@ class ViewsPagerTest extends ViewsSqlTest { ); } + /** + * + */ public function setUp() { parent::setUp('views', 'views_ui', 'views_test'); } @@ -29,11 +36,10 @@ class ViewsPagerTest extends ViewsSqlTest { public function testStorePagerSettings() { $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); $this->drupalLogin($admin_user); - // Test behaviour described in http://drupal.org/node/652712#comment-2354918. - + // Test behaviour described in + // http://drupal.org/node/652712#comment-2354918. $this->drupalGet('admin/structure/views/view/frontpage/edit'); - $edit = array( 'pager_options[items_per_page]' => 20, ); @@ -70,8 +76,8 @@ class ViewsPagerTest extends ViewsSqlTest { $this->drupalPost('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply')); $this->assertText('20 items'); - // add new display and test the settings again, by override it. - $edit = array( ); + // Add new display and test the settings again, by override it. + $edit = array(); // Add a display and override the pager settings. $this->drupalPost('admin/structure/views/view/test_store_pager_settings/edit', $edit, t('Add Page')); $edit = array( @@ -91,11 +97,13 @@ class ViewsPagerTest extends ViewsSqlTest { ); $this->drupalPost('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply')); $this->assertText('20 items'); - } + /** + * + */ public function viewsStorePagerSettings() { - $view = new view; + $view = new view(); $view->name = 'test_store_pager_settings'; $view->description = ''; $view->tag = ''; @@ -120,8 +128,8 @@ class ViewsPagerTest extends ViewsSqlTest { * Tests the none-pager-query. */ public function testNoLimit() { - // Create 11 nodes and make sure that everyone is returned. - // We create 11 nodes, because the default pager plugin had 10 items per page. + // Create 11 nodes and make sure that everyone is returned. We create 11 + // nodes, because the default pager plugin had 10 items per page. for ($i = 0; $i < 11; $i++) { $this->drupalCreateNode(); } @@ -153,15 +161,18 @@ class ViewsPagerTest extends ViewsSqlTest { $this->assertEqual($view->query->pager->get_items_per_page(), 0); } + /** + * + */ public function viewsPagerNoLimit() { - $view = new view; + $view = new view(); $view->name = 'test_pager_none'; $view->description = ''; $view->tag = ''; $view->view_php = ''; $view->base_table = 'node'; $view->is_cacheable = FALSE; - $view->api_version =3; + $view->api_version = 3; $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ /* Display: Master */ @@ -175,6 +186,9 @@ class ViewsPagerTest extends ViewsSqlTest { return $view; } + /** + * + */ public function testViewTotalRowsWithoutPager() { $this->createNodes(23); @@ -186,6 +200,9 @@ class ViewsPagerTest extends ViewsSqlTest { $this->assertEqual($view->total_rows, 23, "'total_rows' is calculated when pager type is 'none' and 'get_total_rows' is TRUE."); } + /** + * + */ public function createNodes($count) { if ($count >= 0) { for ($i = 0; $i < $count; $i++) { @@ -198,8 +215,8 @@ class ViewsPagerTest extends ViewsSqlTest { * Tests the some pager plugin. */ public function testLimit() { - // Create 11 nodes and make sure that everyone is returned. - // We create 11 nodes, because the default pager plugin had 10 items per page. + // Create 11 nodes and make sure that everyone is returned. We create 11 + // nodes, because the default pager plugin had 10 items per page. for ($i = 0; $i < 11; $i++) { $this->drupalCreateNode(); } @@ -229,8 +246,11 @@ class ViewsPagerTest extends ViewsSqlTest { $this->assertFalse($view->query->pager->use_count_query()); } + /** + * + */ public function viewsPagerLimit() { - $view = new view; + $view = new view(); $view->name = 'test_pager_some'; $view->description = ''; $view->tag = ''; @@ -257,8 +277,8 @@ class ViewsPagerTest extends ViewsSqlTest { * Tests the normal pager. */ public function testNormalPager() { - // Create 11 nodes and make sure that everyone is returned. - // We create 11 nodes, because the default pager plugin had 10 items per page. + // Create 11 nodes and make sure that everyone is returned. We create 11 + // nodes, because the default pager plugin had 10 items per page. for ($i = 0; $i < 11; $i++) { $this->drupalCreateNode(); } @@ -290,8 +310,7 @@ class ViewsPagerTest extends ViewsSqlTest { $this->assertEqual(count($view->result), 11, 'All items are return'); - // TODO test number of pages. - + // @todo test number of pages. // Test items per page = 0. $view->destroy(); @@ -313,8 +332,11 @@ class ViewsPagerTest extends ViewsSqlTest { $this->assertEqual(count($view->result), 11); } + /** + * + */ function viewPagerFullZeroItemsPerPage() { - $view = new view; + $view = new view(); $view->name = 'view_pager_full_zero_items_per_page'; $view->description = ''; $view->tag = ''; @@ -353,8 +375,11 @@ class ViewsPagerTest extends ViewsSqlTest { return $view; } + /** + * + */ function viewsPagerFull() { - $view = new view; + $view = new view(); $view->name = 'test_pager_full'; $view->description = ''; $view->tag = ''; @@ -379,8 +404,11 @@ class ViewsPagerTest extends ViewsSqlTest { return $view; } + /** + * + */ function viewsPagerFullFields() { - $view = new view; + $view = new view(); $view->name = 'test_pager_full'; $view->description = ''; $view->tag = ''; @@ -421,22 +449,24 @@ class ViewsPagerTest extends ViewsSqlTest { * Tests the minipager. */ public function testMiniPager() { - // the functionality is the same as the normal pager, so i don't know what to test here. + // The functionality is the same as the normal pager, so i don't know what + // to test here. } /** * Tests rendering with NULL pager. */ public function testRenderNullPager() { - // Create 11 nodes and make sure that everyone is returned. - // We create 11 nodes, because the default pager plugin had 10 items per page. + // Create 11 nodes and make sure that everyone is returned. We create 11 + // nodes, because the default pager plugin had 10 items per page. for ($i = 0; $i < 11; $i++) { $this->drupalCreateNode(); } $view = $this->viewsPagerFullFields(); $view->set_display('default'); $this->executeView($view); - $view->use_ajax = TRUE; // force the value again here + $view->use_ajax = TRUE; + // force the value again here. $view->query->pager = NULL; $output = $view->render(); $this->assertEqual(preg_match('/
      /', $output), 0, t('The pager is not rendered.')); @@ -448,7 +478,6 @@ class ViewsPagerTest extends ViewsSqlTest { function testPagerApi() { $view = $this->viewsPagerFull(); // On the first round don't initialize the pager. - $this->assertEqual($view->get_items_per_page(), NULL, 'If the pager is not initialized and no manual override there is no items per page.'); $rand_number = rand(1, 5); $view->set_items_per_page($rand_number); @@ -491,6 +520,6 @@ class ViewsPagerTest extends ViewsSqlTest { $rand_number = rand(6, 11); $view->query->pager->set_current_page($rand_number); $this->assertEqual($view->get_current_page(), $rand_number, 'Make sure get_current_page uses the settings of set_current_page.'); - } + } diff --git a/sites/all/modules/views/tests/views_plugin_localization_test.inc b/sites/all/modules/views/tests/views_plugin_localization_test.inc index 1987fd8..ce90dff 100644 --- a/sites/all/modules/views/tests/views_plugin_localization_test.inc +++ b/sites/all/modules/views/tests/views_plugin_localization_test.inc @@ -9,15 +9,17 @@ * A stump localisation plugin which has static variables to cache the input. */ class views_plugin_localization_test extends views_plugin_localization { + /** * Store the strings which was translated. */ - var $translated_strings; + public $translated_strings; + /** * Return the string and take sure that the test can find out whether the * string got translated. */ - function translate_string($string, $keys = array(), $format = '') { + public function translate_string($string, $keys = array(), $format = '') { $this->translated_strings[] = $string; return $string . "-translated"; } @@ -25,7 +27,7 @@ class views_plugin_localization_test extends views_plugin_localization { /** * Store the export strings. */ - function export($source) { + public function export($source) { if (!empty($source['value'])) { $this->export_strings[] = $source['value']; } @@ -34,7 +36,8 @@ class views_plugin_localization_test extends views_plugin_localization { /** * Return the stored strings for the simpletest. */ - function get_export_strings() { + public function get_export_strings() { return $this->export_strings; } + } diff --git a/sites/all/modules/views/tests/views_query.test b/sites/all/modules/views/tests/views_query.test index db7d656..ed10f3b 100644 --- a/sites/all/modules/views/tests/views_query.test +++ b/sites/all/modules/views/tests/views_query.test @@ -2,13 +2,24 @@ /** * @file - * Tests for Views query features. + * Abstract class for views testing. */ /** - * Abstract class for views testing. + * */ abstract class ViewsTestCase extends DrupalWebTestCase { + + /** + * + */ + protected $sort_column = NULL; + + /** + * + */ + protected $sort_order = 1; + /** * Helper function: verify a result set returned by view. * @@ -16,13 +27,13 @@ abstract class ViewsTestCase extends DrupalWebTestCase { * column map, taking the order of the rows into account, but not the order * of the columns. * - * @param $view - * An executed View. - * @param $expected_result - * An expected result set. - * @param $column_map - * An associative array mapping the columns of the result set from the view - * (as keys) and the expected result set (as values). + * @param view $view + * An executed View. + * @param array $expected_result + * An expected result set. + * @param array $column_map + * An associative array mapping the columns of the result set from the view + * (as keys) and the expected result set (as values). */ protected function assertIdenticalResultset($view, $expected_result, $column_map = array(), $message = 'Identical result set') { return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, 'assertIdentical'); @@ -33,25 +44,29 @@ abstract class ViewsTestCase extends DrupalWebTestCase { * * Inverse of ViewsTestCase::assertIdenticalResultset(). * - * @param $view - * An executed View. - * @param $expected_result - * An expected result set. - * @param $column_map - * An associative array mapping the columns of the result set from the view - * (as keys) and the expected result set (as values). + * @param view $view + * An executed View. + * @param array $expected_result + * An expected result set. + * @param array $column_map + * An associative array mapping the columns of the result set from the view + * (as keys) and the expected result set (as values). */ protected function assertNotIdenticalResultset($view, $expected_result, $column_map = array(), $message = 'Identical result set') { return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, 'assertNotIdentical'); } + /** + * + */ protected function assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, $assert_method) { // Convert $view->result to an array of arrays. $result = array(); foreach ($view->result as $key => $value) { $row = array(); foreach ($column_map as $view_column => $expected_column) { - // The comparison will be done on the string representation of the value. + // The comparison will be done on the string representation of the + // value. $row[$expected_column] = (string) $value->$view_column; } $result[$key] = $row; @@ -61,7 +76,8 @@ abstract class ViewsTestCase extends DrupalWebTestCase { foreach ($expected_result as $key => $value) { $row = array(); foreach ($column_map as $expected_column) { - // The comparison will be done on the string representation of the value. + // The comparison will be done on the string representation of the + // value. $row[$expected_column] = (string) (is_object($value) ? $value->$expected_column : $value[$expected_column]); } $expected_result[$key] = $row; @@ -71,14 +87,14 @@ abstract class ViewsTestCase extends DrupalWebTestCase { $result = array_values($result); $expected_result = array_values($expected_result); - $this->verbose('
      Returned data set: ' . print_r($result, TRUE) . "\n\nExpected: ". print_r($expected_result, TRUE));
      +    $this->verbose('
      Returned data set: ' . print_r($result, TRUE) . "\n\nExpected: " . print_r($expected_result, TRUE));
       
           // Do the actual comparison.
           return $this->$assert_method($result, $expected_result, $message);
         }
       
         /**
      -   * Helper function: order an array of array based on a column.
      +   * Order an array of array based on a column.
          */
         protected function orderResultSet($result_set, $column, $reverse = FALSE) {
           $this->sort_column = $column;
      @@ -87,9 +103,6 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
           return $result_set;
         }
       
      -  protected $sort_column = NULL;
      -  protected $sort_order = 1;
      -
         /**
          * Helper comparison function for orderResultSet().
          */
      @@ -97,20 +110,20 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
           $value1 = $a[$this->sort_column];
           $value2 = $b[$this->sort_column];
           if ($value1 == $value2) {
      -        return 0;
      +      return 0;
           }
           return $this->sort_order * (($value1 < $value2) ? -1 : 1);
         }
       
         /**
      -   * Helper function to check whether a button with a certain id exists and has a certain label.
      +   * Check whether a button with a certain id exists and has a certain label.
          */
         protected function helperButtonHasLabel($id, $expected_label, $message = 'Label has the expected value: %label.') {
           return $this->assertFieldById($id, $expected_label, t($message, array('%label' => $expected_label)));
         }
       
         /**
      -   * Helper function to execute a view with debugging.
      +   * Execute a view with debugging.
          *
          * @param view $view
          * @param array $args
      @@ -121,14 +134,56 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
           $view->execute();
           $this->verbose('
      Executed view: ' . ((string) $view->build_info['query']) . '
      '); } + + /** + * Log in as user 1. + */ + protected function loginUser1() { + $password = user_password(); + // Reset the user 1 password. + $account = user_load(1); + $edit = array( + 'pass' => $password, + ); + $account = user_save($account, $edit); + $account->pass_raw = $password; + + // Log in as user 1. + $this->drupalLogin($account); + } + + /** + * {@inheritdoc} + */ + protected function verbose($message, $title = NULL) { + // Handle arrays, objects, etc. + if (!is_string($message)) { + $message = "
      \n" . print_r($message, TRUE) . "\n
      \n"; + } + + // Optional title to go before the output. + if (!empty($title)) { + $title = '

      ' . check_plain($title) . "

      \n"; + } + + parent::verbose($title . $message); + } + } +/** + * + */ abstract class ViewsSqlTest extends ViewsTestCase { + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp('views', 'views_ui'); - // Define the schema and views data variable before enabling the test module. + // Define the schema and views data variable before enabling the test + // module. variable_set('views_test_schema', $this->schemaDefinition()); variable_set('views_test_views_data', $this->viewsData()); variable_set('views_test_views_plugins', $this->viewsPlugins()); @@ -147,14 +202,32 @@ abstract class ViewsSqlTest extends ViewsTestCase { } /** - * This function allows to enable views ui from a higher class which can't change the setup function anymore. + * Create a term. * - * @TODO - * Convert existing setUp functions. + * @param int $vid + * The vocabulary ID that the term is to be added to. + * + * @return object + * A full term object with a random name. + */ + protected function drupalCreateTerm($vid) { + $term = new stdClass(); + $term->name = $this->randomName(); + $term->description = $this->randomName(); + $term->vid = $vid; + taxonomy_term_save($term); + return $term; + } + + /** + * This function allows to enable views ui from a higher class which can't + * change the setup function anymore. + * + * @todo Convert existing setUp functions. */ function enableViewsUi() { module_enable(array('views_ui')); - // @TODO Figure out why it's required to clear the cache here. + // @todo Figure out why it's required to clear the cache here. views_module_include('views_default', TRUE); views_get_all_views(TRUE); menu_rebuild(); @@ -202,7 +275,7 @@ abstract class ViewsSqlTest extends ViewsTestCase { ), 'primary key' => array('id'), 'unique keys' => array( - 'name' => array('name') + 'name' => array('name'), ), 'indexes' => array( 'ages' => array('age'), @@ -314,6 +387,9 @@ abstract class ViewsSqlTest extends ViewsTestCase { return $data; } + /** + * + */ protected function viewsPlugins() { return array(); } @@ -422,11 +498,12 @@ abstract class ViewsSqlTest extends ViewsTestCase { views_include('view'); $view = $this->getBasicView(); - // In order to test exposed filters, we have to disable - // the exposed forms cache. + // In order to test exposed filters, we have to disable the exposed forms + // cache. drupal_static_reset('views_exposed_form_cache'); $display = $view->new_display('page', 'Page', 'page_1'); return $view; } + } diff --git a/sites/all/modules/views/tests/views_test.info b/sites/all/modules/views/tests/views_test.info index c23f6c0..d7e7921 100644 --- a/sites/all/modules/views/tests/views_test.info +++ b/sites/all/modules/views/tests/views_test.info @@ -5,9 +5,8 @@ core = 7.x dependencies[] = views hidden = TRUE -; Information added by Drupal.org packaging script on 2017-08-23 -version = "7.x-3.18" +; Information added by Drupal.org packaging script on 2019-05-10 +version = "7.x-3.23" core = "7.x" project = "views" -datestamp = "1503495103" - +datestamp = "1557505389" diff --git a/sites/all/modules/views/tests/views_test.module b/sites/all/modules/views/tests/views_test.module index be533e0..caa87b9 100644 --- a/sites/all/modules/views/tests/views_test.module +++ b/sites/all/modules/views/tests/views_test.module @@ -35,7 +35,7 @@ function views_test_views_data() { $count = variable_get('views_test_views_data_count', 0); $count++; variable_set('views_test_views_data_count', $count); - return variable_get('views_test_views_data', array()); + return variable_get('views_test_views_data', array()); } /** diff --git a/sites/all/modules/views/tests/views_test.views_default.inc b/sites/all/modules/views/tests/views_test.views_default.inc index fa49acb..a494a4e 100644 --- a/sites/all/modules/views/tests/views_test.views_default.inc +++ b/sites/all/modules/views/tests/views_test.views_default.inc @@ -9,7 +9,7 @@ * Implements hook_views_default_views(). */ function views_test_views_default_views() { - $view = new view; + $view = new view(); $view->name = 'test_views_groupby_save'; $view->description = ''; $view->tag = ''; @@ -31,7 +31,7 @@ function views_test_views_default_views() { $views[$view->name] = $view; - $view = new view; + $view = new view(); $view->name = 'test_rename_reset_button'; $view->description = ''; $view->tag = ''; @@ -70,7 +70,7 @@ function views_test_views_default_views() { $views[$view->name] = $view; - $view = new view; + $view = new view(); $view->name = 'test_exposed_admin_ui'; $view->description = ''; $view->tag = ''; @@ -110,7 +110,7 @@ function views_test_views_default_views() { $views[$view->name] = $view; - $view = new view; + $view = new view(); $view->name = 'test_filter_in_operator_ui'; $view->description = ''; $view->tag = ''; @@ -142,7 +142,7 @@ function views_test_views_default_views() { $views[$view->name] = $view; - $view = new view; + $view = new view(); $view->name = 'test_argument_default_current_user'; $view->description = ''; $view->tag = ''; diff --git a/sites/all/modules/views/tests/views_translatable.test b/sites/all/modules/views/tests/views_translatable.test index 983a97e..9c3422c 100644 --- a/sites/all/modules/views/tests/views_translatable.test +++ b/sites/all/modules/views/tests/views_translatable.test @@ -31,7 +31,7 @@ class ViewsTranslatableTest extends ViewsSqlTest { 'help' => t('This is a test description.'), 'handler' => 'views_plugin_localization_test', 'parent' => 'parent', - 'path' => drupal_get_path('module', 'views') .'/tests', + 'path' => drupal_get_path('module', 'views') . '/tests', ), ), ); @@ -100,7 +100,6 @@ class ViewsTranslatableTest extends ViewsSqlTest { $view->init_display(); // Don't run translation. We just want to get the right keys. - foreach ($view->display as $display_id => $display) { $translatables = array(); $display->handler->unpack_translatables($translatables); @@ -145,7 +144,7 @@ class ViewsTranslatableTest extends ViewsSqlTest { } public function view_unpack_translatable() { - $view = new view; + $view = new view(); $view->name = 'view_unpack_translatable'; $view->description = ''; $view->tag = ''; @@ -218,4 +217,5 @@ class ViewsTranslatableTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/views/tests/views_ui.test b/sites/all/modules/views/tests/views_ui.test index 8785539..8a7e0e1 100644 --- a/sites/all/modules/views/tests/views_ui.test +++ b/sites/all/modules/views/tests/views_ui.test @@ -9,6 +9,10 @@ * Views UI wizard tests. */ class ViewsUIWizardHelper extends DrupalWebTestCase { + + /** + * + */ function setUp() { // Enable views_ui. parent::setUp('views_ui'); @@ -17,12 +21,17 @@ class ViewsUIWizardHelper extends DrupalWebTestCase { $views_admin = $this->drupalCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view revisions')); $this->drupalLogin($views_admin); } + } /** * Tests creating views with the wizard and viewing them on the listing page. */ class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard basic functionality', @@ -31,6 +40,9 @@ class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper { ); } + /** + * + */ function testViewsWizardAndListing() { // Check if we can access the main views admin page. $this->drupalGet('admin/structure/views'); @@ -46,7 +58,7 @@ class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper { $this->assertText(t('Your view was saved. You may edit it from the list below.')); $this->assertText($view1['human_name']); $this->assertText($view1['description']); - foreach(array('delete', 'clone', 'edit') as $operation) { + foreach (array('delete', 'clone', 'edit') as $operation) { $this->assertLinkByHref(url('admin/structure/views/view/' . $view1['name'] . '/' . $operation)); } @@ -146,12 +158,17 @@ class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper { // Make sure the listing page doesn't show disabled default views. $this->assertNoText('tracker', t('Default tracker view does not show on the listing page.')); } + } /** * Tests enabling, disabling, and reverting default views via the listing page. */ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI default views functionality', @@ -168,10 +185,9 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper { // the listing page). $edit_href = 'admin/structure/views/view/frontpage/edit'; $this->drupalGet('admin/structure/views'); - // TODO: Disabled default views do now appear on the front page. Test this + // @todo Disabled default views do now appear on the front page. Test this // behavior with templates instead. // $this->assertNoLinkByHref($edit_href); - // Enable the front page view, and make sure it is now visible on the main // listing page. $this->drupalGet('admin/structure/views/templates'); @@ -205,7 +221,7 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper { // Now disable the view, and make sure it stops appearing on the main view // listing page but instead goes back to displaying on the disabled views // listing page. - // TODO: Test this behavior with templates instead. + // @todo Test this behavior with templates instead. $this->drupalGet('admin/structure/views'); $this->clickViewsOperationLink(t('Disable'), '/frontpage/'); // $this->assertUrl('admin/structure/views'); @@ -225,15 +241,15 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper { * various views listing pages, and they might have tokens in them. So we * need special code to find the correct one to click. * - * @param $label + * @param string $label * Text between the anchor tags of the desired link. - * @param $unique_href_part + * @param string $unique_href_part * A unique string that is expected to occur within the href of the desired * link. For example, if the link URL is expected to look like * "admin/structure/views/view/frontpage/...", then "/frontpage/" could be * passed as the expected unique string. * - * @return + * @return string * The page content that results from clicking on the link, or FALSE on * failure. Failure also results in a failed assertion. */ @@ -254,18 +270,42 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper { return FALSE; } } + } /** * Tests the ability of the views wizard to create views filtered by taxonomy. */ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper { + + /** + * + */ protected $node_type_with_tags; + + /** + * + */ protected $node_type_without_tags; + + /** + * + */ protected $tag_vocabulary; + + /** + * + */ protected $tag_field; + + /** + * + */ protected $tag_instance; + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard taxonomy functionality', @@ -274,6 +314,9 @@ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper { ); } + /** + * {@inheritdoc} + */ function setUp() { parent::setUp(); @@ -392,7 +435,7 @@ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper { } /** - * Tests that the "tagged with" form element only shows for node types that support it. + * Test the "tagged with" form element only shows for node types that support it. */ function testTaggedWithByNodeType() { // The tagging field is associated with one of our node types only. So the @@ -422,12 +465,17 @@ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper { $this->drupalPost(NULL, $view, t('Update "of type" choice')); $this->assertFieldByXpath($tags_xpath); } + } /** * Tests the ability of the views wizard to create views with sorts. */ class ViewsUIWizardSortingTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard sorting functionality', @@ -492,12 +540,17 @@ class ViewsUIWizardSortingTestCase extends ViewsUIWizardHelper { $pos1 = strpos($content, $node1->title); $this->assertTrue($pos3 < $pos2 && $pos2 < $pos1, t('The nodes appear in the expected order in a view that sorts by newest first.')); } + } /** - * Tests the ability of the views wizard to specify the number of items per page. + * Tests the ability of the wizard to specify the number of items per page. */ class ViewsUIWizardItemsPerPageTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard items per page functionality', @@ -577,12 +630,17 @@ class ViewsUIWizardItemsPerPageTestCase extends ViewsUIWizardHelper { $pos3 = strpos($content, $node3->title); $this->assertTrue($pos5 < $pos4 && $pos4 < $pos3, t('The nodes appear in the expected order in the block display.')); } + } /** * Tests the ability of the views wizard to put views in a menu. */ class ViewsUIWizardMenuTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard menu functionality', @@ -625,12 +683,17 @@ class ViewsUIWizardMenuTestCase extends ViewsUIWizardHelper { } $this->assertTrue($found, t('Found a link to %path in the main menu', array('%path' => $view['page[path]']))); } + } /** - * Tests the ability of the views wizard to create views with a jump menu style plugin. + * Tests the ability of the wizard to create views with a jump menu style. */ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard jump menu functionality', @@ -683,7 +746,6 @@ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper { // Submit the jump menu form, and check that we are redirected to the // expected URL. - $edit = array(); $edit['jump'] = url($path, $options); @@ -786,12 +848,17 @@ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper { node_save($node); return 'node/' . $node->nid . '/revisions/' . $node->vid . '/view'; } + } /** * Tests that displays can be correctly overridden via the user interface. */ class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI overridden displays', @@ -948,9 +1015,8 @@ class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper { * Tests that the revert to all displays select-option works as expected. */ function testRevertAllDisplays() { - // Create a basic view with a page, block. - // Because there is both a title on page and block we expect the title on - // the block be overriden. + // Create a basic view with a page, block. Because there is both a title on + // page and block we expect the title on the block be overriden. $view['human_name'] = $this->randomName(16); $view['name'] = strtolower($this->randomName(16)); $view['page[create]'] = 1; @@ -970,4 +1036,5 @@ class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper { $this->drupalPost("admin/structure/views/view/{$view['name']}/edit/block", array(), t('Save')); $this->assertText($view['page[title]']); } + } diff --git a/sites/all/modules/views/tests/views_upgrade.test b/sites/all/modules/views/tests/views_upgrade.test index 3f453db..0c4da8f 100644 --- a/sites/all/modules/views/tests/views_upgrade.test +++ b/sites/all/modules/views/tests/views_upgrade.test @@ -11,6 +11,10 @@ * You can find all conversions by searching for "moved to". */ class ViewsUpgradeTestCase extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views Upgrade test', @@ -19,14 +23,21 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { ); } + /** + * {@inheritdoc} + */ protected function setUp() { -// // To import a view the user needs use PHP for settings rights, so enable php module. + // To import a view the user needs use PHP for settings rights, so enable + // PHP module. parent::setUp(); module_enable(array('php')); $this->resetAll(); } + /** + * + */ function viewsData() { $data = parent::viewsData(); $data['views_test']['old_field_1']['moved to'] = array('views_test', 'id'); @@ -41,6 +52,9 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { return $data; } + /** + * + */ function debugField($field) { $keys = array('id', 'table', 'field', 'actual_field', 'original_field', 'real_field'); $info = array(); @@ -59,8 +73,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { $view->update(); $view->build(); -// $this->assertEqual('old_field_1', $view->field['old_field_1']->options['id'], "Id shouldn't change during conversion"); -// $this->assertEqual('id', $view->field['old_field_1']->field, 'The field should change during conversion'); + // $this->assertEqual('old_field_1', + // $view->field['old_field_1']->options['id'], + // "Id shouldn't change during conversion"); + // $this->assertEqual('id', $view->field['old_field_1']->field, + // 'The field should change during conversion'); $this->assertEqual('id', $view->field['old_field_1']->real_field); $this->assertEqual('views_test', $view->field['old_field_1']->table); $this->assertEqual('old_field_1', $view->field['old_field_1']->original_field, 'The field should have stored the original_field'); @@ -70,11 +87,13 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { $view->update(); $view->build(); -// $this->assertEqual('old_field_2', $view->field['old_field_2']->options['id']); + // $this->assertEqual('old_field_2', + // $view->field['old_field_2']->options['id']); $this->assertEqual('name', $view->field['old_field_2']->real_field); $this->assertEqual('views_test', $view->field['old_field_2']->table); -// $this->assertEqual('old_field_3', $view->filter['old_field_3']->options['id']); + // $this->assertEqual('old_field_3', + // $view->filter['old_field_3']->options['id']); $this->assertEqual('age', $view->filter['old_field_3']->real_field); $this->assertEqual('views_test', $view->filter['old_field_3']->table); @@ -84,7 +103,8 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { $view->build(); $this->assertEqual('views_test', $view->base_table, 'Make sure that view->base_table gets automatically converted.'); -// $this->assertEqual('id', $view->field['id']->field, 'If we move a whole table fields of this table should work, too.'); + // $this->assertEqual('id', $view->field['id']->field, + // 'If we move a whole table fields of this table should work, too.'); $this->assertEqual('id', $view->field['id']->real_field, 'To run the query right the real_field has to be set right.'); $this->assertEqual('views_test', $view->field['id']->table); } @@ -106,8 +126,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { $this->assertText('Recent comments'); } + /** + * + */ public function viewsMovedToField() { - $view = new view; + $view = new view(); $view->name = 'test_views_move_to_field'; $view->description = ''; $view->tag = ''; @@ -127,8 +150,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { return $view; } + /** + * + */ public function viewsMovedToHandler() { - $view = new view; + $view = new view(); $view->name = 'test_views_move_to_handler'; $view->description = ''; $view->tag = ''; @@ -152,8 +178,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { return $view; } + /** + * + */ public function viewsMovedToTable() { - $view = new view; + $view = new view(); $view->name = 'test_views_move_to_table'; $view->description = ''; $view->tag = ''; @@ -173,6 +202,9 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { return $view; } + /** + * + */ protected function viewUpgradeImport() { $import = ' $view = new view; @@ -272,6 +304,7 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { $handler->display->display_options["block_description"] = "Recent comments view" ;'; - return $import; + return $import; } + } diff --git a/sites/all/modules/views/tests/views_view.test b/sites/all/modules/views/tests/views_view.test index e72e811..489864a 100644 --- a/sites/all/modules/views/tests/views_view.test +++ b/sites/all/modules/views/tests/views_view.test @@ -2,26 +2,27 @@ /** * @file - * Definition of ViewsViewTest. + * Views class tests. */ /** - * Views class tests. * - * @codingStandardsIgnoreStart */ class ViewsViewTest extends ViewsSqlTest { - // @codingStandardsIgnoreEnd + + /** + * Provide the test's meta information. + */ public static function getInfo() { return array( 'name' => 'Test the view class', - 'description' => 'Tests some functionality of the view class', + 'description' => 'Tests some functionality of the view class', 'group' => 'Views', ); } /** - * Tests the deconstructor to be sure that every kind of heavy objects are removed. + * Ensure that every kind of heavy objects are removed by the destructor. */ function testDestroy() { $view = $this->view_test_destroy(); @@ -39,6 +40,12 @@ class ViewsViewTest extends ViewsSqlTest { $this->assertViewDestroy($view); } + /** + * Assert that a given view is destroyed properly. + * + * @param object $view + * The view to destroy. + */ function assertViewDestroy($view) { $this->assertFalse(isset($view->display['default']->handler), 'Make sure all displays are destroyed.'); $this->assertFalse(isset($view->display['attachment_1']->handler), 'Make sure all displays are destroyed.'); @@ -61,8 +68,11 @@ class ViewsViewTest extends ViewsSqlTest { $this->assertEqual($view->attachment_after, ''); } + /** + * Test deleting a view. + */ function testDelete() { - // Delete a database view + // Delete a database view. $view = $this->view_test_delete(); $view->save(); $view = views_get_view($view->name); @@ -75,10 +85,13 @@ class ViewsViewTest extends ViewsSqlTest { $this->assertNull($view, "Make sure that the old view gets cleared by the reset parameter."); } + /** + * Test validation. + */ function testValidate() { // Test a view with multiple displays. // Validating a view shouldn't change the active display. - // @todo: Create an extra validation view. + // @todo Create an extra validation view. $view = $this->view_test_destroy(); $view->set_display('page_1'); @@ -86,17 +99,20 @@ class ViewsViewTest extends ViewsSqlTest { $this->assertEqual('page_1', $view->current_display, "The display should be constant while validating"); - // @todo: Write real tests for the validation. + // @todo Write real tests for the validation. // In general the following things could be tested: - // - Deleted displays shouldn't be validated + // - Deleted displays shouldn't be validated. // - Multiple displays are validating and the errors are merged together. } /** - * This view provides some filters, fields, arguments, relationships, sorts, areas and attachments. + * Generate an example view. + * + * Includes: + * filters, fields, arguments, relationships, sorts, areas and attachments. */ function view_test_destroy() { - $view = new view; + $view = new view(); $view->name = 'test_destroy'; $view->description = ''; $view->tag = ''; @@ -257,8 +273,12 @@ class ViewsViewTest extends ViewsSqlTest { return $view; } + + /** + * Creates a test view. + */ function view_test_delete() { - $view = new view; + $view = new view(); $view->name = 'test_view_delete'; $view->description = ''; $view->tag = ''; @@ -294,4 +314,5 @@ class ViewsViewTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/views/theme/theme.inc b/sites/all/modules/views/theme/theme.inc index befd4d1..99b8efe 100644 --- a/sites/all/modules/views/theme/theme.inc +++ b/sites/all/modules/views/theme/theme.inc @@ -8,11 +8,11 @@ /** * Provide a full array of possible themes to try for a given hook. * - * @param $hook + * @param string $hook * The hook to use. This is the base theme/template name. - * @param $view + * @param object $view * The view being rendered. - * @param $display + * @param object $display * The display being rendered, if applicable. */ function _views_theme_functions($hook, $view, $display = NULL) { @@ -52,7 +52,7 @@ function template_preprocess_views_view(&$vars) { $vars['name'] = $view->name; $vars['display_id'] = $view->current_display; - // Basic classes + // Basic classes. $vars['css_class'] = ''; $vars['classes_array'] = array(); @@ -81,7 +81,7 @@ function template_preprocess_views_view(&$vars) { $vars['pager'] = ''; - // @todo: Figure out whether this belongs into views_ui_preprocess_views_view. + // @todo Figure out whether this belongs into views_ui_preprocess_views_view. // Render title for the admin preview. $vars['title'] = !empty($view->views_ui_context) ? filter_xss_admin($view->get_title()) : ''; @@ -104,15 +104,15 @@ function template_preprocess_views_view(&$vars) { // Attachments are always updated with the outer view, never by themselves, // so they do not have dom ids. if (empty($view->is_attachment)) { - // Our JavaScript needs to have some means to find the HTML belonging to this - // view. + // Our JavaScript needs to have some means to find the HTML belonging to + // this view. // // It is true that the DIV wrapper has classes denoting the name of the view // and its display ID, but this is not enough to unequivocally match a view // with its HTML, because one view may appear several times on the page. So - // we set up a hash with the current time, $dom_id, to issue a "unique" identifier for - // each view. This identifier is written to both Drupal.settings and the DIV - // wrapper. + // we set up a hash with the current time, $dom_id, to issue a "unique" + // identifier for each view. This identifier is written to both + // Drupal.settings and the DIV wrapper. $vars['dom_id'] = $view->dom_id; $vars['classes_array'][] = 'view-dom-id-' . $vars['dom_id']; } @@ -129,7 +129,9 @@ function template_preprocess_views_view(&$vars) { 'view_args' => check_plain(implode('/', $view->args)), 'view_path' => check_plain($_GET['q']), // Pass through URL to ensure we get e.g. language prefixes. -// 'view_base_path' => isset($view->display['page']) ? substr(url($view->display['page']->display_options['path']), strlen($base_path)) : '', + // 'view_base_path' => isset($view->display['page']) ? + // substr(url($view->display['page']->display_options['path']), + // strlen($base_path)) : '', 'view_base_path' => $view->get_path(), 'view_dom_id' => $vars['dom_id'], // To fit multiple views on a page, the programmer may have @@ -179,16 +181,17 @@ function template_process_views_view(&$vars) { } /** - * Preprocess theme function to print a single record from a row, with fields + * Preprocess theme function to print a single record from a row, with fields. */ function template_preprocess_views_view_fields(&$vars) { $view = $vars['view']; // Loop through the fields for this view. $previous_inline = FALSE; - $vars['fields'] = array(); // ensure it's at least an empty array. + $vars['fields'] = array(); + // Ensure it's at least an empty array. foreach ($view->field as $id => $field) { - // render this even if set to exclude so it can be used elsewhere. + // Render this even if set to exclude so it can be used elsewhere. $field_output = $view->style_plugin->get_field($view->row_index, $id); $empty = $field->is_value_empty($field_output, $field->options['empty_zero']); if (empty($field->options['exclude']) && (!$empty || (empty($field->options['hide_empty']) && empty($vars['options']['hide_empty'])))) { @@ -207,7 +210,7 @@ function template_preprocess_views_view_fields(&$vars) { if ($class) { $class .= ' '; } - $class .= $classes; + $class .= $classes; } $pre = '<' . $object->element_type; @@ -218,7 +221,8 @@ function template_preprocess_views_view_fields(&$vars) { } // Protect ourself somewhat for backward compatibility. This will prevent - // old templates from producing invalid HTML when no element type is selected. + // old templates from producing invalid HTML when no element type is + // selected. if (empty($object->element_type)) { $object->element_type = 'span'; } @@ -228,7 +232,8 @@ function template_preprocess_views_view_fields(&$vars) { $object->raw = $vars['row']->{$view->field[$id]->field_alias}; } else { - $object->raw = NULL; // make sure it exists to reduce NOTICE + // Make sure it exists to reduce NOTICE. + $object->raw = NULL; } if (!empty($vars['options']['separator']) && $previous_inline && $object->inline && $object->content) { @@ -268,8 +273,8 @@ function template_preprocess_views_view_fields(&$vars) { $object->wrapper_suffix = 'inline_html . '>'; } - // Set up the label for the value and the HTML to make it easier - // on the template. + // Set up the label for the value and the HTML to make it easier on the + // template. $object->label = check_plain($view->field[$id]->label()); $object->label_html = ''; if ($object->label) { @@ -307,7 +312,6 @@ function template_preprocess_views_view_fields(&$vars) { $vars['fields'][$id] = $object; } } - } /** @@ -320,7 +324,7 @@ function theme_views_view_grouping($vars) { $output = '
      '; $output .= '
      ' . $title . '
      '; - $output .= '
      ' . $content . '
      ' ; + $output .= '
      ' . $content . '
      '; $output .= '
      '; return $output; @@ -338,7 +342,7 @@ function template_preprocess_views_view_grouping(&$vars) { * * Interesting bits of info: * $field->field_alias says what the raw value in $row will be. Reach it like - * this: @code { $row->{$field->field_alias} @endcode + * this: @code { $row->{$field->field_alias} @endcode. */ function theme_views_view_field($vars) { $view = $vars['view']; @@ -359,7 +363,7 @@ function template_preprocess_views_view_field(&$vars) { } /** - * Preprocess theme function to print a single record from a row, with fields + * Preprocess theme function to print a single record from a row, with fields. */ function template_preprocess_views_view_summary(&$vars) { $view = $vars['view']; @@ -373,12 +377,17 @@ function template_preprocess_views_view_summary(&$vars) { } $active_urls = drupal_map_assoc(array( - url($_GET['q'], array('alias' => TRUE)), // force system path - url($_GET['q']), // could be an alias + // Force system path. + url($_GET['q'], array('alias' => TRUE)), + url($_GET['q'], $url_options + array('alias' => TRUE)), + // Could be an alias. + url($_GET['q']), + url($_GET['q'], $url_options), )); - // Collect all arguments foreach row, to be able to alter them for example by the validator. - // This is not done per single argument value, because this could cause performance problems. + // Collect all arguments foreach row, to be able to alter them for example by + // the validator. This is not done per single argument value, because this + // could cause performance problems. $row_args = array(); foreach ($vars['rows'] as $id => $row) { @@ -406,8 +415,7 @@ function template_preprocess_views_view_summary(&$vars) { } /** - * Template preprocess theme function to print summary basically - * unformatted. + * Template preprocess theme function to print summary basically unformatted. */ function template_preprocess_views_view_summary_unformatted(&$vars) { $view = $vars['view']; @@ -422,12 +430,17 @@ function template_preprocess_views_view_summary_unformatted(&$vars) { $count = 0; $active_urls = drupal_map_assoc(array( - url($_GET['q'], array('alias' => TRUE)), // force system path - url($_GET['q']), // could be an alias + // Force system path. + url($_GET['q'], array('alias' => TRUE)), + url($_GET['q'], $url_options + array('alias' => TRUE)), + // Could be an alias. + url($_GET['q']), + url($_GET['q'], $url_options), )); - // Collect all arguments foreach row, to be able to alter them for example by the validator. - // This is not done per single argument value, because this could cause performance problems. + // Collect all arguments foreach row, to be able to alter them for example by + // the validator. This is not done per single argument value, because this + // could cause performance problems. $row_args = array(); foreach ($vars['rows'] as $id => $row) { $row_args[$id] = $argument->summary_argument($row); @@ -435,7 +448,7 @@ function template_preprocess_views_view_summary_unformatted(&$vars) { $argument->process_summary_arguments($row_args); foreach ($vars['rows'] as $id => $row) { - // only false on first time: + // Only false on first time. if ($count++) { $vars['rows'][$id]->separator = filter_xss_admin($vars['options']['separator']); } @@ -461,18 +474,33 @@ function template_preprocess_views_view_summary_unformatted(&$vars) { function template_preprocess_views_view_table(&$vars) { $view = $vars['view']; - // We need the raw data for this grouping, which is passed in as $vars['rows']. - // However, the template also needs to use for the rendered fields. We - // therefore swap the raw data out to a new variable and reset $vars['rows'] - // so that it can get rebuilt. - // Store rows so that they may be used by further preprocess functions. + // We need the raw data for this grouping, which is passed in as + // $vars['rows']. However, the template also needs to use for the rendered + // fields. We therefore swap the raw data out to a new variable and reset + // $vars['rows'] so that it can get rebuilt. Store rows so that they may be + // used by further preprocess functions. $result = $vars['result'] = $vars['rows']; $vars['rows'] = array(); $vars['field_classes'] = array(); $vars['header'] = array(); + $vars['classes_array'] = array(); $options = $view->style_plugin->options; $handler = $view->style_plugin; + + if (!empty($handler->options['class'])) { + $classes = explode(' ', $handler->options['class']); + $classes = array_map('views_clean_css_identifier', $classes); + + if (!empty($classes)) { + // Trim empty class entries. + foreach ($classes as $key => $class) { + if (!empty($class)) { + $vars['classes_array'][] = $class; + } + } + } + } $default_row_class = isset($options['default_row_class']) ? $options['default_row_class'] : TRUE; $row_class_special = isset($options['row_class_special']) ? $options['row_class_special'] : TRUE; @@ -493,14 +521,14 @@ function template_preprocess_views_view_table(&$vars) { $renders = $handler->render_fields($result); foreach ($columns as $field => $column) { - // Create a second variable so we can easily find what fields we have and what the - // CSS classes should be. + // Create a second variable so we can easily find what fields we have and + // what the CSS classes should be. $vars['fields'][$field] = drupal_clean_css_identifier($field); if ($active == $field) { $vars['fields'][$field] .= ' active'; } - // render the header labels + // Render the header labels. if ($field == $column && empty($fields[$field]->options['exclude'])) { $label = check_plain(!empty($fields[$field]) ? $fields[$field]->label() : ''); if (empty($options['info'][$field]['sortable']) || !$fields[$field]->click_sortable()) { @@ -540,7 +568,7 @@ function template_preprocess_views_view_table(&$vars) { } $vars['header_classes'][$field] .= $class; } - // Add a CSS align class to each field if one was set + // Add a CSS align class to each field if one was set. if (!empty($options['info'][$field]['align'])) { $vars['header_classes'][$field] .= ' ' . drupal_clean_css_identifier($options['info'][$field]['align']); } @@ -552,17 +580,16 @@ function template_preprocess_views_view_table(&$vars) { $vars['header'][$field] = '<' . $element_label_type . '>' . $vars['header'][$field] . ''; } } - } - // Add a CSS align class to each field if one was set + // Add a CSS align class to each field if one was set. if (!empty($options['info'][$field]['align'])) { $vars['fields'][$field] .= ' ' . drupal_clean_css_identifier($options['info'][$field]['align']); } // Render each field into its appropriate column. foreach ($result as $num => $row) { - // Add field classes + // Add field classes. $vars['field_classes'][$field][$num] = ''; if ($fields[$field]->options['element_default_classes']) { $vars['field_classes'][$field][$num] = "views-field views-field-" . $vars['fields'][$field]; @@ -602,7 +629,8 @@ function template_preprocess_views_view_table(&$vars) { } } - // Remove columns if the option is hide empty column is checked and the field is not empty. + // Remove columns if the option is hide empty column is checked and the + // field is not empty. if (!empty($options['info'][$field]['empty_column'])) { $empty = TRUE; foreach ($vars['rows'] as $num => $columns) { @@ -638,7 +666,7 @@ function template_preprocess_views_view_table(&$vars) { $vars['row_classes'][count($vars['row_classes']) - 1][] = 'views-row-last'; } - $vars['classes_array'] = array('views-table'); + $vars['classes_array'][] = 'views-table'; if (empty($vars['rows']) && !empty($options['empty_table'])) { $vars['rows'][0][0] = $view->display_handler->render_area('empty'); // Calculate the amounts of rows with output. @@ -646,12 +674,11 @@ function template_preprocess_views_view_table(&$vars) { $vars['field_classes'][0][0] = 'views-empty'; } - if (!empty($options['sticky'])) { drupal_add_js('misc/tableheader.js'); $vars['classes_array'][] = "sticky-enabled"; } - $vars['classes_array'][] = 'cols-'. count($vars['header']); + $vars['classes_array'][] = 'cols-' . count($vars['header']); // Add the summary to the list if set. if (!empty($handler->options['summary'])) { @@ -702,7 +729,7 @@ function template_preprocess_views_view_grid(&$vars) { } if ($row) { // Fill up the last line only if it's configured, but this is default. - if (!empty($handler->options['fill_single_line']) && count($rows)) { + if (!empty($handler->options['fill_single_line'])) { for ($i = 0; $i < ($columns - $col_count); $i++) { $row[] = ''; } @@ -731,33 +758,40 @@ function template_preprocess_views_view_grid(&$vars) { $remainders--; } } - for ($i = 0; $i < count($rows[0]); $i++) { - // This should be string so that's okay :) + + // Fill out the row with empty values, if needed. + if (!empty($handler->options['fill_single_line'])) { + $column_fill = $columns; + } + else { + $column_fill = count($rows[0]); + } + for ($i = 0; $i < $column_fill; $i++) { if (!isset($rows[count($rows) - 1][$i])) { $rows[count($rows) - 1][$i] = ''; } } } - // Apply the row classes + // Apply the row classes. foreach ($rows as $row_number => $row) { $row_classes = array(); if ($default_row_class) { - $row_classes[] = 'row-' . ($row_number + 1); + $row_classes[] = 'row-' . ($row_number + 1); } if ($row_class_special) { if ($row_number == 0) { - $row_classes[] = 'row-first'; + $row_classes[] = 'row-first'; } if (count($rows) == ($row_number + 1)) { - $row_classes[] = 'row-last'; + $row_classes[] = 'row-last'; } } $vars['row_classes'][$row_number] = implode(' ', $row_classes); foreach ($rows[$row_number] as $column_number => $item) { $column_classes = array(); if ($default_row_class) { - $column_classes[] = 'col-'. ($column_number + 1); + $column_classes[] = 'col-' . ($column_number + 1); } if ($row_class_special) { if ($column_number == 0) { @@ -791,7 +825,7 @@ function template_preprocess_views_view_grid(&$vars) { } /** - * Display the simple view of rows one after another + * Display the simple view of rows one after another. */ function template_preprocess_views_view_unformatted(&$vars) { $view = $vars['view']; @@ -832,7 +866,7 @@ function template_preprocess_views_view_unformatted(&$vars) { } /** - * Display the view as an HTML list element + * Display the view as an HTML list element. */ function template_preprocess_views_view_list(&$vars) { $handler = $vars['view']->style_plugin; @@ -861,7 +895,7 @@ function template_preprocess_views_view_list(&$vars) { } /** - * Preprocess an RSS feed + * Preprocess an RSS feed. */ function template_preprocess_views_view_rss(&$vars) { global $base_url; @@ -889,8 +923,8 @@ function template_preprocess_views_view_rss(&$vars) { } $vars['title'] = check_plain($title); - // Figure out which display which has a path we're using for this feed. If there isn't - // one, use the global $base_url + // Figure out which display which has a path we're using for this feed. If + // there isn't one, use the global $base_url. $link_display_id = $view->display_handler->get_link_display(); if ($link_display_id && !empty($view->display[$link_display_id])) { $path = $view->display[$link_display_id]->handler->get_path(); @@ -903,7 +937,8 @@ function template_preprocess_views_view_rss(&$vars) { $url_options['query'] = $view->exposed_raw_input; } - // Compare the link to the default home page; if it's the default home page, just use $base_url. + // Compare the link to the default home page; if it's the default home + // page, just use $base_url. if ($path == variable_get('site_frontpage', 'node')) { $path = ''; } @@ -957,8 +992,8 @@ function template_preprocess_views_exposed_form(&$vars) { $checkboxes .= drupal_render($form[$info['value']]); continue; } - $widget = new stdClass; - // set up defaults so that there's always something there. + $widget = new stdClass(); + // Set up defaults so that there's always something there. $widget->label = $widget->operator = $widget->widget = $widget->description = NULL; $widget->id = isset($form[$info['value']]['#id']) ? $form[$info['value']]['#id'] : ''; @@ -981,8 +1016,8 @@ function template_preprocess_views_exposed_form(&$vars) { // Wrap up all the checkboxes we set aside into a widget. if ($checkboxes) { - $widget = new stdClass; - // set up defaults so that there's always something there. + $widget = new stdClass(); + // Set up defaults so that there's always something there. $widget->label = $widget->operator = $widget->widget = NULL; $widget->id = 'checkboxes'; $widget->widget = $checkboxes; @@ -1038,6 +1073,9 @@ function theme_views_form_views_form($variables) { return drupal_render_children($form); } +/** + * theme function for a mini pager. + */ function theme_views_mini_pager($vars) { global $pager_page_array, $pager_total; @@ -1045,12 +1083,11 @@ function theme_views_mini_pager($vars) { $element = $vars['element']; $parameters = $vars['parameters']; - // current is the page we are currently paged to + // Current is the page we are currently paged to. $pager_current = $pager_page_array[$element] + 1; - // max is the maximum page number + // Max is the maximum page number. $pager_max = $pager_total[$element]; // End of marker calculations. - if ($pager_total[$element] > 1) { $li_previous = theme('pager_previous', @@ -1092,6 +1129,7 @@ function theme_views_mini_pager($vars) { 'class' => array('pager-next'), 'data' => $li_next, ); + return theme('item_list', array( 'items' => $items, diff --git a/sites/all/modules/views/theme/views-more.tpl.php b/sites/all/modules/views/theme/views-more.tpl.php index a2e1703..1adfa3e 100644 --- a/sites/all/modules/views/theme/views-more.tpl.php +++ b/sites/all/modules/views/theme/views-more.tpl.php @@ -15,8 +15,7 @@ ?> diff --git a/sites/all/modules/views/theme/views-ui-display-tab-bucket.tpl.php b/sites/all/modules/views/theme/views-ui-display-tab-bucket.tpl.php index 6d51a1d..079f579 100644 --- a/sites/all/modules/views/theme/views-ui-display-tab-bucket.tpl.php +++ b/sites/all/modules/views/theme/views-ui-display-tab-bucket.tpl.php @@ -7,7 +7,7 @@ ?>
      > - + diff --git a/sites/all/modules/views/theme/views-ui-edit-view.tpl.php b/sites/all/modules/views/theme/views-ui-edit-view.tpl.php deleted file mode 100644 index 5c3732c..0000000 --- a/sites/all/modules/views/theme/views-ui-edit-view.tpl.php +++ /dev/null @@ -1,46 +0,0 @@ - -
      - -
      - break this lock.', array('!user' => $locked, '!age' => $lock_age, '!break' => $break)); ?> -
      - -
      "> - vid)): ?> -
      - -
      - - - @base.', - array('%name' => $view->name, '@base' => $base_table)); ?> -
      - - - -
      -
      - -
      -
      - - -
      -
      - - - -

      -
      - -
      -
      diff --git a/sites/all/modules/views/theme/views-view-grid.tpl.php b/sites/all/modules/views/theme/views-view-grid.tpl.php index 09f807a..f56bd61 100644 --- a/sites/all/modules/views/theme/views-view-grid.tpl.php +++ b/sites/all/modules/views/theme/views-view-grid.tpl.php @@ -20,9 +20,9 @@ $columns): ?> - > + class=""> $item): ?> - > + class=""> diff --git a/sites/all/modules/views/theme/views-view-list.tpl.php b/sites/all/modules/views/theme/views-view-list.tpl.php index 601279a..27e2736 100644 --- a/sites/all/modules/views/theme/views-view-list.tpl.php +++ b/sites/all/modules/views/theme/views-view-list.tpl.php @@ -6,6 +6,7 @@ * * - $title : The title of this group of rows. May be empty. * - $options['type'] will either be ul or ol. + * * @ingroup views_templates */ ?> diff --git a/sites/all/modules/views/theme/views-view-row-comment.tpl.php b/sites/all/modules/views/theme/views-view-row-comment.tpl.php index 7fe2e81..dc1aa39 100644 --- a/sites/all/modules/views/theme/views-view-row-comment.tpl.php +++ b/sites/all/modules/views/theme/views-view-row-comment.tpl.php @@ -10,7 +10,7 @@ * a views template, which is why it's not used here, but is a template * 'suggestion' given to the comment template, and is used exactly * the same as any other variant of the comment template file, such as - * node-nodeTYPE.tpl.php + * node-nodeTYPE.tpl.php. * * @ingroup views_templates */ diff --git a/sites/all/modules/views/theme/views-view-summary-unformatted.tpl.php b/sites/all/modules/views/theme/views-view-summary-unformatted.tpl.php index 306d76f..e200893 100644 --- a/sites/all/modules/views/theme/views-view-summary-unformatted.tpl.php +++ b/sites/all/modules/views/theme/views-view-summary-unformatted.tpl.php @@ -11,7 +11,7 @@ ?> $row): ?> '; ?> - separator)) { print $row->separator; } ?> + separator)):?>separator; ?> >link; ?> (count; ?>) diff --git a/sites/all/modules/views/theme/views-view-summary.tpl.php b/sites/all/modules/views/theme/views-view-summary.tpl.php index 22969eb..2b61f2d 100644 --- a/sites/all/modules/views/theme/views-view-summary.tpl.php +++ b/sites/all/modules/views/theme/views-view-summary.tpl.php @@ -10,7 +10,7 @@
        $row): ?> -
      • >link; ?> +
      • >link; ?> (count?>) diff --git a/sites/all/modules/views/theme/views-view-table.tpl.php b/sites/all/modules/views/theme/views-view-table.tpl.php index b3443fc..370ecd7 100644 --- a/sites/all/modules/views/theme/views-view-table.tpl.php +++ b/sites/all/modules/views/theme/views-view-table.tpl.php @@ -16,18 +16,19 @@ * $rows are keyed by row number, fields within rows are keyed by field ID. * - $field_classes: An array of classes to apply to each field, indexed by * field id, then row number. This matches the index in $rows. + * * @ingroup views_templates */ ?> -> - +
        class=""> + $label): ?> - @@ -36,9 +37,9 @@ $row): ?> - > + class=""> $content): ?> - diff --git a/sites/all/modules/views/theme/views-view-unformatted.tpl.php b/sites/all/modules/views/theme/views-view-unformatted.tpl.php index f1cccb8..fc8cfc4 100644 --- a/sites/all/modules/views/theme/views-view-unformatted.tpl.php +++ b/sites/all/modules/views/theme/views-view-unformatted.tpl.php @@ -11,7 +11,7 @@

        $row): ?> - > + class=""> diff --git a/sites/all/modules/views/theme/views-view.tpl.php b/sites/all/modules/views/theme/views-view.tpl.php index 579cf12..96edaab 100644 --- a/sites/all/modules/views/theme/views-view.tpl.php +++ b/sites/all/modules/views/theme/views-view.tpl.php @@ -22,7 +22,7 @@ * - $pager: The pager next/prev links to display, if any * - $exposed: Exposed widget form/info to display * - $feed_icon: Feed icon to display, if any - * - $more: A link to view more, if any + * - $more: A link to view more, if any. * * @ingroup views_templates */ diff --git a/sites/all/modules/views/views.api.php b/sites/all/modules/views/views.api.php index edbb03f..dcf8019 100644 --- a/sites/all/modules/views/views.api.php +++ b/sites/all/modules/views/views.api.php @@ -244,9 +244,11 @@ * 'title' => t('Node'), * 'help' => t('Display the node with standard node view.'), * 'handler' => 'views_plugin_row_node_view', - * 'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules + * // Not necessary for most modules. + * 'path' => drupal_get_path('module', 'views') . '/modules/node', * 'theme' => 'views_view_row_node', - * 'base' => array('node'), // only works with 'node' as base. + * // Only works with 'node' as base. + * 'base' => array('node'), * 'uses options' => TRUE, * 'type' => 'normal', * ), @@ -292,12 +294,12 @@ /** * Describes data tables (or the equivalent) to Views. * - * This hook should be placed in MODULENAME.views.inc and it will be - * auto-loaded. MODULENAME.views.inc must be in the directory specified by the - * 'path' key returned by MODULENAME_views_api(), or the same directory as the - * .module file, if 'path' is unspecified. + * This hook should be placed in MODULENAME.views.inc and it will be auto + * loaded. MODULENAME.views.inc must be in the directory specified by the 'path' + * key returned by MODULENAME_views_api(), or the same directory as the .module + * file, if 'path' is unspecified. * - * @return + * @return array * An associative array describing the data structure. Primary key is the * name used internally by Views for the table(s) – usually the actual table * name. The values for the key entries are described in detail below. @@ -307,17 +309,15 @@ function hook_views_data() { // table: // // CREATE TABLE example_table ( - // nid INT(11) NOT NULL COMMENT 'Primary key; refers to {node}.nid.', + // nid INT(11) NOT NULL COMMENT 'Primary key; refers to {node}.nid.', // plain_text_field VARCHAR(32) COMMENT 'Just a plain text field.', - // numeric_field INT(11) COMMENT 'Just a numeric field.', - // boolean_field INT(1) COMMENT 'Just an on/off field.', - // timestamp_field INT(8) COMMENT 'Just a timestamp field.', + // numeric_field INT(11) COMMENT 'Just a numeric field.', + // boolean_field INT(1) COMMENT 'Just an on/off field.', + // timestamp_field INT(8) COMMENT 'Just a timestamp field.', // PRIMARY KEY(nid) // ); - // First, the entry $data['example_table']['table'] describes properties of // the actual table – not its content. - // The 'group' index will be used as a prefix in the UI for any of this // table's fields, sort criteria, etc. so it's easy to tell where they came // from. @@ -328,7 +328,8 @@ function hook_views_data() { // is not very useful for this table, as it isn't really a distinct object of // its own, but it makes a good example. $data['example_table']['table']['base'] = array( - 'field' => 'nid', // This is the identifier field for the view. + // This is the identifier field for the view. + 'field' => 'nid', 'title' => t('Example table'), 'help' => t('Example table contains example content and can be related to nodes.'), 'weight' => -10, @@ -339,10 +340,10 @@ function hook_views_data() { // table, the fields are automatically available. $data['example_table']['table']['join'] = array( // Index this array by the table name to which this table refers. - // 'left_field' is the primary key in the referenced table. - // 'field' is the foreign key in this table. 'node' => array( + // The primary key in the referenced table. 'left_field' => 'nid', + // The foreign key in this table. 'field' => 'nid', ), ); @@ -362,7 +363,6 @@ function hook_views_data() { // footer or as no result behaviour. // // The handler descriptions are described with examples below. - // Node ID table field. $data['example_table']['nid'] = array( 'title' => t('Example content'), @@ -372,8 +372,10 @@ function hook_views_data() { // other direction, use hook_views_data_alter(), or use the 'implicit' join // method described above. 'relationship' => array( - 'base' => 'node', // The name of the table to join with. - 'base field' => 'nid', // The name of the field on the joined table. + // The name of the table to join with. + 'base' => 'node', + // The name of the field on the joined table. + 'base field' => 'nid', // 'field' => 'nid' -- see hook_views_data_alter(); not needed here. 'handler' => 'views_handler_relationship', 'label' => t('Default label for the relationship'), @@ -388,7 +390,8 @@ function hook_views_data() { 'help' => t('Just a plain text field.'), 'field' => array( 'handler' => 'views_handler_field', - 'click sortable' => TRUE, // This is use by the table display plugin. + // This is use by the table display plugin. + 'click sortable' => TRUE, ), 'sort' => array( 'handler' => 'views_handler_sort', @@ -408,7 +411,7 @@ function hook_views_data() { 'field' => array( 'handler' => 'views_handler_field_numeric', 'click sortable' => TRUE, - ), + ), 'filter' => array( 'handler' => 'views_handler_filter_numeric', ), @@ -427,7 +430,7 @@ function hook_views_data() { ), 'filter' => array( 'handler' => 'views_handler_filter_boolean_operator', - // Note that you can override the field-wide label: + // Note that you can override the field-wide label. 'label' => t('Published'), // This setting is used by the boolean filter handler, as possible option. 'type' => 'yes-no', @@ -468,7 +471,7 @@ function hook_views_data() { * 'path' key returned by MODULENAME_views_api(), or the same directory as the * .module file, if 'path' is unspecified. * - * @param $data + * @param array $data * An array of all Views data, passed by reference. See hook_views_data() for * structure. * @@ -500,9 +503,12 @@ function hook_views_data_alter(&$data) { 'title' => t('Example relationship'), 'help' => t('Example help'), 'relationship' => array( - 'base' => 'example_table', // Table we're joining to. - 'base field' => 'eid', // Field on the joined table. - 'field' => 'fid', // Real field name on the 'foo' table. + // Table we're joining to. + 'base' => 'example_table', + // Field on the joined table. + 'base field' => 'eid', + // Real field name on the 'foo' table. + 'field' => 'fid', 'handler' => 'views_handler_relationship', 'label' => t('Default label for relationship'), 'title' => t('Title seen when adding relationship'), @@ -516,26 +522,26 @@ function hook_views_data_alter(&$data) { /** * Override the default data for a Field API field. * - * Field module's implementation of hook_views_data() invokes this for each + * Field module's Implements hook_views_data() invokes this for each * field in the module that defines the field type (as declared in the field * array). It is not invoked in other modules. * * If no hook implementation exists, hook_views_data() falls back to * field_views_field_default_views_data(). * + * @param array $field + * A field definition array, as returned by field_info_fields(). + * + * @return array + * An array of views data, in the same format as the return value of + * hook_views_data(). + * * @see field_views_data() * @see hook_field_views_data_alter() * @see hook_field_views_data_views_data_alter() - * - * @param $field - * A field definition array, as returned by field_info_fields(). - * - * @return - * An array of views data, in the same format as the return value of - * hook_views_data(). */ function hook_field_views_data($field) { - + return array(); } /** @@ -545,13 +551,13 @@ function hook_field_views_data($field) { * the field, and therefore may be used to alter the default data that * field_views_field_default_views_data() supplies for the field. * - * @param $result - * An array of views table data provided for a single field. This has the same - * format as the return value of hook_views_data(). - * @param $field - * A field definition array, as returned by field_info_fields(). - * @param $module - * The module that defines the field type. + * @param array $result + * An array of views table data provided for a single field. This has the same + * format as the return value of hook_views_data(). + * @param array $field + * A field definition array, as returned by field_info_fields(). + * @param string $module + * The module that defines the field type. * * @see field_views_data() * @see hook_field_views_data() @@ -564,7 +570,7 @@ function hook_field_views_data_alter(&$result, $field, $module) { /** * Alter the views data on a per field basis. * - * Field module's implementation of hook_views_data_alter() invokes this for + * Field module's Implements hook_views_data_alter() invokes this for * each field in the module that defines the field type (as declared in the * field array). It is not invoked in other modules. * @@ -597,7 +603,7 @@ function hook_field_views_data_views_data_alter(&$data, $field) { * .module file, if 'path' is unspecified. All plugin files need to be * referenced in MODULENAME.info with the files[] directive. * - * @return + * @return array * An array on the form $plugins['PLUGIN TYPE']['PLUGIN NAME']. The plugin * must be one of row, display, display_extender, style, argument default, * argument validator, access, query, cache, pager, exposed_form or @@ -619,7 +625,8 @@ function hook_field_views_data_views_data_alter(&$data, $field) { * selectable in the ui, though on the api side they still exists. * - uses options: Set to TRUE to denote that the plugin has an additional * options form. - * - help: A short help text, wrapped in t() used as description on the plugin settings form. + * - help: A short help text, wrapped in t() used as description on the + * plugin settings form. * - help topic: The name of an entry by advanced help for the plugin. * - theme: The name of a theme suggestion to use for the display. * - js: An array with paths to js files that should be included for the @@ -646,8 +653,8 @@ function hook_field_views_data_views_data_alter(&$data, $field) { * should be added. Can for example be 'page' or 'block'. If you don't * specify it there will be contextual links around the rendered view. If * this is not set or regions have been specified, views will display an - * option to 'hide contextual links'. Use an empty array if you do not want - * this. + * option to 'hide contextual links'. Use an empty array if you do not + * want this. * - uses hook menu: Set to TRUE to have the display included by * views_menu_alter(). views_menu_alter executes then execute_hook_menu * on the display object. @@ -664,8 +671,8 @@ function hook_field_views_data_views_data_alter(&$data, $field) { * - uses fields: Set to TRUE to have the style plugin accept field * handlers. * - uses grouping: Set to TRUE to allow the grouping settings for rows. - * - even empty: May have the value 'even empty' to tell Views that the style - * should be rendered even if there are no results. + * - even empty: May have the value 'even empty' to tell Views that the + * style should be rendered even if there are no results. * * - Used by row plugins: * - uses fields: Set to TRUE to have the row plugin accept field handlers. @@ -682,12 +689,14 @@ function hook_views_plugins() { ); return array( - 'module' => 'views', // This just tells our themes are elsewhere. + // This just tells our themes are elsewhere. + 'module' => 'views', 'argument validator' => array( 'taxonomy_term' => array( 'title' => t('Taxonomy term'), 'handler' => 'views_plugin_argument_validate_taxonomy_term', - 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy', // not necessary for most modules + // Declaring path explicitly not necessary for most modules. + 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy', ), ), 'argument default' => array( @@ -711,18 +720,74 @@ function hook_views_plugins_alter(&$plugins) { $plugins['row']['node']['base'][] = 'apachesolr'; } +/** + * Alter existing plugin option definitions. + * + * This can be used to edit default or add new option definitions to existing + * plugins. The reason for doing this is that only overriding the relevent form + * with hook_form_alter() is insufficent because submitted form values will be + * ignored if they haven't been declared as an available option. + * + * An alternative approach you could also take is to extend each plugin + * individually. However if your goal is to override many, or even all plugins, + * this results in a lot of additional code and files. This makes it a lot more + * troublesome to maintain the codebase, as well as interoperability with other + * modules. + * + * @param array $options + * The option definitions to be altered. + * @param $plugin + * A views object of the plugin where the default options are defined. + * + * @see views_object::option_definition() + * @see hook_views_handler_option_definition_alter() + * @see hook_form_alter() + */ +function hook_views_plugin_option_definition_alter(&$options, $plugin) { + // Add a new option definition. + $options['option_name'] = array('default' => ''); +} + +/** + * Alter existing handler option definitions. + * + * This can be used to edit default or add new option definitions to existing + * handlers. The reason for doing this is that only overriding the relevent form + * with hook_form_alter() is insufficent because submitted form values will be + * ignored if they haven't been declared as an available option. + * + * An alternative approach you could also take is to extend each handler + * individually. However if your goal is to override many, or even all handlers, + * this results in a lot of additional code and files. This makes it a lot more + * troublesome to maintain the codebase, as well as interoperability with other + * modules. + * + * @param array $options + * The option definitions to be altered. + * @param $handler + * A views object of the handler where the default options are defined. + * + * @see views_handler::option_definition() + * @see hook_views_plugin_option_definition_alter() + * @see hook_form_alter() + */ +function hook_views_handler_option_definition_alter(&$options, $handler) { + // Add a new option definition. + $options['option_name'] = array('default' => ''); +} + /** * Register View API information. * * This is required for your module to have its include files loaded; for * example, when implementing hook_views_default_views(). * - * @return + * @return array * An array with the following possible keys: * - api: (required) The version of the Views API the module implements. * - path: (optional) If includes are stored somewhere other than within the * root module directory, specify its path here. - * - template path: (optional) A path where the module has stored it's views + * - template path: (optional) A path where the module has stored its views * template files. When you have specified this key views automatically * uses the template files for the views. You can use the same naming * conventions like for normal views template files. @@ -736,8 +801,9 @@ function hook_views_api() { } /** - * This hook allows modules to provide their own views which can either be used - * as-is or as a "starter" for users to build from. + * Allows modules to provide their own views. + * + * These can either be used as-is or as a "starter" for users to build from. * * This hook should be placed in MODULENAME.views_default.inc and it will be * auto-loaded. MODULENAME.views_default.inc must be in the directory specified @@ -747,7 +813,7 @@ function hook_views_api() { * The $view->disabled boolean flag indicates whether the View should be * enabled (FALSE) or disabled (TRUE) by default. * - * @return + * @return array * An associative array containing the structures of views, as generated from * the Export tab, keyed by the view name. A best practice is to go through * and add t() to all title and label strings, with the exception of menu @@ -755,7 +821,7 @@ function hook_views_api() { */ function hook_views_default_views() { // Begin copy and paste of output from the Export tab of a view. - $view = new view; + $view = new view(); $view->name = 'frontpage'; $view->description = 'Emulates the default Drupal front page; you may set the default home page path to this view to make it your front page.'; $view->tag = 'default'; @@ -819,13 +885,11 @@ function hook_views_default_views() { $handler->display->display_options['sitename_title'] = '1'; // (Export ends here.) - // Add view to list of views to provide. $views[$view->name] = $view; - // ...Repeat all of the above for each view the module should provide. - - // At the end, return array of default views. + // Repeat all of the above for each view the module should provide. At the + // end, return array of default views. return $views; } @@ -855,9 +919,10 @@ function hook_views_default_views_alter(&$views) { /** * Performs replacements in the query before being performed. * - * @param $view + * @param object $view * The View being executed. - * @return + * + * @return array * An array with keys being the strings to replace, and the values the strings * to replace them with. The strings to replace are often surrounded with * '***', as illustrated in the example implementation. @@ -874,10 +939,11 @@ function hook_views_query_substitutions($view) { } /** - * This hook is called to get a list of placeholders and their substitutions, - * used when preprocessing a View with form elements. + * This hook is called to get a list of placeholders and their substitutions. * - * @return + * Used when preprocessing a View with form elements. + * + * @return array * An array with keys being the strings to replace, and the values the strings * to replace them with. */ @@ -888,16 +954,31 @@ function hook_views_form_substitutions() { } /** - * Allows altering a view at the very beginning of views processing, before - * anything is done. + * Allows altering a view at the very beginning of processing a preview. + * + * Occurs before anything is done. + * + * This hook is only triggered when the one of the following are invoked: + * - $view->execute_display() + * - $view->preview() + * + * As such code placed in this hook will not fire during: + * - $view->build() + * - $view->execute() + * - $view->render() + * + * Likely, hook_views_pre_build() or hook_views_pre_execute() are much better + * choices for most use cases since they are always invoked, not just when + * previewing a display. * * Adding output to the view can be accomplished by placing text on * $view->attachment_before and $view->attachment_after. - * @param $view + * + * @param object $view * The view object about to be processed. - * @param $display_id + * @param string $display_id * The machine name of the active display. - * @param $args + * @param array $args * An array of arguments passed into the view. */ function hook_views_pre_view(&$view, &$display_id, &$args) { @@ -906,21 +987,21 @@ function hook_views_pre_view(&$view, &$display_id, &$args) { // (Note that this is not necessarily the best way to solve that task. Feel // free to contribute another example!) if ( - $view->name == 'my_special_view' && - user_access('administer site configuration') && - $display_id == 'public_display' + $view->name == 'my_special_view' + && user_access('administer site configuration') + && $display_id == 'public_display' ) { $view->set_display('private_display'); } } /** - * This hook is called right before the build process, but after displays - * are attached and the display performs its pre_execute phase. + * Called after the display's pre_execute phase but before the build process. * * Adding output to the view can be accomplished by placing text on * $view->attachment_before and $view->attachment_after. - * @param $view + * + * @param object $view * The view object about to be processed. */ function hook_views_pre_build(&$view) { @@ -934,12 +1015,15 @@ function hook_views_pre_build(&$view) { } /** - * This hook is called right after the build process. The query is now fully - * built, but it has not yet been run through db_rewrite_sql. + * This hook is called right after the build process. + * + * The query is now fully built, but it has not yet been run through + * db_rewrite_sql. * * Adding output to the view can be accomplished by placing text on * $view->attachment_before and $view->attachment_after. - * @param $view + * + * @param object $view * The view object about to be processed. */ function hook_views_post_build(&$view) { @@ -957,12 +1041,15 @@ function hook_views_post_build(&$view) { } /** - * This hook is called right before the execute process. The query is now fully - * built, but it has not yet been run through db_rewrite_sql. + * This hook is called right before the execute process. + * + * The query is now fully built, but it has not yet been run through + * db_rewrite_sql. * * Adding output to the view can be accomplished by placing text on * $view->attachment_before and $view->attachment_after. - * @param $view + * + * @param object $view * The view object about to be processed. */ function hook_views_pre_execute(&$view) { @@ -976,14 +1063,16 @@ function hook_views_pre_execute(&$view) { } /** - * This hook is called right after the execute process. The query has - * been executed, but the pre_render() phase has not yet happened for - * handlers. + * This hook is called right after the execute process. + * + * The query has been executed, but the pre_render() phase has not yet happened + * for handlers. * * Adding output to the view can be accomplished by placing text on - * $view->attachment_before and $view->attachment_after. Altering the - * content can be achieved by editing the items of $view->result. - * @param $view + * $view->attachment_before and $view->attachment_after. Altering the content + * can be achieved by editing the items of $view->result. + * + * @param object $view * The view object about to be processed. */ function hook_views_post_execute(&$view) { @@ -997,16 +1086,18 @@ function hook_views_post_execute(&$view) { } /** - * This hook is called right before the render process. The query has been - * executed, and the pre_render() phase has already happened for handlers, so - * all data should be available. + * This hook is called right before the render process. + * + * The query has been executed, and the pre_render() phase has already happened + * for handlers, so all data should be available. * * Adding output to the view can be accomplished by placing text on * $view->attachment_before and $view->attachment_after. Altering the content * can be achieved by editing the items of $view->result. * * This hook can be utilized by themes. - * @param $view + * + * @param object $view * The view object about to be processed. */ function hook_views_pre_render(&$view) { @@ -1037,11 +1128,12 @@ function hook_views_pre_render(&$view) { * so all ids used in the query should be discoverable. * * This hook can be utilized by themes. - * @param $view + * + * @param object $view * The view object about to be processed. - * @param $output + * @param string $output * A flat string with the rendered output of the view. - * @param $cache + * @param array $cache * The cache settings. */ function hook_views_post_render(&$view, &$output, &$cache) { @@ -1061,10 +1153,11 @@ function hook_views_post_render(&$view, &$output, &$cache) { * 'path' key returned by MODULENAME_views_api(), or the same directory as the * .module file, if 'path' is unspecified. * - * @param $view + * @param object $view * The view object about to be processed. - * @param $query + * @param object $query * An object describing the query. + * * @see hook_views_query_substitutions() */ function hook_views_query_alter(&$view, &$query) { @@ -1090,8 +1183,9 @@ function hook_views_query_alter(&$view, &$query) { } /** - * Alter the information box that (optionally) appears with a view preview, - * including query and performance statistics. + * Alter the information box that (optionally) appears with a view preview. + * + * Includes query and performance statistics. * * This hook should be placed in MODULENAME.views.inc and it will be * auto-loaded. MODULENAME.views.inc must be in the directory specified by the @@ -1101,14 +1195,15 @@ function hook_views_query_alter(&$view, &$query) { * Warning: $view is not a reference in PHP4 and cannot be modified here. But it * IS a reference in PHP5, and can be modified. Please be careful with it. * - * @param $rows + * @param array $rows * An associative array with two keys: * - query: An array of rows suitable for theme('table'), containing * information about the query and the display title and path. * - statistics: An array of rows suitable for theme('table'), containing * performance statistics. - * @param $view + * @param object $view * The view object. + * * @see theme_table() */ function hook_views_preview_info_alter(&$rows, $view) { @@ -1121,15 +1216,16 @@ function hook_views_preview_info_alter(&$rows, $view) { } /** - * This hooks allows to alter the links at the top of the view edit form. Some - * modules might want to add links there. + * This hooks allows to alter the links at the top of the view edit form. * - * @param $links + * Some modules might want to add links there. + * + * @param array $links * An array of links which will be displayed at the top of the view edit form. * Each entry should be on a form suitable for theme('link'). - * @param view $view + * @param object $view * The full view object which is currently edited. - * @param $display_id + * @param string $display_id * The current display id which is edited. For example that's 'default' or * 'page_1'. */ @@ -1141,12 +1237,11 @@ function hook_views_ui_display_top_links_alter(&$links, $view, $display_id) { } /** - * This hook allows to alter the commands which are used on a views ajax - * request. + * Allows altering the commands which are used on a views AJAX request. * - * @param $commands - * An array of ajax commands - * @param $view view + * @param array $commands + * An array of ajax commands. + * @param object $view * The view which is requested. */ function hook_views_ajax_data_alter(&$commands, $view) { @@ -1165,9 +1260,12 @@ function hook_views_ajax_data_alter(&$commands, $view) { * This hook should fire whenever a view is enabled, disabled, created, * updated, or deleted. * + * @param string $cid + * The cache identifier that is being cleared. + * * @see views_invalidate_cache() */ -function hook_views_invalidate_cache() { +function hook_views_invalidate_cache($cid) { cache_clear_all('views:*', 'cache_mymodule', TRUE); } diff --git a/sites/all/modules/views/views.info b/sites/all/modules/views/views.info index 021c64e..a857b23 100644 --- a/sites/all/modules/views/views.info +++ b/sites/all/modules/views/views.info @@ -285,6 +285,7 @@ files[] = tests/handlers/views_handler_filter_equality.test files[] = tests/handlers/views_handler_filter_in_operator.test files[] = tests/handlers/views_handler_filter_numeric.test files[] = tests/handlers/views_handler_filter_string.test +files[] = tests/handlers/views_handler_manytoone.test files[] = tests/handlers/views_handler_sort_random.test files[] = tests/handlers/views_handler_sort_date.test files[] = tests/handlers/views_handler_sort.test @@ -308,6 +309,7 @@ files[] = tests/views_exposed_form.test files[] = tests/field/views_fieldapi.test files[] = tests/views_glossary.test files[] = tests/views_groupby.test +files[] = tests/views_handler_filter.test files[] = tests/views_handlers.test files[] = tests/views_module.test files[] = tests/views_pager.test @@ -325,12 +327,12 @@ files[] = tests/user/views_user_argument_default.test files[] = tests/user/views_user_argument_validate.test files[] = tests/user/views_user.test files[] = tests/views_cache.test +files[] = tests/views_clone.test files[] = tests/views_view.test files[] = tests/views_ui.test -; Information added by Drupal.org packaging script on 2017-08-23 -version = "7.x-3.18" +; Information added by Drupal.org packaging script on 2019-05-10 +version = "7.x-3.23" core = "7.x" project = "views" -datestamp = "1503495103" - +datestamp = "1557505389" diff --git a/sites/all/modules/views/views.install b/sites/all/modules/views/views.install index 35c570c..92c7abc 100644 --- a/sites/all/modules/views/views.install +++ b/sites/all/modules/views/views.install @@ -19,20 +19,18 @@ function views_install() { /** * Implements hook_schema(). - * - * Generate the current version of the database schema from - * the sequence of schema update functions. Uses a similar - * method to install.inc's drupal_get_schema_versions() to - * establish the update sequence. - * - * To change the schema, add a new views_schema_N() - * function to match the associated views_update_N() - * - * @param $caller_function - * The name of the function that called us. - * Used internally, if requesting a specific schema version. */ -function views_schema($caller_function = FALSE) { +function views_schema($caller_function = NULL) { + // Generate the current version of the database schema from the sequence of + // schema update functions. Uses a similar method to install.inc's + // drupal_get_schema_versions() to establish the update sequence. + // + // To change the schema, add a new views_schema_N() function to match the + // associated views_update_N(). + // + // @param string $caller_function + // The name of the function that called us. Used internally, if requesting a + // specific schema version. static $get_current; static $schemas = array(); @@ -55,19 +53,19 @@ function views_schema($caller_function = FALSE) { if ($schemas) { sort($schemas, SORT_NUMERIC); - // If a specific version was requested, drop any later - // updates from the sequence. + // If a specific version was requested, drop any later updates from the + // sequence. if ($caller_function) { do { $schema = array_pop($schemas); - } while ($schemas && $caller_function != 'views_schema_'. $schema); + } while ($schemas && $caller_function != 'views_schema_' . $schema); } } } // Call views_schema_, for the highest available . if ($schema = array_pop($schemas)) { - $function = 'views_schema_'. $schema; + $function = 'views_schema_' . $schema; return $function(); } @@ -76,12 +74,14 @@ function views_schema($caller_function = FALSE) { /** * Views 2's initial schema. + * * Called directly by views_update_6000() for updates from Drupal 5. * * Important: Do not edit this schema! * - * Updates to the views schema must be provided as views_schema_6xxx() functions, - * which views_schema() automatically sees and applies. See below for examples. + * Updates to the views schema must be provided as views_schema_6xxx() + * functions, which views_schema() automatically sees and applies. See below for + * examples. * * Please do document updates with comments in this function, however. */ @@ -102,11 +102,11 @@ function views_schema_6000() { 'current_version' => '3.0', ), 'object' => 'view', - // the callback to load the displays + // the callback to load the displays. 'subrecords callback' => 'views_load_display_records', - // the variable that holds enabled/disabled status + // the variable that holds enabled/disabled status. 'status' => 'views_defaults', - // CRUD callbacks + // CRUD callbacks. 'create callback' => 'views_new_view', 'save callback' => 'views_save_view', 'delete callback' => 'views_delete_view', @@ -148,7 +148,8 @@ function views_schema_6000() { ), 'base_table' => array( 'type' => 'varchar', - 'length' => '32', // Updated to '64' in views_schema_6005() + 'length' => '32', + // Updated to '64' in views_schema_6005() 'default' => '', 'not null' => TRUE, 'description' => 'What table this view is based on, such as node, user, comment, or term.', @@ -161,7 +162,8 @@ function views_schema_6000() { ), ), 'primary key' => array('vid'), - 'unique key' => array('name' => array('name')), // Updated to 'unique keys' in views_schema_6003() + 'unique key' => array('name' => array('name')), + // Updated to 'unique keys' in views_schema_6003() ); $schema['views_display'] = array( @@ -241,7 +243,8 @@ function views_schema_6000() { 'description' => 'The time this cache was created or updated.', ), 'data' => array( - 'type' => 'blob', // Updated to 'text' (with size => 'big') in views_schema_6004() + 'type' => 'blob', + // Updated to 'text' (with size => 'big') in views_schema_6004() 'description' => 'Serialized data being stored.', 'serialize' => TRUE, ), @@ -294,7 +297,7 @@ function views_update_6001() { update_sql("UPDATE {blocks} SET delta = CONCAT(delta, '-block_1') WHERE module = 'views'"); } -/* +/** * NOTE: Update 6002 removed because it did not always work. * Update 6004 implements the change correctly. */ @@ -337,7 +340,7 @@ function views_update_6004() { } /** - * Enlarge the base_table column + * Enlarge the base_table column. */ function views_schema_6005() { $schema = views_schema(__FUNCTION__); @@ -444,7 +447,7 @@ function views_update_6009() { } /** - * Remove the view_php field + * Remove the view_php field. */ function views_schema_6010() { $schema = views_schema(__FUNCTION__); @@ -454,7 +457,7 @@ function views_schema_6010() { } /** - * Remove the view_php and is_cacheable field + * Remove the view_php and is_cacheable field. */ function views_update_6010() { db_drop_field('views_view', 'view_php'); @@ -578,7 +581,7 @@ function views_update_7000() { } /** - * Fix missing items from Views administrative breadcrumb + * Fix missing items from Views administrative breadcrumb. */ function views_update_7001() { $depth = db_select('menu_links') @@ -619,7 +622,7 @@ function views_schema_7301() { } /** - * Enlarge the name column + * Enlarge the name column. */ function views_update_7301() { $new_field = array( @@ -633,9 +636,9 @@ function views_update_7301() { } /** - * Remove headers field from cache tables + * Remove headers field from cache tables. * - * @see system_update_7054(). + * @see system_update_7054() */ function views_update_7302() { if (db_field_exists('cache_views', 'headers')) { diff --git a/sites/all/modules/views/views.module b/sites/all/modules/views/views.module index 2093aa7..aa407f0 100644 --- a/sites/all/modules/views/views.module +++ b/sites/all/modules/views/views.module @@ -36,7 +36,7 @@ function views_help($path, $arg) { } /** - * Advertise the current views api version + * Advertise the current views api version. */ function views_api_version() { return '3.0'; @@ -81,7 +81,9 @@ function views_api_minimum_version() { } /** - * Implement hook_theme(). Register views theming functions. + * Implements hook_theme(). + * + * Register views theming functions. */ function views_theme($existing, $type, $theme, $path) { $path = drupal_get_path('module', 'views'); @@ -93,9 +95,13 @@ function views_theme($existing, $type, $theme, $path) { 'path' => $path . '/theme', ); - // Our extra version of pager from pager.inc + // Our extra version of pager from pager.inc. $hooks['views_mini_pager'] = $base + array( - 'variables' => array('tags' => array(), 'element' => 0, 'parameters' => array()), + 'variables' => array( + 'tags' => array(), + 'element' => 0, + 'parameters' => array(), + ), 'pattern' => 'views_mini_pager__', ); @@ -104,28 +110,48 @@ function views_theme($existing, $type, $theme, $path) { // $view is an object but the core contextual_preprocess() function only // attaches contextual links when the primary theme argument is an array. 'display' => array('view_array' => array(), 'view' => NULL), - 'style' => array('view' => NULL, 'options' => NULL, 'rows' => NULL, 'title' => NULL), - 'row' => array('view' => NULL, 'options' => NULL, 'row' => NULL, 'field_alias' => NULL), + 'style' => array( + 'view' => NULL, + 'options' => NULL, + 'rows' => NULL, + 'title' => NULL, + ), + 'row' => array( + 'view' => NULL, + 'options' => NULL, + 'row' => NULL, + 'field_alias' => NULL, + ), 'exposed_form' => array('view' => NULL, 'options' => NULL), 'pager' => array( - 'view' => NULL, 'options' => NULL, - 'tags' => array(), 'quantity' => 10, 'element' => 0, 'parameters' => array() + 'view' => NULL, + 'options' => NULL, + 'tags' => array(), + 'quantity' => 10, + 'element' => 0, + 'parameters' => array(), ), ); - // Default view themes + // Default view themes. $hooks['views_view_field'] = $base + array( 'pattern' => 'views_view_field__', 'variables' => array('view' => NULL, 'field' => NULL, 'row' => NULL), ); $hooks['views_view_grouping'] = $base + array( 'pattern' => 'views_view_grouping__', - 'variables' => array('view' => NULL, 'grouping' => NULL, 'grouping_level' => NULL, 'rows' => NULL, 'title' => NULL), + 'variables' => array( + 'view' => NULL, + 'grouping' => NULL, + 'grouping_level' => NULL, + 'rows' => NULL, + 'title' => NULL, + ), ); $plugins = views_fetch_plugin_data(); - // Register theme functions for all style plugins + // Register theme functions for all style plugins. foreach ($plugins as $type => $info) { foreach ($info as $plugin => $def) { if (isset($def['theme']) && (!isset($def['register theme']) || !empty($def['register theme']))) { @@ -180,7 +206,11 @@ function views_theme($existing, $type, $theme, $path) { $hooks['views_more'] = $base + array( 'template' => 'views-more', 'pattern' => 'views_more__', - 'variables' => array('more_url' => NULL, 'link_text' => 'more', 'view' => NULL), + 'variables' => array( + 'more_url' => NULL, + 'link_text' => 'more', + 'view' => NULL, + ), ); // Add theme suggestions which are part of modules. @@ -195,16 +225,16 @@ function views_theme($existing, $type, $theme, $path) { /** * Scans a directory of a module for template files. * - * @param $cache + * @param array $cache * The existing cache of theme hooks to test against. - * @param $path + * @param string $path * The path to search. * * @see drupal_find_theme_templates() */ function _views_find_module_templates($cache, $path) { $templates = array(); - $regex = '/' . '\.tpl\.php' . '$' . '/'; + $regex = '/\.tpl\.php$/'; // Because drupal_system_listing works the way it does, we check for real // templates separately from checking for patterns. @@ -242,11 +272,12 @@ function _views_find_module_templates($cache, $path) { // for the purposes of searching. $pattern = strtr($info['pattern'], '_', '-'); - $matches = preg_grep('/^'. $pattern .'/', $patterns); + $matches = preg_grep('/^' . $pattern . '/', $patterns); if ($matches) { foreach ($matches as $match) { $file = substr($match, 0, strpos($match, '.')); - // Put the underscores back in for the hook name and register this pattern. + // Put the underscores back in for the hook name and register this + // pattern. $templates[strtr($file, '-', '_')] = array( 'template' => $file, 'path' => dirname($files[$match]->uri), @@ -315,6 +346,8 @@ function views_plugin_list() { } /** + * Preprocess a node. + * * A theme preprocess function to automatically allow view-based node * templates if called from a view. * @@ -330,8 +363,8 @@ function views_preprocess_node(&$vars) { if (!empty($vars['node']->view->current_display)) { $vars['theme_hook_suggestions'][] = 'node__view__' . $vars['node']->view->name . '__' . $vars['node']->view->current_display; - // If a node is being rendered in a view, and the view does not have a path, - // prevent drupal from accidentally setting the $page variable: + // If a node is being rendered in a view, and the view does not have a + // path, prevent drupal from accidentally setting the $page variable. if ($vars['page'] && $vars['view_mode'] == 'full' && !$vars['view']->display_handler->has_path()) { $vars['page'] = FALSE; } @@ -345,11 +378,14 @@ function views_preprocess_node(&$vars) { } /** + * Preprocess a comment. + * * A theme preprocess function to automatically allow view-based node * templates if called from a view. */ function views_preprocess_comment(&$vars) { - // The 'view' attribute of the node is added in template_preprocess_views_view_row_comment() + // The 'view' attribute of the node is added in + // template_preprocess_views_view_row_comment(). if (!empty($vars['node']->view) && !empty($vars['node']->view->name)) { $vars['view'] = &$vars['node']->view; $vars['theme_hook_suggestions'][] = 'comment__view__' . $vars['node']->view->name; @@ -360,7 +396,7 @@ function views_preprocess_comment(&$vars) { } /** - * Implement hook_permission(). + * Implements hook_permission(). */ function views_permission() { return array( @@ -378,7 +414,7 @@ function views_permission() { } /** - * Implement hook_menu(). + * Implements hook_menu(). */ function views_menu() { $items = array(); @@ -392,8 +428,8 @@ function views_menu() { 'type' => MENU_CALLBACK, 'file' => 'includes/ajax.inc', ); - // Path is not admin/structure/views due to menu complications with the wildcards from - // the generic ajax callback. + // Path is not admin/structure/views due to menu complications with the + // wildcards from the generic ajax callback. $items['admin/views/ajax/autocomplete/user'] = array( 'page callback' => 'views_ajax_autocomplete_user', 'theme callback' => 'ajax_base_page_theme', @@ -416,7 +452,7 @@ function views_menu() { } /** - * Implement hook_menu_alter(). + * Implements hook_menu_alter(). */ function views_menu_alter(&$callbacks) { $our_paths = array(); @@ -425,18 +461,14 @@ function views_menu_alter(&$callbacks) { list($view, $display_id) = $data; $result = $view->execute_hook_menu($display_id, $callbacks); if (is_array($result)) { - // The menu system doesn't support having two otherwise - // identical paths with different placeholders. So we - // want to remove the existing items from the menu whose - // paths would conflict with ours. - - // First, we must find any existing menu items that may - // conflict. We use a regular expression because we don't - // know what placeholders they might use. Note that we - // first construct the regex itself by replacing %views_arg - // in the display path, then we use this constructed regex - // (which will be something like '#^(foo/%[^/]*/bar)$#') to - // search through the existing paths. + // The menu system doesn't support having two otherwise identical paths + // with different placeholders. So we want to remove the existing items + // from the menu whose paths would conflict with ours. First, we must find + // any existing menu items that may conflict. We use a regular expression + // because we don't know what placeholders they might use. Note that we + // first construct the regex itself by replacing %views_arg in the display + // path, then we use this constructed regex (which will be something like + // '#^(foo/%[^/]*/bar)$#') to search through the existing paths. $regex = '#^(' . preg_replace('#%views_arg#', '%[^/]*', implode('|', array_keys($result))) . ')$#'; $matches = preg_grep($regex, array_keys($callbacks)); @@ -457,10 +489,10 @@ function views_menu_alter(&$callbacks) { // This item already exists, so it must be one that we added. // We change the various callback arguments to pass an array // of possible display IDs instead of a single ID. - $callbacks[$path]['page arguments'][1] = (array)$callbacks[$path]['page arguments'][1]; + $callbacks[$path]['page arguments'][1] = (array) $callbacks[$path]['page arguments'][1]; $callbacks[$path]['page arguments'][1][] = $display_id; $callbacks[$path]['access arguments'][] = $item['access arguments'][0]; - $callbacks[$path]['load arguments'][1] = (array)$callbacks[$path]['load arguments'][1]; + $callbacks[$path]['load arguments'][1] = (array) $callbacks[$path]['load arguments'][1]; $callbacks[$path]['load arguments'][1][] = $display_id; } $our_paths[$path] = TRUE; @@ -476,22 +508,24 @@ function views_menu_alter(&$callbacks) { } /** + * Load a views argument. + * * Helper function for menu loading. This will automatically be * called in order to 'load' a views argument; primarily it * will be used to perform validation. * - * @param $value + * @param string $value * The actual value passed. - * @param $name + * @param string $name * The name of the view. This needs to be specified in the 'load function' * of the menu entry. - * @param $display_id + * @param string $display_id * The display id that will be loaded for this menu item. - * @param $index + * @param int $index * The menu argument index. This counts from 1. */ function views_arg_load($value, $name, $display_id, $index) { - static $views = array(); + static $views = array(); $display_ids = is_array($display_id) ? $display_id : array($display_id); $display_id = reset($display_ids); @@ -547,12 +581,12 @@ function views_arg_load($value, $name, $display_id, $index) { /** * Page callback: Displays a page view, given a name and display id. * - * @param $name + * @param string $name * The name of a view. - * @param $display_id + * @param string $display_id * The display id of a view. * - * @return + * @return string|int * Either the HTML of a fully-executed view, or MENU_NOT_FOUND. */ function views_page($name, $display_id) { @@ -616,8 +650,8 @@ function views_preprocess_html(&$variables) { } /** -* Implements hook_preprocess_HOOK() for page.tpl.php. -*/ + * Implements hook_preprocess_HOOK() for page.tpl.php. + */ function views_preprocess_page(&$variables) { // If the page contains a view as its main content, contextual links may have // been attached to the page as a whole; for example, by views_page_alter(). @@ -649,7 +683,7 @@ function views_contextual_links_view_alter(&$element, $items) { } /** - * Implement hook_block_info(). + * Implements hook_block_info(). */ function views_block_info() { // Try to avoid instantiating all the views just to get the blocks info. @@ -662,7 +696,7 @@ function views_block_info() { $items = array(); $views = views_get_all_views(); foreach ($views as $view) { - // disabled views get nothing. + // Disabled views get nothing. if (!empty($view->disabled)) { continue; } @@ -691,7 +725,7 @@ function views_block_info() { // can also be 32. So for very long deltas, change to md5 hashes. $hashes = array(); - // get the keys because we're modifying the array and we don't want to + // Get the keys because we're modifying the array and we don't want to // confuse PHP too much. $keys = array_keys($items); foreach ($keys as $delta) { @@ -719,11 +753,69 @@ function views_block_info() { } /** - * Implement hook_block_view(). + * Implements hook_block_configure(). + */ +function views_block_configure($delta = '') { + // If there's no Views UI module there's nothing to link to. + if (!module_exists('views_ui')) { + return array(); + } + + // If the user doesn't have access to edit the view then don't bother with + // anything else. + if (!user_access('administer views')) { + return array(); + } + + // If this is 32, this should be an md5 hash. + if (strlen($delta) == 32) { + $hashes = variable_get('views_block_hashes', array()); + if (!empty($hashes[$delta])) { + $delta = $hashes[$delta]; + } + } + + // Some added precaution in case the delta is missing values. + list($view_name, $display_id) = explode('-', $delta, 2) + array('', ''); + + // If the view name or display ID can't be found, there's something wrong. + if ($view_name === '' || $display_id === '') { + return array(); + } + + $view = views_get_view($view_name); + if (empty($view)) { + return array(); + } + + if (!isset($view->display[$display_id])) { + return array(); + } + + /** @var \views_display $display */ + $display = $view->display[$display_id]; + + $view_label = $view->get_human_name(); + $display_label = $display->display_title; + + $path = "admin/structure/views/view/$view_name/edit/$display_id"; + + return array( + 'fieldset' => array( + '#type' => 'fieldset', + '#title' => t('Configure this views display'), + 'content' => array( + '#markup' => l($view_label . ' - ' . $display_label, $path), + ), + ), + ); +} + +/** + * Implements hook_block_view(). */ function views_block_view($delta) { - $start = microtime(TRUE); - // if this is 32, this should be an md5 hash. + // If this is 32, this should be an md5 hash. if (strlen($delta) == 32) { $hashes = variable_get('views_block_hashes', array()); if (!empty($hashes[$delta])) { @@ -758,7 +850,7 @@ function views_block_view($delta) { return; } list($name, $display_id) = $explode; - // Load the view + // Load the view. if ($view = views_get_view($name)) { if ($view->access($display_id)) { $output = $view->execute_display($display_id); @@ -775,18 +867,18 @@ function views_block_view($delta) { /** * Converts Views block content to a renderable array with contextual links. * - * @param $block + * @param array $block * An array representing the block, with the same structure as the return * value of hook_block_view(). This will be modified so as to force * $block['content'] to be a renderable array, containing the optional * '#contextual_links' property (if there are any contextual links associated * with the block). - * @param $view + * @param object $view * The view that was used to generate the block content. - * @param $display_id + * @param string $display_id * The ID of the display within the view that was used to generate the block * content. - * @param $block_type + * @param string $block_type * The type of the block. If it's block it's a regular views display, * but 'special_block_-exp' exist as well. */ @@ -833,12 +925,12 @@ function views_add_block_contextual_links(&$block, $view, $display_id, $block_ty * later on (for example, alter hooks which run later during the same page * request). * - * @param $render_element + * @param array $render_element * The renderable array to which contextual links will be added. This array * should be suitable for passing in to drupal_render() and will normally * contain a representation of the view display whose contextual links are * being requested. - * @param $location + * @param string $location * The location in which the calling function intends to render the view and * its contextual links. The core system supports three options for this * parameter: @@ -858,9 +950,9 @@ function views_add_block_contextual_links(&$block, $view, $display_id, $block_ty * declare, via the 'contextual links locations' array key, which view * displays support having their contextual links rendered in the location * you have defined. - * @param $view + * @param object $view * The view whose contextual links will be added. - * @param $display_id + * @param string $display_id * The ID of the display within $view whose contextual links will be added. * * @see hook_views_plugins() @@ -878,7 +970,7 @@ function views_add_contextual_links(&$render_element, $location, $view, $display $plugin = views_fetch_plugin_data('display', $view->display[$display_id]->display_plugin); // If contextual links locations are not set, provide a sane default. (To // avoid displaying any contextual links at all, a display plugin can still - // set 'contextual links locations' to, e.g., an empty array.) + // set 'contextual links locations' to, e.g., an empty array). $plugin += array('contextual links locations' => array('view')); // On exposed_forms blocks contextual links should always be visible. $plugin['contextual links locations'][] = 'special_block_-exp'; @@ -920,13 +1012,14 @@ function views_add_contextual_links(&$render_element, $location, $view, $display /** * Returns an array of language names. * - * This is a one to one copy of locale_language_list because we can't rely on enabled locale module. + * This is a one to one copy of locale_language_list because we can't rely on + * enabled locale module. * - * @param $field - * 'name' => names in current language, localized - * 'native' => native names - * @param $all - * Boolean to return all languages or only enabled ones + * @param string $field + * Either 'name' for localized names in current language or 'native' for + * native names. + * @param bool $all + * Boolean to return all languages or only enabled ones. * * @see locale_language_list() */ @@ -953,7 +1046,7 @@ function views_flush_caches() { } /** - * Implements hook_field_create_instance. + * Implements hook_field_create_instance(). */ function views_field_create_instance($instance) { cache_clear_all('*', 'cache_views', TRUE); @@ -961,7 +1054,7 @@ function views_field_create_instance($instance) { } /** - * Implements hook_field_update_instance. + * Implements hook_field_update_instance(). */ function views_field_update_instance($instance, $prior_instance) { cache_clear_all('*', 'cache_views', TRUE); @@ -969,7 +1062,7 @@ function views_field_update_instance($instance, $prior_instance) { } /** - * Implements hook_field_delete_instance. + * Implements hook_field_delete_instance(). */ function views_field_delete_instance($instance) { cache_clear_all('*', 'cache_views', TRUE); @@ -978,10 +1071,14 @@ function views_field_delete_instance($instance) { /** * Invalidate the views cache, forcing a rebuild on the next grab of table data. + * + * @param string $cid + * The cache identifier we want to clear. If no given, it will default to '*' + * which will clear the entire cache_views bin. */ -function views_invalidate_cache() { +function views_invalidate_cache($cid = '*') { // Clear the views cache. - cache_clear_all('*', 'cache_views', TRUE); + cache_clear_all($cid, 'cache_views', TRUE); // Clear the page and block cache. cache_clear_all(); @@ -990,7 +1087,7 @@ function views_invalidate_cache() { variable_set('menu_rebuild_needed', TRUE); // Allow modules to respond to the Views cache being cleared. - module_invoke_all('views_invalidate_cache'); + module_invoke_all('views_invalidate_cache', $cid); } /** @@ -1065,7 +1162,7 @@ function views_check_perm($perms, $account = NULL) { /** * Access callback for the views_plugin_access_role access plugin. - + * * Determine if the specified user has access to a view on the basis of any of * the requested roles. If the $account argument is omitted, the current user * is used. @@ -1077,10 +1174,10 @@ function views_check_roles($rids, $account = NULL) { $roles[] = $account->uid ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID; return user_access('access all views', $account) || array_intersect(array_filter($rids), $roles); } -// ------------------------------------------------------------------ -// Functions to help identify views that are running or ran /** + * Set page view. + * * Set the current 'page view' that is being displayed so that it is easy * for other modules or the theme to identify. */ @@ -1094,6 +1191,8 @@ function &views_set_page_view($view = NULL) { } /** + * Get page view. + * * Find out what, if any, page view is currently in use. Please note that * this returns a reference, so be careful! You can unintentionally modify the * $view object. @@ -1106,10 +1205,13 @@ function &views_get_page_view() { } /** + * Set current view. + * * Set the current 'current view' that is being built/rendered so that it is - * easy for other modules or items in drupal_eval to identify + * easy for other modules or items in drupal_eval to identify. * * @return view + * The current view. */ function &views_set_current_view($view = NULL) { static $cache = NULL; @@ -1121,24 +1223,28 @@ function &views_set_current_view($view = NULL) { } /** + * Get current view. + * * Find out what, if any, current view is currently in use. Please note that * this returns a reference, so be careful! You can unintentionally modify the * $view object. * * @return view + * The current view. */ function &views_get_current_view() { return views_set_current_view(); } -// ------------------------------------------------------------------ -// Include file helpers - /** * Include views .inc files as necessary. */ function views_include($file) { - ctools_include($file, 'views'); + static $views_path; + if (!isset($views_path)) { + $views_path = DRUPAL_ROOT . '/' . drupal_get_path('module', 'views'); + } + include_once $views_path . '/includes/' . $file . '.inc'; } /** @@ -1175,7 +1281,7 @@ function views_get_module_apis($api = 'views', $reset = FALSE) { function views_add_css($file) { // We set preprocess to FALSE because we are adding the files conditionally, // and we don't want to generate duplicate cache files. - // TODO: at some point investigate adding some files unconditionally and + // @todo at some point investigate adding some files unconditionally and // allowing preprocess. drupal_add_css(drupal_get_path('module', 'views') . "/css/$file.css", array('preprocess' => FALSE)); } @@ -1184,7 +1290,7 @@ function views_add_css($file) { * Include views .js files. */ function views_add_js($file) { - // If javascript has been disabled by the user, never add js files. + // If JavaScript has been disabled by the user, never add js files. if (variable_get('views_no_javascript', FALSE)) { return; } @@ -1219,22 +1325,18 @@ function views_include_handlers($reset = FALSE) { $finished = TRUE; } -// ----------------------------------------------------------------------- -// Views handler functions - /** * Fetch a handler from the data cache. * - * @param $table + * @param string $table * The name of the table this handler is from. - * @param $field + * @param string $field * The name of the field this handler is from. - * @param $key - * The type of handler. i.e, sort, field, argument, filter, relationship - * @param $override - * Override the actual handler object with this class. Used for - * aggregation when the handler is redirected to the aggregation - * handler. + * @param string $key + * The type of handler. i.e, sort, field, argument, filter, relationship. + * @param mixed $override + * Override the actual handler object with this class. Used for aggregation + * when the handler is redirected to the aggregation handler. * * @return views_handler * An instance of a handler object. May be views_handler_broken. @@ -1246,8 +1348,6 @@ function views_get_handler($table, $field, $key, $override = NULL) { $handler = NULL; views_include('handlers'); - // Support old views_data entries conversion. - // Support conversion on table level. if (isset($data['moved to'])) { $moved = array($data['moved to'], $field); @@ -1265,7 +1365,7 @@ function views_get_handler($table, $field, $key, $override = NULL) { if (!empty($moved)) { list($moved_table, $moved_field) = $moved; if (!empty($recursion_protection[$moved_table][$moved_field])) { - // recursion detected! + // Recursion detected! return NULL; } @@ -1273,7 +1373,7 @@ function views_get_handler($table, $field, $key, $override = NULL) { $handler = views_get_handler($moved_table, $moved_field, $key, $override); $recursion_protection = array(); if ($handler) { - // store these values so we know what we were originally called. + // Store these values so we know what we were originally called. $handler->original_table = $table; $handler->original_field = $field; if (empty($handler->actual_table)) { @@ -1284,7 +1384,7 @@ function views_get_handler($table, $field, $key, $override = NULL) { return $handler; } - // Set up a default handler: + // Set up a default handler. if (empty($data[$field][$key]['handler'])) { $data[$field][$key]['handler'] = 'views_handler_' . $key; } @@ -1300,8 +1400,9 @@ function views_get_handler($table, $field, $key, $override = NULL) { return $handler; } - // DEBUG -- identify missing handlers - vpr("Missing handler: @table @field @key", array('@table' => $table, '@field' => $field, '@key' => $key)); + // DEBUG -- identify missing handlers. + $placeholders = array('@table' => $table, '@field' => $field, '@key' => $key); + vpr("Missing handler: @table @field @key", $placeholders); $broken = array( 'title' => t('Broken handler @table.@field', array('@table' => $table, '@field' => $field)), 'handler' => 'views_handler_' . $key . '_broken', @@ -1312,16 +1413,13 @@ function views_get_handler($table, $field, $key, $override = NULL) { } /** - * Fetch Views' data from the cache + * Fetch Views' data from the cache. */ function views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) { views_include('cache'); return _views_fetch_data($table, $move, $reset); } -// ----------------------------------------------------------------------- -// Views plugin functions - /** * Fetch the plugin data from cache. */ @@ -1331,17 +1429,17 @@ function views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE) { } /** - * Fetch a list of all base tables available + * Fetch a list of all base tables available. * - * @param $type - * Either 'display', 'style' or 'row' - * @param $key - * For style plugins, this is an optional type to restrict to. May be 'normal', - * 'summary', 'feed' or others based on the needs of the display. - * @param $base + * @param string $type + * Either 'display', 'style' or 'row'. + * @param string $key + * For style plugins, this is an optional type to restrict to. May be + * 'normal', 'summary', 'feed' or others based on the needs of the display. + * @param array $base * An array of possible base tables. * - * @return + * @return array * A keyed array of in the form of 'base_table' => 'Description'. */ function views_fetch_plugin_names($type, $key = NULL, $base = array()) { @@ -1363,16 +1461,16 @@ function views_fetch_plugin_names($type, $key = NULL, $base = array()) { asort($plugins[$type]); return $plugins[$type]; } - // fall-through + + // Fall-through. return array(); } /** - * Get a handler for a plugin + * Get a handler for a plugin. * * @return views_plugin - * - * The created plugin object. + * The created plugin object. */ function views_get_plugin($type, $plugin, $reset = FALSE) { views_include('handlers'); @@ -1385,7 +1483,8 @@ function views_get_plugin($type, $plugin, $reset = FALSE) { /** * Load the current enabled localization plugin. * - * @return The name of the localization plugin. + * @return string + * The name of the localization plugin. */ function views_get_localization_plugin() { $plugin = variable_get('views_localization_plugin', ''); @@ -1402,9 +1501,6 @@ function views_get_localization_plugin() { return $plugin; } -// ----------------------------------------------------------------------- -// Views database functions - /** * Get all view templates. * @@ -1445,19 +1541,20 @@ function views_new_view() { } /** - * Return a list of all views and display IDs that have a particular - * setting in their display's plugin settings. + * Get applicable views. * - * @return - * @code - * array( - * array($view, $display_id), - * array($view, $display_id), - * ); - * @endcode + * Return a list of all views and display IDs that have a particular setting in + * their display's plugin settings. + * + * @return array + * An array with the following structure. + * array( + * array($view, $display_id), + * array($view, $display_id), + * ); */ function views_get_applicable_views($type) { - // @todo: Use a smarter flagging system so that we don't have to + // @todo Use a smarter flagging system so that we don't have to // load every view for this. $result = array(); $views = views_get_all_views(); @@ -1498,7 +1595,7 @@ function views_get_applicable_views($type) { /** * Return an array of all views as fully loaded $view objects. * - * @param $reset + * @param bool $reset * If TRUE, reset the static cache forcing views to be reloaded. */ function views_get_all_views($reset = FALSE) { @@ -1523,29 +1620,31 @@ function views_get_disabled_views() { } /** + * Get options array. + * * Return an array of view as options array, that can be used by select, * checkboxes and radios as #options. * * @param bool $views_only - * If TRUE, only return views, not displays. + * If TRUE, only return views, not displays. * @param string $filter - * Filters the views on status. Can either be 'all' (default), 'enabled' or - * 'disabled' - * @param mixed $exclude_view - * view or current display to exclude - * either a - * - views object (containing $exclude_view->name and $exclude_view->current_display) - * - views name as string: e.g. my_view - * - views name and display id (separated by ':'): e.g. my_view:default + * Filters the views on status. Can either be 'all' (default), 'enabled' or + * 'disabled'. + * @param mixed $exclude_view + * View or current display to exclude + * either a + * - views object (containing name and current_display) + * - views name as string: e.g. my_view + * - views name and display id (separated by ':'): e.g. my_view:default. * @param bool $optgroup - * If TRUE, returns an array with optgroups for each view (will be ignored for - * $views_only = TRUE). Can be used by select + * If TRUE, returns an array with optgroups for each view (will be ignored for + * $views_only = TRUE). Can be used by select. * @param bool $sort - * If TRUE, the list of views is sorted ascending. + * If TRUE, the list of views is sorted ascending. * * @return array - * an associative array for use in select. - * - key: view name and display id separated by ':', or the view name only + * An associative array for use in select. + * - key: view name and display id separated by ':', or the view name only */ function views_get_views_as_options($views_only = FALSE, $filter = 'all', $exclude_view = NULL, $optgroup = FALSE, $sort = FALSE) { @@ -1557,6 +1656,7 @@ function views_get_views_as_options($views_only = FALSE, $filter = 'all', $exclu $func = "views_get_{$filter}_views"; $views = $func(); break; + default: return array(); } @@ -1621,10 +1721,11 @@ function views_view_is_disabled($view) { * isn't called 'views_load()' primarily because it might get a view * from the default views which aren't technically loaded from the database. * - * @param $name + * @param string $name * The name of the view. - * @param $reset + * @param bool $reset * If TRUE, reset this entry in the load cache. + * * @return view * A reference to the $view object. Use $reset if you're sure you want * a fresh one. @@ -1730,22 +1831,19 @@ function views_export_status($view, $status) { views_invalidate_cache(); } -// ------------------------------------------------------------------ -// Views debug helper functions - /** * Provide debug output for Views. * * This relies on devel.module * or on the debug() function if you use a simpletest. * - * @param $message + * @param mixed $message * The message/variable which should be debugged. * This either could be * * an array/object which is converted to pretty output - * * a translation source string which is used together with the parameter placeholders. - * - * @param $placeholder + * * a translation source string which is used together with the parameter + * placeholders. + * @param array $placeholders * The placeholders which are used for the translation source string. */ function views_debug($message, $placeholders = array()) { @@ -1758,7 +1856,7 @@ function views_debug($message, $placeholders = array()) { $output = $message; watchdog('views_logging', $output, $placeholders); } - else if ($devel_region == 'drupal_debug') { + elseif ($devel_region == 'drupal_debug') { $output = empty($output) ? t($message, $placeholders) : $output; dd($output); } @@ -1774,14 +1872,14 @@ function views_debug($message, $placeholders = array()) { } /** - * Shortcut to views_debug() + * Shortcut to views_debug(). */ function vpr($message, $placeholders = array()) { views_debug($message, $placeholders); } /** - * Debug messages + * Debug messages. */ function vsm($message) { if (module_exists('devel')) { @@ -1792,7 +1890,8 @@ function vsm($message) { function views_trace() { $message = ''; foreach (debug_backtrace() as $item) { - if (!empty($item['file']) && !in_array($item['function'], array('vsm_trace', 'vpr_trace', 'views_trace'))) { + $traces = array('vsm_trace', 'vpr_trace', 'views_trace'); + if (!empty($item['file']) && !in_array($item['function'], $traces)) { $message .= basename($item['file']) . ": " . (empty($item['class']) ? '' : ($item['class'] . '->')) . "$item[function] line $item[line]" . "\n"; } } @@ -1807,10 +1906,9 @@ function vpr_trace() { dpr(views_trace()); } -// ------------------------------------------------------------------ -// Views form (View with form elements) - /** + * Determine whether the view has form elements. + * * Returns TRUE if the passed-in view contains handlers with views form * implementations, FALSE otherwise. */ @@ -1832,6 +1930,7 @@ function views_view_has_form_elements($view) { /** * This is the entry function. Just gets the form for the current step. + * * The form is always assumed to be multistep, even if it has only one * step (the default 'views_form_views_form' step). That way it is actually * possible for modules to have a multistep form if they need to. @@ -1859,6 +1958,7 @@ function views_form($form, &$form_state, $view, $output) { /** * Callback for the main step of a Views form. + * * Invoked by views_form(). */ function views_form_views_form($form, &$form_state, $view, $output) { @@ -1948,6 +2048,7 @@ function views_form_views_form($form, &$form_state, $view, $output) { /** * Validate handler for the first step of the views form. + * * Calls any existing views_form_validate functions located * on the views fields. */ @@ -1973,6 +2074,7 @@ function views_form_views_form_validate($form, &$form_state) { /** * Submit handler for the first step of the views form. + * * Calls any existing views_form_submit functions located * on the views fields. */ @@ -1996,9 +2098,6 @@ function views_form_views_form_submit($form, &$form_state) { } } -// ------------------------------------------------------------------ -// Exposed widgets form - /** * Form builder for the exposed widgets form. * @@ -2008,7 +2107,8 @@ function views_exposed_form($form, &$form_state) { // Don't show the form when batch operations are in progress. if ($batch = batch_get() && isset($batch['current_set'])) { return array( - // Set the theme callback to be nothing to avoid errors in template_preprocess_views_exposed_form(). + // Set the theme callback to be nothing to avoid errors in + // template_preprocess_views_exposed_form(). '#theme' => '', ); } @@ -2023,7 +2123,7 @@ function views_exposed_form($form, &$form_state) { // Let form plugins know this is for exposed widgets. $form_state['exposed'] = TRUE; - // Check if the form was already created + // Check if the form was already created. if ($cache = views_exposed_form_cache($view->name, $view->current_display)) { return $cache; } @@ -2060,8 +2160,9 @@ function views_exposed_form($form, &$form_state) { } } + // Form submit, #name is an empty string to prevent showing up in $_GET. $form['submit'] = array( - '#name' => '', // prevent from showing up in $_GET. + '#name' => '', '#type' => 'submit', '#value' => t('Apply'), '#id' => drupal_html_id('edit-submit-' . $view->name), @@ -2070,7 +2171,6 @@ function views_exposed_form($form, &$form_state) { $form['#action'] = url($view->display_handler->get_url()); $form['#theme'] = views_theme_functions('views_exposed_form', $view, $display); $form['#id'] = drupal_clean_css_identifier('views_exposed_form-' . check_plain($view->name) . '-' . check_plain($display->id)); -// $form['#attributes']['class'] = array('views-exposed-form'); // If using AJAX, we need the form plugin. if ($view->use_ajax) { @@ -2081,14 +2181,14 @@ function views_exposed_form($form, &$form_state) { $exposed_form_plugin = $form_state['exposed_form_plugin']; $exposed_form_plugin->exposed_form_alter($form, $form_state); - // Save the form + // Save the form. views_exposed_form_cache($view->name, $view->current_display, $form); return $form; } /** - * Implement hook_form_alter for the exposed form. + * Implements hook_form_alter() for views_exposed_form(). * * Since the exposed form is a GET form, we don't want it to send a wide * variety of information. @@ -2100,7 +2200,7 @@ function views_form_views_exposed_form_alter(&$form, &$form_state) { } /** - * Validate handler for exposed filters + * Validate handler for exposed filters. */ function views_exposed_form_validate(&$form, &$form_state) { foreach (array('field', 'filter') as $type) { @@ -2114,7 +2214,7 @@ function views_exposed_form_validate(&$form, &$form_state) { } /** - * Submit handler for exposed filters + * Submit handler for exposed filters. */ function views_exposed_form_submit(&$form, &$form_state) { foreach (array('field', 'filter') as $type) { @@ -2126,8 +2226,16 @@ function views_exposed_form_submit(&$form, &$form_state) { $form_state['view']->exposed_data = $form_state['values']; $form_state['view']->exposed_raw_input = array(); - - $exclude = array('q', 'submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', '', 'reset'); + $exclude = array( + 'q', + 'submit', + 'form_build_id', + 'form_id', + 'form_token', + 'exposed_form_plugin', + '', + 'reset', + ); $exposed_form_plugin = $form_state['exposed_form_plugin']; $exposed_form_plugin->exposed_form_submit($form, $form_state, $exclude); @@ -2141,13 +2249,14 @@ function views_exposed_form_submit(&$form, &$form_state) { /** * Save the Views exposed form for later use. * - * @param $views_name - * String. The views name. - * @param $display_name - * String. The current view display name. - * @param $form_output - * Array (optional). The form structure. Only needed when inserting the value. - * @return + * @param string $views_name + * The views name. + * @param string $display_name + * The current view display name. + * @param array $form_output + * An optional form structure. Only needed when inserting the value. + * + * @return array|bool * Array. The form structure, if any. Otherwise, return FALSE. */ function views_exposed_form_cache($views_name, $display_name, $form_output = NULL) { @@ -2155,19 +2264,15 @@ function views_exposed_form_cache($views_name, $display_name, $form_output = NUL // be cleared between each test. $views_exposed = &drupal_static(__FUNCTION__); - // Save the form output + // Save the form output. if (!empty($form_output)) { $views_exposed[$views_name][$display_name] = $form_output; - return; } - // Return the form output, if any + // Return the form output, if any. return empty($views_exposed[$views_name][$display_name]) ? FALSE : $views_exposed[$views_name][$display_name]; } -// ------------------------------------------------------------------ -// Misc helpers - /** * Build a list of theme function names for use most everywhere. */ @@ -2252,9 +2357,9 @@ function _views_query_tag_alter_condition(QueryAlterableInterface $query, &$cond * to do that, you will need to do what this function does manually, by * loading the view, getting the preview and then getting $view->get_title(). * - * @param $name + * @param string $name * The name of the view to embed. - * @param $display_id + * @param string $display_id * The display id to embed. If unsure, use 'default', as it will always be * valid. But things like 'page' or 'block' should work here. * @param ... @@ -2262,9 +2367,11 @@ function _views_query_tag_alter_condition(QueryAlterableInterface $query, &$cond */ function views_embed_view($name, $display_id = 'default') { $args = func_get_args(); - array_shift($args); // remove $name + // Remove $name. + array_shift($args); if (count($args)) { - array_shift($args); // remove $display_id + // Remove $display_id. + array_shift($args); } $view = views_get_view($name); @@ -2289,14 +2396,17 @@ function views_embed_view($name, $display_id = 'default') { * Everything after #views-tab- is the display ID, e.g. page_1. * @param ... * Any additional parameters will be passed as arguments. + * * @return array * An array containing an object for each view item. */ function views_get_view_result($name, $display_id = NULL) { $args = func_get_args(); - array_shift($args); // remove $name + // Remove $name. + array_shift($args); if (count($args)) { - array_shift($args); // remove $display_id + // Remove $display_id. + array_shift($args); } $view = views_get_view($name); @@ -2361,22 +2471,28 @@ function views_var_export($var, $prefix = '', $init = TRUE) { } /** - * Prepare a string for use as a valid CSS identifier (element, class or ID name). + * Prepare a string for use as a valid CSS identifier. + * * This function is similar to a core version but with more sane filter values. - * * http://www.w3.org/TR/CSS21/syndata.html#characters shows the syntax for valid - * CSS identifiers (including element names, classes, and IDs in selectors.) + * CSS identifiers (including element names, classes, and IDs in selectors). * - * @param $identifier + * @param string $identifier * The identifier to clean. - * @param $filter + * @param array $filter * An array of string replacements to use on the identifier. - * @return + * + * @return string * The cleaned identifier. * * @see drupal_clean_css_identifier() */ -function views_clean_css_identifier($identifier, $filter = array(' ' => '-', '/' => '-', '[' => '-', ']' => '')) { +function views_clean_css_identifier($identifier, $filter = array( + ' ' => '-', + '/' => '-', + '[' => '-', + ']' => '', +)) { // By default, we filter using Drupal's coding standards. $identifier = strtr($identifier, $filter); @@ -2394,19 +2510,19 @@ function views_clean_css_identifier($identifier, $filter = array(' ' => '-', '/' } /** - * Implement hook_views_exportables(). + * Implements hook_views_exportables(). */ function views_views_exportables($op = 'list', $views = NULL, $name = 'foo') { $all_views = views_get_all_views(); if ($op == 'list') { foreach ($all_views as $name => $view) { - // in list, $views is a list of tags. + // In list, $views is a list of tags. if (empty($views) || in_array($view->tag, $views)) { $return[$name] = array( 'name' => check_plain($name), 'desc' => check_plain($view->description), - 'tag' => check_plain($view->tag) + 'tag' => check_plain($view->tag), ); } } @@ -2433,7 +2549,7 @@ function views_views_exportables($op = 'list', $views = NULL, $name = 'foo') { } /** - * #process callback to see if we need to check_plain() the options. + * Process callback to see if we need to check_plain() the options. * * Since FAPI is inconsistent, the #options are sanitized for you in all cases * _except_ checkboxes. We have form elements that are sometimes 'select' and @@ -2451,19 +2567,18 @@ function views_process_check_options($element, &$form_state) { /** * Trim the field down to the specified length. * - * @param $alter + * @param array $alter * - max_length: Maximum length of the string, the rest gets truncated. * - word_boundary: Trim only on a word boundary. * - ellipsis: Show an ellipsis (...) at the end of the trimmed string. * - html: Take sure that the html is correct. - * - * @param $value + * @param string $value * The string which should be trimmed. */ function views_trim_text($alter, $value) { if (drupal_strlen($value) > $alter['max_length']) { $value = drupal_substr($value, 0, $alter['max_length']); - // TODO: replace this with cleanstring of ctools + // @todo Replace this with cleanstring of CTools. if (!empty($alter['word_boundary'])) { $regex = "(.*)\b.+"; if (function_exists('mb_ereg')) { @@ -2477,7 +2592,7 @@ function views_trim_text($alter, $value) { $value = $matches[1]; } } - // Remove scraps of HTML entities from the end of a strings + // Remove scraps of HTML entities from the end of a strings. $value = rtrim(preg_replace('/(?:<(?!.+>)|&(?!.+;)).*$/us', '', $value)); if (!empty($alter['ellipsis'])) { @@ -2500,7 +2615,7 @@ function views_array_key_plus($array) { $keys = array_keys($array); rsort($keys); foreach ($keys as $key) { - $array[$key+1] = $array[$key]; + $array[$key + 1] = $array[$key]; unset($array[$key]); } asort($array); @@ -2508,14 +2623,15 @@ function views_array_key_plus($array) { } /** - * Report to CTools that we use hook_views_api instead of hook_ctools_plugin_api() + * Implements hook_ctools_plugin_api_hook_name(). + * + * Report to CTools that we use hook_views_api instead of + * hook_ctools_plugin_api(). */ function views_ctools_plugin_api_hook_name() { return 'views_api'; } -// Declare API compatibility on behalf of core modules: - /** * Implements hook_views_api(). * @@ -2523,84 +2639,190 @@ function views_ctools_plugin_api_hook_name() { */ function views_views_api() { return array( - // in your modules do *not* use views_api_version()!!! + // In your modules do *not* use views_api_version()!!! 'api' => views_api_version(), 'path' => drupal_get_path('module', 'views') . '/modules', ); } +/** + * Implements hook_admin_menu_cache_info(). + */ +function views_admin_menu_cache_info() { + $caches['views'] = array( + 'title' => t('Views'), + 'callback' => 'views_invalidate_cache', + ); + return $caches; +} + if (!function_exists('aggregator_views_api')) { - function aggregator_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Aggregator module. + */ + function aggregator_views_api() { + return views_views_api(); + } } if (!function_exists('book_views_api')) { - function book_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Book module. + */ + function book_views_api() { + return views_views_api(); + } } if (!function_exists('comment_views_api')) { - function comment_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Comment module. + */ + function comment_views_api() { + return views_views_api(); + } } if (!function_exists('field_views_api')) { - function field_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Field module. + */ + function field_views_api() { + return views_views_api(); + } } if (!function_exists('file_views_api')) { - function file_views_api() { return views_views_api(); } + /** + * Provide Views integration for the File module. + */ + function file_views_api() { + return views_views_api(); + } } if (!function_exists('filter_views_api')) { - function filter_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Filter module. + */ + function filter_views_api() { + return views_views_api(); + } } if (!function_exists('image_views_api')) { - function image_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Image module. + */ + function image_views_api() { + return views_views_api(); + } } if (!function_exists('locale_views_api')) { - function locale_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Locale module. + */ + function locale_views_api() { + return views_views_api(); + } } if (!function_exists('node_views_api')) { - function node_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Node module. + */ + function node_views_api() { + return views_views_api(); + } } if (!function_exists('poll_views_api')) { - function poll_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Poll module. + */ + function poll_views_api() { + return views_views_api(); + } } if (!function_exists('profile_views_api')) { - function profile_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Profile module. + */ + function profile_views_api() { + return views_views_api(); + } } if (!function_exists('search_views_api')) { - function search_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Search module. + */ + function search_views_api() { + return views_views_api(); + } } if (!function_exists('statistics_views_api')) { - function statistics_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Statistics module. + */ + function statistics_views_api() { + return views_views_api(); + } } if (!function_exists('system_views_api')) { - function system_views_api() { return views_views_api(); } + /** + * Provide Views integration for the System module. + */ + function system_views_api() { + return views_views_api(); + } } if (!function_exists('tracker_views_api')) { - function tracker_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Tracker module. + */ + function tracker_views_api() { + return views_views_api(); + } } if (!function_exists('taxonomy_views_api')) { - function taxonomy_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Taxonomy module. + */ + function taxonomy_views_api() { + return views_views_api(); + } } if (!function_exists('translation_views_api')) { - function translation_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Translation module. + */ + function translation_views_api() { + return views_views_api(); + } } if (!function_exists('user_views_api')) { - function user_views_api() { return views_views_api(); } + /** + * Provide Views integration for the User module. + */ + function user_views_api() { + return views_views_api(); + } } if (!function_exists('contact_views_api')) { - function contact_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Contact module. + */ + function contact_views_api() { + return views_views_api(); + } } diff --git a/sites/all/modules/views/views_ui.info b/sites/all/modules/views/views_ui.info index 21705ea..7a8e538 100644 --- a/sites/all/modules/views/views_ui.info +++ b/sites/all/modules/views/views_ui.info @@ -8,9 +8,8 @@ dependencies[] = views files[] = views_ui.module files[] = plugins/views_wizard/views_ui_base_views_wizard.class.php -; Information added by Drupal.org packaging script on 2017-08-23 -version = "7.x-3.18" +; Information added by Drupal.org packaging script on 2019-05-10 +version = "7.x-3.23" core = "7.x" project = "views" -datestamp = "1503495103" - +datestamp = "1557505389" diff --git a/sites/all/modules/views/views_ui.module b/sites/all/modules/views/views_ui.module index c33526a..0eadd6f 100644 --- a/sites/all/modules/views/views_ui.module +++ b/sites/all/modules/views/views_ui.module @@ -435,8 +435,7 @@ function views_ui_preprocess_views_view(&$vars) { /** * Theme preprocess for theme_views_ui_view_preview_section(). * - * @TODO - * Perhaps move this to includes/admin.inc or theme/theme.inc + * @todo Perhaps move this to includes/admin.inc or theme/theme.inc. */ function template_preprocess_views_ui_view_preview_section(&$vars) { switch ($vars['section']) { @@ -483,12 +482,12 @@ function template_preprocess_views_ui_view_preview_section(&$vars) { break; case 'attachment_before': - // @todo: Add links to the attachment configuration page. + // @todo Add links to the attachment configuration page. $vars['title'] = t('Attachment before'); break; case 'attachment_after': - // @todo: Add links to the attachment configuration page. + // @todo Add links to the attachment configuration page. $vars['title'] = t('Attachment after'); break; } @@ -524,9 +523,8 @@ function theme_views_ui_view_preview_section($vars) { * @param string $title * Add a bolded title of this section. * - * @TODO - * Bring in relationships - * Refactor this function to use much stuff of views_ui_edit_form_get_bucket. + * @todo Bring in relationships. + * @todo Refactor this function to use much of views_ui_edit_form_get_bucket. */ function views_ui_view_preview_section_handler_links($view, $type, $title = FALSE) { $display = $view->display_handler->display; @@ -806,6 +804,9 @@ function views_ui_contextual_links_suppress_pop() { * @see http://drupal.org/node/774876 */ function views_ui_ajax_get_form($form_id) { + $args = func_get_args(); + array_shift($args); + // @see ajax_get_form() $form_state = array( 'no_redirect' => TRUE, @@ -814,8 +815,6 @@ function views_ui_ajax_get_form($form_id) { $form_state['rebuild_info']['copy']['#action'] = TRUE; // @see drupal_get_form() - $args = func_get_args(); - array_shift($args); $form_state['build_info']['args'] = $args; $form = drupal_build_form($form_id, $form_state); @@ -904,7 +903,7 @@ function _views_ui_get_displays_list($view) { * @see /js/jquery.ui.dialog.patch.js * @see /js/jquery.ui.dialog.min.js * - * The javascript patch overwrites the $.ui.dialog.overlay.events object to + * The JavaScript patch overwrites the $.ui.dialog.overlay.events object to * remove the mousedown, mouseup and click events from the list of events that * are bound in $.ui.dialog.overlay.create. */
        scope="col"> + class="" scope="col">
        > + class="">