Merge remote-tracking branches 'origin/8.x' and 'origin/8.x-file-config' into 8.x-file-config
commit
bdd013ea2a
|
@ -84,7 +84,7 @@ Install system
|
|||
- David Rothstein 'David_Rothstein' <http://drupal.org/user/124982>
|
||||
|
||||
JavaScript
|
||||
- ?
|
||||
- Théodore Biadala 'nod_' <http://drupal.org/user/598310>
|
||||
|
||||
Language system
|
||||
- Francesco Placella 'plach' <http://drupal.org/user/183211>
|
||||
|
@ -242,7 +242,7 @@ Simpletest module
|
|||
- Károly Négyesi 'chx' <http://drupal.org/user/9446>
|
||||
|
||||
Statistics module
|
||||
- Dave Reid 'davereid' <http://drupal.org/user/53892>
|
||||
- Tim Millwood 'timmillwood' <http://drupal.org/user/227849>
|
||||
|
||||
Syslog module
|
||||
- Khalid Baheyeldin 'kbahey' <http://drupal.org/user/4063>
|
||||
|
|
|
@ -183,7 +183,7 @@ const LANGUAGE_TYPE_CONTENT = 'language_content';
|
|||
/**
|
||||
* The type of language used to select the user interface.
|
||||
*/
|
||||
const LANGUAGE_TYPE_INTERFACE = 'language';
|
||||
const LANGUAGE_TYPE_INTERFACE = 'language_interface';
|
||||
|
||||
/**
|
||||
* The type of language used for URLs.
|
||||
|
@ -1522,12 +1522,12 @@ function drupal_unpack($obj, $field = 'data') {
|
|||
* @ingroup sanitization
|
||||
*/
|
||||
function t($string, array $args = array(), array $options = array()) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
static $custom_strings;
|
||||
|
||||
// Merge in default.
|
||||
if (empty($options['langcode'])) {
|
||||
$options['langcode'] = isset($language->langcode) ? $language->langcode : LANGUAGE_SYSTEM;
|
||||
$options['langcode'] = isset($language_interface->langcode) ? $language_interface->langcode : LANGUAGE_SYSTEM;
|
||||
}
|
||||
if (empty($options['context'])) {
|
||||
$options['context'] = '';
|
||||
|
@ -2614,7 +2614,7 @@ function get_t() {
|
|||
* Initializes all the defined language types.
|
||||
*/
|
||||
function drupal_language_initialize() {
|
||||
$types = language_types();
|
||||
$types = language_types_get_all();
|
||||
|
||||
// Ensure the language is correctly returned, even without multilanguage
|
||||
// support. Also make sure we have a $language fallback, in case a language
|
||||
|
@ -2627,7 +2627,7 @@ function drupal_language_initialize() {
|
|||
if (language_multilingual()) {
|
||||
include_once DRUPAL_ROOT . '/core/includes/language.inc';
|
||||
foreach ($types as $type) {
|
||||
$GLOBALS[$type] = language_initialize($type);
|
||||
$GLOBALS[$type] = language_types_initialize($type);
|
||||
}
|
||||
// Allow modules to react on language system initialization in multilingual
|
||||
// environments.
|
||||
|
@ -2635,14 +2635,20 @@ function drupal_language_initialize() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the available language types.
|
||||
*/
|
||||
function language_types_get_all() {
|
||||
return array_keys(variable_get('language_types', language_types_get_default()));
|
||||
}
|
||||
/**
|
||||
* Returns a list of the built-in language types.
|
||||
*
|
||||
* @return
|
||||
* An array of key-values pairs where the key is the language type and the
|
||||
* value is its configurability.
|
||||
* An array of key-values pairs where the key is the language type name and
|
||||
* the value is its configurability (TRUE/FALSE).
|
||||
*/
|
||||
function drupal_language_types() {
|
||||
function language_types_get_default() {
|
||||
return array(
|
||||
LANGUAGE_TYPE_INTERFACE => TRUE,
|
||||
LANGUAGE_TYPE_CONTENT => FALSE,
|
||||
|
@ -2660,13 +2666,6 @@ function language_multilingual() {
|
|||
return variable_get('language_count', 1) > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the available language types.
|
||||
*/
|
||||
function language_types() {
|
||||
return array_keys(variable_get('language_types', drupal_language_types()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of configured languages.
|
||||
*
|
||||
|
|
|
@ -1892,9 +1892,9 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
|
|||
}
|
||||
|
||||
// Use the default langcode if none is set.
|
||||
global $language;
|
||||
global $language_interface;
|
||||
if (empty($langcode)) {
|
||||
$langcode = isset($language->langcode) ? $language->langcode : LANGUAGE_SYSTEM;
|
||||
$langcode = isset($language_interface->langcode) ? $language_interface->langcode : LANGUAGE_SYSTEM;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
|
@ -2496,8 +2496,8 @@ function drupal_deliver_html_page($page_callback_result) {
|
|||
}
|
||||
|
||||
// Send appropriate HTTP-Header for browsers and search engines.
|
||||
global $language;
|
||||
drupal_add_http_header('Content-Language', $language->langcode);
|
||||
global $language_interface;
|
||||
drupal_add_http_header('Content-Language', $language_interface->langcode);
|
||||
|
||||
// Menu status constants are integers; page content is a string or array.
|
||||
if (is_int($page_callback_result)) {
|
||||
|
@ -6206,7 +6206,7 @@ function drupal_render_cid_parts($granularity = NULL) {
|
|||
// If Locale is enabled but we have only one language we do not need it as cid
|
||||
// part.
|
||||
if (language_multilingual()) {
|
||||
foreach (language_types_configurable() as $language_type) {
|
||||
foreach (language_types_get_configurable() as $language_type) {
|
||||
$cid_parts[] = $GLOBALS[$language_type]->langcode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Initialize the list of date formats and their locales.
|
||||
* Initializes the list of date formats and their locales.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Functions for error handling
|
||||
* Functions for error handling.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,8 @@ const ERROR_REPORTING_DISPLAY_SOME = 1;
|
|||
const ERROR_REPORTING_DISPLAY_ALL = 2;
|
||||
|
||||
/**
|
||||
* Map PHP error constants to watchdog severity levels.
|
||||
* Maps PHP error constants to watchdog severity levels.
|
||||
*
|
||||
* The error constants are documented at
|
||||
* http://php.net/manual/en/errorfunc.constants.php
|
||||
*
|
||||
|
@ -50,7 +51,7 @@ function drupal_error_levels() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Custom PHP error handler.
|
||||
* Provides custom PHP error handling.
|
||||
*
|
||||
* @param $error_level
|
||||
* The level of the error raised.
|
||||
|
@ -61,7 +62,8 @@ function drupal_error_levels() {
|
|||
* @param $line
|
||||
* The line number the error was raised at.
|
||||
* @param $context
|
||||
* An array that points to the active symbol table at the point the error occurred.
|
||||
* An array that points to the active symbol table at the point the error
|
||||
* occurred.
|
||||
*/
|
||||
function _drupal_error_handler_real($error_level, $message, $filename, $line, $context) {
|
||||
if ($error_level & error_reporting()) {
|
||||
|
@ -88,10 +90,11 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
|
|||
}
|
||||
|
||||
/**
|
||||
* Decode an exception, especially to retrive the correct caller.
|
||||
* Decodes an exception and retrieves the correct caller.
|
||||
*
|
||||
* @param $exception
|
||||
* The exception object that was thrown.
|
||||
*
|
||||
* @return
|
||||
* An error in the format expected by _drupal_log_error().
|
||||
*/
|
||||
|
@ -134,10 +137,11 @@ function _drupal_decode_exception($exception) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Render an error message for an exception without any possibility of a further exception occurring.
|
||||
* Renders an exception error message without further exceptions.
|
||||
*
|
||||
* @param $exception
|
||||
* The exception object that was thrown.
|
||||
*
|
||||
* @return
|
||||
* An error message.
|
||||
*/
|
||||
|
@ -169,12 +173,12 @@ function error_displayable($error = NULL) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Log a PHP error or exception, display an error page in fatal cases.
|
||||
* Logs a PHP error or exception and displays an error page in fatal cases.
|
||||
*
|
||||
* @param $error
|
||||
* An array with the following keys: %type, !message, %function, %file, %line
|
||||
* and severity_level. All the parameters are plain-text, with the exception of
|
||||
* !message, which needs to be a safe HTML string.
|
||||
* and severity_level. All the parameters are plain-text, with the exception
|
||||
* of !message, which needs to be a safe HTML string.
|
||||
* @param $fatal
|
||||
* TRUE if the error is fatal.
|
||||
*/
|
||||
|
@ -261,6 +265,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
*
|
||||
* @param $backtrace
|
||||
* A standard PHP backtrace.
|
||||
*
|
||||
* @return
|
||||
* An associative array with keys 'file', 'line' and 'function'.
|
||||
*/
|
||||
|
|
|
@ -70,11 +70,7 @@ const FILE_EXISTS_ERROR = 2;
|
|||
const FILE_STATUS_PERMANENT = 1;
|
||||
|
||||
/**
|
||||
* Methods to manage a registry of stream wrappers.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Drupal stream wrapper registry.
|
||||
* Provides Drupal stream wrapper registry.
|
||||
*
|
||||
* A stream wrapper is an abstraction of a file system that allows Drupal to
|
||||
* use the same set of methods to access both local files and remote resources.
|
||||
|
@ -206,7 +202,7 @@ function file_uri_scheme($uri) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that the scheme of a stream URI is valid.
|
||||
* Checks that the scheme of a stream URI is valid.
|
||||
*
|
||||
* Confirms that there is a registered stream handler for the provided scheme
|
||||
* and that it is callable. This is useful if you want to confirm a valid
|
||||
|
@ -232,7 +228,7 @@ function file_stream_wrapper_valid_scheme($scheme) {
|
|||
|
||||
|
||||
/**
|
||||
* Returns the part of an URI after the schema.
|
||||
* Returns the part of a URI after the schema.
|
||||
*
|
||||
* @param $uri
|
||||
* A stream, referenced as "scheme://target".
|
||||
|
@ -252,7 +248,7 @@ function file_uri_target($uri) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the default file stream implementation.
|
||||
* Gets the default file stream implementation.
|
||||
*
|
||||
* @return
|
||||
* 'public', 'private' or any other file scheme defined as the default.
|
||||
|
@ -322,7 +318,7 @@ function file_stream_wrapper_get_instance_by_uri($uri) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the stream wrapper class responsible for a given scheme.
|
||||
* Returns a reference to the stream wrapper class responsible for a scheme.
|
||||
*
|
||||
* This helper method returns a stream instance using a scheme. That is, the
|
||||
* passed string does not contain a "://". For example, "public" is a scheme
|
||||
|
@ -357,7 +353,6 @@ function file_stream_wrapper_get_instance_by_scheme($scheme) {
|
|||
* Creates a web-accessible URL for a stream to an external or local file.
|
||||
*
|
||||
* Compatibility: normal paths and stream wrappers.
|
||||
* @see http://drupal.org/node/515192
|
||||
*
|
||||
* There are two kinds of local files:
|
||||
* - "managed files", i.e. those stored by a Drupal-compatible stream wrapper.
|
||||
|
@ -375,6 +370,8 @@ function file_stream_wrapper_get_instance_by_scheme($scheme) {
|
|||
* If the provided string already contains a preceding 'http', 'https', or
|
||||
* '/', nothing is done and the same string is returned. If a stream wrapper
|
||||
* could not be found to generate an external URL, then FALSE is returned.
|
||||
*
|
||||
* @see http://drupal.org/node/515192
|
||||
*/
|
||||
function file_create_url($uri) {
|
||||
// Allow the URI to be altered, e.g. to serve a file from a CDN or static
|
||||
|
@ -417,7 +414,7 @@ function file_create_url($uri) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that the directory exists and is writable.
|
||||
* Checks that the directory exists and is writable.
|
||||
*
|
||||
* Directories need to have execute permissions to be considered a directory by
|
||||
* FTP servers, etc.
|
||||
|
@ -459,7 +456,7 @@ function file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS)
|
|||
}
|
||||
|
||||
/**
|
||||
* If missing, create a .htaccess file in each Drupal files directory.
|
||||
* Creates a .htaccess file in each Drupal files directory if it is missing.
|
||||
*/
|
||||
function file_ensure_htaccess() {
|
||||
file_save_htaccess('public://', FALSE);
|
||||
|
@ -471,7 +468,7 @@ function file_ensure_htaccess() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates an .htaccess file in the given directory.
|
||||
* Creates a .htaccess file in the given directory.
|
||||
*
|
||||
* @param $directory
|
||||
* The directory.
|
||||
|
@ -527,19 +524,19 @@ function file_save_htaccess($directory, $private = TRUE) {
|
|||
* @return
|
||||
* An array of file objects, indexed by fid.
|
||||
*
|
||||
* @todo Remove $conditions in Drupal 8.
|
||||
*
|
||||
* @see hook_file_load()
|
||||
* @see file_load()
|
||||
* @see entity_load()
|
||||
* @see EntityFieldQuery
|
||||
*
|
||||
* @todo Remove $conditions in Drupal 8.
|
||||
*/
|
||||
function file_load_multiple($fids = array(), $conditions = array()) {
|
||||
return entity_load('file', $fids, $conditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a file object from the database.
|
||||
* Loads a single file object from the database.
|
||||
*
|
||||
* @param $fid
|
||||
* A file ID.
|
||||
|
@ -556,7 +553,7 @@ function file_load($fid) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Save a file object to the database.
|
||||
* Saves a file object to the database.
|
||||
*
|
||||
* If the $file->fid is not set a new record will be added.
|
||||
*
|
||||
|
@ -798,7 +795,7 @@ function file_copy(stdClass $source, $destination = NULL, $replace = FILE_EXISTS
|
|||
}
|
||||
|
||||
/**
|
||||
* Determine whether the URI has a valid scheme for file API operations.
|
||||
* Determines whether the URI has a valid scheme for file API operations.
|
||||
*
|
||||
* There must be a scheme and it must be a Drupal-provided scheme like
|
||||
* 'public', 'private', 'temporary', or an extension provided with
|
||||
|
@ -927,7 +924,7 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
|
|||
}
|
||||
|
||||
/**
|
||||
* Given a relative path, construct a URI into Drupal's default files location.
|
||||
* Constructs a URI to Drupal's default files location given a relative path.
|
||||
*/
|
||||
function file_build_uri($path) {
|
||||
$uri = file_default_scheme() . '://' . $path;
|
||||
|
@ -935,8 +932,7 @@ function file_build_uri($path) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Determines the destination path for a file depending on how replacement of
|
||||
* existing files should be handled.
|
||||
* Determines the destination path for a file.
|
||||
*
|
||||
* @param $destination
|
||||
* A string specifying the desired final URI or filepath.
|
||||
|
@ -973,7 +969,7 @@ function file_destination($destination, $replace) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Move a file to a new location and update the file's database entry.
|
||||
* Moves a file to a new location and update the file's database entry.
|
||||
*
|
||||
* Moving a file is performed by copying the file to the new location and then
|
||||
* deleting the original.
|
||||
|
@ -1053,8 +1049,7 @@ function file_move(stdClass $source, $destination = NULL, $replace = FILE_EXISTS
|
|||
}
|
||||
|
||||
/**
|
||||
* Move a file to a new location without calling any hooks or making any
|
||||
* changes to the database.
|
||||
* Moves a file to a new location without database changes or hook invocation.
|
||||
*
|
||||
* @param $source
|
||||
* A string specifying the filepath or URI of the original file.
|
||||
|
@ -1083,7 +1078,7 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST
|
|||
}
|
||||
|
||||
/**
|
||||
* Modify a filename as needed for security purposes.
|
||||
* Modifies a filename as needed for security purposes.
|
||||
*
|
||||
* Munging a file name prevents unknown file extensions from masking exploit
|
||||
* files. When web servers such as Apache decide how to process a URL request,
|
||||
|
@ -1147,7 +1142,7 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Undo the effect of file_munge_filename().
|
||||
* Undoes the effect of file_munge_filename().
|
||||
*
|
||||
* @param $filename
|
||||
* String with the filename to be unmunged.
|
||||
|
@ -1160,7 +1155,7 @@ function file_unmunge_filename($filename) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a full file path from a directory and filename.
|
||||
* Creates a full file path from a directory and filename.
|
||||
*
|
||||
* If a file with the specified name already exists, an alternative will be
|
||||
* used.
|
||||
|
@ -1215,7 +1210,7 @@ function file_create_filename($basename, $directory) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete a file and its database record.
|
||||
* Deletes a file and its database record.
|
||||
*
|
||||
* If the $force parameter is not TRUE, file_usage_list() will be called to
|
||||
* determine if the file is being used by any modules. If the file is being
|
||||
|
@ -1276,8 +1271,7 @@ function file_delete(stdClass $file, $force = FALSE) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete a file without calling any hooks or making any changes to the
|
||||
* database.
|
||||
* Deletes a file without database changes or hook invocations.
|
||||
*
|
||||
* This function should be used when the file to be deleted does not have an
|
||||
* entry recorded in the files table.
|
||||
|
@ -1313,7 +1307,7 @@ function file_unmanaged_delete($path) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Recursively delete all files and directories in the specified filepath.
|
||||
* Deletes all files and directories in the specified filepath recursively.
|
||||
*
|
||||
* If the specified path is a directory then the function will call itself
|
||||
* recursively to process the contents. Once the contents have been removed the
|
||||
|
@ -1351,7 +1345,7 @@ function file_unmanaged_delete_recursive($path) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Determine total disk space used by a single user or the whole filesystem.
|
||||
* Determines total disk space used by a single user or the whole filesystem.
|
||||
*
|
||||
* @param $uid
|
||||
* Optional. A user id, specifying NULL returns the total space used by all
|
||||
|
@ -1588,7 +1582,6 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
|
|||
* or open_basedir are enabled, so this function fills that gap.
|
||||
*
|
||||
* Compatibility: normal paths and stream wrappers.
|
||||
* @see http://drupal.org/node/515192
|
||||
*
|
||||
* @param $filename
|
||||
* The filename of the uploaded file.
|
||||
|
@ -1599,6 +1592,7 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
|
|||
* TRUE on success, or FALSE on failure.
|
||||
*
|
||||
* @see move_uploaded_file()
|
||||
* @see http://drupal.org/node/515192
|
||||
* @ingroup php_wrappers
|
||||
*/
|
||||
function drupal_move_uploaded_file($filename, $uri) {
|
||||
|
@ -1619,7 +1613,7 @@ function drupal_move_uploaded_file($filename, $uri) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that a file meets the criteria specified by the validators.
|
||||
* Checks that a file meets the criteria specified by the validators.
|
||||
*
|
||||
* After executing the validator callbacks specified hook_file_validate() will
|
||||
* also be called to allow other modules to report errors about the file.
|
||||
|
@ -1654,10 +1648,11 @@ function file_validate(stdClass &$file, $validators = array()) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check for files with names longer than we can store in the database.
|
||||
* Checks for files with names longer than can be stored in the database.
|
||||
*
|
||||
* @param $file
|
||||
* A Drupal file object.
|
||||
*
|
||||
* @return
|
||||
* An array. If the file name is too long, it will contain an error message.
|
||||
*/
|
||||
|
@ -1674,7 +1669,7 @@ function file_validate_name_length(stdClass $file) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that the filename ends with an allowed extension.
|
||||
* Checks that the filename ends with an allowed extension.
|
||||
*
|
||||
* @param $file
|
||||
* A Drupal file object.
|
||||
|
@ -1698,7 +1693,7 @@ function file_validate_extensions(stdClass $file, $extensions) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that the file's size is below certain limits.
|
||||
* Checks that the file's size is below certain limits.
|
||||
*
|
||||
* This check is not enforced for the user #1.
|
||||
*
|
||||
|
@ -1737,7 +1732,7 @@ function file_validate_size(stdClass $file, $file_limit = 0, $user_limit = 0) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that the file is recognized by image_get_info() as an image.
|
||||
* Checks that the file is recognized by image_get_info() as an image.
|
||||
*
|
||||
* @param $file
|
||||
* A Drupal file object.
|
||||
|
@ -1759,7 +1754,7 @@ function file_validate_is_image(stdClass $file) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Verify that image dimensions are within the specified maximum and minimum.
|
||||
* Verifies that image dimensions are within the specified maximum and minimum.
|
||||
*
|
||||
* Non-image files will be ignored. If a image toolkit is available the image
|
||||
* will be scaled to fit within the desired maximum dimensions.
|
||||
|
@ -1817,7 +1812,7 @@ function file_validate_image_resolution(stdClass $file, $maximum_dimensions = 0,
|
|||
}
|
||||
|
||||
/**
|
||||
* Save a string to the specified destination and create a database file entry.
|
||||
* Saves a file to the specified destination and creates a database entry.
|
||||
*
|
||||
* @param $data
|
||||
* A string containing the contents of the file.
|
||||
|
@ -1881,7 +1876,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
|
|||
}
|
||||
|
||||
/**
|
||||
* Save a string to the specified destination without invoking file API.
|
||||
* Saves a file to the specified destination without invoking file API.
|
||||
*
|
||||
* This function is identical to file_save_data() except the file will not be
|
||||
* saved to the {file_managed} table and none of the file_* hooks will be
|
||||
|
@ -1892,7 +1887,8 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
|
|||
* @param $destination
|
||||
* A string containing the destination location. This must be a stream wrapper
|
||||
* URI. If no value is provided, a randomized name will be generated and the
|
||||
* file will be saved using Drupal's default files scheme, usually "public://".
|
||||
* file will be saved using Drupal's default files scheme, usually
|
||||
* "public://".
|
||||
* @param $replace
|
||||
* Replace behavior when the destination file already exists:
|
||||
* - FILE_EXISTS_REPLACE - Replace the existing file.
|
||||
|
@ -1918,7 +1914,7 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX
|
|||
}
|
||||
|
||||
/**
|
||||
* Transfer file using HTTP to client.
|
||||
* Transfers a file to the client using HTTP.
|
||||
*
|
||||
* Pipes a file through Drupal to the client.
|
||||
*
|
||||
|
@ -1951,7 +1947,7 @@ function file_transfer($uri, $headers) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Menu handler for private file transfers.
|
||||
* Page callback: Handles private file transfers.
|
||||
*
|
||||
* Call modules that implement hook_file_download() to find out if a file is
|
||||
* accessible and what headers it should be transferred with. If one or more
|
||||
|
@ -1961,6 +1957,7 @@ function file_transfer($uri, $headers) {
|
|||
* If the file does not exist drupal_not_found() will be returned.
|
||||
*
|
||||
* @see hook_file_download()
|
||||
* @see system_menu()
|
||||
*/
|
||||
function file_download() {
|
||||
// Merge remainder of arguments from GET['q'], into relative file path.
|
||||
|
@ -2070,7 +2067,7 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Determine the maximum file upload size by querying the PHP settings.
|
||||
* Determines the maximum file upload size by querying the PHP settings.
|
||||
*
|
||||
* @return
|
||||
* A file size limit in bytes based on the PHP upload_max_filesize and
|
||||
|
@ -2094,7 +2091,7 @@ function file_upload_max_size() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Determine an Internet Media Type, or MIME type from a filename.
|
||||
* Determines an Internet Media Type or MIME type from a filename.
|
||||
*
|
||||
* @param $uri
|
||||
* A string containing the URI, path, or filename.
|
||||
|
@ -2123,7 +2120,7 @@ function file_get_mimetype($uri, $mapping = NULL) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the permissions on a file or directory.
|
||||
* Sets the permissions on a file or directory.
|
||||
*
|
||||
* This function will use the 'file_chmod_directory' and 'file_chmod_file'
|
||||
* variables for the default modes for directories and uploaded/generated
|
||||
|
@ -2229,10 +2226,11 @@ function drupal_unlink($uri, $context = NULL) {
|
|||
* The absolute local filesystem path (with no symbolic links), or FALSE on
|
||||
* failure.
|
||||
*
|
||||
* @todo This function is deprecated, and should be removed wherever possible.
|
||||
*
|
||||
* @see DrupalStreamWrapperInterface::realpath()
|
||||
* @see http://php.net/manual/function.realpath.php
|
||||
* @ingroup php_wrappers
|
||||
* @todo: This function is deprecated, and should be removed wherever possible.
|
||||
*/
|
||||
function drupal_realpath($uri) {
|
||||
// If this URI is a stream, pass it off to the appropriate stream wrapper.
|
||||
|
@ -2253,7 +2251,6 @@ function drupal_realpath($uri) {
|
|||
* PHP's dirname() as a fallback.
|
||||
*
|
||||
* Compatibility: normal paths and stream wrappers.
|
||||
* @see http://drupal.org/node/515192
|
||||
*
|
||||
* @param $uri
|
||||
* A URI or path.
|
||||
|
@ -2262,6 +2259,7 @@ function drupal_realpath($uri) {
|
|||
* A string containing the directory name.
|
||||
*
|
||||
* @see dirname()
|
||||
* @see http://drupal.org/node/515192
|
||||
* @ingroup php_wrappers
|
||||
*/
|
||||
function drupal_dirname($uri) {
|
||||
|
@ -2311,7 +2309,6 @@ function drupal_basename($uri, $suffix = NULL) {
|
|||
* is not provided, this function will make sure that Drupal's is used.
|
||||
*
|
||||
* Compatibility: normal paths and stream wrappers.
|
||||
* @see http://drupal.org/node/515192
|
||||
*
|
||||
* @param $uri
|
||||
* A URI or pathname.
|
||||
|
@ -2326,6 +2323,7 @@ function drupal_basename($uri, $suffix = NULL) {
|
|||
* Boolean TRUE on success, or FALSE on failure.
|
||||
*
|
||||
* @see mkdir()
|
||||
* @see http://drupal.org/node/515192
|
||||
* @ingroup php_wrappers
|
||||
*/
|
||||
function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) {
|
||||
|
@ -2342,7 +2340,7 @@ function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Remove a directory.
|
||||
* Removes a directory.
|
||||
*
|
||||
* PHP's rmdir() is broken on Windows, as it can fail to remove a directory
|
||||
* when it has a read-only flag set.
|
||||
|
@ -2379,7 +2377,6 @@ function drupal_rmdir($uri, $context = NULL) {
|
|||
* given a filepath.
|
||||
*
|
||||
* Compatibility: normal paths and stream wrappers.
|
||||
* @see http://drupal.org/node/515192
|
||||
*
|
||||
* @param $directory
|
||||
* The directory where the temporary filename will be created.
|
||||
|
@ -2391,6 +2388,7 @@ function drupal_rmdir($uri, $context = NULL) {
|
|||
* The new temporary filename, or FALSE on failure.
|
||||
*
|
||||
* @see tempnam()
|
||||
* @see http://drupal.org/node/515192
|
||||
* @ingroup php_wrappers
|
||||
*/
|
||||
function drupal_tempnam($directory, $prefix) {
|
||||
|
@ -2413,7 +2411,7 @@ function drupal_tempnam($directory, $prefix) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the path of system-appropriate temporary directory.
|
||||
* Gets the path of system-appropriate temporary directory.
|
||||
*/
|
||||
function file_directory_temp() {
|
||||
$temporary_directory = variable_get('file_temporary_path', NULL);
|
||||
|
@ -2466,6 +2464,7 @@ function file_directory_temp() {
|
|||
*
|
||||
* @param $file
|
||||
* A file object.
|
||||
*
|
||||
* @return
|
||||
* An associative array of headers, as expected by file_transfer().
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Functions for form and batch generation and processing.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup forms Form builder functions
|
||||
* @{
|
||||
|
@ -90,7 +95,11 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Wrapper for drupal_build_form() for use when $form_state is not needed.
|
||||
* Returns a renderable form array for a given form ID.
|
||||
*
|
||||
* This function should be used instead of drupal_build_form() when $form_state
|
||||
* is not needed (i.e., when initially rendering the form) and is often
|
||||
* used as a menu callback.
|
||||
*
|
||||
* @param $form_id
|
||||
* The unique string identifying the desired form. If a function with that
|
||||
|
@ -124,7 +133,7 @@ function drupal_get_form($form_id) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Build and process a form based on a form id.
|
||||
* Builds and processes a form for a given form ID.
|
||||
*
|
||||
* The form may also be retrieved from the cache if the form was built in a
|
||||
* previous page-load. The form is then passed on for processing, validation
|
||||
|
@ -207,8 +216,8 @@ function drupal_get_form($form_id) {
|
|||
* validation functions and submit functions use this array for nearly all
|
||||
* their decision making. (Note that
|
||||
* @link http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/7#tree #tree @endlink
|
||||
* determines whether the values are a flat array or an array whose structure
|
||||
* parallels the $form array.)
|
||||
* determines whether the values are a flat array or an array whose
|
||||
* structure parallels the $form array.)
|
||||
* - input: The array of values as they were submitted by the user. These are
|
||||
* raw and unvalidated, so should not be used without a thorough
|
||||
* understanding of security implications. In almost all cases, code should
|
||||
|
@ -376,7 +385,7 @@ function drupal_build_form($form_id, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieve default values for the $form_state array.
|
||||
* Retrieves default values for the $form_state array.
|
||||
*/
|
||||
function form_state_defaults() {
|
||||
return array(
|
||||
|
@ -482,7 +491,7 @@ function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Fetch a form from cache.
|
||||
* Fetches a form from the cache.
|
||||
*/
|
||||
function form_get_cache($form_build_id, &$form_state) {
|
||||
if ($cached = cache('form')->get('form_' . $form_build_id)) {
|
||||
|
@ -513,7 +522,7 @@ function form_get_cache($form_build_id, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Store a form in the cache.
|
||||
* Stores a form in the cache.
|
||||
*/
|
||||
function form_set_cache($form_build_id, $form, $form_state) {
|
||||
// 6 hours cache life time for forms should be plenty.
|
||||
|
@ -563,7 +572,7 @@ function form_state_keys_no_cache() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Loads an include file and makes sure it is loaded whenever the form is processed.
|
||||
* Ensures an include file is loaded loaded whenever the form is processed.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
|
@ -939,9 +948,10 @@ function drupal_process_form($form_id, &$form, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Prepares a structured form array by adding required elements,
|
||||
* executing any hook_form_alter functions, and optionally inserting
|
||||
* a validation token to prevent tampering.
|
||||
* Prepares a structured form array.
|
||||
*
|
||||
* Adds required elements, executes any hook_form_alter functions, and
|
||||
* optionally inserts a validation token to prevent tampering.
|
||||
*
|
||||
* @param $form_id
|
||||
* A unique string identifying the form for validation, submission,
|
||||
|
@ -1069,8 +1079,7 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
|
|||
|
||||
|
||||
/**
|
||||
* Validates user-submitted form data from the $form_state using
|
||||
* the validate functions defined in a structured form array.
|
||||
* Validates user-submitted form data in the $form_state array.
|
||||
*
|
||||
* @param $form_id
|
||||
* A unique string identifying the form for validation, submission,
|
||||
|
@ -1244,9 +1253,11 @@ function drupal_redirect_form($form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Performs validation on form elements. First ensures required fields are
|
||||
* completed, #maxlength is not exceeded, and selected options were in the
|
||||
* list of options given to the user. Then calls user-defined validators.
|
||||
* Performs validation on form elements.
|
||||
*
|
||||
* First ensures required fields are completed, #maxlength is not exceeded, and
|
||||
* selected options were in the list of options given to the user. Then calls
|
||||
* user-defined validators.
|
||||
*
|
||||
* @param $elements
|
||||
* An associative array containing the structure of the form.
|
||||
|
@ -1398,9 +1409,10 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) {
|
|||
}
|
||||
|
||||
/**
|
||||
* A helper function used to execute custom validation and submission
|
||||
* handlers for a given form. Button-specific handlers are checked
|
||||
* first. If none exist, the function falls back to form-level handlers.
|
||||
* Executes custom validation and submission handlers for a given form.
|
||||
*
|
||||
* Button-specific handlers are checked first. If none exist, the function
|
||||
* falls back to form-level handlers.
|
||||
*
|
||||
* @param $type
|
||||
* The type of handler to execute. 'validate' or 'submit' are the
|
||||
|
@ -1522,8 +1534,6 @@ function form_execute_handlers($type, &$form, &$form_state) {
|
|||
* doing anything with that data that requires it to be valid, PHP errors
|
||||
* would be triggered if the input processing and validation steps were fully
|
||||
* skipped.
|
||||
* @see http://drupal.org/node/370537
|
||||
* @see http://drupal.org/node/763376
|
||||
*
|
||||
* @param $name
|
||||
* The name of the form element. If the #parents property of your form
|
||||
|
@ -1539,6 +1549,9 @@ function form_execute_handlers($type, &$form, &$form_state) {
|
|||
* @return
|
||||
* Return value is for internal use only. To get a list of errors, use
|
||||
* form_get_errors() or form_get_error().
|
||||
*
|
||||
* @see http://drupal.org/node/370537
|
||||
* @see http://drupal.org/node/763376
|
||||
*/
|
||||
function form_set_error($name = NULL, $message = '', $limit_validation_errors = NULL) {
|
||||
$form = &drupal_static(__FUNCTION__, array());
|
||||
|
@ -1584,14 +1597,14 @@ function form_set_error($name = NULL, $message = '', $limit_validation_errors =
|
|||
}
|
||||
|
||||
/**
|
||||
* Clear all errors against all form elements made by form_set_error().
|
||||
* Clears all errors against all form elements made by form_set_error().
|
||||
*/
|
||||
function form_clear_error() {
|
||||
drupal_static_reset('form_set_error');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an associative array of all errors.
|
||||
* Returns an associative array of all errors.
|
||||
*/
|
||||
function form_get_errors() {
|
||||
$form = form_set_error();
|
||||
|
@ -1619,16 +1632,18 @@ function form_get_error($element) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Flag an element as having an error.
|
||||
* Flags an element as having an error.
|
||||
*/
|
||||
function form_error(&$element, $message = '') {
|
||||
form_set_error(implode('][', $element['#parents']), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Walk through the structured form array, adding any required properties to
|
||||
* each element and mapping the incoming input data to the proper elements.
|
||||
* Also, execute any #process handlers attached to a specific element.
|
||||
* Builds and processes all elements in the structured form array.
|
||||
*
|
||||
* Adds any required properties to each element, maps the incoming input data
|
||||
* to the proper elements, and executes any #process handlers attached to a
|
||||
* specific element.
|
||||
*
|
||||
* This is one of the three primary functions that recursively iterates a form
|
||||
* array. This one does it for completing the form building process. The other
|
||||
|
@ -1900,8 +1915,7 @@ function form_builder($form_id, &$element, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Populate the #value and #name properties of input elements so they
|
||||
* can be processed and rendered.
|
||||
* Adds the #name and #value properties of an input element before rendering.
|
||||
*/
|
||||
function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
|
||||
if (!isset($element['#name'])) {
|
||||
|
@ -2040,7 +2054,7 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function to handle the convoluted logic of button click detection.
|
||||
* Detects if an element triggered the form submission via Ajax.
|
||||
*
|
||||
* This detects button or non-button controls that trigger a form submission via
|
||||
* Ajax or some other scriptable environment. These environments can set the
|
||||
|
@ -2060,7 +2074,7 @@ function _form_element_triggered_scripted_submission($element, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function to handle the convoluted logic of button click detection.
|
||||
* Determines if a given button triggered the form submission.
|
||||
*
|
||||
* This detects button controls that trigger a form submission by being clicked
|
||||
* and having the click processed by the browser rather than being captured by
|
||||
|
@ -2155,7 +2169,7 @@ function form_state_values_clean(&$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine the value for an image button form element.
|
||||
* Determines the value for an image button form element.
|
||||
*
|
||||
* @param $form
|
||||
* The form element whose value is being populated.
|
||||
|
@ -2164,6 +2178,7 @@ function form_state_values_clean(&$form_state) {
|
|||
* the element's default value should be returned.
|
||||
* @param $form_state
|
||||
* A keyed array containing the current state of the form.
|
||||
*
|
||||
* @return
|
||||
* The data that will appear in the $form_state['values'] collection
|
||||
* for this element. Return nothing to use the default.
|
||||
|
@ -2202,13 +2217,14 @@ function form_type_image_button_value($form, $input, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine the value for a checkbox form element.
|
||||
* Determines the value for a checkbox form element.
|
||||
*
|
||||
* @param $form
|
||||
* The form element whose value is being populated.
|
||||
* @param $input
|
||||
* @param $input
|
||||
* The incoming input to populate the form element. If this is FALSE,
|
||||
* the element's default value should be returned.
|
||||
*
|
||||
* @return
|
||||
* The data that will appear in the $element_state['values'] collection
|
||||
* for this element. Return nothing to use the default.
|
||||
|
@ -2242,13 +2258,14 @@ function form_type_checkbox_value($element, $input = FALSE) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine the value for a checkboxes form element.
|
||||
* Determines the value for a checkboxes form element.
|
||||
*
|
||||
* @param $element
|
||||
* The form element whose value is being populated.
|
||||
* @param $input
|
||||
* The incoming input to populate the form element. If this is FALSE,
|
||||
* the element's default value should be returned.
|
||||
*
|
||||
* @return
|
||||
* The data that will appear in the $element_state['values'] collection
|
||||
* for this element. Return nothing to use the default.
|
||||
|
@ -2282,13 +2299,14 @@ function form_type_checkboxes_value($element, $input = FALSE) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine the value for a tableselect form element.
|
||||
* Determines the value for a tableselect form element.
|
||||
*
|
||||
* @param $element
|
||||
* The form element whose value is being populated.
|
||||
* @param $input
|
||||
* The incoming input to populate the form element. If this is FALSE,
|
||||
* the element's default value should be returned.
|
||||
*
|
||||
* @return
|
||||
* The data that will appear in the $element_state['values'] collection
|
||||
* for this element. Return nothing to use the default.
|
||||
|
@ -2317,14 +2335,14 @@ function form_type_tableselect_value($element, $input = FALSE) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine the value for a password_confirm form
|
||||
* element.
|
||||
* Determines the value for a password_confirm form element.
|
||||
*
|
||||
* @param $element
|
||||
* The form element whose value is being populated.
|
||||
* @param $input
|
||||
* The incoming input to populate the form element. If this is FALSE,
|
||||
* the element's default value should be returned.
|
||||
*
|
||||
* @return
|
||||
* The data that will appear in the $element_state['values'] collection
|
||||
* for this element. Return nothing to use the default.
|
||||
|
@ -2337,13 +2355,14 @@ function form_type_password_confirm_value($element, $input = FALSE) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine the value for a select form element.
|
||||
* Determines the value for a select form element.
|
||||
*
|
||||
* @param $element
|
||||
* The form element whose value is being populated.
|
||||
* @param $input
|
||||
* The incoming input to populate the form element. If this is FALSE,
|
||||
* the element's default value should be returned.
|
||||
*
|
||||
* @return
|
||||
* The data that will appear in the $element_state['values'] collection
|
||||
* for this element. Return nothing to use the default.
|
||||
|
@ -2377,13 +2396,14 @@ function form_type_select_value($element, $input = FALSE) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine the value for a textfield form element.
|
||||
* Determines the value for a textfield form element.
|
||||
*
|
||||
* @param $element
|
||||
* The form element whose value is being populated.
|
||||
* @param $input
|
||||
* The incoming input to populate the form element. If this is FALSE,
|
||||
* the element's default value should be returned.
|
||||
*
|
||||
* @return
|
||||
* The data that will appear in the $element_state['values'] collection
|
||||
* for this element. Return nothing to use the default.
|
||||
|
@ -2397,13 +2417,14 @@ function form_type_textfield_value($element, $input = FALSE) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine the value for form's token value.
|
||||
* Determines the value for form's token value.
|
||||
*
|
||||
* @param $element
|
||||
* The form element whose value is being populated.
|
||||
* @param $input
|
||||
* The incoming input to populate the form element. If this is FALSE,
|
||||
* the element's default value should be returned.
|
||||
*
|
||||
* @return
|
||||
* The data that will appear in the $element_state['values'] collection
|
||||
* for this element. Return nothing to use the default.
|
||||
|
@ -2415,7 +2436,7 @@ function form_type_token_value($element, $input = FALSE) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Change submitted form values during form validation.
|
||||
* Changes submitted form values during form validation.
|
||||
*
|
||||
* Use this function to change the submitted value of a form element in a form
|
||||
* validation function, so that the changed value persists in $form_state
|
||||
|
@ -2465,11 +2486,9 @@ function form_options_flatten($array) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function for form_options_flatten().
|
||||
* Iterates over an array and returns a flat array with duplicate keys removed.
|
||||
*
|
||||
* Iterates over arrays which may share common values and produces a flat
|
||||
* array that has removed duplicate keys. Also handles cases where objects
|
||||
* are passed as array values.
|
||||
* This function also handles cases where objects are passed as array values.
|
||||
*/
|
||||
function _form_options_flatten($array) {
|
||||
$return = &drupal_static(__FUNCTION__);
|
||||
|
@ -2579,7 +2598,7 @@ function theme_select($variables) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Converts a select form element's options array into an HTML.
|
||||
* Converts a select form element's options array into HTML.
|
||||
*
|
||||
* @param $element
|
||||
* An associative array containing the properties of the element.
|
||||
|
@ -2587,6 +2606,7 @@ function theme_select($variables) {
|
|||
* Mixed: Either an associative array of items to list as choices, or an
|
||||
* object with an 'option' member that is an associative array. This
|
||||
* parameter is only used internally and should not be passed.
|
||||
*
|
||||
* @return
|
||||
* An HTML string of options for the select form element.
|
||||
*/
|
||||
|
@ -2623,8 +2643,7 @@ function form_select_options($element, $choices = NULL) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Traverses a select element's #option array looking for any values
|
||||
* that hold the given key. Returns an array of indexes that match.
|
||||
* Returns the indexes of a select element's options matching a given key.
|
||||
*
|
||||
* This function is useful if you need to modify the options that are
|
||||
* already in a form element; for example, to remove choices which are
|
||||
|
@ -2650,6 +2669,7 @@ function form_select_options($element, $choices = NULL) {
|
|||
* The select element to search.
|
||||
* @param $key
|
||||
* The key to look for.
|
||||
*
|
||||
* @return
|
||||
* An array of indexes that match the given $key. Array will be
|
||||
* empty if no elements were found. FALSE if optgroups were found.
|
||||
|
@ -2786,7 +2806,7 @@ function form_process_password_confirm($element) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Validate password_confirm element.
|
||||
* Validates a password_confirm element.
|
||||
*/
|
||||
function password_confirm_validate($element, &$element_state) {
|
||||
$pass1 = trim($element['pass1']['#value']);
|
||||
|
@ -2837,7 +2857,7 @@ function theme_date($variables) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Roll out a single date element.
|
||||
* Expands a date element into year, month, and day select elements.
|
||||
*/
|
||||
function form_process_date($element) {
|
||||
// Default to current date
|
||||
|
@ -2893,7 +2913,7 @@ function form_process_date($element) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Validates the date type to stop dates like February 30, 2006.
|
||||
* Validates the date type to prevent invalid dates (e.g., February 30, 2006).
|
||||
*/
|
||||
function date_validate($element) {
|
||||
if (!checkdate($element['#value']['month'], $element['#value']['day'], $element['#value']['year'])) {
|
||||
|
@ -2902,7 +2922,9 @@ function date_validate($element) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function for usage with drupal_map_assoc to display month names.
|
||||
* Renders a month name for display.
|
||||
*
|
||||
* Callback for drupal_map_assoc() within form_process_date().
|
||||
*/
|
||||
function map_month($month) {
|
||||
$months = &drupal_static(__FUNCTION__, array(
|
||||
|
@ -2923,7 +2945,7 @@ function map_month($month) {
|
|||
}
|
||||
|
||||
/**
|
||||
* If no default value is set for weight select boxes, use 0.
|
||||
* Sets the value for a weight element, with zero as a default.
|
||||
*/
|
||||
function weight_value(&$form) {
|
||||
if (isset($form['#default_value'])) {
|
||||
|
@ -2935,8 +2957,7 @@ function weight_value(&$form) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Roll out a single radios element to a list of radios,
|
||||
* using the options array as index.
|
||||
* Expands a radios element into individual radio elements.
|
||||
*/
|
||||
function form_process_radios($element) {
|
||||
if (count($element['#options']) > 0) {
|
||||
|
@ -3019,7 +3040,7 @@ function theme_checkboxes($variables) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add form_element theming to an element if title or description is set.
|
||||
* Adds form element theming to an element if its title or description is set.
|
||||
*
|
||||
* This is used as a pre render function for checkboxes and radios.
|
||||
*/
|
||||
|
@ -3066,6 +3087,9 @@ function form_process_checkbox($element, $form_state) {
|
|||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a checkboxes form element.
|
||||
*/
|
||||
function form_process_checkboxes($element) {
|
||||
$value = is_array($element['#value']) ? $element['#value'] : array();
|
||||
$element['#tree'] = TRUE;
|
||||
|
@ -3127,6 +3151,7 @@ function form_process_actions($element, &$form_state) {
|
|||
* container.
|
||||
* @param $form_state
|
||||
* The $form_state array for the form this element belongs to.
|
||||
*
|
||||
* @return
|
||||
* The processed element.
|
||||
*/
|
||||
|
@ -3237,11 +3262,12 @@ function theme_tableselect($variables) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create the correct amount of checkbox or radio elements to populate the table.
|
||||
* Creates checkbox or radio elements to populate a tableselect table.
|
||||
*
|
||||
* @param $element
|
||||
* An associative array containing the properties and children of the
|
||||
* tableselect element.
|
||||
*
|
||||
* @return
|
||||
* The processed element.
|
||||
*/
|
||||
|
@ -3405,7 +3431,7 @@ function form_process_machine_name($element, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Form element validation handler for #type 'machine_name'.
|
||||
* Form element validation handler for machine_name elements.
|
||||
*
|
||||
* Note that #maxlength is validated by _form_validate() already.
|
||||
*/
|
||||
|
@ -3443,8 +3469,7 @@ function form_validate_machine_name(&$element, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds fieldsets to the specified group or adds group members to this
|
||||
* fieldset.
|
||||
* Arranges fieldsets into groups.
|
||||
*
|
||||
* @param $element
|
||||
* An associative array containing the properties and children of the
|
||||
|
@ -3452,6 +3477,7 @@ function form_validate_machine_name(&$element, &$form_state) {
|
|||
* child elements are taken over into $form_state.
|
||||
* @param $form_state
|
||||
* The $form_state array for the form this fieldset belongs to.
|
||||
*
|
||||
* @return
|
||||
* The processed element.
|
||||
*/
|
||||
|
@ -3555,6 +3581,7 @@ function form_pre_render_fieldset($element) {
|
|||
* fieldset.
|
||||
* @param $form_state
|
||||
* The $form_state array for the form this vertical tab widget belongs to.
|
||||
*
|
||||
* @return
|
||||
* The processed element.
|
||||
*/
|
||||
|
@ -3589,8 +3616,8 @@ function form_process_vertical_tabs($element, &$form_state) {
|
|||
*
|
||||
* @param $variables
|
||||
* An associative array containing:
|
||||
* - element: An associative array containing the properties and children of the
|
||||
* fieldset. Properties used: #children.
|
||||
* - element: An associative array containing the properties and children of
|
||||
* the fieldset. Properties used: #children.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
|
@ -3835,7 +3862,7 @@ function theme_password($variables) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Expand weight elements into selects.
|
||||
* Expands a weight element into a select element.
|
||||
*/
|
||||
function form_process_weight($element) {
|
||||
$element['#is_weight'] = TRUE;
|
||||
|
@ -4019,7 +4046,8 @@ function theme_form_required_marker($variables) {
|
|||
*
|
||||
* Form element labels include the #title and a #required marker. The label is
|
||||
* associated with the element itself by the element #id. Labels may appear
|
||||
* before or after elements, depending on theme_form_element() and #title_display.
|
||||
* before or after elements, depending on theme_form_element() and
|
||||
* #title_display.
|
||||
*
|
||||
* This function will not be called for elements with no labels, depending on
|
||||
* #title_display. For elements that have an empty #title and are not required,
|
||||
|
@ -4098,7 +4126,7 @@ function _form_set_class(&$element, $class = array()) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper form element validator: integer.
|
||||
* Form element validation handler for integer elements.
|
||||
*/
|
||||
function element_validate_integer($element, &$form_state) {
|
||||
$value = $element['#value'];
|
||||
|
@ -4108,7 +4136,7 @@ function element_validate_integer($element, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper form element validator: integer > 0.
|
||||
* Form element validation handler for integer elements that must be positive.
|
||||
*/
|
||||
function element_validate_integer_positive($element, &$form_state) {
|
||||
$value = $element['#value'];
|
||||
|
@ -4118,7 +4146,7 @@ function element_validate_integer_positive($element, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper form element validator: number.
|
||||
* Form element validation handler for number elements.
|
||||
*/
|
||||
function element_validate_number($element, &$form_state) {
|
||||
$value = $element['#value'];
|
||||
|
@ -4134,7 +4162,7 @@ function element_validate_number($element, &$form_state) {
|
|||
/**
|
||||
* @defgroup batch Batch operations
|
||||
* @{
|
||||
* Create and process batch operations.
|
||||
* Creates and processes batch operations.
|
||||
*
|
||||
* Functions allowing forms processing to be spread out over several page
|
||||
* requests, thus ensuring that the processing does not get interrupted
|
||||
|
@ -4282,7 +4310,7 @@ function element_validate_number($element, &$form_state) {
|
|||
* clean code independence, ensuring that several batches submitted by
|
||||
* different parts of the code (core / contrib modules) can be processed
|
||||
* correctly while not interfering or having to cope with each other. Each
|
||||
* batch set gets to specify his own UI messages, operates on its own set
|
||||
* batch set gets to specify its own UI messages, operates on its own set
|
||||
* of operations and results, and triggers its own 'finished' callback.
|
||||
* Batch sets are processed sequentially, with the progress bar starting
|
||||
* fresh for every new set.
|
||||
|
@ -4463,6 +4491,7 @@ function &batch_get() {
|
|||
* The batch array.
|
||||
* @param $set_id
|
||||
* The id of the set to process.
|
||||
*
|
||||
* @return
|
||||
* The name and class of the queue are added by reference to the batch set.
|
||||
*/
|
||||
|
@ -4492,6 +4521,7 @@ function _batch_populate_queue(&$batch, $set_id) {
|
|||
*
|
||||
* @param $batch_set
|
||||
* The batch set.
|
||||
*
|
||||
* @return
|
||||
* The queue object.
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Parses Gettext Portable Object file information and inserts into database
|
||||
* Parses Gettext Portable Object information and inserts it into the database.
|
||||
*
|
||||
* @param $file
|
||||
* Drupal file object corresponding to the PO file to import.
|
||||
|
@ -74,7 +74,7 @@ function _locale_import_po($file, $langcode, $mode) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Parses Gettext Portable Object file into an array
|
||||
* Parses a Gettext Portable Object file into an array.
|
||||
*
|
||||
* @param $op
|
||||
* Storage operation type: db-store or mem-store.
|
||||
|
@ -335,7 +335,7 @@ function _locale_import_read_po($op, $file, $mode = NULL, $lang = NULL) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets an error message occurred during locale file parsing.
|
||||
* Sets an error message if an error occurred during locale file parsing.
|
||||
*
|
||||
* @param $message
|
||||
* The message to be translated.
|
||||
|
@ -354,7 +354,7 @@ function _locale_import_message($message, $file, $lineno = NULL) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Imports a string into the database
|
||||
* Performs the specified operation for one string.
|
||||
*
|
||||
* @param $op
|
||||
* Operation to perform: 'db-store', 'db-report', 'mem-store' or 'mem-report'.
|
||||
|
@ -399,20 +399,16 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL
|
|||
// data untouched or if we don't have an existing plural formula.
|
||||
$header = _locale_import_parse_header($value['msgstr']);
|
||||
|
||||
// Get the plural formula and update in database.
|
||||
// Get and store the plural formula if available.
|
||||
if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->uri)) {
|
||||
list($nplurals, $formula) = $p;
|
||||
}
|
||||
else {
|
||||
$nplurals = 0;
|
||||
$formula = '';
|
||||
}
|
||||
$locale_plurals[$lang] = array(
|
||||
'plurals' => $nplurals,
|
||||
'formula' => $formula,
|
||||
);
|
||||
variable_set('locale_translation_plurals', $locale_plurals);
|
||||
}
|
||||
}
|
||||
$header_done = TRUE;
|
||||
}
|
||||
|
||||
|
@ -448,7 +444,7 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL
|
|||
}
|
||||
|
||||
/**
|
||||
* Import one string into the database.
|
||||
* Imports one string into the database.
|
||||
*
|
||||
* @param $report
|
||||
* Report array summarizing the number of changes done in the form:
|
||||
|
@ -562,7 +558,7 @@ function _locale_import_one_string_db(&$report, $langcode, $context, $source, $t
|
|||
}
|
||||
|
||||
/**
|
||||
* Parses a Gettext Portable Object file header
|
||||
* Parses a Gettext Portable Object file header.
|
||||
*
|
||||
* @param $header
|
||||
* A string containing the complete header.
|
||||
|
@ -583,7 +579,7 @@ function _locale_import_parse_header($header) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Parses a Plural-Forms entry from a Gettext Portable Object file header
|
||||
* Parses a Plural-Forms entry from a Gettext Portable Object file header.
|
||||
*
|
||||
* @param $pluralforms
|
||||
* A string containing the Plural-Forms entry.
|
||||
|
@ -627,7 +623,7 @@ function _locale_import_parse_plural_forms($pluralforms, $filepath) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Parses and sanitizes an arithmetic formula into a PHP expression
|
||||
* Parses and sanitizes an arithmetic formula into a PHP expression.
|
||||
*
|
||||
* While parsing, we ensure, that the operators have the right
|
||||
* precedence and associativity.
|
||||
|
@ -730,7 +726,7 @@ function _locale_import_parse_arithmetic($string) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Backward compatible implementation of token_get_all() for formula parsing
|
||||
* Provides backward-compatible formula parsing for token_get_all().
|
||||
*
|
||||
* @param $string
|
||||
* A string containing the arithmetic formula.
|
||||
|
@ -795,9 +791,9 @@ function _locale_import_tokenize_formula($formula) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Modify a string to contain proper count indices
|
||||
* Adds count indices to a string.
|
||||
*
|
||||
* This is a callback function used via array_map()
|
||||
* Callback for array_map() within _locale_import_one_string().
|
||||
*
|
||||
* @param $entry
|
||||
* An array element.
|
||||
|
@ -816,13 +812,13 @@ function _locale_import_append_plural($entry, $key) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generate a short, one string version of the passed comment array
|
||||
* Generates a short, one-string version of the passed comment array.
|
||||
*
|
||||
* @param $comment
|
||||
* An array of strings containing a comment.
|
||||
*
|
||||
* @return
|
||||
* Short one string version of the comment.
|
||||
* Short one-string version of the comment.
|
||||
*/
|
||||
function _locale_import_shorten_comments($comment) {
|
||||
$comm = '';
|
||||
|
@ -839,7 +835,7 @@ function _locale_import_shorten_comments($comment) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Parses a string in quotes
|
||||
* Parses a string in quotes.
|
||||
*
|
||||
* @param $string
|
||||
* A string specified with enclosing quotes.
|
||||
|
@ -865,13 +861,14 @@ function _locale_import_parse_quoted($string) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generates a structured array of all strings with translations in
|
||||
* $language, if given. This array can be used to generate an export
|
||||
* of the string in the database.
|
||||
* Generates a structured array of all translated strings for the language.
|
||||
*
|
||||
* @param $language
|
||||
* Language object to generate the output for, or NULL if generating
|
||||
* translation template.
|
||||
*
|
||||
* @return
|
||||
* An array of translated strings that can be used to generate an export.
|
||||
*/
|
||||
function _locale_export_get_strings($language = NULL) {
|
||||
if (isset($language)) {
|
||||
|
@ -902,7 +899,7 @@ function _locale_export_get_strings($language = NULL) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generates the PO(T) file contents for given strings.
|
||||
* Generates the PO(T) file contents for the given strings.
|
||||
*
|
||||
* @param $language
|
||||
* Language object to generate the output for, or NULL if generating
|
||||
|
@ -999,7 +996,7 @@ function _locale_export_po_generate($language = NULL, $strings = array(), $heade
|
|||
}
|
||||
|
||||
/**
|
||||
* Write a generated PO or POT file to the output.
|
||||
* Writes a generated PO or POT file to the output.
|
||||
*
|
||||
* @param $language
|
||||
* Language object to generate the output for, or NULL if generating
|
||||
|
@ -1026,7 +1023,7 @@ function _locale_export_po($language = NULL, $output = NULL) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Print out a string on multiple lines
|
||||
* Prints a string on multiple lines.
|
||||
*/
|
||||
function _locale_export_string($str) {
|
||||
$stri = addcslashes($str, "\0..\37\\\"");
|
||||
|
@ -1062,7 +1059,7 @@ function _locale_export_string($str) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Custom word wrapping for Portable Object (Template) files.
|
||||
* Wraps text for Portable Object (Template) files.
|
||||
*/
|
||||
function _locale_export_wrap($str, $len) {
|
||||
$words = explode(' ', $str);
|
||||
|
@ -1090,7 +1087,7 @@ function _locale_export_wrap($str, $len) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes plural index information from a string
|
||||
* Removes plural index information from a string.
|
||||
*/
|
||||
function _locale_export_remove_plural($entry) {
|
||||
return preg_replace('/(@count)\[[0-9]\]/', '\\1', $entry);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
|
||||
/**
|
||||
* Perform a depth first sort on a directed acyclic graph.
|
||||
* Performs a depth-first sort on a directed acyclic graph.
|
||||
*
|
||||
* @param $graph
|
||||
* A three dimensional associated array, with the first keys being the names
|
||||
|
@ -72,7 +72,7 @@ function drupal_depth_first_search(&$graph) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function to perform a depth first sort.
|
||||
* Performs a depth-first sort on a graph.
|
||||
*
|
||||
* @param $graph
|
||||
* A three dimensional associated graph array.
|
||||
|
|
|
@ -741,7 +741,7 @@ function install_verify_requirements(&$install_state) {
|
|||
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 <a href="!url">proceed with the installation</a>.', array('!url' => check_url(drupal_requirements_url($severity))));
|
||||
$status_report .= st('Check the messages and <a href="!url">try again</a>.', array('!url' => check_url(drupal_requirements_url($severity))));
|
||||
return $status_report;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -11,11 +11,42 @@
|
|||
const LANGUAGE_NEGOTIATION_DEFAULT = 'language-default';
|
||||
|
||||
/**
|
||||
* Return all the defined language types.
|
||||
* Chooses a language for the given type based on language negotiation settings.
|
||||
*
|
||||
* @param $type
|
||||
* The language type key.
|
||||
*
|
||||
* @return
|
||||
* An array of language type names. The name will be used as the global
|
||||
* variable name the language value will be stored in.
|
||||
* The negotiated language object.
|
||||
*/
|
||||
function language_types_initialize($type) {
|
||||
// Execute the language providers in the order they were set up and return the
|
||||
// first valid language found.
|
||||
$negotiation = variable_get("language_negotiation_$type", array());
|
||||
|
||||
foreach ($negotiation as $provider_id => $provider) {
|
||||
$language = language_provider_invoke($provider_id, $provider);
|
||||
if ($language) {
|
||||
// Remember the provider key used to detect the language.
|
||||
$language->provider = $provider_id;
|
||||
return $language;
|
||||
}
|
||||
}
|
||||
|
||||
// If no other language was found use the default one.
|
||||
$language = language_default();
|
||||
$language->provider = LANGUAGE_NEGOTIATION_DEFAULT;
|
||||
return $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about all defined language types.
|
||||
*
|
||||
* @return
|
||||
* An associative array of language type information arrays keyed by type
|
||||
* names. Based on information from hook_language_types_info().
|
||||
*
|
||||
* @see hook_language_types_info().
|
||||
*/
|
||||
function language_types_info() {
|
||||
$language_types = &drupal_static(__FUNCTION__);
|
||||
|
@ -30,7 +61,7 @@ function language_types_info() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return only the configurable language types.
|
||||
* Returns only the configurable language types.
|
||||
*
|
||||
* A language type maybe configurable or fixed. A fixed language type is a type
|
||||
* whose negotiation values are unchangeable and defined while defining the
|
||||
|
@ -46,11 +77,11 @@ function language_types_info() {
|
|||
* @return
|
||||
* An array of language type names.
|
||||
*/
|
||||
function language_types_configurable($stored = TRUE) {
|
||||
function language_types_get_configurable($stored = TRUE) {
|
||||
$configurable = &drupal_static(__FUNCTION__);
|
||||
|
||||
if ($stored && !isset($configurable)) {
|
||||
$types = variable_get('language_types', drupal_language_types());
|
||||
$types = variable_get('language_types', language_types_get_default());
|
||||
$configurable = array_keys(array_filter($types));
|
||||
}
|
||||
|
||||
|
@ -74,7 +105,7 @@ function language_types_configurable($stored = TRUE) {
|
|||
* An array of language types.
|
||||
*/
|
||||
function language_types_disable($types) {
|
||||
$enabled_types = variable_get('language_types', drupal_language_types());
|
||||
$enabled_types = variable_get('language_types', language_types_get_default());
|
||||
|
||||
foreach ($types as $type) {
|
||||
unset($enabled_types[$type]);
|
||||
|
@ -96,6 +127,7 @@ function language_types_set() {
|
|||
// Determine which language types are configurable and which not by checking
|
||||
// whether the 'fixed' key is defined. Non-configurable (fixed) language types
|
||||
// have their language negotiation settings stored there.
|
||||
$language_types = array();
|
||||
$defined_providers = language_negotiation_info();
|
||||
foreach (language_types_info() as $type => $info) {
|
||||
if (isset($info['fixed'])) {
|
||||
|
@ -113,12 +145,12 @@ function language_types_set() {
|
|||
}
|
||||
}
|
||||
|
||||
// Save language types.
|
||||
// Save enabled language types.
|
||||
variable_set('language_types', $language_types);
|
||||
|
||||
// Ensure that subsequent calls of language_types_configurable() return the
|
||||
// updated language type information.
|
||||
drupal_static_reset('language_types_configurable');
|
||||
// Ensure that subsequent calls of language_types_get_configurable() return
|
||||
// the updated language type information.
|
||||
drupal_static_reset('language_types_get_configurable');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,7 +198,7 @@ function language_negotiation_get($type, $provider_id = NULL) {
|
|||
* provider is enabled, FALSE otherwise.
|
||||
*/
|
||||
function language_negotiation_get_any($provider_id) {
|
||||
foreach (language_types_configurable() as $type) {
|
||||
foreach (language_types_get_configurable() as $type) {
|
||||
if (language_negotiation_get($type, $provider_id)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -250,7 +282,7 @@ function language_negotiation_set($type, $language_providers) {
|
|||
$negotiation = array();
|
||||
$providers_weight = array();
|
||||
$defined_providers = language_negotiation_info();
|
||||
$default_types = language_types_configurable(FALSE);
|
||||
$default_types = language_types_get_configurable(FALSE);
|
||||
|
||||
// Initialize the providers weight list.
|
||||
foreach ($language_providers as $id => $provider) {
|
||||
|
@ -370,34 +402,6 @@ function language_provider_weight($provider) {
|
|||
return isset($provider['weight']) && is_numeric($provider['weight']) ? $provider['weight'] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose a language for the given type based on language negotiation settings.
|
||||
*
|
||||
* @param $type
|
||||
* The language type.
|
||||
*
|
||||
* @return
|
||||
* The negotiated language object.
|
||||
*/
|
||||
function language_initialize($type) {
|
||||
// Execute the language providers in the order they were set up and return the
|
||||
// first valid language found.
|
||||
$negotiation = variable_get("language_negotiation_$type", array());
|
||||
|
||||
foreach ($negotiation as $provider_id => $provider) {
|
||||
$language = language_provider_invoke($provider_id, $provider);
|
||||
if ($language) {
|
||||
$language->provider = $provider_id;
|
||||
return $language;
|
||||
}
|
||||
}
|
||||
|
||||
// If no other language was found use the default one.
|
||||
$language = language_default();
|
||||
$language->provider = LANGUAGE_NEGOTIATION_DEFAULT;
|
||||
return $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default language provider.
|
||||
*
|
||||
|
|
|
@ -112,8 +112,8 @@ const LANGUAGE_NEGOTIATION_URL_DOMAIN = 1;
|
|||
* The current interface language code.
|
||||
*/
|
||||
function locale_language_from_interface() {
|
||||
global $language;
|
||||
return isset($language->langcode) ? $language->langcode : FALSE;
|
||||
global $language_interface;
|
||||
return isset($language_interface->langcode) ? $language_interface->langcode : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -553,8 +553,6 @@ function locale_string_is_safe($string) {
|
|||
* Drupal.formatPlural() and inserts them into the database.
|
||||
*/
|
||||
function _locale_parse_js_file($filepath) {
|
||||
global $language;
|
||||
|
||||
// The file path might contain a query string, so make sure we only use the
|
||||
// actual file.
|
||||
$parsed_url = drupal_parse_url($filepath);
|
||||
|
@ -708,12 +706,13 @@ function _locale_invalidate_js($langcode = NULL) {
|
|||
/**
|
||||
* (Re-)Creates the JavaScript translation file for a language.
|
||||
*
|
||||
* @param $language
|
||||
* @param $langcode
|
||||
* The language, the translation file should be (re)created for.
|
||||
*/
|
||||
function _locale_rebuild_js($langcode = NULL) {
|
||||
if (!isset($langcode)) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
$language = $language_interface;
|
||||
}
|
||||
else {
|
||||
// Get information about the locale.
|
||||
|
|
|
@ -1092,7 +1092,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
|
|||
// Use $mlid as a flag for whether the data being loaded is for the whole tree.
|
||||
$mlid = isset($link['mlid']) ? $link['mlid'] : 0;
|
||||
// Generate a cache ID (cid) specific for this $menu_name, $link, $language, and depth.
|
||||
$cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $GLOBALS['language']->langcode . ':' . (int) $max_depth;
|
||||
$cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $GLOBALS['language_interface']->langcode . ':' . (int) $max_depth;
|
||||
|
||||
if (!isset($tree[$cid])) {
|
||||
// If the static variable doesn't have the data, check {cache_menu}.
|
||||
|
@ -1206,7 +1206,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
|
|||
$max_depth = min($max_depth, MENU_MAX_DEPTH);
|
||||
}
|
||||
// Generate a cache ID (cid) specific for this page.
|
||||
$cid = 'links:' . $menu_name . ':page:' . $item['href'] . ':' . $GLOBALS['language']->langcode . ':' . (int) $item['access'] . ':' . (int) $max_depth;
|
||||
$cid = 'links:' . $menu_name . ':page:' . $item['href'] . ':' . $GLOBALS['language_interface']->langcode . ':' . (int) $item['access'] . ':' . (int) $max_depth;
|
||||
// If we are asked for the active trail only, and $menu_name has not been
|
||||
// built and cached for this page yet, then this likely means that it
|
||||
// won't be built anymore, as this function is invoked from
|
||||
|
@ -1358,7 +1358,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) {
|
|||
if (isset($parameters['expanded'])) {
|
||||
sort($parameters['expanded']);
|
||||
}
|
||||
$tree_cid = 'links:' . $menu_name . ':tree-data:' . $GLOBALS['language']->langcode . ':' . hash('sha256', serialize($parameters));
|
||||
$tree_cid = 'links:' . $menu_name . ':tree-data:' . $GLOBALS['language_interface']->langcode . ':' . hash('sha256', serialize($parameters));
|
||||
|
||||
// If we do not have this tree in the static cache, check {cache_menu}.
|
||||
if (!isset($trees[$tree_cid])) {
|
||||
|
|
|
@ -2500,8 +2500,8 @@ function template_preprocess_html(&$variables) {
|
|||
$variables['body_attributes_array'] = array();
|
||||
|
||||
// HTML element attributes.
|
||||
$variables['html_attributes_array']['lang'] = $GLOBALS['language']->langcode;
|
||||
$variables['html_attributes_array']['dir'] = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
|
||||
$variables['html_attributes_array']['lang'] = $GLOBALS['language_interface']->langcode;
|
||||
$variables['html_attributes_array']['dir'] = $GLOBALS['language_interface']->direction ? 'rtl' : 'ltr';
|
||||
|
||||
// Add favicon.
|
||||
if (theme_get_setting('toggle_favicon')) {
|
||||
|
@ -2571,8 +2571,8 @@ function template_preprocess_page(&$variables) {
|
|||
$variables['base_path'] = base_path();
|
||||
$variables['front_page'] = url();
|
||||
$variables['feed_icons'] = drupal_get_feeds();
|
||||
$variables['language'] = $GLOBALS['language'];
|
||||
$variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
|
||||
$variables['language'] = $GLOBALS['language_interface'];
|
||||
$variables['language']->dir = $GLOBALS['language_interface']->direction ? 'rtl' : 'ltr';
|
||||
$variables['logo'] = theme_get_setting('logo');
|
||||
$variables['main_menu'] = theme_get_setting('toggle_main_menu') ? menu_main_menu() : array();
|
||||
$variables['secondary_menu'] = theme_get_setting('toggle_secondary_menu') ? menu_secondary_menu() : array();
|
||||
|
@ -2774,7 +2774,7 @@ function template_preprocess_maintenance_page(&$variables) {
|
|||
}
|
||||
|
||||
// set the default language if necessary
|
||||
$language = isset($GLOBALS['language']) ? $GLOBALS['language'] : language_default();
|
||||
$language = isset($GLOBALS['language_interface']) ? $GLOBALS['language_interface'] : language_default();
|
||||
|
||||
$variables['head_title_array'] = $head_title;
|
||||
$variables['head_title'] = implode(' | ', $head_title);
|
||||
|
|
|
@ -138,7 +138,7 @@ function update_prepare_d8_bootstrap() {
|
|||
*/
|
||||
function update_prepare_stored_includes() {
|
||||
// Update language negotiation settings.
|
||||
foreach (language_types() as $language_type) {
|
||||
foreach (language_types_get_all() as $language_type) {
|
||||
$negotiation = variable_get("language_negotiation_$language_type", array());
|
||||
foreach ($negotiation as $id => &$provider) {
|
||||
if (isset($negotiation[$id]['file']) && $negotiation[$id]['file'] == 'includes/locale.inc') {
|
||||
|
|
|
@ -360,7 +360,7 @@ Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) {
|
|||
|
||||
// Insert progressbar or throbber.
|
||||
if (this.progress.type == 'bar') {
|
||||
var progressBar = new Drupal.progressBar('ajax-progress-' + this.element.id, eval(this.progress.update_callback), this.progress.method, eval(this.progress.error_callback));
|
||||
var progressBar = new Drupal.progressBar('ajax-progress-' + this.element.id, $.noop, this.progress.method, $.noop);
|
||||
if (this.progress.message) {
|
||||
progressBar.setProgress(-1, this.progress.message);
|
||||
}
|
||||
|
|
|
@ -66,14 +66,16 @@
|
|||
* Most modules do not provide an initial value, and any value provided can
|
||||
* be modified by a user on the block configuration screen.
|
||||
* - 'status': (optional) Initial value for block enabled status. (1 =
|
||||
* enabled, 0 = disabled). Most modules do not provide an initial value,
|
||||
* and any value provided can be modified by a user on the block
|
||||
* configuration screen.
|
||||
* enabled, 0 = disabled). An initial value for 'region' is required for
|
||||
* 'status' to take effect.
|
||||
* Most modules do not provide an initial value, and any value provided can
|
||||
* be modified by a user on the block configuration screen.
|
||||
* - 'region': (optional) Initial value for theme region within which this
|
||||
* block is set. Most modules do not provide an initial value, and
|
||||
* any value provided can be modified by a user on the block configuration
|
||||
* screen. Note: If you set a region that isn't available in the currently
|
||||
* enabled theme, the block will be disabled.
|
||||
* block is set. If the specified region is not available in a theme, the
|
||||
* block will be disabled. The initial value for 'status' must be enabled or
|
||||
* the initial region value is ignored.
|
||||
* Most modules do not provide an initial value, and any value provided can
|
||||
* be modified by a user on the block configuration screen.
|
||||
* - 'visibility': (optional) Initial value for the visibility flag, which
|
||||
* tells how to interpret the 'pages' value. Possible values are:
|
||||
* - BLOCK_VISIBILITY_NOTLISTED: Show on all pages except listed pages.
|
||||
|
@ -319,7 +321,7 @@ function hook_block_view_MODULE_DELTA_alter(&$data, $block) {
|
|||
* An array of $blocks, keyed by the block ID.
|
||||
*/
|
||||
function hook_block_list_alter(&$blocks) {
|
||||
global $language, $theme_key;
|
||||
global $language_interface, $theme_key;
|
||||
|
||||
// This example shows how to achieve language specific visibility setting for
|
||||
// blocks.
|
||||
|
@ -343,7 +345,7 @@ function hook_block_list_alter(&$blocks) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!isset($block_languages[$block->module][$block->delta][$language->language])) {
|
||||
if (!isset($block_languages[$block->module][$block->delta][$language_interface->language])) {
|
||||
// This block should not be displayed with the active language, remove
|
||||
// from the list.
|
||||
unset($blocks[$key]);
|
||||
|
|
|
@ -1228,17 +1228,17 @@ function book_toc($bid, $depth_limit, $exclude = array()) {
|
|||
* @see book-export-html.tpl.php
|
||||
*/
|
||||
function template_preprocess_book_export_html(&$variables) {
|
||||
global $base_url, $language;
|
||||
global $base_url, $language_interface;
|
||||
|
||||
$variables['title'] = check_plain($variables['title']);
|
||||
$variables['base_url'] = $base_url;
|
||||
$variables['language'] = $language;
|
||||
$variables['language_rtl'] = ($language->direction == LANGUAGE_RTL);
|
||||
$variables['language'] = $language_interface;
|
||||
$variables['language_rtl'] = ($language_interface->direction == LANGUAGE_RTL);
|
||||
$variables['head'] = drupal_get_html_head();
|
||||
|
||||
// HTML element attributes.
|
||||
$variables['html_attributes_array']['lang'] = $language->langcode;
|
||||
$variables['html_attributes_array']['dir'] = $language->direction ? 'rtl' : 'ltr';
|
||||
$variables['html_attributes_array']['lang'] = $language_interface->langcode;
|
||||
$variables['html_attributes_array']['dir'] = $language_interface->direction ? 'rtl' : 'ltr';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,11 +25,11 @@ class Comment extends Entity {
|
|||
public $pid;
|
||||
|
||||
/**
|
||||
* The comment language.
|
||||
* The comment language code.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $language = LANGUAGE_NONE;
|
||||
public $langcode = LANGUAGE_NONE;
|
||||
|
||||
/**
|
||||
* The comment title.
|
||||
|
|
|
@ -167,7 +167,7 @@ function comment_schema() {
|
|||
'not null' => FALSE,
|
||||
'description' => "The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on.",
|
||||
),
|
||||
'language' => array(
|
||||
'langcode' => array(
|
||||
'description' => 'The {language}.langcode of this comment.',
|
||||
'type' => 'varchar',
|
||||
'length' => 12,
|
||||
|
@ -179,7 +179,7 @@ function comment_schema() {
|
|||
'comment_status_pid' => array('pid', 'status'),
|
||||
'comment_num_new' => array('nid', 'status', 'created', 'cid', 'thread'),
|
||||
'comment_uid' => array('uid'),
|
||||
'comment_nid_language' => array('nid', 'language'),
|
||||
'comment_nid_langcode' => array('nid', 'langcode'),
|
||||
'comment_created' => array('created'),
|
||||
),
|
||||
'primary key' => array('cid'),
|
||||
|
@ -259,3 +259,29 @@ function comment_schema() {
|
|||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @addtogroup updates-7.x-to-8.x
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renames {comment}.language to {comment}.langcode.
|
||||
*/
|
||||
function comment_update_8000() {
|
||||
db_drop_index('comment', 'comment_nid_langcode');
|
||||
$langcode_spec = array(
|
||||
'type' => 'varchar',
|
||||
'length' => 12,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => "Language code, e.g. 'de' or 'en-US'.",
|
||||
);
|
||||
db_change_field('comment', 'language', 'langcode', $langcode_spec);
|
||||
db_add_index('comment', 'comment_nid_langcode', array('nid', 'langcode'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-7.x-to-8.x"
|
||||
* The next series of updates should start at 9000.
|
||||
*/
|
||||
|
|
|
@ -667,13 +667,17 @@ function comment_node_view($node, $view_mode) {
|
|||
}
|
||||
}
|
||||
if ($node->comment == COMMENT_NODE_OPEN) {
|
||||
$comment_form_location = variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW);
|
||||
if (user_access('post comments')) {
|
||||
$links['comment-add'] = array(
|
||||
'title' => t('Add new comment'),
|
||||
'href' => "comment/reply/$node->nid",
|
||||
'href' => "node/$node->nid",
|
||||
'attributes' => array('title' => t('Add a new comment to this page.')),
|
||||
'fragment' => 'comment-form',
|
||||
);
|
||||
if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) {
|
||||
$links['comment-add']['href'] = "comment/reply/$node->nid";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$links['comment-forbidden'] = array(
|
||||
|
@ -1840,11 +1844,11 @@ function comment_form($form, &$form_state, $comment) {
|
|||
|
||||
// If a content type has multilingual support we set the comment to inherit the
|
||||
// content language. Otherwise mark the comment as language neutral.
|
||||
$comment_langcode = $comment->language;
|
||||
$comment_langcode = $comment->langcode;
|
||||
if (($comment_langcode == LANGUAGE_NONE) && variable_get('node_type_language_' . $node->type, 0)) {
|
||||
$comment_langcode = $language_content->langcode;
|
||||
}
|
||||
$form['language'] = array(
|
||||
$form['langcode'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => $comment_langcode,
|
||||
);
|
||||
|
@ -1907,6 +1911,8 @@ function comment_preview($comment) {
|
|||
if (!empty($account->uid)) {
|
||||
$comment->uid = $account->uid;
|
||||
$comment->name = check_plain($account->name);
|
||||
$comment->signature = $account->signature;
|
||||
$comment->signature_format = $account->signature_format;
|
||||
}
|
||||
elseif (empty($comment->name)) {
|
||||
$comment->name = variable_get('anonymous', t('Anonymous'));
|
||||
|
|
|
@ -451,7 +451,7 @@ class CommentInterfaceTest extends CommentHelperCase {
|
|||
'status' => COMMENT_PUBLISHED,
|
||||
'subject' => $this->randomName(),
|
||||
'hostname' => ip_address(),
|
||||
'language' => LANGUAGE_NONE,
|
||||
'langcode' => LANGUAGE_NONE,
|
||||
'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
|
||||
));
|
||||
comment_save($comment);
|
||||
|
@ -778,7 +778,7 @@ class CommentInterfaceTest extends CommentHelperCase {
|
|||
'status' => COMMENT_PUBLISHED,
|
||||
'subject' => $this->randomName(),
|
||||
'hostname' => ip_address(),
|
||||
'language' => LANGUAGE_NONE,
|
||||
'langcode' => LANGUAGE_NONE,
|
||||
'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
|
||||
));
|
||||
comment_save($comment);
|
||||
|
@ -920,6 +920,17 @@ class CommentInterfaceTest extends CommentHelperCase {
|
|||
}
|
||||
else {
|
||||
$this->assertLink('Add new comment');
|
||||
|
||||
// Verify that the "Add new comment" link points to the correct URL
|
||||
// based on the comment form location configuration.
|
||||
if ($info['form'] == COMMENT_FORM_SEPARATE_PAGE) {
|
||||
$this->assertLinkByHref("comment/reply/$nid#comment-form", 0, 'Comment form link destination is on a separate page.');
|
||||
$this->assertNoLinkByHref("node/$nid#comment-form");
|
||||
}
|
||||
else {
|
||||
$this->assertLinkByHref("node/$nid#comment-form", 0, 'Comment form link destination is on node.');
|
||||
$this->assertNoLinkByHref("comment/reply/$nid#comment-form");
|
||||
}
|
||||
}
|
||||
|
||||
// Also verify that the comment form appears according to the configured
|
||||
|
@ -964,8 +975,15 @@ class CommentPreviewTest extends CommentHelperCase {
|
|||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->drupalLogout();
|
||||
|
||||
// As web user, fill in node creation form and preview node.
|
||||
// Login as web user and add a signature.
|
||||
$this->drupalLogin($this->web_user);
|
||||
variable_set('user_signatures', 1);
|
||||
$test_signature = $this->randomName();
|
||||
$edit['signature[value]'] = '<a href="http://example.com/">' . $test_signature. '</a>';
|
||||
$edit['signature[format]'] = 'filtered_html';
|
||||
$this->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Save'));
|
||||
|
||||
// Fill in the comment form and preview the comment.
|
||||
$edit = array();
|
||||
$edit['subject'] = $this->randomName(8);
|
||||
$edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
|
||||
|
@ -979,6 +997,9 @@ class CommentPreviewTest extends CommentHelperCase {
|
|||
// Check that the title and body fields are displayed with the correct values.
|
||||
$this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.'));
|
||||
$this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.'));
|
||||
|
||||
// Check that the signature is displaying with the correct text format.
|
||||
$this->assertLink($test_signature);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1839,10 +1860,10 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
|
|||
* Creates a comment, then tests the tokens generated from it.
|
||||
*/
|
||||
function testCommentTokenReplacement() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
$url_options = array(
|
||||
'absolute' => TRUE,
|
||||
'language' => $language,
|
||||
'language' => $language_interface,
|
||||
);
|
||||
|
||||
$this->drupalLogin($this->admin_user);
|
||||
|
@ -1875,8 +1896,8 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
|
|||
$tests['[comment:body]'] = _text_sanitize($instance, LANGUAGE_NONE, $comment->comment_body[LANGUAGE_NONE][0], 'value');
|
||||
$tests['[comment:url]'] = url('comment/' . $comment->cid, $url_options + array('fragment' => 'comment-' . $comment->cid));
|
||||
$tests['[comment:edit-url]'] = url('comment/' . $comment->cid . '/edit', $url_options);
|
||||
$tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->created, 2, $language->langcode);
|
||||
$tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->changed, 2, $language->langcode);
|
||||
$tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->created, 2, $language_interface->langcode);
|
||||
$tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->changed, 2, $language_interface->langcode);
|
||||
$tests['[comment:parent:cid]'] = $comment->pid;
|
||||
$tests['[comment:parent:title]'] = check_plain($parent_comment->subject);
|
||||
$tests['[comment:node:nid]'] = $comment->nid;
|
||||
|
@ -1888,7 +1909,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
|
|||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('comment' => $comment), array('language' => $language));
|
||||
$output = token_replace($input, array('comment' => $comment), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Sanitized comment token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
|
@ -1904,7 +1925,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
|
|||
$tests['[comment:author:name]'] = $this->admin_user->name;
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('comment' => $comment), array('language' => $language, 'sanitize' => FALSE));
|
||||
$output = token_replace($input, array('comment' => $comment), array('language' => $language_interface, 'sanitize' => FALSE));
|
||||
$this->assertEqual($output, $expected, t('Unsanitized comment token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
|
@ -1917,7 +1938,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
|
|||
$tests['[node:comment-count-new]'] = 2;
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('node' => $node), array('language' => $language));
|
||||
$output = token_replace($input, array('node' => $node), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Node comment token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,10 +106,10 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
|
|||
$url_options = array('absolute' => TRUE);
|
||||
if (isset($options['language'])) {
|
||||
$url_options['language'] = $options['language'];
|
||||
$language_code = $options['language']->langcode;
|
||||
$langcode = $options['language']->langcode;
|
||||
}
|
||||
else {
|
||||
$language_code = NULL;
|
||||
$langcode = NULL;
|
||||
}
|
||||
$sanitize = !empty($options['sanitize']);
|
||||
|
||||
|
@ -155,9 +155,9 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
|
|||
break;
|
||||
|
||||
case 'body':
|
||||
if ($items = field_get_items('comment', $comment, 'comment_body', $language_code)) {
|
||||
if ($items = field_get_items('comment', $comment, 'comment_body', $langcode)) {
|
||||
$instance = field_info_instance('comment', 'body', 'comment_body');
|
||||
$field_langcode = field_language('comment', $comment, 'comment_body', $language_code);
|
||||
$field_langcode = field_language('comment', $comment, 'comment_body', $langcode);
|
||||
$replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'value') : $items[0]['value'];
|
||||
}
|
||||
break;
|
||||
|
@ -186,11 +186,11 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
|
|||
break;
|
||||
|
||||
case 'created':
|
||||
$replacements[$original] = format_date($comment->created, 'medium', '', NULL, $language_code);
|
||||
$replacements[$original] = format_date($comment->created, 'medium', '', NULL, $langcode);
|
||||
break;
|
||||
|
||||
case 'changed':
|
||||
$replacements[$original] = format_date($comment->changed, 'medium', '', NULL, $language_code);
|
||||
$replacements[$original] = format_date($comment->changed, 'medium', '', NULL, $langcode);
|
||||
break;
|
||||
|
||||
case 'node':
|
||||
|
|
|
@ -134,7 +134,7 @@ function contact_site_form_validate($form, &$form_state) {
|
|||
* @see contact_site_form_validate()
|
||||
*/
|
||||
function contact_site_form_submit($form, &$form_state) {
|
||||
global $user, $language;
|
||||
global $user, $language_interface;
|
||||
|
||||
$values = $form_state['values'];
|
||||
$values['sender'] = $user;
|
||||
|
@ -156,12 +156,12 @@ function contact_site_form_submit($form, &$form_state) {
|
|||
|
||||
// If the user requests it, send a copy using the current language.
|
||||
if ($values['copy']) {
|
||||
drupal_mail('contact', 'page_copy', $from, $language, $values, $from);
|
||||
drupal_mail('contact', 'page_copy', $from, $language_interface, $values, $from);
|
||||
}
|
||||
|
||||
// Send an auto-reply if necessary using the current language.
|
||||
if ($values['category']['reply']) {
|
||||
drupal_mail('contact', 'page_autoreply', $from, $language, $values, $to);
|
||||
drupal_mail('contact', 'page_autoreply', $from, $language_interface, $values, $to);
|
||||
}
|
||||
|
||||
flood_register_event('contact', variable_get('contact_threshold_window', 3600));
|
||||
|
@ -270,7 +270,7 @@ function contact_personal_form_validate($form, &$form_state) {
|
|||
* @see contact_personal_form_validate()
|
||||
*/
|
||||
function contact_personal_form_submit($form, &$form_state) {
|
||||
global $user, $language;
|
||||
global $user, $language_interface;
|
||||
|
||||
$values = $form_state['values'];
|
||||
$values['sender'] = $user;
|
||||
|
@ -291,7 +291,7 @@ function contact_personal_form_submit($form, &$form_state) {
|
|||
|
||||
// Send a copy if requested, using current page language.
|
||||
if ($values['copy']) {
|
||||
drupal_mail('contact', 'user_copy', $from, $language, $values, $from);
|
||||
drupal_mail('contact', 'user_copy', $from, $language_interface, $values, $from);
|
||||
}
|
||||
|
||||
flood_register_event('contact', variable_get('contact_threshold_window', 3600));
|
||||
|
|
|
@ -43,7 +43,7 @@ function entity_modules_disabled() {
|
|||
* @see hook_entity_info_alter()
|
||||
*/
|
||||
function entity_get_info($entity_type = NULL) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// Use the advanced drupal_static() pattern, since this is called very often.
|
||||
static $drupal_static_fast;
|
||||
|
@ -54,7 +54,7 @@ function entity_get_info($entity_type = NULL) {
|
|||
|
||||
// hook_entity_info() includes translated strings, so each language is cached
|
||||
// separately.
|
||||
$langcode = $language->langcode;
|
||||
$langcode = $language_interface->langcode;
|
||||
|
||||
if (empty($entity_info)) {
|
||||
if ($cache = cache()->get("entity_info:$langcode")) {
|
||||
|
|
|
@ -714,12 +714,13 @@ class EntityFieldQuery {
|
|||
* contains everything necessary for processing.
|
||||
*
|
||||
* @return
|
||||
* Either a number if count() was called or an array of associative
|
||||
* arrays of stub entities. The outer array keys are entity types, and the
|
||||
* inner array keys are the relevant ID. (In most this cases this will be
|
||||
* the entity ID. The only exception is when age=FIELD_LOAD_REVISION is used
|
||||
* and field conditions or sorts are present -- in this case, the key will
|
||||
* be the revision ID.) The inner array values are always stub entities, as
|
||||
* Either a number if count() was called or an array of associative arrays
|
||||
* of stub entities. The outer array keys are entity types, and the inner
|
||||
* array keys are the relevant ID. (In most cases this will be the entity
|
||||
* ID. The only exception is when age=FIELD_LOAD_REVISION is used and field
|
||||
* conditions or sorts are present -- in this case, the key will be the
|
||||
* revision ID.) The entity type will only exist in the outer array if
|
||||
* results were found. The inner array values are always stub entities, as
|
||||
* returned by entity_create_stub_entity(). To traverse the returned array:
|
||||
* @code
|
||||
* foreach ($query->execute() as $entity_type => $entities) {
|
||||
|
@ -729,7 +730,9 @@ class EntityFieldQuery {
|
|||
* the entities found:
|
||||
* @code
|
||||
* $result = $query->execute();
|
||||
* if (!empty($result[$my_type])) {
|
||||
* $entities = entity_load($my_type, array_keys($result[$my_type]));
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
public function execute() {
|
||||
|
|
|
@ -67,7 +67,7 @@ function field_info_cache_clear() {
|
|||
* @see _field_info_collate_types_reset()
|
||||
*/
|
||||
function _field_info_collate_types() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// Use the advanced drupal_static() pattern, since this is called very often.
|
||||
static $drupal_static_fast;
|
||||
|
@ -79,7 +79,7 @@ function _field_info_collate_types() {
|
|||
|
||||
// The _info() hooks invoked below include translated strings, so each
|
||||
// language is cached separately.
|
||||
$langcode = $language->langcode;
|
||||
$langcode = $language_interface->langcode;
|
||||
|
||||
if (!isset($info)) {
|
||||
if ($cached = cache('field')->get("field_info_types:$langcode")) {
|
||||
|
|
|
@ -1051,10 +1051,10 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
|
|||
* Creates a file, then tests the tokens generated from it.
|
||||
*/
|
||||
function testFileTokenReplacement() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
$url_options = array(
|
||||
'absolute' => TRUE,
|
||||
'language' => $language,
|
||||
'language' => $language_interface,
|
||||
);
|
||||
|
||||
// Create file field.
|
||||
|
@ -1084,8 +1084,8 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
|
|||
$tests['[file:mime]'] = check_plain($file->filemime);
|
||||
$tests['[file:size]'] = format_size($file->filesize);
|
||||
$tests['[file:url]'] = check_plain(file_create_url($file->uri));
|
||||
$tests['[file:timestamp]'] = format_date($file->timestamp, 'medium', '', NULL, $language->langcode);
|
||||
$tests['[file:timestamp:short]'] = format_date($file->timestamp, 'short', '', NULL, $language->langcode);
|
||||
$tests['[file:timestamp]'] = format_date($file->timestamp, 'medium', '', NULL, $language_interface->langcode);
|
||||
$tests['[file:timestamp:short]'] = format_date($file->timestamp, 'short', '', NULL, $language_interface->langcode);
|
||||
$tests['[file:owner]'] = check_plain(user_format_name($this->admin_user));
|
||||
$tests['[file:owner:uid]'] = $file->uid;
|
||||
|
||||
|
@ -1093,7 +1093,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
|
|||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('file' => $file), array('language' => $language));
|
||||
$output = token_replace($input, array('file' => $file), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Sanitized file token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
|
@ -1104,7 +1104,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
|
|||
$tests['[file:size]'] = format_size($file->filesize);
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('file' => $file), array('language' => $language, 'sanitize' => FALSE));
|
||||
$output = token_replace($input, array('file' => $file), array('language' => $language_interface, 'sanitize' => FALSE));
|
||||
$this->assertEqual($output, $expected, t('Unsanitized file token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -390,12 +390,12 @@ function filter_modules_disabled($modules) {
|
|||
* @see filter_formats_reset()
|
||||
*/
|
||||
function filter_formats($account = NULL) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
$formats = &drupal_static(__FUNCTION__, array());
|
||||
|
||||
// All available formats are cached for performance.
|
||||
if (!isset($formats['all'])) {
|
||||
if ($cache = cache()->get("filter_formats:{$language->langcode}")) {
|
||||
if ($cache = cache()->get("filter_formats:{$language_interface->langcode}")) {
|
||||
$formats['all'] = $cache->data;
|
||||
}
|
||||
else {
|
||||
|
@ -407,7 +407,7 @@ function filter_formats($account = NULL) {
|
|||
->execute()
|
||||
->fetchAllAssoc('format');
|
||||
|
||||
cache()->set("filter_formats:{$language->langcode}", $formats['all']);
|
||||
cache()->set("filter_formats:{$language_interface->langcode}", $formats['all']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -468,10 +468,10 @@ function forum_permission() {
|
|||
/**
|
||||
* Implements hook_taxonomy_term_delete().
|
||||
*/
|
||||
function forum_taxonomy_term_delete($tid) {
|
||||
function forum_taxonomy_term_delete(stdClass $term) {
|
||||
// For containers, remove the tid from the forum_containers variable.
|
||||
$containers = variable_get('forum_containers', array());
|
||||
$key = array_search($tid, $containers);
|
||||
$key = array_search($term->tid, $containers);
|
||||
if ($key !== FALSE) {
|
||||
unset($containers[$key]);
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ class ForumTestCase extends DrupalWebTestCase {
|
|||
// Save forum overview.
|
||||
$this->drupalPost('admin/structure/forum/', array(), t('Save'));
|
||||
$this->assertRaw(t('The configuration options have been saved.'));
|
||||
// Delete this second form.
|
||||
// Delete this second forum.
|
||||
$this->deleteForum($this->delete_forum['tid']);
|
||||
// Create forum at the top (root) level.
|
||||
$this->root_forum = $this->createForum('forum');
|
||||
|
@ -341,6 +341,11 @@ class ForumTestCase extends DrupalWebTestCase {
|
|||
// Assert that the forum no longer exists.
|
||||
$this->drupalGet('forum/' . $tid);
|
||||
$this->assertResponse(404, 'The forum was not found');
|
||||
|
||||
// Assert that the associated term has been removed from the
|
||||
// forum_containers variable.
|
||||
$containers = variable_get('forum_containers', array());
|
||||
$this->assertFalse(in_array($tid, $containers), 'The forum_containers variable has been updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -839,11 +839,11 @@ function image_style_path($style_name, $uri) {
|
|||
* @see image_effect_definition_load()
|
||||
*/
|
||||
function image_effect_definitions() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// hook_image_effect_info() includes translated strings, so each language is
|
||||
// cached separately.
|
||||
$langcode = $language->langcode;
|
||||
$langcode = $language_interface->langcode;
|
||||
|
||||
$effects = &drupal_static(__FUNCTION__);
|
||||
|
||||
|
|
|
@ -192,10 +192,10 @@ function language_delete($langcode) {
|
|||
* and checks to see if a related right to left CSS file should be included.
|
||||
*/
|
||||
function language_css_alter(&$css) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// If the current language is RTL, add the CSS file with the RTL overrides.
|
||||
if ($language->direction == LANGUAGE_RTL) {
|
||||
if ($language_interface->direction == LANGUAGE_RTL) {
|
||||
foreach ($css as $data => $item) {
|
||||
// Only provide RTL overrides for files.
|
||||
if ($item['type'] == 'file') {
|
||||
|
|
|
@ -14,7 +14,7 @@ function language_negotiation_configure_form() {
|
|||
$form = array(
|
||||
'#submit' => array('language_negotiation_configure_form_submit'),
|
||||
'#theme' => 'language_negotiation_configure_form',
|
||||
'#language_types' => language_types_configurable(FALSE),
|
||||
'#language_types' => language_types_get_configurable(FALSE),
|
||||
'#language_types_info' => language_types_info(),
|
||||
'#language_providers' => language_negotiation_info(),
|
||||
);
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
* did not happen yet and thus they cannot rely on translated variables.
|
||||
*/
|
||||
function hook_language_init() {
|
||||
global $language, $conf;
|
||||
global $language_interface, $conf;
|
||||
|
||||
switch ($language->langcode) {
|
||||
switch ($language_interface->langcode) {
|
||||
case 'it':
|
||||
$conf['site_name'] = 'Il mio sito Drupal';
|
||||
break;
|
||||
|
@ -52,10 +52,10 @@ function hook_language_init() {
|
|||
* The current path.
|
||||
*/
|
||||
function hook_language_switch_links_alter(array &$links, $type, $path) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language->langcode])) {
|
||||
foreach ($links[$language->langcode] as $link) {
|
||||
if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language_interface->langcode])) {
|
||||
foreach ($links[$language_interface->langcode] as $link) {
|
||||
$link['attributes']['class'][] = 'active-language';
|
||||
}
|
||||
}
|
||||
|
@ -65,13 +65,19 @@ function hook_language_switch_links_alter(array &$links, $type, $path) {
|
|||
* Allow modules to define their own language types.
|
||||
*
|
||||
* @return
|
||||
* An array of language type definitions. Each language type has an identifier
|
||||
* key. The language type definition is an associative array that may contain
|
||||
* the following key-value pairs:
|
||||
* An associative array of language type definitions.
|
||||
*
|
||||
* Each language type has an identifier key which is used as the name for the
|
||||
* global variable corresponding to the language type in the bootstrap phase.
|
||||
*
|
||||
* The language type definition is an associative array that may contain the
|
||||
* following key-value pairs:
|
||||
* - "name": The human-readable language type identifier.
|
||||
* - "description": A description of the language type.
|
||||
* - "fixed": An array of language provider identifiers. Defining this key
|
||||
* makes the language type non-configurable.
|
||||
* - "fixed": A fixed array of language provider identifiers to use to
|
||||
* initialize this language. Defining this key makes the language type
|
||||
* non-configurable and will always use the specified providers in the given
|
||||
* priority order.
|
||||
*/
|
||||
function hook_language_types_info() {
|
||||
return array(
|
||||
|
@ -88,6 +94,8 @@ function hook_language_types_info() {
|
|||
/**
|
||||
* Perform alterations on language types.
|
||||
*
|
||||
* @see hook_language_types_info().
|
||||
*
|
||||
* @param $language_types
|
||||
* Array of language type definitions.
|
||||
*/
|
||||
|
|
|
@ -29,7 +29,7 @@ function locale_install() {
|
|||
}
|
||||
|
||||
// Enable URL language detection for each (core) configurable language type.
|
||||
foreach (language_types_configurable() as $type) {
|
||||
foreach (language_types_get_configurable() as $type) {
|
||||
variable_set("language_negotiation_$type", $negotiation);
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ function locale_uninstall() {
|
|||
variable_del('locale_translation_plurals');
|
||||
variable_del('locale_translation_javascript');
|
||||
|
||||
foreach (language_types() as $type) {
|
||||
foreach (language_types_get_all() as $type) {
|
||||
variable_del("language_negotiation_$type");
|
||||
variable_del("locale_language_providers_weight_$type");
|
||||
}
|
||||
|
@ -231,6 +231,49 @@ function locale_update_8000() {
|
|||
db_drop_field('locales_source', 'textgroup');
|
||||
}
|
||||
|
||||
/**
|
||||
* Language type 'language' renamed to 'language_interface'.
|
||||
*/
|
||||
function locale_update_8001() {
|
||||
// Only change language_types if we had this setting saved. Keep order
|
||||
// of types because that is significant for value dependency.
|
||||
$types = variable_get('language_types', NULL);
|
||||
if (!empty($types) && isset($types['language'])) {
|
||||
$new_types = array();
|
||||
foreach ($types as $key => $type) {
|
||||
$new_types[$key == 'language' ? 'language_interface' : $key] = $type;
|
||||
}
|
||||
variable_set('language_types', $new_types);
|
||||
}
|
||||
|
||||
// Rename language_negotiation_language setting if exists.
|
||||
$setting = variable_get('language_negotiation_language', NULL);
|
||||
if ($setting !== NULL) {
|
||||
variable_set('language_negotiation_language_interface', $setting);
|
||||
variable_del('language_negotiation_language');
|
||||
}
|
||||
|
||||
// Rename locale_language_providers_weight_language setting if exists.
|
||||
$weight = variable_get('locale_language_providers_weight_language', NULL);
|
||||
if ($weight !== NULL) {
|
||||
variable_set('locale_language_providers_weight_language_interface', $weight);
|
||||
variable_del('locale_language_providers_weight_language');
|
||||
}
|
||||
|
||||
// Update block data in all core block related tables. Contributed modules
|
||||
// storing data for blocks will need to update for themselves.
|
||||
$block_tables = array('block', 'block_node_type', 'block_role');
|
||||
foreach ($block_tables as $table) {
|
||||
db_update($table)
|
||||
->fields(array(
|
||||
'delta' => 'language_interface',
|
||||
))
|
||||
->condition('delta', 'language')
|
||||
->condition('module', 'locale')
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-7.x-to-8.x"
|
||||
* The next series of updates should start at 9000.
|
||||
|
|
|
@ -181,7 +181,7 @@ function locale_menu() {
|
|||
* Initialize date formats according to the user's current locale.
|
||||
*/
|
||||
function locale_init() {
|
||||
global $conf, $language;
|
||||
global $conf, $language_interface;
|
||||
include_once DRUPAL_ROOT . '/core/includes/locale.inc';
|
||||
|
||||
// For each date type (e.g. long, short), get the localized date format
|
||||
|
@ -190,7 +190,7 @@ function locale_init() {
|
|||
// settings page, where we want to display the site default and not the
|
||||
// localized version.
|
||||
if (strpos($_GET['q'], 'admin/config/regional/date-time/formats') !== 0) {
|
||||
$languages = array($language->langcode);
|
||||
$languages = array($language_interface->langcode);
|
||||
|
||||
// Setup appropriate date formats for this locale.
|
||||
$formats = locale_get_localized_date_format($languages);
|
||||
|
@ -218,12 +218,12 @@ function locale_permission() {
|
|||
* @see locale_form_alter()
|
||||
*/
|
||||
function locale_language_selector_form($user) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
// Get list of enabled languages only.
|
||||
$languages = language_list(TRUE);
|
||||
|
||||
// If the user is being created, we set the user language to the page language.
|
||||
$user_preferred_language = $user->uid ? user_preferred_language($user) : $language;
|
||||
$user_preferred_language = $user->uid ? user_preferred_language($user) : $language_interface;
|
||||
|
||||
$names = array();
|
||||
foreach ($languages as $langcode => $item) {
|
||||
|
@ -592,7 +592,7 @@ function locale_language_delete($language) {
|
|||
* Language code to use for the lookup.
|
||||
*/
|
||||
function locale($string = NULL, $context = NULL, $langcode = NULL) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// Use the advanced drupal_static() pattern, since this is called very often.
|
||||
static $drupal_static_fast;
|
||||
|
@ -607,11 +607,12 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) {
|
|||
return $locale_t;
|
||||
}
|
||||
|
||||
$langcode = isset($langcode) ? $langcode : $language->langcode;
|
||||
$langcode = isset($langcode) ? $langcode : $language_interface->langcode;
|
||||
|
||||
// Store database cached translations in a static variable. Only build the
|
||||
// cache after $language has been set to avoid an unnecessary cache rebuild.
|
||||
if (!isset($locale_t[$langcode]) && isset($language)) {
|
||||
// cache after $language_interface has been set to avoid an unnecessary cache
|
||||
// rebuild.
|
||||
if (!isset($locale_t[$langcode]) && isset($language_interface)) {
|
||||
$locale_t[$langcode] = array();
|
||||
// Disabling the usage of string caching allows a module to watch for
|
||||
// the exact list of strings used on a page. From a performance
|
||||
|
@ -702,7 +703,7 @@ function locale_reset() {
|
|||
* plural formula.
|
||||
*/
|
||||
function locale_get_plural($count, $langcode = NULL) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// Used to locally cache the plural formulas for all languages.
|
||||
$plural_formulas = &drupal_static(__FUNCTION__, array());
|
||||
|
@ -710,7 +711,7 @@ function locale_get_plural($count, $langcode = NULL) {
|
|||
// individually for each language.
|
||||
$plural_indexes = &drupal_static(__FUNCTION__ . ':plurals', array());
|
||||
|
||||
$langcode = $langcode ? $langcode : $language->langcode;
|
||||
$langcode = $langcode ? $langcode : $language_interface->langcode;
|
||||
|
||||
if (!isset($plural_indexes[$langcode][$count])) {
|
||||
// Retrieve and statically cache the plural formulas for all languages.
|
||||
|
@ -788,7 +789,7 @@ function locale_system_update($components) {
|
|||
* file if necessary, and adds it to the page.
|
||||
*/
|
||||
function locale_js_alter(&$javascript) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
$dir = 'public://' . variable_get('locale_js_directory', 'languages');
|
||||
$parsed = variable_get('javascript_parsed', array());
|
||||
|
@ -820,11 +821,11 @@ function locale_js_alter(&$javascript) {
|
|||
}
|
||||
|
||||
// If necessary, rebuild the translation file for the current language.
|
||||
if (!empty($parsed['refresh:' . $language->langcode])) {
|
||||
if (!empty($parsed['refresh:' . $language_interface->langcode])) {
|
||||
// Don't clear the refresh flag on failure, so that another try will
|
||||
// be performed later.
|
||||
if (_locale_rebuild_js()) {
|
||||
unset($parsed['refresh:' . $language->langcode]);
|
||||
unset($parsed['refresh:' . $language_interface->langcode]);
|
||||
}
|
||||
// Store any changes after refresh was attempted.
|
||||
variable_set('javascript_parsed', $parsed);
|
||||
|
@ -837,9 +838,9 @@ function locale_js_alter(&$javascript) {
|
|||
|
||||
// Add the translation JavaScript file to the page.
|
||||
$locale_javascripts = variable_get('locale_translation_javascript', array());
|
||||
if ($files && !empty($locale_javascripts[$language->langcode])) {
|
||||
if ($files && !empty($locale_javascripts[$language_interface->langcode])) {
|
||||
// Add the translation JavaScript file to the page.
|
||||
$file = $dir . '/' . $language->langcode . '_' . $locale_javascripts[$language->langcode] . '.js';
|
||||
$file = $dir . '/' . $language_interface->langcode . '_' . $locale_javascripts[$language_interface->langcode] . '.js';
|
||||
$javascript[$file] = drupal_js_defaults($file);
|
||||
}
|
||||
}
|
||||
|
@ -850,14 +851,14 @@ function locale_js_alter(&$javascript) {
|
|||
* Provides the language support for the jQuery UI Date Picker.
|
||||
*/
|
||||
function locale_library_info_alter(&$libraries, $module) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
if ($module == 'system' && isset($libraries['system']['ui.datepicker'])) {
|
||||
$datepicker = drupal_get_path('module', 'locale') . '/locale.datepicker.js';
|
||||
$libraries['system']['ui.datepicker']['js'][$datepicker] = array('group' => JS_THEME);
|
||||
$libraries['system']['ui.datepicker']['js'][] = array(
|
||||
'data' => array(
|
||||
'jqueryuidatepicker' => array(
|
||||
'rtl' => $language->direction == LANGUAGE_RTL,
|
||||
'rtl' => $language_interface->direction == LANGUAGE_RTL,
|
||||
'firstDay' => variable_get('date_first_day', 0),
|
||||
),
|
||||
),
|
||||
|
@ -876,7 +877,7 @@ function locale_block_info() {
|
|||
include_once DRUPAL_ROOT . '/core/includes/language.inc';
|
||||
$block = array();
|
||||
$info = language_types_info();
|
||||
foreach (language_types_configurable(FALSE) as $type) {
|
||||
foreach (language_types_get_configurable(FALSE) as $type) {
|
||||
$block[$type] = array(
|
||||
'info' => t('Language switcher (@type)', array('@type' => $info[$type]['name'])),
|
||||
// Not worth caching.
|
||||
|
@ -934,7 +935,7 @@ function locale_url_outbound_alter(&$path, &$options, $original_path) {
|
|||
$callbacks = array();
|
||||
include_once DRUPAL_ROOT . '/core/includes/language.inc';
|
||||
|
||||
foreach (language_types_configurable() as $type) {
|
||||
foreach (language_types_get_configurable() as $type) {
|
||||
// Get url rewriter callbacks only from enabled language providers.
|
||||
$negotiation = variable_get("language_negotiation_$type", array());
|
||||
|
||||
|
@ -1085,15 +1086,15 @@ function locale_form_system_file_system_settings_alter(&$form, $form_state) {
|
|||
*/
|
||||
function locale_preprocess_node(&$variables) {
|
||||
if ($variables['language'] != LANGUAGE_NONE) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
$node_language = language_load($variables['language']);
|
||||
if ($node_language->langcode != $language->langcode) {
|
||||
if ($node_language->langcode != $language_interface->langcode) {
|
||||
// If the node language was different from the page language, we should
|
||||
// add markup to identify the language. Otherwise the page language is
|
||||
// inherited.
|
||||
$variables['attributes_array']['lang'] = $variables['language'];
|
||||
if ($node_language->direction != $language->direction) {
|
||||
if ($node_language->direction != $language_interface->direction) {
|
||||
// If text direction is different form the page's text direction, add
|
||||
// direction information as well.
|
||||
$dir = array('ltr', 'rtl');
|
||||
|
|
|
@ -617,6 +617,15 @@ class LocalePluralFormatTest extends DrupalWebTestCase {
|
|||
'langcode' => 'hr',
|
||||
));
|
||||
|
||||
// Attempt to import some broken .po files as well to prove that these
|
||||
// will not overwrite the proper plural formula imported above.
|
||||
$this->importPoFile($this->getPoFileWithMissingPlural(), array(
|
||||
'langcode' => 'fr',
|
||||
));
|
||||
$this->importPoFile($this->getPoFileWithBrokenPlural(), array(
|
||||
'langcode' => 'hr',
|
||||
));
|
||||
|
||||
// Reset static caches from locale_get_plural() to ensure we get fresh data.
|
||||
drupal_static_reset('locale_get_plural');
|
||||
drupal_static_reset('locale_get_plural:plurals');
|
||||
|
@ -656,6 +665,7 @@ class LocalePluralFormatTest extends DrupalWebTestCase {
|
|||
$name = tempnam('temporary://', "po_") . '.po';
|
||||
file_put_contents($name, $contents);
|
||||
$options['files[file]'] = $name;
|
||||
$options['mode'] = LOCALE_IMPORT_OVERWRITE;
|
||||
$this->drupalPost('admin/config/regional/translate/import', $options, t('Import'));
|
||||
drupal_unlink($name);
|
||||
}
|
||||
|
@ -702,6 +712,41 @@ msgstr[0] "@count sat"
|
|||
msgstr[1] "@count sata"
|
||||
msgstr[2] "@count sati"
|
||||
|
||||
msgid "Monday"
|
||||
msgstr "Ponedjeljak"
|
||||
EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a .po file with a missing plural formula.
|
||||
*/
|
||||
function getPoFileWithMissingPlural() {
|
||||
return <<< EOF
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Drupal 7\\n"
|
||||
"MIME-Version: 1.0\\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\\n"
|
||||
"Content-Transfer-Encoding: 8bit\\n"
|
||||
|
||||
msgid "Monday"
|
||||
msgstr "lundi"
|
||||
EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a .po file with a broken plural formula.
|
||||
*/
|
||||
function getPoFileWithBrokenPlural() {
|
||||
return <<< EOF
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Drupal 7\\n"
|
||||
"MIME-Version: 1.0\\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\\n"
|
||||
"Content-Transfer-Encoding: 8bit\\n"
|
||||
"Plural-Forms: broken, will not parse\\n"
|
||||
|
||||
msgid "Monday"
|
||||
msgstr "Ponedjeljak"
|
||||
EOF;
|
||||
|
@ -1224,7 +1269,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
|
|||
|
||||
// Check the UI language.
|
||||
drupal_language_initialize();
|
||||
$this->assertEqual($GLOBALS['language']->langcode, $this->langcode, t('Current language: %lang', array('%lang' => $GLOBALS['language']->langcode)));
|
||||
$this->assertEqual($GLOBALS['language_interface']->langcode, $this->langcode, t('Current language: %lang', array('%lang' => $GLOBALS['language_interface']->langcode)));
|
||||
|
||||
// Enable multilingual workflow option for articles.
|
||||
variable_set('node_type_language_article', 1);
|
||||
|
@ -1251,7 +1296,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
|
|||
|
||||
// Change language negotiation options.
|
||||
drupal_load('module', 'locale');
|
||||
variable_set('language_types', drupal_language_types() + array('language_custom' => TRUE));
|
||||
variable_set('language_types', language_types_get_default() + array('language_custom' => TRUE));
|
||||
variable_set('language_negotiation_' . LANGUAGE_TYPE_INTERFACE, locale_language_negotiation_info());
|
||||
variable_set('language_negotiation_' . LANGUAGE_TYPE_CONTENT, locale_language_negotiation_info());
|
||||
variable_set('language_negotiation_' . LANGUAGE_TYPE_URL, locale_language_negotiation_info());
|
||||
|
@ -1269,7 +1314,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
|
|||
|
||||
// Check the init language logic.
|
||||
drupal_language_initialize();
|
||||
$this->assertEqual($GLOBALS['language']->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => $GLOBALS['language']->langcode)));
|
||||
$this->assertEqual($GLOBALS['language_interface']->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => $GLOBALS['language_interface']->langcode)));
|
||||
|
||||
// Check JavaScript files deletion.
|
||||
$this->assertTrue($result = !file_exists($js_file), t('JavaScript file deleted: %file', array('%file' => $result ? $js_file : t('found'))));
|
||||
|
@ -1280,7 +1325,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
|
|||
|
||||
// Check language negotiation.
|
||||
require_once DRUPAL_ROOT . '/core/includes/language.inc';
|
||||
$this->assertTrue(count(language_types()) == count(drupal_language_types()), t('Language types reset'));
|
||||
$this->assertTrue(count(language_types_get_all()) == count(language_types_get_default()), t('Language types reset'));
|
||||
$language_negotiation = language_negotiation_get(LANGUAGE_TYPE_INTERFACE) == LANGUAGE_NEGOTIATION_DEFAULT;
|
||||
$this->assertTrue($language_negotiation, t('Interface language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set'))));
|
||||
$language_negotiation = language_negotiation_get(LANGUAGE_TYPE_CONTENT) == LANGUAGE_NEGOTIATION_DEFAULT;
|
||||
|
@ -1369,7 +1414,7 @@ class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase {
|
|||
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
|
||||
|
||||
// Enable URL language detection and selection.
|
||||
$edit = array('language[enabled][locale-url]' => '1');
|
||||
$edit = array('language_interface[enabled][locale-url]' => '1');
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
|
||||
// Assert that the language switching block is displayed on the frontpage.
|
||||
|
@ -1377,7 +1422,7 @@ class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase {
|
|||
$this->assertText(t('Languages'), t('Language switcher block found.'));
|
||||
|
||||
// Assert that only the current language is marked as active.
|
||||
list($language_switcher) = $this->xpath('//div[@id=:id]/div[@class="content"]', array(':id' => 'block-locale-' . $language_type));
|
||||
list($language_switcher) = $this->xpath('//div[@id=:id]/div[@class="content"]', array(':id' => 'block-locale-' . str_replace('_', '-', $language_type)));
|
||||
$links = array(
|
||||
'active' => array(),
|
||||
'inactive' => array(),
|
||||
|
@ -1649,7 +1694,7 @@ class LocaleUserCreationTest extends DrupalWebTestCase {
|
|||
|
||||
// Set language negotiation.
|
||||
$edit = array(
|
||||
'language[enabled][locale-url]' => TRUE,
|
||||
'language_interface[enabled][locale-url]' => TRUE,
|
||||
);
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
$this->assertText(t('Language negotiation configuration saved.'), t('Set language negotiation.'));
|
||||
|
@ -2303,16 +2348,16 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
|
|||
|
||||
// Enable browser and URL language detection.
|
||||
$edit = array(
|
||||
'language[enabled][locale-browser]' => TRUE,
|
||||
'language[enabled][locale-url]' => TRUE,
|
||||
'language[weight][locale-browser]' => -8,
|
||||
'language[weight][locale-url]' => -10,
|
||||
'language_interface[enabled][locale-browser]' => TRUE,
|
||||
'language_interface[enabled][locale-url]' => TRUE,
|
||||
'language_interface[weight][locale-browser]' => -8,
|
||||
'language_interface[weight][locale-url]' => -10,
|
||||
);
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
$this->drupalGet('admin/config/regional/language/detection');
|
||||
|
||||
// Enable the language switcher block.
|
||||
$edit = array('blocks[locale_language][region]' => 'sidebar_first');
|
||||
$edit = array('blocks[locale_language_interface][region]' => 'sidebar_first');
|
||||
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
|
||||
|
||||
// Access the front page without specifying any valid URL language prefix
|
||||
|
@ -2324,7 +2369,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
|
|||
// Check that the language switcher active link matches the given browser
|
||||
// language.
|
||||
$args = array(':url' => base_path() . (!empty($GLOBALS['conf']['clean_url']) ? $langcode_browser_fallback : "?q=$langcode_browser_fallback"));
|
||||
$fields = $this->xpath('//div[@id="block-locale-language"]//a[@class="language-link active" and @href=:url]', $args);
|
||||
$fields = $this->xpath('//div[@id="block-locale-language-interface"]//a[@class="language-link active" and @href=:url]', $args);
|
||||
$this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->name, t('The browser language is the URL active language'));
|
||||
|
||||
// Check that URLs are rewritten using the given browser language.
|
||||
|
@ -2333,7 +2378,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test if the url function returns the right url when using different domains for different languages.
|
||||
* Tests url() when separate domains are used for multiple languages.
|
||||
*/
|
||||
function testLanguageDomain() {
|
||||
// Add the Italian language.
|
||||
|
@ -2346,8 +2391,8 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
|
|||
|
||||
// Enable browser and URL language detection.
|
||||
$edit = array(
|
||||
'language[enabled][locale-url]' => TRUE,
|
||||
'language[weight][locale-url]' => -10,
|
||||
'language_interface[enabled][locale-url]' => TRUE,
|
||||
'language_interface[weight][locale-url]' => -10,
|
||||
);
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
|
||||
|
@ -2421,7 +2466,7 @@ class LocaleUrlRewritingTest extends DrupalWebTestCase {
|
|||
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
|
||||
|
||||
// Enable URL language detection and selection.
|
||||
$edit = array('language[enabled][locale-url]' => 1);
|
||||
$edit = array('language_interface[enabled][locale-url]' => 1);
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
|
||||
// Reset static caching.
|
||||
|
@ -2499,7 +2544,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
|
|||
language_save($language);
|
||||
|
||||
// Enable URL language detection and selection.
|
||||
$edit = array('language[enabled][locale-url]' => '1');
|
||||
$edit = array('language_interface[enabled][locale-url]' => '1');
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
|
||||
// Set "Basic page" content type to use multilingual support.
|
||||
|
@ -2629,7 +2674,7 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase {
|
|||
// language will fall back to the default language if no URL language can be
|
||||
// detected.
|
||||
$edit = array(
|
||||
'language[enabled][locale-user]' => TRUE,
|
||||
'language_interface[enabled][locale-user]' => TRUE,
|
||||
'language_content[enabled][locale-url]' => TRUE,
|
||||
'language_content[enabled][locale-interface]' => FALSE,
|
||||
);
|
||||
|
@ -2680,8 +2725,8 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase {
|
|||
->orderBy('cid', 'DESC')
|
||||
->execute()
|
||||
->fetchObject();
|
||||
$args = array('%node_language' => $node_langcode, '%comment_language' => $comment->language, '%langcode' => $langcode);
|
||||
$this->assertEqual($comment->language, $langcode, t('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
|
||||
$args = array('%node_language' => $node_langcode, '%comment_language' => $comment->langcode, '%langcode' => $langcode);
|
||||
$this->assertEqual($comment->langcode, $langcode, t('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2795,7 +2840,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
|
|||
variable_set('locale_test_content_language_type', TRUE);
|
||||
$this->languageNegotiationUpdate();
|
||||
$type = LANGUAGE_TYPE_CONTENT;
|
||||
$language_types = variable_get('language_types', drupal_language_types());
|
||||
$language_types = variable_get('language_types', language_types_get_default());
|
||||
$this->assertTrue($language_types[$type], t('Content language type is configurable.'));
|
||||
|
||||
// Enable some core and custom language providers. The test language type is
|
||||
|
@ -2821,7 +2866,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
|
|||
|
||||
// Check that type-specific language providers can be assigned only to the
|
||||
// corresponding language types.
|
||||
foreach (language_types_configurable() as $type) {
|
||||
foreach (language_types_get_configurable() as $type) {
|
||||
$form_field = $type . '[enabled][test_language_provider_ts]';
|
||||
if ($type == $test_type) {
|
||||
$this->assertFieldByXPath("//input[@name=\"$form_field\"]", NULL, t('Type-specific test language provider available for %type.', array('%type' => $type)));
|
||||
|
@ -2834,7 +2879,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
|
|||
// Check language negotiation results.
|
||||
$this->drupalGet('');
|
||||
$last = variable_get('locale_test_language_negotiation_last', array());
|
||||
foreach (language_types() as $type) {
|
||||
foreach (language_types_get_all() as $type) {
|
||||
$langcode = $last[$type];
|
||||
$value = $type == LANGUAGE_TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en';
|
||||
$this->assertEqual($langcode, $value, t('The negotiated language for %type is %language', array('%type' => $type, '%language' => $langcode)));
|
||||
|
@ -2845,7 +2890,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
|
|||
$this->languageNegotiationUpdate('disable');
|
||||
|
||||
// Check that only the core language types are available.
|
||||
foreach (language_types() as $type) {
|
||||
foreach (language_types_get_all() as $type) {
|
||||
$this->assertTrue(strpos($type, 'test') === FALSE, t('The %type language is still available', array('%type' => $type)));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ function locale_test_boot() {
|
|||
*/
|
||||
function locale_test_init() {
|
||||
locale_test_store_language_negotiation();
|
||||
if (isset($GLOBALS['language']) && isset($GLOBALS['language']->provider)) {
|
||||
drupal_set_message(t('Language negotiation provider: @name', array('@name' => $GLOBALS['language']->provider)));
|
||||
if (isset($GLOBALS['language_interface']) && isset($GLOBALS['language_interface']->provider)) {
|
||||
drupal_set_message(t('Language negotiation provider: @name', array('@name' => $GLOBALS['language_interface']->provider)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ function locale_test_language_negotiation_info_alter(array &$language_providers)
|
|||
*/
|
||||
function locale_test_store_language_negotiation() {
|
||||
$last = array();
|
||||
foreach (language_types() as $type) {
|
||||
foreach (language_types_get_all() as $type) {
|
||||
$last[$type] = $GLOBALS[$type]->langcode;
|
||||
}
|
||||
variable_set('locale_test_language_negotiation_last', $last);
|
||||
|
|
|
@ -682,7 +682,7 @@ function node_type_update_nodes($old_type, $type) {
|
|||
* type object by $type->disabled being set to TRUE.
|
||||
*/
|
||||
function _node_types_build($rebuild = FALSE) {
|
||||
$cid = 'node_types:' . $GLOBALS['language']->langcode;
|
||||
$cid = 'node_types:' . $GLOBALS['language_interface']->langcode;
|
||||
|
||||
if (!$rebuild) {
|
||||
$_node_types = &drupal_static(__FUNCTION__);
|
||||
|
|
|
@ -2240,10 +2240,10 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
|
|||
* Creates a node, then tests the tokens generated from it.
|
||||
*/
|
||||
function testNodeTokenReplacement() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
$url_options = array(
|
||||
'absolute' => TRUE,
|
||||
'language' => $language,
|
||||
'language' => $language_interface,
|
||||
);
|
||||
|
||||
// Create a user and a node.
|
||||
|
@ -2276,14 +2276,14 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
|
|||
$tests['[node:author]'] = check_plain(user_format_name($account));
|
||||
$tests['[node:author:uid]'] = $node->uid;
|
||||
$tests['[node:author:name]'] = check_plain(user_format_name($account));
|
||||
$tests['[node:created:since]'] = format_interval(REQUEST_TIME - $node->created, 2, $language->langcode);
|
||||
$tests['[node:changed:since]'] = format_interval(REQUEST_TIME - $node->changed, 2, $language->langcode);
|
||||
$tests['[node:created:since]'] = format_interval(REQUEST_TIME - $node->created, 2, $language_interface->langcode);
|
||||
$tests['[node:changed:since]'] = format_interval(REQUEST_TIME - $node->changed, 2, $language_interface->langcode);
|
||||
|
||||
// Test to make sure that we generated something for each token.
|
||||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('node' => $node), array('language' => $language));
|
||||
$output = token_replace($input, array('node' => $node), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Sanitized node token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
|
@ -2295,7 +2295,7 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
|
|||
$tests['[node:author:name]'] = user_format_name($account);
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('node' => $node), array('language' => $language, 'sanitize' => FALSE));
|
||||
$output = token_replace($input, array('node' => $node), array('language' => $language_interface, 'sanitize' => FALSE));
|
||||
$this->assertEqual($output, $expected, t('Unsanitized node token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,10 +83,10 @@ function openid_redirect_http($url, $message) {
|
|||
* Creates a js auto-submit redirect for (for the 2.x protocol)
|
||||
*/
|
||||
function openid_redirect($url, $message) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
$output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
|
||||
$output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $language->langcode . '" lang="' . $language->langcode . '">' . "\n";
|
||||
$output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $language_interface->langcode . '" lang="' . $language_interface->langcode . '">' . "\n";
|
||||
$output .= "<head>\n";
|
||||
$output .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
|
||||
$output .= "<title>" . t('OpenID redirect') . "</title>\n";
|
||||
|
|
|
@ -251,7 +251,7 @@ class PathLanguageTestCase extends DrupalWebTestCase {
|
|||
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
|
||||
|
||||
// Enable URL language detection and selection.
|
||||
$edit = array('language[enabled][locale-url]' => 1);
|
||||
$edit = array('language_interface[enabled][locale-url]' => 1);
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
}
|
||||
|
||||
|
@ -309,10 +309,10 @@ class PathLanguageTestCase extends DrupalWebTestCase {
|
|||
// Confirm that the alias works even when changing language negotiation
|
||||
// options. Enable User language detection and selection over URL one.
|
||||
$edit = array(
|
||||
'language[enabled][locale-user]' => 1,
|
||||
'language[weight][locale-user]' => -9,
|
||||
'language[enabled][locale-url]' => 1,
|
||||
'language[weight][locale-url]' => -8,
|
||||
'language_interface[enabled][locale-user]' => 1,
|
||||
'language_interface[weight][locale-user]' => -9,
|
||||
'language_interface[enabled][locale-url]' => 1,
|
||||
'language_interface[weight][locale-url]' => -8,
|
||||
);
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
|
||||
|
@ -336,7 +336,7 @@ class PathLanguageTestCase extends DrupalWebTestCase {
|
|||
$this->assertText($french_node->title, 'Alias for French translation works.');
|
||||
|
||||
// Disable URL language negotiation.
|
||||
$edit = array('language[enabled][locale-url]' => FALSE);
|
||||
$edit = array('language_interface[enabled][locale-url]' => FALSE);
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
|
||||
// Check that the English alias still works.
|
||||
|
@ -394,7 +394,7 @@ class PathLanguageUITestCase extends DrupalWebTestCase {
|
|||
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
|
||||
|
||||
// Enable URL language detection and selection.
|
||||
$edit = array('language[enabled][locale-url]' => 1);
|
||||
$edit = array('language_interface[enabled][locale-url]' => 1);
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
}
|
||||
|
||||
|
@ -457,7 +457,6 @@ class PathMonolingualTestCase extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
function setUp() {
|
||||
global $language;
|
||||
parent::setUp('path', 'locale', 'translation');
|
||||
|
||||
// Create and login user.
|
||||
|
@ -482,7 +481,7 @@ class PathMonolingualTestCase extends DrupalWebTestCase {
|
|||
$this->assertEqual(language_default()->langcode, 'fr', t('French is the default language'));
|
||||
|
||||
// Set language detection to URL.
|
||||
$edit = array('language[enabled][locale-url]' => TRUE);
|
||||
$edit = array('language_interface[enabled][locale-url]' => TRUE);
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
|
||||
// Force languages to be initialized.
|
||||
|
|
|
@ -633,7 +633,7 @@ class PollTokenReplaceTestCase extends PollTestCase {
|
|||
* Creates a poll, then tests the tokens generated from it.
|
||||
*/
|
||||
function testPollTokenReplacement() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// Craete a poll with three choices.
|
||||
$title = $this->randomName();
|
||||
|
@ -682,13 +682,13 @@ class PollTokenReplaceTestCase extends PollTestCase {
|
|||
$tests['[node:poll-winner]'] = filter_xss($poll->choice[1]['chtext']);
|
||||
$tests['[node:poll-winner-votes]'] = 2;
|
||||
$tests['[node:poll-winner-percent]'] = 50;
|
||||
$tests['[node:poll-duration]'] = format_interval($poll->runtime, 1, $language->langcode);
|
||||
$tests['[node:poll-duration]'] = format_interval($poll->runtime, 1, $language_interface->langcode);
|
||||
|
||||
// Test to make sure that we generated something for each token.
|
||||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('node' => $poll), array('language' => $language));
|
||||
$output = token_replace($input, array('node' => $poll), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Sanitized poll token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
|
@ -696,7 +696,7 @@ class PollTokenReplaceTestCase extends PollTestCase {
|
|||
$tests['[node:poll-winner]'] = $poll->choice[1]['chtext'];
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('node' => $poll), array('language' => $language, 'sanitize' => FALSE));
|
||||
$output = token_replace($input, array('node' => $poll), array('language' => $language_interface, 'sanitize' => FALSE));
|
||||
$this->assertEqual($output, $expected, t('Unsanitized poll token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,12 +104,12 @@ function template_preprocess_search_results(&$variables) {
|
|||
* @see search-result.tpl.php
|
||||
*/
|
||||
function template_preprocess_search_result(&$variables) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
$result = $variables['result'];
|
||||
$variables['url'] = check_url($result['link']);
|
||||
$variables['title'] = check_plain($result['title']);
|
||||
if (isset($result['language']) && $result['language'] != $language->langcode && $result['language'] != LANGUAGE_NONE) {
|
||||
if (isset($result['language']) && $result['language'] != $language_interface->langcode && $result['language'] != LANGUAGE_NONE) {
|
||||
$variables['title_attributes_array']['lang'] = $result['language'];
|
||||
$variables['content_attributes_array']['lang'] = $result['language'];
|
||||
}
|
||||
|
|
|
@ -1284,7 +1284,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
* either a single array or a variable number of string arguments.
|
||||
*/
|
||||
protected function setUp() {
|
||||
global $user, $language, $conf;
|
||||
global $user, $language_interface, $conf;
|
||||
|
||||
// Generate a temporary prefixed database to ensure that tests have a clean starting point.
|
||||
$this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000);
|
||||
|
@ -1308,7 +1308,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
Database::addConnectionInfo('default', 'default', $connection_info['default']);
|
||||
|
||||
// Store necessary current values before switching to prefixed database.
|
||||
$this->originalLanguage = $language;
|
||||
$this->originalLanguage = $language_interface;
|
||||
$this->originalLanguageDefault = variable_get('language_default');
|
||||
$this->originalConfigDirectory = $GLOBALS['config_directory_name'];
|
||||
$this->originalConfigSignatureKey = $GLOBALS['config_signature_key'];
|
||||
|
@ -1435,7 +1435,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
variable_set('date_default_timezone', date_default_timezone_get());
|
||||
// Set up English language.
|
||||
unset($GLOBALS['conf']['language_default']);
|
||||
$language = language_default();
|
||||
$language_interface = language_default();
|
||||
|
||||
// Use the test mail class instead of the default mail handler class.
|
||||
variable_set('mail_system', array('default-system' => 'TestingMailSystem'));
|
||||
|
@ -1529,7 +1529,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
* and reset the database prefix.
|
||||
*/
|
||||
protected function tearDown() {
|
||||
global $user, $language;
|
||||
global $user, $language_interface;
|
||||
|
||||
// In case a fatal error occurred that was not in the test process read the
|
||||
// log to pick up any fatal errors.
|
||||
|
@ -1583,7 +1583,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
$GLOBALS['config_signature_key'] = $this->originalConfigSignatureKey;
|
||||
|
||||
// Reset language.
|
||||
$language = $this->originalLanguage;
|
||||
$language_interface = $this->originalLanguage;
|
||||
if ($this->originalLanguageDefault) {
|
||||
$GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
|
||||
}
|
||||
|
|
|
@ -786,8 +786,8 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
|
|||
*/
|
||||
function testAlter() {
|
||||
// Switch the language to a right to left language and add system.base.css.
|
||||
global $language;
|
||||
$language->direction = LANGUAGE_RTL;
|
||||
global $language_interface;
|
||||
$language_interface->direction = LANGUAGE_RTL;
|
||||
$path = drupal_get_path('module', 'system');
|
||||
drupal_add_css($path . '/system.base.css');
|
||||
|
||||
|
@ -796,7 +796,7 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
|
|||
$this->assert(strpos($styles, $path . '/system.base-rtl.css') !== FALSE, t('CSS is alterable as right to left overrides are added.'));
|
||||
|
||||
// Change the language back to left to right.
|
||||
$language->direction = LANGUAGE_LTR;
|
||||
$language_interface->direction = LANGUAGE_LTR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -936,7 +936,7 @@ class CommonDrupalHTTPRequestTestCase extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('system_test');
|
||||
parent::setUp('system_test', 'locale');
|
||||
}
|
||||
|
||||
function testDrupalHTTPRequest() {
|
||||
|
@ -1033,6 +1033,26 @@ class CommonDrupalHTTPRequestTestCase extends DrupalWebTestCase {
|
|||
$multiple_redirect_3 = drupal_http_request(url('system-test/multiple-redirects/3', array('absolute' => TRUE)), array('max_redirects' => 3));
|
||||
$this->assertEqual($multiple_redirect_3->redirect_url, $multiple_redirect_final_url, t('redirect_url contains the final redirection location after 3 redirects.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Content-language headers generated by Drupal.
|
||||
*/
|
||||
function testDrupalHTTPRequestHeaders() {
|
||||
// Check the default header.
|
||||
$request = drupal_http_request(url('<front>', array('absolute' => TRUE)));
|
||||
$this->assertEqual($request->headers['content-language'], 'en', t('Content-Language HTTP header is English.'));
|
||||
|
||||
// Add French language.
|
||||
$language = (object) array(
|
||||
'langcode' => 'fr',
|
||||
'name' => 'French',
|
||||
);
|
||||
language_save($language);
|
||||
|
||||
// Request front page in French and check for matching Content-language.
|
||||
$request = drupal_http_request(url('<front>', array('absolute' => TRUE, 'language' => $language)));
|
||||
$this->assertEqual($request->headers['content-language'], 'fr', t('Content-Language HTTP header is French.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2352,7 +2372,7 @@ class CommonFormatDateTestCase extends DrupalWebTestCase {
|
|||
* Tests for the format_date() function.
|
||||
*/
|
||||
function testFormatDate() {
|
||||
global $user, $language;
|
||||
global $user, $language_interface;
|
||||
|
||||
$timestamp = strtotime('2007-03-26T00:00:00+00:00');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', t('Test all parameters.'));
|
||||
|
@ -2388,8 +2408,8 @@ class CommonFormatDateTestCase extends DrupalWebTestCase {
|
|||
// Save the original user and language and then replace it with the test user and language.
|
||||
$real_user = $user;
|
||||
$user = user_load($test_user->uid, TRUE);
|
||||
$real_language = $language->langcode;
|
||||
$language->langcode = $user->language;
|
||||
$real_language = $language_interface->langcode;
|
||||
$language_interface->langcode = $user->language;
|
||||
// Simulate a Drupal bootstrap with the logged-in user.
|
||||
date_default_timezone_set(drupal_get_user_timezone());
|
||||
|
||||
|
@ -2411,7 +2431,7 @@ class CommonFormatDateTestCase extends DrupalWebTestCase {
|
|||
|
||||
// Restore the original user and language, and enable session saving.
|
||||
$user = $real_user;
|
||||
$language->langcode = $real_language;
|
||||
$language_interface->langcode = $real_language;
|
||||
// Restore default time zone.
|
||||
date_default_timezone_set(drupal_get_user_timezone());
|
||||
drupal_save_session(TRUE);
|
||||
|
|
|
@ -32,10 +32,10 @@ class MailTestCase extends DrupalWebTestCase implements MailSystemInterface {
|
|||
* Assert that the pluggable mail system is functional.
|
||||
*/
|
||||
function testPluggableFramework() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// Use MailTestCase for sending a message.
|
||||
$message = drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language);
|
||||
$message = drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language_interface);
|
||||
|
||||
// Assert whether the message was sent through the send function.
|
||||
$this->assertEqual(self::$sent_message['to'], 'testing@example.com', t('Pluggable mail system is extendable.'));
|
||||
|
|
|
@ -28,9 +28,9 @@ db_insert('block')->fields(array(
|
|||
'module' => 'locale',
|
||||
'delta' => 'language',
|
||||
'theme' => 'bartik',
|
||||
'status' => '0',
|
||||
'status' => '1',
|
||||
'weight' => '0',
|
||||
'region' => '-1',
|
||||
'region' => 'sidebar_first',
|
||||
'custom' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
|
@ -524,3 +524,261 @@ db_update('system')->fields(array(
|
|||
->condition('type', 'module')
|
||||
->condition('name', 'locale')
|
||||
->execute();
|
||||
|
||||
// Add a sample node to test comments on.
|
||||
db_insert('node')->fields(array(
|
||||
'nid',
|
||||
'vid',
|
||||
'type',
|
||||
'language',
|
||||
'title',
|
||||
'uid',
|
||||
'status',
|
||||
'created',
|
||||
'changed',
|
||||
'comment',
|
||||
'promote',
|
||||
'sticky',
|
||||
'tnid',
|
||||
'translate',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '38',
|
||||
'vid' => '50',
|
||||
'type' => 'article',
|
||||
'language' => 'und',
|
||||
'title' => 'Node title 38',
|
||||
'uid' => '6',
|
||||
'status' => '1',
|
||||
'created' => '1263769200',
|
||||
'changed' => '1314997642',
|
||||
'comment' => '2',
|
||||
'promote' => '0',
|
||||
'sticky' => '0',
|
||||
'tnid' => '0',
|
||||
'translate' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
||||
// Add its node comment statistics.
|
||||
db_insert('node_comment_statistics')->fields(array(
|
||||
'nid',
|
||||
'cid',
|
||||
'last_comment_timestamp',
|
||||
'last_comment_name',
|
||||
'last_comment_uid',
|
||||
'comment_count',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '38',
|
||||
'cid' => '0',
|
||||
'last_comment_timestamp' => '1314997642',
|
||||
'last_comment_name' => NULL,
|
||||
'last_comment_uid' => '6',
|
||||
'comment_count' => '1',
|
||||
))
|
||||
->execute();
|
||||
|
||||
// Add node revision information.
|
||||
db_insert('node_revision')->fields(array(
|
||||
'nid',
|
||||
'vid',
|
||||
'uid',
|
||||
'title',
|
||||
'log',
|
||||
'timestamp',
|
||||
'status',
|
||||
'comment',
|
||||
'promote',
|
||||
'sticky',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '38',
|
||||
'vid' => '50',
|
||||
'uid' => '6',
|
||||
'title' => 'Node title 38',
|
||||
'log' => 'added a node to comment on',
|
||||
'timestamp' => '1314997642',
|
||||
'status' => '1',
|
||||
'comment' => '2',
|
||||
'promote' => '0',
|
||||
'sticky' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
||||
// Add the body field value.
|
||||
db_insert('field_data_body')->fields(array(
|
||||
'entity_type',
|
||||
'bundle',
|
||||
'deleted',
|
||||
'entity_id',
|
||||
'revision_id',
|
||||
'language',
|
||||
'delta',
|
||||
'body_value',
|
||||
'body_summary',
|
||||
'body_format',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '38',
|
||||
'revision_id' => '50',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'body_value' => 'Node body',
|
||||
'body_summary' => 'Node body',
|
||||
'body_format' => 'filtered_html',
|
||||
))
|
||||
->execute();
|
||||
|
||||
// Add revision information for the body field value.
|
||||
db_insert('field_revision_body')->fields(array(
|
||||
'entity_type',
|
||||
'bundle',
|
||||
'deleted',
|
||||
'entity_id',
|
||||
'revision_id',
|
||||
'language',
|
||||
'delta',
|
||||
'body_value',
|
||||
'body_summary',
|
||||
'body_format',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '38',
|
||||
'revision_id' => '50',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'body_value' => 'Node body',
|
||||
'body_summary' => 'Node body',
|
||||
'body_format' => 'filtered_html',
|
||||
))
|
||||
->execute();
|
||||
|
||||
// Add two comments to this node in a thread.
|
||||
db_insert('comment')->fields(array(
|
||||
'cid',
|
||||
'pid',
|
||||
'nid',
|
||||
'uid',
|
||||
'subject',
|
||||
'hostname',
|
||||
'created',
|
||||
'changed',
|
||||
'status',
|
||||
'thread',
|
||||
'name',
|
||||
'mail',
|
||||
'homepage',
|
||||
'language',
|
||||
))
|
||||
->values(array(
|
||||
'cid' => '1',
|
||||
'pid' => '0',
|
||||
'nid' => '38',
|
||||
'uid' => '6',
|
||||
'subject' => 'First test comment',
|
||||
'hostname' => '127.0.0.1',
|
||||
'created' => '1314997642',
|
||||
'changed' => '1314997642',
|
||||
'status' => '1',
|
||||
'thread' => '01/',
|
||||
'name' => 'test user 4',
|
||||
'mail' => '',
|
||||
'homepage' => '',
|
||||
'language' => 'und',
|
||||
))
|
||||
->values(array(
|
||||
'cid' => '2',
|
||||
'pid' => '0',
|
||||
'nid' => '38',
|
||||
'uid' => '6',
|
||||
'subject' => 'Reply to first test comment',
|
||||
'hostname' => '127.0.0.1',
|
||||
'created' => '1314997642',
|
||||
'changed' => '1314997642',
|
||||
'status' => '1',
|
||||
'thread' => '01.00/',
|
||||
'name' => 'test user 4',
|
||||
'mail' => '',
|
||||
'homepage' => '',
|
||||
'language' => 'und',
|
||||
))
|
||||
->execute();
|
||||
|
||||
// Add both comment bodies.
|
||||
db_insert('field_data_comment_body')->fields(array(
|
||||
'entity_type',
|
||||
'bundle',
|
||||
'deleted',
|
||||
'entity_id',
|
||||
'revision_id',
|
||||
'language',
|
||||
'delta',
|
||||
'comment_body_value',
|
||||
'comment_body_format',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'comment_body_value' => 'Comment body',
|
||||
'comment_body_format' => 'filtered_html',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '2',
|
||||
'revision_id' => '2',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'comment_body_value' => 'Second comment body',
|
||||
'comment_body_format' => 'filtered_html',
|
||||
))
|
||||
->execute();
|
||||
|
||||
// Add revisions for comment bodies.
|
||||
db_insert('field_revision_comment_body')->fields(array(
|
||||
'entity_type',
|
||||
'bundle',
|
||||
'deleted',
|
||||
'entity_id',
|
||||
'revision_id',
|
||||
'language',
|
||||
'delta',
|
||||
'comment_body_value',
|
||||
'comment_body_format',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'comment_body_value' => 'Comment body',
|
||||
'comment_body_format' => 'filtered_html',
|
||||
))
|
||||
->values(array(
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_article',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '2',
|
||||
'revision_id' => '2',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'comment_body_value' => 'Second comment body',
|
||||
'comment_body_format' => 'filtered_html',
|
||||
))
|
||||
->execute();
|
||||
|
|
|
@ -41,6 +41,21 @@ class LanguageUpgradePathTestCase extends UpgradePathTestCase {
|
|||
$this->assertTrue($language->default == ($language->langcode == 'ca'), t('@language default property properly set', array('@language' => $language->name)));
|
||||
}
|
||||
|
||||
// Check that both comments display on the node.
|
||||
$this->drupalGet('node/38');
|
||||
$this->assertText('Node title 38', t('Node 38 displayed after update.'));
|
||||
$this->assertText('First test comment', t('Comment 1 displayed after update.'));
|
||||
$this->assertText('Reply to first test comment', t('Comment 2 displayed after update.'));
|
||||
|
||||
// Directly check the comment language property on the first comment.
|
||||
$comment = db_query('SELECT * FROM {comment} WHERE cid = :cid', array(':cid' => 1))->fetchObject();
|
||||
$this->assertTrue($comment->langcode == 'und', t('Comment 1 language code found.'));
|
||||
|
||||
// Ensure that the language switcher has been correctly upgraded. We need to
|
||||
// assert the expected HTML id because the block might appear even if the
|
||||
// language negotiation settings are not properly upgraded.
|
||||
$this->assertTrue($this->xpath('//div[@id="block-locale-language-interface"]'), t('The language switcher block is being correctly showed.'));
|
||||
|
||||
// Check for node content type settings upgrade.
|
||||
$this->drupalGet('node/add/article');
|
||||
$this->assertFieldByName('language');
|
||||
|
|
|
@ -43,7 +43,7 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
|
|||
* Override of DrupalWebTestCase::setUp() specialized for upgrade testing.
|
||||
*/
|
||||
protected function setUp() {
|
||||
global $user, $language, $conf;
|
||||
global $user, $language_interface, $conf;
|
||||
|
||||
// Load the Update API.
|
||||
require_once DRUPAL_ROOT . '/core/includes/update.inc';
|
||||
|
@ -72,7 +72,7 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
|
|||
Database::addConnectionInfo('default', 'default', $connection_info['default']);
|
||||
|
||||
// Store necessary current values before switching to prefixed database.
|
||||
$this->originalLanguage = $language;
|
||||
$this->originalLanguage = $language_interface;
|
||||
$this->originalLanguageDefault = variable_get('language_default');
|
||||
$this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
|
||||
$this->originalProfile = drupal_get_profile();
|
||||
|
@ -147,7 +147,7 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
|
|||
* Override of DrupalWebTestCase::tearDown() specialized for upgrade testing.
|
||||
*/
|
||||
protected function tearDown() {
|
||||
global $user, $language;
|
||||
global $user, $language_interface;
|
||||
|
||||
// In case a fatal error occurred that was not in the test process read the
|
||||
// log to pick up any fatal errors.
|
||||
|
@ -186,7 +186,7 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
|
|||
parent::refreshVariables();
|
||||
|
||||
// Reset language.
|
||||
$language = $this->originalLanguage;
|
||||
$language_interface = $this->originalLanguage;
|
||||
if ($this->originalLanguageDefault) {
|
||||
$GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
|
||||
}
|
||||
|
|
|
@ -439,7 +439,7 @@ class StatisticsTokenReplaceTestCase extends StatisticsTestCase {
|
|||
* Creates a node, then tests the statistics tokens generated from it.
|
||||
*/
|
||||
function testStatisticsTokenReplacement() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// Create user and node.
|
||||
$user = $this->drupalCreateUser(array('create page content'));
|
||||
|
@ -461,7 +461,7 @@ class StatisticsTokenReplaceTestCase extends StatisticsTestCase {
|
|||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('node' => $node), array('language' => $language));
|
||||
$output = token_replace($input, array('node' => $node), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Statistics token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
?>
|
||||
|
||||
<div id="page">
|
||||
<header id="header" role="banner">
|
||||
<header id="header" role="banner" class="clearfix">
|
||||
|
||||
<?php if ($logo): ?>
|
||||
<a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
|
||||
|
|
|
@ -428,15 +428,13 @@ function system_theme_settings($form, &$form_state, $key = '') {
|
|||
$form['logo'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Logo image settings'),
|
||||
'#description' => t('If toggled on, the following logo will be displayed.'),
|
||||
'#attributes' => array('class' => array('theme-settings-bottom')),
|
||||
);
|
||||
$form['logo']['default_logo'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use the default logo'),
|
||||
'#title' => t('Use the default logo supplied by the theme'),
|
||||
'#default_value' => theme_get_setting('default_logo', $key),
|
||||
'#tree' => FALSE,
|
||||
'#description' => t('Check here if you want the theme to use the logo supplied with it.')
|
||||
);
|
||||
$form['logo']['settings'] = array(
|
||||
'#type' => 'container',
|
||||
|
@ -447,17 +445,10 @@ function system_theme_settings($form, &$form_state, $key = '') {
|
|||
),
|
||||
),
|
||||
);
|
||||
$logo_path = theme_get_setting('logo_path', $key);
|
||||
// If $logo_path is a public:// URI, display the path relative to the files
|
||||
// directory; stream wrappers are not end-user friendly.
|
||||
if (file_uri_scheme($logo_path) == 'public') {
|
||||
$logo_path = file_uri_target($logo_path);
|
||||
}
|
||||
$form['logo']['settings']['logo_path'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Path to custom logo'),
|
||||
'#default_value' => $logo_path,
|
||||
'#description' => t('The path to the file you would like to use as your logo file instead of the default logo.'),
|
||||
'#default_value' => theme_get_setting('logo_path', $key),
|
||||
);
|
||||
$form['logo']['settings']['logo_upload'] = array(
|
||||
'#type' => 'file',
|
||||
|
@ -475,9 +466,8 @@ function system_theme_settings($form, &$form_state, $key = '') {
|
|||
);
|
||||
$form['favicon']['default_favicon'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use the default shortcut icon.'),
|
||||
'#title' => t('Use the default shortcut icon supplied by the theme'),
|
||||
'#default_value' => theme_get_setting('default_favicon', $key),
|
||||
'#description' => t('Check here if you want the theme to use the default shortcut icon.')
|
||||
);
|
||||
$form['favicon']['settings'] = array(
|
||||
'#type' => 'container',
|
||||
|
@ -488,17 +478,10 @@ function system_theme_settings($form, &$form_state, $key = '') {
|
|||
),
|
||||
),
|
||||
);
|
||||
$favicon_path = theme_get_setting('favicon_path', $key);
|
||||
// If $favicon_path is a public:// URI, display the path relative to the
|
||||
// files directory; stream wrappers are not end-user friendly.
|
||||
if (file_uri_scheme($favicon_path) == 'public') {
|
||||
$favicon_path = file_uri_target($favicon_path);
|
||||
}
|
||||
$form['favicon']['settings']['favicon_path'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Path to custom icon'),
|
||||
'#default_value' => $favicon_path,
|
||||
'#description' => t('The path to the image file you would like to use as your custom shortcut icon.')
|
||||
'#default_value' => theme_get_setting('favicon_path', $key),
|
||||
);
|
||||
$form['favicon']['settings']['favicon_upload'] = array(
|
||||
'#type' => 'file',
|
||||
|
@ -507,6 +490,40 @@ function system_theme_settings($form, &$form_state, $key = '') {
|
|||
);
|
||||
}
|
||||
|
||||
// Inject human-friendly values and form element descriptions for logo and
|
||||
// favicon.
|
||||
foreach (array('logo' => 'logo.png', 'favicon' => 'favicon.ico') as $type => $default) {
|
||||
if (isset($form[$type]['settings'][$type . '_path'])) {
|
||||
$element = &$form[$type]['settings'][$type . '_path'];
|
||||
|
||||
// If path is a public:// URI, display the path relative to the files
|
||||
// directory; stream wrappers are not end-user friendly.
|
||||
$original_path = $element['#default_value'];
|
||||
$friendly_path = NULL;
|
||||
if (file_uri_scheme($original_path) == 'public') {
|
||||
$friendly_path = file_uri_target($original_path);
|
||||
$element['#default_value'] = $friendly_path;
|
||||
}
|
||||
|
||||
// Prepare local file path for description.
|
||||
if ($original_path && isset($friendly_path)) {
|
||||
$local_file = strtr($original_path, array('public:/' => variable_get('file_public_path', conf_path() . '/files')));
|
||||
}
|
||||
elseif ($key) {
|
||||
$local_file = drupal_get_path('theme', $key) . '/' . $default;
|
||||
}
|
||||
else {
|
||||
$local_file = path_to_theme() . '/' . $default;
|
||||
}
|
||||
|
||||
$element['#description'] = t('Examples: <code>@implicit-public-file</code> (for a file in the public filesystem), <code>@explicit-file</code>, or <code>@local-file</code>.', array(
|
||||
'@implicit-public-file' => isset($friendly_path) ? $friendly_path : $default,
|
||||
'@explicit-file' => file_uri_scheme($original_path) !== FALSE ? $original_path : 'public://' . $default,
|
||||
'@local-file' => $local_file,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if ($key) {
|
||||
// Call engine-specific settings.
|
||||
$function = $themes[$key]->prefix . '_engine_settings';
|
||||
|
@ -634,13 +651,20 @@ function system_theme_settings_validate($form, &$form_state) {
|
|||
* the path could not be validated.
|
||||
*/
|
||||
function _system_theme_settings_validate_path($path) {
|
||||
if (drupal_realpath($path)) {
|
||||
// The path is relative to the Drupal root, or is a valid URI.
|
||||
// Absolute local file paths are invalid.
|
||||
if (drupal_realpath($path) == $path) {
|
||||
return FALSE;
|
||||
}
|
||||
// A path relative to the Drupal root or a fully qualified URI is valid.
|
||||
if (is_file($path)) {
|
||||
return $path;
|
||||
}
|
||||
$uri = 'public://' . $path;
|
||||
if (file_exists($uri)) {
|
||||
return $uri;
|
||||
// Prepend 'public://' for relative file paths within public filesystem.
|
||||
if (file_uri_scheme($path) === FALSE) {
|
||||
$path = 'public://' . $path;
|
||||
}
|
||||
if (is_file($path)) {
|
||||
return $path;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -1946,7 +1946,7 @@ function hook_xmlrpc_alter(&$methods) {
|
|||
* - message: The text of the message to be logged.
|
||||
*/
|
||||
function hook_watchdog(array $log_entry) {
|
||||
global $base_url, $language;
|
||||
global $base_url, $language_interface;
|
||||
|
||||
$severity_list = array(
|
||||
WATCHDOG_EMERGENCY => t('Emergency'),
|
||||
|
@ -1992,7 +1992,7 @@ function hook_watchdog(array $log_entry) {
|
|||
'@message' => strip_tags($log_entry['message']),
|
||||
));
|
||||
|
||||
drupal_mail('emaillog', 'entry', $to, $language, $params);
|
||||
drupal_mail('emaillog', 'entry', $to, $language_interface, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -96,19 +96,22 @@ Drupal.behaviors.copyFieldValue = {
|
|||
*/
|
||||
Drupal.behaviors.dateTime = {
|
||||
attach: function (context, settings) {
|
||||
for (var value in settings.dateTime) {
|
||||
var settings = settings.dateTime[value];
|
||||
var source = '#edit-' + value;
|
||||
for (var fieldName in settings.dateTime) {
|
||||
if (settings.dateTime.hasOwnProperty(fieldName)) {
|
||||
(function (fieldSettings, fieldName) {
|
||||
var source = '#edit-' + fieldName;
|
||||
var suffix = source + '-suffix';
|
||||
|
||||
// Attach keyup handler to custom format inputs.
|
||||
$('input' + source, context).once('date-time').keyup(function () {
|
||||
var input = $(this);
|
||||
var url = settings.lookup + (settings.lookup.match(/\?q=/) ? '&format=' : '?format=') + encodeURIComponent(input.val());
|
||||
var url = fieldSettings.lookup + (fieldSettings.lookup.match(/\?q=/) ? '&format=' : '?format=') + encodeURIComponent(input.val());
|
||||
$.getJSON(url, function (data) {
|
||||
$(suffix).empty().append(' ' + settings.text + ': <em>' + data + '</em>');
|
||||
$(suffix).empty().append(' ' + fieldSettings.text + ': <em>' + data + '</em>');
|
||||
});
|
||||
});
|
||||
})(settings.dateTime[fieldName], fieldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2037,6 +2037,10 @@ function system_block_info() {
|
|||
'info' => t('Main page content'),
|
||||
// Cached elsewhere.
|
||||
'cache' => DRUPAL_NO_CACHE,
|
||||
// Auto-enable in 'content' region by default, which always exists.
|
||||
// @see system_themes_page(), drupal_render_page()
|
||||
'region' => 'content',
|
||||
'status' => 1,
|
||||
);
|
||||
$blocks['powered-by'] = array(
|
||||
'info' => t('Powered by Drupal'),
|
||||
|
@ -2047,6 +2051,9 @@ function system_block_info() {
|
|||
'info' => t('System help'),
|
||||
'weight' => '5',
|
||||
'cache' => DRUPAL_NO_CACHE,
|
||||
// Auto-enable in 'help' region by default, if the theme defines one.
|
||||
'region' => 'help',
|
||||
'status' => 1,
|
||||
);
|
||||
// System-defined menu blocks.
|
||||
foreach (menu_list_system_menus() as $menu_name => $title) {
|
||||
|
|
|
@ -1587,6 +1587,8 @@ class SystemMainContentFallback extends DrupalWebTestCase {
|
|||
* Tests for the theme interface functionality.
|
||||
*/
|
||||
class SystemThemeFunctionalTest extends DrupalWebTestCase {
|
||||
protected $profile = 'testing';
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Theme interface functionality',
|
||||
|
@ -1596,7 +1598,9 @@ class SystemThemeFunctionalTest extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
parent::setUp(array('node', 'block'));
|
||||
|
||||
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
|
||||
|
||||
$this->admin_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer themes', 'bypass node access', 'administer blocks'));
|
||||
$this->drupalLogin($this->admin_user);
|
||||
|
@ -1609,26 +1613,127 @@ class SystemThemeFunctionalTest extends DrupalWebTestCase {
|
|||
function testThemeSettings() {
|
||||
// Specify a filesystem path to be used for the logo.
|
||||
$file = current($this->drupalGetTestFiles('image'));
|
||||
$fullpath = drupal_realpath($file->uri);
|
||||
$file_relative = strtr($file->uri, array('public:/' => variable_get('file_public_path', conf_path() . '/files')));
|
||||
$default_theme_path = 'core/themes/stark';
|
||||
|
||||
$supported_paths = array(
|
||||
// Raw stream wrapper URI.
|
||||
$file->uri => array(
|
||||
'form' => file_uri_target($file->uri),
|
||||
'src' => file_create_url($file->uri),
|
||||
),
|
||||
// Relative path within the public filesystem.
|
||||
file_uri_target($file->uri) => array(
|
||||
'form' => file_uri_target($file->uri),
|
||||
'src' => file_create_url($file->uri),
|
||||
),
|
||||
// Relative path to a public file.
|
||||
$file_relative => array(
|
||||
'form' => $file_relative,
|
||||
'src' => file_create_url($file->uri),
|
||||
),
|
||||
// Relative path to an arbitrary file.
|
||||
'core/misc/druplicon.png' => array(
|
||||
'form' => 'core/misc/druplicon.png',
|
||||
'src' => $GLOBALS['base_url'] . '/' . 'core/misc/druplicon.png',
|
||||
),
|
||||
// Relative path to a file in a theme.
|
||||
$default_theme_path . '/logo.png' => array(
|
||||
'form' => $default_theme_path . '/logo.png',
|
||||
'src' => $GLOBALS['base_url'] . '/' . $default_theme_path . '/logo.png',
|
||||
),
|
||||
);
|
||||
foreach ($supported_paths as $input => $expected) {
|
||||
$edit = array(
|
||||
'default_logo' => FALSE,
|
||||
'logo_path' => $fullpath,
|
||||
'logo_path' => $input,
|
||||
);
|
||||
$this->drupalPost('admin/appearance/settings', $edit, t('Save configuration'));
|
||||
$this->drupalGet('node');
|
||||
$this->assertRaw($fullpath, t('Logo path successfully changed.'));
|
||||
$this->assertNoText('The custom logo path is invalid.');
|
||||
$this->assertFieldByName('logo_path', $expected['form']);
|
||||
|
||||
// Verify logo path examples.
|
||||
$elements = $this->xpath('//div[contains(@class, :item)]/div[@class=:description]/code', array(
|
||||
':item' => 'form-item-logo-path',
|
||||
':description' => 'description',
|
||||
));
|
||||
// Expected default values (if all else fails).
|
||||
$implicit_public_file = 'logo.png';
|
||||
$explicit_file = 'public://logo.png';
|
||||
$local_file = $default_theme_path . '/logo.png';
|
||||
// Adjust for fully qualified stream wrapper URI in public filesystem.
|
||||
if (file_uri_scheme($input) == 'public') {
|
||||
$implicit_public_file = file_uri_target($input);
|
||||
$explicit_file = $input;
|
||||
$local_file = strtr($input, array('public:/' => variable_get('file_public_path', conf_path() . '/files')));
|
||||
}
|
||||
// Adjust for fully qualified stream wrapper URI elsewhere.
|
||||
elseif (file_uri_scheme($input) !== FALSE) {
|
||||
$explicit_file = $input;
|
||||
}
|
||||
// Adjust for relative path within public filesystem.
|
||||
elseif ($input == file_uri_target($file->uri)) {
|
||||
$implicit_public_file = $input;
|
||||
$explicit_file = 'public://' . $input;
|
||||
$local_file = variable_get('file_public_path', conf_path() . '/files') . '/' . $input;
|
||||
}
|
||||
$this->assertEqual((string) $elements[0], $implicit_public_file);
|
||||
$this->assertEqual((string) $elements[1], $explicit_file);
|
||||
$this->assertEqual((string) $elements[2], $local_file);
|
||||
|
||||
// Verify the actual 'src' attribute of the logo being output.
|
||||
$this->drupalGet('');
|
||||
$elements = $this->xpath('//*[@id=:id]/img', array(':id' => 'logo'));
|
||||
$this->assertEqual((string) $elements[0]['src'], $expected['src']);
|
||||
}
|
||||
|
||||
$unsupported_paths = array(
|
||||
// Stream wrapper URI to non-existing file.
|
||||
'public://whatever.png',
|
||||
'private://whatever.png',
|
||||
'temporary://whatever.png',
|
||||
// Bogus stream wrapper URIs.
|
||||
'public:/whatever.png',
|
||||
'://whatever.png',
|
||||
':whatever.png',
|
||||
'public://',
|
||||
// Relative path within the public filesystem to non-existing file.
|
||||
'whatever.png',
|
||||
// Relative path to non-existing file in public filesystem.
|
||||
variable_get('file_public_path', conf_path() . '/files') . '/whatever.png',
|
||||
// Semi-absolute path to non-existing file in public filesystem.
|
||||
'/' . variable_get('file_public_path', conf_path() . '/files') . '/whatever.png',
|
||||
// Relative path to arbitrary non-existing file.
|
||||
'core/misc/whatever.png',
|
||||
// Semi-absolute path to arbitrary non-existing file.
|
||||
'/core/misc/whatever.png',
|
||||
// Absolute paths to any local file (even if it exists).
|
||||
drupal_realpath($file->uri),
|
||||
);
|
||||
$this->drupalGet('admin/appearance/settings');
|
||||
foreach ($unsupported_paths as $path) {
|
||||
$edit = array(
|
||||
'default_logo' => FALSE,
|
||||
'logo_path' => $path,
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save configuration'));
|
||||
$this->assertText('The custom logo path is invalid.');
|
||||
}
|
||||
|
||||
// Upload a file to use for the logo.
|
||||
$file = current($this->drupalGetTestFiles('image'));
|
||||
$edit = array(
|
||||
'default_logo' => FALSE,
|
||||
'logo_path' => '',
|
||||
'files[logo_upload]' => drupal_realpath($file->uri),
|
||||
);
|
||||
$options = array();
|
||||
$this->drupalPost('admin/appearance/settings', $edit, t('Save configuration'), $options);
|
||||
$this->drupalGet('node');
|
||||
$this->assertRaw($file->name, t('Logo file successfully uploaded.'));
|
||||
$this->drupalPost('admin/appearance/settings', $edit, t('Save configuration'));
|
||||
|
||||
$fields = $this->xpath($this->constructFieldXpath('name', 'logo_path'));
|
||||
$uploaded_filename = 'public://' . $fields[0]['value'];
|
||||
|
||||
$this->drupalGet('');
|
||||
$elements = $this->xpath('//*[@id=:id]/img', array(':id' => 'logo'));
|
||||
$this->assertEqual($elements[0]['src'], file_create_url($uploaded_filename));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1687,20 +1792,20 @@ class SystemThemeFunctionalTest extends DrupalWebTestCase {
|
|||
* Test switching the default theme.
|
||||
*/
|
||||
function testSwitchDefaultTheme() {
|
||||
// Enable "stark" and set it as the default theme.
|
||||
theme_enable(array('stark'));
|
||||
// Enable Bartik and set it as the default theme.
|
||||
theme_enable(array('bartik'));
|
||||
$this->drupalGet('admin/appearance');
|
||||
$this->clickLink(t('Set default'), 1);
|
||||
$this->assertTrue(variable_get('theme_default', '') == 'stark', t('Site default theme switched successfully.'));
|
||||
$this->clickLink(t('Set default'));
|
||||
$this->assertEqual(variable_get('theme_default', ''), 'bartik');
|
||||
|
||||
// Test the default theme on the secondary links (blocks admin page).
|
||||
$this->drupalGet('admin/structure/block');
|
||||
$this->assertText('Stark(' . t('active tab') . ')', t('Default local task on blocks admin page is the default theme.'));
|
||||
// Switch back to Bartik and test again to test that the menu cache is cleared.
|
||||
$this->assertText('Bartik(' . t('active tab') . ')', t('Default local task on blocks admin page is the default theme.'));
|
||||
// Switch back to Stark and test again to test that the menu cache is cleared.
|
||||
$this->drupalGet('admin/appearance');
|
||||
$this->clickLink(t('Set default'), 0);
|
||||
$this->drupalGet('admin/structure/block');
|
||||
$this->assertText('Bartik(' . t('active tab') . ')', t('Default local task on blocks admin page has changed.'));
|
||||
$this->assertText('Stark(' . t('active tab') . ')', t('Default local task on blocks admin page has changed.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1816,7 +1921,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
|
|||
$account = $this->drupalCreateUser();
|
||||
$node = $this->drupalCreateNode(array('uid' => $account->uid));
|
||||
$node->title = '<blink>Blinking Text</blink>';
|
||||
global $user, $language;
|
||||
global $user, $language_interface;
|
||||
|
||||
$source = '[node:title]'; // Title of the node we passed in
|
||||
$source .= '[node:author:name]'; // Node author's name
|
||||
|
@ -1828,18 +1933,18 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
|
|||
|
||||
$target = check_plain($node->title);
|
||||
$target .= check_plain($account->name);
|
||||
$target .= format_interval(REQUEST_TIME - $node->created, 2, $language->langcode);
|
||||
$target .= format_interval(REQUEST_TIME - $node->created, 2, $language_interface->langcode);
|
||||
$target .= check_plain($user->name);
|
||||
$target .= format_date(REQUEST_TIME, 'short', '', NULL, $language->langcode);
|
||||
$target .= format_date(REQUEST_TIME, 'short', '', NULL, $language_interface->langcode);
|
||||
|
||||
// Test that the clear parameter cleans out non-existent tokens.
|
||||
$result = token_replace($source, array('node' => $node), array('language' => $language, 'clear' => TRUE));
|
||||
$result = token_replace($source, array('node' => $node), array('language' => $language_interface, 'clear' => TRUE));
|
||||
$result = $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens cleared out.');
|
||||
|
||||
// Test without using the clear parameter (non-existent token untouched).
|
||||
$target .= '[user:name]';
|
||||
$target .= '[bogus:token]';
|
||||
$result = token_replace($source, array('node' => $node), array('language' => $language));
|
||||
$result = token_replace($source, array('node' => $node), array('language' => $language_interface));
|
||||
$this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.');
|
||||
|
||||
// Check that the results of token_generate are sanitized properly. This does NOT
|
||||
|
@ -1861,7 +1966,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
|
|||
* Test whether token-replacement works in various contexts.
|
||||
*/
|
||||
function testSystemTokenRecognition() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// Generate prefixes and suffixes for the token context.
|
||||
$tests = array(
|
||||
|
@ -1881,7 +1986,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
|
|||
foreach ($tests as $test) {
|
||||
$input = $test['prefix'] . '[site:name]' . $test['suffix'];
|
||||
$expected = $test['prefix'] . 'Drupal' . $test['suffix'];
|
||||
$output = token_replace($input, array(), array('language' => $language));
|
||||
$output = token_replace($input, array(), array('language' => $language_interface));
|
||||
$this->assertTrue($output == $expected, t('Token recognized in string %string', array('%string' => $input)));
|
||||
}
|
||||
}
|
||||
|
@ -1890,10 +1995,10 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
|
|||
* Tests the generation of all system site information tokens.
|
||||
*/
|
||||
function testSystemSiteTokenReplacement() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
$url_options = array(
|
||||
'absolute' => TRUE,
|
||||
'language' => $language,
|
||||
'language' => $language_interface,
|
||||
);
|
||||
|
||||
// Set a few site variables.
|
||||
|
@ -1913,7 +2018,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
|
|||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array(), array('language' => $language));
|
||||
$output = token_replace($input, array(), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Sanitized system site information token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
|
@ -1922,7 +2027,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
|
|||
$tests['[site:slogan]'] = variable_get('site_slogan', '');
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array(), array('language' => $language, 'sanitize' => FALSE));
|
||||
$output = token_replace($input, array(), array('language' => $language_interface, 'sanitize' => FALSE));
|
||||
$this->assertEqual($output, $expected, t('Unsanitized system site information token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
}
|
||||
|
@ -1931,25 +2036,25 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
|
|||
* Tests the generation of all system date tokens.
|
||||
*/
|
||||
function testSystemDateTokenReplacement() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// Set time to one hour before request.
|
||||
$date = REQUEST_TIME - 3600;
|
||||
|
||||
// Generate and test tokens.
|
||||
$tests = array();
|
||||
$tests['[date:short]'] = format_date($date, 'short', '', NULL, $language->langcode);
|
||||
$tests['[date:medium]'] = format_date($date, 'medium', '', NULL, $language->langcode);
|
||||
$tests['[date:long]'] = format_date($date, 'long', '', NULL, $language->langcode);
|
||||
$tests['[date:custom:m/j/Y]'] = format_date($date, 'custom', 'm/j/Y', NULL, $language->langcode);
|
||||
$tests['[date:since]'] = format_interval((REQUEST_TIME - $date), 2, $language->langcode);
|
||||
$tests['[date:short]'] = format_date($date, 'short', '', NULL, $language_interface->langcode);
|
||||
$tests['[date:medium]'] = format_date($date, 'medium', '', NULL, $language_interface->langcode);
|
||||
$tests['[date:long]'] = format_date($date, 'long', '', NULL, $language_interface->langcode);
|
||||
$tests['[date:custom:m/j/Y]'] = format_date($date, 'custom', 'm/j/Y', NULL, $language_interface->langcode);
|
||||
$tests['[date:since]'] = format_interval((REQUEST_TIME - $date), 2, $language_interface->langcode);
|
||||
$tests['[date:raw]'] = filter_xss($date);
|
||||
|
||||
// Test to make sure that we generated something for each token.
|
||||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('date' => $date), array('language' => $language));
|
||||
$output = token_replace($input, array('date' => $date), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Date token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
}
|
||||
|
@ -2579,7 +2684,6 @@ class SystemIndexPhpTest extends DrupalWebTestCase {
|
|||
$this->assertResponse(404, t("Make sure index.php/user returns a 'page not found'."));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uuid.inc and related functions.
|
||||
*/
|
||||
|
|
|
@ -1565,7 +1565,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
|
|||
* Creates some terms and a node, then tests the tokens generated from them.
|
||||
*/
|
||||
function testTaxonomyTokenReplacement() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
// Create two taxonomy terms.
|
||||
$term1 = $this->createTerm($this->vocabulary);
|
||||
|
@ -1594,7 +1594,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
|
|||
$tests['[term:vocabulary:name]'] = check_plain($this->vocabulary->name);
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('term' => $term1), array('language' => $language));
|
||||
$output = token_replace($input, array('term' => $term1), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
|
@ -1614,7 +1614,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
|
|||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('term' => $term2), array('language' => $language));
|
||||
$output = token_replace($input, array('term' => $term2), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
|
@ -1625,7 +1625,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
|
|||
$tests['[term:vocabulary:name]'] = $this->vocabulary->name;
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('term' => $term2), array('language' => $language, 'sanitize' => FALSE));
|
||||
$output = token_replace($input, array('term' => $term2), array('language' => $language_interface, 'sanitize' => FALSE));
|
||||
$this->assertEqual($output, $expected, t('Unsanitized taxonomy term token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
|
@ -1641,7 +1641,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
|
|||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('vocabulary' => $this->vocabulary), array('language' => $language));
|
||||
$output = token_replace($input, array('vocabulary' => $this->vocabulary), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
|
@ -1650,7 +1650,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
|
|||
$tests['[vocabulary:description]'] = $this->vocabulary->description;
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('vocabulary' => $this->vocabulary), array('language' => $language, 'sanitize' => FALSE));
|
||||
$output = token_replace($input, array('vocabulary' => $this->vocabulary), array('language' => $language_interface, 'sanitize' => FALSE));
|
||||
$this->assertEqual($output, $expected, t('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update, and uninstall functions for tracker.module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Enables tracking of recent content for users.
|
||||
* Tracks recent content posted by a user or users.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -70,6 +70,11 @@ function tracker_menu() {
|
|||
|
||||
/**
|
||||
* Implements hook_cron().
|
||||
*
|
||||
* Updates tracking information for any items still to be tracked. The variable
|
||||
* 'tracker_index_nid' is set to ((the last node ID that was indexed) - 1) and
|
||||
* used to select the nodes to be processed. If there are no remaining nodes to
|
||||
* process, 'tracker_index_nid' will be 0.
|
||||
*/
|
||||
function tracker_cron() {
|
||||
$max_nid = variable_get('tracker_index_nid', 0);
|
||||
|
@ -148,7 +153,16 @@ function tracker_cron() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Access callback for tracker/%user_uid_optional.
|
||||
* Access callback: Determines access permission for a user's own account.
|
||||
*
|
||||
* @param int $account
|
||||
* The account ID to check.
|
||||
*
|
||||
* @return boolean
|
||||
* TRUE if a user is accessing tracking info for their own account and
|
||||
* has permission to access the content.
|
||||
*
|
||||
* @see tracker_menu()
|
||||
*/
|
||||
function _tracker_myrecent_access($account) {
|
||||
// This path is only allowed for authenticated users looking at their own content.
|
||||
|
@ -156,7 +170,16 @@ function _tracker_myrecent_access($account) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Access callback for user/%user/track.
|
||||
* Access callback: Determines access permission for an account.
|
||||
*
|
||||
* @param int $account
|
||||
* The user account ID to track.
|
||||
*
|
||||
* @return boolean
|
||||
* TRUE if a user has permission to access the account for $account and
|
||||
* has permission to access the content.
|
||||
*
|
||||
* @see tracker_menu()
|
||||
*/
|
||||
function _tracker_user_access($account) {
|
||||
return user_view_access($account) && user_access('access content');
|
||||
|
@ -164,6 +187,8 @@ function _tracker_user_access($account) {
|
|||
|
||||
/**
|
||||
* Implements hook_node_insert().
|
||||
*
|
||||
* Adds new tracking information for this node since it's new.
|
||||
*/
|
||||
function tracker_node_insert($node, $arg = 0) {
|
||||
_tracker_add($node->nid, $node->uid, $node->changed);
|
||||
|
@ -171,6 +196,8 @@ function tracker_node_insert($node, $arg = 0) {
|
|||
|
||||
/**
|
||||
* Implements hook_node_update().
|
||||
*
|
||||
* Adds tracking information for this node since it's been updated.
|
||||
*/
|
||||
function tracker_node_update($node, $arg = 0) {
|
||||
_tracker_add($node->nid, $node->uid, $node->changed);
|
||||
|
@ -178,6 +205,8 @@ function tracker_node_update($node, $arg = 0) {
|
|||
|
||||
/**
|
||||
* Implements hook_node_predelete().
|
||||
*
|
||||
* Deletes tracking information for a node.
|
||||
*/
|
||||
function tracker_node_predelete($node, $arg = 0) {
|
||||
db_delete('tracker_node')
|
||||
|
@ -196,7 +225,7 @@ function tracker_node_predelete($node, $arg = 0) {
|
|||
*/
|
||||
function tracker_comment_update($comment) {
|
||||
// comment_save() calls hook_comment_publish() for all published comments
|
||||
// so we to handle all other values here.
|
||||
// so we need to handle all other values here.
|
||||
if ($comment->status != COMMENT_PUBLISHED) {
|
||||
_tracker_remove($comment->nid, $comment->uid, $comment->changed);
|
||||
}
|
||||
|
@ -227,7 +256,7 @@ function tracker_comment_delete($comment) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Update indexing tables when a node is added, updated or commented on.
|
||||
* Updates indexing tables when a node is added, updated, or commented on.
|
||||
*
|
||||
* @param $nid
|
||||
* A node ID.
|
||||
|
@ -266,7 +295,7 @@ function _tracker_add($nid, $uid, $changed) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Determine the max timestamp between $node->changed and the last comment.
|
||||
* Determines the max timestamp between $node->changed and the last comment.
|
||||
*
|
||||
* @param $nid
|
||||
* A node ID.
|
||||
|
@ -288,7 +317,7 @@ function _tracker_calculate_changed($nid) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Clean up indexed data when nodes or comments are removed.
|
||||
* Cleans up indexed data when nodes or comments are removed.
|
||||
*
|
||||
* @param $nid
|
||||
* The node ID.
|
||||
|
@ -311,7 +340,7 @@ function _tracker_remove($nid, $uid = NULL, $changed = NULL) {
|
|||
|
||||
// Comments are a second reason to keep the user's subscription.
|
||||
if (!$keep_subscription) {
|
||||
// Check if the user has commented at least once on the given nid
|
||||
// Check if the user has commented at least once on the given nid.
|
||||
$keep_subscription = db_query_range('SELECT COUNT(*) FROM {comment} WHERE nid = :nid AND uid = :uid AND status = :status', 0, 1, array(
|
||||
':nid' => $nid,
|
||||
':uid' => $uid,
|
||||
|
@ -329,9 +358,8 @@ function _tracker_remove($nid, $uid = NULL, $changed = NULL) {
|
|||
|
||||
// Now we need to update the (possibly) changed timestamps for other users
|
||||
// and the node itself.
|
||||
|
||||
// We only need to do this if the removed item has a timestamp that equals
|
||||
// or exceeds the listed changed timestamp for the node
|
||||
// or exceeds the listed changed timestamp for the node.
|
||||
$tracker_node = db_query('SELECT nid, changed FROM {tracker_node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject();
|
||||
if ($tracker_node && $changed >= $tracker_node->changed) {
|
||||
// If we're here, the item being removed is *possibly* the item that
|
||||
|
|
|
@ -2,12 +2,20 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* User page callbacks for the tracker module.
|
||||
* User page callbacks for tracker.module.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Menu callback; prints a listing of active nodes on the site.
|
||||
* Page callback: Generates a page of tracked nodes for the site.
|
||||
*
|
||||
* Queries the database for info, adds RDFa info if applicable, and generates
|
||||
* the render array that will be used to render the page.
|
||||
*
|
||||
* @return array
|
||||
* A renderable array.
|
||||
*
|
||||
* @see tracker_menu()
|
||||
*/
|
||||
function tracker_page($account = NULL, $set_title = FALSE) {
|
||||
if ($account) {
|
||||
|
@ -38,23 +46,23 @@ function tracker_page($account = NULL, $set_title = FALSE) {
|
|||
|
||||
$rows = array();
|
||||
if (!empty($nodes)) {
|
||||
// Now, get the data and put into the placeholder array
|
||||
// Now, get the data and put into the placeholder array.
|
||||
$result = db_query('SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid WHERE n.nid IN (:nids)', array(':nids' => array_keys($nodes)), array('target' => 'slave'));
|
||||
foreach ($result as $node) {
|
||||
$node->last_activity = $nodes[$node->nid]->changed;
|
||||
$nodes[$node->nid] = $node;
|
||||
}
|
||||
|
||||
// Finally display the data
|
||||
// Display the data.
|
||||
foreach ($nodes as $node) {
|
||||
// Determine the number of comments:
|
||||
// Determine the number of comments.
|
||||
$comments = 0;
|
||||
if ($node->comment_count) {
|
||||
$comments = $node->comment_count;
|
||||
|
||||
if ($new = comment_num_new($node->nid)) {
|
||||
$comments .= '<br />';
|
||||
$comments .= l(format_plural($new, '1 new', '@count new'), 'node/'. $node->nid, array('fragment' => 'new'));
|
||||
$comments .= l(format_plural($new, '1 new', '@count new'), 'node/' . $node->nid, array('fragment' => 'new'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +105,7 @@ function tracker_page($account = NULL, $set_title = FALSE) {
|
|||
$row['last updated'] += $mapping_last_activity;
|
||||
|
||||
// We need to add the about attribute on the tr tag to specify which
|
||||
// node the RDFa annoatations above apply to. We move the content of
|
||||
// node the RDFa annotations above apply to. We move the content of
|
||||
// $row to a 'data' sub array so we can specify attributes for the row.
|
||||
$row = array('data' => $row);
|
||||
$row['about'] = url('node/' . $node->nid);
|
||||
|
|
|
@ -5,8 +5,23 @@
|
|||
* Tests for tracker.module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Defines a base class for testing tracker.module.
|
||||
*/
|
||||
class TrackerTest extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* The main user for testing.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* A second user that will 'create' comments and nodes.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $other_user;
|
||||
|
||||
public static function getInfo() {
|
||||
|
@ -29,13 +44,13 @@ class TrackerTest extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test the presence of nodes on the global tracker listing.
|
||||
* Tests for the presence of nodes on the global tracker listing.
|
||||
*/
|
||||
function testTrackerAll() {
|
||||
$this->drupalLogin($this->user);
|
||||
|
||||
$unpublished = $this->drupalCreateNode(array(
|
||||
'title' =>$this->randomName(8),
|
||||
'title' => $this->randomName(8),
|
||||
'status' => 0,
|
||||
));
|
||||
$published = $this->drupalCreateNode(array(
|
||||
|
@ -55,7 +70,7 @@ class TrackerTest extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test the presence of nodes on a user's tracker listing.
|
||||
* Tests for the presence of nodes on a user's tracker listing.
|
||||
*/
|
||||
function testTrackerUser() {
|
||||
$this->drupalLogin($this->user);
|
||||
|
@ -101,7 +116,7 @@ class TrackerTest extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test the presence of the "new" flag for nodes.
|
||||
* Tests for the presence of the "new" flag for nodes.
|
||||
*/
|
||||
function testTrackerNewNodes() {
|
||||
$this->drupalLogin($this->user);
|
||||
|
@ -129,7 +144,7 @@ class TrackerTest extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test comment counters on the tracker listing.
|
||||
* Tests for comment counters on the tracker listing.
|
||||
*/
|
||||
function testTrackerNewComments() {
|
||||
$this->drupalLogin($this->user);
|
||||
|
@ -144,7 +159,8 @@ class TrackerTest extends DrupalWebTestCase {
|
|||
'subject' => $this->randomName(),
|
||||
'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
|
||||
);
|
||||
$this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save')); // The new comment is automatically viewed by the current user.
|
||||
// The new comment is automatically viewed by the current user.
|
||||
$this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save'));
|
||||
|
||||
$this->drupalLogin($this->other_user);
|
||||
$this->drupalGet('tracker');
|
||||
|
@ -157,7 +173,7 @@ class TrackerTest extends DrupalWebTestCase {
|
|||
'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
|
||||
);
|
||||
// If the comment is posted in the same second as the last one then Drupal
|
||||
// can't tell a difference, so wait one second here.
|
||||
// can't tell the difference, so we wait one second here.
|
||||
sleep(1);
|
||||
$this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save'));
|
||||
|
||||
|
@ -167,7 +183,7 @@ class TrackerTest extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that existing nodes are indexed by cron.
|
||||
* Tests that existing nodes are indexed by cron.
|
||||
*/
|
||||
function testTrackerCronIndexing() {
|
||||
$this->drupalLogin($this->user);
|
||||
|
@ -213,7 +229,6 @@ class TrackerTest extends DrupalWebTestCase {
|
|||
$this->assertText('1 new', t('New comment is counted on the tracker listing pages.'));
|
||||
$this->assertText('updated', t('Node is listed as updated'));
|
||||
|
||||
|
||||
// Fetch the site-wide tracker.
|
||||
$this->drupalGet('tracker');
|
||||
|
||||
|
@ -225,7 +240,7 @@ class TrackerTest extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that publish/unpublish works at admin/content/node
|
||||
* Tests that publish/unpublish works at admin/content/node.
|
||||
*/
|
||||
function testTrackerAdminUnpublish() {
|
||||
$admin_user = $this->drupalCreateUser(array('access content overview', 'administer nodes', 'bypass node access'));
|
||||
|
|
|
@ -179,7 +179,7 @@ class TranslationTestCase extends DrupalWebTestCase {
|
|||
// Check that content translation links are shown even when no language
|
||||
// negotiation is configured.
|
||||
$this->drupalLogin($this->admin_user);
|
||||
$edit = array('language[enabled][locale-url]' => FALSE);
|
||||
$edit = array('language_interface[enabled][locale-url]' => FALSE);
|
||||
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
$this->resetCaches();
|
||||
$edit = array('status' => TRUE);
|
||||
|
|
|
@ -2758,7 +2758,7 @@ Your account on [site:name] has been canceled.
|
|||
if ($replace) {
|
||||
// We do not sanitize the token replacement, since the output of this
|
||||
// replacement is intended for an e-mail message, not a web browser.
|
||||
return token_replace($text, $variables, array('language' => $language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE));
|
||||
return token_replace($text, $variables, array('language' => $language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
|
||||
}
|
||||
|
||||
return $text;
|
||||
|
|
|
@ -72,11 +72,11 @@ function user_pass_validate($form, &$form_state) {
|
|||
}
|
||||
|
||||
function user_pass_submit($form, &$form_state) {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
|
||||
$account = $form_state['values']['account'];
|
||||
// Mail one time login URL and instructions using current language.
|
||||
$mail = _user_mail_notify('password_reset', $account, $language);
|
||||
$mail = _user_mail_notify('password_reset', $account, $language_interface);
|
||||
if (!empty($mail)) {
|
||||
watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail));
|
||||
drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
|
||||
|
|
|
@ -1895,10 +1895,10 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
|
|||
* Creates a user, then tests the tokens generated from it.
|
||||
*/
|
||||
function testUserTokenReplacement() {
|
||||
global $language;
|
||||
global $language_interface;
|
||||
$url_options = array(
|
||||
'absolute' => TRUE,
|
||||
'language' => $language,
|
||||
'language' => $language_interface,
|
||||
);
|
||||
|
||||
// Create two users and log them in one after another.
|
||||
|
@ -1918,17 +1918,17 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
|
|||
$tests['[user:mail]'] = check_plain($account->mail);
|
||||
$tests['[user:url]'] = url("user/$account->uid", $url_options);
|
||||
$tests['[user:edit-url]'] = url("user/$account->uid/edit", $url_options);
|
||||
$tests['[user:last-login]'] = format_date($account->login, 'medium', '', NULL, $language->langcode);
|
||||
$tests['[user:last-login:short]'] = format_date($account->login, 'short', '', NULL, $language->langcode);
|
||||
$tests['[user:created]'] = format_date($account->created, 'medium', '', NULL, $language->langcode);
|
||||
$tests['[user:created:short]'] = format_date($account->created, 'short', '', NULL, $language->langcode);
|
||||
$tests['[user:last-login]'] = format_date($account->login, 'medium', '', NULL, $language_interface->langcode);
|
||||
$tests['[user:last-login:short]'] = format_date($account->login, 'short', '', NULL, $language_interface->langcode);
|
||||
$tests['[user:created]'] = format_date($account->created, 'medium', '', NULL, $language_interface->langcode);
|
||||
$tests['[user:created:short]'] = format_date($account->created, 'short', '', NULL, $language_interface->langcode);
|
||||
$tests['[current-user:name]'] = check_plain(user_format_name($global_account));
|
||||
|
||||
// Test to make sure that we generated something for each token.
|
||||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('user' => $account), array('language' => $language));
|
||||
$output = token_replace($input, array('user' => $account), array('language' => $language_interface));
|
||||
$this->assertEqual($output, $expected, t('Sanitized user token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
|
@ -1938,7 +1938,7 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
|
|||
$tests['[current-user:name]'] = user_format_name($global_account);
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('user' => $account), array('language' => $language, 'sanitize' => FALSE));
|
||||
$output = token_replace($input, array('user' => $account), array('language' => $language_interface, 'sanitize' => FALSE));
|
||||
$this->assertEqual($output, $expected, t('Unsanitized user token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -379,6 +379,10 @@ update_prepare_d8_bootstrap();
|
|||
// Determine if the current user has access to run update.php.
|
||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
|
||||
|
||||
// The interface language global has been renamed in D8, we must ensure that it
|
||||
// contains a valid value while language settings are upgraded.
|
||||
$GLOBALS[LANGUAGE_TYPE_INTERFACE] = language_default();
|
||||
|
||||
// Only allow the requirements check to proceed if the current user has access
|
||||
// to run updates (since it may expose sensitive information about the site's
|
||||
// configuration).
|
||||
|
|
Loading…
Reference in New Issue