Commit b5e33f62 authored by Crell's avatar Crell
Browse files

Merge branch '8.x' into dbtngtng

parents d3cf8901 b989d0cc
......@@ -1808,7 +1808,7 @@ function format_size($size, $langcode = NULL) {
/**
* Formats a time interval with the requested granularity.
*
* @param $timestamp
* @param $interval
* The length of the interval in seconds.
* @param $granularity
* How many different units to display in the string.
......@@ -1819,7 +1819,7 @@ function format_size($size, $langcode = NULL) {
* @return
* A translated string representation of the interval.
*/
function format_interval($timestamp, $granularity = 2, $langcode = NULL) {
function format_interval($interval, $granularity = 2, $langcode = NULL) {
$units = array(
'1 year|@count years' => 31536000,
'1 month|@count months' => 2592000,
......@@ -1832,9 +1832,9 @@ function format_interval($timestamp, $granularity = 2, $langcode = NULL) {
$output = '';
foreach ($units as $key => $value) {
$key = explode('|', $key);
if ($timestamp >= $value) {
$output .= ($output ? ' ' : '') . format_plural(floor($timestamp / $value), $key[0], $key[1], array(), array('langcode' => $langcode));
$timestamp %= $value;
if ($interval >= $value) {
$output .= ($output ? ' ' : '') . format_plural(floor($interval / $value), $key[0], $key[1], array(), array('langcode' => $langcode));
$interval %= $value;
$granularity--;
}
......
......@@ -98,7 +98,7 @@
* generate the same form (or very similar forms) using different $form_ids
* can implement hook_forms(), which maps different $form_id values to the
* proper form constructor function. Examples may be found in node_forms(),
* search_forms(), and user_forms().
* and search_forms().
* @param ...
* Any additional arguments are passed on to the functions called by
* drupal_get_form(), including the unique form constructor function. For
......@@ -136,7 +136,7 @@ function drupal_get_form($form_id) {
* generate the same form (or very similar forms) using different $form_ids
* can implement hook_forms(), which maps different $form_id values to the
* proper form constructor function. Examples may be found in node_forms(),
* search_forms(), and user_forms().
* and search_forms().
* @param $form_state
* An array which stores information about the form. This is passed as a
* reference so that the caller can use it to examine what in the form changed
......@@ -421,7 +421,7 @@ function form_state_defaults() {
* Modules that need to generate the same form (or very similar forms)
* using different $form_ids can implement hook_forms(), which maps
* different $form_id values to the proper form constructor function. Examples
* may be found in node_forms(), search_forms(), and user_forms().
* may be found in node_forms() and search_forms().
* @param $form_state
* A keyed array containing the current state of the form.
* @param $old_form
......@@ -627,7 +627,7 @@ function form_load_include(&$form_state, $type, $module, $name = NULL) {
* Modules that need to generate the same form (or very similar forms)
* using different $form_ids can implement hook_forms(), which maps
* different $form_id values to the proper form constructor function. Examples
* may be found in node_forms(), search_forms(), and user_forms().
* may be found in node_forms() and search_forms().
* @param $form_state
* A keyed array containing the current state of the form. Most important is
* the $form_state['values'] collection, a tree of data used to simulate the
......
......@@ -1543,7 +1543,7 @@ function theme_link($variables) {
* @param $variables
* An associative array containing:
* - links: An associative array of links to be themed. The key for each link
* is used as its css class. Each link should be itself an array, with the
* is used as its CSS class. Each link should be itself an array, with the
* following elements:
* - title: The link text.
* - href: The link URL. If omitted, the 'title' is shown as a plain text
......
......@@ -77,8 +77,13 @@
* Text with tokens replaced.
*/
function token_replace($text, array $data = array(), array $options = array()) {
$text_tokens = token_scan($text);
if (empty($text_tokens)) {
return $text;
}
$replacements = array();
foreach (token_scan($text) as $type => $tokens) {
foreach ($text_tokens as $type => $tokens) {
$replacements += token_generate($type, $tokens, $data, $options);
if (!empty($options['clear'])) {
$replacements += array_fill_keys($tokens, '');
......
......@@ -318,7 +318,7 @@ Drupal.ajax.prototype.beforeSerialize = function (element, options) {
Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) {
// This function is left empty to make it simple to override for modules
// that wish to add functionality here.
}
};
/**
* Prepare the Ajax request before it is sent.
......
......@@ -26,7 +26,7 @@ Drupal.behaviors.machineName = {
var $source = $(source_id, context).addClass('machine-name-source');
var $target = $(options.target, context).addClass('machine-name-target');
var $suffix = $(options.suffix, context);
var $wrapper = $target.parents('.form-item:first');
var $wrapper = $target.closest('.form-item');
// All elements have to exist.
if (!$source.length || !$target.length || !$suffix.length || !$wrapper.length) {
return;
......
......@@ -125,7 +125,7 @@ Drupal.tableDrag.prototype.initColumns = function () {
var field = $('.' + this.tableSettings[group][d].target + ':first', this.table);
if (field.size() && this.tableSettings[group][d].hidden) {
var hidden = this.tableSettings[group][d].hidden;
var cell = field.parents('td:first');
var cell = field.closest('td');
break;
}
}
......@@ -744,7 +744,7 @@ Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
switch (rowSettings.action) {
case 'depth':
// Get the depth of the target row.
targetElement.value = $('.indentation', $(sourceElement).parents('tr:first')).size();
targetElement.value = $('.indentation', $(sourceElement).closest('tr')).size();
break;
case 'match':
// Update the value.
......@@ -876,7 +876,7 @@ Drupal.tableDrag.prototype.row = function (tableRow, method, indentEnabled, maxD
this.group = [tableRow];
this.groupDepth = $('.indentation', tableRow).size();
this.changed = false;
this.table = $(tableRow).parents('table:first').get(0);
this.table = $(tableRow).closest('table').get(0);
this.indentEnabled = indentEnabled;
this.maxDepth = maxDepth;
this.direction = ''; // Direction the row is being moved.
......
......@@ -29,7 +29,7 @@ Drupal.tableSelect = function () {
checkboxes.each(function () {
this.checked = event.target.checked;
// Either add or remove the selected class based on the state of the check all checkbox.
$(this).parents('tr:first')[ this.checked ? 'addClass' : 'removeClass' ]('selected');
$(this).closest('tr').toggleClass('selected', this.checked);
});
// Update the title and the state of the check all box.
updateSelectAll(event.target.checked);
......@@ -39,14 +39,14 @@ Drupal.tableSelect = function () {
// For each of the checkboxes within the table that are not disabled.
checkboxes = $('td input:checkbox:enabled', table).click(function (e) {
// Either add or remove the selected class based on the state of the check all checkbox.
$(this).parents('tr:first')[ this.checked ? 'addClass' : 'removeClass' ]('selected');
$(this).closest('tr').toggleClass('selected', this.checked);
// If this is a shift click, we need to highlight everything in the range.
// Also make sure that we are actually checking checkboxes over a range and
// that a checkbox has been checked or unchecked before.
if (e.shiftKey && lastChecked && lastChecked != e.target) {
// We use the checkbox's parent TR to do our range searching.
Drupal.tableSelectRange($(e.target).parents('tr')[0], $(lastChecked).parents('tr')[0], e.target.checked);
Drupal.tableSelectRange($(e.target).closest('tr')[0], $(lastChecked).closest('tr')[0], e.target.checked);
}
// If all checkboxes are checked, make sure the select-all one is checked too, otherwise keep unchecked.
......
......@@ -266,6 +266,10 @@ EOF;
return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_atom.xml';
}
function getHtmlEntitiesSample() {
return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_title_entities.xml';
}
/**
* Creates sample article nodes.
*
......@@ -915,4 +919,15 @@ class FeedParserTestCase extends AggregatorTestCase {
$this->assertText('Some text.');
$this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', array(':link' => 'http://example.org/2003/12/13/atom03'))->fetchField(), 'Atom entry id element is parsed correctly.');
}
/**
* Tests a feed that uses HTML entities in item titles.
*/
function testHtmlEntitiesSample() {
$feed = $this->createFeed($this->getHtmlEntitiesSample());
aggregator_refresh($feed);
$this->drupalGet('aggregator/sources/' . $feed->fid);
$this->assertResponse(200, t('Feed %name exists.', array('%name' => $feed->title)));
$this->assertRaw("Quote" Amp&");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<rss version="0.91">
<channel>
<title>Example with Entities</title>
<link>http://example.com</link>
<description>Example RSS Feed With HTML Entities in Title</description>
<language>en-us</language>
<item>
<title>Quote&quot; Amp&amp;</title>
<link>http://example.com/example-turns-one</link>
<description>Some text.</description>
</item>
</channel>
</rss>
......@@ -113,7 +113,7 @@ Drupal.behaviors.blockDrag = {
$('select.block-region-select', context).once('block-region-select', function () {
$(this).change(function (event) {
// Make our new row and select field.
var row = $(this).parents('tr:first');
var row = $(this).closest('tr');
var select = $(this);
tableDrag.rowObject = new tableDrag.row(row);
......
......@@ -43,6 +43,6 @@
float: right;
right: -10px;
}
html.js #preview {
.js #preview {
float: right;
}
......@@ -78,7 +78,7 @@
#preview {
display: none;
}
html.js #preview {
.js #preview {
display: block;
position: relative;
float: left; /* LTR */
......
......@@ -51,28 +51,6 @@ function color_form_system_theme_settings_alter(&$form, &$form_state) {
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function color_form_system_themes_alter(&$form, &$form_state) {
_color_theme_select_form_alter($form, $form_state);
}
/**
* Helper for hook_form_FORM_ID_alter() implementations.
*/
function _color_theme_select_form_alter(&$form, &$form_state) {
// Use the generated screenshot in the theme list.
$themes = list_themes();
foreach (element_children($form) as $theme) {
if ($screenshot = variable_get('color_' . $theme . '_screenshot')) {
if (isset($form[$theme]['screenshot'])) {
$form[$theme]['screenshot']['#markup'] = theme('image', array('uri' => $screenshot, 'title' => '', 'attributes' => array('class' => array('screenshot'))));
}
}
}
}
/**
* Replaces style sheets with color-altered style sheets.
*
......
......@@ -1672,7 +1672,7 @@ function comment_forms() {
* @ingroup forms
*/
function comment_form($form, &$form_state, $comment) {
global $user;
global $user, $language_content;
// During initial form build, add the comment entity to the form state for
// use during form building and processing. During a rebuild, use what is in
......@@ -1833,11 +1833,22 @@ function comment_form($form, &$form_state, $comment) {
);
// Add internal comment properties.
foreach (array('cid', 'pid', 'nid', 'language', 'uid') as $key) {
foreach (array('cid', 'pid', 'nid', 'uid') as $key) {
$form[$key] = array('#type' => 'value', '#value' => $comment->$key);
}
$form['node_type'] = array('#type' => 'value', '#value' => 'comment_node_' . $node->type);
// 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;
if (($comment_langcode == LANGUAGE_NONE) && variable_get('language_content_type_' . $node->type, 0)) {
$comment_langcode = $language_content->langcode;
}
$form['language'] = array(
'#type' => 'value',
'#value' => $comment_langcode,
);
// Only show the save button if comment previews are optional or if we are
// already previewing the submission.
$form['actions'] = array('#type' => 'actions');
......
......@@ -25,7 +25,7 @@ div.contextual-links-wrapper {
top: 2px;
z-index: 999;
}
html.js div.contextual-links-wrapper {
.js div.contextual-links-wrapper {
display: block;
}
a.contextual-links-trigger {
......
......@@ -103,10 +103,9 @@ function field_schema() {
'active' => array('active'),
'storage_active' => array('storage_active'),
'deleted' => array('deleted'),
// Used by field_modules_disabled().
// Used by field_sync_field_status().
'module' => array('module'),
'storage_module' => array('storage_module'),
// Used by field_associate_fields().
'type' => array('type'),
'storage_type' => array('storage_type'),
),
......
......@@ -362,11 +362,12 @@ function field_theme() {
/**
* Implements hook_cron().
*
* Purges some deleted Field API data, if any exists.
*/
function field_cron() {
// Refresh the 'active' status of fields.
field_sync_field_status();
// Do a pass of purging on deleted Field API data, if any exists.
$limit = variable_get('field_purge_batch_size', 10);
field_purge_batch($limit);
}
......@@ -412,10 +413,29 @@ function field_system_info_alter(&$info, $file, $type) {
* Implements hook_flush_caches().
*/
function field_flush_caches() {
// Refresh the 'active' status of fields.
field_sync_field_status();
// Request a flush of our cache table.
return array('field');
}
/**
* Implements hook_modules_enabled().
*/
function field_modules_enabled($modules) {
// Refresh the 'active' status of fields.
field_sync_field_status();
}
/**
* Implements hook_modules_disabled().
*/
function field_modules_disabled($modules) {
// Refresh the 'active' status of fields.
field_sync_field_status();
}
/**
* Refreshes the 'active' and 'storage_active' columns for fields.
*/
......@@ -449,18 +469,18 @@ function field_sync_field_status() {
function field_associate_fields($module) {
// Associate field types.
$field_types = (array) module_invoke($module, 'field_info');
foreach ($field_types as $name => $field_info) {
if ($field_types) {
db_update('field_config')
->fields(array('module' => $module, 'active' => 1))
->condition('type', $name)
->condition('type', array_keys($field_types))
->execute();
}
// Associate storage backends.
$storage_types = (array) module_invoke($module, 'field_storage_info');
foreach ($storage_types as $name => $storage_info) {
if ($storage_types) {
db_update('field_config')
->fields(array('storage_module' => $module, 'storage_active' => 1))
->condition('storage_type', $name)
->condition('storage_type', array_keys($storage_types))
->execute();
}
}
......
......@@ -2357,7 +2357,6 @@ class FieldCrudTestCase extends FieldTestCase {
$this->assertTrue($field_definition <= $field, t('The field was properly read.'));
module_disable($modules, FALSE);
drupal_flush_all_caches();
$fields = field_read_fields(array('field_name' => $field_name), array('include_inactive' => TRUE));
$this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, t('The field is properly read when explicitly fetching inactive fields.'));
......@@ -2370,7 +2369,6 @@ class FieldCrudTestCase extends FieldTestCase {
$module = array_shift($modules);
module_enable(array($module), FALSE);
drupal_flush_all_caches();
}
// Check that the field is active again after all modules have been
......
......@@ -28,7 +28,7 @@ Drupal.fieldUIFieldOverview = {
// 'Field type' select updates its 'Widget' select.
$('.field-type-select', table).each(function () {
this.targetSelect = $('.widget-type-select', $(this).parents('tr').eq(0));
this.targetSelect = $('.widget-type-select', $(this).closest('tr'));
$(this).bind('change keyup', function () {
var selectedFieldType = this.options[this.selectedIndex].value;
......@@ -43,8 +43,8 @@ Drupal.fieldUIFieldOverview = {
// 'Existing field' select updates its 'Widget' select and 'Label' textfield.
$('.field-select', table).each(function () {
this.targetSelect = $('.widget-type-select', $(this).parents('tr').eq(0));
this.targetTextfield = $('.label-textfield', $(this).parents('tr').eq(0));
this.targetSelect = $('.widget-type-select', $(this).closest('tr'));
this.targetTextfield = $('.label-textfield', $(this).closest('tr'));
this.targetTextfield
.data('field_ui_edited', false)
.bind('keyup', function (e) {
......@@ -140,7 +140,7 @@ Drupal.fieldUIOverview = {
*/
onChange: function () {
var $trigger = $(this);
var row = $trigger.parents('tr:first').get(0);
var row = $trigger.closest('tr').get(0);
var rowHandler = $(row).data('fieldUIRowHandler');
var refreshRows = {};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment