diff --git a/core/MAINTAINERS.txt b/core/MAINTAINERS.txt index 8f8edb2..1630b3b 100644 --- a/core/MAINTAINERS.txt +++ b/core/MAINTAINERS.txt @@ -118,10 +118,6 @@ Path system - Dave Reid 'davereid' http://drupal.org/user/53892 - Nathaniel Catchpole 'catch' http://drupal.org/user/35733 -Plugin system -- Kris Vanderwater 'EclipseGc' http://drupal.org/user/61203 -- Alex Bronstein 'effulgentsia' http://drupal.org/user/78040 - Render system - Moshe Weitzman 'moshe weitzman' http://drupal.org/user/23 - Alex Bronstein 'effulgentsia' http://drupal.org/user/78040 @@ -207,6 +203,10 @@ Database Logging module Edit module - Wim Leers 'Wim Leers' http://drupal.org/user/99777 +Entity Reference module +- Amitai Burstein 'Amitaibu' http://drupal.org/user/57511 +- Andrei Mateescu 'amateescu' http://drupal.org/user/729614 + Field module - Yves Chedemois 'yched' http://drupal.org/user/39567 - Barry Jaspan 'bjaspan' http://drupal.org/user/46413 diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index a7fbe7b..f0dca74 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -251,8 +251,8 @@ function ajax_render($commands = array()) { // reliably diffed with array_diff_key(), since the number can change // due to factors unrelated to the inline content, so for now, we strip // the inline items from Ajax responses, and can add support for them - // when drupal_add_css() and drupal_add_js() are changed to use a hash - // of the inline content as the array key. + // when drupal_add_css() and drupal_add_js() are changed to using md5() + // or some other hash of the inline content. foreach ($items[$type] as $key => $item) { if (is_numeric($key)) { unset($items[$type][$key]); diff --git a/core/includes/config.inc b/core/includes/config.inc index 20e6bb4..1453ade 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -182,8 +182,6 @@ function config_sync_changes(array $config_changes, StorageInterface $source_sto $factory = drupal_container()->get('config.factory'); foreach (array('delete', 'create', 'change') as $op) { foreach ($config_changes[$op] as $name) { - // Validate the configuration object name before importing it. - Config::validateName($name); if ($op == 'delete') { $target_storage->delete($name); } @@ -258,8 +256,6 @@ function config_import_invoke_owner(array $config_changes, StorageInterface $sou // Call to the configuration entity's storage controller to handle the // configuration change. $handled_by_module = FALSE; - // Validate the configuration object name before importing it. - Config::validateName($name); if ($entity_type = config_get_entity_type_by_name($name)) { $old_config = new Config($name, $target_storage); $old_config->load(); diff --git a/core/includes/form.inc b/core/includes/form.inc index 7507234..a855434 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -3994,14 +3994,6 @@ function form_process_vertical_tabs($element, &$form_state) { '#parents' => $element['#parents'], ); - // Add an invisible label for accessibility. - if (!isset($element['#title'])) { - $element['#title'] = t('Vertical Tabs'); - $element['#title_display'] = 'invisible'; - } - - $element['#attached']['library'][] = array('system', 'drupal.vertical-tabs'); - // The JavaScript stores the currently selected tab in this hidden // field so that the active tab can be restored the next time the // form is rendered, e.g. on preview pages or when form validation @@ -4020,25 +4012,6 @@ function form_process_vertical_tabs($element, &$form_state) { } /** - * Prepares a vertical_tabs element for rendering. - * - * @param array $element - * An associative array containing the properties and children of the - * vertical tabs element. - * - * @return array - * The modified element. - */ -function form_pre_render_vertical_tabs($element) { - // Do not render the vertical tabs element if it is empty. - $group = implode('][', $element['#parents']); - if (!element_get_visible_children($element['group']['#groups'][$group])) { - $element['#printed'] = TRUE; - } - return $element; -} - -/** * Returns HTML for an element's children details as vertical tabs. * * @param $variables @@ -4050,7 +4023,26 @@ function form_pre_render_vertical_tabs($element) { */ function theme_vertical_tabs($variables) { $element = $variables['element']; - return '
Follow these steps to translate Drupal into your language:
'; + $output .= '' . $directory . '
For more information on installing Drupal in different languages, visit the drupal.org handbook page.
'; + $output .= 'How should the installation continue?
'; + $output .= 'Translations will be downloaded from the Drupal Translation website. ' . - 'If you do not want this, select English and continue the installation. For more information, see the online handbook.
', + '#markup' => '' . st('Learn how to install Drupal in other languages') . '
', ); } $form['actions'] = array('#type' => 'actions'); @@ -1416,112 +1443,6 @@ function install_select_language_form($form, &$form_state, $files = array()) { } /** - * Download a translation file for the selected langaguage. - * - * @param array $install_state - * An array of information about the current installation state. - * - * @return string - * A themed status report, or an exception if there are requirement errors. - * Upon successfull download the page is reloaded and no output is returned. - */ -function install_download_translation(&$install_state) { - // Check whether all conditions are met to download. Download the translation - // if possible. - $requirements = install_check_translations($install_state); - if ($output = install_display_requirements($install_state, $requirements)) { - return $output; - } - - // The download was successfull, reload the page in the new lanagage. - install_goto(install_redirect_url($install_state)); -} - -/** - * Attempts to get a file using drupal_http_request and to store it locally. - * - * @param string $uri - * The URI of the file to grab. - * @param string $destination - * Stream wrapper URI specifying where the file should be placed. If a - * directory path is provided, the file is saved into that directory under its - * original name. If the path contains a filename as well, that one will be - * used instead. - * - * @return boolean - * TRUE on success, FALSE on failure. - */ -function install_retrieve_file($uri, $destination) { - $parsed_url = parse_url($uri); - if (is_dir(drupal_realpath($destination))) { - // Prevent URIs with triple slashes when gluing parts together. - $path = str_replace('///', '//', "$destination/") . drupal_basename($parsed_url['path']); - } - else { - $path = $destination; - } - $result = drupal_http_request($uri); - if ($result->code != 200) { - return FALSE; - } - if (file_put_contents($path, $result->data) === FALSE) { - return FALSE; - } - return TRUE; -} - -/** - * Checks if the localization server can be contacted. - * - * @param string $uri - * The URI to contact. - * - * @return string - * URI of the server if the localization server was contacted successfully. - * FALSE if not. - */ -function install_check_localization_server($uri) { - $result = drupal_http_request($uri, array('method' => 'HEAD')); - return (!isset($result->error) && $result->code == 200); -} - -/** - * Gets the core release version for localization. - * - * In case core has a development version we fall back to the latest stable - * release. e.g. 8.2-dev falls back to 8.1. 8.0-dev falls back to 7.0. Fallback - * is required because the localization server only provides translation files - * for stable releases. - * - * @return array - * Associative array containing 'core' and 'version' of the release. - */ -function install_get_localization_release() { - if (strpos(VERSION, 'dev')) { - list($version, ) = explode('-', VERSION); - list($major, $minor) = explode('.', $version); - - // Calculate the major and minor release numbers to fall back to. - // E.g. 8.0-dev falls back to 7.0 and 8.2-dev falls back to 8.1. - if ($minor == 0) { - $major--; - } - else { - $minor--; - } - $release = "$major.$minor"; - } - else { - $release = VERSION; - } - - return array( - 'core' => "$major.x", - 'version' => $release, - ); -} - -/** * Indicates that there are no profiles available. */ function install_no_profile_error() { @@ -1640,10 +1561,10 @@ function install_profile_modules(&$install_state) { * The batch definition, if there are language files to import. */ function install_import_translations(&$install_state) { - include_once DRUPAL_ROOT . '/core/modules/locale/locale.bulk.inc'; - include_once DRUPAL_ROOT . '/core/includes/standard.inc'; - + include_once drupal_get_path('module', 'locale') . '/locale.bulk.inc'; $langcode = $install_state['parameters']['langcode']; + + include_once DRUPAL_ROOT . '/core/includes/standard.inc'; $standard_languages = standard_language_list(); if (!isset($standard_languages[$langcode])) { // Drupal does not know about this language, so we prefill its values with @@ -1664,39 +1585,16 @@ function install_import_translations(&$install_state) { language_save($language); } - // If a non-English language was selected, remove English and import the - // translations. + // If a non-english language was selected, remove English. if ($langcode != 'en') { language_delete('en'); - - // Set up a batch to import translations for the newly added language. - _install_prepare_import(); - module_load_include('fetch.inc', 'locale'); - if ($batch = locale_translation_batch_fetch_build(array(), array($langcode))) { - return $batch; - } } -} - -/** - * Tells the translation import process that Drupal core is installed. - */ -function _install_prepare_import() { - global $install_state; - $release = install_get_localization_release(); - db_insert('locale_project') - ->fields(array( - 'name' => 'drupal', - 'project_type' => 'module', - 'core' => $release['core'], - 'version' => $release['version'], - 'server_pattern' => $install_state['server_pattern'], - 'status' => 1, - )) - ->execute(); - module_load_include('compare.inc', 'locale'); - locale_translation_check_projects_local(array('drupal'), array($install_state['parameters']['langcode'])); + // Collect files to import for this language. + $batch = locale_translate_batch_import_files(array('langcode' => $langcode)); + if (!empty($batch)) { + return $batch; + } } /** @@ -1749,29 +1647,20 @@ function install_configure_form($form, &$form_state, &$install_state) { /** * Finishes importing files at end of installation. * - * If other projects besides Drupal core have been installed, their translation - * will be imported here. - * * @param $install_state * An array of information about the current installation state. * * @return * The batch definition, if there are language files to import. + * + * @todo + * This currently does the same as the first import step. Need to revisit + * once we have l10n_update functionality integrated. See + * http://drupal.org/node/1191488. */ function install_import_translations_remaining(&$install_state) { - module_load_include('fetch.inc', 'locale'); - module_load_include('compare.inc', 'locale'); - - // Build a fresh list of installed projects. When more projects than core are - // installed, their translations will be downloaded (if required) and imported - // using a batch. - $projects = locale_translation_build_projects(); - if (count($projects) > 1) { - $options = _locale_translation_default_update_options(); - if ($batch = locale_translation_batch_update_build(array(), array($install_state['parameters']['langcode']), $options)) { - return $batch; - } - } + include_once drupal_get_path('module', 'locale') . '/locale.bulk.inc'; + return locale_translate_batch_import_files(array('langcode' => $install_state['parameters']['langcode'])); } /** @@ -1835,162 +1724,6 @@ function _install_profile_modules_finished($success, $results, $operations) { /** * Checks installation requirements and reports any errors. */ -function install_check_translations($install_state) { - include_once DRUPAL_ROOT . '/core/includes/standard.inc'; - $requirements = array(); - - $readable = FALSE; - $writable = FALSE; - $executable = FALSE; - $files_directory = variable_get('file_public_path', conf_path() . '/files'); - $translations_directory = variable_get('locale_translate_file_directory', conf_path() . '/files/translations'); - $translations_directory_exists = FALSE; - $online = FALSE; - $server_available = FALSE; - $translation_available = FALSE; - - // First attempt to create or make writable the files directory. - file_prepare_directory($files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); - // Then, attempt to create or make writable the translations directory. - file_prepare_directory($translations_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); - - // Get values so the requirements errors can be specific. - if (drupal_verify_install_file($translations_directory, FILE_EXIST|FILE_WRITABLE, 'dir')) { - $readable = is_readable($translations_directory); - $writable = is_writable($translations_directory); - $executable = is_executable($translations_directory); - $translations_directory_exists = TRUE; - } - - // Build URLs for the translation file and the translation server. - $release = install_get_localization_release(); - $langcode = $install_state['parameters']['langcode']; - $variables = array( - '%project' => 'drupal', - '%version' => $release['version'], - '%core' => $release['core'], - '%language' => $langcode, - ); - $translation_url = strtr($install_state['server_pattern'], $variables); - $elements = parse_url($translation_url); - $server_url = $elements['scheme'] . '://' . $elements['host']; - - // Build the language name for display. - $languages = standard_language_list(); - $language = isset($languages[$langcode]) ? $languages[$langcode][0] : $langcode; - - // Check if the desirered translation file is available and if the translation - // server can be reached, or in other words if we have an internet connection. - if ($translation_available = install_check_localization_server($translation_url)) { - $online = TRUE; - $server_available = TRUE; - } - else { - if ($server_available = install_check_localization_server($server_url)) { - $online = TRUE; - } - } - - // If the translations directory does not exists, throw an error. - if (!$translations_directory_exists) { - $requirements['translations directory exists'] = array( - 'title' => st('Translations directory'), - 'value' => st('The translations directory does not exist.'), - 'severity' => REQUIREMENT_ERROR, - 'description' => st('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in INSTALL.txt.', array('%translations_directory' => $translations_directory, '@install_txt' => base_path() . 'core/INSTALL.txt')), - ); - } - else { - $requirements['translations directory exists'] = array( - 'title' => st('Translations directory'), - 'value' => st('The diretory %translations_directory exists.', array('%translations_directory' => $translations_directory)), - ); - // If the translations directory is not readable, throw an error. - if (!$readable) { - $requirements['translations directory readable'] = array( - 'title' => st('Translations directory'), - 'value' => st('The translations directory is not readable.'), - 'severity' => REQUIREMENT_ERROR, - 'description' => st('The installer requires read permissions to %translations_directory at all times. If you are unsure how to grant file permissions, consult the online handbook.', array('%translations_directory' => $translations_directory, '@handbook_url' => 'http://drupal.org/server-permissions')), - ); - } - // If translations directory is not writable, throw an error. - if (!$writable) { - $requirements['translations directory writable'] = array( - 'title' => st('Translations directory'), - 'value' => st('The translations directory is not writable.'), - 'severity' => REQUIREMENT_ERROR, - 'description' => st('The installer requires write permissions to %translations_directory during the installation process. If you are unsure how to grant file permissions, consult the online handbook.', array('%translations_directory' => $translations_directory, '@handbook_url' => 'http://drupal.org/server-permissions')), - ); - } - else { - $requirements['translations directory writable'] = array( - 'title' => st('Translations directory'), - 'value' => st('The translations directory is writable.'), - ); - } - // If translations directory is not executable, throw an error. - if (!$executable) { - $requirements['translations directory executable'] = array( - 'title' => st('Translations directory'), - 'value' => st('The translations directory is not executable.'), - 'severity' => REQUIREMENT_ERROR, - 'description' => st('The installer requires execute permissions to %translations_directory during the installation process. If you are unsure how to grant file permissions, consult the online handbook.', array('%translations_directory' => $translations_directory, '@handbook_url' => 'http://drupal.org/server-permissions')), - ); - } - } - - // If the translations server can not be contacted, throw an error. - if (!$online) { - $requirements['online'] = array( - 'title' => st('Internet'), - 'value' => st('The translation server is offline.'), - 'severity' => REQUIREMENT_ERROR, - 'description' => st('The installer requires to contact the translation server to download a translation file. Check your internet connection and verify that your website can reach the translation server at !server_url.', array('!server_url' => $server_url)), - ); - } - else { - $requirements['online'] = array( - 'title' => st('Internet'), - 'value' => st('The translation server is online.'), - ); - // If translation file is not found at the translation server, throw an - // error. - if (!$translation_available) { - $requirements['translation available'] = array( - 'title' => st('Translation'), - 'value' => st('The %language translation is not available.', array('%language' => $language)), - 'severity' => REQUIREMENT_ERROR, - 'description' => st('The %language translation file is not available at the translation server. Choose a different language or select English and translate your website later.', array('%language' => $language, '!url' => check_url($_SERVER['SCRIPT_NAME']))), - ); - } - else { - $requirements['translation available'] = array( - 'title' => st('Translation'), - 'value' => st('The %language translation is available.', array('%language' => $language)), - ); - } - } - - if ($translations_directory_exists && $readable && $writable && $executable && $translation_available) { - $translation_downloaded = install_retrieve_file($translation_url, $translations_directory); - - if (!$translation_downloaded) { - $requirements['translation downloaded'] = array( - 'title' => st('Translation'), - 'value' => st('The %language translation could not be downloaded.', array('%language' => $language)), - 'severity' => REQUIREMENT_ERROR, - 'description' => st('The %language translation file could not be downloaded. Choose a different language or select English and translate your website later.', array('%language' => $language, '!url' => check_url($_SERVER['SCRIPT_NAME']))), - ); - } - } - - return $requirements; -} - -/** - * Checks installation requirements and reports any errors. - */ function install_check_requirements($install_state) { $profile = $install_state['parameters']['profile']; @@ -2126,56 +1859,6 @@ function install_check_requirements($install_state) { } /** - * Displays installation requirements. - * - * @param array $install_state - * An array of information about the current installation state. - * @param array $requirements - * An array of requirements, in the same format as is returned by - * hook_requirements(). - * - * @return - * A themed status report, or an exception if there are requirement errors. - * If there are only requirement warnings, a themed status report is shown - * initially, but the user is allowed to bypass it by providing 'continue=1' - * in the URL. Otherwise, no output is returned, so that the next task can be - * run in the same page request. - * - * @thows \Exception - */ -function install_display_requirements($install_state, $requirements) { - // Check the severity of the requirements reported. - $severity = drupal_requirements_severity($requirements); - - // If there are errors, always display them. If there are only warnings, skip - // them if the user has provided a URL parameter acknowledging the warnings - // and indicating a desire to continue anyway. See drupal_requirements_url(). - if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && empty($install_state['parameters']['continue']))) { - if ($install_state['interactive']) { - drupal_set_title(st('Requirements problem')); - $status_report = theme('status_report', array('requirements' => $requirements)); - $status_report .= st('Check the messages and try again.', array('!url' => check_url(drupal_requirements_url($severity)))); - return $status_report; - } - else { - // Throw an exception showing any unmet requirements. - $failures = array(); - foreach ($requirements as $requirement) { - // Skip warnings altogether for non-interactive installations; these - // proceed in a single request so there is no good opportunity (and no - // good method) to warn the user anyway. - if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) { - $failures[] = $requirement['title'] . ': ' . $requirement['value'] . "\n\n" . $requirement['description']; - } - } - if (!empty($failures)) { - throw new \Exception(implode("\n\n", $failures)); - } - } - } -} - -/** * Form constructor for a site configuration form. * * @param $install_state diff --git a/core/includes/install.inc b/core/includes/install.inc index 9223b9c..aada754 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -429,10 +429,6 @@ function drupal_install_system() { module_list_reset(); module_implements_reset(); - // To ensure that the system module can be found by the plugin system, warm - // the module list cache. - // @todo Remove this in http://drupal.org/node/1798732. - module_list(); config_install_default_config('module', 'system'); module_invoke('system', 'install'); diff --git a/core/includes/menu.inc b/core/includes/menu.inc index e6810b8..7d419ac 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -2641,6 +2641,7 @@ function menu_reset_static_cache() { drupal_static_reset('menu_tree'); drupal_static_reset('menu_tree_all_data'); drupal_static_reset('menu_tree_page_data'); + drupal_static_reset('menu_load_all'); drupal_static_reset('menu_link_get_preferred'); } diff --git a/core/includes/path.inc b/core/includes/path.inc index d0c954e..ba7c034 100644 --- a/core/includes/path.inc +++ b/core/includes/path.inc @@ -96,7 +96,7 @@ function current_path() { } /** - * Fetches a specific URL alias from the database. + * Fetch a specific URL alias from the database. * * @param $conditions * A string representing the source, a number representing the pid, or an @@ -118,11 +118,11 @@ function path_load($conditions) { } /** - * Determines whether a path is in the administrative section of the site. + * Determine whether a path is in the administrative section of the site. * - * By default, paths are considered to be non-administrative. If a path does - * not match any of the patterns in path_get_admin_paths(), or if it matches - * both administrative and non-administrative patterns, it is considered + * By default, paths are considered to be non-administrative. If a path does not + * match any of the patterns in path_get_admin_paths(), or if it matches both + * administrative and non-administrative patterns, it is considered * non-administrative. * * @param $path @@ -146,7 +146,7 @@ function path_is_admin($path) { } /** - * Gets a list of administrative and non-administrative paths. + * Get a list of administrative and non-administrative paths. * * @return array * An associative array containing the following keys: diff --git a/core/includes/schema.inc b/core/includes/schema.inc index b370145..7661dcb 100644 --- a/core/includes/schema.inc +++ b/core/includes/schema.inc @@ -123,8 +123,8 @@ function drupal_get_complete_schema($rebuild = FALSE) { * A module name. * * @return array|bool - * If the module has updates, an array of available updates sorted by - * version. Otherwise, FALSE. + * If the module has updates, an array of available updates sorted by version. + * Otherwise, FALSE. */ function drupal_get_schema_versions($module) { $updates = &drupal_static(__FUNCTION__, NULL); @@ -369,9 +369,9 @@ function drupal_schema_fields_sql($table, $prefix = NULL) { * An object or array representing the record to write, passed in by * reference. If inserting a new record, values not provided in $record will * be populated in $record and in the database with the default values from - * the schema, as well as a single serial (auto-increment) field - * (if present). If updating an existing record, only provided values are - * updated in the database, and $record is not modified. + * the schema, as well as a single serial (auto-increment) field (if present). + * If updating an existing record, only provided values are updated in the + * database, and $record is not modified. * @param array $primary_keys * To indicate that this is a new record to be inserted, omit this argument. * If this is an update, this argument specifies the primary keys' field diff --git a/core/includes/session.inc b/core/includes/session.inc index 31e67a6..9ffd3d1 100644 --- a/core/includes/session.inc +++ b/core/includes/session.inc @@ -270,7 +270,7 @@ function drupal_session_initialize() { } /** - * Starts a session forcefully, preserving already set session data. + * Forcefully starts a session, preserving already set session data. * * @ingroup php_wrappers */ diff --git a/core/includes/tablesort.inc b/core/includes/tablesort.inc index c42b1f4..818b61d 100644 --- a/core/includes/tablesort.inc +++ b/core/includes/tablesort.inc @@ -13,7 +13,7 @@ */ /** - * Initializes the table sort context. + * Initialize the table sort context. */ function tablesort_init($header) { $ts = tablesort_get_order($header); @@ -23,7 +23,7 @@ function tablesort_init($header) { } /** - * Formats a column header. + * Format a column header. * * If the cell in question is the column header for the current sort criterion, * it gets special formatting. All possible sort criteria become links. @@ -34,7 +34,6 @@ function tablesort_init($header) { * An array of column headers in the format described in theme_table(). * @param $ts * The current table sort context as returned from tablesort_init(). - * * @return * A properly formatted cell, ready for _theme_table_cell(). */ @@ -64,7 +63,7 @@ function tablesort_header($cell, $header, $ts) { } /** - * Formats a table cell. + * Format a table cell. * * Adds a class attribute to all cells in the currently active column. * @@ -76,7 +75,6 @@ function tablesort_header($cell, $header, $ts) { * The current table sort context as returned from tablesort_init(). * @param $i * The index of the cell's table column. - * * @return * A properly formatted cell, ready for _theme_table_cell(). */ @@ -93,7 +91,7 @@ function tablesort_cell($cell, $header, $ts, $i) { } /** - * Composes a URL query parameter array for table sorting links. + * Compose a URL query parameter array for table sorting links. * * @return * A URL query parameter array that consists of all components of the current @@ -104,11 +102,10 @@ function tablesort_get_query_parameters() { } /** - * Determines the current sort criterion. + * Determine the current sort criterion. * * @param $headers * An array of column headers in the format described in theme_table(). - * * @return * An associative array describing the criterion, containing the keys: * - "name": The localized title of the table column. @@ -141,11 +138,10 @@ function tablesort_get_order($headers) { } /** - * Determines the current sort direction. + * Determine the current sort direction. * * @param $headers * An array of column headers in the format described in theme_table(). - * * @return * The current sort direction ("asc" or "desc"). */ diff --git a/core/includes/theme.inc b/core/includes/theme.inc index bab2af5..9b50f90 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -75,7 +75,7 @@ function drupal_theme_access($theme) { } /** - * Initializes the theme system by loading the theme. + * Initialize the theme system by loading the theme. */ function drupal_theme_initialize() { global $theme, $user, $theme_key; @@ -114,9 +114,8 @@ function drupal_theme_initialize() { } /** - * Initializes the theme system given already loaded information. - * - * This function is useful to initialize a theme when no database is present. + * Initialize the theme system given already loaded information. This + * function is useful to initialize a theme when no database is present. * * @param $theme * An object with the following information: @@ -278,7 +277,7 @@ function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callb } /** - * Gets the theme registry. + * Get the theme registry. * * @param bool $complete * Optional boolean to indicate whether to return the complete theme registry @@ -323,7 +322,7 @@ function theme_get_registry($complete = TRUE) { } /** - * Sets the callback that will be used by theme_get_registry(). + * Set the callback that will be used by theme_get_registry() to fetch the registry. * * @param $callback * The name of the callback function. @@ -339,7 +338,7 @@ function _theme_registry_callback($callback = NULL, array $arguments = array()) } /** - * Gets the theme_registry cache; if it doesn't exist, builds it. + * Get the theme_registry cache; if it doesn't exist, build it. * * @param $theme * The loaded $theme object as returned by list_themes(). @@ -380,17 +379,16 @@ function _theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL, } /** - * Writes the theme_registry cache into the database. + * Write the theme_registry cache into the database. */ function _theme_save_registry($theme, $registry) { cache()->set("theme_registry:$theme->name", $registry, CacheBackendInterface::CACHE_PERMANENT, array('theme_registry' => TRUE)); } /** - * Forces the system to rebuild the theme registry. - * - * This function should be called when modules are added to the system, or when - * a dynamic system needs to add more theme hooks. + * Force the system to rebuild the theme registry; this should be called + * when modules are added to the system, or when a dynamic system needs + * to add more theme hooks. */ function drupal_theme_rebuild() { drupal_static_reset('theme_get_registry'); @@ -407,17 +405,17 @@ function drupal_theme_rebuild() { * - 'type': The passed-in $type. * - 'theme path': The passed-in $path. * - 'function': The name of the function generating output for this theme - * hook. Either defined explicitly in hook_theme() or, if neither - * 'function' nor 'template' is defined, then the default theme function - * name is used. The default theme function name is the theme hook prefixed - * by either 'theme_' for modules or '$name_' for everything else. If - * 'function' is defined, 'template' is not used. + * hook. Either defined explicitly in hook_theme() or, if neither 'function' + * nor 'template' is defined, then the default theme function name is used. + * The default theme function name is the theme hook prefixed by either + * 'theme_' for modules or '$name_' for everything else. If 'function' is + * defined, 'template' is not used. * - 'template': The filename of the template generating output for this * theme hook. The template is in the directory defined by the 'path' key of * hook_theme() or defaults to "$path/templates". * - 'variables': The variables for this theme hook as defined in - * hook_theme(). If there is more than one implementation and 'variables' - * is not specified in a later one, then the previous definition is kept. + * hook_theme(). If there is more than one implementation and 'variables' is + * not specified in a later one, then the previous definition is kept. * - 'render element': The renderable element for this theme hook as defined * in hook_theme(). If there is more than one implementation and * 'render element' is not specified in a later one, then the previous @@ -592,8 +590,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { $cache = $result + $cache; } - // Let themes have variable processors even if they didn't register a - // template. + // Let themes have variable processors even if they didn't register a template. if ($type == 'theme' || $type == 'base_theme') { foreach ($cache as $hook => $info) { // Check only if not registered by the theme or engine. @@ -620,7 +617,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { } /** - * Builds the theme registry cache. + * Build the theme registry cache. * * @param $theme * The loaded $theme object as returned by list_themes(). @@ -682,7 +679,7 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) { } /** - * Returns a list of all currently available themes. + * Return a list of all currently available themes. * * Retrieved from the database, if available and the site is not in maintenance * mode; otherwise compiled freshly from the filesystem. @@ -861,15 +858,15 @@ function drupal_find_base_themes($themes, $key, $used_keys = array()) { * executed (if they exist), in the following order (note that in the following * list, HOOK indicates the theme hook name, MODULE indicates a module name, * THEME indicates a theme name, and ENGINE indicates a theme engine name): - * - template_preprocess(&$variables, $hook): Creates a default set of - * variables for all theme hooks with template implementations. + * - template_preprocess(&$variables, $hook): Creates a default set of variables + * for all theme hooks with template implementations. * - template_preprocess_HOOK(&$variables): Should be implemented by the module * that registers the theme hook, to set up default variables. * - MODULE_preprocess(&$variables, $hook): hook_preprocess() is invoked on all * implementing modules. * - MODULE_preprocess_HOOK(&$variables): hook_preprocess_HOOK() is invoked on - * all implementing modules, so that modules that didn't define the theme - * hook can alter the variables. + * all implementing modules, so that modules that didn't define the theme hook + * can alter the variables. * - ENGINE_engine_preprocess(&$variables, $hook): Allows the theme engine to * set necessary variables for all theme hooks with template implementations. * - ENGINE_engine_preprocess_HOOK(&$variables): Allows the theme engine to set @@ -924,10 +921,10 @@ function drupal_find_base_themes($themes, $key, $used_keys = array()) { * @param $hook * The name of the theme hook to call. If the name contains a * double-underscore ('__') and there isn't an implementation for the full - * name, the part before the '__' is checked. This allows a fallback to a - * more generic implementation. For example, if theme('links__node', ...) is - * called, but there is no implementation of that theme hook, then the - * 'links' implementation is used. This process is iterative, so if + * name, the part before the '__' is checked. This allows a fallback to a more + * generic implementation. For example, if theme('links__node', ...) is + * called, but there is no implementation of that theme hook, then the 'links' + * implementation is used. This process is iterative, so if * theme('links__contextual__node', ...) is called, theme() checks for the * following implementations, and uses the first one that exists: * - links__contextual__node @@ -1006,8 +1003,7 @@ function theme($hook, $variables = array()) { // point path_to_theme() to the currently used theme path: $theme_path = $info['theme path']; - // Include a file if the theme function or variable processor is held - // elsewhere. + // Include a file if the theme function or variable processor is held elsewhere. if (!empty($info['includes'])) { foreach ($info['includes'] as $include_file) { include_once DRUPAL_ROOT . '/' . $include_file; @@ -1171,14 +1167,14 @@ function theme($hook, $variables = array()) { } /** - * Returns the path to the current themed element. - * - * It can point to the active theme or the module handling a themed - * implementation. For example, when invoked within the scope of a theming call - * it will depend on where the theming function is handled. If implemented from - * a module, it will point to the module. If implemented from the active theme, - * it will point to the active theme. When called outside the scope of a - * theming call, it will always point to the active theme. + * Return the path to the current themed element. + * + * It can point to the active theme or the module handling a themed implementation. + * For example, when invoked within the scope of a theming call it will depend + * on where the theming function is handled. If implemented from a module, it + * will point to the module. If implemented from the active theme, it will point + * to the active theme. When called outside the scope of a theming call, it will + * always point to the active theme. */ function path_to_theme() { global $theme_path; @@ -1191,7 +1187,7 @@ function path_to_theme() { } /** - * Allows themes and/or theme engines to discover overridden theme functions. + * Allow themes and/or theme engines to easily discover overridden theme functions. * * @param $cache * The existing cache of theme hooks to test against. @@ -1248,7 +1244,7 @@ function drupal_find_theme_functions($cache, $prefixes) { } /** - * Allows themes and/or theme engines to easily discover overridden templates. + * Allow themes and/or theme engines to easily discover overridden templates. * * @param $cache * The existing cache of theme hooks to test against. @@ -1345,8 +1341,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { if (($pos = strpos($match, '.')) !== FALSE) { $file = substr($match, 0, $pos); } - // 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. $arg_name = isset($info['variables']) ? 'variables' : 'render element'; $implementations[strtr($file, '-', '_')] = array( 'template' => $file, @@ -1362,7 +1357,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { } /** - * Retrieves a setting for the current theme or for a given theme. + * Retrieve a setting for the current theme or for a given theme. * * The final setting is obtained from the last value found in the following * sources: @@ -1480,7 +1475,7 @@ function theme_get_setting($setting_name, $theme = NULL) { } /** - * Renders a system default template, which is essentially a PHP template. + * Render a system default template, which is essentially a PHP template. * * @param $template_file * The filename of the template to render. @@ -1491,21 +1486,14 @@ function theme_get_setting($setting_name, $theme = NULL) { * The output generated by the template. */ function theme_render_template($template_file, $variables) { - // Extract the variables to a local namespace - extract($variables, EXTR_SKIP); - - // Start output buffering - ob_start(); - - // Include the template file - include DRUPAL_ROOT . '/' . $template_file; - - // End buffering and return its contents - return ob_get_clean(); + extract($variables, EXTR_SKIP); // Extract the variables to a local namespace + ob_start(); // Start output buffering + include DRUPAL_ROOT . '/' . $template_file; // Include the template file + return ob_get_clean(); // End buffering and return its contents } /** - * Enables a given list of themes. + * Enable a given list of themes. * * @param $theme_list * An array of theme names. @@ -1533,7 +1521,7 @@ function theme_enable($theme_list) { } /** - * Disables a given list of themes. + * Disable a given list of themes. * * @param $theme_list * An array of theme names. @@ -1602,21 +1590,20 @@ function template_preprocess_datetime(&$variables) { * * @param $variables * An associative array containing: - * - timestamp: (optional) A UNIX timestamp for the datetime attribute. If - * the datetime cannot be represented as a UNIX timestamp, use a valid - * datetime attribute value in $variables['attributes']['datetime']. + * - timestamp: (optional) A UNIX timestamp for the datetime attribute. If the + * datetime cannot be represented as a UNIX timestamp, use a valid datetime + * attribute value in $variables['attributes']['datetime']. * - text: (optional) The content to display within the